Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation on adding diagnostic output. #331

Merged
merged 26 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
158b443
Fix nt_zbgc_frac
dabail10 Feb 18, 2020
93c6ab4
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Feb 20, 2020
8f3263d
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Feb 24, 2020
776316e
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Apr 2, 2020
a2219bf
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Apr 6, 2020
2abbfa7
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Apr 22, 2020
9bb6df7
Merge branch 'master' of https://github.com/ESCOMP/Icepack
dabail10 Apr 22, 2020
b72c0bc
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 May 15, 2020
1f0195e
Merge branch 'master' of https://github.com/ESCOMP/Icepack
dabail10 May 15, 2020
78c0aef
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 May 29, 2020
6a603cd
Merge branch 'master' of https://github.com/ESCOMP/Icepack
dabail10 May 29, 2020
d353104
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Jun 10, 2020
d9273f1
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Jun 24, 2020
2ec16b0
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Jul 6, 2020
a40bbf9
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Jul 13, 2020
faa181f
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Jul 16, 2020
a2950cc
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack
dabail10 Jul 24, 2020
e920664
New developer guide module on adding diagnostics
dabail10 Jul 28, 2020
641b354
Merge branch 'master' of https://github.com/CICE-Consortium/Icepack i…
dabail10 Dec 14, 2020
a12e4a9
More on adding diagnostics
dabail10 Dec 14, 2020
a7f961a
test
dabail10 Dec 14, 2020
88d35ce
fix errors
dabail10 Dec 14, 2020
616a69a
Fix version of bibtex
dabail10 Dec 14, 2020
9b6238a
Fix version of bibtex
dabail10 Dec 14, 2020
dde8c27
Merge branch 'master' of git+ssh://github.com/CICE-Consortium/Icepack…
dabail10 Mar 18, 2021
25a2793
Update documentation for diagnostics
dabail10 Mar 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions doc/source/developer_guide/dg_adding_diagnostics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
:tocdepth: 3

.. _adddiag:

Adding diagnostics
==================

Icepack produces separate ASCII (text) log output for four cells, each with a different initial condition (full ITD, slab ice, ice free, land) designated by the variable ``n`` here. Each of the diagnostic files contains the state information for that cell. The procedure for adding diagnostic variables to the output is outlined here.

#. For non-BGC variables, edit **icedrv\_diagnostics.F90**:

- If the variable is already defined within the code, then add it to a "use" statement in the subroutine
``runtime_diags``.

- Note that if the variable is not readily accessible through a use statement, then a global variable may need to
be defined. This might be in **icedrv\_state.F90** or **icedrv\_flux.F90** for example.

- Additionally, if the variable is a derived quantity, then the variables needed to calculate the new quantity
may need to be added to a use statement. For example, see how ``hiavg`` and ``hsavg`` are computed.

- If the variable is a scalar, then follow the example of ``aice`` or ``hiavg``, copying the write statement to
an appropriate place in the output list, and editing as needed. The format "900" is appropriate for most scalars.
The following example adds snow melt (``melts``).

.. code-block:: fortran

use icedrv_flux, only: melts

write(nu_diag_out+n-1,900) 'snow melt (m) = ',melts(n) ! snow melt

- If the variable is an array, then you can compute the mean value (e.g. ``hiavg``) or print the array values (e.g. ``fiso_evap``).
This may requires adding the array sizes and a counter for the loop(s). E.g. to print
the category ice area, ``aicen`` over ncat thickness categories:

.. code-block:: fortran

use icedrv_domain_size, only: ncat

use icedrv_state, only: aicen

! local variables

integer (kind=int_kind) :: &
n, nc, k

do nc = 1,ncat
write(nu_diag_out+n-1,901) 'Category ice area = ',aicen(n,nc),nc ! category ice area
enddo

- If the variable is a tracer, then in addition to the variable trcr or trcrn, you will need the tracer
index (e.g. ``nt_Tsfc``).

- In some cases, a new format statement might be needed.

#. For BGC variables, edit **icedrv\_diagnostics\_bgc.F90**:

- If the variable is already defined within the code, then add it to a "use" statement in the subroutine
``hbrine_diags`` or ``bgc_diags`` or ``zsal_diags`` and follow a similar procedure for state variables as above.

- Note that the BGC needs to be activated and the particular tracer turned on.

In general, try to format the output statements to line up with the surrounding print messages. This may require a couple of tries to get it to compile and run.

1 change: 1 addition & 0 deletions doc/source/developer_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ Developer Guide
dg_driver.rst
dg_scripts.rst
dg_adding_tracers.rst
dg_adding_diagnostics.rst
dg_other.rst
6 changes: 3 additions & 3 deletions doc/source/science_guide/sg_thermo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,9 @@ Climate System Model (CCSM3), the albedo depends on the temperature and
thickness of ice and snow and on the spectral distribution of the
incoming solar radiation. Albedo parameters have been chosen to fit
observations from the SHEBA field experiment. For
:math:`T_{sf} < -1^{\circ}C` and :math:`h_i > `\ ``ahmax``, the bare ice
albedo is 0.78 for visible wavelengths (:math:`<700`\ nm) and 0.36 for
near IR wavelengths (:math:`>700`\ nm). As :math:`h_i` decreases from
:math:`T_{sf} < -1^{\circ}C` and :math:`h_i >` \ `ahmax`, the bare ice
albedo is 0.78 for visible wavelengths (:math:`<700` \ nm) and 0.36 for
near IR wavelengths (:math:`>700` \ nm). As :math:`h_i` decreases from
ahmax to zero, the ice albedo decreases smoothly (using an arctangent
function) to the ocean albedo, 0.06. The ice albedo in both spectral
bands decreases by 0.075 as :math:`T_{sf}` rises from
Expand Down