Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+Add user-controlled underflow of tracers #131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/ALE/MOM_ALE.F90
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,11 @@ subroutine remap_all_state_vars(CS, G, GV, h_old, h_new, Reg, OBC, &
h_neglect, h_neglect_edge)
endif

! Possibly underflow any very tiny tracer concentrations to 0. Note that this is not conservative!
if (Tr%conc_underflow > 0.0) then ; do k=1,GV%ke
if (abs(tr_column(k)) < Tr%conc_underflow) tr_column(k) = 0.0
enddo ; endif

! Intermediate steps for tendency of tracer concentration and tracer content.
if (present(dt)) then
if (Tr%id_remap_conc > 0) then
Expand All @@ -895,6 +900,7 @@ subroutine remap_all_state_vars(CS, G, GV, h_old, h_new, Reg, OBC, &
enddo
endif
endif

! update tracer concentration
Tr%t(i,j,:) = tr_column(:)
endif ; enddo ; enddo
Expand Down
15 changes: 13 additions & 2 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,8 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
integer :: nkml, nkbl, verbosity, write_geom
integer :: dynamics_stencil ! The computational stencil for the calculations
! in the dynamic core.
real :: salin_underflow ! A tiny value of salinity below which the it is set to 0 [S ~> ppt]
real :: temp_underflow ! A tiny magnitude of temperatures below which they are set to 0 [C ~> degC]
real :: conv2watt ! A conversion factor from temperature fluxes to heat
! fluxes [J m-2 H-1 degC-1 ~> J m-3 degC-1 or J kg-1 degC-1]
real :: conv2salt ! A conversion factor for salt fluxes [m H-1 ~> 1] or [kg m-2 H-1 ~> 1]
Expand Down Expand Up @@ -2022,6 +2024,13 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
call get_param(param_file, "MOM", "MIN_SALINITY", CS%tv%min_salinity, &
"The minimum value of salinity when BOUND_SALINITY=True.", &
units="PPT", default=0.0, scale=US%ppt_to_S, do_not_log=.not.bound_salinity)
call get_param(param_file, "MOM", "SALINITY_UNDERFLOW", salin_underflow, &
"A tiny value of salinity below which the it is set to 0. For reference, "//&
"one molecule of salt per square meter of ocean is of order 1e-29 ppt.", &
units="PPT", default=0.0, scale=US%ppt_to_S)
call get_param(param_file, "MOM", "TEMPERATURE_UNDERFLOW", temp_underflow, &
"A tiny magnitude of temperatures below which they are set to 0.", &
units="degC", default=0.0, scale=US%degC_to_C)
call get_param(param_file, "MOM", "C_P", CS%tv%C_p, &
"The heat capacity of sea water, approximated as a "//&
"constant. This is only used if ENABLE_THERMODYNAMICS is "//&
Expand Down Expand Up @@ -2324,12 +2333,14 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
tr_desc=vd_T, registry_diags=.true., conc_scale=US%C_to_degC, &
flux_nameroot='T', flux_units='W', flux_longname='Heat', &
flux_scale=conv2watt, convergence_units='W m-2', &
convergence_scale=conv2watt, CMOR_tendprefix="opottemp", diag_form=2)
convergence_scale=conv2watt, CMOR_tendprefix="opottemp", &
diag_form=2, underflow_conc=temp_underflow)
call register_tracer(CS%tv%S, CS%tracer_Reg, param_file, HI, GV, &
tr_desc=vd_S, registry_diags=.true., conc_scale=US%S_to_ppt, &
flux_nameroot='S', flux_units=S_flux_units, flux_longname='Salt', &
flux_scale=conv2salt, convergence_units='kg m-2 s-1', &
convergence_scale=0.001*US%S_to_ppt*GV%H_to_kg_m2, CMOR_tendprefix="osalt", diag_form=2)
convergence_scale=0.001*US%S_to_ppt*GV%H_to_kg_m2, CMOR_tendprefix="osalt", &
diag_form=2, underflow_conc=salin_underflow)
endif
endif

Expand Down
7 changes: 7 additions & 0 deletions src/tracer/MOM_lateral_boundary_diffusion.F90
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ subroutine lateral_boundary_diffusion(G, GV, US, h, Coef_x, Coef_y, dt, Reg, CS)
endif
enddo ; enddo ; enddo

! Do user controlled underflow of the tracer concentrations.
if (tracer%conc_underflow > 0.0) then
do k=1,GV%ke ; do j=G%jsc,G%jec ; do i=G%isc,G%iec
if (abs(tracer%t(i,j,k)) < tracer%conc_underflow) tracer%t(i,j,k) = 0.0
enddo ; enddo ; enddo
endif

if (CS%debug) then
call hchksum(tracer%t, "after LBD "//tracer%name,G%HI)
! tracer (native grid) integrated tracer amounts before and after LBD
Expand Down
8 changes: 8 additions & 0 deletions src/tracer/MOM_neutral_diffusion.F90
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ subroutine neutral_diffusion(G, GV, h, Coef_x, Coef_y, dt, Reg, US, CS)
do k = 1, GV%ke
tracer%t(i,j,k) = tracer%t(i,j,k) + dTracer(k) * &
( G%IareaT(i,j) / ( h(i,j,k) + GV%H_subroundoff ) )
if (abs(tracer%t(i,j,k)) < tracer%conc_underflow) tracer%t(i,j,k) = 0.0
enddo

if (tracer%id_dfxy_conc > 0 .or. tracer%id_dfxy_cont > 0 .or. tracer%id_dfxy_cont_2d > 0 ) then
Expand All @@ -651,6 +652,13 @@ subroutine neutral_diffusion(G, GV, h, Coef_x, Coef_y, dt, Reg, US, CS)
endif
enddo ; enddo

! Do user controlled underflow of the tracer concentrations.
if (tracer%conc_underflow > 0.0) then
do k=1,GV%ke ; do j=G%jsc,G%jec ; do i=G%isc,G%iec
if (abs(tracer%t(i,j,k)) < tracer%conc_underflow) tracer%t(i,j,k) = 0.0
enddo ; enddo ; enddo
endif

! Diagnose vertically summed zonal flux, giving zonal tracer transport from ndiff.
! Note sign corresponds to downgradient flux convention.
if (tracer%id_dfx_2d > 0) then
Expand Down
17 changes: 14 additions & 3 deletions src/tracer/MOM_tracer_advect.F90
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,14 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, &

enddo

endif

endif ; enddo ! End of j-loop.

enddo ! End of j-loop.
! Do user controlled underflow of the tracer concentrations.
do m=1,ntr ; if (Tr(m)%conc_underflow > 0.0) then
do j=js,je ; do i=is,ie
if (abs(Tr(m)%t(i,j,k)) < Tr(m)%conc_underflow) Tr(m)%t(i,j,k) = 0.0
enddo ; enddo
endif ; enddo

! compute ad2d_x diagnostic outside above j-loop so as to make the summation ordered when OMP is active.

Expand Down Expand Up @@ -1047,6 +1051,13 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, &
enddo
endif ; enddo ! End of j-loop.

! Do user controlled underflow of the tracer concentrations.
do m=1,ntr ; if (Tr(m)%conc_underflow > 0.0) then
do j=js,je ; do i=is,ie
if (abs(Tr(m)%t(i,j,k)) < Tr(m)%conc_underflow) Tr(m)%t(i,j,k) = 0.0
enddo ; enddo
endif ; enddo

! compute ad2d_y diagnostic outside above j-loop so as to make the summation ordered when OMP is active.

!$OMP ordered
Expand Down
18 changes: 17 additions & 1 deletion src/tracer/MOM_tracer_hor_diff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,14 @@ subroutine tracer_hordiff(h, dt, MEKE, VarMix, G, GV, US, CS, Reg, tv, do_online

enddo ! End of k loop.

! Do user controlled underflow of the tracer concentrations.
do m=1,ntr ; if (Reg%Tr(m)%conc_underflow > 0.0) then
!$OMP parallel do default(shared)
do k=1,nz ; do j=js,je ; do i=is,ie
if (abs(Reg%Tr(m)%t(i,j,k)) < Reg%Tr(m)%conc_underflow) Reg%Tr(m)%t(i,j,k) = 0.0
enddo ; enddo ; enddo
endif ; enddo

enddo ! End of "while" loop.

endif ! endif for CS%use_neutral_diffusion
Expand Down Expand Up @@ -1398,7 +1406,7 @@ subroutine tracer_epipycnal_ML_diff(h, dt, Tr, ntr, khdt_epi_x, khdt_epi_y, G, &
endif
enddo
endif ; enddo ; enddo
!$OMP parallel do default(none) shared(PEmax_kRho,is,ie,js,je,G,h,Tr,tr_flux_conv,m)
!$OMP parallel do default(shared)
do k=1,PEmax_kRho ; do j=js,je ; do i=is,ie
if ((G%mask2dT(i,j) > 0.0) .and. (h(i,j,k) > 0.0)) then
Tr(m)%t(i,j,k) = Tr(m)%t(i,j,k) + tr_flux_conv(i,j,k) / &
Expand All @@ -1407,6 +1415,14 @@ subroutine tracer_epipycnal_ML_diff(h, dt, Tr, ntr, khdt_epi_x, khdt_epi_y, G, &
endif
enddo ; enddo ; enddo

! Do user controlled underflow of the tracer concentrations.
if (Tr(m)%conc_underflow > 0.0) then
!$OMP parallel do default(shared)
do k=1,nz ; do j=js,je ; do i=is,ie
if (abs(Tr(m)%t(i,j,k)) < Tr(m)%conc_underflow) Tr(m)%t(i,j,k) = 0.0
enddo ; enddo ; enddo
endif

enddo ! Loop over tracers
enddo ! Loop over iterations

Expand Down
Loading