Skip to content

Commit e7aeb23

Browse files
committed
+Eliminated h_neglect argument to remapping_core_h
Eliminated the previously optional h_neglect and h_neglect_edge arguments to remapping_core_h and remapping_core_w, and added optional h_neglect and h_neglect_edge arguments to initialize_remapping for storage in the remapping control structures. The answer_date, h_neglect and h_neglect_edge arguments to ALE_remap_scalar were also eliminated, as they are no longer used. The new routine open_boundary_setup_vert was added to manage these changes. A new verticalGrid_type argument was added to wave_speed_init. The h_neglect argument to 29 routines was made non-optional, because there is no way to provide a consistent hard-coded default for a dimensional parameter. The (mostly low-level) routines where this change to a non-optional h_neglect was made include build_reconstructions_1d, P1M_interpolation, P3M_interpolation, P3M_boundary_extrapolation, PLM_reconstruction, PLM_boundary_extrapolation, PPM_reconstruction, PPM_limiter_standard, PPM_boundary_extrapolation, PQM_reconstruction, PQM_limiter, PQM_boundary_extrapolation_v1, build_hycom1_column, build_rho_column, bound_edge_values, edge_values_explicit_h4, edge_values_explicit_h4cw, edge_values_implicit_h4, edge_slopes_implicit_h3, edge_slopes_implicit_h5, edge_values_implicit_h6, regridding_set_ppolys, build_and_interpolate_grid, remapByProjection, remapByDeltaZ, and integrateReconOnInterval. In two modules (MOM_open_boundary and MOM_wave_speed), two separate copies of remapping_CS variables were needed to accommodate different negligible thicknesses or units in different remapping calls. In those cases that also have an optional h_neglect_edge argument the default is now set to h_neglect. Improperly hard-coded dimensional default values for h_neglect or h_neglect_edge were eliminated in 16 places as a result of this change, but they were added back in 2 unit testing routines (one of these is archaic and unused) that do not use exercise dimensional rescaling tests. Because the previously optional arguments were already present in all calls from the dev/gfdl or main branches of the MOM6 code, and because the places where arguments have been removed they are balanced by equivalent arguments added to initialize_remapping, all answers are bitwise identical in the regression tests, but this change in interfaces could impact other code that is not in the main branch of MOM6.
1 parent f1ba822 commit e7aeb23

28 files changed

+476
-577
lines changed

config_src/drivers/timing_tests/time_MOM_remapping.F90

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ program time_MOM_remapping
1717
real, dimension(nschemes) :: tmin ! Shortest time for a call [s]
1818
real, dimension(nschemes) :: tmax ! Longest time for a call [s]
1919
real, dimension(:,:), allocatable :: u0, u1 ! Source/target values [arbitrary but same units as each other]
20-
real, dimension(:,:), allocatable :: h0, h1 ! Source target thicknesses [0..1]
20+
real, dimension(:,:), allocatable :: h0, h1 ! Source target thicknesses [0..1] [nondim]
2121
real :: start, finish ! Times [s]
22+
real :: h_neglect ! A negligible thickness [nondim]
2223
real :: h0sum, h1sum ! Totals of h0 and h1 [nondim]
2324
integer :: ij, k, isamp, iter, ischeme ! Indices and counters
2425
integer :: seed_size ! Number of integers used by seed
@@ -50,6 +51,7 @@ program time_MOM_remapping
5051
h0(:,ij) = h0(:,ij) / h0sum
5152
h1(:,ij) = h1(:,ij) / h1sum
5253
enddo
54+
h_neglect = 1.0-30
5355

5456
! Loop over many samples of timing loop to collect statistics
5557
tmean(:) = 0.
@@ -59,11 +61,12 @@ program time_MOM_remapping
5961
do isamp = 1, nsamp
6062
! Time reconstruction + remapping
6163
do ischeme = 1, nschemes
62-
call initialize_remapping(CS, remapping_scheme=trim(scheme_labels(ischeme)))
64+
call initialize_remapping(CS, remapping_scheme=trim(scheme_labels(ischeme)), &
65+
h_neglect=h_neglect, h_neglect_edge=h_neglect)
6366
call cpu_time(start)
6467
do iter = 1, nits ! Make many passes to reduce sampling error
6568
do ij = 1, nij ! Calling nij times to make similar to cost in MOM_ALE()
66-
call remapping_core_h(CS, nk, h0(:,ij), u0(:,ij), nk, h1(:,ij), u1(:,ij))
69+
call remapping_core_h(CS, nk, h0(:,ij), u0(:,ij), nk, h1(:,ij), u1(:,ij), h_neglect)
6770
enddo
6871
enddo
6972
call cpu_time(finish)

src/ALE/MOM_ALE.F90

Lines changed: 27 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ subroutine ALE_init( param_file, GV, US, max_depth, CS)
181181
logical :: om4_remap_via_sub_cells
182182
type(hybgen_regrid_CS), pointer :: hybgen_regridCS => NULL() ! Control structure for hybgen regridding
183183
! for sharing parameters.
184+
real :: h_neglect, h_neglect_edge ! small thicknesses [H ~> m or kg m-2]
184185

185186
if (associated(CS)) then
186187
call MOM_error(WARNING, "ALE_init called with an associated "// &
@@ -248,20 +249,30 @@ subroutine ALE_init( param_file, GV, US, max_depth, CS)
248249
default=default_answer_date, do_not_log=.not.GV%Boussinesq)
249250
if (.not.GV%Boussinesq) CS%answer_date = max(CS%answer_date, 20230701)
250251

252+
if (CS%answer_date >= 20190101) then
253+
h_neglect = GV%H_subroundoff ; h_neglect_edge = GV%H_subroundoff
254+
elseif (GV%Boussinesq) then
255+
h_neglect = GV%m_to_H * 1.0e-30 ; h_neglect_edge = GV%m_to_H * 1.0e-10
256+
else
257+
h_neglect = GV%kg_m2_to_H * 1.0e-30 ; h_neglect_edge = GV%kg_m2_to_H * 1.0e-10
258+
endif
259+
251260
call initialize_remapping( CS%remapCS, string, &
252261
boundary_extrapolation=init_boundary_extrap, &
253262
check_reconstruction=check_reconstruction, &
254263
check_remapping=check_remapping, &
255264
force_bounds_in_subcell=force_bounds_in_subcell, &
256265
om4_remap_via_sub_cells=om4_remap_via_sub_cells, &
257-
answer_date=CS%answer_date)
266+
answer_date=CS%answer_date, &
267+
h_neglect=h_neglect, h_neglect_edge=h_neglect_edge)
258268
call initialize_remapping( CS%vel_remapCS, vel_string, &
259269
boundary_extrapolation=init_boundary_extrap, &
260270
check_reconstruction=check_reconstruction, &
261271
check_remapping=check_remapping, &
262272
force_bounds_in_subcell=force_bounds_in_subcell, &
263273
om4_remap_via_sub_cells=om4_remap_via_sub_cells, &
264-
answer_date=CS%answer_date)
274+
answer_date=CS%answer_date, &
275+
h_neglect=h_neglect, h_neglect_edge=h_neglect_edge)
265276

266277
call get_param(param_file, mdl, "PARTIAL_CELL_VELOCITY_REMAP", CS%partial_cell_vel_remap, &
267278
"If true, use partial cell thicknesses at velocity points that are masked out "//&
@@ -345,7 +356,7 @@ subroutine ALE_set_OM4_remap_algorithm( CS, om4_remap_via_sub_cells )
345356
type(ALE_CS), pointer :: CS !< Module control structure
346357
logical, intent(in) :: om4_remap_via_sub_cells !< If true, use OM4 remapping algorithm
347358

348-
call remapping_set_param(CS%remapCS, om4_remap_via_sub_cells =om4_remap_via_sub_cells )
359+
call remapping_set_param(CS%remapCS, om4_remap_via_sub_cells=om4_remap_via_sub_cells )
349360

350361
end subroutine ALE_set_OM4_remap_algorithm
351362

@@ -591,8 +602,8 @@ subroutine ALE_offline_inputs(CS, G, GV, US, h, tv, Reg, uhtr, vhtr, Kd, debug,
591602
endif
592603
enddo ; enddo
593604

594-
call ALE_remap_scalar(CS%remapCS, G, GV, nk, h, tv%T, h_new, tv%T, answer_date=CS%answer_date)
595-
call ALE_remap_scalar(CS%remapCS, G, GV, nk, h, tv%S, h_new, tv%S, answer_date=CS%answer_date)
605+
call ALE_remap_scalar(CS%remapCS, G, GV, nk, h, tv%T, h_new, tv%T)
606+
call ALE_remap_scalar(CS%remapCS, G, GV, nk, h, tv%S, h_new, tv%S)
596607

597608
if (debug) call MOM_tracer_chkinv("After ALE_offline_inputs", G, GV, h_new, Reg%Tr, Reg%ntr)
598609

@@ -653,7 +664,6 @@ subroutine ALE_regrid_accelerated(CS, G, GV, US, h, tv, n_itt, u, v, OBC, Reg, d
653664
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: dzInterface ! Interface height changes within
654665
! an iteration [H ~> m or kg m-2]
655666
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: dzIntTotal ! Cumulative interface position changes [H ~> m or kg m-2]
656-
real :: h_neglect, h_neglect_edge ! small thicknesses [H ~> m or kg m-2]
657667

658668
nz = GV%ke
659669

@@ -680,14 +690,6 @@ subroutine ALE_regrid_accelerated(CS, G, GV, US, h, tv, n_itt, u, v, OBC, Reg, d
680690
if (present(dt)) &
681691
call ALE_update_regrid_weights(dt, CS)
682692

683-
if (CS%answer_date >= 20190101) then
684-
h_neglect = GV%H_subroundoff ; h_neglect_edge = GV%H_subroundoff
685-
elseif (GV%Boussinesq) then
686-
h_neglect = GV%m_to_H * 1.0e-30 ; h_neglect_edge = GV%m_to_H * 1.0e-10
687-
else
688-
h_neglect = GV%kg_m2_to_H * 1.0e-30 ; h_neglect_edge = GV%kg_m2_to_H * 1.0e-10
689-
endif
690-
691693
do itt = 1, n_itt
692694

693695
call do_group_pass(pass_T_S_h, G%domain)
@@ -704,10 +706,8 @@ subroutine ALE_regrid_accelerated(CS, G, GV, US, h, tv, n_itt, u, v, OBC, Reg, d
704706

705707
! remap from original grid onto new grid
706708
do j = G%jsc-1,G%jec+1 ; do i = G%isc-1,G%iec+1
707-
call remapping_core_h(CS%remapCS, nz, h_orig(i,j,:), tv%S(i,j,:), nz, h(i,j,:), tv_local%S(i,j,:), &
708-
h_neglect, h_neglect_edge)
709-
call remapping_core_h(CS%remapCS, nz, h_orig(i,j,:), tv%T(i,j,:), nz, h(i,j,:), tv_local%T(i,j,:), &
710-
h_neglect, h_neglect_edge)
709+
call remapping_core_h(CS%remapCS, nz, h_orig(i,j,:), tv%S(i,j,:), nz, h(i,j,:), tv_local%S(i,j,:))
710+
call remapping_core_h(CS%remapCS, nz, h_orig(i,j,:), tv%T(i,j,:), nz, h(i,j,:), tv_local%T(i,j,:))
711711
enddo ; enddo
712712

713713
! starting grid for next iteration
@@ -763,22 +763,13 @@ subroutine ALE_remap_tracers(CS, G, GV, h_old, h_new, Reg, debug, dt, PCM_cell)
763763
real :: Idt ! The inverse of the timestep [T-1 ~> s-1]
764764
real :: h1(GV%ke) ! A column of source grid layer thicknesses [H ~> m or kg m-2]
765765
real :: h2(GV%ke) ! A column of target grid layer thicknesses [H ~> m or kg m-2]
766-
real :: h_neglect, h_neglect_edge ! Tiny thicknesses used in remapping [H ~> m or kg m-2]
767766
logical :: show_call_tree
768767
type(tracer_type), pointer :: Tr => NULL()
769768
integer :: i, j, k, m, nz, ntr
770769

771770
show_call_tree = .false.
772771
if (present(debug)) show_call_tree = debug
773772

774-
if (CS%answer_date >= 20190101) then
775-
h_neglect = GV%H_subroundoff ; h_neglect_edge = GV%H_subroundoff
776-
elseif (GV%Boussinesq) then
777-
h_neglect = GV%m_to_H*1.0e-30 ; h_neglect_edge = GV%m_to_H*1.0e-10
778-
else
779-
h_neglect = GV%kg_m2_to_H*1.0e-30 ; h_neglect_edge = GV%kg_m2_to_H*1.0e-10
780-
endif
781-
782773
if (show_call_tree) call callTree_enter("ALE_remap_tracers(), MOM_ALE.F90")
783774

784775
nz = GV%ke
@@ -803,11 +794,9 @@ subroutine ALE_remap_tracers(CS, G, GV, h_old, h_new, Reg, debug, dt, PCM_cell)
803794
h2(:) = h_new(i,j,:)
804795
if (present(PCM_cell)) then
805796
PCM(:) = PCM_cell(i,j,:)
806-
call remapping_core_h(CS%remapCS, nz, h1, Tr%t(i,j,:), nz, h2, tr_column, &
807-
h_neglect, h_neglect_edge, PCM_cell=PCM)
797+
call remapping_core_h(CS%remapCS, nz, h1, Tr%t(i,j,:), nz, h2, tr_column, PCM_cell=PCM)
808798
else
809-
call remapping_core_h(CS%remapCS, nz, h1, Tr%t(i,j,:), nz, h2, tr_column, &
810-
h_neglect, h_neglect_edge)
799+
call remapping_core_h(CS%remapCS, nz, h1, Tr%t(i,j,:), nz, h2, tr_column)
811800
endif
812801

813802
! Possibly underflow any very tiny tracer concentrations to 0. Note that this is not conservative!
@@ -1091,22 +1080,13 @@ subroutine ALE_remap_velocities(CS, G, GV, h_old_u, h_old_v, h_new_u, h_new_v, u
10911080
real :: v_tgt(GV%ke) ! A column of v-velocities on the target grid [L T-1 ~> m s-1]
10921081
real :: h1(GV%ke) ! A column of source grid layer thicknesses [H ~> m or kg m-2]
10931082
real :: h2(GV%ke) ! A column of target grid layer thicknesses [H ~> m or kg m-2]
1094-
real :: h_neglect, h_neglect_edge ! Tiny thicknesses used in remapping [H ~> m or kg m-2]
10951083
logical :: show_call_tree
10961084
integer :: i, j, k, nz
10971085

10981086
show_call_tree = .false.
10991087
if (present(debug)) show_call_tree = debug
11001088
if (show_call_tree) call callTree_enter("ALE_remap_velocities()")
11011089

1102-
if (CS%answer_date >= 20190101) then
1103-
h_neglect = GV%H_subroundoff ; h_neglect_edge = GV%H_subroundoff
1104-
elseif (GV%Boussinesq) then
1105-
h_neglect = GV%m_to_H*1.0e-30 ; h_neglect_edge = GV%m_to_H*1.0e-10
1106-
else
1107-
h_neglect = GV%kg_m2_to_H*1.0e-30 ; h_neglect_edge = GV%kg_m2_to_H*1.0e-10
1108-
endif
1109-
11101090
nz = GV%ke
11111091

11121092
! --- Remap u profiles from the source vertical grid onto the new target grid.
@@ -1120,8 +1100,7 @@ subroutine ALE_remap_velocities(CS, G, GV, h_old_u, h_old_v, h_new_u, h_new_v, u
11201100
u_src(k) = u(I,j,k)
11211101
enddo
11221102

1123-
call remapping_core_h(CS%vel_remapCS, nz, h1, u_src, nz, h2, u_tgt, &
1124-
h_neglect, h_neglect_edge)
1103+
call remapping_core_h(CS%vel_remapCS, nz, h1, u_src, nz, h2, u_tgt)
11251104

11261105
if ((CS%BBL_h_vel_mask > 0.0) .and. (CS%h_vel_mask > 0.0)) &
11271106
call mask_near_bottom_vel(u_tgt, h2, CS%BBL_h_vel_mask, CS%h_vel_mask, nz)
@@ -1146,8 +1125,7 @@ subroutine ALE_remap_velocities(CS, G, GV, h_old_u, h_old_v, h_new_u, h_new_v, u
11461125
v_src(k) = v(i,J,k)
11471126
enddo
11481127

1149-
call remapping_core_h(CS%vel_remapCS, nz, h1, v_src, nz, h2, v_tgt, &
1150-
h_neglect, h_neglect_edge)
1128+
call remapping_core_h(CS%vel_remapCS, nz, h1, v_src, nz, h2, v_tgt)
11511129

11521130
if ((CS%BBL_h_vel_mask > 0.0) .and. (CS%h_vel_mask > 0.0)) then
11531131
call mask_near_bottom_vel(v_tgt, h2, CS%BBL_h_vel_mask, CS%h_vel_mask, nz)
@@ -1300,8 +1278,7 @@ end subroutine mask_near_bottom_vel
13001278
!> Remaps a single scalar between grids described by thicknesses h_src and h_dst.
13011279
!! h_dst must be dimensioned as a model array with GV%ke layers while h_src can
13021280
!! have an arbitrary number of layers specified by nk_src.
1303-
subroutine ALE_remap_scalar(CS, G, GV, nk_src, h_src, s_src, h_dst, s_dst, all_cells, old_remap, &
1304-
answers_2018, answer_date, h_neglect, h_neglect_edge)
1281+
subroutine ALE_remap_scalar(CS, G, GV, nk_src, h_src, s_src, h_dst, s_dst, all_cells, old_remap)
13051282
type(remapping_CS), intent(in) :: CS !< Remapping control structure
13061283
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
13071284
type(verticalGrid_type), intent(in) :: GV !< Ocean vertical grid structure
@@ -1319,44 +1296,16 @@ subroutine ALE_remap_scalar(CS, G, GV, nk_src, h_src, s_src, h_dst, s_dst, all_c
13191296
!! layers otherwise (default).
13201297
logical, optional, intent(in) :: old_remap !< If true, use the old "remapping_core_w"
13211298
!! method, otherwise use "remapping_core_h".
1322-
logical, optional, intent(in) :: answers_2018 !< If true, use the order of arithmetic
1323-
!! and expressions that recover the answers for
1324-
!! remapping from the end of 2018. Otherwise,
1325-
!! use more robust forms of the same expressions.
1326-
integer, optional, intent(in) :: answer_date !< The vintage of the expressions to use
1327-
!! for remapping
1328-
real, optional, intent(in) :: h_neglect !< A negligibly small thickness used in
1329-
!! remapping cell reconstructions, in the same
1330-
!! units as h_src, often [H ~> m or kg m-2]
1331-
real, optional, intent(in) :: h_neglect_edge !< A negligibly small thickness used in
1332-
!! remapping edge value calculations, in the same
1333-
!! units as h_src, often [H ~> m or kg m-2]
1334-
! Local variables
1299+
! Local variables
13351300
integer :: i, j, k, n_points
13361301
real :: dx(GV%ke+1) ! Change in interface position [H ~> m or kg m-2]
1337-
real :: h_neg, h_neg_edge ! Tiny thicknesses used in remapping [H ~> m or kg m-2]
1338-
logical :: ignore_vanished_layers, use_remapping_core_w, use_2018_remap
1302+
logical :: ignore_vanished_layers, use_remapping_core_w
13391303

13401304
ignore_vanished_layers = .false.
13411305
if (present(all_cells)) ignore_vanished_layers = .not. all_cells
13421306
use_remapping_core_w = .false.
13431307
if (present(old_remap)) use_remapping_core_w = old_remap
13441308
n_points = nk_src
1345-
use_2018_remap = .true. ; if (present(answers_2018)) use_2018_remap = answers_2018
1346-
if (present(answer_date)) use_2018_remap = (answer_date < 20190101)
1347-
1348-
if (present(h_neglect)) then
1349-
h_neg = h_neglect
1350-
h_neg_edge = h_neg ; if (present(h_neglect_edge)) h_neg_edge = h_neglect_edge
1351-
else
1352-
if (.not.use_2018_remap) then
1353-
h_neg = GV%H_subroundoff ; h_neg_edge = GV%H_subroundoff
1354-
elseif (GV%Boussinesq) then
1355-
h_neg = GV%m_to_H*1.0e-30 ; h_neg_edge = GV%m_to_H*1.0e-10
1356-
else
1357-
h_neg = GV%kg_m2_to_H*1.0e-30 ; h_neg_edge = GV%kg_m2_to_H*1.0e-10
1358-
endif
1359-
endif
13601309

13611310
!$OMP parallel do default(shared) firstprivate(n_points,dx)
13621311
do j = G%jsc,G%jec ; do i = G%isc,G%iec
@@ -1371,10 +1320,10 @@ subroutine ALE_remap_scalar(CS, G, GV, nk_src, h_src, s_src, h_dst, s_dst, all_c
13711320
if (use_remapping_core_w) then
13721321
call dzFromH1H2( n_points, h_src(i,j,1:n_points), GV%ke, h_dst(i,j,:), dx )
13731322
call remapping_core_w(CS, n_points, h_src(i,j,1:n_points), s_src(i,j,1:n_points), &
1374-
GV%ke, dx, s_dst(i,j,:), h_neg, h_neg_edge)
1323+
GV%ke, dx, s_dst(i,j,:))
13751324
else
13761325
call remapping_core_h(CS, n_points, h_src(i,j,1:n_points), s_src(i,j,1:n_points), &
1377-
GV%ke, h_dst(i,j,:), s_dst(i,j,:), h_neg, h_neg_edge)
1326+
GV%ke, h_dst(i,j,:), s_dst(i,j,:))
13781327
endif
13791328
else
13801329
s_dst(i,j,:) = 0.

0 commit comments

Comments
 (0)