diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index 2126535dd1..b3a2ce4593 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -971,9 +971,9 @@ subroutine step_MOM(fluxes, state, Time_start, time_interval, CS) call do_group_pass(CS%pass_uv_T_S_h, G%Domain) call cpu_clock_end(id_clock_pass) - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. + call diag_update_target_grids(CS%diag) if (CS%debug) then call uchksum(u,"Post-dia first u", G, haloshift=2) @@ -1050,9 +1050,9 @@ subroutine step_MOM(fluxes, state, Time_start, time_interval, CS) call disable_averaging(CS%diag) if (showCallTree) call callTree_waypoint("finished thickness_diffuse_first (step_MOM)") - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. + call diag_update_target_grids(CS%diag) endif endif @@ -1273,9 +1273,10 @@ subroutine step_MOM(fluxes, state, Time_start, time_interval, CS) endif endif - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. This needs to + ! happen after the H update and before the next post_data. + call diag_update_target_grids(CS%diag) call cpu_clock_begin(id_clock_pass) call do_group_pass(CS%pass_uv_T_S_h, G%Domain) @@ -2017,9 +2018,9 @@ subroutine initialize_MOM(Time, param_file, dirs, CS, Time_in) ! e.g. to generate the target grids below. call set_axes_info(G, param_file, diag) - ! The diag mediator may need to (re)generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. This needs to + call diag_update_target_grids(diag) call cpu_clock_begin(id_clock_MOM_init) if (CS%use_ALE_algorithm) then diff --git a/src/core/MOM_continuity.F90 b/src/core/MOM_continuity.F90 index b0556eaf06..0f62976a4f 100644 --- a/src/core/MOM_continuity.F90 +++ b/src/core/MOM_continuity.F90 @@ -72,7 +72,7 @@ module MOM_continuity contains -subroutine continuity(u, v, hin, h, uh, vh, dt, G, CS, uhbt, vhbt, OBC, & +subroutine continuity(u, v, hin, h, uh, vh, dt, G, CS, diag_cs, uhbt, vhbt, OBC, & visc_rem_u, visc_rem_v, u_cor, v_cor, & uhbt_aux, vhbt_aux, u_cor_aux, v_cor_aux, BT_cont) real, intent(in), dimension(NIMEMB_,NJMEM_,NKMEM_) :: u @@ -84,6 +84,7 @@ subroutine continuity(u, v, hin, h, uh, vh, dt, G, CS, uhbt, vhbt, OBC, & real, intent(in) :: dt type(ocean_grid_type), intent(inout) :: G type(continuity_CS), pointer :: CS + type(diag_ctrl), intent(inout) :: diag_cs real, intent(in), optional, dimension(NIMEMB_,NJMEM_) :: uhbt real, intent(in), optional, dimension(NIMEM_,NJMEMB_) :: vhbt type(ocean_OBC_type), pointer, optional :: OBC @@ -150,7 +151,7 @@ subroutine continuity(u, v, hin, h, uh, vh, dt, G, CS, uhbt, vhbt, OBC, & " or neither.") if (CS%continuity_scheme == PPM_SCHEME) then - call continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS%PPM_CSp, uhbt, vhbt, OBC, & + call continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS%PPM_CSp, diag_cs, uhbt, vhbt, OBC, & visc_rem_u, visc_rem_v, u_cor, v_cor, & uhbt_aux, vhbt_aux, u_cor_aux, v_cor_aux, BT_cont) else diff --git a/src/core/MOM_continuity_PPM.F90 b/src/core/MOM_continuity_PPM.F90 index 949173d072..552aff2aad 100644 --- a/src/core/MOM_continuity_PPM.F90 +++ b/src/core/MOM_continuity_PPM.F90 @@ -44,7 +44,7 @@ module MOM_continuity_PPM !********+*********+*********+*********+*********+*********+*********+** use MOM_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end, CLOCK_ROUTINE -use MOM_diag_mediator, only : time_type, diag_ctrl +use MOM_diag_mediator, only : time_type, diag_ctrl, diag_update_target_grids use MOM_error_handler, only : MOM_error, FATAL, WARNING, is_root_pe use MOM_file_parser, only : get_param, log_version, param_file_type use MOM_grid, only : ocean_grid_type @@ -103,7 +103,7 @@ module MOM_continuity_PPM contains -subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS, uhbt, vhbt, OBC, & +subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS, diag_cs, uhbt, vhbt, OBC, & visc_rem_u, visc_rem_v, u_cor, v_cor, & uhbt_aux, vhbt_aux, u_cor_aux, v_cor_aux, BT_cont) real, dimension(NIMEMB_,NJMEM_,NKMEM_), intent(in) :: u @@ -115,6 +115,7 @@ subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS, uhbt, vhbt, OBC, & real, intent(in) :: dt type(ocean_grid_type), intent(inout) :: G type(continuity_PPM_CS), pointer :: CS + type(diag_ctrl), intent(inout) :: diag_cs real, dimension(NIMEMB_,NJMEM_), intent(in), optional :: uhbt real, dimension(NIMEM_,NJMEMB_), intent(in), optional :: vhbt type(ocean_OBC_type), pointer, optional :: OBC @@ -316,6 +317,10 @@ subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS, uhbt, vhbt, OBC, & endif endif + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. + call diag_update_target_grids(diag_cs) + end subroutine continuity_PPM subroutine zonal_mass_flux(u, h_in, uh, dt, G, CS, LB, uhbt, OBC, & diff --git a/src/core/MOM_dynamics_legacy_split.F90 b/src/core/MOM_dynamics_legacy_split.F90 index 68e4767215..20ddf14572 100644 --- a/src/core/MOM_dynamics_legacy_split.F90 +++ b/src/core/MOM_dynamics_legacy_split.F90 @@ -588,7 +588,7 @@ subroutine step_MOM_dyn_legacy_split(u, v, h, tv, visc, & if (CS%readjust_velocity) then ! Adjust the input velocites so that their transports match uhbt_out & vhbt_out. call continuity(u, v, h, hp, uh_in, vh_in, dt, G, & - CS%continuity_CSp, uhbt_in, vhbt_in, CS%OBC, & + CS%continuity_CSp, CS%diag, uhbt_in, vhbt_in, CS%OBC, & CS%visc_rem_u, CS%visc_rem_v, u_adj, v_adj, & BT_cont=CS%BT_cont) u_init => u_adj ; v_init => v_adj @@ -601,7 +601,7 @@ subroutine step_MOM_dyn_legacy_split(u, v, h, tv, visc, & CS%readjust_velocity = .false. else call continuity(u, v, h, hp, uh_in, vh_in, dt, G, & - CS%continuity_CSp, OBC=CS%OBC, BT_cont=CS%BT_cont) + CS%continuity_CSp, CS%diag, OBC=CS%OBC, BT_cont=CS%BT_cont) !### call continuity(u, v, h, hp, uh_in, vh_in, dt, G, & !### CS%continuity_CSp, OBC=CS%OBC, visc_rem_u=CS%visc_rem_u, & !### visc_rem_v=CS%visc_rem_v, BT_cont=CS%BT_cont) @@ -631,8 +631,9 @@ subroutine step_MOM_dyn_legacy_split(u, v, h, tv, visc, & if (associated(CS%BT_cont) .or. CS%BT_use_layer_fluxes) then call cpu_clock_begin(id_clock_continuity) call continuity(u, v, h, hp, uh_in, vh_in, dt, G, & - CS%continuity_CSp, OBC=CS%OBC, visc_rem_u=CS%visc_rem_u, & - visc_rem_v=CS%visc_rem_v, BT_cont=CS%BT_cont) + CS%continuity_CSp, CS%diag, OBC=CS%OBC, & + visc_rem_u=CS%visc_rem_u, visc_rem_v=CS%visc_rem_v, & + BT_cont=CS%BT_cont) call cpu_clock_end(id_clock_continuity) if (BT_cont_BT_thick) then call cpu_clock_begin(id_clock_pass) @@ -716,8 +717,8 @@ subroutine step_MOM_dyn_legacy_split(u, v, h, tv, visc, & ! hp = h + dt * div . uh call cpu_clock_begin(id_clock_continuity) call continuity(up, vp, h, hp, uh, vh, dt, G, CS%continuity_CSp, & - CS%uhbt, CS%vhbt, CS%OBC, CS%visc_rem_u, CS%visc_rem_v, & - u_av, v_av, BT_cont=CS%BT_cont) + CS%diag, CS%uhbt, CS%vhbt, CS%OBC, CS%visc_rem_u, & + CS%visc_rem_v, u_av, v_av, BT_cont=CS%BT_cont) call cpu_clock_end(id_clock_continuity) call cpu_clock_begin(id_clock_pass) @@ -927,7 +928,7 @@ subroutine step_MOM_dyn_legacy_split(u, v, h, tv, visc, & enddo ; enddo ; enddo ; endif call cpu_clock_begin(id_clock_continuity) call continuity(u, v, h, h, uh, vh, dt, G, & - CS%continuity_CSp, CS%uhbt, CS%vhbt, CS%OBC, & + CS%continuity_CSp, CS%diag, CS%uhbt, CS%vhbt, CS%OBC, & CS%visc_rem_u, CS%visc_rem_v, u_av, v_av, & uhbt_out, vhbt_out, u, v) call cpu_clock_end(id_clock_continuity) @@ -966,7 +967,7 @@ subroutine step_MOM_dyn_legacy_split(u, v, h, tv, visc, & ! u_av and v_av adjusted so their mass transports match uhbt and vhbt. call cpu_clock_begin(id_clock_continuity) call continuity(u, v, h, h, uh, vh, dt, G, & - CS%continuity_CSp, CS%uhbt, CS%vhbt, CS%OBC, & + CS%continuity_CSp, CS%diag, CS%uhbt, CS%vhbt, CS%OBC, & CS%visc_rem_u, CS%visc_rem_v, u_av, v_av) call cpu_clock_end(id_clock_continuity) call cpu_clock_begin(id_clock_pass) @@ -1066,7 +1067,7 @@ subroutine adjustments_dyn_legacy_split(u, v, h, dt, G, CS) if (CS%readjust_BT_trans) then call cpu_clock_begin(id_clock_continuity) call continuity(u, v, h, h_temp, uh_temp, vh_temp, dt, G, & - CS%continuity_CSp, OBC=CS%OBC) + CS%continuity_CSp, CS%diag, OBC=CS%OBC) call cpu_clock_end(id_clock_continuity) !$OMP parallel default(none) shared(is,ie,js,je,nz,CS,uh_temp,vh_temp) !$OMP do @@ -1406,7 +1407,7 @@ subroutine initialize_dyn_legacy_split(u, v, h, uh, vh, eta, Time, G, param_file if (.not. query_initialized(uh,"uh",restart_CS) .or. & .not. query_initialized(vh,"vh",restart_CS)) then h_tmp(:,:,:) = h(:,:,:) - call continuity(u, v, h, h_tmp, uh, vh, dt, G, CS%continuity_CSp, OBC=CS%OBC) + call continuity(u, v, h, h_tmp, uh, vh, dt, G, CS%continuity_CSp, CS%diag, OBC=CS%OBC) call cpu_clock_begin(id_clock_pass_init) call pass_var(h_tmp, G%Domain) call cpu_clock_end(id_clock_pass_init) diff --git a/src/core/MOM_dynamics_split_RK2.F90 b/src/core/MOM_dynamics_split_RK2.F90 index 996d4bf13f..39f9d86e3b 100644 --- a/src/core/MOM_dynamics_split_RK2.F90 +++ b/src/core/MOM_dynamics_split_RK2.F90 @@ -605,7 +605,7 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, & if (associated(CS%BT_cont) .or. CS%BT_use_layer_fluxes) then call cpu_clock_begin(id_clock_continuity) call continuity(u, v, h, hp, uh_in, vh_in, dt, G, & - CS%continuity_CSp, OBC=CS%OBC, visc_rem_u=CS%visc_rem_u, & + CS%continuity_CSp, CS%diag, OBC=CS%OBC, visc_rem_u=CS%visc_rem_u, & visc_rem_v=CS%visc_rem_v, BT_cont=CS%BT_cont) call cpu_clock_end(id_clock_continuity) if (BT_cont_BT_thick) then @@ -695,16 +695,12 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, & ! uh = u_av * h ! hp = h + dt * div . uh call cpu_clock_begin(id_clock_continuity) - call continuity(up, vp, h, hp, uh, vh, dt, G, CS%continuity_CSp, & + call continuity(up, vp, h, hp, uh, vh, dt, G, CS%continuity_CSp, CS%diag, & CS%uhbt, CS%vhbt, CS%OBC, CS%visc_rem_u, CS%visc_rem_v, & u_av, v_av, BT_cont=CS%BT_cont) call cpu_clock_end(id_clock_continuity) if (showCallTree) call callTree_wayPoint("done with continuity (step_MOM_dyn_split_RK2)") - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) - call cpu_clock_begin(id_clock_pass) call do_group_pass(CS%pass_hp_uv, G%Domain) if (G%nonblocking_updates) then @@ -905,7 +901,7 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, & ! u_av and v_av adjusted so their mass transports match uhbt and vhbt. call cpu_clock_begin(id_clock_continuity) call continuity(u, v, h, h, uh, vh, dt, G, & - CS%continuity_CSp, CS%uhbt, CS%vhbt, CS%OBC, & + CS%continuity_CSp, CS%diag, CS%uhbt, CS%vhbt, CS%OBC, & CS%visc_rem_u, CS%visc_rem_v, u_av, v_av) call cpu_clock_end(id_clock_continuity) call cpu_clock_begin(id_clock_pass) @@ -913,10 +909,6 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, & call cpu_clock_end(id_clock_pass) if (showCallTree) call callTree_wayPoint("done with continuity (step_MOM_dyn_split_RK2)") - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) - call cpu_clock_begin(id_clock_pass) if (G%nonblocking_updates) then call start_group_pass(CS%pass_av_uvh, G%Domain) @@ -1266,7 +1258,7 @@ subroutine initialize_dyn_split_RK2(u, v, h, uh, vh, eta, Time, G, param_file, & if (.not. query_initialized(uh,"uh",restart_CS) .or. & .not. query_initialized(vh,"vh",restart_CS)) then h_tmp(:,:,:) = h(:,:,:) - call continuity(u, v, h, h_tmp, uh, vh, dt, G, CS%continuity_CSp, OBC=CS%OBC) + call continuity(u, v, h, h_tmp, uh, vh, dt, G, CS%continuity_CSp, CS%diag, OBC=CS%OBC) call cpu_clock_begin(id_clock_pass_init) call create_group_pass(pass_h_tmp, h_tmp, G%Domain) call do_group_pass(pass_h_tmp, G%Domain) @@ -1277,8 +1269,6 @@ subroutine initialize_dyn_split_RK2(u, v, h, uh, vh, eta, Time, G, param_file, & CS%h_av(:,:,:) = h(:,:,:) endif - call diag_update_target_grids(G, CS%diag) - call cpu_clock_begin(id_clock_pass_init) call create_group_pass(pass_av_h_uvh, CS%u_av,CS%v_av, G%Domain) call create_group_pass(pass_av_h_uvh, CS%h_av, G%Domain) diff --git a/src/core/MOM_dynamics_unsplit.F90 b/src/core/MOM_dynamics_unsplit.F90 index dd36f3aa19..9c51432819 100644 --- a/src/core/MOM_dynamics_unsplit.F90 +++ b/src/core/MOM_dynamics_unsplit.F90 @@ -268,7 +268,8 @@ subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, fluxes, & ! uh = u*h ! hp = h + dt/2 div . uh call cpu_clock_begin(id_clock_continuity) - call continuity(u, v, h, hp, uh, vh, dt*0.5, G, CS%continuity_CSp, OBC=CS%OBC) + call continuity(u, v, h, hp, uh, vh, dt*0.5, G, CS%continuity_CSp, CS%diag, & + OBC=CS%OBC) call cpu_clock_end(id_clock_continuity) call cpu_clock_begin(id_clock_pass) call pass_var(hp, G%Domain) @@ -377,7 +378,7 @@ subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, fluxes, & ! h_av = hp + dt/2 div . uh call cpu_clock_begin(id_clock_continuity) call continuity(up, vp, hp, h_av, uh, vh, & - (0.5*dt), G, CS%continuity_CSp, OBC=CS%OBC) + (0.5*dt), G, CS%continuity_CSp, CS%diag, OBC=CS%OBC) call cpu_clock_end(id_clock_continuity) call cpu_clock_begin(id_clock_pass) call pass_var(h_av, G%Domain) @@ -436,7 +437,7 @@ subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, fluxes, & ! h = hp + dt/2 div . uh call cpu_clock_begin(id_clock_continuity) call continuity(upp, vpp, hp, h, uh, vh, & - (dt*0.5), G, CS%continuity_CSp, OBC=CS%OBC) + (dt*0.5), G, CS%continuity_CSp, CS%diag, OBC=CS%OBC) call cpu_clock_end(id_clock_continuity) call cpu_clock_begin(id_clock_pass) call pass_var(h, G%Domain) diff --git a/src/core/MOM_dynamics_unsplit_RK2.F90 b/src/core/MOM_dynamics_unsplit_RK2.F90 index 57edff0a20..87a8b2052f 100644 --- a/src/core/MOM_dynamics_unsplit_RK2.F90 +++ b/src/core/MOM_dynamics_unsplit_RK2.F90 @@ -282,7 +282,8 @@ subroutine step_MOM_dyn_unsplit_RK2(u_in, v_in, h_in, tv, visc, Time_local, dt, call cpu_clock_begin(id_clock_continuity) ! This is a duplicate caclulation of the last continuity from the previous step ! and could/should be optimized out. -AJA - call continuity(u_in, v_in, h_in, hp, uh, vh, dt_pred, G, CS%continuity_CSp, OBC=CS%OBC) + call continuity(u_in, v_in, h_in, hp, uh, vh, dt_pred, G, CS%continuity_CSp, & + CS%diag, OBC=CS%OBC) call cpu_clock_end(id_clock_continuity) call cpu_clock_begin(id_clock_pass) call pass_var(hp, G%Domain) @@ -369,7 +370,7 @@ subroutine step_MOM_dyn_unsplit_RK2(u_in, v_in, h_in, tv, visc, Time_local, dt, ! h_av = h + dt div . uh call cpu_clock_begin(id_clock_continuity) call continuity(up, vp, h_in, hp, uh, vh, & - dt, G, CS%continuity_CSp, OBC=CS%OBC) + dt, G, CS%continuity_CSp, CS%diag, OBC=CS%OBC) call cpu_clock_end(id_clock_continuity) call cpu_clock_begin(id_clock_pass) call pass_var(hp, G%Domain) @@ -426,7 +427,7 @@ subroutine step_MOM_dyn_unsplit_RK2(u_in, v_in, h_in, tv, visc, Time_local, dt, ! h[n+1] = h[n] + dt div . uh call cpu_clock_begin(id_clock_continuity) call continuity(up, vp, h_in, h_in, uh, vh, & - dt, G, CS%continuity_CSp, OBC=CS%OBC) + dt, G, CS%continuity_CSp, CS%diag, OBC=CS%OBC) call cpu_clock_end(id_clock_continuity) call cpu_clock_begin(id_clock_pass) call pass_var(h_in, G%Domain) diff --git a/src/framework/MOM_diag_mediator.F90 b/src/framework/MOM_diag_mediator.F90 index c897ccbe5c..bedd86ab14 100644 --- a/src/framework/MOM_diag_mediator.F90 +++ b/src/framework/MOM_diag_mediator.F90 @@ -58,6 +58,8 @@ module MOM_diag_mediator #define DIM_J(a) lbound(a, 2):ubound(a, 2) #define DIM_K(a) lbound(a, 3):ubound(a, 3) +#define __DO_SAFETY_CHECKS__ + public set_axes_info, post_data, register_diag_field, time_type public post_data_1d_k public safe_alloc_ptr, safe_alloc_alloc @@ -755,20 +757,19 @@ subroutine remap_diag_to_z(field, diag, diag_cs, remapped_field) end subroutine remap_diag_to_z -subroutine diag_update_target_grids(G, diag_cs) +subroutine diag_update_target_grids(diag_cs) ! Build/update target vertical grids for diagnostic remapping. ! ! The target grids need to be updated whenever sea surface ! height changes. - type(ocean_grid_type), intent(in) :: G type(diag_ctrl), intent(inout) :: diag_cs ! Arguments: -! (in) G - ocean grid structure. ! (inout) diag_cs - structure used to regulate diagnostic output. real, dimension(size(diag_cs%h, 3)) :: h_src + type(ocean_grid_type), pointer :: G real :: depth integer :: nz_src, nz_dest integer :: i, j, k @@ -776,6 +777,7 @@ subroutine diag_update_target_grids(G, diag_cs) nz_dest = diag_cs%nz_remap nz_src = size(diag_cs%h, 3) + G => diag_cs%G if (.not. diag_cs%remapping_initialized) then call assert(allocated(diag_cs%zi_remap), & diff --git a/src/parameterizations/lateral/MOM_mixed_layer_restrat.F90 b/src/parameterizations/lateral/MOM_mixed_layer_restrat.F90 index 00064b9067..41286a7a87 100644 --- a/src/parameterizations/lateral/MOM_mixed_layer_restrat.F90 +++ b/src/parameterizations/lateral/MOM_mixed_layer_restrat.F90 @@ -395,9 +395,10 @@ subroutine mixedlayer_restrat_general(h, uhtr, vhtr, tv, fluxes, dt, G, CS) enddo ; enddo ; enddo !$OMP end parallel - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. + ! This needs to happen after the H update and before the next post_data. + call diag_update_target_grids(CS%diag) ! Offer fields for averaging. if (query_averaging_enabled(CS%diag)) then @@ -649,9 +650,9 @@ subroutine mixedlayer_restrat_BML(h, uhtr, vhtr, tv, fluxes, dt, G, CS) enddo ; enddo ; enddo !$OMP end parallel - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. + call diag_update_target_grids(CS%diag) ! Offer fields for averaging. if (query_averaging_enabled(CS%diag) .and. & diff --git a/src/parameterizations/lateral/MOM_thickness_diffuse.F90 b/src/parameterizations/lateral/MOM_thickness_diffuse.F90 index 5e6ca27ebc..680134381a 100644 --- a/src/parameterizations/lateral/MOM_thickness_diffuse.F90 +++ b/src/parameterizations/lateral/MOM_thickness_diffuse.F90 @@ -339,9 +339,10 @@ subroutine thickness_diffuse(h, uhtr, vhtr, tv, dt, G, MEKE, VarMix, CDp, CS) enddo ; enddo enddo - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. + ! This needs to happen after the H update and before the next post_data. + call diag_update_target_grids(CS%diag) if (MEKE_not_null .AND. ASSOCIATED(VarMix)) then if (ASSOCIATED(MEKE%Rd_dx_h) .and. ASSOCIATED(VarMix%Rd_dx_h)) then diff --git a/src/parameterizations/vertical/MOM_bulk_mixed_layer.F90 b/src/parameterizations/vertical/MOM_bulk_mixed_layer.F90 index 5cdf994fcb..a1313727b3 100644 --- a/src/parameterizations/vertical/MOM_bulk_mixed_layer.F90 +++ b/src/parameterizations/vertical/MOM_bulk_mixed_layer.F90 @@ -805,9 +805,10 @@ subroutine bulkmixedlayer(h_3d, u_3d, v_3d, tv, fluxes, dt, ea, eb, G, CS, & enddo ! j loop - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. + ! This needs to happen after the H update and before the next post_data. + call diag_update_target_grids(CS%diag) !$OMP end parallel diff --git a/src/parameterizations/vertical/MOM_diabatic_driver.F90 b/src/parameterizations/vertical/MOM_diabatic_driver.F90 index 06ad550324..157a0119ec 100644 --- a/src/parameterizations/vertical/MOM_diabatic_driver.F90 +++ b/src/parameterizations/vertical/MOM_diabatic_driver.F90 @@ -408,9 +408,9 @@ subroutine diabatic(u, v, h, tv, fluxes, visc, ADp, CDp, dt, G, CS) if (CS%debugConservation) call MOM_state_stats('geothermal', u, v, h, tv%T, tv%S, G) endif - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. + call diag_update_target_grids(CS%diag) ! Set_opacity estimates the optical properties of the water column. ! It will need to be modified later to include information about the @@ -907,9 +907,9 @@ subroutine diabatic(u, v, h, tv, fluxes, visc, ADp, CDp, dt, G, CS) if (CS%debugConservation) call MOM_state_stats('regularize_layers', u, v, h, tv%T, tv%S, G) endif - ! The diag mediator may need to re-generate target grids for remmapping when - ! total thickness changes. - call diag_update_target_grids(G, CS%diag) + ! Whenever thickness changes let the diag manager know, target grids + ! for vertical remapping may need to be regenerated. + call diag_update_target_grids(CS%diag) if ((CS%id_Tdif > 0) .or. (CS%id_Tdif_z > 0) .or. & (CS%id_Tadv > 0) .or. (CS%id_Tadv_z > 0)) then