Skip to content

Commit

Permalink
add minimum and maximum biomass conc. for ICM oyster and SAV
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhengui committed Sep 18, 2024
1 parent 4746d15 commit 3e65e00
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
2 changes: 2 additions & 0 deletions sample_inputs/icm.nml
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ s2ht = 0.0036 0.0036 0.0 !coeffs. converting (leaf,stem,root) to canopy heigh
sc2dw = 0.38 !carbon to dry weight ratio of sav
sn2c = 0.09 !nitrogen to carbon ratio of sav
sp2c = 0.01 !phosphorus to carbon ratio
savm = 1.0 1.0 1.0 0.2 500.0 500.0 500.0 100 !minimum and maximum SAV leaf/stem/root/tuber conc (g[C].m-2)

!----------------------
!Epiphytes (activated when isav_icm=2)
Expand Down Expand Up @@ -620,6 +621,7 @@ cDoyp = 152 152 152 152 152 304 304 304 304 304 !date range for predation
cDoyh = 122 122 122 122 122 274 274 274 274 274 !date range for predation (day of year)
cn2c = 0.167 0.167 0.167 0.167 0.167 !nitrogen to carbon ratio
cp2c = 0.011 0.011 0.011 0.011 0.011 !phosphorus to carbon ratio
clamm = 0.001 0.001 0.001 0.001 0.001 1.0 1.0 1.0 1.0 1.0 !minimum and maximum clam conc. [g[C].m-2)
/

&ERO
Expand Down
36 changes: 29 additions & 7 deletions src/ICM/icm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -926,8 +926,8 @@ subroutine sav_calc(id,kb,zid,shtz,tdep,sLight0)
real(rkind),intent(in),dimension(nvrt) :: zid,sLight0

!local variables
integer :: k
real(rkind) :: drat,srat,leafC,stemC,xT,mLight,rIK,Ns,Ps,fT,fI,fN,fP,zm
integer :: i,k
real(rkind) :: drat,srat,leafC,stemC,xT,mLight,rIK,Ns,Ps,fT,fI,fN,fP,zm,sFCPm(4)
real(rkind) :: sfPN,sfPNb,sfPPb,leaf0,stem0,TB,MT0(4),BM,BMb,sfT,sfI,sfN,sfP,s
real(rkind) :: efT,eKd,efI,efN,efP,efEP,eGP,eMT,ePR,efPN,zEP0,eMT0
real(rkind),dimension(nvrt) :: sLight,dz,zleaf,zstem,GP,MT1,MT2,zEP
Expand Down Expand Up @@ -1012,14 +1012,29 @@ subroutine sav_calc(id,kb,zid,shtz,tdep,sLight0)
MT0(4)=sMTB(4)*exp(sKTMT(4)*(temp(kb+1)-sTMT(4)))*tuber
endif

!apply minimum and maximum conc.
sFCPm=sFCP !initial partitioning coefficient
do i=1,4
if(sav(i,id)<savm(i,1)) then !reach the minimum
MT0(i)=0.0
if(i==1) MT1(k)=0.0
if(i==2) MT2(k)=0.0
if(i==4) TB=0.0
elseif(sav(i,id)>savm(i,2)) then !reach the maximum
sFCPm(i)=0.0
endif
enddo
s=sum(sFCPm); sFCPm=sFCPm/max(s,1.d-3) !modify mass distribution
if(s<1.d-6) GP(k)=0.0 !turn off growth if maximum concentrations are reached

!new concentration
zleaf(k)=zleaf(k)+(sFCP(1)*(1.0-sFAM)*GP(k)-MT1(k)+TB/Hs)*dtw
zstem(k)=zstem(k)+(sFCP(2)*(1.0-sFAM)*GP(k)-MT2(k))*dtw
zleaf(k)=zleaf(k)+(sFCPm(1)*(1.0-sFAM)*GP(k)-MT1(k)+TB/Hs)*dtw
zstem(k)=zstem(k)+(sFCPm(2)*(1.0-sFAM)*GP(k)-MT2(k))*dtw
if(k==nvrt) then !For SAV above water, only metabolism is allowed
leaf0=leaf0-MT0(1)*dtw
stem0=stem0-MT0(2)*dtw
sroot=sroot+(sFCP(3)*(1.0-sFAM)*sum(GP((kb+1):nvrt)*dz((kb+1):nvrt))-MT0(3))*dtw
tuber=tuber+(sFCP(4)*(1.0-sFAM)*sum(GP((kb+1):nvrt)*dz((kb+1):nvrt))-MT0(4)-TB)*dtw
sroot=sroot+(sFCPm(3)*(1.0-sFAM)*sum(GP((kb+1):nvrt)*dz((kb+1):nvrt))-MT0(3))*dtw
tuber=tuber+(sFCPm(4)*(1.0-sFAM)*sum(GP((kb+1):nvrt)*dz((kb+1):nvrt))-MT0(4)-TB)*dtw
endif

!debug
Expand Down Expand Up @@ -1210,7 +1225,14 @@ subroutine clam_calc(id,kb,wdz)
RT(i)=cMRT(i)*(1.d0-fDO(i))*CLAM(i,id) !mortality (g[C].m-2.day-1)
if(idoy>=cDoyp(i,1).and.idoy<=cDoyp(i,2)) PR(i) =cPRR(i)*CLAM(i,id) !predation (g[C].m-2.day-1)
if(idoy>=cDoyh(i,1).and.idoy<=cDoyh(i,2)) HST(i)=cHSR(i)*CLAM(i,id) !harvest (g[C].m-2.day-1)
CLAM(i,id)=CLAM(i,id)+(GP(i)-MT(i)-RT(i)-PR(i)-HST(i))*dtw !update clam biomass

!update clam biomass
if(CLAM(i,id)<clamm(i,1)) then !reach minimum biomass conc.
MT(i)=0.0; RT(i)=0.0; RT(i)=0.0; HST(i)=0.0
elseif (CLAM(i,id)>clam(i,2)) then !reach maximum biomass conc.
Fr(i)=0.0; GP(i)=0.0; TFC(i)=0.0; TFN(i)=0.0; TFP(i)=0.0; ATFC(i)=0.0; ATFN(i)=0.0; ATFP(i)=0.0
endif
CLAM(i,id)=CLAM(i,id)+(GP(i)-MT(i)-RT(i)-PR(i)-HST(i))*dtw

!debug
if(idbg(10)/=0) then
Expand Down
22 changes: 12 additions & 10 deletions src/ICM/icm_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ subroutine read_icm_param(imode)
& zFSP,zFCM,zFNM,zFPM,zFSM,zKhDO,zn2c,zp2c,zs2c,z2pr,p2pr
namelist /PH_ICM/ ppatch0,inu_ph,pKCACO3,pKCA,pRea
namelist /SAV_ICM/ spatch0,sFc,sav0,sGPM,sTGP,sKTGP,sFAM,sFCP,sMTB,sTMT,sKTMT,sFNM,sFPM,sFCM,sFNMb, &
& sFPMb,sFCMb,sKTB,sDoy,sKhN,sKhP,salpha,sKe,shtm,s2ht,sc2dw,sn2c,sp2c,EP0,eGPM,eTGP, &
& sFPMb,sFCMb,sKTB,sDoy,sKhN,sKhP,salpha,sKe,shtm,s2ht,sc2dw,sn2c,sp2c,savm,EP0,eGPM,eTGP, &
& eKTGP,eKe,ealpha,eMTB,eTMT,eKTMT,ePRR,eFCM,eFNM,eFPM,eFCP,eFNP,eFPP,en2c,ep2c,eKhN,eKhP,eKhE
namelist /MARSH/ iNmarsh,vpatch0,vmarsh0,vGPM,vFAM,vTGP,vKTGP,vFCP,vMTB,vTMT,vKTMT,vFCM,vFNM, &
& vFPM,vFW,vKhN,vKhP,valpha,vKe,vSopt,vKs,vInun,vht0,vcrit,v2ht,vc2dw,vn2c,vp2c,vAw, &
Expand All @@ -70,7 +70,7 @@ subroutine read_icm_param(imode)
namelist /BAG/ gpatch0,gBA0,gGPM,gTGP,gKTGP,gMTB,gPRR,gTR,gKTR,galpha,gKSED,gKBA,gKhN,gKhP, &
& gp2c,gn2c,gFCP,gFNP,gFPP
namelist /CLAM_ICM/ cpatch0,cFc,clam0,cfrmax,cTFR,csalt,cKDO,cDOh,cfTSSm,cRF,cIFmax,cMTB, &
& cTMT,cKTMT,cMRT,cPRR,cHSR,cDoyp,CDoyh,cn2c,cp2c,cKTFR,cKTSS,cTSS,calpha
& cTMT,cKTMT,cMRT,cPRR,cHSR,cDoyp,CDoyh,cn2c,cp2c,cKTFR,cKTSS,cTSS,calpha,clamm
namelist /ERO/ ierosion,erosion,etau,eporo,efrac,ediso,dfrac,dWS_POC

if(imode==0) then
Expand Down Expand Up @@ -103,7 +103,7 @@ subroutine read_icm_param(imode)
allocate(clam0(nclam),cfrmax(nclam),cTFR(nclam),csalt(nclam),cKDO(nclam),cDOh(nclam),cfTSSm(nclam), &
& cRF(nclam),cIFmax(nclam),cMTB(nclam),cTMT(nclam),cKTMT(nclam),cMRT(nclam),cn2c(nclam), &
& cp2c(nclam),cKTFR(nclam,2),cKTSS(nclam,2),cTSS(nclam,4),calpha(nclam,5),cPRR(nclam), &
& cHSR(nclam),cDoyp(nclam,2),CDoyh(nclam,2),cFc(nclam),stat=istat)
& cHSR(nclam),cDoyp(nclam,2),CDoyh(nclam,2),cFc(nclam),clamm(nclam,2),stat=istat)
if(istat/=0) call parallel_abort('failed in alloc. clam0')
allocate(vmarsh0(nmarsh,3),vGPM(nmarsh),vFAM(nmarsh),vTGP(nmarsh),vKTGP(nmarsh,2), &
& vFCP(nmarsh,3),vMTB(nmarsh,3),vTMT(nmarsh,3),vKTMT(nmarsh,3),vFCM(nmarsh,4),vFNM(nmarsh,4), &
Expand Down Expand Up @@ -134,7 +134,7 @@ subroutine read_icm_param(imode)
!init. SAV module
spatch0=0; sFc=0; sav0=0; sGPM=0; sTGP=0; sKTGP=0; sFAM=0; sFCP=0; sMTB=0; sTMT=0; sKTMT=0;
sFNM=0; sFPM=0; sFCM=0; sFNMb=0; sFPMb=0; sFCMb=0; sKhN=0; sKhP=0; salpha=0; sKe=0;
shtm=0; s2ht=0; sc2dw=0; sn2c=0; sp2c=0; EP0=0; eGPM=0; eTGP=0; eKTGP=0; eKe=0; ealpha=0;
shtm=0; s2ht=0; sc2dw=0; sn2c=0; sp2c=0; savm=0; EP0=0; eGPM=0; eTGP=0; eKTGP=0; eKe=0; ealpha=0;
eMTB=0; eTMT=0; eKTMT=0; ePRR=0; eFCM=0; eFNM=0; eFPM=0; eFCP=0; eFNP=0; eFPP=0; en2c=0;
ep2c=0; eKhN=0; eKhP=0; eKhE=0

Expand Down Expand Up @@ -163,7 +163,7 @@ subroutine read_icm_param(imode)
!init. CLAM module
cpatch0=1; clam0=0; cfrmax=0; cTFR=0; csalt=0; cKDO=0; cDOh=0; cfTSSm=0; cRF=0; cIFmax=0
cMTB=0; cTMT=0; cKTMT=0; cMRT=0; cPRR=0; cHSR=0; cDoyp=0; cDoyh=0; cn2c=0; cp2c=0
cKTFR=0; cKTSS=0; cTSS=0; calpha=0; cFc=1.0
cKTFR=0; cKTSS=0; cTSS=0; calpha=0; cFc=1.0; clamm=0

!init. ERO module
ierosion=0; erosion=0; etau=0; eporo=0; efrac=0; ediso=0; dfrac=0; dWS_POC=0
Expand Down Expand Up @@ -880,19 +880,19 @@ subroutine icm_vars_init

!SAV,MARSH,BA,pH,CLAM modules
if(jsav/=0) then
pname((m+1):(m+28))=&
pname((m+1):(m+29))=&
& (/'spatch0','sav0 ','sGPM ','sTGP ','sKTGP ',&
& 'sFAM ','sFCP ','sMTB ','sTMT ','sKTMT ',&
& 'sFCM ','sFNM ','sFPM ','sFCMb ','sFNMb ',&
& 'sFPMb ','sKhN ','sKhP ','salpha ','sKe ',&
& 'shtm ','s2ht ','sc2dw ','sn2c ','sp2c ',&
& 'sKTB ','sDoy ','sFc '/)
& 'sKTB ','sDoy ','sFc ','savm '/)
sp(m+1)%p=>spatch0; sp(m+2)%p1=>sav0; sp(m+3)%p=>sGPM; sp(m+4)%p=>sTGP; sp(m+5)%p1=>sKTGP; m=m+5
sp(m+1)%p=>sFAM; sp(m+2)%p1=>sFCP; sp(m+3)%p1=>sMTB; sp(m+4)%p1=>sTMT; sp(m+5)%p1=>sKTMT; m=m+5
sp(m+1)%p1=>sFCM; sp(m+2)%p1=>sFNM; sp(m+3)%p1=>sFPM; sp(m+4)%p1=>sFCMb; sp(m+5)%p1=>sFNMb; m=m+5
sp(m+1)%p1=>sFPMb; sp(m+2)%p1=>sKhN; sp(m+3)%p1=>sKhP; sp(m+4)%p=>salpha; sp(m+5)%p=>sKe; m=m+5
sp(m+1)%p1=>shtm; sp(m+2)%p1=>s2ht; sp(m+3)%p=>sc2dw; sp(m+4)%p=>sn2c; sp(m+5)%p=>sp2c; m=m+5
sp(m+1)%p=>sKTB; sp(m+2)%p1=>sDoy; sp(m+3)%p=>sFc; m=m+3
sp(m+1)%p=>sKTB; sp(m+2)%p1=>sDoy; sp(m+3)%p=>sFc; sp(m+4)%p2=>savm; m=m+4
if(jsav==2) then
pname((m+1):(m+21))=&
& (/'EP0 ','eGPM ','eTGP ','eKTGP ','eKe ',&
Expand Down Expand Up @@ -943,17 +943,19 @@ subroutine icm_vars_init
endif

if(iClam==1) then
pname((m+1):(m+25))=&
pname((m+1):(m+26))=&
& (/'cpatch0','clam0 ','cfrmax ','cTFR ','csalt ',&
& 'cKDO ','cDOh ','cfTSSm ','cRF ','cIFmax ',&
& 'cMTB ','cTMT ','cKTMT ','cMRT ','cPRR ',&
& 'cHSR ','cDoyp ','cDoyh ','cn2c ','cp2c ',&
& 'cKTFR ','cKTSS ','cTSS ','calpha ','cFc '/)
& 'cKTFR ','cKTSS ','cTSS ','calpha ','cFc ',&
& 'clamm '/)
sp(m+1)%p=>cpatch0; sp(m+2)%p1=>clam0; sp(m+3)%p1=>cfrmax; sp(m+4)%p1=>cTFR; sp(m+5)%p1=>csalt; m=m+5
sp(m+1)%p1=>cKDO; sp(m+2)%p1=>cDOh; sp(m+3)%p1=>cfTSSm; sp(m+4)%p1=>cRF; sp(m+5)%p1=>cIFmax; m=m+5
sp(m+1)%p1=>cMTB; sp(m+2)%p1=>cTMT; sp(m+3)%p1=>cKTMT; sp(m+4)%p1=>cMRT; sp(m+5)%p1=>cPRR; m=m+5
sp(m+1)%p1=>cHSR; sp(m+2)%p2=>cDoyp; sp(m+3)%p2=>cDoyh; sp(m+4)%p1=>cn2c; sp(m+5)%p1=>cp2c; m=m+5
sp(m+1)%p2=>cKTFR; sp(m+2)%p2=>cKTSS; sp(m+3)%p2=>cTSS; sp(m+4)%p2=>calpha;sp(m+5)%p1=>cFc; m=m+5
sp(m+1)%p2=>clamm; m=m+1
endif

!read spatially varying parameters
Expand Down
4 changes: 2 additions & 2 deletions src/ICM/icm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module icm_mod
real(rkind),save,target :: sFCMb(4),sFNMb(4),sFPMb(4) !metabolism of root to (POM(G1-G3),dissolved nutrients)
real(rkind),save,target :: sKTB,sDoy(2),sKhN(2),sKhP(2) !tuber mass transfer, half-saturation conc. of N, P
real(rkind),save,target :: salpha,sKe,shtm(2),s2ht(3) !(P-I curve, light attenu., canopy height)
real(rkind),save,target :: sc2dw,sn2c,sp2c !convert ratios
real(rkind),save,target :: sc2dw,sn2c,sp2c,savm(4,2) !convert ratios,min and max conc.
real(rkind),save,target :: EP0,eGPM,eTGP,eKTGP(2),eKe,ealpha,eMTB,eTMT,eKTMT,ePRR,eKhN,eKhP,eKhE !epiphytes growth,metabolism, predation
real(rkind),save,target :: eFCM(4),eFNM(4),eFPM(4),eFCP(4),eFNP(4),eFPP(4),en2c,ep2c !epiphytes partition

Expand Down Expand Up @@ -177,7 +177,7 @@ module icm_mod
real(rkind),save,target :: cpatch0
real(rkind),save,target,allocatable,dimension(:) :: cFc,clam0,cfrmax,cTFR,csalt,cKDO,cDOh,cfTSSm,cRF, &
& cIFmax,cMTB,cTMT,cKTMT,cMRT,cPRR,cHSR,cn2c,cp2c
real(rkind),save,target,allocatable,dimension(:,:) :: cKTFR,cKTSS,cTSS,calpha,cDoyp,cDoyh
real(rkind),save,target,allocatable,dimension(:,:) :: cKTFR,cKTSS,cTSS,calpha,cDoyp,cDoyh,clamm

integer,save,allocatable,dimension(:) :: cpatch
real(rkind),save,target,allocatable,dimension(:,:) :: CLAM,cFPOC,cFPON,cFPOP
Expand Down

0 comments on commit 3e65e00

Please sign in to comment.