Skip to content

Commit 2d121dc

Browse files
Hallberg-NOAAmarshallward
authored andcommitted
(*)Pass dz to user initialize_ALE_sponge calls
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.
1 parent a71fbce commit 2d121dc

6 files changed

Lines changed: 8 additions & 55 deletions

src/initialization/MOM_state_initialization.F90

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,6 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t
19151915
character(len=40) :: mdl = "initialize_sponges_file"
19161916
character(len=200) :: damping_file, uv_damping_file, state_file, state_uv_file ! Strings for filenames
19171917
character(len=200) :: filename, inputdir ! Strings for file/path and path.
1918-
type(verticalGrid_type) :: GV_loc ! A temporary vertical grid structure
19191918

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

2105-
allocate(h(isd:ied,jsd:jed,nz_data))
21062104
if (use_temperature) then
21072105
allocate(tmp_T(isd:ied,jsd:jed,nz_data))
21082106
allocate(tmp_S(isd:ied,jsd:jed,nz_data))
21092107
call MOM_read_data(filename, potemp_var, tmp_T(:,:,:), G%Domain, scale=US%degC_to_C)
21102108
call MOM_read_data(filename, salin_var, tmp_S(:,:,:), G%Domain, scale=US%ppt_to_S)
21112109
endif
21122110

2113-
GV_loc = GV ; GV_loc%ke = nz_data
2114-
if (use_temperature .and. associated(tv%eqn_of_state)) then
2115-
call dz_to_thickness(dz, tmp_T, tmp_S, tv%eqn_of_state, h, G, GV_loc, US)
2116-
else
2117-
call dz_to_thickness_simple(dz, h, G, GV_loc, US, layer_mode=.true.)
2118-
endif
2119-
21202111
if (sponge_uv) then
21212112
call initialize_ALE_sponge(Idamp, G, GV, param_file, ALE_CSp, dz, nz_data, Idamp_u, Idamp_v, &
21222113
data_h_is_Z=.true.)
@@ -2132,7 +2123,6 @@ subroutine initialize_sponges_file(G, GV, US, use_temperature, tv, u, v, depth_t
21322123
deallocate(tmp_S)
21332124
deallocate(tmp_T)
21342125
endif
2135-
deallocate(h)
21362126
deallocate(dz)
21372127

21382128
if (sponge_uv) then

src/user/DOME2d_initialization.F90

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module DOME2d_initialization
99
use MOM_file_parser, only : get_param, log_version, param_file_type
1010
use MOM_get_input, only : directories
1111
use MOM_grid, only : ocean_grid_type
12-
use MOM_interface_heights, only : dz_to_thickness, dz_to_thickness_simple
1312
use MOM_sponge, only : sponge_CS, set_up_sponge_field, initialize_sponge
1413
use MOM_unit_scaling, only : unit_scale_type
1514
use MOM_variables, only : thermo_var_ptrs
@@ -375,7 +374,6 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A
375374
real :: T(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for temp [C ~> degC]
376375
real :: S(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for salt [S ~> ppt]
377376
real :: dz(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for thickness in height units [Z ~> m]
378-
real :: h(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for thickness [H ~> m or kg m-2]
379377
real :: eta(SZI_(G),SZJ_(G),SZK_(GV)+1) ! A temporary array for interface heights [Z ~> m]
380378
real :: Idamp(SZI_(G),SZJ_(G)) ! The sponge damping rate [T-1 ~> s-1]
381379
real :: S_ref ! Reference salinity within the surface layer [S ~> ppt]
@@ -466,7 +464,6 @@ subroutine DOME2d_initialize_sponges(G, GV, US, tv, depth_tot, param_file, use_A
466464
endif
467465
enddo ; enddo
468466

469-
470467
if (use_ALE) then
471468

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

505-
! Convert thicknesses from height units to thickness units
506-
if (associated(tv%eqn_of_state)) then
507-
call dz_to_thickness(dz, T, S, tv%eqn_of_state, h, G, GV, US)
508-
else
509-
call dz_to_thickness_simple(dz, h, G, GV, US, layer_mode=.true.)
510-
endif
511-
512502
! Store damping rates and the grid on which the T/S sponge data will reside
513-
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, h, nz)
503+
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, dz, nz, data_h_is_Z=.true.)
514504

515505
if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp, 'temp', &
516506
sp_long_name='temperature', sp_unit='degC s-1')

src/user/ISOMIP_initialization.F90

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module ISOMIP_initialization
1010
use MOM_file_parser, only : get_param, log_version, param_file_type
1111
use MOM_get_input, only : directories
1212
use MOM_grid, only : ocean_grid_type
13-
use MOM_interface_heights, only : dz_to_thickness
1413
use MOM_io, only : file_exists, MOM_read_data, slasher
1514
use MOM_unit_scaling, only : unit_scale_type
1615
use MOM_variables, only : thermo_var_ptrs
@@ -458,7 +457,6 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp,
458457
real :: S(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for salt [S ~> ppt]
459458
! real :: RHO(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for RHO [R ~> kg m-3]
460459
real :: dz(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge layer thicknesses in height units [Z ~> m]
461-
real :: h(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge layer thicknesses [H ~> m or kg m-2]
462460
real :: Idamp(SZI_(G),SZJ_(G)) ! The sponge damping rate [T-1 ~> s-1]
463461
real :: TNUDG ! Nudging time scale [T ~> s]
464462
real :: S_sur, S_bot ! Surface and bottom salinities in the sponge region [S ~> ppt]
@@ -624,13 +622,6 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp,
624622
enddo
625623
enddo ; enddo
626624

627-
! Convert thicknesses from height units to thickness units
628-
if (associated(tv%eqn_of_state)) then
629-
call dz_to_thickness(dz, T, S, tv%eqn_of_state, h, G, GV, US)
630-
else
631-
call MOM_error(FATAL, "The ISOMIP test case requires an equation of state.")
632-
endif
633-
634625
! for debugging
635626
!i=G%iec; j=G%jec
636627
!do k = 1,nz
@@ -640,7 +631,7 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp,
640631
!enddo
641632

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

645636
! Now register all of the fields which are damped in the sponge. !
646637
! By default, momentum is advected vertically within the sponge, but !

src/user/RGC_initialization.F90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ subroutine RGC_initialize_sponges(G, GV, US, tv, u, v, depth_tot, PF, use_ALE, C
6363
real :: U1(SZIB_(G),SZJ_(G),SZK_(GV)) ! A temporary array for u [L T-1 ~> m s-1]
6464
real :: V1(SZI_(G),SZJB_(G),SZK_(GV)) ! A temporary array for v [L T-1 ~> m s-1]
6565
real :: tmp(SZI_(G),SZJ_(G)) ! A temporary array for tracers.
66-
real :: h(SZI_(G),SZJ_(G),SZK_(GV)) ! A temporary array for thickness at h points [H ~> m or kg m-2]
66+
real :: dz(SZI_(G),SZJ_(G),SZK_(GV)) ! Sponge layer thicknesses in height units [Z ~> m]
6767
real :: Idamp(SZI_(G),SZJ_(G)) ! The sponge damping rate at h points [T-1 ~> s-1]
6868
real :: TNUDG ! Nudging time scale [T ~> s]
6969
real :: pres(SZI_(G)) ! An array of the reference pressure [R L2 T-2 ~> Pa]
@@ -153,10 +153,10 @@ subroutine RGC_initialize_sponges(G, GV, US, tv, u, v, depth_tot, PF, use_ALE, C
153153
call MOM_read_data(filename, salt_var, S(:,:,:), G%Domain, scale=US%ppt_to_S)
154154
if (use_ALE) then
155155

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

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

161161
! The remaining calls to set_up_sponge_field can be in any order.
162162
if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp, 'temp', &

src/user/dense_water_initialization.F90

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module dense_water_initialization
99
use MOM_EOS, only : EOS_type
1010
use MOM_error_handler, only : MOM_error, FATAL
1111
use MOM_file_parser, only : get_param, param_file_type
12-
use MOM_interface_heights, only : dz_to_thickness, dz_to_thickness_simple
1312
use MOM_grid, only : ocean_grid_type
1413
use MOM_sponge, only : sponge_CS
1514
use MOM_unit_scaling, only : unit_scale_type
@@ -174,7 +173,6 @@ subroutine dense_water_initialize_sponges(G, GV, US, tv, depth_tot, param_file,
174173

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

296-
! Convert thicknesses from height units to thickness units
297-
if (associated(tv%eqn_of_state)) then
298-
call dz_to_thickness(dz, T, S, tv%eqn_of_state, h, G, GV, US)
299-
else
300-
call dz_to_thickness_simple(dz, h, G, GV, US, layer_mode=.true.)
301-
endif
302-
303294
! This call sets up the damping rates and interface heights in the sponges.
304-
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, h, nz)
295+
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, dz, nz, data_h_is_Z=.true.)
305296

306297
if ( associated(tv%T) ) call set_up_ALE_sponge_field(T, G, GV, tv%T, ACSp, 'temp', &
307298
sp_long_name='temperature', sp_unit='degC s-1')

src/user/dumbbell_initialization.F90

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module dumbbell_initialization
99
use MOM_file_parser, only : get_param, log_version, param_file_type
1010
use MOM_get_input, only : directories
1111
use MOM_grid, only : ocean_grid_type
12-
use MOM_interface_heights, only : dz_to_thickness, dz_to_thickness_simple
1312
use MOM_interface_heights, only : thickness_to_dz
1413
use MOM_sponge, only : set_up_sponge_field, initialize_sponge, sponge_CS
1514
use MOM_tracer_registry, only : tracer_registry_type
@@ -352,7 +351,6 @@ subroutine dumbbell_initialize_sponges(G, GV, US, tv, h_in, depth_tot, param_fil
352351

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

463-
! Convert thicknesses from height units to thickness units
464-
if (associated(tv%eqn_of_state)) then
465-
call dz_to_thickness(dz, T, S, tv%eqn_of_state, h, G, GV, US)
466-
else
467-
call dz_to_thickness_simple(dz, h, G, GV, US, layer_mode=.true.)
468-
endif
469-
470461
! Store damping rates and the grid on which the T/S sponge data will reside
471-
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, h, nz)
462+
call initialize_ALE_sponge(Idamp, G, GV, param_file, ACSp, dz, nz, data_h_is_Z=.true.)
472463

473464
if (associated(tv%S)) call set_up_ALE_sponge_field(S, G, GV, tv%S, ACSp, 'salt', &
474465
sp_long_name='salinity', sp_unit='g kg-1 s-1')

0 commit comments

Comments
 (0)