Skip to content

Commit 20faef7

Browse files
authored
WOMBAT: make conservation checks optional in same way as WOMBATmid (#45)
Also fix up formatting for WOMBATmid conservation checks
1 parent 5ba87f8 commit 20faef7

File tree

2 files changed

+166
-141
lines changed

2 files changed

+166
-141
lines changed

generic_tracers/generic_WOMBATlite.F90

Lines changed: 85 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@
7272
! If true and do_burial is true, add back the lost NO3 and Alk due to
7373
! burial to surface
7474
! </DATA>
75+
!
76+
! <DATA NAME="do_check_n_conserve" TYPE="logical">
77+
! If true, check that the ecosystem model conserves nitrogen. NOTE:
78+
! not appropriate if dentirification, anammox and nitrogen fixation are on.
79+
! </DATA>
80+
!
81+
! <DATA NAME="do_check_c_conserve" TYPE="logical">
82+
! If true, check that the ecosystem model conserves carbon
83+
! </DATA>
7584
! </NAMELIST>
7685
!
7786
!-----------------------------------------------------------------------
@@ -125,8 +134,11 @@ module generic_WOMBATlite
125134
logical :: do_caco3_dynamics = .true. ! do dynamic CaCO3 precipitation, dissolution and ballasting?
126135
logical :: do_burial = .false. ! permanently bury organics and CaCO3 in sediments?
127136
logical :: do_conserve_tracers = .false. ! add back the lost NO3 and Alk due to burial to surface?
137+
logical :: do_check_n_conserve = .true. ! check that the N fluxes balance in the ecosystem
138+
logical :: do_check_c_conserve = .true. ! check that the C fluxes balance in the ecosystem
128139

129-
namelist /generic_wombatlite_nml/ co2_calc, do_caco3_dynamics, do_burial, do_conserve_tracers
140+
namelist /generic_wombatlite_nml/ co2_calc, do_caco3_dynamics, do_burial, do_conserve_tracers, &
141+
do_check_n_conserve, do_check_c_conserve
130142

131143
!=======================================================================
132144
! This type contains all the parameters and arrays used in this module
@@ -555,6 +567,16 @@ subroutine generic_WOMBATlite_register(tracer_list)
555567
'do_conserve_tracers = .true. is doing nothing because do_burial = .false.')
556568
endif
557569

570+
if (do_check_n_conserve) then
571+
write (stdoutunit,*) trim(note_header), &
572+
'Checking that the ecosystem model conserves nitrogen'
573+
endif
574+
575+
if (do_check_c_conserve) then
576+
write (stdoutunit,*) trim(note_header), &
577+
'Checking that the ecosystem model conserves carbon'
578+
endif
579+
558580
! Specify all prognostic and diagnostic tracers of this modules.
559581
call user_add_tracers(tracer_list)
560582

@@ -3004,65 +3026,69 @@ subroutine generic_WOMBATlite_update_from_source(tracer_list, Temp, Salt, &
30043026
wombat%f_zoo(i,j,k) + wombat%f_caco3(i,j,k)
30053027

30063028
if (tn.gt.1) then
3007-
if (abs(n_pools(i,j,k,2) - n_pools(i,j,k,1)).gt.1e-16) then
3008-
print *, "--------------------------------------------"
3009-
print *, trim(error_header) // " Ecosystem model is not conserving nitrogen"
3010-
print *, " Longitude index =", i
3011-
print *, " Latitude index =", j
3012-
print *, " Depth index and value =", k, wombat%zm(i,j,k)
3013-
print *, " Nested timestep number =", tn
3014-
print *, " "
3015-
print *, " Biological N budget (molN/kg) at two timesteps =", n_pools(i,j,k,1), n_pools(i,j,k,2)
3016-
print *, " Difference in budget between timesteps =", n_pools(i,j,k,2) - n_pools(i,j,k,1)
3017-
print *, " "
3018-
print *, " NO3 (molNO3/kg) =", wombat%f_no3(i,j,k)
3019-
print *, " PHY (molN/kg) =", wombat%f_phy(i,j,k) * 16.0 / 122.0
3020-
print *, " ZOO (molN/kg) =", wombat%f_zoo(i,j,k) * 16.0 / 122.0
3021-
print *, " DET (molN/kg) =", wombat%f_det(i,j,k) * 16.0 / 122.0
3022-
print *, " "
3023-
print *, " phygrow (molC/kg/s) =", wombat%phygrow(i,j,k)
3024-
print *, " detremi (molC/kg/s) =", wombat%detremi(i,j,k)
3025-
print *, " zooresp (molC/kg/s) =", wombat%zooresp(i,j,k)
3026-
print *, " zooexcrphy (molC/kg/s) =", wombat%zooexcrphy(i,j,k)
3027-
print *, " zooexcrdet (molC/kg/s) =", wombat%zooexcrdet(i,j,k)
3028-
print *, " phyresp (molC/kg/s) =", wombat%phyresp(i,j,k)
3029-
print *, "--------------------------------------------"
3030-
call mpp_error(FATAL, trim(error_header) // " Terminating run due to non-conservation of tracer")
3029+
if (do_check_n_conserve) then
3030+
if (abs(n_pools(i,j,k,2) - n_pools(i,j,k,1)).gt.1e-16) then
3031+
print *, "--------------------------------------------"
3032+
print *, trim(error_header) // " Ecosystem model is not conserving nitrogen"
3033+
print *, " Longitude index =", i
3034+
print *, " Latitude index =", j
3035+
print *, " Depth index and value =", k, wombat%zm(i,j,k)
3036+
print *, " Nested timestep number =", tn
3037+
print *, " "
3038+
print *, " Biological N budget (molN/kg) at two timesteps =", n_pools(i,j,k,1), n_pools(i,j,k,2)
3039+
print *, " Difference in budget between timesteps =", n_pools(i,j,k,2) - n_pools(i,j,k,1)
3040+
print *, " "
3041+
print *, " NO3 (molNO3/kg) =", wombat%f_no3(i,j,k)
3042+
print *, " PHY (molN/kg) =", wombat%f_phy(i,j,k) * 16.0 / 122.0
3043+
print *, " ZOO (molN/kg) =", wombat%f_zoo(i,j,k) * 16.0 / 122.0
3044+
print *, " DET (molN/kg) =", wombat%f_det(i,j,k) * 16.0 / 122.0
3045+
print *, " "
3046+
print *, " phygrow (molC/kg/s) =", wombat%phygrow(i,j,k)
3047+
print *, " detremi (molC/kg/s) =", wombat%detremi(i,j,k)
3048+
print *, " zooresp (molC/kg/s) =", wombat%zooresp(i,j,k)
3049+
print *, " zooexcrphy (molC/kg/s) =", wombat%zooexcrphy(i,j,k)
3050+
print *, " zooexcrdet (molC/kg/s) =", wombat%zooexcrdet(i,j,k)
3051+
print *, " phyresp (molC/kg/s) =", wombat%phyresp(i,j,k)
3052+
print *, "--------------------------------------------"
3053+
call mpp_error(FATAL, trim(error_header) // " Terminating run due to non-conservation of tracer")
3054+
endif
30313055
endif
3032-
if (abs(c_pools(i,j,k,2) - c_pools(i,j,k,1)).gt.1e-16) then
3033-
print *, "--------------------------------------------"
3034-
print *, trim(error_header) // " Ecosystem model is not conserving carbon"
3035-
print *, " Longitude index =", i
3036-
print *, " Latitude index =", j
3037-
print *, " Depth index and value =", k, wombat%zm(i,j,k)
3038-
print *, " Nested timestep number =", tn
3039-
print *, " "
3040-
print *, " Biological C budget (molC/kg) at two timesteps =", c_pools(i,j,k,1), c_pools(i,j,k,2)
3041-
print *, " Difference in budget between timesteps =", c_pools(i,j,k,2) - c_pools(i,j,k,1)
3042-
print *, " "
3043-
print *, " DIC (molC/kg) =", wombat%f_dic(i,j,k)
3044-
print *, " ALK (molC/kg) =", wombat%f_alk(i,j,k)
3045-
print *, " PHY (molC/kg) =", wombat%f_phy(i,j,k)
3046-
print *, " ZOO (molN/kg) =", wombat%f_zoo(i,j,k)
3047-
print *, " DET (molN/kg) =", wombat%f_det(i,j,k)
3048-
print *, " CaCO3 (molC/kg) =", wombat%f_caco3(i,j,k)
3049-
print *, " Temp =", Temp(i,j,k)
3050-
print *, " Salt =", Salt(i,j,k)
3051-
print *, " surface pCO2 =", wombat%pco2_csurf(i,j)
3052-
print *, " htotal =", wombat%htotal(i,j,k)
3053-
print *, " "
3054-
print *, " phygrow (molC/kg/s) =", wombat%phygrow(i,j,k)
3055-
print *, " detremi (molC/kg/s) =", wombat%detremi(i,j,k)
3056-
print *, " zooresp (molC/kg/s) =", wombat%zooresp(i,j,k)
3057-
print *, " zooexcrphy (molC/kg/s) =", wombat%zooexcrphy(i,j,k)
3058-
print *, " zooexcrdet (molC/kg/s) =", wombat%zooexcrdet(i,j,k)
3059-
print *, " phyresp (molC/kg/s) =", wombat%phyresp(i,j,k)
3060-
print *, " zooslopphy * pic2poc(i,j,k) (molC/kg/s) =", wombat%zooslopphy(i,j,k) * wombat%pic2poc(i,j,k)
3061-
print *, " phymort * pic2poc(i,j,k) (molC/kg/s) =", wombat%phymort(i,j,k) * wombat%pic2poc(i,j,k)
3062-
print *, " zoomort * pic2poc(i,j,k) (molC/kg/s) =", wombat%zoomort(i,j,k) * wombat%pic2poc(i,j,k)
3063-
print *, " caldiss (molC/kg/s) =", wombat%caldiss(i,j,k)
3064-
print *, "--------------------------------------------"
3065-
call mpp_error(FATAL, trim(error_header) // " Terminating run due to non-conservation of tracer")
3056+
if (do_check_c_conserve) then
3057+
if (abs(c_pools(i,j,k,2) - c_pools(i,j,k,1)).gt.1e-16) then
3058+
print *, "--------------------------------------------"
3059+
print *, trim(error_header) // " Ecosystem model is not conserving carbon"
3060+
print *, " Longitude index =", i
3061+
print *, " Latitude index =", j
3062+
print *, " Depth index and value =", k, wombat%zm(i,j,k)
3063+
print *, " Nested timestep number =", tn
3064+
print *, " "
3065+
print *, " Biological C budget (molC/kg) at two timesteps =", c_pools(i,j,k,1), c_pools(i,j,k,2)
3066+
print *, " Difference in budget between timesteps =", c_pools(i,j,k,2) - c_pools(i,j,k,1)
3067+
print *, " "
3068+
print *, " DIC (molC/kg) =", wombat%f_dic(i,j,k)
3069+
print *, " ALK (molC/kg) =", wombat%f_alk(i,j,k)
3070+
print *, " PHY (molC/kg) =", wombat%f_phy(i,j,k)
3071+
print *, " ZOO (molN/kg) =", wombat%f_zoo(i,j,k)
3072+
print *, " DET (molN/kg) =", wombat%f_det(i,j,k)
3073+
print *, " CaCO3 (molC/kg) =", wombat%f_caco3(i,j,k)
3074+
print *, " Temp =", Temp(i,j,k)
3075+
print *, " Salt =", Salt(i,j,k)
3076+
print *, " surface pCO2 =", wombat%pco2_csurf(i,j)
3077+
print *, " htotal =", wombat%htotal(i,j,k)
3078+
print *, " "
3079+
print *, " phygrow (molC/kg/s) =", wombat%phygrow(i,j,k)
3080+
print *, " detremi (molC/kg/s) =", wombat%detremi(i,j,k)
3081+
print *, " zooresp (molC/kg/s) =", wombat%zooresp(i,j,k)
3082+
print *, " zooexcrphy (molC/kg/s) =", wombat%zooexcrphy(i,j,k)
3083+
print *, " zooexcrdet (molC/kg/s) =", wombat%zooexcrdet(i,j,k)
3084+
print *, " phyresp (molC/kg/s) =", wombat%phyresp(i,j,k)
3085+
print *, " zooslopphy * pic2poc(i,j,k) (molC/kg/s) =", wombat%zooslopphy(i,j,k) * wombat%pic2poc(i,j,k)
3086+
print *, " phymort * pic2poc(i,j,k) (molC/kg/s) =", wombat%phymort(i,j,k) * wombat%pic2poc(i,j,k)
3087+
print *, " zoomort * pic2poc(i,j,k) (molC/kg/s) =", wombat%zoomort(i,j,k) * wombat%pic2poc(i,j,k)
3088+
print *, " caldiss (molC/kg/s) =", wombat%caldiss(i,j,k)
3089+
print *, "--------------------------------------------"
3090+
call mpp_error(FATAL, trim(error_header) // " Terminating run due to non-conservation of tracer")
3091+
endif
30663092
endif
30673093
endif
30683094

0 commit comments

Comments
 (0)