Skip to content

Commit

Permalink
(*)Pass dz to user initialize_ALE_sponge calls
Browse files Browse the repository at this point in the history
  Pass vertical extents (dz in [Z ~> m]) instead of thicknesses (h in
[H ~> m or kg m-2] and use data_h_is_Z flag in calls to initialize_ALE_sponge
calls from 5 user modules and avoid extra calls to dz_to_thickness in these
routines.  All Boussinesq solutions are bitwise identical, but in any
non-Boussinesq configurations using ALE sponges, the previous conversion from dz
to thickness and back again can change dz in the last bits, so some
non-Boussinesq answers could change.
  • Loading branch information
Hallberg-NOAA authored and marshallward committed Apr 10, 2024
1 parent a71fbce commit 2d121dc
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 55 deletions.
10 changes: 0 additions & 10 deletions src/initialization/MOM_state_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,6 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t
character(len=40) :: mdl = "initialize_sponges_file"
character(len=200) :: damping_file, uv_damping_file, state_file, state_uv_file ! Strings for filenames
character(len=200) :: filename, inputdir ! Strings for file/path and path.
type(verticalGrid_type) :: GV_loc ! A temporary vertical grid structure

logical :: use_ALE ! True if ALE is being used, False if in layered mode
logical :: time_space_interp_sponge ! If true use sponge data that need to be interpolated in both
Expand Down Expand Up @@ -2102,21 +2101,13 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t
enddo; enddo ; enddo
deallocate(eta)

allocate(h(isd:ied,jsd:jed,nz_data))
if (use_temperature) then
allocate(tmp_T(isd:ied,jsd:jed,nz_data))
allocate(tmp_S(isd:ied,jsd:jed,nz_data))
call MOM_read_data(filename, potemp_var, tmp_T(:,:,:), G%Domain, scale=US%degC_to_C)
call MOM_read_data(filename, salin_var, tmp_S(:,:,:), G%Domain, scale=US%ppt_to_S)
endif

GV_loc = GV ; GV_loc%ke = nz_data
if (use_temperature .and. associated(tv%eqn_of_state)) then
call dz_to_thickness(dz, tmp_T, tmp_S, tv%eqn_of_state, h, G, GV_loc, US)
else
call dz_to_thickness_simple(dz, h, G, GV_loc, US, layer_mode=.true.)
endif

if (sponge_uv) then
call initialize_ALE_sponge(Idamp, G, GV, param_file, ALE_CSp, dz, nz_data, Idamp_u, Idamp_v, &
data_h_is_Z=.true.)
Expand All @@ -2132,7 +2123,6 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t
deallocate(tmp_S)
deallocate(tmp_T)
endif
deallocate(h)
deallocate(dz)

if (sponge_uv) then
Expand Down
12 changes: 1 addition & 11 deletions src/user/DOME2d_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module DOME2d_initialization
use MOM_file_parser, only : get_param, log_version, param_file_type
use MOM_get_input, only : directories
use MOM_grid, only : ocean_grid_type
use MOM_interface_heights, only : dz_to_thickness, dz_to_thickness_simple
use MOM_sponge, only : sponge_CS, set_up_sponge_field, initialize_sponge
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : thermo_var_ptrs
Expand Down Expand Up @@ -375,7 +374,6 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A
real :: T(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for temp [C ~> degC]
real :: S(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for salt [S ~> ppt]
real :: dz(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for thickness in height units [Z ~> m]
real :: h(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for thickness [H ~> m or kg m-2]
real :: eta(SZI_(G),SZJ_(G),SZK_(GV)+1) ! A temporary array for interface heights [Z ~> m]
real :: Idamp(SZI_(G),SZJ_(G)) ! The sponge damping rate [T-1 ~> s-1]
real :: S_ref ! Reference salinity within the surface layer [S ~> ppt]
Expand Down Expand Up @@ -466,7 +464,6 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A
endif
enddo ; enddo


if (use_ALE) then

! Construct a grid (somewhat arbitrarily) to describe the sponge T/S on
Expand Down Expand Up @@ -502,15 +499,8 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A
enddo
enddo ; enddo

! Convert thicknesses from height units to thickness units
if (associated(tv%eqn_of_state)) then
call dz_to_thickness(dz, T, S, tv%eqn_of_state, h, G, GV, US)
else
call dz_to_thickness_simple(dz, h, G, GV, US, layer_mode=.true.)
endif

! Store damping rates and the grid on which the T/S sponge data will reside
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, h, nz)
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, dz, nz, data_h_is_Z=.true.)

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')
Expand Down
11 changes: 1 addition & 10 deletions src/user/ISOMIP_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module ISOMIP_initialization
use MOM_file_parser, only : get_param, log_version, param_file_type
use MOM_get_input, only : directories
use MOM_grid, only : ocean_grid_type
use MOM_interface_heights, only : dz_to_thickness
use MOM_io, only : file_exists, MOM_read_data, slasher
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : thermo_var_ptrs
Expand Down Expand Up @@ -458,7 +457,6 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp,
real :: S(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for salt [S ~> ppt]
! real :: RHO(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for RHO [R ~> kg m-3]
real :: dz(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge layer thicknesses in height units [Z ~> m]
real :: h(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge layer thicknesses [H ~> m or kg m-2]
real :: Idamp(SZI_(G),SZJ_(G)) ! The sponge damping rate [T-1 ~> s-1]
real :: TNUDG ! Nudging time scale [T ~> s]
real :: S_sur, S_bot ! Surface and bottom salinities in the sponge region [S ~> ppt]
Expand Down Expand Up @@ -624,13 +622,6 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp,
enddo
enddo ; enddo

! Convert thicknesses from height units to thickness units
if (associated(tv%eqn_of_state)) then
call dz_to_thickness(dz, T, S, tv%eqn_of_state, h, G, GV, US)
else
call MOM_error(FATAL, "The ISOMIP test case requires an equation of state.")
endif

! for debugging
!i=G%iec; j=G%jec
!do k = 1,nz
Expand All @@ -640,7 +631,7 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp,
!enddo

! This call sets up the damping rates and interface heights in the sponges.
call initialize_ALE_sponge(Idamp, G, GV, PF, ACSp, h, nz)
call initialize_ALE_sponge(Idamp, G, GV, PF, ACSp, dz, nz, data_h_is_Z=.true.)

! Now register all of the fields which are damped in the sponge. !
! By default, momentum is advected vertically within the sponge, but !
Expand Down
8 changes: 4 additions & 4 deletions src/user/RGC_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ subroutine RGC_initialize_sponges(G, GV, US, tv, u, v, depth_tot, PF, use_ALE, C
real :: U1(SZIB_(G),SZJ_(G),SZK_(GV)) ! A temporary array for u [L T-1 ~> m s-1]
real :: V1(SZI_(G),SZJB_(G),SZK_(GV)) ! A temporary array for v [L T-1 ~> m s-1]
real :: tmp(SZI_(G),SZJ_(G)) ! A temporary array for tracers.
real :: h(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for thickness at h points [H ~> m or kg m-2]
real :: dz(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge layer thicknesses in height units [Z ~> m]
real :: Idamp(SZI_(G),SZJ_(G)) ! The sponge damping rate at h points [T-1 ~> s-1]
real :: TNUDG ! Nudging time scale [T ~> s]
real :: pres(SZI_(G)) ! An array of the reference pressure [R L2 T-2 ~> Pa]
Expand Down Expand Up @@ -153,10 +153,10 @@ subroutine RGC_initialize_sponges(G, GV, US, tv, u, v, depth_tot, PF, use_ALE, C
call MOM_read_data(filename, salt_var, S(:,:,:), G%Domain, scale=US%ppt_to_S)
if (use_ALE) then

call MOM_read_data(filename, h_var, h(:,:,:), G%Domain, scale=GV%m_to_H)
call pass_var(h, G%domain)
call MOM_read_data(filename, h_var, dz(:,:,:), G%Domain, scale=US%m_to_Z)
call pass_var(dz, G%domain)

call initialize_ALE_sponge(Idamp, G, GV, PF, ACSp, h, nz)
call initialize_ALE_sponge(Idamp, G, GV, PF, ACSp, dz, nz, data_h_is_Z=.true.)

! 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, 'temp', &
Expand Down
11 changes: 1 addition & 10 deletions src/user/dense_water_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module dense_water_initialization
use MOM_EOS, only : EOS_type
use MOM_error_handler, only : MOM_error, FATAL
use MOM_file_parser, only : get_param, param_file_type
use MOM_interface_heights, only : dz_to_thickness, dz_to_thickness_simple
use MOM_grid, only : ocean_grid_type
use MOM_sponge, only : sponge_CS
use MOM_unit_scaling, only : unit_scale_type
Expand Down Expand Up @@ -174,7 +173,6 @@ subroutine dense_water_initialize_sponges(G, GV, US, tv, depth_tot, param_file,

real, dimension(SZI_(G),SZJ_(G)) :: Idamp ! inverse damping timescale [T-1 ~> s-1]
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: dz ! sponge layer thicknesses in height units [Z ~> m]
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: h ! sponge layer thicknesses [H ~> m or kg m-2]
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: T ! sponge temperature [C ~> degC]
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: S ! sponge salinity [S ~> ppt]
real, dimension(SZK_(GV)+1) :: e0, eta1D ! interface positions for ALE sponge [Z ~> m]
Expand Down Expand Up @@ -293,15 +291,8 @@ subroutine dense_water_initialize_sponges(G, GV, US, tv, depth_tot, param_file,
enddo
enddo

! Convert thicknesses from height units to thickness units
if (associated(tv%eqn_of_state)) then
call dz_to_thickness(dz, T, S, tv%eqn_of_state, h, G, GV, US)
else
call dz_to_thickness_simple(dz, h, G, GV, US, layer_mode=.true.)
endif

! This call sets up the damping rates and interface heights in the sponges.
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, h, nz)
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, dz, nz, data_h_is_Z=.true.)

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')
Expand Down
11 changes: 1 addition & 10 deletions src/user/dumbbell_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module dumbbell_initialization
use MOM_file_parser, only : get_param, log_version, param_file_type
use MOM_get_input, only : directories
use MOM_grid, only : ocean_grid_type
use MOM_interface_heights, only : dz_to_thickness, dz_to_thickness_simple
use MOM_interface_heights, only : thickness_to_dz
use MOM_sponge, only : set_up_sponge_field, initialize_sponge, sponge_CS
use MOM_tracer_registry, only : tracer_registry_type
Expand Down Expand Up @@ -352,7 +351,6 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil

real, dimension(SZI_(G),SZJ_(G)) :: Idamp ! inverse damping timescale [T-1 ~> s-1]
real :: dz(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge thicknesses in height units [Z ~> m]
real :: h(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge thicknesses [H ~> m or kg m-2]
real :: S(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge salinities [S ~> ppt]
real :: T(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge tempertures [C ~> degC], used only to convert thicknesses
! in non-Boussinesq mode
Expand Down Expand Up @@ -460,15 +458,8 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil
endif
enddo ; enddo

! Convert thicknesses from height units to thickness units
if (associated(tv%eqn_of_state)) then
call dz_to_thickness(dz, T, S, tv%eqn_of_state, h, G, GV, US)
else
call dz_to_thickness_simple(dz, h, G, GV, US, layer_mode=.true.)
endif

! Store damping rates and the grid on which the T/S sponge data will reside
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, h, nz)
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, dz, nz, data_h_is_Z=.true.)

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')
Expand Down

0 comments on commit 2d121dc

Please sign in to comment.