Skip to content
11 changes: 3 additions & 8 deletions src/initialization/MOM_grid_initialize.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module MOM_grid_initialize
use MOM_domains, only : To_North, To_South, To_East, To_West
use MOM_domains, only : MOM_domain_type, clone_MOM_domain, deallocate_MOM_domain
use MOM_dyn_horgrid, only : dyn_horgrid_type, set_derived_dyn_horgrid
use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, WARNING, is_root_pe
use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, is_root_pe
use MOM_error_handler, only : callTree_enter, callTree_leave
use MOM_file_parser, only : get_param, log_param, log_version, param_file_type
use MOM_io, only : MOM_read_data, slasher, file_exists, stdout
Expand Down Expand Up @@ -1219,15 +1219,10 @@ subroutine initialize_masks(G, PF, US)
units="m", default=0.0, scale=m_to_Z_scale)
call get_param(PF, mdl, "MASKING_DEPTH", mask_depth, &
"The depth below which to mask points as land points, for which all "//&
"fluxes are zeroed out. MASKING_DEPTH needs to be smaller than MINIMUM_DEPTH", &
"fluxes are zeroed out. MASKING_DEPTH is ignored if it has the special "//&
"default value.", &
units="m", default=-9999.0, scale=m_to_Z_scale)

if (mask_depth > min_depth) then
mask_depth = -9999.0*m_to_Z_scale
call MOM_error(WARNING, "MOM_grid_init: initialize_masks "//&
'MASKING_DEPTH is larger than MINIMUM_DEPTH and therefore ignored.')
endif

Dmask = mask_depth
if (mask_depth == -9999.*m_to_Z_scale) Dmask = min_depth

Expand Down
48 changes: 28 additions & 20 deletions src/initialization/MOM_shared_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ subroutine apply_topography_edits_from_file(D, G, param_file, US)
character(len=40) :: mdl = "apply_topography_edits_from_file" ! This subroutine's name.
integer :: i, j, n, ncid, n_edits, i_file, j_file, ndims, sizes(8)
logical :: topo_edits_change_mask
real :: min_depth, mask_depth
real :: min_depth ! The shallowest value of wet points [Z ~> m]
real :: mask_depth ! The depth defining the land-sea boundary [Z ~> m]

call callTree_enter(trim(mdl)//"(), MOM_shared_initialization.F90")

Expand All @@ -218,7 +219,8 @@ subroutine apply_topography_edits_from_file(D, G, param_file, US)
units="m", default=0.0, scale=m_to_Z)
call get_param(param_file, mdl, "MASKING_DEPTH", mask_depth, &
"The depth below which to mask points as land points, for which all "//&
"fluxes are zeroed out. MASKING_DEPTH needs to be smaller than MINIMUM_DEPTH", &
"fluxes are zeroed out. MASKING_DEPTH is ignored if it has the special "//&
"default value.", &
units="m", default=-9999.0, scale=m_to_Z)
if (mask_depth == -9999.*m_to_Z) mask_depth = min_depth

Expand Down Expand Up @@ -408,7 +410,8 @@ subroutine limit_topography(D, G, param_file, max_depth, US)
real :: m_to_Z ! A dimensional rescaling factor.
integer :: i, j
character(len=40) :: mdl = "limit_topography" ! This subroutine's name.
real :: min_depth, mask_depth
real :: min_depth ! The shallowest value of wet points [Z ~> m]
real :: mask_depth ! The depth defining the land-sea boundary [Z ~> m]

call callTree_enter(trim(mdl)//"(), MOM_shared_initialization.F90")

Expand All @@ -421,34 +424,39 @@ subroutine limit_topography(D, G, param_file, max_depth, US)
"MINIMUM_DEPTH but deeper than MASKING_DEPTH are rounded to MINIMUM_DEPTH.", &
units="m", default=0.0, scale=m_to_Z)
call get_param(param_file, mdl, "MASKING_DEPTH", mask_depth, &
"The depth below which to mask the ocean as land.", &
"The depth below which to mask points as land points, for which all "//&
"fluxes are zeroed out. MASKING_DEPTH is ignored if it has the special "//&
"default value.", &
units="m", default=-9999.0, scale=m_to_Z, do_not_log=.true.)

if (mask_depth > min_depth) then
mask_depth = -9999.0*m_to_Z
call MOM_error(WARNING, "MOM_shared_initialization: limit_topography "//&
'MASKING_DEPTH is larger than MINIMUM_DEPTH and therefore ignored.')
endif

! Make sure that min_depth < D(x,y) < max_depth for ocean points
! TBD: The following f.p. equivalence uses a special value. Originally, any negative value
! indicated the branch. We should create a logical flag to indicate this branch.
if (mask_depth == -9999.*m_to_Z) then
if (min_depth > 0.0) then ! This is retained to avoid answer changes (over the land points) in the test cases.
do j=G%jsd,G%jed ; do i=G%isd,G%ied
D(i,j) = min( max( D(i,j), 0.5*min_depth ), max_depth )
enddo ; enddo
else
do j=G%jsd,G%jed ; do i=G%isd,G%ied
D(i,j) = min( max( D(i,j), min_depth ), max_depth )
enddo ; enddo
if (min_depth<0.) then
call MOM_error(FATAL, trim(mdl)//": MINIMUM_DEPTH<0 does not work as expected "//&
"unless MASKING_DEPTH has been set appropriately. Set a meaningful "//&
"MASKING_DEPTH to enabled negative depths (land elevations) and to "//&
"enable flooding.")
endif
! This is the old path way. The 0.5*min_depth is obscure and is retained to be
! backward reproducible. If you are looking at the following line you should probably
! set MASKING_DEPTH. This path way does not work for negative depths, i.e. flooding.
do j=G%jsd,G%jed ; do i=G%isd,G%ied
D(i,j) = min( max( D(i,j), 0.5*min_depth ), max_depth )
enddo ; enddo
else
! This is the preferred path way.
! mask_depth has a meaningful value; anything shallower than mask_depth is land.
! If min_depth<mask_depth (which happens when using positive depths and not changing
! MINIMUM_DEPTH) then the shallower is used to modify and determine values on land points.
do j=G%jsd,G%jed ; do i=G%isd,G%ied
if (D(i,j) > mask_depth) then
if (D(i,j) > min(min_depth,mask_depth)) then
D(i,j) = min( max( D(i,j), min_depth ), max_depth )
else
! This statement is required for cases with masked-out PEs over the land,
! to remove the large initialized values (-9e30) from the halos.
D(i,j) = mask_depth
D(i,j) = min(min_depth,mask_depth)
endif
enddo ; enddo
endif
Expand Down
4 changes: 2 additions & 2 deletions src/tracer/MOM_tracer_flow_control.F90
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module MOM_tracer_flow_control
logical :: use_pseudo_salt_tracer = .false. !< If true, use the psuedo_salt tracer package
logical :: use_boundary_impulse_tracer = .false. !< If true, use the boundary impulse tracer package
logical :: use_dyed_obc_tracer = .false. !< If true, use the dyed OBC tracer package
logical :: use_nw2_tracers = .false. !< If true, use the ideal age tracer package
logical :: use_nw2_tracers = .false. !< If true, use the NW2 tracer package
!>@{ Pointers to the control strucures for the tracer packages
type(USER_tracer_example_CS), pointer :: USER_tracer_example_CSp => NULL()
type(DOME_tracer_CS), pointer :: DOME_tracer_CSp => NULL()
Expand Down Expand Up @@ -267,7 +267,7 @@ subroutine call_tracer_register(HI, GV, US, param_file, CS, tr_Reg, restart_CS)
if (CS%use_dyed_obc_tracer) CS%use_dyed_obc_tracer = &
register_dyed_obc_tracer(HI, GV, param_file, CS%dyed_obc_tracer_CSp, &
tr_Reg, restart_CS)
if (CS%use_nw2_tracers) CS%use_ideal_age = &
if (CS%use_nw2_tracers) CS%use_nw2_tracers = &
register_nw2_tracers(HI, GV, param_file, CS%nw2_tracers_CSp, tr_Reg, restart_CS)

end subroutine call_tracer_register
Expand Down
2 changes: 1 addition & 1 deletion src/tracer/MOM_tracer_registry.F90
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, US, use_ALE)
trim(flux_units), v_extensive=.true., y_cell_method='sum', &
conversion=(US%L_to_m**2)*Tr%flux_scale*US%s_to_T)
Tr%id_dfy = register_diag_field("ocean_model", trim(shortnm)//"_dfy", &
diag%axesCvL, Time, trim(flux_longname)//" diffusive zonal flux" , &
diag%axesCvL, Time, trim(flux_longname)//" diffusive meridional flux" , &
trim(flux_units), v_extensive=.true., x_cell_method='sum', &
conversion=(US%L_to_m**2)*Tr%flux_scale*US%s_to_T)
Tr%id_lbd_dfx = register_diag_field("ocean_model", trim(shortnm)//"_lbd_diffx", &
Expand Down