Skip to content

Commit

Permalink
Move calls to update grid for z remapping of diagnostics out of
Browse files Browse the repository at this point in the history
continuity(). It is not necessary to pass the diag mediator structure
into calls to continuity(). #62
  • Loading branch information
nichannah committed Jul 22, 2015
1 parent d485907 commit 8008eea
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 30 deletions.
5 changes: 2 additions & 3 deletions src/core/MOM_continuity.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module MOM_continuity

contains

subroutine continuity(u, v, hin, h, uh, vh, dt, G, CS, diag_cs, uhbt, vhbt, OBC, &
subroutine continuity(u, v, hin, h, uh, vh, dt, G, 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
Expand All @@ -84,7 +84,6 @@ subroutine continuity(u, v, hin, h, uh, vh, dt, G, CS, diag_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
Expand Down Expand Up @@ -151,7 +150,7 @@ subroutine continuity(u, v, hin, h, uh, vh, dt, G, CS, diag_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, diag_cs, uhbt, vhbt, OBC, &
call continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS%PPM_CSp, 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
Expand Down
9 changes: 2 additions & 7 deletions src/core/MOM_continuity_PPM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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, diag_update_target_grids
use MOM_diag_mediator, only : time_type, diag_ctrl
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
Expand Down Expand Up @@ -103,7 +103,7 @@ module MOM_continuity_PPM

contains

subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS, diag_cs, uhbt, vhbt, OBC, &
subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, 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
Expand All @@ -115,7 +115,6 @@ subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS, diag_cs, uhbt, vhbt,
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
Expand Down Expand Up @@ -317,10 +316,6 @@ subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, CS, diag_cs, uhbt, vhbt,
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, &
Expand Down
24 changes: 15 additions & 9 deletions src/core/MOM_dynamics_legacy_split.F90
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module MOM_dynamics_legacy_split
use MOM_diag_mediator, only : diag_mediator_init, enable_averaging
use MOM_diag_mediator, only : disable_averaging, post_data, safe_alloc_ptr
use MOM_diag_mediator, only : register_diag_field, register_static_field
use MOM_diag_mediator, only : set_diag_mediator_grid, diag_ctrl
use MOM_diag_mediator, only : set_diag_mediator_grid, diag_ctrl, diag_update_target_grids
use MOM_domains, only : MOM_domains_init, pass_var, pass_vector
use MOM_domains, only : pass_var_start, pass_var_complete
use MOM_domains, only : pass_vector_start, pass_vector_complete
Expand Down Expand Up @@ -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, CS%diag, uhbt_in, vhbt_in, CS%OBC, &
CS%continuity_CSp, 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
Expand All @@ -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, CS%diag, OBC=CS%OBC, BT_cont=CS%BT_cont)
CS%continuity_CSp, 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)
Expand Down Expand Up @@ -631,7 +631,7 @@ 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, CS%diag, OBC=CS%OBC, &
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)
call cpu_clock_end(id_clock_continuity)
Expand Down Expand Up @@ -717,7 +717,7 @@ 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%diag, CS%uhbt, CS%vhbt, CS%OBC, CS%visc_rem_u, &
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)

Expand Down Expand Up @@ -928,10 +928,13 @@ 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%diag, CS%uhbt, CS%vhbt, CS%OBC, &
CS%continuity_CSp, 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)
! 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 (G%nonblocking_updates) then
call cpu_clock_begin(id_clock_pass)
pid_h = pass_var_start(h, G%Domain)
Expand Down Expand Up @@ -967,9 +970,12 @@ 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%diag, CS%uhbt, CS%vhbt, CS%OBC, &
CS%continuity_CSp, 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)
! 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)
call cpu_clock_begin(id_clock_pass)
call pass_var(h, G%Domain)
call cpu_clock_end(id_clock_pass)
Expand Down Expand Up @@ -1067,7 +1073,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, CS%diag, OBC=CS%OBC)
CS%continuity_CSp, 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
Expand Down Expand Up @@ -1407,7 +1413,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, CS%diag, OBC=CS%OBC)
call continuity(u, v, h, h_tmp, uh, vh, dt, G, CS%continuity_CSp, 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)
Expand Down
11 changes: 7 additions & 4 deletions src/core/MOM_dynamics_split_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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, CS%diag, OBC=CS%OBC, visc_rem_u=CS%visc_rem_u, &
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)
call cpu_clock_end(id_clock_continuity)
if (BT_cont_BT_thick) then
Expand Down Expand Up @@ -695,7 +695,7 @@ 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, CS%diag, &
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)
call cpu_clock_end(id_clock_continuity)
Expand Down Expand Up @@ -901,9 +901,12 @@ 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%diag, CS%uhbt, CS%vhbt, CS%OBC, &
CS%continuity_CSp, 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)
! 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)
call cpu_clock_begin(id_clock_pass)
call do_group_pass(CS%pass_h, G%Domain)
call cpu_clock_end(id_clock_pass)
Expand Down Expand Up @@ -1258,7 +1261,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, CS%diag, OBC=CS%OBC)
call continuity(u, v, h, h_tmp, uh, vh, dt, G, CS%continuity_CSp, 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)
Expand Down
11 changes: 7 additions & 4 deletions src/core/MOM_dynamics_unsplit.F90
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module MOM_dynamics_unsplit
use MOM_diag_mediator, only : diag_mediator_init, enable_averaging
use MOM_diag_mediator, only : disable_averaging, post_data, safe_alloc_ptr
use MOM_diag_mediator, only : register_diag_field, register_static_field
use MOM_diag_mediator, only : set_diag_mediator_grid, diag_ctrl
use MOM_diag_mediator, only : set_diag_mediator_grid, diag_ctrl, diag_update_target_grids
use MOM_domains, only : MOM_domains_init, pass_var, pass_vector
use MOM_domains, only : pass_var_start, pass_var_complete
use MOM_domains, only : pass_vector_start, pass_vector_complete
Expand Down Expand Up @@ -268,7 +268,7 @@ 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, CS%diag, &
call continuity(u, v, h, hp, uh, vh, dt*0.5, G, CS%continuity_CSp, &
OBC=CS%OBC)
call cpu_clock_end(id_clock_continuity)
call cpu_clock_begin(id_clock_pass)
Expand Down Expand Up @@ -378,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, CS%diag, OBC=CS%OBC)
(0.5*dt), G, CS%continuity_CSp, OBC=CS%OBC)
call cpu_clock_end(id_clock_continuity)
call cpu_clock_begin(id_clock_pass)
call pass_var(h_av, G%Domain)
Expand Down Expand Up @@ -437,8 +437,11 @@ 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, CS%diag, OBC=CS%OBC)
(dt*0.5), G, CS%continuity_CSp, OBC=CS%OBC)
call cpu_clock_end(id_clock_continuity)
! 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)
call cpu_clock_begin(id_clock_pass)
call pass_var(h, G%Domain)
call pass_vector(uh, vh, G%Domain)
Expand Down
6 changes: 3 additions & 3 deletions src/core/MOM_dynamics_unsplit_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ subroutine step_MOM_dyn_unsplit_RK2(u_in, v_in, h_in, tv, visc, Time_local, dt,
! 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, &
CS%diag, OBC=CS%OBC)
OBC=CS%OBC)
call cpu_clock_end(id_clock_continuity)
call cpu_clock_begin(id_clock_pass)
call pass_var(hp, G%Domain)
Expand Down Expand Up @@ -370,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, CS%diag, OBC=CS%OBC)
dt, G, CS%continuity_CSp, OBC=CS%OBC)
call cpu_clock_end(id_clock_continuity)
call cpu_clock_begin(id_clock_pass)
call pass_var(hp, G%Domain)
Expand Down Expand Up @@ -427,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, CS%diag, OBC=CS%OBC)
dt, G, CS%continuity_CSp, OBC=CS%OBC)
call cpu_clock_end(id_clock_continuity)
call cpu_clock_begin(id_clock_pass)
call pass_var(h_in, G%Domain)
Expand Down

0 comments on commit 8008eea

Please sign in to comment.