Skip to content

Commit

Permalink
Gamma leaf age calc only if on
Browse files Browse the repository at this point in the history
with the enhanced debug flags, was complaining about the
past (and/or current) LAI being unitialized in the first
expression of the calculation
  • Loading branch information
zmoon committed Feb 1, 2024
1 parent b3d6edb commit d241bea
Showing 1 changed file with 33 additions and 38 deletions.
71 changes: 33 additions & 38 deletions src/canopy_utils_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -658,56 +658,51 @@ function GET_GAMMA_LEAFAGE(leafage_opt,LAIpast,LAIcurrent,tsteplai,TABOVE,Anew,A
!------------------------------------------------------------------------------
!BOC

!-----------------------
! Compute GAMMA_LEAFAGE
!-----------------------


!TABOVE (Tt in MEGAN code) -> Above Canopy TEMP (tmp2mref or temp2)

! Calculate foliage fraction
!-----------------------
!Also, Compute ti and tm
! ti: number of days after budbreak required to induce emissions
! tm: number of days after budbreak required to reach peak emissions
IF (LAIcurrent - LAIpast > LAIdelta) THEN !(i.e. LAI has Increased)
IF (TABOVE .le. 303.0_rk) THEN
ti = 5.0_rk + 0.7_rk*(300.0_rk-TABOVE)
ELSE
ti = 2.9_rk
ENDIF
tm = 2.3_rk*ti
!Fnew calculated
IF (ti .ge. tsteplai) THEN
Fnew = 1.0_rk - (LAIpast/LAIcurrent)
ELSE
Fnew = (ti/tsteplai) * ( 1.0_rk-(LAIpast/LAIcurrent) )
ENDIF
!Fmat calculated
IF (tm .ge. tsteplai) THEN
Fmat = LAIpast/LAIcurrent
ELSE
Fmat = (LAIpast/LAIcurrent) + ( (tsteplai-tm)/tsteplai ) * ( 1.0_rk-(LAIpast/LAIcurrent) )
ENDIF

Fgro = 1.0_rk - Fnew - Fmat
Fold = 0.0_rk
ELSEIF (LAIpast - LAIcurrent > LAIdelta) THEN !(i.e. LAI has decreased)
Fnew = 0.0_rk
Fgro = 0.0_rk
Fold = ( LAIpast-LAIcurrent ) / LAIpast
Fmat = 1.0_rk-Fold
ELSE !(LAIpast == LAIcurrent) THEN !If LAI remains same
Fnew = 0.0_rk
Fgro = 0.1_rk
Fmat = 0.8_rk
Fold = 0.1_rk
ENDIF

!-----------------------
! Compute GAMMA_AGE
!-----------------------
IF (leafage_opt .eq. 0) THEN
IF (LAIcurrent - LAIpast > LAIdelta) THEN !(i.e. LAI has Increased)
IF (TABOVE .le. 303.0_rk) THEN
ti = 5.0_rk + 0.7_rk*(300.0_rk-TABOVE)
ELSE
ti = 2.9_rk
ENDIF
tm = 2.3_rk*ti
!Fnew calculated
IF (ti .ge. tsteplai) THEN
Fnew = 1.0_rk - (LAIpast/LAIcurrent)
ELSE
Fnew = (ti/tsteplai) * ( 1.0_rk-(LAIpast/LAIcurrent) )
ENDIF
!Fmat calculated
IF (tm .ge. tsteplai) THEN
Fmat = LAIpast/LAIcurrent
ELSE
Fmat = (LAIpast/LAIcurrent) + ( (tsteplai-tm)/tsteplai ) * ( 1.0_rk-(LAIpast/LAIcurrent) )
ENDIF

Fgro = 1.0_rk - Fnew - Fmat
Fold = 0.0_rk
ELSEIF (LAIpast - LAIcurrent > LAIdelta) THEN !(i.e. LAI has decreased)
Fnew = 0.0_rk
Fgro = 0.0_rk
Fold = ( LAIpast-LAIcurrent ) / LAIpast
Fmat = 1.0_rk-Fold
ELSE !(LAIpast == LAIcurrent) THEN !If LAI remains same
Fnew = 0.0_rk
Fgro = 0.1_rk
Fmat = 0.8_rk
Fold = 0.1_rk
ENDIF
! Compute GAMMA_LEAFAGE
GAMMA_LEAFAGE = Fnew*Anew + Fgro*Agro + Fmat*Amat + Fold*Aold
! Prevent negative values
Expand Down

0 comments on commit d241bea

Please sign in to comment.