From bf2c83f3d6f9c45bdaf7132b74fbddaeadfafccb Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Thu, 7 Jul 2022 12:23:09 -0400 Subject: [PATCH 01/15] Change dumbbell initialization --- .DS_Store | Bin 0 -> 6148 bytes src/.DS_Store | Bin 0 -> 8196 bytes .../MOM_state_initialization.F90 | 2 +- src/user/dumbbell_initialization.F90 | 74 ++++++++++++++++-- 4 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 .DS_Store create mode 100644 src/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..967887c2aff4da305da78dd97e26ae40dcba8b4e GIT binary patch literal 6148 zcmeHKL5tHs6n>LNH|Zkupr8j~z-w6>#fo^zcDsiK^{^2=sMMsXHEcFhns$3Ah1~VO zc=m_rfAOU6&Aft5>q!tP^We?*X6Ah_ov&mj0|25oPXmA!0C?zxZWEgwM)Txb=J1G* zD5yq~s{~^zcFc1YtO8bn|5pKecO8gfc$TYS?fpIasZIa*CJaGA0UscPF$|!D=@#b; zX8z7`Aw|v*%FWv1ZY{3~&)^JB;1pg!gzXVrLR#Z|s&N`HfeRSdvVPREd^pE?$Iyr8 zyX!jR8l$mmWzM(VS;?ZDux4MANuHInPUpLD8t%302cG90dheo-Y7x!i*}Uw<(>K(6 zsZ^e<<2ZShjTVE}%@bA3;;a}=H6cq!nDX{@R-|gtQ}ZG%H8(O7p6~mE)}7_@LHBW6 z22X-jTP}mn!$)n|4Z5q9@7=n0|LOVQBEKvY35OLG4Ckz=YgL>=0MqdFCT^!biF@63MM>2+tl|h_A z6NZXtsDiH;!q9PCa$d+-88mbdeEAUkWWhHSp`VWRrA`MC8nmrdz$&n*K*MxfbpD_I z`ToC2vOTMSRba0a5Ng2H+b2D}E%C`QFgHtrq-Pe$~h5@#~m-C-xwaV9Zf2;{EM z;466cLG)cb=~vyoF*At^B8swI&{h3YUw6+}#dLZ?M4~+oJ)#{Va!}aTs!(f$$GNP? zhUvKoD}X223t}0dRa^139hL#hfMvikU>UFs{2L75%w}1l+NxIvl)3`ImeH*Qb@k&P*5wY^ma%hf(E|}03ag>QTrq^XI|vQOc+2?DwbgJE zYGur0Ru<-lBFxo8xXPVGOIxcg1D1hR2Keq?qFs7K`w!#X{e2fB*S{%Iurl>XQcC@T z-^YSql|qWhr$b8MpV0`d9%XryxLQDMQ=eYb7&!Kqz;>Yzpm_%FEvzfv6=tZwJB8-} zGfmV^j|*#lT|w~9`f80M*q9FTh>gPn;sW-Tpzt1j_($~i$Bqlw&%c5VCfU$@JNXn0 z<0u<78ehalseEp8%W<5l^Rja!C!LW$8fR@kea@{XQpUka-4C8d{YkfW>48i}ew6f6 z1&G2vTwXkjl2A_Ca-4*j!gln4Q>j$CwJX!<&E}oD>)rEab$9ADZr!fCO|LndRh-M$ zZrp#|J&p&7WWpiByn*SwZZGtE)J`SnO(#uanJ}q52fi06`h6AbP!Z`P7(POtf!aZy zP$VhQhoywvrXhS!LXHGMJr|H-(h;ZX@(h~@B;z>=()?;FL6?2YNX~4HAG5O7@6?cP z{lSnrCZryR^lsyKL%MkI+H4h%<5EM^Xz=eyC| ppt] real :: S_light, S_dense ! The lightest and densest salinities in the sponges [S ~> ppt]. real :: eta_IC_quanta ! The granularity of quantization of intial interface heights [Z-1 ~> m-1]. + logical :: dbrotate ! If true, rotate the domain. + logical :: use_ALE ! True if ALE is being used, False if in layered mode + ! This include declares and sets the variable "version". # include "version_variable.h" character(len=20) :: verticalCoordinate integer :: i, j, k, is, ie, js, je, nz + real :: x, y is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke @@ -128,6 +132,8 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, units='m', default=1.0e-3, scale=US%m_to_Z, do_not_log=just_read) call get_param(param_file, mdl,"REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) + call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) + if(.not. use_ALE) verticalCoordinate = "LAYER" ! WARNING: this routine specifies the interface heights so that the last layer ! is vanished, even at maximum depth. In order to have a uniform @@ -141,8 +147,38 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, !enddo select case ( coordinateMode(verticalCoordinate) ) - - case ( REGRIDDING_LAYER, REGRIDDING_RHO ) ! Initial thicknesses for isopycnal coordinates + case ( REGRIDDING_LAYER) ! Initial thicknesses for isopycnal coordinates + call get_param(param_file, mdl, "DUMBBELL_ROTATION", dbrotate, & + 'Logical for rotation of dumbbell domain.',& + units='nondim', default=.false., do_not_log=just_read) + do j=js,je + do i=is,ie + ! Compute normalized zonal coordinates (x,y=0 at center of domain) + if (dbrotate) then + ! This is really y in the rotated case + x = G%geoLatT(i,j) + else + x = G%geoLonT(i,j) + endif + + eta1D(1) = 0.0 + eta1D(nz+1) = -depth_tot(i,j) + if (x<0.0) then + do k=nz,2, -1 + eta1D(k) = eta1D(k+1) + min_thickness + enddo + else + do k=2,nz + eta1D(k) = eta1D(k-1) - min_thickness + enddo + endif + + do k=1,nz + h(i,j,k) = GV%Z_to_H * (eta1D(k) - eta1D(k+1)) + enddo + enddo; enddo + + case ( REGRIDDING_RHO, REGRIDDING_HYCOM1) ! Initial thicknesses for isopycnal coordinates call get_param(param_file, mdl, "INITIAL_SSS", S_surf, & units='1e-3', default=34., scale=US%ppt_to_S, do_not_log=.true.) call get_param(param_file, mdl, "INITIAL_S_RANGE", S_range, & @@ -231,12 +267,18 @@ subroutine dumbbell_initialize_temperature_salinity ( T, S, h, G, GV, US, param_ real :: x ! The fractional position in the domain [nondim] real :: dblen ! The size of the dumbbell test case [axis_units] logical :: dbrotate ! If true, rotate the domain. + logical :: use_ALE ! If false, use layer mode. character(len=20) :: verticalCoordinate, density_profile is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke T_surf = 20.0*US%degC_to_C + ! layer mode + call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) + if(.not. use_ALE) call MOM_error(FATAL, "dumbbell_initialize_temperature_salinity: "//& + "Please use 'fit' for 'TS_CONFIG' in the LAYER mode.") + call get_param(param_file, mdl, "REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) call get_param(param_file, mdl, "INITIAL_DENSITY_PROFILE", density_profile, & @@ -288,11 +330,12 @@ subroutine dumbbell_initialize_temperature_salinity ( T, S, h, G, GV, US, param_ end subroutine dumbbell_initialize_temperature_salinity !> Initialize the restoring sponges for the dumbbell test case -subroutine dumbbell_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_ALE, CSp, ACSp) +subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_file, use_ALE, CSp, ACSp) type(ocean_grid_type), intent(in) :: G !< Horizontal grid control structure type(verticalGrid_type), intent(in) :: GV !< Vertical grid control structure type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type type(thermo_var_ptrs), intent(in) :: tv !< Thermodynamic variables + real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h_in !< Layer thickness [H ~> m or kg m-2] real, dimension(SZI_(G),SZJ_(G)), & intent(in) :: depth_tot !< The nominal total depth of the ocean [Z ~> m] type(param_file_type), intent(in) :: param_file !< Parameter file structure @@ -306,6 +349,7 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: h ! sponge thicknesses [H ~> m or kg m-2] real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: S ! sponge salinities [S ~> ppt] real, dimension(SZK_(GV)+1) :: eta1D ! interface positions for ALE sponge + real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: eta ! A temporary array for interface heights [Z ~> m]. integer :: i, j, k, nz real :: x ! The fractional position in the domain [nondim] @@ -404,9 +448,27 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use enddo endif enddo ; enddo - endif - if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + + else + do j=G%jsc,G%jec ; do i=G%isc,G%iec + eta(i,j,1) = 0.0 + do k=2,nz + eta(i,j,k) = eta(i,j,k-1)-h_in(i,j,k-1) + enddo + eta(i,j,nz+1) = -depth_tot(i,j) + do k=1,nz + S(i,j,k)= tv%S(i,j,k) + enddo + enddo ; enddo + + ! This call sets up the damping rates and interface heights. + ! This sets the inverse damping timescale fields in the sponges. ! + call initialize_sponge(Idamp, eta, G, param_file, CSp, GV) + + ! The remaining calls to set_up_sponge_field can be in any order. ! + if ( associated(tv%S) ) call set_up_sponge_field(S, tv%S, G, GV, nz, CSp) + endif end subroutine dumbbell_initialize_sponges From 63d7624e48892be36e770dce0df0c0b9b70663ee Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Thu, 7 Jul 2022 12:34:50 -0400 Subject: [PATCH 02/15] Change in Dumbbell Layer Mode --- .DS_Store | Bin 6148 -> 0 bytes src/.DS_Store | Bin 8196 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store delete mode 100644 src/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 967887c2aff4da305da78dd97e26ae40dcba8b4e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKL5tHs6n>LNH|Zkupr8j~z-w6>#fo^zcDsiK^{^2=sMMsXHEcFhns$3Ah1~VO zc=m_rfAOU6&Aft5>q!tP^We?*X6Ah_ov&mj0|25oPXmA!0C?zxZWEgwM)Txb=J1G* zD5yq~s{~^zcFc1YtO8bn|5pKecO8gfc$TYS?fpIasZIa*CJaGA0UscPF$|!D=@#b; zX8z7`Aw|v*%FWv1ZY{3~&)^JB;1pg!gzXVrLR#Z|s&N`HfeRSdvVPREd^pE?$Iyr8 zyX!jR8l$mmWzM(VS;?ZDux4MANuHInPUpLD8t%302cG90dheo-Y7x!i*}Uw<(>K(6 zsZ^e<<2ZShjTVE}%@bA3;;a}=H6cq!nDX{@R-|gtQ}ZG%H8(O7p6~mE)}7_@LHBW6 z22X-jTP}mn!$)n|4Z5q9@7=n0|LOVQBEKvY35OLG4Ckz=YgL>=0MqdFCT^!biF@63MM>2+tl|h_A z6NZXtsDiH;!q9PCa$d+-88mbdeEAUkWWhHSp`VWRrA`MC8nmrdz$&n*K*MxfbpD_I z`ToC2vOTMSRba0a5Ng2H+b2D}E%C`QFgHtrq-Pe$~h5@#~m-C-xwaV9Zf2;{EM z;466cLG)cb=~vyoF*At^B8swI&{h3YUw6+}#dLZ?M4~+oJ)#{Va!}aTs!(f$$GNP? zhUvKoD}X223t}0dRa^139hL#hfMvikU>UFs{2L75%w}1l+NxIvl)3`ImeH*Qb@k&P*5wY^ma%hf(E|}03ag>QTrq^XI|vQOc+2?DwbgJE zYGur0Ru<-lBFxo8xXPVGOIxcg1D1hR2Keq?qFs7K`w!#X{e2fB*S{%Iurl>XQcC@T z-^YSql|qWhr$b8MpV0`d9%XryxLQDMQ=eYb7&!Kqz;>Yzpm_%FEvzfv6=tZwJB8-} zGfmV^j|*#lT|w~9`f80M*q9FTh>gPn;sW-Tpzt1j_($~i$Bqlw&%c5VCfU$@JNXn0 z<0u<78ehalseEp8%W<5l^Rja!C!LW$8fR@kea@{XQpUka-4C8d{YkfW>48i}ew6f6 z1&G2vTwXkjl2A_Ca-4*j!gln4Q>j$CwJX!<&E}oD>)rEab$9ADZr!fCO|LndRh-M$ zZrp#|J&p&7WWpiByn*SwZZGtE)J`SnO(#uanJ}q52fi06`h6AbP!Z`P7(POtf!aZy zP$VhQhoywvrXhS!LXHGMJr|H-(h;ZX@(h~@B;z>=()?;FL6?2YNX~4HAG5O7@6?cP z{lSnrCZryR^lsyKL%MkI+H4h%<5EM^Xz=eyC| Date: Thu, 7 Jul 2022 13:04:26 -0400 Subject: [PATCH 03/15] Revert "Change dumbbell initialization" This reverts commit bf2c83f3d6f9c45bdaf7132b74fbddaeadfafccb. --- .../MOM_state_initialization.F90 | 2 +- src/user/dumbbell_initialization.F90 | 74 ++----------------- 2 files changed, 7 insertions(+), 69 deletions(-) diff --git a/src/initialization/MOM_state_initialization.F90 b/src/initialization/MOM_state_initialization.F90 index cd6ddbeca7..0757fd887f 100644 --- a/src/initialization/MOM_state_initialization.F90 +++ b/src/initialization/MOM_state_initialization.F90 @@ -585,7 +585,7 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, & case ("USER"); call user_initialize_sponges(G, GV, use_temperature, tv, PF, sponge_CSp, h) case ("BFB"); call BFB_initialize_sponges_southonly(G, GV, US, use_temperature, tv, depth_tot, PF, & sponge_CSp, h) - case ("DUMBBELL"); call dumbbell_initialize_sponges(G, GV, US, tv, h, depth_tot, PF, useALE, & + case ("DUMBBELL"); call dumbbell_initialize_sponges(G, GV, US, tv, depth_tot, PF, useALE, & sponge_CSp, ALE_sponge_CSp) case ("phillips"); call Phillips_initialize_sponges(G, GV, US, tv, PF, sponge_CSp, h) case ("dense"); call dense_water_initialize_sponges(G, GV, US, tv, depth_tot, PF, useALE, & diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 820ce69049..c197274067 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -16,7 +16,7 @@ module dumbbell_initialization use MOM_verticalGrid, only : verticalGrid_type use regrid_consts, only : coordinateMode, DEFAULT_COORDINATE_MODE use regrid_consts, only : REGRIDDING_LAYER, REGRIDDING_ZSTAR -use regrid_consts, only : REGRIDDING_RHO, REGRIDDING_SIGMA, REGRIDDING_HYCOM1 +use regrid_consts, only : REGRIDDING_RHO, REGRIDDING_SIGMA use MOM_ALE_sponge, only : ALE_sponge_CS, set_up_ALE_sponge_field, initialize_ALE_sponge implicit none ; private @@ -112,14 +112,10 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, real :: S_range ! The range of salinities in this test case [S ~> ppt] real :: S_light, S_dense ! The lightest and densest salinities in the sponges [S ~> ppt]. real :: eta_IC_quanta ! The granularity of quantization of intial interface heights [Z-1 ~> m-1]. - logical :: dbrotate ! If true, rotate the domain. - logical :: use_ALE ! True if ALE is being used, False if in layered mode - ! This include declares and sets the variable "version". # include "version_variable.h" character(len=20) :: verticalCoordinate integer :: i, j, k, is, ie, js, je, nz - real :: x, y is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke @@ -132,8 +128,6 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, units='m', default=1.0e-3, scale=US%m_to_Z, do_not_log=just_read) call get_param(param_file, mdl,"REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) - call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) - if(.not. use_ALE) verticalCoordinate = "LAYER" ! WARNING: this routine specifies the interface heights so that the last layer ! is vanished, even at maximum depth. In order to have a uniform @@ -147,38 +141,8 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, !enddo select case ( coordinateMode(verticalCoordinate) ) - case ( REGRIDDING_LAYER) ! Initial thicknesses for isopycnal coordinates - call get_param(param_file, mdl, "DUMBBELL_ROTATION", dbrotate, & - 'Logical for rotation of dumbbell domain.',& - units='nondim', default=.false., do_not_log=just_read) - do j=js,je - do i=is,ie - ! Compute normalized zonal coordinates (x,y=0 at center of domain) - if (dbrotate) then - ! This is really y in the rotated case - x = G%geoLatT(i,j) - else - x = G%geoLonT(i,j) - endif - - eta1D(1) = 0.0 - eta1D(nz+1) = -depth_tot(i,j) - if (x<0.0) then - do k=nz,2, -1 - eta1D(k) = eta1D(k+1) + min_thickness - enddo - else - do k=2,nz - eta1D(k) = eta1D(k-1) - min_thickness - enddo - endif - - do k=1,nz - h(i,j,k) = GV%Z_to_H * (eta1D(k) - eta1D(k+1)) - enddo - enddo; enddo - - case ( REGRIDDING_RHO, REGRIDDING_HYCOM1) ! Initial thicknesses for isopycnal coordinates + + case ( REGRIDDING_LAYER, REGRIDDING_RHO ) ! Initial thicknesses for isopycnal coordinates call get_param(param_file, mdl, "INITIAL_SSS", S_surf, & units='1e-3', default=34., scale=US%ppt_to_S, do_not_log=.true.) call get_param(param_file, mdl, "INITIAL_S_RANGE", S_range, & @@ -267,18 +231,12 @@ subroutine dumbbell_initialize_temperature_salinity ( T, S, h, G, GV, US, param_ real :: x ! The fractional position in the domain [nondim] real :: dblen ! The size of the dumbbell test case [axis_units] logical :: dbrotate ! If true, rotate the domain. - logical :: use_ALE ! If false, use layer mode. character(len=20) :: verticalCoordinate, density_profile is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke T_surf = 20.0*US%degC_to_C - ! layer mode - call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) - if(.not. use_ALE) call MOM_error(FATAL, "dumbbell_initialize_temperature_salinity: "//& - "Please use 'fit' for 'TS_CONFIG' in the LAYER mode.") - call get_param(param_file, mdl, "REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) call get_param(param_file, mdl, "INITIAL_DENSITY_PROFILE", density_profile, & @@ -330,12 +288,11 @@ subroutine dumbbell_initialize_temperature_salinity ( T, S, h, G, GV, US, param_ end subroutine dumbbell_initialize_temperature_salinity !> Initialize the restoring sponges for the dumbbell test case -subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_file, use_ALE, CSp, ACSp) +subroutine dumbbell_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_ALE, CSp, ACSp) type(ocean_grid_type), intent(in) :: G !< Horizontal grid control structure type(verticalGrid_type), intent(in) :: GV !< Vertical grid control structure type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type type(thermo_var_ptrs), intent(in) :: tv !< Thermodynamic variables - real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h_in !< Layer thickness [H ~> m or kg m-2] real, dimension(SZI_(G),SZJ_(G)), & intent(in) :: depth_tot !< The nominal total depth of the ocean [Z ~> m] type(param_file_type), intent(in) :: param_file !< Parameter file structure @@ -349,7 +306,6 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: h ! sponge thicknesses [H ~> m or kg m-2] real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: S ! sponge salinities [S ~> ppt] real, dimension(SZK_(GV)+1) :: eta1D ! interface positions for ALE sponge - real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: eta ! A temporary array for interface heights [Z ~> m]. integer :: i, j, k, nz real :: x ! The fractional position in the domain [nondim] @@ -448,27 +404,9 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil enddo endif enddo ; enddo - if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) - - else - do j=G%jsc,G%jec ; do i=G%isc,G%iec - eta(i,j,1) = 0.0 - do k=2,nz - eta(i,j,k) = eta(i,j,k-1)-h_in(i,j,k-1) - enddo - eta(i,j,nz+1) = -depth_tot(i,j) - do k=1,nz - S(i,j,k)= tv%S(i,j,k) - enddo - enddo ; enddo - - ! This call sets up the damping rates and interface heights. - ! This sets the inverse damping timescale fields in the sponges. ! - call initialize_sponge(Idamp, eta, G, param_file, CSp, GV) + endif - ! The remaining calls to set_up_sponge_field can be in any order. ! - if ( associated(tv%S) ) call set_up_sponge_field(S, tv%S, G, GV, nz, CSp) - endif + if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) end subroutine dumbbell_initialize_sponges From 83f5777e0ba29a9c4c5eb64bc912f674908714ed Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Thu, 7 Jul 2022 13:09:41 -0400 Subject: [PATCH 04/15] Revert "Revert "Change dumbbell initialization"" This reverts commit aaf446d116382a86bceb6f28c5fb4b4fc66a70fc. --- .../MOM_state_initialization.F90 | 2 +- src/user/dumbbell_initialization.F90 | 74 +++++++++++++++++-- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/initialization/MOM_state_initialization.F90 b/src/initialization/MOM_state_initialization.F90 index 0757fd887f..cd6ddbeca7 100644 --- a/src/initialization/MOM_state_initialization.F90 +++ b/src/initialization/MOM_state_initialization.F90 @@ -585,7 +585,7 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, & case ("USER"); call user_initialize_sponges(G, GV, use_temperature, tv, PF, sponge_CSp, h) case ("BFB"); call BFB_initialize_sponges_southonly(G, GV, US, use_temperature, tv, depth_tot, PF, & sponge_CSp, h) - case ("DUMBBELL"); call dumbbell_initialize_sponges(G, GV, US, tv, depth_tot, PF, useALE, & + case ("DUMBBELL"); call dumbbell_initialize_sponges(G, GV, US, tv, h, depth_tot, PF, useALE, & sponge_CSp, ALE_sponge_CSp) case ("phillips"); call Phillips_initialize_sponges(G, GV, US, tv, PF, sponge_CSp, h) case ("dense"); call dense_water_initialize_sponges(G, GV, US, tv, depth_tot, PF, useALE, & diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index c197274067..820ce69049 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -16,7 +16,7 @@ module dumbbell_initialization use MOM_verticalGrid, only : verticalGrid_type use regrid_consts, only : coordinateMode, DEFAULT_COORDINATE_MODE use regrid_consts, only : REGRIDDING_LAYER, REGRIDDING_ZSTAR -use regrid_consts, only : REGRIDDING_RHO, REGRIDDING_SIGMA +use regrid_consts, only : REGRIDDING_RHO, REGRIDDING_SIGMA, REGRIDDING_HYCOM1 use MOM_ALE_sponge, only : ALE_sponge_CS, set_up_ALE_sponge_field, initialize_ALE_sponge implicit none ; private @@ -112,10 +112,14 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, real :: S_range ! The range of salinities in this test case [S ~> ppt] real :: S_light, S_dense ! The lightest and densest salinities in the sponges [S ~> ppt]. real :: eta_IC_quanta ! The granularity of quantization of intial interface heights [Z-1 ~> m-1]. + logical :: dbrotate ! If true, rotate the domain. + logical :: use_ALE ! True if ALE is being used, False if in layered mode + ! This include declares and sets the variable "version". # include "version_variable.h" character(len=20) :: verticalCoordinate integer :: i, j, k, is, ie, js, je, nz + real :: x, y is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke @@ -128,6 +132,8 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, units='m', default=1.0e-3, scale=US%m_to_Z, do_not_log=just_read) call get_param(param_file, mdl,"REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) + call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) + if(.not. use_ALE) verticalCoordinate = "LAYER" ! WARNING: this routine specifies the interface heights so that the last layer ! is vanished, even at maximum depth. In order to have a uniform @@ -141,8 +147,38 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, !enddo select case ( coordinateMode(verticalCoordinate) ) - - case ( REGRIDDING_LAYER, REGRIDDING_RHO ) ! Initial thicknesses for isopycnal coordinates + case ( REGRIDDING_LAYER) ! Initial thicknesses for isopycnal coordinates + call get_param(param_file, mdl, "DUMBBELL_ROTATION", dbrotate, & + 'Logical for rotation of dumbbell domain.',& + units='nondim', default=.false., do_not_log=just_read) + do j=js,je + do i=is,ie + ! Compute normalized zonal coordinates (x,y=0 at center of domain) + if (dbrotate) then + ! This is really y in the rotated case + x = G%geoLatT(i,j) + else + x = G%geoLonT(i,j) + endif + + eta1D(1) = 0.0 + eta1D(nz+1) = -depth_tot(i,j) + if (x<0.0) then + do k=nz,2, -1 + eta1D(k) = eta1D(k+1) + min_thickness + enddo + else + do k=2,nz + eta1D(k) = eta1D(k-1) - min_thickness + enddo + endif + + do k=1,nz + h(i,j,k) = GV%Z_to_H * (eta1D(k) - eta1D(k+1)) + enddo + enddo; enddo + + case ( REGRIDDING_RHO, REGRIDDING_HYCOM1) ! Initial thicknesses for isopycnal coordinates call get_param(param_file, mdl, "INITIAL_SSS", S_surf, & units='1e-3', default=34., scale=US%ppt_to_S, do_not_log=.true.) call get_param(param_file, mdl, "INITIAL_S_RANGE", S_range, & @@ -231,12 +267,18 @@ subroutine dumbbell_initialize_temperature_salinity ( T, S, h, G, GV, US, param_ real :: x ! The fractional position in the domain [nondim] real :: dblen ! The size of the dumbbell test case [axis_units] logical :: dbrotate ! If true, rotate the domain. + logical :: use_ALE ! If false, use layer mode. character(len=20) :: verticalCoordinate, density_profile is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke T_surf = 20.0*US%degC_to_C + ! layer mode + call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) + if(.not. use_ALE) call MOM_error(FATAL, "dumbbell_initialize_temperature_salinity: "//& + "Please use 'fit' for 'TS_CONFIG' in the LAYER mode.") + call get_param(param_file, mdl, "REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) call get_param(param_file, mdl, "INITIAL_DENSITY_PROFILE", density_profile, & @@ -288,11 +330,12 @@ subroutine dumbbell_initialize_temperature_salinity ( T, S, h, G, GV, US, param_ end subroutine dumbbell_initialize_temperature_salinity !> Initialize the restoring sponges for the dumbbell test case -subroutine dumbbell_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_ALE, CSp, ACSp) +subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_file, use_ALE, CSp, ACSp) type(ocean_grid_type), intent(in) :: G !< Horizontal grid control structure type(verticalGrid_type), intent(in) :: GV !< Vertical grid control structure type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type type(thermo_var_ptrs), intent(in) :: tv !< Thermodynamic variables + real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h_in !< Layer thickness [H ~> m or kg m-2] real, dimension(SZI_(G),SZJ_(G)), & intent(in) :: depth_tot !< The nominal total depth of the ocean [Z ~> m] type(param_file_type), intent(in) :: param_file !< Parameter file structure @@ -306,6 +349,7 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: h ! sponge thicknesses [H ~> m or kg m-2] real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: S ! sponge salinities [S ~> ppt] real, dimension(SZK_(GV)+1) :: eta1D ! interface positions for ALE sponge + real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: eta ! A temporary array for interface heights [Z ~> m]. integer :: i, j, k, nz real :: x ! The fractional position in the domain [nondim] @@ -404,9 +448,27 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use enddo endif enddo ; enddo - endif - if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + + else + do j=G%jsc,G%jec ; do i=G%isc,G%iec + eta(i,j,1) = 0.0 + do k=2,nz + eta(i,j,k) = eta(i,j,k-1)-h_in(i,j,k-1) + enddo + eta(i,j,nz+1) = -depth_tot(i,j) + do k=1,nz + S(i,j,k)= tv%S(i,j,k) + enddo + enddo ; enddo + + ! This call sets up the damping rates and interface heights. + ! This sets the inverse damping timescale fields in the sponges. ! + call initialize_sponge(Idamp, eta, G, param_file, CSp, GV) + + ! The remaining calls to set_up_sponge_field can be in any order. ! + if ( associated(tv%S) ) call set_up_sponge_field(S, tv%S, G, GV, nz, CSp) + endif end subroutine dumbbell_initialize_sponges From dc82d3ad952befc9bd555259ae184479a3711f2e Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Thu, 7 Jul 2022 17:32:46 -0400 Subject: [PATCH 05/15] Update dumbbell_initialization.F90 --- src/user/dumbbell_initialization.F90 | 57 +++++++++++++--------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 820ce69049..9390f26dca 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -113,8 +113,8 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, real :: S_light, S_dense ! The lightest and densest salinities in the sponges [S ~> ppt]. real :: eta_IC_quanta ! The granularity of quantization of intial interface heights [Z-1 ~> m-1]. logical :: dbrotate ! If true, rotate the domain. - logical :: use_ALE ! True if ALE is being used, False if in layered mode - + logical :: use_ALE ! True if ALE is being used, False if in layered mode + ! This include declares and sets the variable "version". # include "version_variable.h" character(len=20) :: verticalCoordinate @@ -132,7 +132,7 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, units='m', default=1.0e-3, scale=US%m_to_Z, do_not_log=just_read) call get_param(param_file, mdl,"REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) - call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) + call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) if(.not. use_ALE) verticalCoordinate = "LAYER" ! WARNING: this routine specifies the interface heights so that the last layer @@ -148,36 +148,34 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, select case ( coordinateMode(verticalCoordinate) ) case ( REGRIDDING_LAYER) ! Initial thicknesses for isopycnal coordinates - call get_param(param_file, mdl, "DUMBBELL_ROTATION", dbrotate, & + call get_param(param_file, mdl, "DUMBBELL_ROTATION", dbrotate, & 'Logical for rotation of dumbbell domain.',& units='nondim', default=.false., do_not_log=just_read) do j=js,je do i=is,ie ! Compute normalized zonal coordinates (x,y=0 at center of domain) if (dbrotate) then - ! This is really y in the rotated case - x = G%geoLatT(i,j) + ! This is really y in the rotated case + x = G%geoLatT(i,j) else - x = G%geoLonT(i,j) + x = G%geoLonT(i,j) endif - - eta1D(1) = 0.0 - eta1D(nz+1) = -depth_tot(i,j) + eta1D(1) = 0.0 + eta1D(nz+1) = -depth_tot(i,j) if (x<0.0) then do k=nz,2, -1 eta1D(k) = eta1D(k+1) + min_thickness - enddo + enddo else do k=2,nz eta1D(k) = eta1D(k-1) - min_thickness enddo endif - do k=1,nz - h(i,j,k) = GV%Z_to_H * (eta1D(k) - eta1D(k+1)) + h(i,j,k) = GV%Z_to_H * (eta1D(k) - eta1D(k+1)) enddo - enddo; enddo - + enddo; enddo + case ( REGRIDDING_RHO, REGRIDDING_HYCOM1) ! Initial thicknesses for isopycnal coordinates call get_param(param_file, mdl, "INITIAL_SSS", S_surf, & units='1e-3', default=34., scale=US%ppt_to_S, do_not_log=.true.) @@ -278,7 +276,7 @@ subroutine dumbbell_initialize_temperature_salinity ( T, S, h, G, GV, US, param_ call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) if(.not. use_ALE) call MOM_error(FATAL, "dumbbell_initialize_temperature_salinity: "//& "Please use 'fit' for 'TS_CONFIG' in the LAYER mode.") - + call get_param(param_file, mdl, "REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) call get_param(param_file, mdl, "INITIAL_DENSITY_PROFILE", density_profile, & @@ -449,26 +447,25 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil endif enddo ; enddo if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) - else do j=G%jsc,G%jec ; do i=G%isc,G%iec eta(i,j,1) = 0.0 do k=2,nz - eta(i,j,k) = eta(i,j,k-1)-h_in(i,j,k-1) - enddo - eta(i,j,nz+1) = -depth_tot(i,j) + eta(i,j,k) = eta(i,j,k-1)-h_in(i,j,k-1) + enddo + eta(i,j,nz+1) = -depth_tot(i,j) do k=1,nz - S(i,j,k)= tv%S(i,j,k) + S(i,j,k)= tv%S(i,j,k) enddo - enddo ; enddo - - ! This call sets up the damping rates and interface heights. - ! This sets the inverse damping timescale fields in the sponges. ! - call initialize_sponge(Idamp, eta, G, param_file, CSp, GV) - - ! The remaining calls to set_up_sponge_field can be in any order. ! - if ( associated(tv%S) ) call set_up_sponge_field(S, tv%S, G, GV, nz, CSp) - endif + enddo ; enddo + + ! This call sets up the damping rates and interface heights. + ! This sets the inverse damping timescale fields in the sponges. ! + call initialize_sponge(Idamp, eta, G, param_file, CSp, GV) + + ! The remaining calls to set_up_sponge_field can be in any order. ! + if ( associated(tv%S) ) call set_up_sponge_field(S, tv%S, G, GV, nz, CSp) + endif end subroutine dumbbell_initialize_sponges From 16375ad48bdebe192b3436ea1919e818f73a8455 Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Thu, 7 Jul 2022 17:57:45 -0400 Subject: [PATCH 06/15] Update dumbbell_initialization.F90 --- src/user/dumbbell_initialization.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 9390f26dca..7162e4bc81 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -133,7 +133,7 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, call get_param(param_file, mdl,"REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) - if(.not. use_ALE) verticalCoordinate = "LAYER" + if(.not. use_ALE) verticalCoordinate = "LAYER" ! WARNING: this routine specifies the interface heights so that the last layer ! is vanished, even at maximum depth. In order to have a uniform @@ -162,7 +162,7 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, endif eta1D(1) = 0.0 eta1D(nz+1) = -depth_tot(i,j) - if (x<0.0) then + if (x<0.0) then do k=nz,2, -1 eta1D(k) = eta1D(k+1) + min_thickness enddo From 3e56e422a2c394f6f1f6f56d8a85fa7b006197f3 Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Thu, 7 Jul 2022 18:12:47 -0400 Subject: [PATCH 07/15] Update dumbbell_initialization.F90 --- src/user/dumbbell_initialization.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 7162e4bc81..54e5862ea7 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -458,11 +458,11 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil S(i,j,k)= tv%S(i,j,k) enddo enddo ; enddo - + ! This call sets up the damping rates and interface heights. ! This sets the inverse damping timescale fields in the sponges. ! call initialize_sponge(Idamp, eta, G, param_file, CSp, GV) - + ! The remaining calls to set_up_sponge_field can be in any order. ! if ( associated(tv%S) ) call set_up_sponge_field(S, tv%S, G, GV, nz, CSp) endif From 9de382d75ddc85d4b5fa7f0ff989fd5b782d9398 Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Sun, 10 Jul 2022 14:59:48 -0400 Subject: [PATCH 08/15] Update dumbbell_initialization.F90 --- src/user/dumbbell_initialization.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 54e5862ea7..e3f0c6dad3 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -133,7 +133,7 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file, call get_param(param_file, mdl,"REGRIDDING_COORDINATE_MODE", verticalCoordinate, & default=DEFAULT_COORDINATE_MODE, do_not_log=just_read) call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) - if(.not. use_ALE) verticalCoordinate = "LAYER" + if (.not. use_ALE) verticalCoordinate = "LAYER" ! WARNING: this routine specifies the interface heights so that the last layer ! is vanished, even at maximum depth. In order to have a uniform @@ -274,7 +274,7 @@ subroutine dumbbell_initialize_temperature_salinity ( T, S, h, G, GV, US, param_ ! layer mode call get_param(param_file, mdl, "USE_REGRIDDING", use_ALE, do_not_log = .true.) - if(.not. use_ALE) call MOM_error(FATAL, "dumbbell_initialize_temperature_salinity: "//& + if (.not. use_ALE) call MOM_error(FATAL, "dumbbell_initialize_temperature_salinity: "//& "Please use 'fit' for 'TS_CONFIG' in the LAYER mode.") call get_param(param_file, mdl, "REGRIDDING_COORDINATE_MODE", verticalCoordinate, & From 433ee56da89c59b8ad5af1f6e12c29af13acc5fd Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Fri, 15 Jul 2022 12:03:26 -0400 Subject: [PATCH 09/15] Update dumbbell_initialization.F90 --- src/user/dumbbell_initialization.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index e3f0c6dad3..570e638465 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -451,7 +451,7 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil do j=G%jsc,G%jec ; do i=G%isc,G%iec eta(i,j,1) = 0.0 do k=2,nz - eta(i,j,k) = eta(i,j,k-1)-h_in(i,j,k-1) + eta(i,j,k) = eta(i,j,k-1)- GV%H_to_Z * h_in(i,j,k-1) enddo eta(i,j,nz+1) = -depth_tot(i,j) do k=1,nz From fffd4e3856375404a5d581172e4cf64990aff1a7 Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Mon, 18 Jul 2022 18:49:46 -0400 Subject: [PATCH 10/15] Fix sponge diagnostics --- .../MOM_state_initialization.F90 | 12 ++-- .../vertical/MOM_ALE_sponge.F90 | 59 +++++++++++++++---- src/tracer/RGC_tracer.F90 | 2 +- src/user/DOME2d_initialization.F90 | 10 ++-- src/user/ISOMIP_initialization.F90 | 11 ++-- src/user/RGC_initialization.F90 | 6 +- src/user/dense_water_initialization.F90 | 6 +- src/user/dumbbell_initialization.F90 | 7 ++- 8 files changed, 79 insertions(+), 34 deletions(-) diff --git a/src/initialization/MOM_state_initialization.F90 b/src/initialization/MOM_state_initialization.F90 index cd6ddbeca7..01511b7c67 100644 --- a/src/initialization/MOM_state_initialization.F90 +++ b/src/initialization/MOM_state_initialization.F90 @@ -2113,9 +2113,11 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t if (use_temperature) then allocate(tmp_tr(isd:ied,jsd:jed,nz_data)) call MOM_read_data(filename, potemp_var, tmp_tr(:,:,:), G%Domain, scale=US%degC_to_C) - call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%T, ALE_CSp) + call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') call MOM_read_data(filename, salin_var, tmp_tr(:,:,:), G%Domain, scale=US%ppt_to_S) - call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp) + call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') deallocate(tmp_tr) endif if (sponge_uv) then @@ -2138,8 +2140,10 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t endif ! The remaining calls to set_up_sponge_field can be in any order. if ( use_temperature) then - call set_up_ALE_sponge_field(filename, potemp_var, Time, G, GV, US, tv%T, ALE_CSp, scale=US%C_to_degC) - call set_up_ALE_sponge_field(filename, salin_var, Time, G, GV, US, tv%S, ALE_CSp, scale=US%S_to_ppt) + call set_up_ALE_sponge_field(filename, potemp_var, Time, G, GV, US, tv%T, ALE_CSp, & + 'temp', sp_long_name='temperature', sp_unit = 'degC s-1', scale=US%C_to_degC) + call set_up_ALE_sponge_field(filename, salin_var, Time, G, GV, US, tv%S, ALE_CSp, & + 'salt', sp_long_name='salinity', sp_unit = 'g kg-1 s-1', scale=US%S_to_ppt) endif if (sponge_uv) then filename = trim(inputdir)//trim(state_uv_file) diff --git a/src/parameterizations/vertical/MOM_ALE_sponge.F90 b/src/parameterizations/vertical/MOM_ALE_sponge.F90 index 9409a07fc1..2305189d9d 100644 --- a/src/parameterizations/vertical/MOM_ALE_sponge.F90 +++ b/src/parameterizations/vertical/MOM_ALE_sponge.F90 @@ -81,6 +81,9 @@ module MOM_ALE_sponge real :: scale = 1.0 !< A multiplicative factor by which to rescale input data real, dimension(:,:), pointer :: p => NULL() !< pointer the data. real, dimension(:,:), pointer :: h => NULL() !< pointer the data grid. + Character (:), allocatable :: name !< The name of the input field + Character (:), allocatable :: long_name !< The long name of the input field + Character (:), allocatable :: unit !< The unit of the input field end type p2d !> ALE sponge control structure @@ -132,7 +135,7 @@ module MOM_ALE_sponge logical :: tripolar_N !< grid is folded at its north edge !>@{ Diagnostic IDs - integer, dimension(2) :: id_sp_tendency !< Diagnostic ids for temperature and salinity + integer, dimension(MAX_FIELDS_) :: id_sp_tendency !< Diagnostic ids for temperature and salinity !! tendency due to sponges integer :: id_sp_u_tendency !< Diagnostic id for zonal momentum tendency due to !! Rayleigh damping @@ -598,15 +601,19 @@ subroutine init_ALE_sponge_diags(Time, G, diag, CS, US) !! output. type(ALE_sponge_CS), intent(inout) :: CS !< ALE sponge control structure type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type + ! Local Variables + integer :: m CS%diag => diag - CS%id_sp_tendency(1) = -1 - CS%id_sp_tendency(1) = register_diag_field('ocean_model', 'sp_tendency_temp', diag%axesTL, Time, & - 'Time tendency due to temperature restoring', 'degC s-1', conversion=US%s_to_T) - CS%id_sp_tendency(2) = -1 - CS%id_sp_tendency(2) = register_diag_field('ocean_model', 'sp_tendency_salt', diag%axesTL, Time, & - 'Time tendency due to salinity restoring', 'g kg-1 s-1', conversion=US%s_to_T) + do m=1,CS%fldno + CS%id_sp_tendency(m) = -1 + CS%id_sp_tendency(m) = register_diag_field('ocean_model', & + 'sp_tendency_' // CS%Ref_val(m)%name, diag%axesTL, Time, & + 'Time tendency due to restoring ' // CS%Ref_val(m)%long_name, & + CS%Ref_val(m)%unit, conversion=US%s_to_T) + enddo + CS%id_sp_u_tendency = -1 CS%id_sp_u_tendency = register_diag_field('ocean_model', 'sp_tendency_u', diag%axesCuL, Time, & 'Zonal acceleration due to sponges', 'm s-2', conversion=US%L_T2_to_m_s2) @@ -618,7 +625,8 @@ end subroutine init_ALE_sponge_diags !> This subroutine stores the reference profile at h points for the variable !! whose address is given by f_ptr. -subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, scale) +subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, & + sp_name, sp_long_name, sp_unit, scale) type(ocean_grid_type), intent(in) :: G !< Grid structure type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure type(ALE_sponge_CS), pointer :: CS !< ALE sponge control structure (in/out). @@ -627,16 +635,27 @@ subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, scale) !! arbitrary number of layers. real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), & target, intent(in) :: f_ptr !< Pointer to the field to be damped + character(len=*), intent(in) :: sp_name !< The name of the tracer field + character(len=*), optional, & + intent(in) :: sp_long_name !< The long name of the tracer field + !! if not given, use the sp_name + character(len=*), optional, & + intent(in) :: sp_unit !< The unit of the tracer field + !! if not given, use the none real, optional, intent(in) :: scale !< A factor by which to rescale the input data, including any !! contributions due to dimensional rescaling. The default is 1. real :: scale_fac ! A factor by which to scale sp_val before storing it. integer :: k, col character(len=256) :: mesg ! String for error messages + character(len=256) :: long_name ! The long name of the tracer field + character(len=256) :: unit ! The unit of the tracer field if (.not.associated(CS)) return scale_fac = 1.0 ; if (present(scale)) scale_fac = scale + long_name = sp_name; if (present(sp_long_name)) long_name = sp_long_name + unit = 'none'; if (present(sp_unit)) unit = sp_unit CS%fldno = CS%fldno + 1 if (CS%fldno > MAX_FIELDS_) then @@ -648,6 +667,9 @@ subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, scale) ! stores the reference profile CS%Ref_val(CS%fldno)%nz_data = CS%nz_data + CS%Ref_val(CS%fldno)%name = sp_name + CS%Ref_val(CS%fldno)%long_name = long_name + CS%Ref_val(CS%fldno)%unit = unit allocate(CS%Ref_val(CS%fldno)%p(CS%nz_data,CS%num_col), source=0.0) do col=1,CS%num_col do k=1,CS%nz_data @@ -661,7 +683,8 @@ end subroutine set_up_ALE_sponge_field_fixed !> This subroutine stores the reference profile at h points for the variable !! whose address is given by filename and fieldname. -subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, f_ptr, CS, scale) +subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, f_ptr, CS, & + sp_name, sp_long_name, sp_unit, scale) character(len=*), intent(in) :: filename !< The name of the file with the !! time varying field data character(len=*), intent(in) :: fieldname !< The name of the field in the file @@ -673,6 +696,13 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), & target, intent(in) :: f_ptr !< Pointer to the field to be damped (in). type(ALE_sponge_CS), pointer :: CS !< Sponge control structure (in/out). + character(len=*), intent(in) :: sp_name !< The name of the tracer field + character(len=*), optional, & + intent(in) :: sp_long_name !< The long name of the tracer field + !! if not given, use the sp_name + character(len=*), optional, & + intent(in) :: sp_unit !< The unit of the tracer field + !! if not given, use 'none' real, optional, intent(in) :: scale !< A factor by which to rescale the input data, including any !! contributions due to dimensional rescaling. The default is 1. @@ -681,6 +711,11 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, integer, dimension(4) :: fld_sz integer :: nz_data !< the number of vertical levels in this input field character(len=256) :: mesg ! String for error messages + character(len=256) :: long_name ! The long name of the tracer field + character(len=256) :: unit ! The unit of the tracer field + long_name = sp_name; if (present(sp_long_name)) long_name = sp_long_name + unit = 'none'; if (present(sp_unit)) unit = sp_unit + ! Local variables for ALE remapping if (.not.associated(CS)) return @@ -700,6 +735,9 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, else CS%Ref_val(CS%fldno)%id = init_external_field(filename, fieldname) endif + CS%Ref_val(CS%fldno)%name = sp_name + CS%Ref_val(CS%fldno)%long_name = long_name + CS%Ref_val(CS%fldno)%unit = unit fld_sz(1:4) = -1 call get_external_field_info(CS%Ref_val(CS%fldno)%id, size=fld_sz) nz_data = fld_sz(3) @@ -1222,7 +1260,8 @@ subroutine rotate_ALE_sponge(sponge_in, G_in, sponge, G, GV, turns, param_file) call rotate_array(sp_val_in, turns, sp_val) ! NOTE: This points sp_val with the unrotated field. See note below. - call set_up_ALE_sponge_field(sp_val, G, GV, sp_ptr, sponge) + call set_up_ALE_sponge_field(sp_val, G, GV, sp_ptr, sponge, & + sponge_in%Ref_val(n)%name, sp_long_name=sponge_in%Ref_val(n)%long_name, sp_unit=sponge_in%Ref_val(n)%unit) deallocate(sp_val_in) else diff --git a/src/tracer/RGC_tracer.F90 b/src/tracer/RGC_tracer.F90 index 2921fdd124..4b25c58900 100644 --- a/src/tracer/RGC_tracer.F90 +++ b/src/tracer/RGC_tracer.F90 @@ -232,7 +232,7 @@ subroutine initialize_RGC_tracer(restart, day, G, GV, h, diag, OBC, CS, & do m=1,1 ! This is needed to force the compiler not to do a copy in the sponge calls. tr_ptr => CS%tr(:,:,:,m) - call set_up_ALE_sponge_field(temp, G, GV, tr_ptr, sponge_CSp) + call set_up_ALE_sponge_field(temp, G, GV, tr_ptr, sponge_CSp, 'RGC_tracer') enddo deallocate(temp) endif diff --git a/src/user/DOME2d_initialization.F90 b/src/user/DOME2d_initialization.F90 index 393347d1f2..bb48fdd423 100644 --- a/src/user/DOME2d_initialization.F90 +++ b/src/user/DOME2d_initialization.F90 @@ -473,12 +473,10 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A enddo enddo ; enddo - if ( associated(tv%T) ) then - call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) - endif - if ( associated(tv%S) ) then - call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) - endif + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') + if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') else diff --git a/src/user/ISOMIP_initialization.F90 b/src/user/ISOMIP_initialization.F90 index 5e91eaa86a..8248752e78 100644 --- a/src/user/ISOMIP_initialization.F90 +++ b/src/user/ISOMIP_initialization.F90 @@ -626,12 +626,11 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp, ! momentum is typically not damped within the sponge. ! ! The remaining calls to set_up_sponge_field can be in any order. ! - if ( associated(tv%T) ) then - call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) - endif - if ( associated(tv%S) ) then - call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) - endif + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') + if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + else ! layer mode ! 1) Read eta, salt and temp from IC file diff --git a/src/user/RGC_initialization.F90 b/src/user/RGC_initialization.F90 index d9c1846a0e..5410bc0a7d 100644 --- a/src/user/RGC_initialization.F90 +++ b/src/user/RGC_initialization.F90 @@ -168,8 +168,10 @@ subroutine RGC_initialize_sponges(G, GV, US, tv, u, v, depth_tot, PF, use_ALE, C call initialize_ALE_sponge(Idamp, G, GV, PF, ACSp, h, nz) ! The remaining calls to set_up_sponge_field can be in any order. - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) - if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') + if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') if (sponge_uv) then U1(:,:,:) = 0.0 ; V1(:,:,:) = 0.0 diff --git a/src/user/dense_water_initialization.F90 b/src/user/dense_water_initialization.F90 index 1c372bf1b7..a7c5086aa4 100644 --- a/src/user/dense_water_initialization.F90 +++ b/src/user/dense_water_initialization.F90 @@ -277,8 +277,10 @@ subroutine dense_water_initialize_sponges(G, GV, US, tv, depth_tot, param_file, enddo enddo - if (associated(tv%T)) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) - if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') + if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') else call MOM_error(FATAL, "dense_water_initialize_sponges: trying to use non ALE sponge") endif diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 570e638465..9a510578e1 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -446,12 +446,13 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil enddo endif enddo ; enddo - if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') else do j=G%jsc,G%jec ; do i=G%isc,G%iec eta(i,j,1) = 0.0 do k=2,nz - eta(i,j,k) = eta(i,j,k-1)- GV%H_to_Z * h_in(i,j,k-1) + eta(i,j,k) = eta(i,j,k-1) - GV%H_to_Z * h_in(i,j,k-1) enddo eta(i,j,nz+1) = -depth_tot(i,j) do k=1,nz @@ -469,4 +470,4 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil end subroutine dumbbell_initialize_sponges -end module dumbbell_initialization +end module dumbbell_initialization \ No newline at end of file From db077c839c25c870681ed874fc6104922daef61b Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:11:25 -0400 Subject: [PATCH 11/15] Revert "Fix sponge diagnostics" This reverts commit fffd4e3856375404a5d581172e4cf64990aff1a7. --- .../MOM_state_initialization.F90 | 12 ++-- .../vertical/MOM_ALE_sponge.F90 | 59 ++++--------------- src/tracer/RGC_tracer.F90 | 2 +- src/user/DOME2d_initialization.F90 | 10 ++-- src/user/ISOMIP_initialization.F90 | 11 ++-- src/user/RGC_initialization.F90 | 6 +- src/user/dense_water_initialization.F90 | 6 +- src/user/dumbbell_initialization.F90 | 7 +-- 8 files changed, 34 insertions(+), 79 deletions(-) diff --git a/src/initialization/MOM_state_initialization.F90 b/src/initialization/MOM_state_initialization.F90 index 01511b7c67..cd6ddbeca7 100644 --- a/src/initialization/MOM_state_initialization.F90 +++ b/src/initialization/MOM_state_initialization.F90 @@ -2113,11 +2113,9 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t if (use_temperature) then allocate(tmp_tr(isd:ied,jsd:jed,nz_data)) call MOM_read_data(filename, potemp_var, tmp_tr(:,:,:), G%Domain, scale=US%degC_to_C) - call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') + call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%T, ALE_CSp) call MOM_read_data(filename, salin_var, tmp_tr(:,:,:), G%Domain, scale=US%ppt_to_S) - call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp) deallocate(tmp_tr) endif if (sponge_uv) then @@ -2140,10 +2138,8 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t endif ! The remaining calls to set_up_sponge_field can be in any order. if ( use_temperature) then - call set_up_ALE_sponge_field(filename, potemp_var, Time, G, GV, US, tv%T, ALE_CSp, & - 'temp', sp_long_name='temperature', sp_unit = 'degC s-1', scale=US%C_to_degC) - call set_up_ALE_sponge_field(filename, salin_var, Time, G, GV, US, tv%S, ALE_CSp, & - 'salt', sp_long_name='salinity', sp_unit = 'g kg-1 s-1', scale=US%S_to_ppt) + call set_up_ALE_sponge_field(filename, potemp_var, Time, G, GV, US, tv%T, ALE_CSp, scale=US%C_to_degC) + call set_up_ALE_sponge_field(filename, salin_var, Time, G, GV, US, tv%S, ALE_CSp, scale=US%S_to_ppt) endif if (sponge_uv) then filename = trim(inputdir)//trim(state_uv_file) diff --git a/src/parameterizations/vertical/MOM_ALE_sponge.F90 b/src/parameterizations/vertical/MOM_ALE_sponge.F90 index 2305189d9d..9409a07fc1 100644 --- a/src/parameterizations/vertical/MOM_ALE_sponge.F90 +++ b/src/parameterizations/vertical/MOM_ALE_sponge.F90 @@ -81,9 +81,6 @@ module MOM_ALE_sponge real :: scale = 1.0 !< A multiplicative factor by which to rescale input data real, dimension(:,:), pointer :: p => NULL() !< pointer the data. real, dimension(:,:), pointer :: h => NULL() !< pointer the data grid. - Character (:), allocatable :: name !< The name of the input field - Character (:), allocatable :: long_name !< The long name of the input field - Character (:), allocatable :: unit !< The unit of the input field end type p2d !> ALE sponge control structure @@ -135,7 +132,7 @@ module MOM_ALE_sponge logical :: tripolar_N !< grid is folded at its north edge !>@{ Diagnostic IDs - integer, dimension(MAX_FIELDS_) :: id_sp_tendency !< Diagnostic ids for temperature and salinity + integer, dimension(2) :: id_sp_tendency !< Diagnostic ids for temperature and salinity !! tendency due to sponges integer :: id_sp_u_tendency !< Diagnostic id for zonal momentum tendency due to !! Rayleigh damping @@ -601,19 +598,15 @@ subroutine init_ALE_sponge_diags(Time, G, diag, CS, US) !! output. type(ALE_sponge_CS), intent(inout) :: CS !< ALE sponge control structure type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type - ! Local Variables - integer :: m CS%diag => diag - do m=1,CS%fldno - CS%id_sp_tendency(m) = -1 - CS%id_sp_tendency(m) = register_diag_field('ocean_model', & - 'sp_tendency_' // CS%Ref_val(m)%name, diag%axesTL, Time, & - 'Time tendency due to restoring ' // CS%Ref_val(m)%long_name, & - CS%Ref_val(m)%unit, conversion=US%s_to_T) - enddo - + CS%id_sp_tendency(1) = -1 + CS%id_sp_tendency(1) = register_diag_field('ocean_model', 'sp_tendency_temp', diag%axesTL, Time, & + 'Time tendency due to temperature restoring', 'degC s-1', conversion=US%s_to_T) + CS%id_sp_tendency(2) = -1 + CS%id_sp_tendency(2) = register_diag_field('ocean_model', 'sp_tendency_salt', diag%axesTL, Time, & + 'Time tendency due to salinity restoring', 'g kg-1 s-1', conversion=US%s_to_T) CS%id_sp_u_tendency = -1 CS%id_sp_u_tendency = register_diag_field('ocean_model', 'sp_tendency_u', diag%axesCuL, Time, & 'Zonal acceleration due to sponges', 'm s-2', conversion=US%L_T2_to_m_s2) @@ -625,8 +618,7 @@ end subroutine init_ALE_sponge_diags !> This subroutine stores the reference profile at h points for the variable !! whose address is given by f_ptr. -subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, & - sp_name, sp_long_name, sp_unit, scale) +subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, scale) type(ocean_grid_type), intent(in) :: G !< Grid structure type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure type(ALE_sponge_CS), pointer :: CS !< ALE sponge control structure (in/out). @@ -635,27 +627,16 @@ subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, & !! arbitrary number of layers. real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), & target, intent(in) :: f_ptr !< Pointer to the field to be damped - character(len=*), intent(in) :: sp_name !< The name of the tracer field - character(len=*), optional, & - intent(in) :: sp_long_name !< The long name of the tracer field - !! if not given, use the sp_name - character(len=*), optional, & - intent(in) :: sp_unit !< The unit of the tracer field - !! if not given, use the none real, optional, intent(in) :: scale !< A factor by which to rescale the input data, including any !! contributions due to dimensional rescaling. The default is 1. real :: scale_fac ! A factor by which to scale sp_val before storing it. integer :: k, col character(len=256) :: mesg ! String for error messages - character(len=256) :: long_name ! The long name of the tracer field - character(len=256) :: unit ! The unit of the tracer field if (.not.associated(CS)) return scale_fac = 1.0 ; if (present(scale)) scale_fac = scale - long_name = sp_name; if (present(sp_long_name)) long_name = sp_long_name - unit = 'none'; if (present(sp_unit)) unit = sp_unit CS%fldno = CS%fldno + 1 if (CS%fldno > MAX_FIELDS_) then @@ -667,9 +648,6 @@ subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, & ! stores the reference profile CS%Ref_val(CS%fldno)%nz_data = CS%nz_data - CS%Ref_val(CS%fldno)%name = sp_name - CS%Ref_val(CS%fldno)%long_name = long_name - CS%Ref_val(CS%fldno)%unit = unit allocate(CS%Ref_val(CS%fldno)%p(CS%nz_data,CS%num_col), source=0.0) do col=1,CS%num_col do k=1,CS%nz_data @@ -683,8 +661,7 @@ end subroutine set_up_ALE_sponge_field_fixed !> This subroutine stores the reference profile at h points for the variable !! whose address is given by filename and fieldname. -subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, f_ptr, CS, & - sp_name, sp_long_name, sp_unit, scale) +subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, f_ptr, CS, scale) character(len=*), intent(in) :: filename !< The name of the file with the !! time varying field data character(len=*), intent(in) :: fieldname !< The name of the field in the file @@ -696,13 +673,6 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), & target, intent(in) :: f_ptr !< Pointer to the field to be damped (in). type(ALE_sponge_CS), pointer :: CS !< Sponge control structure (in/out). - character(len=*), intent(in) :: sp_name !< The name of the tracer field - character(len=*), optional, & - intent(in) :: sp_long_name !< The long name of the tracer field - !! if not given, use the sp_name - character(len=*), optional, & - intent(in) :: sp_unit !< The unit of the tracer field - !! if not given, use 'none' real, optional, intent(in) :: scale !< A factor by which to rescale the input data, including any !! contributions due to dimensional rescaling. The default is 1. @@ -711,11 +681,6 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, integer, dimension(4) :: fld_sz integer :: nz_data !< the number of vertical levels in this input field character(len=256) :: mesg ! String for error messages - character(len=256) :: long_name ! The long name of the tracer field - character(len=256) :: unit ! The unit of the tracer field - long_name = sp_name; if (present(sp_long_name)) long_name = sp_long_name - unit = 'none'; if (present(sp_unit)) unit = sp_unit - ! Local variables for ALE remapping if (.not.associated(CS)) return @@ -735,9 +700,6 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, else CS%Ref_val(CS%fldno)%id = init_external_field(filename, fieldname) endif - CS%Ref_val(CS%fldno)%name = sp_name - CS%Ref_val(CS%fldno)%long_name = long_name - CS%Ref_val(CS%fldno)%unit = unit fld_sz(1:4) = -1 call get_external_field_info(CS%Ref_val(CS%fldno)%id, size=fld_sz) nz_data = fld_sz(3) @@ -1260,8 +1222,7 @@ subroutine rotate_ALE_sponge(sponge_in, G_in, sponge, G, GV, turns, param_file) call rotate_array(sp_val_in, turns, sp_val) ! NOTE: This points sp_val with the unrotated field. See note below. - call set_up_ALE_sponge_field(sp_val, G, GV, sp_ptr, sponge, & - sponge_in%Ref_val(n)%name, sp_long_name=sponge_in%Ref_val(n)%long_name, sp_unit=sponge_in%Ref_val(n)%unit) + call set_up_ALE_sponge_field(sp_val, G, GV, sp_ptr, sponge) deallocate(sp_val_in) else diff --git a/src/tracer/RGC_tracer.F90 b/src/tracer/RGC_tracer.F90 index 4b25c58900..2921fdd124 100644 --- a/src/tracer/RGC_tracer.F90 +++ b/src/tracer/RGC_tracer.F90 @@ -232,7 +232,7 @@ subroutine initialize_RGC_tracer(restart, day, G, GV, h, diag, OBC, CS, & do m=1,1 ! This is needed to force the compiler not to do a copy in the sponge calls. tr_ptr => CS%tr(:,:,:,m) - call set_up_ALE_sponge_field(temp, G, GV, tr_ptr, sponge_CSp, 'RGC_tracer') + call set_up_ALE_sponge_field(temp, G, GV, tr_ptr, sponge_CSp) enddo deallocate(temp) endif diff --git a/src/user/DOME2d_initialization.F90 b/src/user/DOME2d_initialization.F90 index bb48fdd423..393347d1f2 100644 --- a/src/user/DOME2d_initialization.F90 +++ b/src/user/DOME2d_initialization.F90 @@ -473,10 +473,12 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A enddo enddo ; enddo - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') - if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + if ( associated(tv%T) ) then + call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) + endif + if ( associated(tv%S) ) then + call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + endif else diff --git a/src/user/ISOMIP_initialization.F90 b/src/user/ISOMIP_initialization.F90 index 8248752e78..5e91eaa86a 100644 --- a/src/user/ISOMIP_initialization.F90 +++ b/src/user/ISOMIP_initialization.F90 @@ -626,11 +626,12 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp, ! momentum is typically not damped within the sponge. ! ! The remaining calls to set_up_sponge_field can be in any order. ! - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') - if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') - + if ( associated(tv%T) ) then + call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) + endif + if ( associated(tv%S) ) then + call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + endif else ! layer mode ! 1) Read eta, salt and temp from IC file diff --git a/src/user/RGC_initialization.F90 b/src/user/RGC_initialization.F90 index 5410bc0a7d..d9c1846a0e 100644 --- a/src/user/RGC_initialization.F90 +++ b/src/user/RGC_initialization.F90 @@ -168,10 +168,8 @@ subroutine RGC_initialize_sponges(G, GV, US, tv, u, v, depth_tot, PF, use_ALE, C call initialize_ALE_sponge(Idamp, G, GV, PF, ACSp, h, nz) ! The remaining calls to set_up_sponge_field can be in any order. - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') - if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) + if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) if (sponge_uv) then U1(:,:,:) = 0.0 ; V1(:,:,:) = 0.0 diff --git a/src/user/dense_water_initialization.F90 b/src/user/dense_water_initialization.F90 index a7c5086aa4..1c372bf1b7 100644 --- a/src/user/dense_water_initialization.F90 +++ b/src/user/dense_water_initialization.F90 @@ -277,10 +277,8 @@ subroutine dense_water_initialize_sponges(G, GV, US, tv, depth_tot, param_file, enddo enddo - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') - if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + if (associated(tv%T)) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) + if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) else call MOM_error(FATAL, "dense_water_initialize_sponges: trying to use non ALE sponge") endif diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 9a510578e1..570e638465 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -446,13 +446,12 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil enddo endif enddo ; enddo - if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) else do j=G%jsc,G%jec ; do i=G%isc,G%iec eta(i,j,1) = 0.0 do k=2,nz - eta(i,j,k) = eta(i,j,k-1) - GV%H_to_Z * h_in(i,j,k-1) + eta(i,j,k) = eta(i,j,k-1)- GV%H_to_Z * h_in(i,j,k-1) enddo eta(i,j,nz+1) = -depth_tot(i,j) do k=1,nz @@ -470,4 +469,4 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil end subroutine dumbbell_initialize_sponges -end module dumbbell_initialization \ No newline at end of file +end module dumbbell_initialization From 02ed1bd33dcdc2b8268aafd9801741275f3d02c1 Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Fri, 22 Jul 2022 15:01:48 -0400 Subject: [PATCH 12/15] Fix ALE Sponge Diagnostics --- .../MOM_state_initialization.F90 | 17 ++++-- .../vertical/MOM_ALE_sponge.F90 | 59 +++++++++++++++---- src/tracer/RGC_tracer.F90 | 2 +- src/user/DOME2d_initialization.F90 | 10 ++-- src/user/ISOMIP_initialization.F90 | 11 ++-- src/user/RGC_initialization.F90 | 6 +- src/user/dense_water_initialization.F90 | 6 +- src/user/dumbbell_initialization.F90 | 7 ++- 8 files changed, 82 insertions(+), 36 deletions(-) diff --git a/src/initialization/MOM_state_initialization.F90 b/src/initialization/MOM_state_initialization.F90 index cd6ddbeca7..01d9947c6a 100644 --- a/src/initialization/MOM_state_initialization.F90 +++ b/src/initialization/MOM_state_initialization.F90 @@ -2113,9 +2113,11 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t if (use_temperature) then allocate(tmp_tr(isd:ied,jsd:jed,nz_data)) call MOM_read_data(filename, potemp_var, tmp_tr(:,:,:), G%Domain, scale=US%degC_to_C) - call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%T, ALE_CSp) + call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') call MOM_read_data(filename, salin_var, tmp_tr(:,:,:), G%Domain, scale=US%ppt_to_S) - call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp) + call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') deallocate(tmp_tr) endif if (sponge_uv) then @@ -2138,16 +2140,19 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t endif ! The remaining calls to set_up_sponge_field can be in any order. if ( use_temperature) then - call set_up_ALE_sponge_field(filename, potemp_var, Time, G, GV, US, tv%T, ALE_CSp, scale=US%C_to_degC) - call set_up_ALE_sponge_field(filename, salin_var, Time, G, GV, US, tv%S, ALE_CSp, scale=US%S_to_ppt) + call set_up_ALE_sponge_field(filename, potemp_var, Time, G, GV, US, tv%T, ALE_CSp, & + 'temp', sp_long_name='temperature', sp_unit = 'degC s-1', scale=US%degC_to_C) + call set_up_ALE_sponge_field(filename, salin_var, Time, G, GV, US, tv%S, ALE_CSp, & + 'salt', sp_long_name='salinity', sp_unit = 'g kg-1 s-1', scale=US%ppt_to_S) endif if (sponge_uv) then filename = trim(inputdir)//trim(state_uv_file) call log_param(param_file, mdl, "INPUTDIR/SPONGE_STATE_UV_FILE", filename) if (.not.file_exists(filename, G%Domain)) & call MOM_error(FATAL, " initialize_sponges: Unable to open "//trim(filename)) - call set_up_ALE_sponge_vel_field(filename, u_var, filename, v_var, Time, G, GV, US, ALE_CSp, u, v) - endif + call set_up_ALE_sponge_vel_field(filename, u_var, filename, v_var, Time, G, GV, US, & + ALE_CSp, u, v, scale=US%m_s_to_L_T) + endif endif endif diff --git a/src/parameterizations/vertical/MOM_ALE_sponge.F90 b/src/parameterizations/vertical/MOM_ALE_sponge.F90 index 9409a07fc1..2305189d9d 100644 --- a/src/parameterizations/vertical/MOM_ALE_sponge.F90 +++ b/src/parameterizations/vertical/MOM_ALE_sponge.F90 @@ -81,6 +81,9 @@ module MOM_ALE_sponge real :: scale = 1.0 !< A multiplicative factor by which to rescale input data real, dimension(:,:), pointer :: p => NULL() !< pointer the data. real, dimension(:,:), pointer :: h => NULL() !< pointer the data grid. + Character (:), allocatable :: name !< The name of the input field + Character (:), allocatable :: long_name !< The long name of the input field + Character (:), allocatable :: unit !< The unit of the input field end type p2d !> ALE sponge control structure @@ -132,7 +135,7 @@ module MOM_ALE_sponge logical :: tripolar_N !< grid is folded at its north edge !>@{ Diagnostic IDs - integer, dimension(2) :: id_sp_tendency !< Diagnostic ids for temperature and salinity + integer, dimension(MAX_FIELDS_) :: id_sp_tendency !< Diagnostic ids for temperature and salinity !! tendency due to sponges integer :: id_sp_u_tendency !< Diagnostic id for zonal momentum tendency due to !! Rayleigh damping @@ -598,15 +601,19 @@ subroutine init_ALE_sponge_diags(Time, G, diag, CS, US) !! output. type(ALE_sponge_CS), intent(inout) :: CS !< ALE sponge control structure type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type + ! Local Variables + integer :: m CS%diag => diag - CS%id_sp_tendency(1) = -1 - CS%id_sp_tendency(1) = register_diag_field('ocean_model', 'sp_tendency_temp', diag%axesTL, Time, & - 'Time tendency due to temperature restoring', 'degC s-1', conversion=US%s_to_T) - CS%id_sp_tendency(2) = -1 - CS%id_sp_tendency(2) = register_diag_field('ocean_model', 'sp_tendency_salt', diag%axesTL, Time, & - 'Time tendency due to salinity restoring', 'g kg-1 s-1', conversion=US%s_to_T) + do m=1,CS%fldno + CS%id_sp_tendency(m) = -1 + CS%id_sp_tendency(m) = register_diag_field('ocean_model', & + 'sp_tendency_' // CS%Ref_val(m)%name, diag%axesTL, Time, & + 'Time tendency due to restoring ' // CS%Ref_val(m)%long_name, & + CS%Ref_val(m)%unit, conversion=US%s_to_T) + enddo + CS%id_sp_u_tendency = -1 CS%id_sp_u_tendency = register_diag_field('ocean_model', 'sp_tendency_u', diag%axesCuL, Time, & 'Zonal acceleration due to sponges', 'm s-2', conversion=US%L_T2_to_m_s2) @@ -618,7 +625,8 @@ end subroutine init_ALE_sponge_diags !> This subroutine stores the reference profile at h points for the variable !! whose address is given by f_ptr. -subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, scale) +subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, & + sp_name, sp_long_name, sp_unit, scale) type(ocean_grid_type), intent(in) :: G !< Grid structure type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure type(ALE_sponge_CS), pointer :: CS !< ALE sponge control structure (in/out). @@ -627,16 +635,27 @@ subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, scale) !! arbitrary number of layers. real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), & target, intent(in) :: f_ptr !< Pointer to the field to be damped + character(len=*), intent(in) :: sp_name !< The name of the tracer field + character(len=*), optional, & + intent(in) :: sp_long_name !< The long name of the tracer field + !! if not given, use the sp_name + character(len=*), optional, & + intent(in) :: sp_unit !< The unit of the tracer field + !! if not given, use the none real, optional, intent(in) :: scale !< A factor by which to rescale the input data, including any !! contributions due to dimensional rescaling. The default is 1. real :: scale_fac ! A factor by which to scale sp_val before storing it. integer :: k, col character(len=256) :: mesg ! String for error messages + character(len=256) :: long_name ! The long name of the tracer field + character(len=256) :: unit ! The unit of the tracer field if (.not.associated(CS)) return scale_fac = 1.0 ; if (present(scale)) scale_fac = scale + long_name = sp_name; if (present(sp_long_name)) long_name = sp_long_name + unit = 'none'; if (present(sp_unit)) unit = sp_unit CS%fldno = CS%fldno + 1 if (CS%fldno > MAX_FIELDS_) then @@ -648,6 +667,9 @@ subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, scale) ! stores the reference profile CS%Ref_val(CS%fldno)%nz_data = CS%nz_data + CS%Ref_val(CS%fldno)%name = sp_name + CS%Ref_val(CS%fldno)%long_name = long_name + CS%Ref_val(CS%fldno)%unit = unit allocate(CS%Ref_val(CS%fldno)%p(CS%nz_data,CS%num_col), source=0.0) do col=1,CS%num_col do k=1,CS%nz_data @@ -661,7 +683,8 @@ end subroutine set_up_ALE_sponge_field_fixed !> This subroutine stores the reference profile at h points for the variable !! whose address is given by filename and fieldname. -subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, f_ptr, CS, scale) +subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, f_ptr, CS, & + sp_name, sp_long_name, sp_unit, scale) character(len=*), intent(in) :: filename !< The name of the file with the !! time varying field data character(len=*), intent(in) :: fieldname !< The name of the field in the file @@ -673,6 +696,13 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), & target, intent(in) :: f_ptr !< Pointer to the field to be damped (in). type(ALE_sponge_CS), pointer :: CS !< Sponge control structure (in/out). + character(len=*), intent(in) :: sp_name !< The name of the tracer field + character(len=*), optional, & + intent(in) :: sp_long_name !< The long name of the tracer field + !! if not given, use the sp_name + character(len=*), optional, & + intent(in) :: sp_unit !< The unit of the tracer field + !! if not given, use 'none' real, optional, intent(in) :: scale !< A factor by which to rescale the input data, including any !! contributions due to dimensional rescaling. The default is 1. @@ -681,6 +711,11 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, integer, dimension(4) :: fld_sz integer :: nz_data !< the number of vertical levels in this input field character(len=256) :: mesg ! String for error messages + character(len=256) :: long_name ! The long name of the tracer field + character(len=256) :: unit ! The unit of the tracer field + long_name = sp_name; if (present(sp_long_name)) long_name = sp_long_name + unit = 'none'; if (present(sp_unit)) unit = sp_unit + ! Local variables for ALE remapping if (.not.associated(CS)) return @@ -700,6 +735,9 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US, else CS%Ref_val(CS%fldno)%id = init_external_field(filename, fieldname) endif + CS%Ref_val(CS%fldno)%name = sp_name + CS%Ref_val(CS%fldno)%long_name = long_name + CS%Ref_val(CS%fldno)%unit = unit fld_sz(1:4) = -1 call get_external_field_info(CS%Ref_val(CS%fldno)%id, size=fld_sz) nz_data = fld_sz(3) @@ -1222,7 +1260,8 @@ subroutine rotate_ALE_sponge(sponge_in, G_in, sponge, G, GV, turns, param_file) call rotate_array(sp_val_in, turns, sp_val) ! NOTE: This points sp_val with the unrotated field. See note below. - call set_up_ALE_sponge_field(sp_val, G, GV, sp_ptr, sponge) + call set_up_ALE_sponge_field(sp_val, G, GV, sp_ptr, sponge, & + sponge_in%Ref_val(n)%name, sp_long_name=sponge_in%Ref_val(n)%long_name, sp_unit=sponge_in%Ref_val(n)%unit) deallocate(sp_val_in) else diff --git a/src/tracer/RGC_tracer.F90 b/src/tracer/RGC_tracer.F90 index 2921fdd124..4b25c58900 100644 --- a/src/tracer/RGC_tracer.F90 +++ b/src/tracer/RGC_tracer.F90 @@ -232,7 +232,7 @@ subroutine initialize_RGC_tracer(restart, day, G, GV, h, diag, OBC, CS, & do m=1,1 ! This is needed to force the compiler not to do a copy in the sponge calls. tr_ptr => CS%tr(:,:,:,m) - call set_up_ALE_sponge_field(temp, G, GV, tr_ptr, sponge_CSp) + call set_up_ALE_sponge_field(temp, G, GV, tr_ptr, sponge_CSp, 'RGC_tracer') enddo deallocate(temp) endif diff --git a/src/user/DOME2d_initialization.F90 b/src/user/DOME2d_initialization.F90 index 393347d1f2..bb48fdd423 100644 --- a/src/user/DOME2d_initialization.F90 +++ b/src/user/DOME2d_initialization.F90 @@ -473,12 +473,10 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A enddo enddo ; enddo - if ( associated(tv%T) ) then - call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) - endif - if ( associated(tv%S) ) then - call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) - endif + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') + if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') else diff --git a/src/user/ISOMIP_initialization.F90 b/src/user/ISOMIP_initialization.F90 index 5e91eaa86a..8248752e78 100644 --- a/src/user/ISOMIP_initialization.F90 +++ b/src/user/ISOMIP_initialization.F90 @@ -626,12 +626,11 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp, ! momentum is typically not damped within the sponge. ! ! The remaining calls to set_up_sponge_field can be in any order. ! - if ( associated(tv%T) ) then - call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) - endif - if ( associated(tv%S) ) then - call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) - endif + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') + if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + else ! layer mode ! 1) Read eta, salt and temp from IC file diff --git a/src/user/RGC_initialization.F90 b/src/user/RGC_initialization.F90 index d9c1846a0e..5410bc0a7d 100644 --- a/src/user/RGC_initialization.F90 +++ b/src/user/RGC_initialization.F90 @@ -168,8 +168,10 @@ subroutine RGC_initialize_sponges(G, GV, US, tv, u, v, depth_tot, PF, use_ALE, C call initialize_ALE_sponge(Idamp, G, GV, PF, ACSp, h, nz) ! The remaining calls to set_up_sponge_field can be in any order. - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) - if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') + if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') if (sponge_uv) then U1(:,:,:) = 0.0 ; V1(:,:,:) = 0.0 diff --git a/src/user/dense_water_initialization.F90 b/src/user/dense_water_initialization.F90 index 1c372bf1b7..a7c5086aa4 100644 --- a/src/user/dense_water_initialization.F90 +++ b/src/user/dense_water_initialization.F90 @@ -277,8 +277,10 @@ subroutine dense_water_initialize_sponges(G, GV, US, tv, depth_tot, param_file, enddo enddo - if (associated(tv%T)) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp) - if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + sp_long_name='temperature', sp_unit = 'degC s-1') + if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') else call MOM_error(FATAL, "dense_water_initialize_sponges: trying to use non ALE sponge") endif diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 570e638465..9a510578e1 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -446,12 +446,13 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil enddo endif enddo ; enddo - if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp) + if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & + sp_long_name='salinity', sp_unit = 'g kg-1 s-1') else do j=G%jsc,G%jec ; do i=G%isc,G%iec eta(i,j,1) = 0.0 do k=2,nz - eta(i,j,k) = eta(i,j,k-1)- GV%H_to_Z * h_in(i,j,k-1) + eta(i,j,k) = eta(i,j,k-1) - GV%H_to_Z * h_in(i,j,k-1) enddo eta(i,j,nz+1) = -depth_tot(i,j) do k=1,nz @@ -469,4 +470,4 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil end subroutine dumbbell_initialize_sponges -end module dumbbell_initialization +end module dumbbell_initialization \ No newline at end of file From b36f8089367561d6be5fb29ebd0d24191cfc7b73 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Thu, 18 Aug 2022 18:01:36 -0400 Subject: [PATCH 13/15] A minor style change removing spaces around = in optional. function arguments. --- src/initialization/MOM_state_initialization.F90 | 8 ++++---- src/user/DOME2d_initialization.F90 | 4 ++-- src/user/ISOMIP_initialization.F90 | 4 ++-- src/user/RGC_initialization.F90 | 4 ++-- src/user/dense_water_initialization.F90 | 4 ++-- src/user/dumbbell_initialization.F90 | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/initialization/MOM_state_initialization.F90 b/src/initialization/MOM_state_initialization.F90 index 8688fea955..1df08ae0a0 100644 --- a/src/initialization/MOM_state_initialization.F90 +++ b/src/initialization/MOM_state_initialization.F90 @@ -2136,10 +2136,10 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t allocate(tmp_tr(isd:ied,jsd:jed,nz_data)) call MOM_read_data(filename, potemp_var, tmp_tr(:,:,:), G%Domain, scale=US%degC_to_C) call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') + sp_long_name='temperature', sp_unit='degC s-1') call MOM_read_data(filename, salin_var, tmp_tr(:,:,:), G%Domain, scale=US%ppt_to_S) call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + sp_long_name='salinity', sp_unit='g kg-1 s-1') deallocate(tmp_tr) endif if (sponge_uv) then @@ -2163,9 +2163,9 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t ! The remaining calls to set_up_sponge_field can be in any order. if ( use_temperature) then call set_up_ALE_sponge_field(filename, potemp_var, Time, G, GV, US, tv%T, ALE_CSp, & - 'temp', sp_long_name='temperature', sp_unit = 'degC s-1', scale=US%degC_to_C) + 'temp', sp_long_name='temperature', sp_unit='degC s-1', scale=US%degC_to_C) call set_up_ALE_sponge_field(filename, salin_var, Time, G, GV, US, tv%S, ALE_CSp, & - 'salt', sp_long_name='salinity', sp_unit = 'g kg-1 s-1', scale=US%ppt_to_S) + 'salt', sp_long_name='salinity', sp_unit='g kg-1 s-1', scale=US%ppt_to_S) endif if (sponge_uv) then filename = trim(inputdir)//trim(state_uv_file) diff --git a/src/user/DOME2d_initialization.F90 b/src/user/DOME2d_initialization.F90 index 746663061b..a0aecde6d3 100644 --- a/src/user/DOME2d_initialization.F90 +++ b/src/user/DOME2d_initialization.F90 @@ -474,9 +474,9 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A enddo ; enddo if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') + sp_long_name='temperature', sp_unit='degC s-1') if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + sp_long_name='salinity', sp_unit='g kg-1 s-1') else diff --git a/src/user/ISOMIP_initialization.F90 b/src/user/ISOMIP_initialization.F90 index 8248752e78..a6b41b78c3 100644 --- a/src/user/ISOMIP_initialization.F90 +++ b/src/user/ISOMIP_initialization.F90 @@ -627,9 +627,9 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp, ! The remaining calls to set_up_sponge_field can be in any order. ! if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') + sp_long_name='temperature', sp_unit='degC s-1') if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + sp_long_name='salinity', sp_unit='g kg-1 s-1') else ! layer mode diff --git a/src/user/RGC_initialization.F90 b/src/user/RGC_initialization.F90 index 5410bc0a7d..48a36c2baa 100644 --- a/src/user/RGC_initialization.F90 +++ b/src/user/RGC_initialization.F90 @@ -169,9 +169,9 @@ subroutine RGC_initialize_sponges(G, GV, US, tv, u, v, depth_tot, PF, use_ALE, C ! The remaining calls to set_up_sponge_field can be in any order. if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') + sp_long_name='temperature', sp_unit='degC s-1') if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + sp_long_name='salinity', sp_unit='g kg-1 s-1') if (sponge_uv) then U1(:,:,:) = 0.0 ; V1(:,:,:) = 0.0 diff --git a/src/user/dense_water_initialization.F90 b/src/user/dense_water_initialization.F90 index 94309e0a73..a836e88f85 100644 --- a/src/user/dense_water_initialization.F90 +++ b/src/user/dense_water_initialization.F90 @@ -280,9 +280,9 @@ subroutine dense_water_initialize_sponges(G, GV, US, tv, depth_tot, param_file, enddo if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & - sp_long_name='temperature', sp_unit = 'degC s-1') + sp_long_name='temperature', sp_unit='degC s-1') if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + sp_long_name='salinity', sp_unit='g kg-1 s-1') else call MOM_error(FATAL, "dense_water_initialize_sponges: trying to use non ALE sponge") endif diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 02813f5ea8..762477b6c4 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -447,7 +447,7 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil endif enddo ; enddo if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & - sp_long_name='salinity', sp_unit = 'g kg-1 s-1') + sp_long_name='salinity', sp_unit='g kg-1 s-1') else do j=G%jsc,G%jec ; do i=G%isc,G%iec eta(i,j,1) = 0.0 From 60f14bc979e1dea01bbac9cf6f7b421785093dd2 Mon Sep 17 00:00:00 2001 From: WenhaoChen89 <96131003+WenhaoChen89@users.noreply.github.com> Date: Thu, 18 Aug 2022 21:45:58 -0400 Subject: [PATCH 14/15] Fix ALE sponge diagnostics --- src/initialization/MOM_state_initialization.F90 | 2 +- src/parameterizations/vertical/MOM_ALE_sponge.F90 | 8 ++++---- src/user/DOME2d_initialization.F90 | 2 +- src/user/ISOMIP_initialization.F90 | 2 +- src/user/RGC_initialization.F90 | 2 +- src/user/dense_water_initialization.F90 | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/initialization/MOM_state_initialization.F90 b/src/initialization/MOM_state_initialization.F90 index 1df08ae0a0..58a6f9ed8d 100644 --- a/src/initialization/MOM_state_initialization.F90 +++ b/src/initialization/MOM_state_initialization.F90 @@ -2135,7 +2135,7 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t if (use_temperature) then allocate(tmp_tr(isd:ied,jsd:jed,nz_data)) call MOM_read_data(filename, potemp_var, tmp_tr(:,:,:), G%Domain, scale=US%degC_to_C) - call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'temp', & + call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%T, ALE_CSp, 'temp', & sp_long_name='temperature', sp_unit='degC s-1') call MOM_read_data(filename, salin_var, tmp_tr(:,:,:), G%Domain, scale=US%ppt_to_S) call set_up_ALE_sponge_field(tmp_tr, G, GV, tv%S, ALE_CSp, 'salt', & diff --git a/src/parameterizations/vertical/MOM_ALE_sponge.F90 b/src/parameterizations/vertical/MOM_ALE_sponge.F90 index 3de4f93505..0186a351bd 100644 --- a/src/parameterizations/vertical/MOM_ALE_sponge.F90 +++ b/src/parameterizations/vertical/MOM_ALE_sponge.F90 @@ -81,9 +81,9 @@ module MOM_ALE_sponge real :: scale = 1.0 !< A multiplicative factor by which to rescale input data real, dimension(:,:), pointer :: p => NULL() !< pointer the data. real, dimension(:,:), pointer :: h => NULL() !< pointer the data grid. - Character (:), allocatable :: name !< The name of the input field - Character (:), allocatable :: long_name !< The long name of the input field - Character (:), allocatable :: unit !< The unit of the input field + Character(:), allocatable :: name !< The name of the input field + Character(:), allocatable :: long_name !< The long name of the input field + Character(:), allocatable :: unit !< The unit of the input field end type p2d !> ALE sponge control structure @@ -137,7 +137,7 @@ module MOM_ALE_sponge logical :: tripolar_N !< grid is folded at its north edge !>@{ Diagnostic IDs - integer, dimension(MAX_FIELDS_) :: id_sp_tendency !< Diagnostic ids for temperature and salinity + integer, dimension(MAX_FIELDS_) :: id_sp_tendency !< Diagnostic ids for tracers !! tendency due to sponges integer :: id_sp_u_tendency !< Diagnostic id for zonal momentum tendency due to !! Rayleigh damping diff --git a/src/user/DOME2d_initialization.F90 b/src/user/DOME2d_initialization.F90 index a0aecde6d3..a997cde26b 100644 --- a/src/user/DOME2d_initialization.F90 +++ b/src/user/DOME2d_initialization.F90 @@ -473,7 +473,7 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A enddo enddo ; enddo - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp, 'temp', & sp_long_name='temperature', sp_unit='degC s-1') if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & sp_long_name='salinity', sp_unit='g kg-1 s-1') diff --git a/src/user/ISOMIP_initialization.F90 b/src/user/ISOMIP_initialization.F90 index a6b41b78c3..aaededaa8c 100644 --- a/src/user/ISOMIP_initialization.F90 +++ b/src/user/ISOMIP_initialization.F90 @@ -626,7 +626,7 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp, ! momentum is typically not damped within the sponge. ! ! The remaining calls to set_up_sponge_field can be in any order. ! - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp, 'temp', & sp_long_name='temperature', sp_unit='degC s-1') if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & sp_long_name='salinity', sp_unit='g kg-1 s-1') diff --git a/src/user/RGC_initialization.F90 b/src/user/RGC_initialization.F90 index 48a36c2baa..b56e0b895a 100644 --- a/src/user/RGC_initialization.F90 +++ b/src/user/RGC_initialization.F90 @@ -168,7 +168,7 @@ subroutine RGC_initialize_sponges(G, GV, US, tv, u, v, depth_tot, PF, use_ALE, C call initialize_ALE_sponge(Idamp, G, GV, PF, ACSp, h, nz) ! The remaining calls to set_up_sponge_field can be in any order. - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp, 'temp', & sp_long_name='temperature', sp_unit='degC s-1') if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & sp_long_name='salinity', sp_unit='g kg-1 s-1') diff --git a/src/user/dense_water_initialization.F90 b/src/user/dense_water_initialization.F90 index a836e88f85..a81c400256 100644 --- a/src/user/dense_water_initialization.F90 +++ b/src/user/dense_water_initialization.F90 @@ -279,7 +279,7 @@ subroutine dense_water_initialize_sponges(G, GV, US, tv, depth_tot, param_file, enddo enddo - if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%S, ACSp, 'temp', & + if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp, 'temp', & sp_long_name='temperature', sp_unit='degC s-1') if ( associated(tv%S) ) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', & sp_long_name='salinity', sp_unit='g kg-1 s-1') From 059d8ae4568a76938c40473ec695d625cec79e19 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Fri, 19 Aug 2022 09:23:06 -0400 Subject: [PATCH 15/15] character declaration fix --- src/parameterizations/vertical/MOM_ALE_sponge.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parameterizations/vertical/MOM_ALE_sponge.F90 b/src/parameterizations/vertical/MOM_ALE_sponge.F90 index 0186a351bd..9f5241bb9a 100644 --- a/src/parameterizations/vertical/MOM_ALE_sponge.F90 +++ b/src/parameterizations/vertical/MOM_ALE_sponge.F90 @@ -81,9 +81,9 @@ module MOM_ALE_sponge real :: scale = 1.0 !< A multiplicative factor by which to rescale input data real, dimension(:,:), pointer :: p => NULL() !< pointer the data. real, dimension(:,:), pointer :: h => NULL() !< pointer the data grid. - Character(:), allocatable :: name !< The name of the input field - Character(:), allocatable :: long_name !< The long name of the input field - Character(:), allocatable :: unit !< The unit of the input field + character(len=:), allocatable :: name !< The name of the input field + character(len=:), allocatable :: long_name !< The long name of the input field + character(len=:), allocatable :: unit !< The unit of the input field end type p2d !> ALE sponge control structure