Skip to content

Commit

Permalink
1)fix a bug in simple marsh model, 2). make vKPOM vary for each WQ va…
Browse files Browse the repository at this point in the history
…raiables
  • Loading branch information
wzhengui committed Aug 23, 2024
1 parent cc238c5 commit a35a085
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
3 changes: 2 additions & 1 deletion sample_inputs/icm.nml
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,15 @@ vp2c = 0.01 0.01 0.01 !phosphorus to carbon ratio [nmarsh]

!----------------------
!simple wetland model (imarsh=2)
!vKPOM (order same as WSP): (PB1,PB2,PB3) (RPOC,LPOC,DOC) (RPON,LPON,DON,NH4,NO3) (RPOP,LPOP,DOP,PO4) (COD,DO) (SRPOM, PIP)
!----------------------
vAw = 0.1 !ratio between marsh area to adjacent water volume (m-1)
vKNO3 = 0.01 !mass-transfer coefficient for NO3 removal (m.day-1)
vKPOM = 0.05 !settling velocity caused by marsh (m.day-1)
vKTw = 0.069 !temperature dependence for wetland effect (oC-1)
vRTw = 20 !reference temperature for wetland effect (oC)
vKhDO = 1.0 !half saturation for wetland effect (mg/L)
vOCw = 0.1 !wetland oxygen consumption rate (g.m-2.day-1)
vKPOM = 0.005 0.005 0.0 0.05 0.05 0.0 0.05 0.05 0.0 0.0 0.0 0.05 0.05 0.0 0.0 0.0 0.0 0.05 0.05 0.05 0.01 !settling velocity caused by marsh (m.day-1)
/

&BAG
Expand Down
25 changes: 13 additions & 12 deletions src/ICM/icm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ subroutine marsh_calc(id,kb,zid,vhtz,vLight)

!local variables
integer :: i,j,k,m
real(rkind) :: fR,fT,fST,fI,fN,fP,fDO,mLight,mtemp,msalt,rIK,Kd,xT,xS,rc,vdc,drat
real(rkind) :: fR,fT,fST,fI,fN,fP,fDO,mLight,mtemp,msalt,rIK,Kd,xT,xS,vdc,drat
real(rkind),dimension(nmarsh) :: BMw,BMb,srat,orat
real(rkind) :: tdep,dz(nvrt),GP(nmarsh),MT(3,nmarsh)
real(rkind),pointer,dimension(:) :: vleaf,vstem,vroot
Expand Down Expand Up @@ -777,21 +777,22 @@ subroutine marsh_calc(id,kb,zid,vhtz,vLight)
elseif(vpatch(id)==1.and.jmarsh==2.and.idry_e(id)==0) then
!currently, the sink due marsh doesn't go to the sediment (todo) for this simple model
db_vdNO3(id)=0; db_vdDOX(id)=0; db_vdRPOC(id)=0; db_vdLPOC(id)=0; db_vdRPON(id)=0; db_vdLPON(id)=0
db_vdRPOP(id)=0; db_vdLPOP(id)=0; db_vdSRPOC(id)=0; db_vdSRPON(id)=0; db_vdSRPOP(id)=0
db_vdRPOP(id)=0; db_vdLPOP(id)=0; db_vdSRPOC(id)=0; db_vdSRPON(id)=0; db_vdSRPOP(id)=0; db_vdPIP(id)=0
do k=kb+1,nvrt
fT=exp(vKTw*(temp(k)-vRTw)); fDO=DOX(k)/(vKhDO+DOX(k)); rc=vKPOM*vAw !pre-compute
fT=exp(vKTw*(temp(k)-vRTw)); fDO=DOX(k)/(vKhDO+DOX(k)) !pre-compute
vdc=vKNO3*vAw*fT*NO3(k); vdwqc(iNO3,k)=-vdc; db_vdNO3(id)=db_vdNO3(id)+vdc*dz(k) !vdNO3: g.m-2.day
vdc=vAw*fDO*fT*vOCw; vdwqc(iDOX,k)=-vdc; db_vdDOX(id)=db_vdDOX(id)+vdc*dz(k)
vdc=rc*RPOC(k); vdwqc(iRPOC,k)=-vdc; db_vdRPOC(id)=db_vdRPOC(id)+vdc*dz(k)
vdc=rc*LPOC(k); vdwqc(iLPOC,k)=-vdc; db_vdLPOC(id)=db_vdLPOC(id)+vdc*dz(k)
vdc=rc*RPON(k); vdwqc(iRPON,k)=-vdc; db_vdRPON(id)=db_vdRPON(id)+vdc*dz(k)
vdc=rc*LPON(k); vdwqc(iLPON,k)=-vdc; db_vdLPON(id)=db_vdLPON(id)+vdc*dz(k)
vdc=rc*RPOP(k); vdwqc(iRPOP,k)=-vdc; db_vdRPOP(id)=db_vdRPOP(id)+vdc*dz(k)
vdc=rc*LPOP(k); vdwqc(iLPOP,k)=-vdc; db_vdLPOP(id)=db_vdLPOP(id)+vdc*dz(k)
vdc=vKPOM(iRPOC)*vAW*RPOC(k); vdwqc(iRPOC,k)=-vdc; db_vdRPOC(id)=db_vdRPOC(id)+vdc*dz(k)
vdc=vKPOM(iLPOC)*vAW*LPOC(k); vdwqc(iLPOC,k)=-vdc; db_vdLPOC(id)=db_vdLPOC(id)+vdc*dz(k)
vdc=vKPOM(iRPON)*vAW*RPON(k); vdwqc(iRPON,k)=-vdc; db_vdRPON(id)=db_vdRPON(id)+vdc*dz(k)
vdc=vKPOM(iLPON)*vAW*LPON(k); vdwqc(iLPON,k)=-vdc; db_vdLPON(id)=db_vdLPON(id)+vdc*dz(k)
vdc=vKPOM(iRPOP)*vAW*RPOP(k); vdwqc(iRPOP,k)=-vdc; db_vdRPOP(id)=db_vdRPOP(id)+vdc*dz(k)
vdc=vKPOM(iLPOP)*vAW*LPOP(k); vdwqc(iLPOP,k)=-vdc; db_vdLPOP(id)=db_vdLPOP(id)+vdc*dz(k)
if(iSRM==1) then
vdc=rc*SRPOC(k); vdwqc(iSRPOC,k)=-vdc; db_vdSRPOC(id)=db_vdSRPOC(id)+vdc*dz(k)
vdc=rc*SRPON(k); vdwqc(iSRPON,k)=-vdc; db_vdSRPON(id)=db_vdSRPON(id)+vdc*dz(k)
vdc=rc*SRPOP(k); vdwqc(iSRPOP,k)=-vdc; db_vdSRPOP(id)=db_vdSRPOP(id)+vdc*dz(k)
vdc=vKPOM(iSRPOC)*vAw*SRPOC(k); vdwqc(iSRPOC,k)=-vdc; db_vdSRPOC(id)=db_vdSRPOC(id)+vdc*dz(k)
vdc=vKPOM(iSRPON)*vAw*SRPON(k); vdwqc(iSRPON,k)=-vdc; db_vdSRPON(id)=db_vdSRPON(id)+vdc*dz(k)
vdc=vKPOM(iSRPOP)*vAw*SRPOP(k); vdwqc(iSRPOP,k)=-vdc; db_vdSRPOP(id)=db_vdSRPOP(id)+vdc*dz(k)
vdc=vKPOM(iPIP)*vAw*PIP(k); vdwqc(iPIP,k) =-vdc; db_vdPIP(id) =db_vdPIP(id) +vdc*dz(k)
endif
enddo
endif !vpatch(id)
Expand Down
16 changes: 10 additions & 6 deletions src/ICM/icm_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ subroutine read_icm_param(imode)
& vFCP(nmarsh,3),vMTB(nmarsh,3),vTMT(nmarsh,3),vKTMT(nmarsh,3),vFCM(nmarsh,4),vFNM(nmarsh,4), &
& vFPM(nmarsh,4),vFW(nmarsh),vKhN(nmarsh),vKhP(nmarsh),valpha(nmarsh),vKe(nmarsh),vSopt(nmarsh), &
& vKs(nmarsh),vInun(nmarsh),vht0(nmarsh),vcrit(nmarsh),v2ht(nmarsh,2),vc2dw(nmarsh),vn2c(nmarsh), &
& vp2c(nmarsh),stat=istat)
& vp2c(nmarsh),vKPOM(ntrs_icm),stat=istat)
if(istat/=0) call parallel_abort('failed in alloc. vmarsh0')

!init. CORE module
Expand Down Expand Up @@ -349,7 +349,8 @@ subroutine read_icm_param(imode)
p=>wqout(nout+9); p%name='ICM_vdSRPOC'; allocate(p%data(1,1,nea)); p%p1=>p%data(1,1,:); p%p1=0; db_vdSRPOC=>p%p1; p%itype=4
p=>wqout(nout+10); p%name='ICM_vdSRPON'; allocate(p%data(1,1,nea)); p%p1=>p%data(1,1,:); p%p1=0; db_vdSRPON=>p%p1; p%itype=4
p=>wqout(nout+11); p%name='ICM_vdSRPOP'; allocate(p%data(1,1,nea)); p%p1=>p%data(1,1,:); p%p1=0; db_vdSRPOP=>p%p1; p%itype=4
nb=11; nouts(7)=nouts(7)+nb; nout=nout+nb
p=>wqout(nout+12); p%name='ICM_vdPIP'; allocate(p%data(1,1,nea)); p%p1=>p%data(1,1,:); p%p1=0; db_vdPIP=>p%p1; p%itype=4
nb=12; nouts(7)=nouts(7)+nb; nout=nout+nb
endif
endif

Expand Down Expand Up @@ -919,7 +920,7 @@ subroutine icm_vars_init
pname((m+1):(m+8))=&
& (/'vpatch0','vAw ','vKNO3 ','vKPOM ','vKTw ',&
& 'vRTw ','vKhDO ','vOCw '/)
sp(m+1)%p=>vpatch0; sp(m+2)%p=>vAw; sp(m+3)%p=>vKNO3; sp(m+4)%p=>vKPOM; sp(m+5)%p=>vKTw; m=m+5
sp(m+1)%p=>vpatch0; sp(m+2)%p=>vAw; sp(m+3)%p=>vKNO3; sp(m+4)%p1=>vKPOM; sp(m+5)%p=>vKTw; m=m+5
sp(m+1)%p=>vRTw; sp(m+2)%p=>vKhDO; sp(m+3)%p=>vOCw; m=m+3
endif

Expand Down Expand Up @@ -1047,9 +1048,12 @@ subroutine icm_vars_init
if(jsav==2) then; EP(i)=0; TEP(i)=0; endif
endif
endif
if(jmarsh==1) then
vpatch(i)=nint(vpatch0); vmarsh(:,:,i)=vmarsh0; call get_canopy(i)
if(vpatch(i)==0) then; vmarsh(:,:,i)=0; vht(:,i)=0; endif
if(jmarsh/=0) then
vpatch(i)=nint(vpatch0)
if(jmarsh==1) then
vmarsh(:,:,i)=vmarsh0; call get_canopy(i)
if(vpatch(i)==0) then; vmarsh(:,:,i)=0; vht(:,i)=0; endif
endif
endif
if(iBA==1) then
gpatch(i)=nint(gpatch0); gBA(i)=gBA0
Expand Down
5 changes: 3 additions & 2 deletions src/ICM/icm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ module icm_mod
!metabolism partition, growth limit of nutrient,light,salinity,inundation
real(rkind),save,target,allocatable,dimension(:) :: vFW,vKhN,vKhP,valpha,vKe,vSopt,vKs,vInun
real(rkind),save,target,allocatable :: vht0(:),vcrit(:),v2ht(:,:),vc2dw(:),vn2c(:),vp2c(:) !misc
real(rkind),save,target :: vAw,vKNO3,vKPOM,vKTW,vRTw,vKhDO,vOCw
real(rkind),save,target :: vAw,vKNO3,vKTW,vRTw,vKhDO,vOCw
real(rkind),save,target,allocatable :: vKPOM(:)

integer,save,allocatable :: vpatch(:) !marsh regions
real(rkind),save,target,allocatable :: vmarsh(:,:,:),vht(:,:) !marsh biomass
real(rkind),save,target,allocatable :: vFPOC(:,:),vFPON(:,:),vFPOP(:,:),vbNH4(:),vbPO4(:),vSOD(:) !sediment
real(rkind),save,pointer :: db_vGP(:,:),db_vBMw(:,:),db_vBMb(:,:)
real(rkind),save,pointer,dimension(:) :: db_vdNO3,db_vdDOX,db_vdRPOC,db_vdLPOC,db_vdRPON,db_vdLPON, &
& db_vdRPOP,db_vdLPOP,db_vdSRPOC,db_vdSRPON,db_vdSRPOP
& db_vdRPOP,db_vdLPOP,db_vdSRPOC,db_vdSRPON,db_vdSRPOP,db_vdPIP

!-------------------------------------------------------------------------------
!sediment flux model (SFM) parameters and variables
Expand Down

0 comments on commit a35a085

Please sign in to comment.