From 158b4433b804bc40db40deb335bb9f33eaff5b7e Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 18 Feb 2020 13:59:40 -0700 Subject: [PATCH 1/5] Fix nt_zbgc_frac --- configuration/driver/icedrv_init_column.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/driver/icedrv_init_column.F90 b/configuration/driver/icedrv_init_column.F90 index c708189f8..977d04fb2 100644 --- a/configuration/driver/icedrv_init_column.F90 +++ b/configuration/driver/icedrv_init_column.F90 @@ -1311,6 +1311,7 @@ subroutine init_zbgc nt_bgc_DMS = 0 nt_bgc_PON = 0 nt_bgc_hum = 0 + nt_zbgc_frac = 0 !----------------------------------------------------------------- ! Define array parameters @@ -1700,7 +1701,6 @@ subroutine init_zbgc endif ! tr_zaero !echmod keep trcr indices etc here but move zbgc_frac_init, zbgc_init_frac, tau_ret, tau_rel to icepack - nt_zbgc_frac = 0 if (nbtrcr > 0) then nt_zbgc_frac = ntrcr + 1 ntrcr = ntrcr + nbtrcr From e920664dbfe063fb03e169bee9f110ef8b5b495f Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 28 Jul 2020 15:44:15 -0600 Subject: [PATCH 2/5] New developer guide module on adding diagnostics --- .../developer_guide/dg_adding_diagnostics.rst | 57 +++++++++++++++++++ doc/source/developer_guide/index.rst | 1 + 2 files changed, 58 insertions(+) create mode 100755 doc/source/developer_guide/dg_adding_diagnostics.rst diff --git a/doc/source/developer_guide/dg_adding_diagnostics.rst b/doc/source/developer_guide/dg_adding_diagnostics.rst new file mode 100755 index 000000000..f0b381ca9 --- /dev/null +++ b/doc/source/developer_guide/dg_adding_diagnostics.rst @@ -0,0 +1,57 @@ +:tocdepth: 3 + +.. _adddiag: + +Adding diagnostics +================== + +Icepack only produces ASCII (text) log output for four points (full model with ITD, an initially ice free point, a land point, and a case with a slab ocean). Each of these files contains the state information for that point. Sometimes additional variables are required in this output. The procedure for adding diagnostic variables is outlined here. + +#. For non-BGC variables, one should 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``. + + - If the variable is just a scalar, then follow the example of "aice". Copy the write statement for Qa to + a place in the output list where it is most appropriate. The format "900" is appropriate for most scalars. + Edit the copied statement to be the variable you want. The following example adds snow-melt (melts). + + .. code-block:: fortran + + use icedrv_flux, only: melts + + write(nu_diag_out+n-1,900) 'snow melt = ',melts(n)! snow melt + + - If the variable is an array, say depending on ncat, then follow the example of fiso_evap. This just requires + adding a loop for the print statement. Make sure ncat and a counter, nc are available. Say for example, + the category ice area, aicen. + + .. 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 to have the tracer + index available. Here, you can look at the example of nt_Tsfc. + + - In some cases, a new format statement might be required if 900 or 901 are not correct. + +#. For BGC variables, one should 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``. The similar procedure for state variables is used here. + + - Note that the BGC needs to be activited 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. + diff --git a/doc/source/developer_guide/index.rst b/doc/source/developer_guide/index.rst index 31757e2a6..8206dbd3d 100755 --- a/doc/source/developer_guide/index.rst +++ b/doc/source/developer_guide/index.rst @@ -16,4 +16,5 @@ Developer Guide dg_driver.rst dg_scripts.rst dg_adding_tracers.rst + dg_adding_diagnostics.rst dg_other.rst From 259f102dfcf1d8c05602c8eabfc8245b02a48a9e Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 19 Aug 2020 12:21:54 -0600 Subject: [PATCH 3/5] Updating to master --- .../developer_guide/dg_adding_diagnostics.rst | 57 ------------------- doc/source/developer_guide/index.rst | 1 - 2 files changed, 58 deletions(-) delete mode 100755 doc/source/developer_guide/dg_adding_diagnostics.rst diff --git a/doc/source/developer_guide/dg_adding_diagnostics.rst b/doc/source/developer_guide/dg_adding_diagnostics.rst deleted file mode 100755 index f0b381ca9..000000000 --- a/doc/source/developer_guide/dg_adding_diagnostics.rst +++ /dev/null @@ -1,57 +0,0 @@ -:tocdepth: 3 - -.. _adddiag: - -Adding diagnostics -================== - -Icepack only produces ASCII (text) log output for four points (full model with ITD, an initially ice free point, a land point, and a case with a slab ocean). Each of these files contains the state information for that point. Sometimes additional variables are required in this output. The procedure for adding diagnostic variables is outlined here. - -#. For non-BGC variables, one should 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``. - - - If the variable is just a scalar, then follow the example of "aice". Copy the write statement for Qa to - a place in the output list where it is most appropriate. The format "900" is appropriate for most scalars. - Edit the copied statement to be the variable you want. The following example adds snow-melt (melts). - - .. code-block:: fortran - - use icedrv_flux, only: melts - - write(nu_diag_out+n-1,900) 'snow melt = ',melts(n)! snow melt - - - If the variable is an array, say depending on ncat, then follow the example of fiso_evap. This just requires - adding a loop for the print statement. Make sure ncat and a counter, nc are available. Say for example, - the category ice area, aicen. - - .. 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 to have the tracer - index available. Here, you can look at the example of nt_Tsfc. - - - In some cases, a new format statement might be required if 900 or 901 are not correct. - -#. For BGC variables, one should 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``. The similar procedure for state variables is used here. - - - Note that the BGC needs to be activited 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. - diff --git a/doc/source/developer_guide/index.rst b/doc/source/developer_guide/index.rst index 8206dbd3d..31757e2a6 100755 --- a/doc/source/developer_guide/index.rst +++ b/doc/source/developer_guide/index.rst @@ -16,5 +16,4 @@ Developer Guide dg_driver.rst dg_scripts.rst dg_adding_tracers.rst - dg_adding_diagnostics.rst dg_other.rst From 0a33d12deb455028b0987da8160fac150586165c Mon Sep 17 00:00:00 2001 From: David Bailey Date: Wed, 19 Aug 2020 16:41:01 -0600 Subject: [PATCH 4/5] Bug fix for hbnew calculation --- columnphysics/icepack_therm_itd.F90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/columnphysics/icepack_therm_itd.F90 b/columnphysics/icepack_therm_itd.F90 index 4f773a14e..57728c881 100644 --- a/columnphysics/icepack_therm_itd.F90 +++ b/columnphysics/icepack_therm_itd.F90 @@ -145,6 +145,7 @@ subroutine linear_itd (ncat, hin_max, & real (kind=dbl_kind) :: & slope , & ! rate of change of dhice with hice + denom , & ! denominator in hbnew calculation dh0 , & ! change in ice thickness at h = 0 da0 , & ! area melting from category 1 damax , & ! max allowed reduction in category 1 area @@ -307,8 +308,8 @@ subroutine linear_itd (ncat, hin_max, & if (hicen_init(n) > puny .and. & hicen_init(n+1) > puny) then ! interpolate between adjacent category growth rates - slope = (dhicen(n+1) - dhicen(n)) / & - (hicen_init(n+1) - hicen_init(n)) + denom = max(puny,hicen_init(n+1) - hicen_init(n)) + slope = (dhicen(n+1) - dhicen(n)) / denom hbnew(n) = hin_max(n) + dhicen(n) & + slope * (hin_max(n) - hicen_init(n)) elseif (hicen_init(n) > puny) then ! hicen_init(n+1)=0 From 2b92358473b5a9eb04c62a286840d2cf07c7bae1 Mon Sep 17 00:00:00 2001 From: David Bailey Date: Thu, 20 Aug 2020 09:54:19 -0600 Subject: [PATCH 5/5] add units to comment --- columnphysics/icepack_therm_itd.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/columnphysics/icepack_therm_itd.F90 b/columnphysics/icepack_therm_itd.F90 index 57728c881..9c48b4e48 100644 --- a/columnphysics/icepack_therm_itd.F90 +++ b/columnphysics/icepack_therm_itd.F90 @@ -145,7 +145,7 @@ subroutine linear_itd (ncat, hin_max, & real (kind=dbl_kind) :: & slope , & ! rate of change of dhice with hice - denom , & ! denominator in hbnew calculation + denom , & ! denominator in hbnew calculation (m) dh0 , & ! change in ice thickness at h = 0 da0 , & ! area melting from category 1 damax , & ! max allowed reduction in category 1 area