Commit f145d25a authored by Jorn Bruggeman's avatar Jorn Bruggeman
Browse files

renamed preprocessor macros for accessing sources/fluxes across interfaces

parent 3e3d6908
...@@ -259,17 +259,14 @@ ...@@ -259,17 +259,14 @@
#define _ADD_HORIZONTAL_(variable,value) cache%write_hz _INDEX_HORIZONTAL_SLICE_PLUS_1_(variable%horizontal_sum_index) = cache%write_hz _INDEX_HORIZONTAL_SLICE_PLUS_1_(variable%horizontal_sum_index) + (value) #define _ADD_HORIZONTAL_(variable,value) cache%write_hz _INDEX_HORIZONTAL_SLICE_PLUS_1_(variable%horizontal_sum_index) = cache%write_hz _INDEX_HORIZONTAL_SLICE_PLUS_1_(variable%horizontal_sum_index) + (value)
! For BGC models: Expressions for setting space-dependent FABM variables defined on the full spatial domain. ! For BGC models: Expressions for setting space-dependent FABM variables defined on the full spatial domain.
#define _SET_ODE_(variable,value) _ADD_(variable%sms,(value)*self%rdt__) #define _ADD_SOURCE_(variable,value) _ADD_(variable%sms,(value)*self%rdt__)
#define _SET_BOTTOM_ODE_(variable,value) _ADD_HORIZONTAL_(variable%bottom_sms,(value)*self%rdt__) #define _ADD_BOTTOM_SOURCE_(variable,value) _ADD_HORIZONTAL_(variable%bottom_sms,(value)*self%rdt__)
#define _SET_SURFACE_ODE_(variable,value) _ADD_HORIZONTAL_(variable%surface_sms,(value)*self%rdt__) #define _ADD_SURFACE_SOURCE_(variable,value) _ADD_HORIZONTAL_(variable%surface_sms,(value)*self%rdt__)
#define _SET_BOTTOM_EXCHANGE_(variable,value) _ADD_HORIZONTAL_(variable%bottom_flux,(value)*self%rdt__) #define _ADD_BOTTOM_FLUX_(variable,value) _ADD_HORIZONTAL_(variable%bottom_flux,(value)*self%rdt__)
#define _SET_SURFACE_EXCHANGE_(variable,value) _ADD_HORIZONTAL_(variable%surface_flux,(value)*self%rdt__) #define _ADD_SURFACE_FLUX_(variable,value) _ADD_HORIZONTAL_(variable%surface_flux,(value)*self%rdt__)
#define _SET_DD_(variable1,variable2,value) dd _INDEX_SLICE_PLUS_2_(variable1%state_index,variable2%state_index) = dd _INDEX_SLICE_PLUS_2_(variable1%state_index,variable2%state_index) + (value)*self%rdt__ #define _SET_DD_(variable1,variable2,value) dd _INDEX_SLICE_PLUS_2_(variable1%state_index,variable2%state_index) = dd _INDEX_SLICE_PLUS_2_(variable1%state_index,variable2%state_index) + (value)*self%rdt__
#define _SET_PP_(variable1,variable2,value) pp _INDEX_SLICE_PLUS_2_(variable1%state_index,variable2%state_index) = pp _INDEX_SLICE_PLUS_2_(variable1%state_index,variable2%state_index) + (value)*self%rdt__ #define _SET_PP_(variable1,variable2,value) pp _INDEX_SLICE_PLUS_2_(variable1%state_index,variable2%state_index) = pp _INDEX_SLICE_PLUS_2_(variable1%state_index,variable2%state_index) + (value)*self%rdt__
#define _SET_EXTINCTION_(value) _ADD_(self%extinction_id,value) #define _ADD_VERTICAL_VELOCITY_(variable,value) _ADD_(variable%movement,(value)*self%rdt__)
#define _SCALE_DRAG_(value) _ADD_HORIZONTAL_(self%surface_drag_id,(value)-1.0_rk)
#define _SET_ALBEDO_(value) _ADD_HORIZONTAL_(self%albedo_id,value)
#define _SET_VERTICAL_MOVEMENT_(variable,value) _ADD_(variable%movement,(value)*self%rdt__)
#define _INVALIDATE_STATE_ cache%valid = .false. #define _INVALIDATE_STATE_ cache%valid = .false.
#define _REPAIR_STATE_ cache%repair #define _REPAIR_STATE_ cache%repair
...@@ -299,3 +296,14 @@ ...@@ -299,3 +296,14 @@
#define _SET_SURFACE_DIAGNOSTIC_(variable,value) cache%write_hz _INDEX_HORIZONTAL_SLICE_PLUS_1_(variable%surface_write_index) = value #define _SET_SURFACE_DIAGNOSTIC_(variable,value) cache%write_hz _INDEX_HORIZONTAL_SLICE_PLUS_1_(variable%surface_write_index) = value
#define _ASSERT_(condition, routine, message) if (.not.(condition)) call driver%fatal_error(routine, message) #define _ASSERT_(condition, routine, message) if (.not.(condition)) call driver%fatal_error(routine, message)
! Backward compatibility with pre-1.0 FABM (2020-04-22)
#define _SET_ODE_(variable,value) _ADD_SOURCE_(variable,value)
#define _SET_BOTTOM_ODE_(variable,value) _ADD_BOTTOM_SOURCE_(variable,value)
#define _SET_SURFACE_ODE_(variable,value) _ADD_SURFACE_SOURCE_(variable,value)
#define _SET_BOTTOM_EXCHANGE_(variable,value) _ADD_BOTTOM_FLUX_(variable,value)
#define _SET_SURFACE_EXCHANGE_(variable,value) _ADD_SURFACE_FLUX_(variable,value)
#define _SET_VERTICAL_MOVEMENT_(variable,value) _ADD_VERTICAL_VELOCITY_(variable,value)
#define _SET_EXTINCTION_(value) _ADD_(self%extinction_id,value)
#define _SCALE_DRAG_(value) _ADD_HORIZONTAL_(self%surface_drag_id,(value)-1.0_rk)
#define _SET_ALBEDO_(value) _ADD_HORIZONTAL_(self%albedo_id,value)
...@@ -104,7 +104,7 @@ contains ...@@ -104,7 +104,7 @@ contains
end if end if
! Send rate of change to FABM ! Send rate of change to FABM
_SET_ODE_(self%id_c,-self%k*f*c) _ADD_SOURCE_(self%id_c,-self%k*f*c)
! Leave spatial loops (if any) ! Leave spatial loops (if any)
_LOOP_END_ _LOOP_END_
......
...@@ -130,7 +130,7 @@ contains ...@@ -130,7 +130,7 @@ contains
end if end if
! Send rate of change to FABM ! Send rate of change to FABM
_SET_ODE_(self%id_c,-self%k*f*c) _ADD_SOURCE_(self%id_c,-self%k*f*c)
! Leave spatial loops (if any) ! Leave spatial loops (if any)
_LOOP_END_ _LOOP_END_
...@@ -174,8 +174,8 @@ contains ...@@ -174,8 +174,8 @@ contains
! Sedimentation ! Sedimentation
if (self%do_sed) then if (self%do_sed) then
!_SET_BOTTOM_EXCHANGE_(self%id_c,-self%w*c) !_ADD_BOTTOM_FLUX_(self%id_c,-self%w*c)
!_SET_BOTTOM_ODE_(self%id_c_bot, +self%w*c) !_ADD_BOTTOM_SOURCE_(self%id_c_bot, +self%w*c)
! Resuspension/Erosion ! Resuspension/Erosion
select case(self%resusp_meth) select case(self%resusp_meth)
...@@ -208,10 +208,10 @@ contains ...@@ -208,10 +208,10 @@ contains
!write(*,*) 'h = ',h !write(*,*) 'h = ',h
!write(*,*) 'max_dt = ',max_dt !write(*,*) 'max_dt = ',max_dt
_SET_BOTTOM_EXCHANGE_(self%id_c,-min(h/max_dt,self%w)*c+erosion) _ADD_BOTTOM_FLUX_(self%id_c,-min(h/max_dt,self%w)*c+erosion)
_SET_BOTTOM_ODE_(self%id_c_bot, +min(h/max_dt,self%w)*c-erosion) _ADD_BOTTOM_SOURCE_(self%id_c_bot, +min(h/max_dt,self%w)*c-erosion)
!_SET_BOTTOM_EXCHANGE_(self%id_c,-self%w*c+erosion) !_ADD_BOTTOM_FLUX_(self%id_c,-self%w*c+erosion)
!_SET_BOTTOM_ODE_(self%id_c_bot, +self%w*c-erosion) !_ADD_BOTTOM_SOURCE_(self%id_c_bot, +self%w*c-erosion)
end if end if
......
...@@ -122,8 +122,8 @@ ...@@ -122,8 +122,8 @@
f = -g/self%Y f = -g/self%Y
! !
! Set temporal derivatives, subtracted by the secs_pr_day ! Set temporal derivatives, subtracted by the secs_pr_day
_SET_ODE_(self%id_predator,g) _ADD_SOURCE_(self%id_predator,g)
_SET_ODE_(self%id_prey,f) _ADD_SOURCE_(self%id_prey,f)
! Export diagnostic variables ! Export diagnostic variables
! Leave spatial loops (if any) ! Leave spatial loops (if any)
_LOOP_END_ _LOOP_END_
......
...@@ -122,8 +122,8 @@ ...@@ -122,8 +122,8 @@
f = (self%b-self%p*predator)*prey f = (self%b-self%p*predator)*prey
! !
! Set temporal derivatives, subtracted by the secs_pr_day ! Set temporal derivatives, subtracted by the secs_pr_day
_SET_ODE_(self%id_predator,g) _ADD_SOURCE_(self%id_predator,g)
_SET_ODE_(self%id_prey,f) _ADD_SOURCE_(self%id_prey,f)
! Export diagnostic variables ! Export diagnostic variables
! Leave spatial loops (if any) ! Leave spatial loops (if any)
_LOOP_END_ _LOOP_END_
......
...@@ -84,8 +84,8 @@ contains ...@@ -84,8 +84,8 @@ contains
end if end if
! Set fluxes of pelagic variables. ! Set fluxes of pelagic variables.
_SET_ODE_(self%id_prey, -prey * clearance_rate) _ADD_SOURCE_(self%id_prey, -prey * clearance_rate)
_SET_ODE_(self%id_consumed_prey, prey * clearance_rate) _ADD_SOURCE_(self%id_consumed_prey, prey * clearance_rate)
! Leave spatial loops (if any). ! Leave spatial loops (if any).
_LOOP_END_ _LOOP_END_
......
...@@ -53,9 +53,9 @@ contains ...@@ -53,9 +53,9 @@ contains
_GET_(self%id_z, z) _GET_(self%id_z, z)
! Set temporal derivatives ! Set temporal derivatives
_SET_ODE_(self%id_x, self%sigma*(y-x)) _ADD_SOURCE_(self%id_x, self%sigma*(y-x))
_SET_ODE_(self%id_y, x*(self%rho-z)-y) _ADD_SOURCE_(self%id_y, x*(self%rho-z)-y)
_SET_ODE_(self%id_z, x*y-self%beta*z) _ADD_SOURCE_(self%id_z, x*y-self%beta*z)
_LOOP_END_ _LOOP_END_
end subroutine do end subroutine do
......
...@@ -63,7 +63,7 @@ contains ...@@ -63,7 +63,7 @@ contains
_HORIZONTAL_LOOP_BEGIN_ _HORIZONTAL_LOOP_BEGIN_
! Transfer surface exchange value to FABM. ! Transfer surface exchange value to FABM.
_SET_SURFACE_EXCHANGE_(self%id_tracer, self%surface_flux) _ADD_SURFACE_FLUX_(self%id_tracer, self%surface_flux)
! Leave spatial loops (if any) ! Leave spatial loops (if any)
_HORIZONTAL_LOOP_END_ _HORIZONTAL_LOOP_END_
......
...@@ -81,15 +81,15 @@ contains ...@@ -81,15 +81,15 @@ contains
g = self%g_max * biomass * prey / (prey + self%K) g = self%g_max * biomass * prey / (prey + self%K)
! Set local temporal derivatives of benthic variables ! Set local temporal derivatives of benthic variables
_SET_BOTTOM_ODE_(self%id_biomass, g - self%h * biomass) _ADD_BOTTOM_SOURCE_(self%id_biomass, g - self%h * biomass)
if (self%interact_with_pelagic) then if (self%interact_with_pelagic) then
! Set bottom fluxes of pelagic variables (these mirror local benthic derivatives and have unit mmol m-2 s-1) ! Set bottom fluxes of pelagic variables (these mirror local benthic derivatives and have unit mmol m-2 s-1)
_SET_BOTTOM_EXCHANGE_(self%id_prey, -g) _ADD_BOTTOM_FLUX_(self%id_prey, -g)
_SET_BOTTOM_EXCHANGE_(self%id_waste, self%h * biomass) _ADD_BOTTOM_FLUX_(self%id_waste, self%h * biomass)
else else
_SET_BOTTOM_ODE_(self%id_bottom_prey, -g) _ADD_BOTTOM_SOURCE_(self%id_bottom_prey, -g)
_SET_BOTTOM_ODE_(self%id_bottom_waste, self%h * biomass) _ADD_BOTTOM_SOURCE_(self%id_bottom_waste, self%h * biomass)
end if end if
! Leave spatial loops over the horizontal domain (if any). ! Leave spatial loops over the horizontal domain (if any).
......
...@@ -160,7 +160,7 @@ contains ...@@ -160,7 +160,7 @@ contains
! Now distribute the same relative change across the column. ! Now distribute the same relative change across the column.
_GET_(self%id_target,local) _GET_(self%id_target,local)
_GET_(self%id_weights,weight) _GET_(self%id_weights,weight)
_SET_ODE_(self%id_target,relative_change*local*weight) _ADD_SOURCE_(self%id_target,relative_change*local*weight)
_LOOP_END_ _LOOP_END_
end subroutine depth_integral_rate_distributor_do end subroutine depth_integral_rate_distributor_do
......
...@@ -65,8 +65,8 @@ contains ...@@ -65,8 +65,8 @@ contains
_GET_(self%id_d, d) ! detritus _GET_(self%id_d, d) ! detritus
! Set temporal derivatives ! Set temporal derivatives
_SET_ODE_(self%id_d, -self%rdn*d) _ADD_SOURCE_(self%id_d, -self%rdn*d)
_SET_ODE_(self%id_mintarget, self%rdn*d) _ADD_SOURCE_(self%id_mintarget, self%rdn*d)
! Leave spatial loops (if any) ! Leave spatial loops (if any)
_LOOP_END_ _LOOP_END_
......
...@@ -105,12 +105,12 @@ contains ...@@ -105,12 +105,12 @@ contains
primprod = fnp(self%rmax, self%alpha, n, p + self%p0, par, iopt) primprod = fnp(self%rmax, self%alpha, n, p + self%p0, par, iopt)
! Set temporal derivatives ! Set temporal derivatives
_SET_ODE_(self%id_p,primprod - self%rpn*p - rpd*p) _ADD_SOURCE_(self%id_p,primprod - self%rpn*p - rpd*p)
! If an externally maintained ... ! If an externally maintained ...
_SET_ODE_(self%id_upttarget,-primprod) _ADD_SOURCE_(self%id_upttarget,-primprod)
_SET_ODE_(self%id_morttarget,rpd*p) _ADD_SOURCE_(self%id_morttarget,rpd*p)
_SET_ODE_(self%id_exctarget,self%rpn*p) _ADD_SOURCE_(self%id_exctarget,self%rpn*p)
! Export diagnostic variables ! Export diagnostic variables
_SET_DIAGNOSTIC_(self%id_dPAR,par) _SET_DIAGNOSTIC_(self%id_dPAR,par)
......
...@@ -67,10 +67,10 @@ contains ...@@ -67,10 +67,10 @@ contains
g = fpz(self%gmax, self%iv, p, z + self%z0) g = fpz(self%gmax, self%iv, p, z + self%z0)
! Set temporal derivatives ! Set temporal derivatives
_SET_ODE_(self%id_z, g - self%rzn*z - self%rzd*z) _ADD_SOURCE_(self%id_z, g - self%rzn*z - self%rzd*z)
_SET_ODE_(self%id_grztarget, -g) _ADD_SOURCE_(self%id_grztarget, -g)
_SET_ODE_(self%id_morttarget, self%rzd*z) _ADD_SOURCE_(self%id_morttarget, self%rzd*z)
_SET_ODE_(self%id_exctarget, self%rzn*z) _ADD_SOURCE_(self%id_exctarget, self%rzn*z)
! Leave spatial loops (if any) ! Leave spatial loops (if any)
_LOOP_END_ _LOOP_END_
......
...@@ -257,15 +257,15 @@ contains ...@@ -257,15 +257,15 @@ contains
r3=self%r3max*1.0_rk/(1.0_rk+exp(self%beta_bg*(self%tbg-temp))) & r3=self%r3max*1.0_rk/(1.0_rk+exp(self%beta_bg*(self%tbg-temp))) &
*min(yy(self%sr*self%alpha3,po),ppi)*(p3+self%p30) *min(yy(self%sr*self%alpha3,po),ppi)*(p3+self%p30)
_SET_ODE_(self%id_p1,r1-fpz(self%iv,self%g1max,temp,self%topt,psum)*p1/psum*(zo+self%zo0)-lp*p1) _ADD_SOURCE_(self%id_p1,r1-fpz(self%iv,self%g1max,temp,self%topt,psum)*p1/psum*(zo+self%zo0)-lp*p1)
_SET_ODE_(self%id_p2,r2-fpz(self%iv,self%g2max,temp,self%topt,psum)*p2/psum*(zo+self%zo0)-lp*p2) _ADD_SOURCE_(self%id_p2,r2-fpz(self%iv,self%g2max,temp,self%topt,psum)*p2/psum*(zo+self%zo0)-lp*p2)
_SET_ODE_(self%id_p3,r3-fpz(self%iv,self%g3max,temp,self%topt,psum)*p3/psum*(zo+self%zo0)-lp*p3) _ADD_SOURCE_(self%id_p3,r3-fpz(self%iv,self%g3max,temp,self%topt,psum)*p3/psum*(zo+self%zo0)-lp*p3)
_SET_ODE_(self%id_zo,(fpz(self%iv,self%g1max,temp,self%topt,psum)*p1+fpz(self%iv,self%g2max,temp,self%topt,psum)*p2+fpz(self%iv,self%g3max,temp,self%topt,psum)*p3)*(zo+self%zo0)/psum-self%lza*zo*(zo+self%zo0)-self%lzd*zo*(zo+self%zo0)) _ADD_SOURCE_(self%id_zo,(fpz(self%iv,self%g1max,temp,self%topt,psum)*p1+fpz(self%iv,self%g2max,temp,self%topt,psum)*p2+fpz(self%iv,self%g3max,temp,self%topt,psum)*p3)*(zo+self%zo0)/psum-self%lza*zo*(zo+self%zo0)-self%lzd*zo*(zo+self%zo0))
_SET_ODE_(self%id_de,self%lpd*p1+self%lpd*p2+self%lpd*p3+self%lzd*zo*(zo+self%zo0)-llda*de) _ADD_SOURCE_(self%id_de,self%lpd*p1+self%lpd*p2+self%lpd*p3+self%lzd*zo*(zo+self%zo0)-llda*de)
_SET_ODE_(self%id_am,llda*de-llan*am-am/(am+ni)*r1-am/(am+ni)*r2+self%lpa*(p1+p2+p3)+self%lza*zo*(zo+self%zo0)) _ADD_SOURCE_(self%id_am,llda*de-llan*am-am/(am+ni)*r1-am/(am+ni)*r2+self%lpa*(p1+p2+p3)+self%lza*zo*(zo+self%zo0))
_SET_ODE_(self%id_ni,llan*am-ni/(am+ni)*r1-ni/(am+ni)*r2-self%s1*llda*de*thomnp) _ADD_SOURCE_(self%id_ni,llan*am-ni/(am+ni)*r1-ni/(am+ni)*r2-self%s1*llda*de*thomnp)
_SET_ODE_(self%id_po,self%sr*(-r1-r2-r3+llda*de+self%lpa*(p1+p2+p3)+self%lza*zo*(zo+self%zo0))) _ADD_SOURCE_(self%id_po,self%sr*(-r1-r2-r3+llda*de+self%lpa*(p1+p2+p3)+self%lza*zo*(zo+self%zo0)))
_SET_ODE_(self%id_o2,self%s2*(am/(am+ni)*(r1+r2)+r3)-self%s4*(llan*am)+self%s3*(ni/(am+ni)*(r1+r2))-self%s2*(thopnp+thomnm)*llda*de-self%s2*(self%lpa*(p1+p2+p3)+self%lza*zo*(zo+self%zo0))) _ADD_SOURCE_(self%id_o2,self%s2*(am/(am+ni)*(r1+r2)+r3)-self%s4*(llan*am)+self%s3*(ni/(am+ni)*(r1+r2))-self%s2*(thopnp+thomnm)*llda*de-self%s2*(self%lpa*(p1+p2+p3)+self%lza*zo*(zo+self%zo0)))
! Set diagnostic variables ! Set diagnostic variables
_SET_DIAGNOSTIC_(self%id_dPAR,par) _SET_DIAGNOSTIC_(self%id_dPAR,par)
...@@ -326,12 +326,12 @@ contains ...@@ -326,12 +326,12 @@ contains
llsd=0.0_rk llsd=0.0_rk
end if end if
_SET_BOTTOM_ODE_(self%id_fl,llds*deb-llsd*fl-llsa*fl-th(oxb,wo,0.0_rk,1.0_rk)*llsa*fl) _ADD_BOTTOM_SOURCE_(self%id_fl,llds*deb-llsd*fl-llsa*fl-th(oxb,wo,0.0_rk,1.0_rk)*llsa*fl)
_SET_BOTTOM_EXCHANGE_(self%id_de,-llds*deb+llsd*fl) _ADD_BOTTOM_FLUX_(self%id_de,-llds*deb+llsd*fl)
_SET_BOTTOM_EXCHANGE_(self%id_am,llsa*fl) _ADD_BOTTOM_FLUX_(self%id_am,llsa*fl)
_SET_BOTTOM_EXCHANGE_(self%id_ni,-self%s1*thomnp*llsa*fl) _ADD_BOTTOM_FLUX_(self%id_ni,-self%s1*thomnp*llsa*fl)
_SET_BOTTOM_EXCHANGE_(self%id_po,self%sr*(1.0_rk-self%ph1*th(oxb,wo,0.0_rk,1.0_rk)*yy(self%ph2,oxb))*llsa*fl) _ADD_BOTTOM_FLUX_(self%id_po,self%sr*(1.0_rk-self%ph1*th(oxb,wo,0.0_rk,1.0_rk)*yy(self%ph2,oxb))*llsa*fl)
_SET_BOTTOM_EXCHANGE_(self%id_o2,-(self%s4+self%s2*(thopnp+thomnm))*llsa*fl) _ADD_BOTTOM_FLUX_(self%id_o2,-(self%s4+self%s2*(thopnp+thomnm))*llsa*fl)
! Leave spatial loops over the horizontal domain (if any). ! Leave spatial loops over the horizontal domain (if any).
_HORIZONTAL_LOOP_END_ _HORIZONTAL_LOOP_END_
...@@ -424,11 +424,11 @@ contains ...@@ -424,11 +424,11 @@ contains
else else
flo2 = self%pvel*(self%a0*(self%a1-self%a2*temp)-o2) flo2 = self%pvel*(self%a0*(self%a1-self%a2*temp)-o2)
end if end if
_SET_SURFACE_EXCHANGE_(self%id_o2,flo2) _ADD_SURFACE_FLUX_(self%id_o2,flo2)
_SET_SURFACE_EXCHANGE_(self%id_ni,self%sfl_ni) _ADD_SURFACE_FLUX_(self%id_ni,self%sfl_ni)
_SET_SURFACE_EXCHANGE_(self%id_am,self%sfl_am) _ADD_SURFACE_FLUX_(self%id_am,self%sfl_am)
_SET_SURFACE_EXCHANGE_(self%id_po,self%sfl_po) _ADD_SURFACE_FLUX_(self%id_po,self%sfl_po)
_HORIZONTAL_LOOP_END_ _HORIZONTAL_LOOP_END_
end subroutine do_surface end subroutine do_surface
......
...@@ -293,13 +293,13 @@ contains ...@@ -293,13 +293,13 @@ contains
- self%vb*l/(self%k4+min67+l)*(b+self%b0) - self%vb*l/(self%k4+min67+l)*(b+self%b0)
! Provide temporal derivatives to FABM. ! Provide temporal derivatives to FABM.
_SET_ODE_(self%id_p,d_p) _ADD_SOURCE_(self%id_p,d_p)
_SET_ODE_(self%id_z,d_z) _ADD_SOURCE_(self%id_z,d_z)
_SET_ODE_(self%id_d,d_d) _ADD_SOURCE_(self%id_d,d_d)
_SET_ODE_(self%id_b,d_b) _ADD_SOURCE_(self%id_b,d_b)
_SET_ODE_(self%id_n,d_n) _ADD_SOURCE_(self%id_n,d_n)
_SET_ODE_(self%id_a,d_a) _ADD_SOURCE_(self%id_a,d_a)
_SET_ODE_(self%id_l,d_l) _ADD_SOURCE_(self%id_l,d_l)
! Provide diagnostic variables to FABM. ! Provide diagnostic variables to FABM.
_SET_DIAGNOSTIC_(self%id_pp,secs_pr_day*ff*(n/self%k1+a/self%k2)/(1.0_rk+n/self%k1+a/self%k2)) _SET_DIAGNOSTIC_(self%id_pp,secs_pr_day*ff*(n/self%k1+a/self%k2)/(1.0_rk+n/self%k1+a/self%k2))
......
...@@ -189,14 +189,14 @@ contains ...@@ -189,14 +189,14 @@ contains
dn = - primprod + self%rpn*p + self%rzn*z + self%rdn*d dn = - primprod + self%rpn*p + self%rzn*z + self%rdn*d
! Set temporal derivatives ! Set temporal derivatives
_SET_ODE_(self%id_n,dn) _ADD_SOURCE_(self%id_n,dn)
_SET_ODE_(self%id_p,primprod - g - self%rpn*p - rpd*p) _ADD_SOURCE_(self%id_p,primprod - g - self%rpn*p - rpd*p)
_SET_ODE_(self%id_z,g - self%rzn*z - self%rzd*z) _ADD_SOURCE_(self%id_z,g - self%rzn*z - self%rzd*z)
_SET_ODE_(self%id_d,rpd*p + self%rzd*z - self%rdn*d) _ADD_SOURCE_(self%id_d,rpd*p + self%rzd*z - self%rdn*d)
! If an externally maintained DIC pool is present, change the DIC pool according to the ! If an externally maintained DIC pool is present, change the DIC pool according to the
! the change in nutrients (assuming constant C:N ratio) ! the change in nutrients (assuming constant C:N ratio)
if (_AVAILABLE_(self%id_dic)) _SET_ODE_(self%id_dic,self%dic_per_n*dn) if (_AVAILABLE_(self%id_dic)) _ADD_SOURCE_(self%id_dic,self%dic_per_n*dn)
! Export diagnostic variables ! Export diagnostic variables
_SET_DIAGNOSTIC_(self%id_dPAR,par) _SET_DIAGNOSTIC_(self%id_dPAR,par)
......
...@@ -251,14 +251,14 @@ ...@@ -251,14 +251,14 @@
#define _CONV_UNIT_ /secs_pr_day #define _CONV_UNIT_ /secs_pr_day
! reaction rates ! reaction rates
_SET_ODE_(self%id_fdet, -f_T * CprodF _CONV_UNIT_) _ADD_SOURCE_(self%id_fdet, -f_T * CprodF _CONV_UNIT_)
_SET_ODE_(self%id_sdet, -f_T * CprodS _CONV_UNIT_) _ADD_SOURCE_(self%id_sdet, -f_T * CprodS _CONV_UNIT_)
_SET_ODE_(self%id_oxy , (-OxicMin - 2.0_rk* Nitri - OduOx) _CONV_UNIT_) !RH 1.0->150/106*OxicMin (if [oxy]=mmolO2/m**3) _ADD_SOURCE_(self%id_oxy , (-OxicMin - 2.0_rk* Nitri - OduOx) _CONV_UNIT_) !RH 1.0->150/106*OxicMin (if [oxy]=mmolO2/m**3)
_SET_ODE_(self%id_no3 , (-0.8_rk*Denitrific + Nitri) _CONV_UNIT_) !RH 0.8-> ~104/106? _ADD_SOURCE_(self%id_no3 , (-0.8_rk*Denitrific + Nitri) _CONV_UNIT_) !RH 0.8-> ~104/106?
_SET_ODE_(self%id_nh3 , (f_T * Nprod - Nitri) / (1.0_rk + self%NH3Ads) _CONV_UNIT_) _ADD_SOURCE_(self%id_nh3 , (f_T * Nprod - Nitri) / (1.0_rk + self%NH3Ads) _CONV_UNIT_)
_SET_ODE_(self%id_odu , (AnoxicMin - OduOx - OduDepo) _CONV_UNIT_) _ADD_SOURCE_(self%id_odu , (AnoxicMin - OduOx - OduDepo) _CONV_UNIT_)
_SET_ODE_(self%id_po4 , (f_T * Pprod - radsP) _CONV_UNIT_) _ADD_SOURCE_(self%id_po4 , (f_T * Pprod - radsP) _CONV_UNIT_)
_SET_ODE_(self%id_pdet, (radsP - f_T * Pprod) _CONV_UNIT_) _ADD_SOURCE_(self%id_pdet, (radsP - f_T * Pprod) _CONV_UNIT_)
! Export diagnostic variables ! Export diagnostic variables
_SET_DIAGNOSTIC_(self%id_denit,Denitrific) _SET_DIAGNOSTIC_(self%id_denit,Denitrific)
......
...@@ -153,12 +153,12 @@ ...@@ -153,12 +153,12 @@
if ( self%external_tracer ) then if ( self%external_tracer ) then
_GET_(self%id_tracer,tracer) _GET_(self%id_tracer,tracer)
_GET_(self%id_age_alpha,alpha) _GET_(self%id_age_alpha,alpha)
_SET_ODE_(self%id_age_alpha,tracer) _ADD_SOURCE_(self%id_age_alpha,tracer)
age = 0.0_rk age = 0.0_rk
if ( tracer .gt. 0.0_rk ) age = alpha/tracer if ( tracer .gt. 0.0_rk ) age = alpha/tracer
_SET_DIAGNOSTIC_(self%id_tracer_age,age/secs_pr_day) _SET_DIAGNOSTIC_(self%id_tracer_age,age/secs_pr_day)
else else
_SET_ODE_(self%id_age,1.0_rk/secs_pr_day) _ADD_SOURCE_(self%id_age,1.0_rk/secs_pr_day)
endif endif
! Leave spatial loops (if any) ! Leave spatial loops (if any)
......
...@@ -932,21 +932,21 @@ subroutine initialize(self,configunit) ...@@ -932,21 +932,21 @@ subroutine initialize(self,configunit)
! Calculation of late auxiliary variables ! Calculation of late auxiliary variables
! Applying time tendencies for tracers ! Applying time tendencies for tracers
_SET_ODE_(self%id_t_n2 ,0.0_rk + (p_det_denit_nh4)*(2.65_rk) /secs_pr_day + (p_h2s_oxno3_sul)*(0.2_rk) /secs_pr_day + (p_sul_oxno3_so4)*(0.6_rk) /secs_pr_day - (p_n2_assim_cya)*(0.5_rk) /secs_pr_day ) _ADD_SOURCE_(self%id_t_n2 ,0.0_rk + (p_det_denit_nh4)*(2.65_rk) /secs_pr_day + (p_h2s_oxno3_sul)*(0.2_rk) /secs_pr_day + (p_sul_oxno3_so4)*(0.6_rk) /secs_pr_day - (p_n2_assim_cya)*(0.5_rk) /secs_pr_day )
_SET_ODE_(self%id_t_o2 ,0.0_rk + (p_no3_assim_lpp)*(8.625_rk) /secs_pr_day + (p_nh4_assim_lpp)*(6.625_rk) /secs_pr_day + (p_no3_assim_spp)*(8.625_rk) /secs_pr_day + (p_nh4_assim_spp)*(6.625_rk) /secs_pr_day + (p_n2_assim_cya)*(7.375_rk) /secs_pr_day - (p_lpp_resp_nh4)*(6.625_rk) /secs_pr_day - (p_spp_resp_nh4)*(6.625_rk) /secs_pr_day - (p_cya_resp_nh4)*(6.625_rk) /secs_pr_day - (p_zoo_resp_nh4)*(6.625_rk) /secs_pr_day - (p_nh4_nit_no3)*(2) /secs_pr_day - (p_det_resp_nh4)*(6.625_rk) /secs_pr_day - (p_h2s_oxo2_sul)*(0.5_rk) /secs_pr_day - (p_sul_oxo2_so4)*(1.5_rk) /secs_pr_day ) _ADD_SOURCE_(self%id_t_o2 ,0.0_rk + (p_no3_assim_lpp)*(8.625_rk) /secs_pr_day + (p_nh4_assim_lpp)*(6.625_rk) /secs_pr_day + (p_no3_assim_spp)*(8.625_rk) /secs_pr_day + (p_nh4_assim_spp)*(6.625_rk) /secs_pr_day + (p_n2_assim_cya)*(7.375_rk) /secs_pr_day - (p_lpp_resp_nh4)*(6.625_rk) /secs_pr_day - (p_spp_resp_nh4)*(6.625_rk) /secs_pr_day - (p_cya_resp_nh4)*(6.625_rk) /secs_pr_day - (p_zoo_resp_nh4)*(6.625_rk) /secs_pr_day - (p_nh4_nit_no3)*(2) /secs_pr_day - (p_det_resp_nh4)*(6.625_rk) /secs_pr_day - (p_h2s_oxo2_sul)*(0.5_rk) /secs_pr_day - (p_sul_oxo2_so4)*(1.5_rk) /secs_pr_day )
_SET_ODE_(self%id_t_nh4 ,0.0_rk + p_lpp_resp_nh4 /secs_pr_day + p_spp_resp_nh4 /secs_pr_day + p_cya_resp_nh4 /secs_pr_day + p_zoo_resp_nh4 /secs_pr_day + p_det_resp_nh4 /secs_pr_day + p_det_denit_nh4 /secs_pr_day + p_det_sulf_nh4 /secs_pr_day - p_nh4_assim_lpp /secs_pr_day - p_nh4_assim_spp /secs_pr_day - p_nh4_nit_no3 /secs_pr_day ) _ADD_SOURCE_(self%id_t_nh4 ,0.0_rk + p_lpp_resp_nh4 /secs_pr_day + p_spp_resp_nh4 /secs_pr_day + p_cya_resp_nh4 /secs_pr_day + p_zoo_resp_nh4 /secs_pr_day + p_det_resp_nh4 /secs_pr_day + p_det_denit_nh4 /secs_pr_day + p_det_sulf_nh4 /secs_pr_day - p_nh4_assim_lpp /secs_pr_day - p_nh4_assim_spp /secs_pr_day - p_nh4_nit_no3 /secs_pr_day )
_SET_ODE_(self%id_t_no3 ,0.0_rk + p_nh4_nit_no3 /secs_pr_day - p_no3_assim_lpp /secs_pr_day - p_no3_assim_spp /secs_pr_day - (p_det_denit_nh4)*(5.3_rk) /secs_pr_day - (p_h2s_oxno3_sul)*(0.4_rk) /secs_pr_day - (p_sul_oxno3_so4)*(1.2_rk) /secs_pr_day ) _ADD_SOURCE_(self%id_t_no3 ,0.0_rk + p_nh4_nit_no3 /secs_pr_day - p_no3_assim_lpp /secs_pr_day - p_no3_assim_spp /secs_pr_day - (p_det_denit_nh4)*(5.3_rk) /secs_pr_day - (p_h2s_oxno3_sul)*(0.4_rk) /secs_pr_day - (p_sul_oxno3_so4)*(1.2_rk) /secs_pr_day )
_SET_ODE_(self%id_t_po4 ,0.0_rk + (p_lpp_resp_nh4)*(rfr_p) /secs_pr_day + (p_spp_resp_nh4)*(rfr_p) /secs_pr_day + (p_cya_resp_nh4)*(rfr_p) /secs_pr_day + (p_zoo_resp_nh4)*(rfr_p) /secs_pr_day + (p_det_resp_nh4)*(rfr_p) /secs_pr_day + (p_det_denit_nh4)*(rfr_p) /secs_pr_day + (p_det_sulf_nh4)*(rfr_p) /secs_pr_day - (p_no3_assim_lpp)*(rfr_p) /secs_pr_day - (p_nh4_assim_lpp)*(rfr_p) /secs_pr_day - (p_no3_assim_spp)*(rfr_p) /secs_pr_day - (p_nh4_assim_spp)*(rfr_p) /secs_pr_day - (p_n2_assim_cya)*(rfr_p) /secs_pr_day ) _ADD_SOURCE_(self%id_t_po4 ,0.0_rk + (p_lpp_resp_nh4)*(rfr_p) /secs_pr_day + (p_spp_resp_nh4)*(rfr_p) /secs_pr_day + (p_cya_resp_nh4)*(rfr_p) /secs_pr_day + (p_zoo_resp_nh4)*(rfr_p) /secs_pr_day + (p_det_resp_nh4)*(rfr_p) /secs_pr_day + (p_det_denit_nh4)*(rfr_p) /secs_pr_day + (p_det_sulf_nh4)*(rfr_p) /secs_pr_day - (p_no3_assim_lpp)*(rfr_p) /secs_pr_day - (p_nh4_assim_lpp)*(rfr_p) /secs_pr_day - (p_no3_assim_spp)*(rfr_p) /secs_pr_day - (p_nh4_assim_spp)*(rfr_p) /secs_pr_day - (p_n2_assim_cya)*(rfr_p) /secs_pr_day )
_SET_ODE_(self%id_t_spp ,0.0_rk + p_no3_assim_spp /secs_pr_day + p_nh4_assim_spp /secs_pr_day - p_spp_graz_zoo /secs_pr_day - p_spp_resp_nh4 /secs_pr_day - p_spp_mort_det /secs_pr_day ) _ADD_SOURCE_(self%id_t_spp ,0.0_rk + p_no3_assim_spp /secs_pr_day + p_nh4_assim_spp /secs_pr_day - p_spp_graz_zoo /secs_pr_day - p_spp_resp_nh4 /secs_pr_day - p_spp_mort_det /secs_pr_day )
_SET_ODE_(self%id_t_zoo ,0.0_rk + p_lpp_graz_zoo /secs_pr_day + p_spp_graz_zoo /secs_pr_day + p_cya_graz_zoo /secs_pr_day - p_zoo_resp_nh4 /secs_pr_day - p_zoo_mort_det /secs_pr_day ) _ADD_SOURCE_(self%id_t_zoo ,0.0_rk + p_lpp_graz_zoo /secs_pr_day + p_spp_graz_zoo /secs_pr_day + p_cya_graz_zoo /secs_pr_day - p_zoo_resp_nh4 /secs_pr_day - p_zoo_mort_det /secs_pr_day )
_SET_ODE_(self%id_t_h2s ,0.0_rk + (p_det_sulf_nh4)*(3.3125_rk) /secs_pr_day - p_h2s_oxo2_sul /secs_pr_day - p_h2s_oxno3_sul /secs_pr_day ) _ADD_SOURCE_(self%id_t_h2s ,0.0_rk + (p_det_sulf_nh4)*(3.3125_rk) /secs_pr_day - p_h2s_oxo2_sul /secs_pr_day - p_h2s_oxno3_sul /secs_pr_day )
_SET_ODE_(self%id_t_sul ,0.0_rk + p_h2s_oxo2_sul /secs_pr_day + p_h2s_oxno3_sul /secs_pr_day - p_sul_oxo2_so4 /secs_pr_day - p_sul_oxno3_so4 /secs_pr_day ) _ADD_SOURCE_(self%id_t_sul ,0.0_rk + p_h2s_oxo2_sul /secs_pr_day + p_h2s_oxno3_sul /secs_pr_day - p_sul_oxo2_so4 /secs_pr_day - p_sul_oxno3_so4 /secs_pr_day )
_SET_ODE_(self%id_t_ipw ,0.0_rk ) _ADD_SOURCE_(self%id_t_ipw ,0.0_rk )
_SET_ODE_(self%id_t_lpp ,0.0_rk + p_no3_assim_lpp /secs_pr_day + p_nh4_assim_lpp /secs_pr_day - p_lpp_graz_zoo /secs_pr_day - p_lpp_resp_nh4 /secs_pr_day - p_lpp_mort_det /secs_pr_day ) _ADD_SOURCE_(self%id_t_lpp ,0.0_rk + p_no3_assim_lpp /secs_pr_day + p_nh4_assim_lpp /secs_pr_day - p_lpp_graz_zoo /secs_pr_day - p_lpp_resp_nh4 /secs_pr_day - p_lpp_mort_det /secs_pr_day )
_SET_ODE_(self%id_t_cya ,0.0_rk + p_n2_assim_cya /secs_pr_day - p_cya_graz_zoo /secs_pr_day - p_cya_resp_nh4 /secs_pr_day - p_cya_mort_det /secs_pr_day ) _ADD_SOURCE_(self%id_t_cya ,0.0_rk + p_n2_assim_cya /secs_pr_day - p_cya_graz_zoo /secs_pr_day - p_cya_resp_nh4 /secs_pr_day - p_cya_mort_det /secs_pr_day )
_SET_ODE_(self%id_t_det ,0.0_rk + p_lpp_mort_det /secs_pr_day + p_spp_mort_det /secs_pr_day + p_cya_mort_det /secs_pr_day + p_zoo_mort_det /secs_pr_day - p_det_resp_nh4 /secs_pr_day - p_det_denit_nh4 /secs_pr_day - p_det_sulf_nh4 /secs_pr_day ) _ADD_SOURCE_(self%id_t_det ,0.0_rk + p_lpp_mort_det /secs_pr_day + p_spp_mort_det /secs_pr_day + p_cya_mort_det /secs_pr_day + p_zoo_mort_det /secs_pr_day - p_det_resp_nh4 /secs_pr_day - p_det_denit_nh4 /secs_pr_day - p_det_sulf_nh4 /secs_pr_day )
if (_AVAILABLE_(self%id_t_dic)) _SET_ODE_(self%id_t_dic, rfr_c*(r_pp_mort * food_zoo + r_zoo_resp * zoo_eff + r_sed_rec * t_det - r_det_rec * spp_plus_spp0 - r_lpp_assim * lpp_plus_lpp0 - r_cya_assim * cya_plus_cya0)/secs_pr_day) if (_AVAILABLE_(self%id_t_dic)) _ADD_SOURCE_(self%id_t_dic, rfr_c*(r_pp_mort * food_zoo + r_zoo_resp * zoo_eff + r_sed_rec * t_det - r_det_rec * spp_plus_spp0 - r_lpp_assim * lpp_plus_lpp0 - r_cya_assim * cya_plus_cya0)/secs_pr_day)
! Export diagnostic variables ! Export diagnostic variables
! _SET_DIAGNOSTIC_(self%id_dPAR,par) ! _SET_DIAGNOSTIC_(self%id_dPAR,par)
...@@ -1372,18 +1372,18 @@ subroutine initialize(self,configunit) ...@@ -1372,18 +1372,18 @@ subroutine initialize(self,configunit)
p_ips_burial = (ips_eff*r_ips_burial*sed_active/sed_max)*lim_t_ips_17 p_ips_burial = (ips_eff*r_ips_burial*sed_active/sed_max)*lim_t_ips_17
! Apply time tendencies to tracers ! Apply time tendencies to tracers
_SET_BOTTOM_ODE_(self%id_t_sed ,0.0_rk + p_det_sedi_sed /secs_pr_day - p_sed_resp_nh4 /secs_pr_day - p_sed_denit_nh4 /secs_pr_day - p_sed_sulf_nh4 /secs_pr_day - p_sed_ero_det /secs_pr_day - p_sed_biores_det /secs_pr_day - p_sed_burial /secs_pr_day )