Skip to content

Commit

Permalink
Merge pull request #27 from nikizadehgfdl/tolerance_nml
Browse files Browse the repository at this point in the history
Add imbalance tolerance to a namelist
  • Loading branch information
nikizadehgfdl authored Dec 4, 2023
2 parents edbe781 + e44be60 commit 011b724
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions generic_tracers/generic_COBALT.F90
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ module generic_COBALT
real :: irr_inhibit = 10.
real :: gamma_nitrif= 3.5e6 !month(-1)
real :: k_nh3_nitrif= 3.1e-9 !mol/kg
real :: imbalance_tolerance=1.0e-10 !the tolerance for non-conservation in C,N,P,Sc,Fe

integer :: scheme_no3_nh4_lim = 2 !1-Frost and Franzen (1992)
!2-O'Neill
Expand All @@ -212,8 +213,7 @@ module generic_COBALT

namelist /generic_COBALT_nml/ do_14c, co2_calc, debug, do_nh3_atm_ocean_exchange, scheme_nitrif, &
k_nh4_small,k_nh4_large,k_nh4_diazo,scheme_no3_nh4_lim,k_no3_small,k_no3_large,k_no3_diazo, &
o2_min_nit,k_o2_nit,irr_inhibit,k_nh3_nitrif, &
gamma_nitrif
o2_min_nit,k_o2_nit,irr_inhibit,k_nh3_nitrif,gamma_nitrif,imbalance_tolerance

! Declare phytoplankton, zooplankton and cobalt variable types, which contain
! the vast majority of all variables used in this module.
Expand Down Expand Up @@ -6494,7 +6494,6 @@ subroutine generic_COBALT_update_from_source(tracer_list,Temp,Salt,rho_dzt,dzt,h
real, dimension(:,:), Allocatable :: pka_nh3,phos_nh3_exchange

real :: tr,ltr

real :: imbal
integer :: stdoutunit, imbal_flag, outunit

Expand Down Expand Up @@ -8477,7 +8476,7 @@ subroutine generic_COBALT_update_from_source(tracer_list,Temp,Salt,rho_dzt,dzt,h
cobalt%p_nsmz(i,j,k,tau) + cobalt%p_nmdz(i,j,k,tau) + &
cobalt%p_nlgz(i,j,k,tau))*grid_tmask(i,j,k)
imbal = (post_totn(i,j,k) - pre_totn(i,j,k) - net_srcn(i,j,k))*86400.0/dt*1.03e6
if (abs(imbal).gt.1.0e-10) then
if (abs(imbal).gt.imbalance_tolerance) then
call mpp_error(FATAL,&
'==>biological source/sink imbalance (generic_COBALT_update_from_source): Nitrogen')
endif
Expand All @@ -8491,7 +8490,7 @@ subroutine generic_COBALT_update_from_source(tracer_list,Temp,Salt,rho_dzt,dzt,h
cobalt%p_nsmz(i,j,k,tau) + cobalt%p_nmdz(i,j,k,tau) + &
cobalt%p_nlgz(i,j,k,tau)))*grid_tmask(i,j,k)
imbal = (post_totc(i,j,k) - pre_totc(i,j,k))*86400.0/dt*1.03e6
if (abs(imbal).gt.1.0e-9) then
if (abs(imbal).gt.imbalance_tolerance) then
call mpp_error(FATAL,&
'==>biological source/sink imbalance (generic_COBALT_update_from_source): Carbon')
endif
Expand All @@ -8506,7 +8505,7 @@ subroutine generic_COBALT_update_from_source(tracer_list,Temp,Salt,rho_dzt,dzt,h
cobalt%p_nlgz(i,j,k,tau)*zoo(3)%q_p_2_n + &
bact(1)%q_p_2_n*cobalt%p_nbact(i,j,k,tau))*grid_tmask(i,j,k)
imbal = (post_totp(i,j,k) - pre_totp(i,j,k))*86400.0/dt*1.03e6
if (abs(imbal).gt.1.0e-10) then
if (abs(imbal).gt.imbalance_tolerance) then
call mpp_error(FATAL,&
'==>biological source/sink imbalance (generic_COBALT_update_from_source): Phosphorus')
endif
Expand All @@ -8515,15 +8514,15 @@ subroutine generic_COBALT_update_from_source(tracer_list,Temp,Salt,rho_dzt,dzt,h
cobalt%p_felg(i,j,k,tau) + cobalt%p_fesm(i,j,k,tau) + &
cobalt%p_fedet(i,j,k,tau))*grid_tmask(i,j,k)
imbal = (post_totfe(i,j,k) - pre_totfe(i,j,k) - net_srcfe(i,j,k))*86400.0/dt*1.03e6
if (abs(imbal).gt.1.0e-10) then
if (abs(imbal).gt.imbalance_tolerance) then
call mpp_error(FATAL,&
'==>biological source/sink imbalance (generic_COBALT_update_from_source): Iron')
endif

post_totsi(i,j,k) = (cobalt%p_sio4(i,j,k,tau) + cobalt%p_silg(i,j,k,tau) + &
cobalt%p_sidet(i,j,k,tau))*grid_tmask(i,j,k)
imbal = (post_totsi(i,j,k) - pre_totsi(i,j,k))*86400.0/dt*1.03e6
if (abs(imbal).gt.1.0e-10) then
if (abs(imbal).gt.imbalance_tolerance) then
call mpp_error(FATAL,&
'==>biological source/sink imbalance (generic_COBALT_update_from_source): Silica')
endif
Expand Down

0 comments on commit 011b724

Please sign in to comment.