Skip to content

Commit

Permalink
Import ed_v0.1.0 changes into a branch from r120.
Browse files Browse the repository at this point in the history
Created patch file between clm4_5_1_r097 and
ed_v010_21_clm4_5_1_r097 tags with the command:

  svn diff \
    https://svn-ccsm-models.cgd.ucar.edu/clm2/trunk_tags/clm4_5_1_r097/ \
    https://svn-ccsm-models.cgd.ucar.edu/clm2/branch_tags/ed_v0.1.0_tags/ed_v010_21_clm4_5_1_r097 > \
    ed_v0.1.0-21_r097.patch

Manually edit patch file to remove property changes. Manually
edit patch file to change 'models/lnd' to 'components' in patch
file paths.

There are some failed hunks in SVN_EXTERNAL_DIRECTORIES that
failed to apply and were ignored. It looks like most of these are
irrelevent because of cime changes, but one may need to be
revisited:

  https://svn-ccsm-models.cgd.ucar.edu/scripts/branch_tags/refKovenMuszala_tags/rkm_01_scripts4_141023

Testing: Branch has not been compiled or tested.
  • Loading branch information
bandre-ucar committed Dec 15, 2015
1 parent c1f1cd9 commit e840829
Show file tree
Hide file tree
Showing 11 changed files with 296 additions and 86 deletions.
1 change: 1 addition & 0 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ subroutine allocate_live_biomass(cc_p)
currentcohort%balive -currentcohort%bl- currentcohort%br - currentcohort%bsw, currentcohort%status_coh,currentcohort%balive
write(iulog,*) 'actual vs predicted balive',ideal_balive,currentcohort%balive ,ratio_balive,leaf_frac
write(iulog,*) 'leaf,root,stem',currentcohort%bl,currentcohort%br,currentcohort%bsw
write(iulog,*) 'pft',ft,pftcon%evergreen(ft),pftcon%season_decid(ft),leaves_off_switch
endif
currentCohort%b = currentCohort%bdead + currentCohort%balive

Expand Down
14 changes: 10 additions & 4 deletions biogeochem/EDGrowthFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ real(r8) function Bleaf( cohort_in )
! ============================================================================

type(ed_cohort_type), intent(in) :: cohort_in
real(r8) :: slascaler ! changes the target biomass according to the SLA

if(cohort_in%dbh < 0._r8.or.cohort_in%pft == 0.or.cohort_in%dbh > 1000.0_r8)then
write(iulog,*) 'problems in bleaf',cohort_in%dbh,cohort_in%pft
Expand All @@ -111,12 +112,17 @@ real(r8) function Bleaf( cohort_in )
if(cohort_in%dbh <= EDecophyscon%max_dbh(cohort_in%pft))then
bleaf = 0.0419_r8 * (cohort_in%dbh**1.56) * EDecophyscon%wood_density(cohort_in%pft)**0.55_r8
else
bleaf = 0.0419_r8 * (EDecophyscon%max_dbh(cohort_in%pft)**1.56) * EDecophyscon%wood_density(cohort_in%pft)**0.55_r8
endif

bleaf = 0.0419_r8 * (EDecophyscon%max_dbh(cohort_in%pft)**1.56) * EDecophyscon%wood_density(cohort_in%pft)**0.55_r8
endif
slascaler = 0.03_r8/pftcon%slatop(cohort_in%pft)
bleaf = bleaf * slascaler

!write(*,*) 'bleaf',bleaf, slascaler,cohort_in%pft

!Adjust for canopies that have become so deep that their bottom layer is not producing any carbon...
!nb this will change the allometry and the effects of this remain untested. RF. April 2014
bleaf = bleaf*cohort_in%canopy_trim

bleaf = bleaf * cohort_in%canopy_trim

return
end function Bleaf
Expand Down
6 changes: 5 additions & 1 deletion biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,11 @@ subroutine fuse_2_patches(dp, rp)
rp%frac_burnt = (dp%frac_burnt*dp%area + rp%frac_burnt*rp%area)/(dp%area + rp%area)
rp%burnt_frac_litter(:) = (dp%burnt_frac_litter(:)*dp%area + rp%burnt_frac_litter(:)*rp%area)/(dp%area + rp%area)
rp%btran_ft(:) = (dp%btran_ft(:)*dp%area + rp%btran_ft(:)*rp%area)/(dp%area + rp%area)

rp%dleaf_litter_dt(:) = (dp%dleaf_litter_dt(:)*dp%area + rp%dleaf_litter_dt(:)*rp%area)/(dp%area+rp%area)
rp%leaf_litter_in(:) = (dp%leaf_litter_in(:)*dp%area + rp%leaf_litter_in(:)*rp%area)/(dp%area+rp%area)
rp%leaf_litter_out(:) = (dp%leaf_litter_out(:)*dp%area + rp%leaf_litter_out(:)*rp%area)/(dp%area+rp%area)


rp%area = rp%area + dp%area !THIS MUST COME AT THE END!

!insert donor cohorts into recipient patch
Expand Down
41 changes: 38 additions & 3 deletions biogeochem/EDPhenologyType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module EDPhenologyType
! Public procedures
procedure, public :: accumulateAndExtract
procedure, public :: init
procedure, public :: restart
procedure, public :: initAccVars
procedure, public :: initAccBuffer
procedure, public :: clean
Expand All @@ -51,6 +52,40 @@ module EDPhenologyType
contains

!------------------------------------------------------------------------------

!------------------------------------------------------------------------
subroutine Restart(this, bounds, ncid, flag)
!
! !DESCRIPTION:
! Read/Write module information to/from restart file.
!
! !USES:
use shr_log_mod , only : errMsg => shr_log_errMsg
use spmdMod , only : masterproc
use abortutils , only : endrun
use ncdio_pio , only : file_desc_t, ncd_double
use restUtilMod
!
! !ARGUMENTS:
class(ed_phenology_type) :: this
type(bounds_type), intent(in) :: bounds
type(file_desc_t), intent(inout) :: ncid
character(len=*) , intent(in) :: flag

!
! !LOCAL VARIABLES:
integer :: j,c ! indices
logical :: readvar ! determine if variable is on initial file
!-----------------------------------------------------------------------

call restartvar(ncid=ncid, flag=flag, varname='ED_GDD', xtype=ncd_double, &
dim1name='pft', &
long_name='growing degree days for ED', units='ddays', &
interpinic_flag='interp', readvar=readvar, data=this%ED_GDD_patch)


end subroutine restart

subroutine accumulateAndExtract( this, bounds, &
t_ref2m_patch, &
gridcell, latdeg, &
Expand Down Expand Up @@ -78,6 +113,7 @@ subroutine accumulateAndExtract( this, bounds, &
! local variables
!
! update_accum_field expects a pointer, can't make this an allocatable
!
real(r8), pointer :: rbufslp(:) ! temporary single level - pft level
integer :: g, p ! local index for gridcell and pft
integer :: ier ! error code
Expand All @@ -91,7 +127,7 @@ subroutine accumulateAndExtract( this, bounds, &

! Accumulate and extract GDD0 for ED
do p = bounds%begp,bounds%endp

g = gridcell(p)

if (latdeg(g) >= 0._r8) then
Expand Down Expand Up @@ -120,11 +156,10 @@ subroutine accumulateAndExtract( this, bounds, &
if( latdeg(g) < 0._r8 .and. month < calParams%june ) then !do not accumulate in earlier half of year.
rbufslp(p) = accumResetVal
endif

end do

call update_accum_field ( trim(this%accString), rbufslp, get_nstep() )
call extract_accum_field ( trim(this%accstring), this%ED_GDD_patch, get_nstep() )
call extract_accum_field ( trim(this%accString), this%ED_GDD_patch, get_nstep() )

deallocate(rbufslp)

Expand Down
66 changes: 45 additions & 21 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module EDPhysiologyMod

use shr_kind_mod , only : r8 => shr_kind_r8
use clm_varctl , only : iulog
use spmdMod , only : masterproc
use TemperatureType , only : temperature_type
use SoilStateType , only : soilstate_type
use WaterstateType , only : waterstate_type
Expand Down Expand Up @@ -85,6 +86,7 @@ subroutine non_canopy_derivs( currentPatch, temperature_inst, soilstate_inst, wa

currentPatch%leaf_litter_in(:) = 0.0_r8
currentPatch%root_litter_in(:) = 0.0_r8
currentPatch%dleaf_litter_dt(:) = 0.0_r8
currentPatch%leaf_litter_out(:) = 0.0_r8
currentPatch%root_litter_out(:) = 0.0_r8
currentPatch%cwd_AG_in(:) = 0.0_r8
Expand Down Expand Up @@ -230,6 +232,8 @@ subroutine phenology( currentSite, ed_phenology_inst, temperature_inst, watersta
!
! !USES:
use clm_varcon, only : tfrz
use clm_time_manager, only : get_days_per_year, get_curr_date
use clm_time_manager, only : get_ref_date, timemgr_datediff
use EDTypesMod, only : udata
!
! !ARGUMENTS:
Expand All @@ -247,6 +251,14 @@ subroutine phenology( currentSite, ed_phenology_inst, temperature_inst, watersta
integer :: ncolddayslim ! critical no days underneath the threshold for leaf drop
integer :: i
integer :: timesincedleafon,timesincedleafoff,timesinceleafon,timesinceleafoff
integer :: refdate
integer :: curdate

integer :: yr ! year (0, ...)
integer :: mon ! month (1, ..., 12)
integer :: day ! day of month (1, ..., 31)
integer :: sec ! seconds of the day

real(r8) :: gdd_threshold
real(r8) :: a,b,c ! params of leaf-pn model from botta et al. 2000.
real(r8) :: cold_t ! threshold below which cold days are counted
Expand All @@ -256,13 +268,26 @@ subroutine phenology( currentSite, ed_phenology_inst, temperature_inst, watersta
real(r8) :: off_time ! minimum number of days between leaf off and leaf on for drought phenology
real(r8) :: temp_in_C ! daily averaged temperature in celcius
real(r8) :: mindayson
real(r8) :: modelday

!------------------------------------------------------------------------

t_veg24 => temperature_inst%t_veg24_patch ! Input: [real(r8) (:)] avg pft vegetation temperature for last 24 hrs
ED_GDD_patch => ed_phenology_inst%ED_GDD_patch ! Input: [real(r8) (:)] growing deg. days base 0 deg C (ddays)


g = currentSite%clmgcell


call get_curr_date(yr, mon, day, sec)
curdate = yr*10000 + mon*100 + day

call get_ref_date(yr, mon, day, sec)
refdate = yr*10000 + mon*100 + day

call timemgr_datediff(refdate, 0, curdate, sec, modelday)
if ( masterproc ) write(iulog,*) 'modelday',modelday

! Parameter of drought decid leaf loss in mm in top layer...FIX(RF,032414)
! - this is arbitrary and poorly understood. Needs work. ED_
drought_threshold = 0.15
Expand Down Expand Up @@ -315,29 +340,23 @@ subroutine phenology( currentSite, ed_phenology_inst, temperature_inst, watersta
endif
enddo

timesinceleafoff = t - currentSite%leafoffdate
if (t < currentSite%leafoffdate)then
timesinceleafoff = t +(365-currentSite%leafoffdate)
endif

timesinceleafoff = modelday - currentSite%leafoffdate
!LEAF ON: COLD DECIDUOUS. Needs to
!1) have exceeded the growing degree day threshold
!2) The leaves should not be on already
!3) There should have been at least on chilling day in the counting period.
if (ED_GDD_patch(currentSite%oldest_patch%clm_pno) > gdd_threshold)then
if (currentSite%status == 1)then
if (currentSite%ncd >= 1)then
currentSite%status = 2 !alter status of site to 'leaves on'
currentSite%leafondate = t !record leaf on date
write(iulog,*) 'leaves on'
currentSite%status = 2 !alter status of site to 'leaves on'
currentSite%leafondate = t !record leaf on date
write(iulog,*) 'leaves on'
endif !ncd
endif !status
endif !GDD

timesinceleafon = t - currentSite%leafondate
if (t < currentSite%leafondate)then
timesinceleafon = t +(365-currentSite%leafondate)
endif
timesinceleafon = modelday - currentSite%leafondate


!LEAF OFF: COLD THRESHOLD
!Needs to:
Expand All @@ -350,18 +369,18 @@ subroutine phenology( currentSite, ed_phenology_inst, temperature_inst, watersta
if (timesinceleafon > mindayson)then
if (currentSite%status == 2)then
currentSite%status = 1 !alter status of site to 'leaves on'
currentSite%leafoffdate = t !record leaf off date
write(iulog,*) 'leaves off'
currentSite%leafoffdate = modelday !record leaf off date
write(iulog,*) 'leaves off cold'
endif
endif
endif

!LEAF OFF: COLD LIFESPAN THRESHOLD
if (timesinceleafoff > 360)then !remove leaves after a whole year when there is no 'off' period.
if (currentSite%status == 2)then
if(timesinceleafoff > 400)then !remove leaves after a whole year when there is no 'off' period.
if(currentSite%status == 2)then
currentSite%status = 1 !alter status of site to 'leaves on'
currentSite%leafoffdate = t !record leaf off date
write(iulog,*) 'leaves off'
currentSite%leafoffdate = modelday !record leaf off date
write(iulog,*) 'leaves off time'
endif
endif

Expand Down Expand Up @@ -476,10 +495,15 @@ subroutine phenology_leafonoff(currentSite)
! !LOCAL VARIABLES:
type(ed_patch_type) , pointer :: currentPatch
type(ed_cohort_type), pointer :: currentCohort

real(r8) :: store_output ! the amount of the store to put into leaves - is a barrier against negative storage and C starvation.

!------------------------------------------------------------------------

currentPatch => CurrentSite%oldest_patch

store_output = 0.5_r8

do while(associated(currentPatch))
currentCohort => currentPatch%tallest
do while(associated(currentCohort))
Expand All @@ -492,7 +516,7 @@ subroutine phenology_leafonoff(currentSite)
if (currentCohort%laimemory <= currentCohort%bstore)then
currentCohort%bl = currentCohort%laimemory !extract stored carbon to make new leaves.
else
currentCohort%bl = currentCohort%bstore !we can only put on as much carbon as there is in the store...
currentCohort%bl = currentCohort%bstore * store_output !we can only put on as much carbon as there is in the store...
!nb. Putting all of bstore into leaves is C-starvation suicidal. The tendency for this could be parameterized
endif
currentCohort%balive = currentCohort%balive + currentCohort%bl ! Add deployed carbon to alive biomass pool
Expand Down Expand Up @@ -525,8 +549,8 @@ subroutine phenology_leafonoff(currentSite)
if (currentCohort%laimemory <= currentCohort%bstore)then
currentCohort%bl = currentCohort%laimemory !extract stored carbon to make new leaves.
else
currentCohort%bl = currentCohort%bstore !we can only put on as much carbon as there is in the store...
endif
currentCohort%bl = currentCohort%bstore * store_output !we can only put on as much carbon as there is in the store...
endif
currentCohort%balive = currentCohort%balive + currentCohort%bl
currentCohort%bstore = currentCohort%bstore - currentCohort%bl ! empty store
currentCohort%laimemory = 0.0_r8
Expand Down
12 changes: 9 additions & 3 deletions biogeophys/EDPhotosynthesisMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ subroutine Photosynthesis_ED (bounds, fn, filterp, esat_tv, eair, oair, cair, &

!RF - copied this from the CLM trunk code, but where did it come from, and how can we make these consistant?
!jmax25top(FT) = (2.59_r8 - 0.035_r8*min(max((t10(p)-tfrz),11._r8),35._r8)) * vcmax25top(FT)
jmax25top(FT) = 0.167_r8 * vcmax25top(FT)
jmax25top(FT) = 1.67_r8 * vcmax25top(FT)
tpu25top(FT) = 0.167_r8 * vcmax25top(FT)
kp25top(FT) = 20000._r8 * vcmax25top(FT)

Expand Down Expand Up @@ -776,7 +776,13 @@ subroutine Photosynthesis_ED (bounds, fn, filterp, esat_tv, eair, oair, cair, &
enddo !sunsha loop
!average leaf-level stomatal resistance rate over sun and shade leaves...
rs_z(cl,ft,iv) = 1._r8/gs_z(cl,ft,iv)
else !No leaf area. This layer is present only because of stems. (leaves are off, or have reduced to 0
currentPatch%psn_z(cl,ft,iv) = 0._r8
rs_z(CL,FT,iv) = min(rsmax0, 1._r8/bbb(FT) * cf)

end if !is there leaf area?


end if ! night or day
end do ! iv canopy layer
end if ! present(L,ft) ? rd_array
Expand Down Expand Up @@ -811,8 +817,8 @@ subroutine Photosynthesis_ED (bounds, fn, filterp, esat_tv, eair, oair, cair, &
!------------------------------------------------------------------------------
! Convert from umolC/m2leaf/s to umolC/indiv/s ( x canopy area x 1m2 leaf area).
tree_area = currentCohort%c_area/currentCohort%n
if(currentCohort%nv > 1)then

if (currentCohort%nv > 1) then !is there canopy, and are the leaves on?
currentCohort%gpp_clm = sum(currentPatch%psn_z(cl,ft,1:currentCohort%nv-1) * &
currentPatch%elai_profile(cl,ft,1:currentCohort%nv-1)) * tree_area
currentCohort%rd = sum(lmr_z(cl,ft,1:currentCohort%nv-1) * &
Expand Down
35 changes: 20 additions & 15 deletions biogeophys/EDSurfaceAlbedoMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ subroutine ED_Norman_Radiation (bounds, &
fsun_z => surfalb_inst%fsun_z_patch & ! Output: [real(r8) (:,:) ] sunlit fraction of canopy layer
)



! TODO (mv, 2014-10-29) the filter here is different than below
! this is needed to have the VOC's be bfb - this needs to be
! re-examined int he future
Expand Down Expand Up @@ -281,7 +279,7 @@ subroutine ED_Norman_Radiation (bounds, &
sb = (90._r8 - (acos(cosz)*180/pi)) * (pi / 180._r8)
chil(p) = xl(ft) !min(max(xl(ft), -0.4_r8), 0.6_r8 )
if (abs(chil(p)) <= 0.01_r8) then
chil = 0.01_r8
chil(p) = 0.01_r8
end if
phi1b(p,ft) = 0.5_r8 - 0.633_r8*chil(p) - 0.330_r8*chil(p)*chil(p)
phi2b(p,ft) = 0.877_r8 * (1._r8 - 2._r8*phi1b(p,ft)) !0 = horiz leaves, 1 - vert leaves.
Expand Down Expand Up @@ -725,16 +723,23 @@ subroutine ED_Norman_Radiation (bounds, &
! Absorbed radiation, shaded and sunlit portions of leaf layers
!here we get one unit of diffuse radiation... how much of
!it is absorbed?
do iv = 1, currentPatch%nrad(L,ft)
if (radtype==1)then
currentPatch%fabd_sha_z(L,ft,iv) = Abs_dif_z(ft,iv) * (1._r8 - currentPatch%f_sun(L,ft,iv))
currentPatch%fabd_sun_z(L,ft,iv) = Abs_dif_z(ft,iv) * currentPatch%f_sun(L,ft,iv) + &
Abs_dir_z(ft,iv)
else
currentPatch%fabi_sha_z(L,ft,iv) = Abs_dif_z(ft,iv) * (1._r8 - currentPatch%f_sun(L,ft,iv))
currentPatch%fabi_sun_z(L,ft,iv) = Abs_dif_z(ft,iv) * currentPatch%f_sun(L,ft,iv)
end if
end do

if (ib == 1) then ! only set the absorbed PAR for the visible light band.
do iv = 1, currentPatch%nrad(L,ft)
if (radtype==1) then
currentPatch%fabd_sha_z(L,ft,iv) = Abs_dif_z(ft,iv) * &
(1._r8 - currentPatch%f_sun(L,ft,iv))
currentPatch%fabd_sun_z(L,ft,iv) = Abs_dif_z(ft,iv) * &
currentPatch%f_sun(L,ft,iv) + &
Abs_dir_z(ft,iv)
else
currentPatch%fabi_sha_z(L,ft,iv) = Abs_dif_z(ft,iv) * &
(1._r8 - currentPatch%f_sun(L,ft,iv))
currentPatch%fabi_sun_z(L,ft,iv) = Abs_dif_z(ft,iv) * &
currentPatch%f_sun(L,ft,iv)
endif
end do
endif ! ib

!==============================================================================!
! Sum fluxes
Expand Down Expand Up @@ -886,7 +891,7 @@ subroutine ED_Norman_Radiation (bounds, &
write(iulog,*) 'cp',currentPatch%area, currentPatch%patchno
write(iulog,*) 'albgrd(c,ib)',albgrd(c,ib)

! albd(p,ib) = albd(p,ib) + error
albd(p,ib) = albd(p,ib) + error
end if
else

Expand All @@ -910,7 +915,7 @@ subroutine ED_Norman_Radiation (bounds, &
write(iulog,*) 'CAP',currentPatch%canopy_area_profile(1,1:2,1)


! albi(p,ib) = albi(p,ib) + error
albi(p,ib) = albi(p,ib) + error
end if


Expand Down
Loading

0 comments on commit e840829

Please sign in to comment.