Skip to content

Commit

Permalink
+Pass timesteps to tracer column_physics in [T]
Browse files Browse the repository at this point in the history
  Pass timesteps to the various tracer column_physics routines in [T] for
dimensional consistency testing.  Also added a new unit_scale_type argument to
these routines.  All answers are bitwise identical, but there are minor
interface changes to 13 subroutines.
  • Loading branch information
Hallberg-NOAA committed Nov 14, 2019
1 parent 00da24e commit 0281e21
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 104 deletions.
20 changes: 10 additions & 10 deletions src/parameterizations/vertical/MOM_diabatic_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ subroutine diabatic_ALE_legacy(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Tim

! For passive tracers, the changes in thickness due to boundary fluxes has yet to be applied
! so hold should be h_orig
call call_tracer_column_fns(h_prebound, h, ea_s, eb_s, fluxes, Hml, US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(h_prebound, h, ea_s, eb_s, fluxes, Hml, dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug, &
evap_CFL_limit = CS%evap_CFL_limit, &
minimum_forcing_depth = CS%minimum_forcing_depth)
Expand Down Expand Up @@ -1162,13 +1162,13 @@ subroutine diabatic_ALE_legacy(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Tim
enddo ; enddo ; enddo

! For passive tracers, the changes in thickness due to boundary fluxes has yet to be applied
call call_tracer_column_fns(h_prebound, h, eatr, ebtr, fluxes, Hml, US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(h_prebound, h, eatr, ebtr, fluxes, Hml, dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug,&
evap_CFL_limit = CS%evap_CFL_limit, &
minimum_forcing_depth = CS%minimum_forcing_depth)
else
! For passive tracers, the changes in thickness due to boundary fluxes has yet to be applied
call call_tracer_column_fns(h_prebound, h, eatr, ebtr, fluxes, Hml, US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(h_prebound, h, eatr, ebtr, fluxes, Hml, dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug, &
evap_CFL_limit = CS%evap_CFL_limit, &
minimum_forcing_depth = CS%minimum_forcing_depth)
Expand Down Expand Up @@ -1807,7 +1807,7 @@ subroutine diabatic_ALE(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end,

! For passive tracers, the changes in thickness due to boundary fluxes has yet to be applied
! so hold should be h_orig
call call_tracer_column_fns(h_prebound, h, ea_s, eb_s, fluxes, Hml, US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(h_prebound, h, ea_s, eb_s, fluxes, Hml, dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug, &
evap_CFL_limit = CS%evap_CFL_limit, &
minimum_forcing_depth = CS%minimum_forcing_depth)
Expand All @@ -1831,13 +1831,13 @@ subroutine diabatic_ALE(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end,
enddo ; enddo ; enddo

! For passive tracers, the changes in thickness due to boundary fluxes has yet to be applied
call call_tracer_column_fns(h_prebound, h, eatr, ebtr, fluxes, Hml, US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(h_prebound, h, eatr, ebtr, fluxes, Hml, dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug,&
evap_CFL_limit = CS%evap_CFL_limit, &
minimum_forcing_depth = CS%minimum_forcing_depth)
else
! For passive tracers, the changes in thickness due to boundary fluxes has yet to be applied
call call_tracer_column_fns(h_prebound, h, eatr, ebtr, fluxes, Hml, US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(h_prebound, h, eatr, ebtr, fluxes, Hml, dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug, &
evap_CFL_limit = CS%evap_CFL_limit, &
minimum_forcing_depth = CS%minimum_forcing_depth)
Expand Down Expand Up @@ -2642,7 +2642,7 @@ subroutine layered_diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_e

enddo

call call_tracer_column_fns(hold, h, eatr, ebtr, fluxes, Hml, US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(hold, h, eatr, ebtr, fluxes, Hml, dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug)

elseif (associated(visc%Kd_extra_S)) then ! extra diffusivity for passive tracers
Expand All @@ -2663,11 +2663,11 @@ subroutine layered_diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_e
eatr(i,j,k) = ea(i,j,k) + add_ent
enddo ; enddo ; enddo

call call_tracer_column_fns(hold, h, eatr, ebtr, fluxes, Hml, US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(hold, h, eatr, ebtr, fluxes, Hml, dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug)

else
call call_tracer_column_fns(hold, h, ea, eb, fluxes, Hml, US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(hold, h, ea, eb, fluxes, Hml, dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug)

endif ! (CS%mix_boundary_tracers)
Expand Down Expand Up @@ -2900,7 +2900,7 @@ subroutine adiabatic(h, tv, fluxes, dt, G, GV, US, CS)

zeros(:,:,:) = 0.0

call call_tracer_column_fns(h, h, zeros, zeros, fluxes, zeros(:,:,1), US%T_to_s*dt, G, GV, tv, &
call call_tracer_column_fns(h, h, zeros, zeros, fluxes, zeros(:,:,1), dt, G, GV, US, tv, &
CS%optics, CS%tracer_flow_CSp, CS%debug)

end subroutine adiabatic
Expand Down
11 changes: 6 additions & 5 deletions src/tracer/DOME_tracer.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module DOME_tracer
use MOM_time_manager, only : time_type
use MOM_tracer_registry, only : register_tracer, tracer_registry_type
use MOM_tracer_diabatic, only : tracer_vertdiff, applyTracerBoundaryFluxesInOut
use MOM_unit_scaling, only : unit_scale_type
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : surface
use MOM_verticalGrid, only : verticalGrid_type

Expand Down Expand Up @@ -143,7 +143,7 @@ subroutine initialize_DOME_tracer(restart, day, G, GV, US, h, diag, OBC, CS, &
sponge_CSp, param_file)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
logical, intent(in) :: restart !< .true. if the fields have already
!! been read from a restart file.
type(time_type), target, intent(in) :: day !< Time of the start of the run.
Expand Down Expand Up @@ -283,7 +283,7 @@ end subroutine initialize_DOME_tracer
!!
!! The arguments to this subroutine are redundant in that
!! h_new(k) = h_old(k) + ea(k) - eb(k-1) + eb(k) - ea(k+1)
subroutine DOME_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, CS, &
subroutine DOME_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, US, CS, &
evap_CFL_limit, minimum_forcing_depth)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
Expand All @@ -301,7 +301,8 @@ subroutine DOME_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV,
!! added [H ~> m or kg m-2].
type(forcing), intent(in) :: fluxes !< A structure containing pointers to thermodynamic
!! and tracer forcing fields. Unused fields have NULL ptrs.
real, intent(in) :: dt !< The amount of time covered by this call [s]
real, intent(in) :: dt !< The amount of time covered by this call [T ~> s]
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(DOME_tracer_CS), pointer :: CS !< The control structure returned by a previous
!! call to DOME_register_tracer.
real, optional, intent(in) :: evap_CFL_limit !< Limit on the fraction of the water that can
Expand All @@ -323,7 +324,7 @@ subroutine DOME_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV,
do k=1,nz ;do j=js,je ; do i=is,ie
h_work(i,j,k) = h_old(i,j,k)
enddo ; enddo ; enddo
call applyTracerBoundaryFluxesInOut(G, GV, CS%tr(:,:,:,m) , dt, fluxes, h_work, &
call applyTracerBoundaryFluxesInOut(G, GV, CS%tr(:,:,:,m), US%T_to_s*dt, fluxes, h_work, &
evap_CFL_limit, minimum_forcing_depth)
call tracer_vertdiff(h_work, ea, eb, dt, CS%tr(:,:,:,m), G, GV)
enddo
Expand Down
12 changes: 7 additions & 5 deletions src/tracer/ISOMIP_tracer.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ module ISOMIP_tracer
! Original sample tracer package by Robert Hallberg, 2002
! Adapted to the ISOMIP test case by Gustavo Marques, May 2016

use MOM_coms, only : max_across_PEs
use MOM_diag_mediator, only : diag_ctrl
use MOM_error_handler, only : MOM_error, FATAL, WARNING
use MOM_file_parser, only : get_param, log_param, log_version, param_file_type
use MOM_forcing_type, only : forcing
use MOM_hor_index, only : hor_index_type
use MOM_grid, only : ocean_grid_type
use MOM_io, only : file_exists, MOM_read_data, slasher, vardesc, var_desc, query_vardesc
use MOM_open_boundary, only : ocean_OBC_type
use MOM_restart, only : MOM_restart_CS
use MOM_ALE_sponge, only : set_up_ALE_sponge_field, ALE_sponge_CS
use MOM_time_manager, only : time_type
use MOM_tracer_registry, only : register_tracer, tracer_registry_type
use MOM_tracer_diabatic, only : tracer_vertdiff, applyTracerBoundaryFluxesInOut
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : surface
use MOM_open_boundary, only : ocean_OBC_type
use MOM_verticalGrid, only : verticalGrid_type
use MOM_coms, only : max_across_PEs

use coupler_types_mod, only : coupler_type_set_data, ind_csurf
use atmos_ocean_fluxes_mod, only : aof_set_coupler_flux
Expand Down Expand Up @@ -247,7 +248,7 @@ end subroutine initialize_ISOMIP_tracer

!> This subroutine applies diapycnal diffusion, including the surface boundary
!! conditions and any other column tracer physics or chemistry to the tracers from this file.
subroutine ISOMIP_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, CS, &
subroutine ISOMIP_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, US, CS, &
evap_CFL_limit, minimum_forcing_depth)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
Expand All @@ -265,7 +266,8 @@ subroutine ISOMIP_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, G
!! added [H ~> m or kg m-2].
type(forcing), intent(in) :: fluxes !< A structure containing pointers to thermodynamic
!! and tracer forcing fields. Unused fields have NULL ptrs.
real, intent(in) :: dt !< The amount of time covered by this call [s]
real, intent(in) :: dt !< The amount of time covered by this call [T ~> s]
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(ISOMIP_tracer_CS), pointer :: CS !< The control structure returned by a previous
!! call to ISOMIP_register_tracer.
real, optional, intent(in) :: evap_CFL_limit !< Limit on the fraction of the water that can
Expand Down Expand Up @@ -312,7 +314,7 @@ subroutine ISOMIP_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, G
do k=1,nz ;do j=js,je ; do i=is,ie
h_work(i,j,k) = h_old(i,j,k)
enddo ; enddo ; enddo
call applyTracerBoundaryFluxesInOut(G, GV, CS%tr(:,:,:,m) , dt, fluxes, h_work, &
call applyTracerBoundaryFluxesInOut(G, GV, CS%tr(:,:,:,m) , US%T_to_s*dt, fluxes, h_work, &
evap_CFL_limit, minimum_forcing_depth)
call tracer_vertdiff(h_work, ea, eb, dt, CS%tr(:,:,:,m), G, GV)
enddo
Expand Down
17 changes: 9 additions & 8 deletions src/tracer/MOM_OCMIP2_CFC.F90
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ end subroutine init_tracer_CFC
!> This subroutine applies diapycnal diffusion, souces and sinks and any other column
!! tracer physics or chemistry to the OCMIP2 CFC tracers.
!! CFCs are relatively simple, as they are passive tracers with only a surface flux as a source.
subroutine OCMIP2_CFC_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, CS, &
subroutine OCMIP2_CFC_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, US, CS, &
evap_CFL_limit, minimum_forcing_depth)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
Expand All @@ -424,7 +424,8 @@ subroutine OCMIP2_CFC_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, CS
!! added [H ~> m or kg m-2].
type(forcing), intent(in) :: fluxes !< A structure containing pointers to thermodynamic
!! and tracer forcing fields. Unused fields have NULL ptrs.
real, intent(in) :: dt !< The amount of time covered by this call [s]
real, intent(in) :: dt !< The amount of time covered by this call [T ~> s]
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(OCMIP2_CFC_CS), pointer :: CS !< The control structure returned by a
!! previous call to register_OCMIP2_CFC.
real, optional, intent(in) :: evap_CFL_limit !< Limit on the fraction of the water that can
Expand Down Expand Up @@ -470,19 +471,19 @@ subroutine OCMIP2_CFC_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, CS
do k=1,nz ;do j=js,je ; do i=is,ie
h_work(i,j,k) = h_old(i,j,k)
enddo ; enddo ; enddo
call applyTracerBoundaryFluxesInOut(G, GV, CFC11, dt, fluxes, h_work, &
call applyTracerBoundaryFluxesInOut(G, GV, CFC11, US%T_to_s*dt, fluxes, h_work, &
evap_CFL_limit, minimum_forcing_depth)
call tracer_vertdiff(h_work, ea, eb, dt, CFC11, G, GV, sfc_flux=CFC11_flux)
call tracer_vertdiff(h_work, ea, eb, US%T_to_s*dt, CFC11, G, GV, sfc_flux=CFC11_flux)

do k=1,nz ;do j=js,je ; do i=is,ie
h_work(i,j,k) = h_old(i,j,k)
enddo ; enddo ; enddo
call applyTracerBoundaryFluxesInOut(G, GV, CFC12, dt, fluxes, h_work, &
call applyTracerBoundaryFluxesInOut(G, GV, CFC12, US%T_to_s*dt, fluxes, h_work, &
evap_CFL_limit, minimum_forcing_depth)
call tracer_vertdiff(h_work, ea, eb, dt, CFC12, G, GV, sfc_flux=CFC12_flux)
call tracer_vertdiff(h_work, ea, eb, US%T_to_s*dt, CFC12, G, GV, sfc_flux=CFC12_flux)
else
call tracer_vertdiff(h_old, ea, eb, dt, CFC11, G, GV, sfc_flux=CFC11_flux)
call tracer_vertdiff(h_old, ea, eb, dt, CFC12, G, GV, sfc_flux=CFC12_flux)
call tracer_vertdiff(h_old, ea, eb, US%T_to_s*dt, CFC11, G, GV, sfc_flux=CFC11_flux)
call tracer_vertdiff(h_old, ea, eb, US%T_to_s*dt, CFC12, G, GV, sfc_flux=CFC12_flux)
endif

! Write out any desired diagnostics from tracer sources & sinks here.
Expand Down
18 changes: 11 additions & 7 deletions src/tracer/MOM_offline_main.F90
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,8 @@ subroutine offline_diabatic_ale(fluxes, Time_start, Time_end, CS, h_pre, eatr, e

! Note that tracerBoundaryFluxesInOut within this subroutine should NOT be called
! as the freshwater fluxes have already been accounted for
call call_tracer_column_fns(h_pre, h_pre, eatr, ebtr, fluxes, CS%MLD, CS%dt_offline_vertical, CS%G, CS%GV, &
CS%tv, CS%optics, CS%tracer_flow_CSp, CS%debug)
call call_tracer_column_fns(h_pre, h_pre, eatr, ebtr, fluxes, CS%MLD, CS%US%s_to_T*CS%dt_offline_vertical, &
CS%G, CS%GV, CS%US, CS%tv, CS%optics, CS%tracer_flow_CSp, CS%debug)

if (CS%diurnal_SW .and. CS%read_sw) then
fluxes%sw(:,:) = sw
Expand Down Expand Up @@ -871,19 +871,23 @@ subroutine offline_advection_layer(fluxes, Time_start, time_interval, CS, h_pre,
temp_old, salt_old, &
temp_mean, salt_mean, &
zero_3dh !
integer :: niter, iter
real :: Inum_iter, dt_iter
logical :: converged
integer :: niter, iter
real :: Inum_iter
real :: dt_iter ! The timestep of each iteration [T ~> s]
logical :: converged
character(len=160) :: mesg ! The text of an error message
integer :: i, j, k, m, is, ie, js, je, isd, ied, jsd, jed, nz
integer :: isv, iev, jsv, jev ! The valid range of the indices.
integer :: IsdB, IedB, JsdB, JedB
logical :: z_first, x_before_y

G => CS%G ; GV => CS%GV
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB

dt_iter = CS%US%s_to_T * time_interval / real(max(1, CS%num_off_iter))

do iter=1,CS%num_off_iter

do k = 1, nz ; do j=js-1,je+1 ; do i=is-1,ie+1
Expand All @@ -907,7 +911,7 @@ subroutine offline_advection_layer(fluxes, Time_start, time_interval, CS, h_pre,
! First do vertical advection
call update_h_vertical_flux(G, GV, eatr_sub, ebtr_sub, h_pre, h_new)
call call_tracer_column_fns(h_pre, h_new, eatr_sub, ebtr_sub, &
fluxes, CS%mld, dt_iter, G, GV, CS%tv, CS%optics, CS%tracer_flow_CSp, CS%debug)
fluxes, CS%mld, dt_iter, G, GV, CS%US, CS%tv, CS%optics, CS%tracer_flow_CSp, CS%debug)
! We are now done with the vertical mass transports, so now h_new is h_sub
do k = 1, nz ; do j=js-1,je+1 ; do i=is-1,ie+1
h_pre(i,j,k) = h_new(i,j,k)
Expand Down Expand Up @@ -947,7 +951,7 @@ subroutine offline_advection_layer(fluxes, Time_start, time_interval, CS, h_pre,
! Second vertical advection
call update_h_vertical_flux(G, GV, eatr_sub, ebtr_sub, h_pre, h_new)
call call_tracer_column_fns(h_pre, h_new, eatr_sub, ebtr_sub, &
fluxes, CS%mld, dt_iter, G, GV, CS%tv, CS%optics, CS%tracer_flow_CSp, CS%debug)
fluxes, CS%mld, dt_iter, G, GV, CS%US, CS%tv, CS%optics, CS%tracer_flow_CSp, CS%debug)
! We are now done with the vertical mass transports, so now h_new is h_sub
do k = 1, nz ; do i=is-1,ie+1 ; do j=js-1,je+1
h_pre(i,j,k) = h_new(i,j,k)
Expand Down
Loading

0 comments on commit 0281e21

Please sign in to comment.