Skip to content

Commit

Permalink
Merge 3098c8d into be5602e
Browse files Browse the repository at this point in the history
  • Loading branch information
Hallberg-NOAA authored Jul 27, 2023
2 parents be5602e + 3098c8d commit e6cecc9
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 128 deletions.
40 changes: 20 additions & 20 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3124,26 +3124,6 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
call ALE_register_diags(Time, G, GV, US, diag, CS%ALE_CSp)
endif

! This subroutine initializes any tracer packages.
call tracer_flow_control_init(.not.new_sim, Time, G, GV, US, CS%h, param_file, &
CS%diag, CS%OBC, CS%tracer_flow_CSp, CS%sponge_CSp, &
CS%ALE_sponge_CSp, CS%tv)
if (present(tracer_flow_CSp)) tracer_flow_CSp => CS%tracer_flow_CSp

! If running in offline tracer mode, initialize the necessary control structure and
! parameters
if (present(offline_tracer_mode)) offline_tracer_mode=CS%offline_tracer_mode

if (CS%offline_tracer_mode) then
! Setup some initial parameterizations and also assign some of the subtypes
call offline_transport_init(param_file, CS%offline_CSp, CS%diabatic_CSp, G, GV, US)
call insert_offline_main( CS=CS%offline_CSp, ALE_CSp=CS%ALE_CSp, diabatic_CSp=CS%diabatic_CSp, &
diag=CS%diag, OBC=CS%OBC, tracer_adv_CSp=CS%tracer_adv_CSp, &
tracer_flow_CSp=CS%tracer_flow_CSp, tracer_Reg=CS%tracer_Reg, &
tv=CS%tv, x_before_y=(MODULO(first_direction,2)==0), debug=CS%debug )
call register_diags_offline_transport(Time, CS%diag, CS%offline_CSp, GV, US)
endif

!--- set up group pass for u,v,T,S and h. pass_uv_T_S_h also is used in step_MOM
call cpu_clock_begin(id_clock_pass_init)
dynamics_stencil = min(3, G%Domain%nihalo, G%Domain%njhalo)
Expand All @@ -3169,6 +3149,26 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &

call cpu_clock_end(id_clock_pass_init)

! This subroutine initializes any tracer packages.
call tracer_flow_control_init(.not.new_sim, Time, G, GV, US, CS%h, param_file, &
CS%diag, CS%OBC, CS%tracer_flow_CSp, CS%sponge_CSp, &
CS%ALE_sponge_CSp, CS%tv)
if (present(tracer_flow_CSp)) tracer_flow_CSp => CS%tracer_flow_CSp

! If running in offline tracer mode, initialize the necessary control structure and
! parameters
if (present(offline_tracer_mode)) offline_tracer_mode=CS%offline_tracer_mode

if (CS%offline_tracer_mode) then
! Setup some initial parameterizations and also assign some of the subtypes
call offline_transport_init(param_file, CS%offline_CSp, CS%diabatic_CSp, G, GV, US)
call insert_offline_main( CS=CS%offline_CSp, ALE_CSp=CS%ALE_CSp, diabatic_CSp=CS%diabatic_CSp, &
diag=CS%diag, OBC=CS%OBC, tracer_adv_CSp=CS%tracer_adv_CSp, &
tracer_flow_CSp=CS%tracer_flow_CSp, tracer_Reg=CS%tracer_Reg, &
tv=CS%tv, x_before_y=(MODULO(first_direction,2)==0), debug=CS%debug )
call register_diags_offline_transport(Time, CS%diag, CS%offline_CSp, GV, US)
endif

call register_obsolete_diagnostics(param_file, CS%diag)

if (use_frazil) then
Expand Down
66 changes: 35 additions & 31 deletions src/tracer/DOME_tracer.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module DOME_tracer
use MOM_forcing_type, only : forcing
use MOM_hor_index, only : hor_index_type
use MOM_grid, only : ocean_grid_type
use MOM_interface_heights, only : thickness_to_dz
use MOM_io, only : file_exists, MOM_read_data, slasher, vardesc, var_desc, query_vardesc
use MOM_open_boundary, only : ocean_OBC_type, OBC_segment_tracer_type
use MOM_open_boundary, only : OBC_segment_type
Expand All @@ -19,7 +20,7 @@ module DOME_tracer
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_variables, only : surface, thermo_var_ptrs
use MOM_verticalGrid, only : verticalGrid_type

implicit none ; private
Expand Down Expand Up @@ -156,7 +157,7 @@ end function register_DOME_tracer

!> Initializes the NTR tracer fields in tr(:,:,:,:) and sets up the tracer output.
subroutine initialize_DOME_tracer(restart, day, G, GV, US, h, diag, OBC, CS, &
sponge_CSp, param_file)
sponge_CSp, tv)
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
Expand All @@ -170,27 +171,27 @@ subroutine initialize_DOME_tracer(restart, day, G, GV, US, h, diag, OBC, CS, &
!! call to DOME_register_tracer.
type(sponge_CS), pointer :: sponge_CSp !< A pointer to the control structure
!! for the sponges, if they are in use.
type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time parameters
type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various thermodynamic variables

! Local variables
! Local variables
real, allocatable :: temp(:,:,:) ! Target values for the tracers in the sponges, perhaps in [g kg-1]
character(len=16) :: name ! A variable's name in a NetCDF file.
real, pointer :: tr_ptr(:,:,:) => NULL() ! A pointer to one of the tracers, perhaps in [g kg-1]
real :: dz(SZI_(G),SZK_(GV)) ! Height change across layers [Z ~> m]
real :: tr_y ! Initial zonally uniform tracer concentrations, perhaps in [g kg-1]
real :: h_neglect ! A thickness that is so small it is usually lost
! in roundoff and can be neglected [H ~> m or kg m-2].
real :: dz_neglect ! A thickness that is so small it is usually lost
! in roundoff and can be neglected [Z ~> m or kg m-2].
real :: e(SZK_(GV)+1) ! Interface heights relative to the sea surface (negative down) [Z ~> m]
real :: e_top ! Height of the top of the tracer band relative to the sea surface [Z ~> m]
real :: e_bot ! Height of the bottom of the tracer band relative to the sea surface [Z ~> m]
real :: d_tr ! A change in tracer concentrations, in tracer units, perhaps [g kg-1]
integer :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz, m
integer :: IsdB, IedB, JsdB, JedB

if (.not.associated(CS)) return
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
h_neglect = GV%H_subroundoff

dz_neglect = GV%dz_subroundoff

CS%Time => day
CS%diag => diag
Expand Down Expand Up @@ -225,31 +226,34 @@ subroutine initialize_DOME_tracer(restart, day, G, GV, US, h, diag, OBC, CS, &
enddo ; enddo ; enddo

if (NTR >= 7) then
do j=js,je ; do i=is,ie
e(1) = 0.0
do k=1,nz
e(K+1) = e(K) - h(i,j,k)*GV%H_to_Z
do m=7,NTR
e_top = -CS%sheet_spacing * (real(m-6))
e_bot = -CS%sheet_spacing * (real(m-6) + 0.5)
if (e_top < e(K)) then
if (e_top < e(K+1)) then ; d_tr = 0.0
elseif (e_bot < e(K+1)) then
d_tr = 1.0 * (e_top-e(K+1)) / ((h(i,j,k)+h_neglect)*GV%H_to_Z)
else ; d_tr = 1.0 * (e_top-e_bot) / ((h(i,j,k)+h_neglect)*GV%H_to_Z)
do j=js,je
call thickness_to_dz(h, tv, dz, j, G, GV)
do i=is,ie
e(1) = 0.0
do k=1,nz
e(K+1) = e(K) - dz(i,k)
do m=7,NTR
e_top = -CS%sheet_spacing * (real(m-6))
e_bot = -CS%sheet_spacing * (real(m-6) + 0.5)
if (e_top < e(K)) then
if (e_top < e(K+1)) then ; d_tr = 0.0
elseif (e_bot < e(K+1)) then
d_tr = 1.0 * (e_top-e(K+1)) / (dz(i,k)+dz_neglect)
else ; d_tr = 1.0 * (e_top-e_bot) / (dz(i,k)+dz_neglect)
endif
elseif (e_bot < e(K)) then
if (e_bot < e(K+1)) then ; d_tr = 1.0
else ; d_tr = 1.0 * (e(K)-e_bot) / (dz(i,k)+dz_neglect)
endif
else
d_tr = 0.0
endif
elseif (e_bot < e(K)) then
if (e_bot < e(K+1)) then ; d_tr = 1.0
else ; d_tr = 1.0 * (e(K)-e_bot) / ((h(i,j,k)+h_neglect)*GV%H_to_Z)
endif
else
d_tr = 0.0
endif
if (h(i,j,k) < 2.0*GV%Angstrom_H) d_tr=0.0
CS%tr(i,j,k,m) = CS%tr(i,j,k,m) + d_tr
if (dz(i,k) < 2.0*GV%Angstrom_Z) d_tr=0.0
CS%tr(i,j,k,m) = CS%tr(i,j,k,m) + d_tr
enddo
enddo
enddo
enddo ; enddo
enddo
endif

endif
Expand Down
27 changes: 12 additions & 15 deletions src/tracer/MOM_tracer_flow_control.F90
Original file line number Diff line number Diff line change
Expand Up @@ -317,34 +317,31 @@ subroutine tracer_flow_control_init(restart, day, G, GV, US, h, param_file, diag
sponge_CSp)
if (CS%use_DOME_tracer) &
call initialize_DOME_tracer(restart, day, G, GV, US, h, diag, OBC, CS%DOME_tracer_CSp, &
sponge_CSp, param_file)
sponge_CSp, tv)
if (CS%use_ISOMIP_tracer) &
call initialize_ISOMIP_tracer(restart, day, G, GV, h, diag, OBC, CS%ISOMIP_tracer_CSp, &
ALE_sponge_CSp)
if (CS%use_RGC_tracer) &
call initialize_RGC_tracer(restart, day, G, GV, h, diag, OBC, &
CS%RGC_tracer_CSp, sponge_CSp, ALE_sponge_CSp)
call initialize_RGC_tracer(restart, day, G, GV, h, diag, OBC, CS%RGC_tracer_CSp, &
sponge_CSp, ALE_sponge_CSp)
if (CS%use_ideal_age) &
call initialize_ideal_age_tracer(restart, day, G, GV, US, h, diag, OBC, CS%ideal_age_tracer_CSp, &
sponge_CSp)
sponge_CSp)
if (CS%use_regional_dyes) &
call initialize_dye_tracer(restart, day, G, GV, h, diag, OBC, CS%dye_tracer_CSp, &
sponge_CSp)
call initialize_dye_tracer(restart, day, G, GV, h, diag, OBC, CS%dye_tracer_CSp, sponge_CSp, tv)
if (CS%use_oil) &
call initialize_oil_tracer(restart, day, G, GV, US, h, diag, OBC, CS%oil_tracer_CSp, &
sponge_CSp)
call initialize_oil_tracer(restart, day, G, GV, US, h, diag, OBC, CS%oil_tracer_CSp, sponge_CSp)
if (CS%use_advection_test_tracer) &
call initialize_advection_test_tracer(restart, day, G, GV, h, diag, OBC, CS%advection_test_tracer_CSp, &
sponge_CSp)
if (CS%use_OCMIP2_CFC) &
call initialize_OCMIP2_CFC(restart, day, G, GV, US, h, diag, OBC, CS%OCMIP2_CFC_CSp, &
sponge_CSp)
call initialize_OCMIP2_CFC(restart, day, G, GV, US, h, diag, OBC, CS%OCMIP2_CFC_CSp, sponge_CSp)
if (CS%use_CFC_cap) &
call initialize_CFC_cap(restart, day, G, GV, US, h, diag, OBC, CS%CFC_cap_CSp)

if (CS%use_MOM_generic_tracer) &
call initialize_MOM_generic_tracer(restart, day, G, GV, US, h, param_file, diag, OBC, &
CS%MOM_generic_tracer_CSp, sponge_CSp, ALE_sponge_CSp)
CS%MOM_generic_tracer_CSp, sponge_CSp, ALE_sponge_CSp)
if (CS%use_pseudo_salt_tracer) &
call initialize_pseudo_salt_tracer(restart, day, G, GV, US, h, diag, OBC, CS%pseudo_salt_tracer_CSp, &
sponge_CSp, tv)
Expand Down Expand Up @@ -488,13 +485,13 @@ subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV,
minimum_forcing_depth=minimum_forcing_depth)
if (CS%use_ideal_age) &
call ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, CS%ideal_age_tracer_CSp, &
G, GV, US, tv, CS%ideal_age_tracer_CSp, &
evap_CFL_limit=evap_CFL_limit, &
minimum_forcing_depth=minimum_forcing_depth, &
Hbl=Hml)
if (CS%use_regional_dyes) &
call dye_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, CS%dye_tracer_CSp, &
G, GV, US, tv, CS%dye_tracer_CSp, &
evap_CFL_limit=evap_CFL_limit, &
minimum_forcing_depth=minimum_forcing_depth)
if (CS%use_oil) &
Expand Down Expand Up @@ -567,10 +564,10 @@ subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV,
G, GV, US, CS%RGC_tracer_CSp)
if (CS%use_ideal_age) &
call ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, CS%ideal_age_tracer_CSp, Hbl=Hml)
G, GV, US, tv, CS%ideal_age_tracer_CSp, Hbl=Hml)
if (CS%use_regional_dyes) &
call dye_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, CS%dye_tracer_CSp)
G, GV, US, tv, CS%dye_tracer_CSp)
if (CS%use_oil) &
call oil_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, CS%oil_tracer_CSp, tv)
Expand Down
Loading

0 comments on commit e6cecc9

Please sign in to comment.