From e2ca93d3afc54b12c0bd1a8dcf9ce861dcef4735 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Mon, 14 Jan 2019 15:50:49 -0800 Subject: [PATCH 01/27] Refactoring the phenology timing code --- biogeochem/EDPhysiologyMod.F90 | 209 +++++++++++++++++------------- main/EDInitMod.F90 | 21 +-- main/EDTypesMod.F90 | 10 +- main/FatesRestartInterfaceMod.F90 | 14 +- 4 files changed, 140 insertions(+), 114 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 65e94c036b..28ec452aa6 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -406,10 +406,13 @@ subroutine phenology( currentSite, bc_in ) ! ! !LOCAL VARIABLES: - integer :: t ! day of year - integer :: ncolddays ! no days underneath the threshold for leaf drop + integer :: model_day_int ! integer model day 1 - inf + integer :: ncolddays ! no days underneath the threshold for leaf drop integer :: i - integer :: timesincedleafon,timesincedleafoff,timesinceleafon,timesinceleafoff + integer :: dayssincedleafon ! Days since drought-decid leaf-on started + integer :: dayssincedleafoff ! Days since drought-decid leaf-off started + integer :: dayssincecleafon ! Days since cold-decid leaf-on started + integer :: dayssincecleafoff ! Days since cold-decid leaf-off started integer :: refdate integer :: curdate @@ -417,22 +420,32 @@ subroutine phenology( currentSite, bc_in ) integer :: mon ! month (1, ..., 12) integer :: day ! day of month (1, ..., 31) integer :: sec ! seconds of the day - + real(r8) :: mean_10day_liqvol ! mean liquid volume (m3/m3) over last 10 days real(r8) :: leaf_c ! leaf carbon [kg] real(r8) :: fnrt_c ! fineroot carbon [kg] real(r8) :: sapw_c ! sapwood carbon [kg] real(r8) :: store_c ! storage carbon [kg] real(r8) :: struct_c ! structure carbon [kg] - real(r8) :: gdd_threshold - integer :: ncdstart ! beginning of counting period for chilling degree days. - integer :: gddstart ! beginning of counting period for growing degree days. - real(r8) :: temp_in_C ! daily averaged temperature in celcius + real(r8) :: gdd_threshold ! GDD accumulation function, + ! which also depends on chilling days. + integer :: ncdstart ! beginning of counting period for chilling degree days. + integer :: gddstart ! beginning of counting period for growing degree days. + real(r8) :: temp_in_C ! daily averaged temperature in celcius real(r8), parameter :: canopy_leaf_lifespan = 365.0_r8 ! Mean lifespan canopy leaves ! FIX(RGK 07/10/17) ! This is a band-aid on unusual code - + + ! This is the minimum number of days that the site must be in a "leaf-on" + ! status in order to start evaluating soil drying to trigger an off state + ! this prevents "flicker" + integer, parameter :: leafon_min_flicker = 100 + + + ! This is the integer model day. The first day of the simulation is 1, and it + ! continues monotonically, indefinitely + model_day_int = nint(hlm_model_day) ! Parameter of drought decid leaf loss in mm in top layer...FIX(RF,032414) ! - this is arbitrary and poorly understood. Needs work. ED_ @@ -440,7 +453,6 @@ subroutine phenology( currentSite, bc_in ) !Parameters: defaults from Botta et al. 2000 GCB,6 709-725 !Parameters, default from from SDGVM model of senesence - t = hlm_day_of_year temp_in_C = bc_in%t_veg24_si - tfrz !-----------------Cold Phenology--------------------! @@ -448,24 +460,23 @@ subroutine phenology( currentSite, bc_in ) !Zero growing degree and chilling day counters if (currentSite%lat > 0)then ncdstart = 270 !Northern Hemisphere begining November - gddstart = 1 !Northern Hemisphere begining January + gddstart = 1 !Northern Hemisphere begining January (RGK: NOT EARLIER?) else ncdstart = 120 !Southern Hemisphere beginning May gddstart = 181 !Northern Hemisphere begining July endif - ! FIX(SPM,032414) - this will only work for the first year, no? - if (t == ncdstart)then - currentSite%ncd = 0._r8 + if (hlm_day_of_year == ncdstart)then + currentSite%ncd = 0 endif !Accumulate growing/chilling days after start of counting period if (temp_in_C < ED_val_phen_chiltemp)then - currentSite%ncd = currentSite%ncd + 1.0_r8 + currentSite%ncd = currentSite%ncd + 1 endif !GDD accumulation function, which also depends on chilling days. - gdd_threshold = ED_val_phen_a + ED_val_phen_b*exp(ED_val_phen_c*currentSite%ncd) + gdd_threshold = ED_val_phen_a + ED_val_phen_b*exp(ED_val_phen_c*real(currentSite%ncd,r8)) !Accumulate temperature of last 10 days. currentSite%last_n_days(2:senes) = currentSite%last_n_days(1:senes-1) @@ -481,7 +492,7 @@ subroutine phenology( currentSite, bc_in ) ! Here is where we do the GDD accumulation calculation ! ! reset GDD on set dates - if (t == gddstart)then + if (hlm_day_of_year == gddstart)then currentSite%ED_GDD_site = 0._r8 endif ! @@ -490,8 +501,12 @@ subroutine phenology( currentSite, bc_in ) currentSite%ED_GDD_site = currentSite%ED_GDD_site + bc_in%t_veg24_si - tfrz endif + + ! HLM model day is the total number of days since simulation start + ! The leafoffdate and leafondates are all recorded in this unit + + dayssincecleafoff = model_day_int - currentSite%cleafoffdate - timesinceleafoff = hlm_model_day - currentSite%leafoffdate !LEAF ON: COLD DECIDUOUS. Needs to !1) have exceeded the growing degree day threshold !2) The leaves should not be on already @@ -500,14 +515,13 @@ subroutine phenology( currentSite, bc_in ) if (currentSite%status == 1) then if (currentSite%ncd >= 1) then currentSite%status = 2 !alter status of site to 'leaves on' - ! NOTE(bja, 2015-01) should leafondate = model_day to be consistent with leaf off? - currentSite%leafondate = t !record leaf on date + currentSite%cleafondate = model_day_int if ( debug ) write(fates_log(),*) 'leaves on' endif !ncd endif !status endif !GDD - timesinceleafon = hlm_model_day - currentSite%leafondate + dayssincecleafon = model_day_int - currentSite%cleafondate !LEAF OFF: COLD THRESHOLD @@ -515,23 +529,24 @@ subroutine phenology( currentSite, bc_in ) !1) have exceeded the number of cold days threshold !2) have exceeded the minimum leafon time. !3) The leaves should not be off already - !4) The day of the year should be larger than the counting period. (not sure if we need this/if it will break the restarting) + !4) The day of the year should be larger than the counting period. + ! (not sure if we need this/if it will break the restarting) if (ncolddays > ED_val_phen_ncolddayslim)then - if (timesinceleafon > ED_val_phen_mindayson)then + if (dayssincecleafon > ED_val_phen_mindayson)then if (currentSite%status == 2)then currentSite%status = 1 !alter status of site to 'leaves on' - currentSite%leafoffdate = hlm_model_day !record leaf off date + currentSite%cleafoffdate = hlm_model_day !record leaf off date if ( debug ) write(fates_log(),*) 'leaves off' endif endif endif !LEAF OFF: COLD LIFESPAN THRESHOLD - if(timesinceleafoff > 400)then !remove leaves after a whole year when there is no 'off' period. + if(dayssincecleafoff > 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 = hlm_model_day !record leaf off date + currentSite%cleafoffdate = hlm_model_day !record leaf off date if ( debug ) write(fates_log(),*) 'leaves off' endif endif @@ -545,93 +560,103 @@ subroutine phenology( currentSite, bc_in ) ! B*: If the soil is only wet for a very short time, then the leaves stay on for 100 days ! C*: The leaves are only permitted to come ON for a 60 day window around when they last came on, ! to prevent 'flickering' on in response to wet season storms - ! D*: We don't allow anything to happen in the first ten days to allow the water memory window to come into equlibirum. - ! E*: If the soil is always wet, the leaves come on at the beginning of the window, and then last for their lifespan. + ! D*: We don't allow anything to happen in the first ten days to allow the water memory window + ! to come into equlibirium. + ! E*: If the soil is always wet, the leaves come on at the beginning of the window, and then + ! last for their lifespan. ! ISSUES ! 1. It's not clear what water content we should track. Here we are tracking the top layer, - ! but we probably should track something like BTRAN, - ! but BTRAN is defined for each PFT, and there could potentially be more than one stress-dec PFT.... ? - ! 2. In the beginning, the window is set at an arbitrary time of the year, so the leaves might come on - ! in the dry season, using up stored reserves - ! for the stress-dec plants, and potentially killing them. To get around this, we need to read in the - ! 'leaf on' date from some kind of start-up file + ! but we probably should track something like BTRAN, but BTRAN is defined for each PFT, + ! and there could potentially be more than one stress-dec PFT.... ? + ! 2. In the beginning, the window is set at an arbitrary time of the year, so the leaves + ! might come on in the dry season, using up stored reserves + ! for the stress-dec plants, and potentially killing them. To get around this, + ! we need to read in the 'leaf on' date from some kind of start-up file ! but we would need that to happen for every resolution, etc. - ! 3. Will this methodology properly kill off the stress-dec trees where there is no water stress? - ! What about where the wet period coincides with the - ! warm period? We would just get them overlapping with the cold-dec trees, even though that isn't appropriate.... - ! Why don't the drought deciduous trees grow - ! in the North? Is cold decidousness maybe even the same as drought deciduosness there (and so does this + ! 3. Will this methodology properly kill off the stress-dec trees where there is no + ! water stress? What about where the wet period coincides with the warm period? + ! We would just get them overlapping with the cold-dec trees, even though that isn't appropriate + ! Why don't the drought deciduous trees grow in the North? + ! Is cold decidousness maybe even the same as drought deciduosness there (and so does this ! distinction actually matter??).... - !Accumulate surface water memory of last 10 days. - + ! Accumulate surface water memory of last 10 days. + ! Liquid volume in ground layer (m3/m3) do i = 1,numWaterMem-1 !shift memory along one currentSite%water_memory(numWaterMem+1-i) = currentSite%water_memory(numWaterMem-i) enddo - currentSite%water_memory(1) = bc_in%h2o_liqvol_sl(1) !waterstate_inst%h2osoi_vol_col(coli,1) - - !In drought phenology, we often need to force the leaves to stay on or off as moisture fluctuates... - timesincedleafoff = 0 - if (currentSite%dstatus == 1)then !the leaves are off. How long have they been off? - !leaves have come on, but last year, so at a later date than now. - if (currentSite%dleafoffdate > 0.and.currentSite%dleafoffdate > t)then - timesincedleafoff = t + (360 - currentSite%dleafoffdate) - else - timesincedleafoff = t - currentSite%dleafoffdate - endif - endif + currentSite%water_memory(1) = bc_in%h2o_liqvol_sl(1) + + ! Calculate the mean water content over the last 10 days (m3/m3) + mean_10day_liqvol = sum(currentSite%water_memory(1:numWaterMem))/real(numWaterMem,r8) - timesincedleafon = 0 + ! In drought phenology, we often need to force the leaves to stay on or off as moisture fluctuates... + dayssincedleafoff = 0 + if (currentSite%dstatus == 1)then + dayssincedleafoff = model_day_int - currentSite%dleafoffdate + endif + + dayssincedleafon = 0 !the leaves are on. How long have they been on? - if (currentSite%dstatus == 2)then - !leaves have come on, but last year, so at a later date than now. - if (currentSite%dleafondate > 0.and.currentSite%dleafondate > t)then - timesincedleafon = t + (360 - currentSite%dleafondate) - else - timesincedleafon = t - currentSite%dleafondate - endif + if (currentSite%dstatus == 2)then + dayssincedleafon = model_day_int - currentSite%dleafondate endif - !LEAF ON: DROUGHT DECIDUOUS WETNESS - !Here, we used a window of oppurtunity to determine if we are close to the time when then leaves came on last year - if ((t >= currentSite%dleafondate - 30.and.t <= currentSite%dleafondate + 30).or.(t > 360 - 15.and. & - currentSite%dleafondate < 15))then ! are we in the window? - ! TODO: CHANGE THIS MATH, MOVE THE DENOMENATOR OUTSIDE OF THE SUM (rgk 01-2017) - if (sum(currentSite%water_memory(1:numWaterMem)/real(numWaterMem,r8)) & - >= ED_val_phen_drought_threshold.and.currentSite%dstatus == 1.and.t >= 10)then - ! leave some minimum time between leaf off and leaf on to prevent 'flickering'. - if (timesincedleafoff > ED_val_phen_doff_time)then - currentSite%dstatus = 2 !alter status of site to 'leaves on' - currentSite%dleafondate = t !record leaf on date + ! LEAF ON: DROUGHT DECIDUOUS WETNESS + ! Here, we used a window of oppurtunity to determine if we are + ! close to the time when then leaves came on last year + + ! Has it been ... + ! a) a year, plus or minus 1 month since we last had leaf-on? + ! b) Has there also been at least a nominaly short amount of "leaf-off" + ! c) is the model day at least > 10 (let soil water spin-up) + ! Note that cold-starts begin in the "leaf-on" + ! status + if ( (currentSite%dstatus == 1) .and. & + (model_day_int > 10) .and. & + (dayssincedleafon > 365-30 .and. dayssinceleafon < 365+30 ) .and. & + (dayssincedleafoff > ED_val_phen_doff_time) ) then + + ! If leaves are off, and have been off for at least a few days + ! and the time is consistent with the correct + ! time window... test if the moisture conditions allow for leaf-on + + if ( mean_10day_liqvol >= ED_val_phen_drought_threshold ) then + currentSite%dstatus = 2 ! set status to leaf-on + currentSite%dleafondate = model_day_int ! save the model day we start flushing endif endif endif - !we still haven't done budburst by end of window - if (t == currentSite%dleafondate+30.and.currentSite%dstatus == 1)then - currentSite%dstatus = 2 ! force budburst! - currentSite%dleafondate = t ! record leaf on date + ! If we still haven't done budburst by end of window + ! force it! + if ( (currentSite%dstatus == 1) .and. & + (model_day_int >= currentSite%dleafondate+365+30) ) then + currentSite%dstatus = 2 ! force budburst! + currentSite%dleafondate = model_day_int ! record leaf on date endif - !LEAF OFF: DROUGHT DECIDUOUS LIFESPAN - if the leaf gets to the end of its useful life. A*, E* - if (currentSite%dstatus == 2.and.t >= 10)then !D* - !Are the leaves at the end of their lives? - !FIX(RF,0401014)- this is hardwiring.... - !FIX(RGK:changed from hard-coded pft 7 leaf lifespan to labeled constant (1 year) - if ( timesincedleafon > canopy_leaf_lifespan )then - currentSite%dstatus = 1 !alter status of site to 'leaves on' - currentSite%dleafoffdate = t !record leaf on date + ! LEAF OFF: DROUGHT DECIDUOUS LIFESPAN - if the leaf gets to + ! the end of its useful life. A*, E* + ! i.e. Are the leaves rouhgly at the end of their lives? + + if ( (currentSite%dstatus == 2) .and. & + + (dayssincedleafon > canopy_leaf_lifespan) )then + currentSite%dstatus = 1 !alter status of site to 'leaves on' + currentSite%dleafoffdate = model_day_int !record leaf on date endif endif - !LEAF OFF: DROUGHT DECIDUOUS DRYNESS - if the soil gets too dry, and the leaves have already been on a while... - if (currentSite%dstatus == 2.and.t >= 10)then !D* - if (sum(currentSite%water_memory(1:10)/10._r8) <= ED_val_phen_drought_threshold)then - if (timesincedleafon > 100)then !B* Have the leaves been on for some reasonable length of time? To prevent flickering. - currentSite%dstatus = 1 !alter status of site to 'leaves on' - currentSite%dleafoffdate = t !record leaf on date - endif - endif + ! LEAF OFF: DROUGHT DECIDUOUS DRYNESS - if the soil gets too dry, + ! and the leaves have already been on a while... + + if ( (currentSite%dstatus == 2) .and. & + (model_day_int > 10) .and. & + (mean_10day_liqvol <= ED_val_phen_drought_threshold) .and. & + (dayssincedleafon > ED_val_phen_mindayson) ) then + currentSite%dstatus = 1 !alter status of site to 'leaves on' + currentSite%dleafoffdate = hlm_day_of_year !record leaf on date endif call phenology_leafonoff(currentSite) diff --git a/main/EDInitMod.F90 b/main/EDInitMod.F90 index 50aa6d77c2..75374a3985 100644 --- a/main/EDInitMod.F90 +++ b/main/EDInitMod.F90 @@ -7,6 +7,7 @@ module EDInitMod use FatesConstantsMod , only : r8 => fates_r8 use FatesConstantsMod , only : ifalse use FatesConstantsMod , only : itrue + use FatesConstantsMod , only : fates_unset_int use FatesGlobals , only : endrun => fates_endrun use EDTypesMod , only : nclmax use FatesGlobals , only : fates_log @@ -108,12 +109,12 @@ subroutine zero_site( site_in ) site_in%status = 0 ! are leaves in this pixel on or off? site_in%dstatus = 0 site_in%ED_GDD_site = nan ! growing degree days - site_in%ncd = nan ! no chilling days + site_in%ncd = fates_unset_int site_in%last_n_days(:) = 999 ! record of last 10 days temperature for senescence model. - site_in%leafondate = 999 ! doy of leaf on - site_in%leafoffdate = 999 ! doy of leaf off - site_in%dleafondate = 999 ! doy of leaf on drought - site_in%dleafoffdate = 999 ! doy of leaf on drought + site_in%cleafondate = fates_unset_int ! doy of leaf on + site_in%cleafoffdate = fates_unset_int ! doy of leaf off + site_in%dleafondate = fates_unset_int ! doy of leaf on drought + site_in%dleafoffdate = fates_unset_int ! doy of leaf on drought site_in%water_memory(:) = nan @@ -183,7 +184,7 @@ subroutine set_site_properties( nsites, sites) real(r8) :: leafon real(r8) :: leafoff real(r8) :: stat - real(r8) :: NCD + integer :: NCD real(r8) :: GDD real(r8) :: dstat real(r8) :: acc_NI @@ -194,7 +195,7 @@ subroutine set_site_properties( nsites, sites) if ( hlm_is_restart == ifalse ) then !initial guess numbers for site condition. - NCD = 0.0_r8 + NCD = 0 GDD = 30.0_r8 leafon = 100.0_r8 leafoff = 300.0_r8 @@ -207,7 +208,7 @@ subroutine set_site_properties( nsites, sites) else ! assignements for restarts - NCD = 1.0_r8 ! NCD should be 1 on restart + NCD = 1 ! NCD should be 1 on restart (RGK-PHEN: ?) GDD = 0.0_r8 leafon = 0.0_r8 leafoff = 0.0_r8 @@ -222,8 +223,8 @@ subroutine set_site_properties( nsites, sites) do s = 1,nsites sites(s)%ncd = NCD - sites(s)%leafondate = leafon - sites(s)%leafoffdate = leafoff + sites(s)%cleafondate = leafon + sites(s)%cleafoffdate = leafoff sites(s)%dleafoffdate = dleafoff sites(s)%dleafondate = dleafon sites(s)%ED_GDD_site = GDD diff --git a/main/EDTypesMod.F90 b/main/EDTypesMod.F90 index 8f9457ed10..ba72c20141 100644 --- a/main/EDTypesMod.F90 +++ b/main/EDTypesMod.F90 @@ -580,12 +580,12 @@ module EDTypesMod real(r8) :: ED_GDD_site ! ED Phenology growing degree days. integer :: status ! are leaves in this pixel on or off for cold decid integer :: dstatus ! are leaves in this pixel on or off for drought decid - real(r8) :: ncd ! no chilling days:- + integer :: ncd ! no chilling days:- real(r8) :: last_n_days(senes) ! record of last 10 days temperature for senescence model. deg C - integer :: leafondate ! doy of leaf on:- - integer :: leafoffdate ! doy of leaf off:- - integer :: dleafondate ! doy of leaf on drought:- - integer :: dleafoffdate ! doy of leaf on drought:- + integer :: cleafondate ! model date (day integer) of leaf on (cold):- + integer :: cleafoffdate ! model date (day integer) of leaf off (cold):- + integer :: dleafondate ! model date (day integer) of leaf on drought:- + integer :: dleafoffdate ! model date (day integer) of leaf on drought:- real(r8) :: water_memory(numWaterMem) ! last 10 days of soil moisture memory... !SEED BANK diff --git a/main/FatesRestartInterfaceMod.F90 b/main/FatesRestartInterfaceMod.F90 index fb9b316f45..c9be0f31ee 100644 --- a/main/FatesRestartInterfaceMod.F90 +++ b/main/FatesRestartInterfaceMod.F90 @@ -560,7 +560,7 @@ subroutine define_restart_vars(this, initialize_variables) long_name='status flag for drought deciduous plants', units='unitless', flushval = flushzero, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_dd_status_si ) - call this%set_restart_var(vname='fates_chilling_days', vtype=site_r8, & + call this%set_restart_var(vname='fates_chilling_days', vtype=site_int, & long_name='chilling day counter', units='unitless', flushval = flushzero, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_nchill_days_si ) @@ -1425,7 +1425,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites) rio_old_stock_si => this%rvars(ir_oldstock_si)%r81d, & rio_cd_status_si => this%rvars(ir_cd_status_si)%r81d, & rio_dd_status_si => this%rvars(ir_dd_status_si)%r81d, & - rio_nchill_days_si => this%rvars(ir_nchill_days_si)%r81d, & + rio_nchill_days_si => this%rvars(ir_nchill_days_si)%int1d, & rio_leafondate_si => this%rvars(ir_leafondate_si)%r81d, & rio_leafoffdate_si => this%rvars(ir_leafoffdate_si)%r81d, & rio_dleafondate_si => this%rvars(ir_dleafondate_si)%r81d, & @@ -1783,8 +1783,8 @@ subroutine set_restart_vectors(this,nc,nsites,sites) rio_cd_status_si(io_idx_si) = sites(s)%status rio_dd_status_si(io_idx_si) = sites(s)%dstatus rio_nchill_days_si(io_idx_si) = sites(s)%ncd - rio_leafondate_si(io_idx_si) = sites(s)%leafondate - rio_leafoffdate_si(io_idx_si) = sites(s)%leafoffdate + rio_leafondate_si(io_idx_si) = sites(s)%cleafondate + rio_leafoffdate_si(io_idx_si) = sites(s)%cleafoffdate rio_dleafondate_si(io_idx_si) = sites(s)%dleafondate rio_dleafoffdate_si(io_idx_si) = sites(s)%dleafoffdate rio_acc_ni_si(io_idx_si) = sites(s)%acc_NI @@ -2121,7 +2121,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites) rio_old_stock_si => this%rvars(ir_oldstock_si)%r81d, & rio_cd_status_si => this%rvars(ir_cd_status_si)%r81d, & rio_dd_status_si => this%rvars(ir_dd_status_si)%r81d, & - rio_nchill_days_si => this%rvars(ir_nchill_days_si)%r81d, & + rio_nchill_days_si => this%rvars(ir_nchill_days_si)%int1d, & rio_leafondate_si => this%rvars(ir_leafondate_si)%r81d, & rio_leafoffdate_si => this%rvars(ir_leafoffdate_si)%r81d, & rio_dleafondate_si => this%rvars(ir_dleafondate_si)%r81d, & @@ -2500,8 +2500,8 @@ subroutine get_restart_vectors(this, nc, nsites, sites) sites(s)%status = rio_cd_status_si(io_idx_si) sites(s)%dstatus = rio_dd_status_si(io_idx_si) sites(s)%ncd = rio_nchill_days_si(io_idx_si) - sites(s)%leafondate = rio_leafondate_si(io_idx_si) - sites(s)%leafoffdate = rio_leafoffdate_si(io_idx_si) + sites(s)%cleafondate = rio_leafondate_si(io_idx_si) + sites(s)%cleafoffdate = rio_leafoffdate_si(io_idx_si) sites(s)%dleafondate = rio_dleafondate_si(io_idx_si) sites(s)%dleafoffdate = rio_dleafoffdate_si(io_idx_si) sites(s)%acc_NI = rio_acc_ni_si(io_idx_si) From 5bfa1bd011f82aad43805535e4c120b978e4fea9 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 15 Jan 2019 10:31:57 -0800 Subject: [PATCH 02/27] More refactors to phenology timing --- biogeochem/EDPhysiologyMod.F90 | 87 ++++++++++++++----------------- main/EDInitMod.F90 | 5 +- main/EDTypesMod.F90 | 4 +- main/FatesRestartInterfaceMod.F90 | 22 +++++++- 4 files changed, 64 insertions(+), 54 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 28ec452aa6..d8ef758e27 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -29,7 +29,7 @@ module EDPhysiologyMod use EDTypesMod , only : external_recruitment use EDTypesMod , only : ncwd use EDTypesMod , only : nlevleaf - use EDTypesMod , only : senes + use EDTypesMod , only : num_vegtemp_mem use EDTypesMod , only : maxpft use EDTypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type use EDTypesMod , only : dump_cohort @@ -408,18 +408,12 @@ subroutine phenology( currentSite, bc_in ) integer :: model_day_int ! integer model day 1 - inf integer :: ncolddays ! no days underneath the threshold for leaf drop - integer :: i + integer :: i_wmem ! Loop counter for water mem days + integer :: i_tmem ! Loop counter for veg temp mem days integer :: dayssincedleafon ! Days since drought-decid leaf-on started integer :: dayssincedleafoff ! Days since drought-decid leaf-off started integer :: dayssincecleafon ! Days since cold-decid leaf-on started integer :: dayssincecleafoff ! Days since cold-decid leaf-off started - 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) :: mean_10day_liqvol ! mean liquid volume (m3/m3) over last 10 days real(r8) :: leaf_c ! leaf carbon [kg] real(r8) :: fnrt_c ! fineroot carbon [kg] @@ -449,7 +443,6 @@ subroutine phenology( currentSite, bc_in ) ! Parameter of drought decid leaf loss in mm in top layer...FIX(RF,032414) ! - this is arbitrary and poorly understood. Needs work. ED_ - !Parameters: defaults from Botta et al. 2000 GCB,6 709-725 !Parameters, default from from SDGVM model of senesence @@ -479,12 +472,12 @@ subroutine phenology( currentSite, bc_in ) gdd_threshold = ED_val_phen_a + ED_val_phen_b*exp(ED_val_phen_c*real(currentSite%ncd,r8)) !Accumulate temperature of last 10 days. - currentSite%last_n_days(2:senes) = currentSite%last_n_days(1:senes-1) - currentSite%last_n_days(1) = temp_in_C + currentSite%vegtemp_memory(2:num_vegtemp_mem) = currentSite%vegtemp_memory(1:num_vegtemp_mem-1) + currentSite%vegtemp_memory(1) = temp_in_C !count number of days for leaves off ncolddays = 0 - do i = 1,senes - if (currentSite%last_n_days(i) < ED_val_phen_coldtemp)then + do i_tmem = 1,num_vegtemp_mem + if (currentSite%vegtemp_memory(i_tmem) < ED_val_phen_coldtemp)then ncolddays = ncolddays + 1 endif enddo @@ -501,7 +494,6 @@ subroutine phenology( currentSite, bc_in ) currentSite%ED_GDD_site = currentSite%ED_GDD_site + bc_in%t_veg24_si - tfrz endif - ! HLM model day is the total number of days since simulation start ! The leafoffdate and leafondates are all recorded in this unit @@ -510,15 +502,13 @@ subroutine phenology( currentSite, bc_in ) !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 (currentSite%ED_GDD_site > gdd_threshold)then - if (currentSite%status == 1) then - if (currentSite%ncd >= 1) then - currentSite%status = 2 !alter status of site to 'leaves on' - currentSite%cleafondate = model_day_int - if ( debug ) write(fates_log(),*) 'leaves on' - endif !ncd - endif !status + !3) There should have been at least one chilling day in the counting period. + if ( (currentSite%status == 1) .and. & + (currentSite%ED_GDD_site > gdd_threshold) .and. & + (currentSite%ncd >= 1) ) then + currentSite%status = 2 !alter status of site to 'leaves on' + currentSite%cleafondate = model_day_int + if ( debug ) write(fates_log(),*) 'leaves on' endif !GDD dayssincecleafon = model_day_int - currentSite%cleafondate @@ -529,26 +519,28 @@ subroutine phenology( currentSite, bc_in ) !1) have exceeded the number of cold days threshold !2) have exceeded the minimum leafon time. !3) The leaves should not be off already - !4) The day of the year should be larger than the counting period. - ! (not sure if we need this/if it will break the restarting) + !4) The day of simulation should be larger than the counting period. + - if (ncolddays > ED_val_phen_ncolddayslim)then - if (dayssincecleafon > ED_val_phen_mindayson)then - if (currentSite%status == 2)then - currentSite%status = 1 !alter status of site to 'leaves on' - currentSite%cleafoffdate = hlm_model_day !record leaf off date - if ( debug ) write(fates_log(),*) 'leaves off' - endif - endif - endif + if ( (currentSite%status == 2) .and. & + (model_day_int > num_vegtemp_mem) .and. & + (ncolddays > ED_val_phen_ncolddayslim) .and. & + (dayssincecleafon > ED_val_phen_mindayson) )then + + currentSite%status = 1 !alter status of site to 'leaves on' + currentSite%cleafoffdate = model_day_int !record leaf off date + if ( debug ) write(fates_log(),*) 'leaves off' + endif + !LEAF OFF: COLD LIFESPAN THRESHOLD - if(dayssincecleafoff > 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%cleafoffdate = hlm_model_day !record leaf off date - if ( debug ) write(fates_log(),*) 'leaves off' - endif + if( (currentSite%status == 2) .and. & + (dayssincecleafoff > 400)) then !remove leaves after a whole year when there is no 'off' period. + + currentSite%status = 1 !alter status of site to 'leaves on' + currentSite%cleafoffdate = model_day_int !record leaf off date + + if ( debug ) write(fates_log(),*) 'leaves off' endif !-----------------Drought Phenology--------------------! @@ -582,8 +574,8 @@ subroutine phenology( currentSite, bc_in ) ! Accumulate surface water memory of last 10 days. ! Liquid volume in ground layer (m3/m3) - do i = 1,numWaterMem-1 !shift memory along one - currentSite%water_memory(numWaterMem+1-i) = currentSite%water_memory(numWaterMem-i) + do i_wmem = 1,numWaterMem-1 !shift memory along one + currentSite%water_memory(numWaterMem+1-i_wmem) = currentSite%water_memory(numWaterMem-i_wmem) enddo currentSite%water_memory(1) = bc_in%h2o_liqvol_sl(1) @@ -613,8 +605,8 @@ subroutine phenology( currentSite, bc_in ) ! Note that cold-starts begin in the "leaf-on" ! status if ( (currentSite%dstatus == 1) .and. & - (model_day_int > 10) .and. & - (dayssincedleafon > 365-30 .and. dayssinceleafon < 365+30 ) .and. & + (model_day_int > numWaterMem) .and. & + (dayssincedleafon > 365-30 .and. dayssincedleafon < 365+30 ) .and. & (dayssincedleafoff > ED_val_phen_doff_time) ) then ! If leaves are off, and have been off for at least a few days @@ -624,7 +616,6 @@ subroutine phenology( currentSite, bc_in ) if ( mean_10day_liqvol >= ED_val_phen_drought_threshold ) then currentSite%dstatus = 2 ! set status to leaf-on currentSite%dleafondate = model_day_int ! save the model day we start flushing - endif endif endif @@ -641,11 +632,9 @@ subroutine phenology( currentSite, bc_in ) ! i.e. Are the leaves rouhgly at the end of their lives? if ( (currentSite%dstatus == 2) .and. & - (dayssincedleafon > canopy_leaf_lifespan) )then currentSite%dstatus = 1 !alter status of site to 'leaves on' currentSite%dleafoffdate = model_day_int !record leaf on date - endif endif ! LEAF OFF: DROUGHT DECIDUOUS DRYNESS - if the soil gets too dry, @@ -1054,7 +1043,7 @@ subroutine recruitment( currentSite, currentPatch, bc_in ) endif if (temp_cohort%n > 0.0_r8 )then - if ( DEBUG ) write(fates_log(),*) 'EDPhysiologyMod.F90 call create_cohort ' + if ( debug ) write(fates_log(),*) 'EDPhysiologyMod.F90 call create_cohort ' !constrain the number of individual based on rhyzosphere water availability if( hlm_use_planthydro.eq.itrue ) then call carea_allom(temp_cohort%dbh,temp_cohort%n,currentSite%spread, & diff --git a/main/EDInitMod.F90 b/main/EDInitMod.F90 index 75374a3985..bca8b472c4 100644 --- a/main/EDInitMod.F90 +++ b/main/EDInitMod.F90 @@ -110,13 +110,13 @@ subroutine zero_site( site_in ) site_in%dstatus = 0 site_in%ED_GDD_site = nan ! growing degree days site_in%ncd = fates_unset_int - site_in%last_n_days(:) = 999 ! record of last 10 days temperature for senescence model. + site_in%cleafondate = fates_unset_int ! doy of leaf on site_in%cleafoffdate = fates_unset_int ! doy of leaf off site_in%dleafondate = fates_unset_int ! doy of leaf on drought site_in%dleafoffdate = fates_unset_int ! doy of leaf on drought site_in%water_memory(:) = nan - + site_in%vegtemp_memory(:) = nan ! record of last 10 days temperature for senescence model. ! SEED site_in%seed_bank(:) = 0._r8 @@ -231,6 +231,7 @@ subroutine set_site_properties( nsites, sites) if ( hlm_is_restart == ifalse ) then sites(s)%water_memory(1:numWaterMem) = watermem + sites(s)%vegtemp_memory(1:num_vegtemp_mem) = 0._r8 end if sites(s)%status = stat diff --git a/main/EDTypesMod.F90 b/main/EDTypesMod.F90 index ba72c20141..f11bb37f87 100644 --- a/main/EDTypesMod.F90 +++ b/main/EDTypesMod.F90 @@ -115,7 +115,7 @@ module EDTypesMod ! BIOLOGY/BIOGEOCHEMISTRY integer , parameter :: external_recruitment = 0 ! external recruitment flag 1=yes - integer , parameter :: SENES = 10 ! Window of time over which we track temp for cold sensecence (days) + integer , parameter :: num_vegtemp_mem = 10 ! Window of time over which we track temp for cold sensecence (days) real(r8), parameter :: dinc_ed = 1.0_r8 ! size of VAI bins (LAI+SAI) [CHANGE THIS NAME WITH NEXT INTERFACE ! UPDATE] integer , parameter :: N_DIST_TYPES = 3 ! Disturbance Modes 1) tree-fall, 2) fire, 3) logging @@ -581,7 +581,7 @@ module EDTypesMod integer :: status ! are leaves in this pixel on or off for cold decid integer :: dstatus ! are leaves in this pixel on or off for drought decid integer :: ncd ! no chilling days:- - real(r8) :: last_n_days(senes) ! record of last 10 days temperature for senescence model. deg C + real(r8) :: vegtemp_memory(num_vegtemp_mem) ! record of last 10 days temperature for senescence model. deg C integer :: cleafondate ! model date (day integer) of leaf on (cold):- integer :: cleafoffdate ! model date (day integer) of leaf off (cold):- integer :: dleafondate ! model date (day integer) of leaf on drought:- diff --git a/main/FatesRestartInterfaceMod.F90 b/main/FatesRestartInterfaceMod.F90 index c9be0f31ee..b21068fe9b 100644 --- a/main/FatesRestartInterfaceMod.F90 +++ b/main/FatesRestartInterfaceMod.F90 @@ -141,6 +141,7 @@ module FatesRestartInterfaceMod ! Site level integer, private :: ir_watermem_siwm + integer, private :: ir_vegtempmem_siwm integer, private :: ir_seed_bank_sift integer, private :: ir_spread_si integer, private :: ir_recrate_sift @@ -961,6 +962,10 @@ subroutine define_restart_vars(this, initialize_variables) units='m3/m3', flushval = flushzero, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_watermem_siwm ) + call this%set_restart_var(vname='fates_vegtemp_memory', vtype=cohort_r8, & + long_name='last 10 days of 24-hour vegetation temperature, by site x day-index', & + units='m3/m3', flushval = flushzero, & + hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_vegtempmem_siwm ) call this%set_restart_var(vname='fates_recrate', vtype=cohort_r8, & long_name='fates diagnostics on recruitment', & @@ -1402,6 +1407,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites) integer :: io_idx_si_lyr_shell ! site - layer x shell index integer :: io_idx_si_scpf ! each size-class x pft index within site integer :: io_idx_si_sc ! each size-class index within site + integer :: io_idx_si_vtmem ! indices for veg-temp memory at site ! Some counters (for checking mostly) integer :: totalcohorts ! total cohort count on this thread (diagnostic) @@ -1488,6 +1494,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites) rio_age_pa => this%rvars(ir_age_pa)%r81d, & rio_area_pa => this%rvars(ir_area_pa)%r81d, & rio_watermem_siwm => this%rvars(ir_watermem_siwm)%r81d, & + rio_vegtempmem_siwm => this%rvars(ir_vegtempmem_siwm)%r81d, & rio_recrate_sift => this%rvars(ir_recrate_sift)%r81d, & rio_fmortrate_cano_siscpf => this%rvars(ir_fmortrate_cano_siscpf)%r81d, & rio_fmortrate_usto_siscpf => this%rvars(ir_fmortrate_usto_siscpf)%r81d, & @@ -1531,6 +1538,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites) io_idx_pa_cwd = io_idx_co_1st io_idx_pa_ib = io_idx_co_1st io_idx_si_wmem = io_idx_co_1st + io_idx_si_vtmem = io_idx_co_1st ! Hydraulics counters lyr = hydraulic layer, shell = rhizosphere shell @@ -1815,6 +1823,11 @@ subroutine set_restart_vectors(this,nc,nsites,sites) io_idx_si_wmem = io_idx_si_wmem + 1 end do + do i = 1, num_vegtemp_mem + rio_vegtempmem_siwm( io_idx_si_vtmem ) = sites(s)%vegtemp_memory(i) + io_idx_si_vtmem = io_idx_si_vtmem + 1 + end do + ! ----------------------------------------------------------------------------- ! Set site-level hydraulics arrays ! ----------------------------------------------------------------------------- @@ -1938,7 +1951,7 @@ subroutine create_patchcohort_structure(this, nc, nsites, sites, bc_in) ! restart file ! - sites(s)%ncd = 0.0_r8 + sites(s)%ncd = 0 if ( rio_npatch_si(io_idx_si)<0 .or. rio_npatch_si(io_idx_si) > 10000 ) then write(fates_log(),*) 'a column was expected to contain a valid number of patches' @@ -2103,6 +2116,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites) integer :: io_idx_pa_cwd ! each cwd class within each patch (pa_cwd) integer :: io_idx_pa_ib ! each SW radiation band per patch (pa_ib) integer :: io_idx_si_wmem ! each water memory class within each site + integer :: io_idx_si_vtmem ! counter for vegetation temp memory integer :: io_idx_si_lyr_shell ! site - layer x shell index integer :: io_idx_si_scpf ! each size-class x pft index within site integer :: io_idx_si_sc ! each size-class index within site @@ -2216,6 +2230,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites) io_idx_pa_cwd = io_idx_co_1st io_idx_pa_ib = io_idx_co_1st io_idx_si_wmem = io_idx_co_1st + io_idx_si_vtmem = io_idx_co_1st ! Hydraulics counters lyr = hydraulic layer, shell = rhizosphere shell io_idx_si_lyr_shell = io_idx_co_1st @@ -2435,6 +2450,11 @@ subroutine get_restart_vectors(this, nc, nsites, sites) io_idx_si_wmem = io_idx_si_wmem + 1 end do + do i = 1, num_vegtemp_mem + sites(s)%vegtemp_memory(i) = rio_vegtempmem_siwm( io_idx_si_vtmem ) + io_idx_si_vtmem = io_idx_si_vtmem + 1 + end do + ! ----------------------------------------------------------------------------- ! Retrieve site-level hydraulics arrays ! Note that Hydraulics structures, their allocations, and the length From 6146799c7ea7c88cb182dc3b42089a534a924512 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 15 Jan 2019 15:02:25 -0800 Subject: [PATCH 03/27] Small syntax updates to phen refactor, added history tracking of site level status --- biogeochem/EDPhysiologyMod.F90 | 16 ++++---- main/EDInitMod.F90 | 26 ++++++------ main/FatesHistoryInterfaceMod.F90 | 25 ++++++++++-- main/FatesRestartInterfaceMod.F90 | 67 ++++++++++++++++--------------- 4 files changed, 80 insertions(+), 54 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index d8ef758e27..4c12ca64df 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -431,11 +431,6 @@ subroutine phenology( currentSite, bc_in ) ! FIX(RGK 07/10/17) ! This is a band-aid on unusual code - ! This is the minimum number of days that the site must be in a "leaf-on" - ! status in order to start evaluating soil drying to trigger an off state - ! this prevents "flicker" - integer, parameter :: leafon_min_flicker = 100 - ! This is the integer model day. The first day of the simulation is 1, and it ! continues monotonically, indefinitely @@ -453,7 +448,7 @@ subroutine phenology( currentSite, bc_in ) !Zero growing degree and chilling day counters if (currentSite%lat > 0)then ncdstart = 270 !Northern Hemisphere begining November - gddstart = 1 !Northern Hemisphere begining January (RGK: NOT EARLIER?) + gddstart = 1 !Northern Hemisphere begining January else ncdstart = 120 !Southern Hemisphere beginning May gddstart = 181 !Northern Hemisphere begining July @@ -535,6 +530,7 @@ subroutine phenology( currentSite, bc_in ) !LEAF OFF: COLD LIFESPAN THRESHOLD if( (currentSite%status == 2) .and. & + ! (RGK-PHEN: REPLACE WITH canopy_leaf_lifespan?) (dayssincecleafoff > 400)) then !remove leaves after a whole year when there is no 'off' period. currentSite%status = 1 !alter status of site to 'leaves on' @@ -631,6 +627,12 @@ subroutine phenology( currentSite, bc_in ) ! the end of its useful life. A*, E* ! i.e. Are the leaves rouhgly at the end of their lives? + ! (RGK-PHEN) SHOULD THIS BE REMOVED OR MODIFIED? + ! I FEEL LIKE THERE SHOULD BE SOME OTHER MECHANISM IN PLACE HERE + ! DROUGHT DECIDUOUS TREES THAT NEVER EXPERIENCE DROUGHT + ! MEDIATED LEAF DROP SHOULD BE UNFAIRLY COMPETITIVE RIGHT? + ! PERHAPS THIS CAN BE ADDRESSED BY LEAF-AGE BINS... + if ( (currentSite%dstatus == 2) .and. & (dayssincedleafon > canopy_leaf_lifespan) )then currentSite%dstatus = 1 !alter status of site to 'leaves on' @@ -641,7 +643,7 @@ subroutine phenology( currentSite, bc_in ) ! and the leaves have already been on a while... if ( (currentSite%dstatus == 2) .and. & - (model_day_int > 10) .and. & + (model_day_int > numWaterMem) .and. & (mean_10day_liqvol <= ED_val_phen_drought_threshold) .and. & (dayssincedleafon > ED_val_phen_mindayson) ) then currentSite%dstatus = 1 !alter status of site to 'leaves on' diff --git a/main/EDInitMod.F90 b/main/EDInitMod.F90 index bca8b472c4..b12afc95a9 100644 --- a/main/EDInitMod.F90 +++ b/main/EDInitMod.F90 @@ -17,7 +17,8 @@ module EDInitMod use EDPatchDynamicsMod , only : create_patch use EDTypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type use EDTypesMod , only : ncwd - use EDTypesMod , only : nuMWaterMem + use EDTypesMod , only : numWaterMem + use EDTypesMod , only : num_vegtemp_mem use EDTypesMod , only : maxpft use EDTypesMod , only : AREA use EDTypesMod , only : init_spread_near_bare_ground @@ -181,24 +182,25 @@ subroutine set_site_properties( nsites, sites) ! ! !LOCAL VARIABLES: integer :: s - real(r8) :: leafon - real(r8) :: leafoff + real(r8) :: stat integer :: NCD real(r8) :: GDD real(r8) :: dstat real(r8) :: acc_NI - real(r8) :: watermem - integer :: dleafoff - integer :: dleafon + real(r8) :: watermem + real(r8) :: cleafon ! DOY for cold-decid leaf-on, initial guess + real(r8) :: cleafoff ! DOY for cold-decid leaf-off, initial guess + integer :: dleafoff ! DOY for drought-decid leaf-off, initial guess + integer :: dleafon ! DOY for drought-decid leaf-on, initial guess !---------------------------------------------------------------------- if ( hlm_is_restart == ifalse ) then !initial guess numbers for site condition. NCD = 0 GDD = 30.0_r8 - leafon = 100.0_r8 - leafoff = 300.0_r8 + cleafon = 100.0_r8 + cleafoff = 300.0_r8 stat = 2 acc_NI = 0.0_r8 dstat = 2 @@ -210,8 +212,8 @@ subroutine set_site_properties( nsites, sites) NCD = 1 ! NCD should be 1 on restart (RGK-PHEN: ?) GDD = 0.0_r8 - leafon = 0.0_r8 - leafoff = 0.0_r8 + cleafon = 0.0_r8 + cleafoff = 0.0_r8 stat = 1 acc_NI = 0.0_r8 dstat = 2 @@ -223,8 +225,8 @@ subroutine set_site_properties( nsites, sites) do s = 1,nsites sites(s)%ncd = NCD - sites(s)%cleafondate = leafon - sites(s)%cleafoffdate = leafoff + sites(s)%cleafondate = cleafon + sites(s)%cleafoffdate = cleafoff sites(s)%dleafoffdate = dleafoff sites(s)%dleafondate = dleafon sites(s)%ED_GDD_site = GDD diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index 9913aeca3f..ba9abd9b40 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -158,7 +158,9 @@ module FatesHistoryInterfaceMod integer, private :: ih_h2oveg_growturn_err_si integer, private :: ih_h2oveg_pheno_err_si integer, private :: ih_h2oveg_hydro_err_si - + integer, private :: ih_site_cstatus_si + integer, private :: ih_site_dstatus_si + ! Indices to (site x scpf) variables integer, private :: ih_nplant_si_scpf integer, private :: ih_gpp_si_scpf @@ -1523,7 +1525,9 @@ subroutine update_history_dyn(this,nc,nsites,sites) hio_ddbh_canopy_si_scag => this%hvars(ih_ddbh_canopy_si_scag)%r82d, & hio_ddbh_understory_si_scag => this%hvars(ih_ddbh_understory_si_scag)%r82d, & hio_mortality_canopy_si_scag => this%hvars(ih_mortality_canopy_si_scag)%r82d, & - hio_mortality_understory_si_scag => this%hvars(ih_mortality_understory_si_scag)%r82d) + hio_mortality_understory_si_scag => this%hvars(ih_mortality_understory_si_scag)%r82d, & + hio_site_cstatus_si => this%hvars(ih_site_cstatus_si)%r81d, & + hio_site_dstatus_si => this%hvars(ih_site_dstatus_si)%r81d ) ! --------------------------------------------------------------------------------- @@ -1554,7 +1558,10 @@ subroutine update_history_dyn(this,nc,nsites,sites) hio_canopy_spread_si(io_si) = sites(s)%spread - + ! Update the site statuses (stati?) + hio_site_cstatus_si(io_si) = real(sites(s)%status,r8) + hio_site_dstatus_si(io_si) = real(sites(s)%dstatus,r8) + ! If hydraulics are turned on, track the error terms ! associated with dynamics @@ -3211,6 +3218,18 @@ subroutine define_history_vars(this, initialize_variables) avgflag='A', vtype=patch_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_area_treespread_pa) + call this%set_history_var(vname='SITE_COLD_STATUS', units='1,2', & + long='Site level cold status, 1=too cold for leaves, 2=not-too cold', & + use_default='active', & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + ivar=ivar, initialize=initialize_variables, index = ih_site_cstatus_si) + + call this%set_history_var(vname='SITE_DROUGHT_STATUS', units='1,2', & + long='Site level drought status, 1=too dry for leaves, 2=not-too dry', & + use_default='active', & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + ivar=ivar, initialize=initialize_variables, index = ih_site_dstatus_si) + call this%set_history_var(vname='CANOPY_SPREAD', units='0-1', & long='Scaling factor between tree basal area and canopy area', & use_default='active', & diff --git a/main/FatesRestartInterfaceMod.F90 b/main/FatesRestartInterfaceMod.F90 index b21068fe9b..d3d5150905 100644 --- a/main/FatesRestartInterfaceMod.F90 +++ b/main/FatesRestartInterfaceMod.F90 @@ -141,7 +141,7 @@ module FatesRestartInterfaceMod ! Site level integer, private :: ir_watermem_siwm - integer, private :: ir_vegtempmem_siwm + integer, private :: ir_vegtempmem_sitm integer, private :: ir_seed_bank_sift integer, private :: ir_spread_si integer, private :: ir_recrate_sift @@ -553,32 +553,32 @@ subroutine define_restart_vars(this, initialize_variables) flushval = flushzero, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_oldstock_si ) - call this%set_restart_var(vname='fates_cold_dec_status', vtype=site_r8, & - long_name='status flag for cold deciduous plants', units='unitless', flushval = flushzero, & + call this%set_restart_var(vname='fates_cold_dec_status', vtype=site_int, & + long_name='status flag for cold deciduous plants', units='unitless', flushval = flushinvalid, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_cd_status_si ) - call this%set_restart_var(vname='fates_drought_dec_status', vtype=site_r8, & - long_name='status flag for drought deciduous plants', units='unitless', flushval = flushzero, & + call this%set_restart_var(vname='fates_drought_dec_status', vtype=site_int, & + long_name='status flag for drought deciduous plants', units='unitless', flushval = flushinvalid, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_dd_status_si ) call this%set_restart_var(vname='fates_chilling_days', vtype=site_int, & - long_name='chilling day counter', units='unitless', flushval = flushzero, & + long_name='chilling day counter', units='unitless', flushval = flushinvalid, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_nchill_days_si ) - call this%set_restart_var(vname='fates_leafondate', vtype=site_r8, & - long_name='the day of year for leaf on', units='day of year', flushval = flushzero, & + call this%set_restart_var(vname='fates_leafondate', vtype=site_int, & + long_name='the day of year for leaf on', units='day of year', flushval = flushinvalid, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_leafondate_si ) - call this%set_restart_var(vname='fates_leafoffdate', vtype=site_r8, & - long_name='the day of year for leaf off', units='day of year', flushval = flushzero, & + call this%set_restart_var(vname='fates_leafoffdate', vtype=site_int, & + long_name='the day of year for leaf off', units='day of year', flushval = flushinvalid, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_leafoffdate_si ) - call this%set_restart_var(vname='fates_drought_leafondate', vtype=site_r8, & - long_name='the day of year for drought based leaf-on', units='day of year', flushval = flushzero, & + call this%set_restart_var(vname='fates_drought_leafondate', vtype=site_int, & + long_name='the day of year for drought based leaf-on', units='day of year', flushval = flushinvalid, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_dleafondate_si ) - call this%set_restart_var(vname='fates_drought_leafoffdate', vtype=site_r8, & - long_name='the day of year for drought based leaf-off', units='day of year', flushval = flushzero, & + call this%set_restart_var(vname='fates_drought_leafoffdate', vtype=site_int, & + long_name='the day of year for drought based leaf-off', units='day of year', flushval = flushinvalid, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_dleafoffdate_si ) call this%set_restart_var(vname='fates_acc_nesterov_id', vtype=site_r8, & @@ -965,7 +965,7 @@ subroutine define_restart_vars(this, initialize_variables) call this%set_restart_var(vname='fates_vegtemp_memory', vtype=cohort_r8, & long_name='last 10 days of 24-hour vegetation temperature, by site x day-index', & units='m3/m3', flushval = flushzero, & - hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_vegtempmem_siwm ) + hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_vegtempmem_sitm ) call this%set_restart_var(vname='fates_recrate', vtype=cohort_r8, & long_name='fates diagnostics on recruitment', & @@ -1379,6 +1379,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites) use EDTypesMod, only : ncwd use EDTypesMod, only : maxSWb use EDTypesMod, only : numWaterMem + use EDTypesMod, only : num_vegtemp_mem ! Arguments class(fates_restart_interface_type) :: this @@ -1429,13 +1430,13 @@ subroutine set_restart_vectors(this,nc,nsites,sites) associate( rio_npatch_si => this%rvars(ir_npatch_si)%int1d, & rio_old_stock_si => this%rvars(ir_oldstock_si)%r81d, & - rio_cd_status_si => this%rvars(ir_cd_status_si)%r81d, & - rio_dd_status_si => this%rvars(ir_dd_status_si)%r81d, & + rio_cd_status_si => this%rvars(ir_cd_status_si)%int1d, & + rio_dd_status_si => this%rvars(ir_dd_status_si)%int1d, & rio_nchill_days_si => this%rvars(ir_nchill_days_si)%int1d, & - rio_leafondate_si => this%rvars(ir_leafondate_si)%r81d, & - rio_leafoffdate_si => this%rvars(ir_leafoffdate_si)%r81d, & - rio_dleafondate_si => this%rvars(ir_dleafondate_si)%r81d, & - rio_dleafoffdate_si => this%rvars(ir_dleafoffdate_si)%r81d, & + rio_leafondate_si => this%rvars(ir_leafondate_si)%int1d, & + rio_leafoffdate_si => this%rvars(ir_leafoffdate_si)%int1d, & + rio_dleafondate_si => this%rvars(ir_dleafondate_si)%int1d, & + rio_dleafoffdate_si => this%rvars(ir_dleafoffdate_si)%int1d, & rio_acc_ni_si => this%rvars(ir_acc_ni_si)%r81d, & rio_gdd_si => this%rvars(ir_gdd_si)%r81d, & rio_nep_timeintegrated_si => this%rvars(ir_nep_timeintegrated_si)%r81d, & @@ -1494,7 +1495,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites) rio_age_pa => this%rvars(ir_age_pa)%r81d, & rio_area_pa => this%rvars(ir_area_pa)%r81d, & rio_watermem_siwm => this%rvars(ir_watermem_siwm)%r81d, & - rio_vegtempmem_siwm => this%rvars(ir_vegtempmem_siwm)%r81d, & + rio_vegtempmem_sitm => this%rvars(ir_vegtempmem_sitm)%r81d, & rio_recrate_sift => this%rvars(ir_recrate_sift)%r81d, & rio_fmortrate_cano_siscpf => this%rvars(ir_fmortrate_cano_siscpf)%r81d, & rio_fmortrate_usto_siscpf => this%rvars(ir_fmortrate_usto_siscpf)%r81d, & @@ -1824,7 +1825,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites) end do do i = 1, num_vegtemp_mem - rio_vegtempmem_siwm( io_idx_si_vtmem ) = sites(s)%vegtemp_memory(i) + rio_vegtempmem_sitm( io_idx_si_vtmem ) = sites(s)%vegtemp_memory(i) io_idx_si_vtmem = io_idx_si_vtmem + 1 end do @@ -2083,6 +2084,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites) use FatesInterfaceMod, only : numpft use FatesInterfaceMod, only : fates_maxElementsPerPatch use EDTypesMod, only : numWaterMem + use EDTypesMod, only : num_vegtemp_mem use FatesSizeAgeTypeIndicesMod, only : get_age_class_index ! !ARGUMENTS: @@ -2133,13 +2135,13 @@ subroutine get_restart_vectors(this, nc, nsites, sites) associate( rio_npatch_si => this%rvars(ir_npatch_si)%int1d, & rio_old_stock_si => this%rvars(ir_oldstock_si)%r81d, & - rio_cd_status_si => this%rvars(ir_cd_status_si)%r81d, & - rio_dd_status_si => this%rvars(ir_dd_status_si)%r81d, & + rio_cd_status_si => this%rvars(ir_cd_status_si)%int1d, & + rio_dd_status_si => this%rvars(ir_dd_status_si)%int1d, & rio_nchill_days_si => this%rvars(ir_nchill_days_si)%int1d, & - rio_leafondate_si => this%rvars(ir_leafondate_si)%r81d, & - rio_leafoffdate_si => this%rvars(ir_leafoffdate_si)%r81d, & - rio_dleafondate_si => this%rvars(ir_dleafondate_si)%r81d, & - rio_dleafoffdate_si => this%rvars(ir_dleafoffdate_si)%r81d, & + rio_leafondate_si => this%rvars(ir_leafondate_si)%int1d, & + rio_leafoffdate_si => this%rvars(ir_leafoffdate_si)%int1d, & + rio_dleafondate_si => this%rvars(ir_dleafondate_si)%int1d, & + rio_dleafoffdate_si => this%rvars(ir_dleafoffdate_si)%int1d, & rio_acc_ni_si => this%rvars(ir_acc_ni_si)%r81d, & rio_gdd_si => this%rvars(ir_gdd_si)%r81d, & rio_nep_timeintegrated_si => this%rvars(ir_nep_timeintegrated_si)%r81d, & @@ -2198,6 +2200,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites) rio_age_pa => this%rvars(ir_age_pa)%r81d, & rio_area_pa => this%rvars(ir_area_pa)%r81d, & rio_watermem_siwm => this%rvars(ir_watermem_siwm)%r81d, & + rio_vegtempmem_sitm => this%rvars(ir_vegtempmem_sitm)%r81d, & rio_recrate_sift => this%rvars(ir_recrate_sift)%r81d, & rio_fmortrate_cano_siscpf => this%rvars(ir_fmortrate_cano_siscpf)%r81d, & rio_fmortrate_usto_siscpf => this%rvars(ir_fmortrate_usto_siscpf)%r81d, & @@ -2450,9 +2453,9 @@ subroutine get_restart_vectors(this, nc, nsites, sites) io_idx_si_wmem = io_idx_si_wmem + 1 end do - do i = 1, num_vegtemp_mem - sites(s)%vegtemp_memory(i) = rio_vegtempmem_siwm( io_idx_si_vtmem ) - io_idx_si_vtmem = io_idx_si_vtmem + 1 + do i = 1, num_vegtemp_mem + sites(s)%vegtemp_memory(i) = rio_vegtempmem_sitm( io_idx_si_vtmem ) + io_idx_si_vtmem = io_idx_si_vtmem + 1 end do ! ----------------------------------------------------------------------------- From c1c3a53812bc97cd798e97e3072dc1e83df0b73d Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 17 Jan 2019 11:17:16 -0800 Subject: [PATCH 04/27] Adding history flags that can specify something other than zero for non-fates columns --- main/FatesHistoryInterfaceMod.F90 | 37 ++++++++++++++++++++++++++----- main/FatesHistoryVariableType.F90 | 12 +++++++++- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index ba9abd9b40..59aa290fa1 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -402,7 +402,11 @@ module FatesHistoryInterfaceMod ! The number of variable dim/kind types we have defined (static) integer, parameter :: fates_history_num_dimensions = 16 integer, parameter :: fates_history_num_dim_kinds = 18 - + + ! These flags are used to help specify what to do with non-fates + ! locations in the host model + integer, parameter :: zero_flag = 0 + integer, parameter :: ignore_flag = 1 ! This structure is allocated by thread, and must be calculated after the FATES @@ -1050,7 +1054,7 @@ end subroutine flush_hvars ! ===================================================================================== subroutine set_history_var(this, vname, units, long, use_default, avgflag, vtype, & - hlms, flushval, upfreq, ivar, initialize, index) + hlms, flushval, upfreq, ivar, initialize, index, set_nonfates) use FatesUtilsMod, only : check_hlm_list use FatesInterfaceMod, only : hlm_name @@ -1075,10 +1079,23 @@ subroutine set_history_var(this, vname, units, long, use_default, avgflag, vtype ! explict name (for fast reference during update) ! A zero is passed back when the variable is ! not used + + integer, intent(in), optional :: set_nonfates ! If this flag is not present + ! it is assumed that non-fates + ! columns in the host model + ! (or any entity parallel with columns) + ! are set to zero. + ! If this is present, then the + ! value is treated as a flag + ! (0 = 0._r8) + ! (1 = ignore) + + ! locals integer :: ub1, lb1, ub2, lb2 ! Bounds for allocating the var integer :: ityp + integer :: nonfates ! non-optional logical :: write_var @@ -1088,9 +1105,15 @@ subroutine set_history_var(this, vname, units, long, use_default, avgflag, vtype index = ivar if (initialize) then + if(present(set_nonfates_in)) then + nonfates = set_nonfates_in + else + nonfates = zero_flag + end if + call this%hvars(ivar)%Init(vname, units, long, use_default, & - vtype, avgflag, flushval, upfreq, fates_history_num_dim_kinds, this%dim_kinds, & - this%dim_bounds) + vtype, avgflag, flushval, nonfates, upfreq, & + fates_history_num_dim_kinds, this%dim_kinds, this%dim_bounds) end if else index = 0 @@ -3222,13 +3245,15 @@ subroutine define_history_vars(this, initialize_variables) long='Site level cold status, 1=too cold for leaves, 2=not-too cold', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_site_cstatus_si) + ivar=ivar, initialize=initialize_variables, index = ih_site_cstatus_si, & + set_nonfates=ignore_flag) call this%set_history_var(vname='SITE_DROUGHT_STATUS', units='1,2', & long='Site level drought status, 1=too dry for leaves, 2=not-too dry', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_site_dstatus_si) + ivar=ivar, initialize=initialize_variables, index = ih_site_dstatus_si, & + set_nonfates=ignore_flag) call this%set_history_var(vname='CANOPY_SPREAD', units='0-1', & long='Scaling factor between tree basal area and canopy area', & diff --git a/main/FatesHistoryVariableType.F90 b/main/FatesHistoryVariableType.F90 index 07b24176f4..a29759dee6 100644 --- a/main/FatesHistoryVariableType.F90 +++ b/main/FatesHistoryVariableType.F90 @@ -22,6 +22,14 @@ module FatesHistoryVariableType ! 1 = dynamics "dyn" (daily) ! 2 = production "prod" (prob model tstep) real(r8) :: flushval + integer :: set_nonfates ! This is a flag that tells the host + ! what to do with the non-fates + ! entities that may be in parallel with + ! fates sites (for intance lakes) + ! its up to the interface to interpret the flag + ! but 0 should map to 0.0 + ! and 1 should map to an ignore flag if possible + integer :: dim_kinds_index ! Pointers (only one of these is allocated per variable) real(r8), pointer :: r81d(:) @@ -39,7 +47,7 @@ module FatesHistoryVariableType contains subroutine Init(this, vname, units, long, use_default, & - vtype, avgflag, flushval, upfreq, num_dim_kinds, dim_kinds, dim_bounds) + vtype, avgflag, flushval, set_nonfates, upfreq, num_dim_kinds, dim_kinds, dim_bounds) use FatesIODimensionsMod, only : fates_io_dimension_type @@ -61,6 +69,7 @@ subroutine Init(this, vname, units, long, use_default, & character(len=*), intent(in) :: use_default character(len=*), intent(in) :: vtype character(len=*), intent(in) :: avgflag + real(r8), intent(in) :: set_nonfates real(r8), intent(in) :: flushval ! If the type is an int we will round with nint integer, intent(in) :: upfreq integer, intent(in) :: num_dim_kinds @@ -76,6 +85,7 @@ subroutine Init(this, vname, units, long, use_default, & this%use_default = use_default this%vtype = vtype this%avgflag = avgflag + this%set_nonfates = set_nonfates this%flushval = flushval this%upfreq = upfreq From 1d319ced059f7d6673087f209d5139fa22d8d980 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 17 Jan 2019 11:35:08 -0800 Subject: [PATCH 05/27] Small bugfix on the nonfates history flag --- main/FatesHistoryInterfaceMod.F90 | 4 ++-- main/FatesHistoryVariableType.F90 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index 59aa290fa1..f501fab451 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -1105,8 +1105,8 @@ subroutine set_history_var(this, vname, units, long, use_default, avgflag, vtype index = ivar if (initialize) then - if(present(set_nonfates_in)) then - nonfates = set_nonfates_in + if(present(set_nonfates)) then + nonfates = set_nonfates else nonfates = zero_flag end if diff --git a/main/FatesHistoryVariableType.F90 b/main/FatesHistoryVariableType.F90 index a29759dee6..1f8d13b1e2 100644 --- a/main/FatesHistoryVariableType.F90 +++ b/main/FatesHistoryVariableType.F90 @@ -69,7 +69,7 @@ subroutine Init(this, vname, units, long, use_default, & character(len=*), intent(in) :: use_default character(len=*), intent(in) :: vtype character(len=*), intent(in) :: avgflag - real(r8), intent(in) :: set_nonfates + integer, intent(in) :: set_nonfates real(r8), intent(in) :: flushval ! If the type is an int we will round with nint integer, intent(in) :: upfreq integer, intent(in) :: num_dim_kinds From b08ba2a81d61c7e180a64ce6146ee267f70ff02a Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 18 Jan 2019 14:57:50 -0700 Subject: [PATCH 06/27] added spval to flushval for STATUS flags --- main/FatesConstantsMod.F90 | 6 ++++++ main/FatesHistoryInterfaceMod.F90 | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/main/FatesConstantsMod.F90 b/main/FatesConstantsMod.F90 index f585c53915..f90286d96c 100644 --- a/main/FatesConstantsMod.F90 +++ b/main/FatesConstantsMod.F90 @@ -18,6 +18,12 @@ module FatesConstantsMod ! Unset and various other 'special' values integer, parameter :: fates_unset_int = -9999 + ! special value for real data (history ignore val) + real(fates_r8), parameter :: clm_spval = 1.e36_fates_r8 + + ! special value for integer data + integer , parameter :: clm_ispval = -9999 + ! Integer equivalent of true (in case some compilers dont auto convert) integer, parameter :: itrue = 1 diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index f501fab451..5ec015ccc6 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -6,6 +6,7 @@ module FatesHistoryInterfaceMod use FatesConstantsMod , only : fates_long_string_length use FatesConstantsMod , only : itrue,ifalse use FatesConstantsMod , only : calloc_abs_error + use FatesConstantsMod , only : clm_spval use FatesGlobals , only : fates_log use FatesGlobals , only : endrun => fates_endrun use EDTypesMod , only : nclmax @@ -1557,7 +1558,7 @@ subroutine update_history_dyn(this,nc,nsites,sites) ! Flush arrays to values defined by %flushval (see registry entry in ! subroutine define_history_vars() ! --------------------------------------------------------------------------------- - call this%flush_hvars(nc,upfreq_in=1) + !! call this%flush_hvars(nc,upfreq_in=1) ! If we don't have dynamics turned on, we just abort these diagnostics @@ -3244,14 +3245,14 @@ subroutine define_history_vars(this, initialize_variables) call this%set_history_var(vname='SITE_COLD_STATUS', units='1,2', & long='Site level cold status, 1=too cold for leaves, 2=not-too cold', & use_default='active', & - avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_site_cstatus_si, & set_nonfates=ignore_flag) call this%set_history_var(vname='SITE_DROUGHT_STATUS', units='1,2', & long='Site level drought status, 1=too dry for leaves, 2=not-too dry', & use_default='active', & - avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_site_dstatus_si, & set_nonfates=ignore_flag) From 85f78ce4e05698bf824581955eede89aded4909f Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 23 Jan 2019 16:37:57 -0800 Subject: [PATCH 07/27] Added diagnostics for site level phenology statistics --- main/FatesHistoryInterfaceMod.F90 | 99 ++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index f501fab451..a94e85f770 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -10,6 +10,8 @@ module FatesHistoryInterfaceMod use FatesGlobals , only : endrun => fates_endrun use EDTypesMod , only : nclmax use EDTypesMod , only : ican_upper + use EDTypesMod , only : numWaterMem + use EDTypesMod , only : num_vegtemp_mem use FatesIODimensionsMod , only : fates_io_dimension_type use FatesIOVariableKindMod , only : fates_io_variable_kind_type use FatesHistoryVariableType , only : fates_history_variable_type @@ -19,8 +21,10 @@ module FatesHistoryInterfaceMod use FatesInterfaceMod , only : numpft use FatesInterfaceMod , only : hlm_freq_day use EDParamsMod , only : ED_val_comp_excln + use EDParamsMod , only : ED_val_phen_coldtemp use FatesInterfaceMod , only : nlevsclass, nlevage use FatesInterfaceMod , only : nlevheight + use FatesInterfaceMod , only : hlm_model_day ! FIXME(bja, 2016-10) need to remove CLM dependancy use EDPftvarcon , only : EDPftvarcon_inst @@ -160,6 +164,14 @@ module FatesHistoryInterfaceMod integer, private :: ih_h2oveg_hydro_err_si integer, private :: ih_site_cstatus_si integer, private :: ih_site_dstatus_si + integer, private :: ih_gdd_si + integer, private :: ih_site_ncolddays_si + integer, private :: ih_cleafoff_si + integer, private :: ih_cleafon_si + integer, private :: ih_dleafoff_si + integer, private :: ih_dleafon_si + integer, private :: ih_meanliqvol_si + ! Indices to (site x scpf) variables integer, private :: ih_nplant_si_scpf @@ -1335,6 +1347,10 @@ subroutine update_history_dyn(this,nc,nsites,sites) integer :: ican, ileaf, cnlf_indx ! iterators for leaf and canopy level integer :: height_bin_max, height_bin_min ! which height bin a given cohort's canopy is in integer :: i_heightbin ! iterator for height bins + integer :: i_tmem ! iterator for veg temp bins + integer :: ncolddays ! number of days below cold threshold over counting period + integer :: model_day_int ! integer model day from reference + real(r8) :: n_density ! individual of cohort per m2. real(r8) :: n_perm2 ! individuals per m2 for the whole column @@ -1550,7 +1566,14 @@ subroutine update_history_dyn(this,nc,nsites,sites) hio_mortality_canopy_si_scag => this%hvars(ih_mortality_canopy_si_scag)%r82d, & hio_mortality_understory_si_scag => this%hvars(ih_mortality_understory_si_scag)%r82d, & hio_site_cstatus_si => this%hvars(ih_site_cstatus_si)%r81d, & - hio_site_dstatus_si => this%hvars(ih_site_dstatus_si)%r81d ) + hio_site_dstatus_si => this%hvars(ih_site_dstatus_si)%r81d, & + hio_gdd_si => this%hvars(ih_gdd_si)%r81d, & + hio_site_ncolddays_si => this%hvars(ih_site_ncolddays_si)%r81d, & + hio_cleafoff_si => this%hvars(ih_cleafoff_si)%r81d, & + hio_cleafon_si => this%hvars(ih_cleafon_si)%r81d, & + hio_dleafoff_si => this%hvars(ih_dleafoff_si)%r81d, & + hio_dleafon_si => this%hvars(ih_dleafoff_si)%r81d, & + hio_meanliqvol_si => this%hvars(ih_meanliqvol_si)%r81d ) ! --------------------------------------------------------------------------------- @@ -1563,6 +1586,8 @@ subroutine update_history_dyn(this,nc,nsites,sites) ! If we don't have dynamics turned on, we just abort these diagnostics if (hlm_use_ed_st3.eq.itrue) return + model_day_int = nint(hlm_model_day) + ! --------------------------------------------------------------------------------- ! Loop through the FATES scale hierarchy and fill the history IO arrays ! --------------------------------------------------------------------------------- @@ -1585,6 +1610,29 @@ subroutine update_history_dyn(this,nc,nsites,sites) hio_site_cstatus_si(io_si) = real(sites(s)%status,r8) hio_site_dstatus_si(io_si) = real(sites(s)%dstatus,r8) + !count number of days for leaves off + if(model_day_int>num_vegtemp_mem)then + ncolddays = 0 + do i_tmem = 1,num_vegtemp_mem + if (sites(s)%vegtemp_memory(i_tmem) < ED_val_phen_coldtemp)then + ncolddays = ncolddays + 1 + endif + enddo + hio_site_ncolddays_si(io_si) = real(ncolddays,r8) + end if + + hio_gdd_si(io_si) = sites(s)%ed_gdd_site + hio_cleafoff_si(io_si) = real(model_day_int - sites(s)%cleafoffdate,r8) + hio_cleafon_si(io_si) = real(model_day_int - sites(s)%cleafondate,r8) + hio_dleafoff_si(io_si) = real(model_day_int - sites(s)%dleafoffdate,r8) + hio_dleafon_si(io_si) = real(model_day_int - sites(s)%dleafondate,r8) + + if(model_day_int>numWaterMem)then + hio_meanliqvol_si(io_si) = & + sum(sites(s)%water_memory(1:numWaterMem))/real(numWaterMem,r8) + end if + + ! If hydraulics are turned on, track the error terms ! associated with dynamics @@ -3255,6 +3303,55 @@ subroutine define_history_vars(this, initialize_variables) ivar=ivar, initialize=initialize_variables, index = ih_site_dstatus_si, & set_nonfates=ignore_flag) + call this%set_history_var(vname='SITE_GDD', units='degC', & + long='site level growing degree days', & + use_default='active', & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + ivar=ivar, initialize=initialize_variables, index = ih_gdd_si, & + set_nonfates=ignore_flag) + + call this%set_history_var(vname='SITE_NCOLDDAYS', units = 'days', & + long='site level number of cold days', & + use_default='active', & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + ivar=ivar, initialize=initialize_variables, index = ih_site_ncolddays_si, & + set_nonfates=ignore_flag) + + call this%set_history_var(vname='SITE_DAYSINCE_COLDLEAFOFF', units='days', & + long='site level days elapsed since cold leaf drop', & + use_default='active', & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + ivar=ivar, initialize=initialize_variables, index = ih_cleafoff_si, & + set_nonfates=ignore_flag) + + call this%set_history_var(vname='SITE_DAYSINCE_COLDLEAFON', units='days', & + long='site level days elapsed since cold leaf flush', & + use_default='active', & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + ivar=ivar, initialize=initialize_variables, index = ih_cleafon_si, & + set_nonfates=ignore_flag) + + call this%set_history_var(vname='SITE_DAYSINCE_DROUGHTLEAFOFF', units='days', & + long='site level days elapsed since drought leaf drop', & + use_default='active', & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + ivar=ivar, initialize=initialize_variables, index = ih_dleafoff_si, & + set_nonfates=ignore_flag) + + call this%set_history_var(vname='SITE_DAYSINCE_DROUGHTLEAFON', units='days', & + long='site level days elapsed since drought leaf flush', & + use_default='active', & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + ivar=ivar, initialize=initialize_variables, index = ih_dleafon_si, & + set_nonfates=ignore_flag) + + call this%set_history_var(vname='SITE_MEANLIQVOL_DROUGHTPHEN', units='m3/m3', & + long='site level mean liquid water volume for drought phen', & + use_default='active', & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + ivar=ivar, initialize=initialize_variables, index = ih_meanliqvol_si, & + set_nonfates=ignore_flag) + call this%set_history_var(vname='CANOPY_SPREAD', units='0-1', & long='Scaling factor between tree basal area and canopy area', & use_default='active', & From 30cdb724170fa852cb6b4b2aa85b8818e2fe1eb8 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 23 Jan 2019 16:49:53 -0800 Subject: [PATCH 08/27] Added special flags to fates phenology diagnostics, re-added the flushing for dynamics diagnostics --- main/FatesHistoryInterfaceMod.F90 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index c066a83c55..2c3251cc50 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -1581,7 +1581,7 @@ subroutine update_history_dyn(this,nc,nsites,sites) ! Flush arrays to values defined by %flushval (see registry entry in ! subroutine define_history_vars() ! --------------------------------------------------------------------------------- - !! call this%flush_hvars(nc,upfreq_in=1) + call this%flush_hvars(nc,upfreq_in=1) ! If we don't have dynamics turned on, we just abort these diagnostics @@ -3307,49 +3307,49 @@ subroutine define_history_vars(this, initialize_variables) call this%set_history_var(vname='SITE_GDD', units='degC', & long='site level growing degree days', & use_default='active', & - avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_gdd_si, & set_nonfates=ignore_flag) call this%set_history_var(vname='SITE_NCOLDDAYS', units = 'days', & long='site level number of cold days', & use_default='active', & - avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_site_ncolddays_si, & set_nonfates=ignore_flag) call this%set_history_var(vname='SITE_DAYSINCE_COLDLEAFOFF', units='days', & long='site level days elapsed since cold leaf drop', & use_default='active', & - avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_cleafoff_si, & set_nonfates=ignore_flag) call this%set_history_var(vname='SITE_DAYSINCE_COLDLEAFON', units='days', & long='site level days elapsed since cold leaf flush', & use_default='active', & - avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_cleafon_si, & set_nonfates=ignore_flag) call this%set_history_var(vname='SITE_DAYSINCE_DROUGHTLEAFOFF', units='days', & long='site level days elapsed since drought leaf drop', & use_default='active', & - avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_dleafoff_si, & set_nonfates=ignore_flag) call this%set_history_var(vname='SITE_DAYSINCE_DROUGHTLEAFON', units='days', & long='site level days elapsed since drought leaf flush', & use_default='active', & - avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_dleafon_si, & set_nonfates=ignore_flag) call this%set_history_var(vname='SITE_MEANLIQVOL_DROUGHTPHEN', units='m3/m3', & long='site level mean liquid water volume for drought phen', & use_default='active', & - avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & + avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_meanliqvol_si, & set_nonfates=ignore_flag) From 4a2980a638170e30f62ab1b2f115aca764dfe033 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 25 Jan 2019 11:11:44 -0800 Subject: [PATCH 09/27] Preventing flickering from pre-mature leaf-on in cold-deciduous, removing NCD>1 --- biogeochem/EDPhysiologyMod.F90 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 4c12ca64df..dc30a99dbf 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -464,6 +464,7 @@ subroutine phenology( currentSite, bc_in ) endif !GDD accumulation function, which also depends on chilling days. + ! -68 + 638 * (-0.001 * ncd) gdd_threshold = ED_val_phen_a + ED_val_phen_b*exp(ED_val_phen_c*real(currentSite%ncd,r8)) !Accumulate temperature of last 10 days. @@ -498,9 +499,12 @@ subroutine phenology( currentSite, bc_in ) !1) have exceeded the growing degree day threshold !2) The leaves should not be on already !3) There should have been at least one chilling day in the counting period. + + ! (currentSite%ncd >= 1) .and. & + if ( (currentSite%status == 1) .and. & (currentSite%ED_GDD_site > gdd_threshold) .and. & - (currentSite%ncd >= 1) ) then + (dayssinceleafoff > ED_val_phen_mindayson)) then currentSite%status = 2 !alter status of site to 'leaves on' currentSite%cleafondate = model_day_int if ( debug ) write(fates_log(),*) 'leaves on' @@ -529,15 +533,15 @@ subroutine phenology( currentSite, bc_in ) endif !LEAF OFF: COLD LIFESPAN THRESHOLD - if( (currentSite%status == 2) .and. & - ! (RGK-PHEN: REPLACE WITH canopy_leaf_lifespan?) - (dayssincecleafoff > 400)) then !remove leaves after a whole year when there is no 'off' period. +!! if( (currentSite%status == 2) .and. & +!! ! (RGK-PHEN: REPLACE WITH canopy_leaf_lifespan?) +!! (dayssincecleafoff > 400)) then !remove leaves after a whole year when there is no 'off' period. - currentSite%status = 1 !alter status of site to 'leaves on' - currentSite%cleafoffdate = model_day_int !record leaf off date +!! currentSite%status = 1 !alter status of site to 'leaves on' +!! currentSite%cleafoffdate = model_day_int !record leaf off date - if ( debug ) write(fates_log(),*) 'leaves off' - endif +!! if ( debug ) write(fates_log(),*) 'leaves off' +!! endif !-----------------Drought Phenology--------------------! ! Principles of drought-deciduos phenology model... From 51ef6e689cd3a1ed7e1d7862a36ab86b9f0e3edd Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 25 Jan 2019 17:25:25 -0700 Subject: [PATCH 10/27] Zeroing gdd counter when cold leaves drop to prevent reflushing --- biogeochem/EDPhysiologyMod.F90 | 36 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index dc30a99dbf..dbef876404 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -500,11 +500,10 @@ subroutine phenology( currentSite, bc_in ) !2) The leaves should not be on already !3) There should have been at least one chilling day in the counting period. - ! (currentSite%ncd >= 1) .and. & - - if ( (currentSite%status == 1) .and. & + if ( (currentSite%status == 1 .or. currentSite%status == 0) .and. & (currentSite%ED_GDD_site > gdd_threshold) .and. & - (dayssinceleafoff > ED_val_phen_mindayson)) then + (currentSite%ncd >= 1) .and. & + (dayssincecleafoff > ED_val_phen_mindayson)) then currentSite%status = 2 !alter status of site to 'leaves on' currentSite%cleafondate = model_day_int if ( debug ) write(fates_log(),*) 'leaves on' @@ -526,22 +525,27 @@ subroutine phenology( currentSite, bc_in ) (ncolddays > ED_val_phen_ncolddayslim) .and. & (dayssincecleafon > ED_val_phen_mindayson) )then - currentSite%status = 1 !alter status of site to 'leaves on' + currentSite%ED_GDD_site = 0._r8 ! The equations for Botta et al + ! are for calculations of + ! first flush, but if we dont + ! clear this value, it will cause + ! leaves to flush later in the year + currentSite%status = 1 !alter status of site to 'leaves on' currentSite%cleafoffdate = model_day_int !record leaf off date if ( debug ) write(fates_log(),*) 'leaves off' endif !LEAF OFF: COLD LIFESPAN THRESHOLD -!! if( (currentSite%status == 2) .and. & -!! ! (RGK-PHEN: REPLACE WITH canopy_leaf_lifespan?) -!! (dayssincecleafoff > 400)) then !remove leaves after a whole year when there is no 'off' period. - -!! currentSite%status = 1 !alter status of site to 'leaves on' -!! currentSite%cleafoffdate = model_day_int !record leaf off date + if( (currentSite%status == 2) .and. & + ! (RGK-PHEN: REPLACE WITH canopy_leaf_lifespan?) + (dayssincecleafoff > 400)) then !remove leaves after a whole year when there is no 'off' period. + + currentSite%status = 0 ! alter status of site to "not-cold deciduous" + currentSite%cleafoffdate = model_day_int ! record leaf off date -!! if ( debug ) write(fates_log(),*) 'leaves off' -!! endif + if ( debug ) write(fates_log(),*) 'leaves off' + endif !-----------------Drought Phenology--------------------! ! Principles of drought-deciduos phenology model... @@ -639,7 +643,7 @@ subroutine phenology( currentSite, bc_in ) if ( (currentSite%dstatus == 2) .and. & (dayssincedleafon > canopy_leaf_lifespan) )then - currentSite%dstatus = 1 !alter status of site to 'leaves on' + currentSite%dstatus = 1 !alter status of site to 'leaves off' currentSite%dleafoffdate = model_day_int !record leaf on date endif @@ -650,7 +654,7 @@ subroutine phenology( currentSite, bc_in ) (model_day_int > numWaterMem) .and. & (mean_10day_liqvol <= ED_val_phen_drought_threshold) .and. & (dayssincedleafon > ED_val_phen_mindayson) ) then - currentSite%dstatus = 1 !alter status of site to 'leaves on' + currentSite%dstatus = 1 !alter status of site to 'leaves off' currentSite%dleafoffdate = hlm_day_of_year !record leaf on date endif @@ -720,7 +724,7 @@ subroutine phenology_leafonoff(currentSite) endif ! growing season !COLD LEAF OFF - if (currentSite%status == 1)then !past leaf drop day? Leaves still on tree? + if (currentSite%status == 1 .or. currentSite%status == 0)then !past leaf drop day? Leaves still on tree? if (currentCohort%status_coh == 2)then ! leaves have not dropped ! This sets the cohort to the "leaves off" flag From 42ed191aba0657a58f6571f73ec0598a29c13c8b Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 25 Jan 2019 17:43:31 -0700 Subject: [PATCH 11/27] Minor syntax updates to cold deciduous formulation, fixed Botta et al C parameter for the GDD threshold equation --- biogeochem/EDPhysiologyMod.F90 | 11 +++++++++-- main/EDInitMod.F90 | 12 ++++++------ main/EDTypesMod.F90 | 4 ++++ parameter_files/fates_params_14pfts.cdl | 2 +- parameter_files/fates_params_coastal_veg.cdl | 2 +- parameter_files/fates_params_default.cdl | 2 +- parameter_files/fates_params_hydro_default.cdl | 2 +- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index dbef876404..62f23e7f0d 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -499,6 +499,9 @@ subroutine phenology( currentSite, bc_in ) !1) have exceeded the growing degree day threshold !2) The leaves should not be on already !3) There should have been at least one chilling day in the counting period. + ! this prevents tropical or warm climate plants that are "cold-deciduous" + ! from ever re-flushing after they have reached their maximum age (thus + ! preventing them from competing if ( (currentSite%status == 1 .or. currentSite%status == 0) .and. & (currentSite%ED_GDD_site > gdd_threshold) .and. & @@ -536,9 +539,13 @@ subroutine phenology( currentSite, bc_in ) if ( debug ) write(fates_log(),*) 'leaves off' endif - !LEAF OFF: COLD LIFESPAN THRESHOLD + ! LEAF OFF: COLD LIFESPAN THRESHOLD + ! NOTE: Some areas of the planet will never generate a cold day + ! and thus %ncd will never go from zero to 1. The following logic + ! when coupled with this fact will essentially prevent cold-deciduous + ! plants from re-emerging in areas without at least some cold days + if( (currentSite%status == 2) .and. & - ! (RGK-PHEN: REPLACE WITH canopy_leaf_lifespan?) (dayssincecleafoff > 400)) then !remove leaves after a whole year when there is no 'off' period. currentSite%status = 0 ! alter status of site to "not-cold deciduous" diff --git a/main/EDInitMod.F90 b/main/EDInitMod.F90 index b12afc95a9..3dd5520754 100644 --- a/main/EDInitMod.F90 +++ b/main/EDInitMod.F90 @@ -107,8 +107,8 @@ subroutine zero_site( site_in ) site_in%total_burn_flux_to_atm = 0._r8 ! PHENOLOGY - site_in%status = 0 ! are leaves in this pixel on or off? - site_in%dstatus = 0 + site_in%status = fates_unset_int ! are leaves in this pixel on or off? + site_in%dstatus = fates_unset_int site_in%ED_GDD_site = nan ! growing degree days site_in%ncd = fates_unset_int @@ -200,10 +200,10 @@ subroutine set_site_properties( nsites, sites) NCD = 0 GDD = 30.0_r8 cleafon = 100.0_r8 - cleafoff = 300.0_r8 - stat = 2 + cleafoff = 300.0_r8 + stat = 2 ! Leaves are on acc_NI = 0.0_r8 - dstat = 2 + dstat = 2 ! Leaves are on dleafoff = 300 dleafon = 100 watermem = 0.5_r8 @@ -214,7 +214,7 @@ subroutine set_site_properties( nsites, sites) GDD = 0.0_r8 cleafon = 0.0_r8 cleafoff = 0.0_r8 - stat = 1 + stat = 1 acc_NI = 0.0_r8 dstat = 2 dleafoff = 300 diff --git a/main/EDTypesMod.F90 b/main/EDTypesMod.F90 index f11bb37f87..08df70aea7 100644 --- a/main/EDTypesMod.F90 +++ b/main/EDTypesMod.F90 @@ -579,6 +579,10 @@ module EDTypesMod ! PHENOLOGY real(r8) :: ED_GDD_site ! ED Phenology growing degree days. integer :: status ! are leaves in this pixel on or off for cold decid + ! 0 = this site has not experienced a cold period over at least + ! 400 days, leaves are dropped and flagged as non-cold region + ! 1 = this site is in a cold-state where leaves should have fallen + ! 2 = this site is in a warm-state where leaves are allowed to flush integer :: dstatus ! are leaves in this pixel on or off for drought decid integer :: ncd ! no chilling days:- real(r8) :: vegtemp_memory(num_vegtemp_mem) ! record of last 10 days temperature for senescence model. deg C diff --git a/parameter_files/fates_params_14pfts.cdl b/parameter_files/fates_params_14pfts.cdl index be2fcdda0b..46bdf8684c 100644 --- a/parameter_files/fates_params_14pfts.cdl +++ b/parameter_files/fates_params_14pfts.cdl @@ -661,7 +661,7 @@ data: fates_phen_b = 638 ; - fates_phen_c = -0.001 ; + fates_phen_c = -0.01 ; fates_phen_chiltemp = 5 ; diff --git a/parameter_files/fates_params_coastal_veg.cdl b/parameter_files/fates_params_coastal_veg.cdl index 60c887fb83..8ce33e3c81 100644 --- a/parameter_files/fates_params_coastal_veg.cdl +++ b/parameter_files/fates_params_coastal_veg.cdl @@ -920,7 +920,7 @@ data: fates_phen_b = 638 ; - fates_phen_c = -0.001 ; + fates_phen_c = -0.01 ; fates_phen_chiltemp = 5 ; diff --git a/parameter_files/fates_params_default.cdl b/parameter_files/fates_params_default.cdl index 0579b9405a..52ecbe65ef 100644 --- a/parameter_files/fates_params_default.cdl +++ b/parameter_files/fates_params_default.cdl @@ -1044,7 +1044,7 @@ data: fates_phen_b = 638 ; - fates_phen_c = -0.001 ; + fates_phen_c = -0.01 ; fates_phen_chiltemp = 5 ; diff --git a/parameter_files/fates_params_hydro_default.cdl b/parameter_files/fates_params_hydro_default.cdl index e6e3adfbec..97ee38f921 100644 --- a/parameter_files/fates_params_hydro_default.cdl +++ b/parameter_files/fates_params_hydro_default.cdl @@ -1041,7 +1041,7 @@ data: fates_phen_b = 638 ; - fates_phen_c = -0.001 ; + fates_phen_c = -0.01 ; fates_phen_chiltemp = 5 ; From 7c00439101b4ba01067ab3ba1b684b5c8d30dc4e Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Sat, 26 Jan 2019 17:32:01 -0700 Subject: [PATCH 12/27] Removed the set_nonfates stuff --- biogeochem/EDPhysiologyMod.F90 | 4 +-- main/FatesHistoryInterfaceMod.F90 | 48 +++++++------------------------ main/FatesHistoryVariableType.F90 | 14 ++------- 3 files changed, 15 insertions(+), 51 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 62f23e7f0d..be6729b993 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -617,7 +617,7 @@ subroutine phenology( currentSite, bc_in ) ! status if ( (currentSite%dstatus == 1) .and. & (model_day_int > numWaterMem) .and. & - (dayssincedleafon > 365-30 .and. dayssincedleafon < 365+30 ) .and. & + (dayssincedleafon >= 365-30 .and. dayssincedleafon =< 365+30 ) .and. & (dayssincedleafoff > ED_val_phen_doff_time) ) then ! If leaves are off, and have been off for at least a few days @@ -660,7 +660,7 @@ subroutine phenology( currentSite, bc_in ) if ( (currentSite%dstatus == 2) .and. & (model_day_int > numWaterMem) .and. & (mean_10day_liqvol <= ED_val_phen_drought_threshold) .and. & - (dayssincedleafon > ED_val_phen_mindayson) ) then + (dayssincedleafon > 100 ) ) then currentSite%dstatus = 1 !alter status of site to 'leaves off' currentSite%dleafoffdate = hlm_day_of_year !record leaf on date endif diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index 2c3251cc50..a95ef4165f 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -1067,7 +1067,7 @@ end subroutine flush_hvars ! ===================================================================================== subroutine set_history_var(this, vname, units, long, use_default, avgflag, vtype, & - hlms, flushval, upfreq, ivar, initialize, index, set_nonfates) + hlms, flushval, upfreq, ivar, initialize, index) use FatesUtilsMod, only : check_hlm_list use FatesInterfaceMod, only : hlm_name @@ -1093,17 +1093,6 @@ subroutine set_history_var(this, vname, units, long, use_default, avgflag, vtype ! A zero is passed back when the variable is ! not used - integer, intent(in), optional :: set_nonfates ! If this flag is not present - ! it is assumed that non-fates - ! columns in the host model - ! (or any entity parallel with columns) - ! are set to zero. - ! If this is present, then the - ! value is treated as a flag - ! (0 = 0._r8) - ! (1 = ignore) - - ! locals integer :: ub1, lb1, ub2, lb2 ! Bounds for allocating the var @@ -1118,14 +1107,8 @@ subroutine set_history_var(this, vname, units, long, use_default, avgflag, vtype index = ivar if (initialize) then - if(present(set_nonfates)) then - nonfates = set_nonfates - else - nonfates = zero_flag - end if - call this%hvars(ivar)%Init(vname, units, long, use_default, & - vtype, avgflag, flushval, nonfates, upfreq, & + vtype, avgflag, flushval, upfreq, & fates_history_num_dim_kinds, this%dim_kinds, this%dim_bounds) end if else @@ -3294,64 +3277,55 @@ subroutine define_history_vars(this, initialize_variables) long='Site level cold status, 1=too cold for leaves, 2=not-too cold', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_site_cstatus_si, & - set_nonfates=ignore_flag) + ivar=ivar, initialize=initialize_variables, index = ih_site_cstatus_si ) call this%set_history_var(vname='SITE_DROUGHT_STATUS', units='1,2', & long='Site level drought status, 1=too dry for leaves, 2=not-too dry', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_site_dstatus_si, & - set_nonfates=ignore_flag) + ivar=ivar, initialize=initialize_variables, index = ih_site_dstatus_si) call this%set_history_var(vname='SITE_GDD', units='degC', & long='site level growing degree days', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_gdd_si, & - set_nonfates=ignore_flag) + ivar=ivar, initialize=initialize_variables, index = ih_gdd_si) call this%set_history_var(vname='SITE_NCOLDDAYS', units = 'days', & long='site level number of cold days', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_site_ncolddays_si, & - set_nonfates=ignore_flag) + ivar=ivar, initialize=initialize_variables, index = ih_site_ncolddays_si) call this%set_history_var(vname='SITE_DAYSINCE_COLDLEAFOFF', units='days', & long='site level days elapsed since cold leaf drop', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_cleafoff_si, & - set_nonfates=ignore_flag) + ivar=ivar, initialize=initialize_variables, index = ih_cleafoff_si) call this%set_history_var(vname='SITE_DAYSINCE_COLDLEAFON', units='days', & long='site level days elapsed since cold leaf flush', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_cleafon_si, & - set_nonfates=ignore_flag) + ivar=ivar, initialize=initialize_variables, index = ih_cleafon_si) call this%set_history_var(vname='SITE_DAYSINCE_DROUGHTLEAFOFF', units='days', & long='site level days elapsed since drought leaf drop', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_dleafoff_si, & - set_nonfates=ignore_flag) + ivar=ivar, initialize=initialize_variables, index = ih_dleafoff_si) call this%set_history_var(vname='SITE_DAYSINCE_DROUGHTLEAFON', units='days', & long='site level days elapsed since drought leaf flush', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_dleafon_si, & - set_nonfates=ignore_flag) + ivar=ivar, initialize=initialize_variables, index = ih_dleafon_si) call this%set_history_var(vname='SITE_MEANLIQVOL_DROUGHTPHEN', units='m3/m3', & long='site level mean liquid water volume for drought phen', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=clm_spval, upfreq=1, & - ivar=ivar, initialize=initialize_variables, index = ih_meanliqvol_si, & - set_nonfates=ignore_flag) + ivar=ivar, initialize=initialize_variables, index = ih_meanliqvol_si) call this%set_history_var(vname='CANOPY_SPREAD', units='0-1', & long='Scaling factor between tree basal area and canopy area', & diff --git a/main/FatesHistoryVariableType.F90 b/main/FatesHistoryVariableType.F90 index 1f8d13b1e2..f61d030298 100644 --- a/main/FatesHistoryVariableType.F90 +++ b/main/FatesHistoryVariableType.F90 @@ -22,15 +22,7 @@ module FatesHistoryVariableType ! 1 = dynamics "dyn" (daily) ! 2 = production "prod" (prob model tstep) real(r8) :: flushval - integer :: set_nonfates ! This is a flag that tells the host - ! what to do with the non-fates - ! entities that may be in parallel with - ! fates sites (for intance lakes) - ! its up to the interface to interpret the flag - ! but 0 should map to 0.0 - ! and 1 should map to an ignore flag if possible - - integer :: dim_kinds_index + ! Pointers (only one of these is allocated per variable) real(r8), pointer :: r81d(:) real(r8), pointer :: r82d(:,:) @@ -47,7 +39,7 @@ module FatesHistoryVariableType contains subroutine Init(this, vname, units, long, use_default, & - vtype, avgflag, flushval, set_nonfates, upfreq, num_dim_kinds, dim_kinds, dim_bounds) + vtype, avgflag, flushval, upfreq, num_dim_kinds, dim_kinds, dim_bounds) use FatesIODimensionsMod, only : fates_io_dimension_type @@ -69,7 +61,6 @@ subroutine Init(this, vname, units, long, use_default, & character(len=*), intent(in) :: use_default character(len=*), intent(in) :: vtype character(len=*), intent(in) :: avgflag - integer, intent(in) :: set_nonfates real(r8), intent(in) :: flushval ! If the type is an int we will round with nint integer, intent(in) :: upfreq integer, intent(in) :: num_dim_kinds @@ -85,7 +76,6 @@ subroutine Init(this, vname, units, long, use_default, & this%use_default = use_default this%vtype = vtype this%avgflag = avgflag - this%set_nonfates = set_nonfates this%flushval = flushval this%upfreq = upfreq From f96eb775f27690da34a6866449add57d2029bdce Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Sat, 26 Jan 2019 17:46:37 -0700 Subject: [PATCH 13/27] Fixed type that removed dim_kinds_index --- main/FatesHistoryVariableType.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/FatesHistoryVariableType.F90 b/main/FatesHistoryVariableType.F90 index f61d030298..8bdc5b2442 100644 --- a/main/FatesHistoryVariableType.F90 +++ b/main/FatesHistoryVariableType.F90 @@ -21,8 +21,8 @@ module FatesHistoryVariableType integer :: upfreq ! Update frequency (this is for checks and flushing) ! 1 = dynamics "dyn" (daily) ! 2 = production "prod" (prob model tstep) - real(r8) :: flushval - + real(r8) :: flushval + integer :: dim_kinds_index ! Pointers (only one of these is allocated per variable) real(r8), pointer :: r81d(:) real(r8), pointer :: r82d(:,:) From 1f841dbabc5d107537b0e24922f68332e702b8ba Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 29 Jan 2019 18:06:10 -0800 Subject: [PATCH 14/27] Removed status condition to dayssinced counters in drought phenology --- biogeochem/EDPhysiologyMod.F90 | 52 ++++++++++++++++++---------------- main/EDTypesMod.F90 | 4 +++ 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index be6729b993..50bfa2be92 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -594,16 +594,16 @@ subroutine phenology( currentSite, bc_in ) mean_10day_liqvol = sum(currentSite%water_memory(1:numWaterMem))/real(numWaterMem,r8) ! In drought phenology, we often need to force the leaves to stay on or off as moisture fluctuates... - dayssincedleafoff = 0 - if (currentSite%dstatus == 1)then - dayssincedleafoff = model_day_int - currentSite%dleafoffdate - endif + ! dayssincedleafoff = 0 + !if (currentSite%dstatus == 1 .or. currentSite%dstatus == 0)then + dayssincedleafoff = model_day_int - currentSite%dleafoffdate + !endif - dayssincedleafon = 0 + !dayssincedleafon = 0 !the leaves are on. How long have they been on? - if (currentSite%dstatus == 2)then - dayssincedleafon = model_day_int - currentSite%dleafondate - endif + !if (currentSite%dstatus == 2 .or. currentSite%dstatus == 3)then + dayssincedleafon = model_day_int - currentSite%dleafondate + !endif ! LEAF ON: DROUGHT DECIDUOUS WETNESS ! Here, we used a window of oppurtunity to determine if we are @@ -615,9 +615,9 @@ subroutine phenology( currentSite, bc_in ) ! c) is the model day at least > 10 (let soil water spin-up) ! Note that cold-starts begin in the "leaf-on" ! status - if ( (currentSite%dstatus == 1) .and. & + if ( (currentSite%dstatus == 1 .or. currentSite%dstatus == 0) .and. & (model_day_int > numWaterMem) .and. & - (dayssincedleafon >= 365-30 .and. dayssincedleafon =< 365+30 ) .and. & + (dayssincedleafon >= 365-30 .and. dayssincedleafon <= 365+30 ) .and. & (dayssincedleafoff > ED_val_phen_doff_time) ) then ! If leaves are off, and have been off for at least a few days @@ -632,9 +632,9 @@ subroutine phenology( currentSite, bc_in ) ! If we still haven't done budburst by end of window ! force it! - if ( (currentSite%dstatus == 1) .and. & - (model_day_int >= currentSite%dleafondate+365+30) ) then - currentSite%dstatus = 2 ! force budburst! + if ( (currentSite%dstatus == 1 .or. currentSite%dstatus == 0) .and. & + (dayssincedleafon > 365+30) ) then + currentSite%dstatus = 3 ! force budburst! currentSite%dleafondate = model_day_int ! record leaf on date endif @@ -648,16 +648,16 @@ subroutine phenology( currentSite, bc_in ) ! MEDIATED LEAF DROP SHOULD BE UNFAIRLY COMPETITIVE RIGHT? ! PERHAPS THIS CAN BE ADDRESSED BY LEAF-AGE BINS... - if ( (currentSite%dstatus == 2) .and. & + if ( (currentSite%dstatus == 2 .or. currentSite%dstatus == 3 ) .and. & (dayssincedleafon > canopy_leaf_lifespan) )then - currentSite%dstatus = 1 !alter status of site to 'leaves off' + currentSite%dstatus = 0 !alter status of site to 'leaves off' currentSite%dleafoffdate = model_day_int !record leaf on date endif ! LEAF OFF: DROUGHT DECIDUOUS DRYNESS - if the soil gets too dry, ! and the leaves have already been on a while... - if ( (currentSite%dstatus == 2) .and. & + if ( (currentSite%dstatus == 2 .or. currentSite%dstatus == 3 ) .and. & (model_day_int > numWaterMem) .and. & (mean_10day_liqvol <= ED_val_phen_drought_threshold) .and. & (dayssincedleafon > 100 ) ) then @@ -756,7 +756,7 @@ subroutine phenology_leafonoff(currentSite) !DROUGHT LEAF ON if (EDPftvarcon_inst%stress_decid(ipft) == 1)then - if (currentSite%dstatus == 2)then + if (currentSite%dstatus == 2 .or. currentSite%dstatus == 3 )then ! we have just moved to leaves being on . if (currentCohort%status_coh == 1)then @@ -784,7 +784,7 @@ subroutine phenology_leafonoff(currentSite) endif !currentSite status !DROUGHT LEAF OFF - if (currentSite%dstatus == 1)then + if (currentSite%dstatus == 1 .or. currentSite%dstatus == 0)then if (currentCohort%status_coh == 2)then ! leaves have not dropped ! This sets the cohort to the "leaves off" flag @@ -970,11 +970,13 @@ subroutine seed_germination( currentSite, currentPatch ) currentPatch%seed_germination(p) = min(currentSite%seed_bank(p) * & EDPftvarcon_inst%germination_timescale(p),max_germination) !set the germination only under the growing season...c.xu - if (EDPftvarcon_inst%season_decid(p) == 1.and.currentSite%status == 1)then - currentPatch%seed_germination(p) = 0.0_r8 + if ( (EDPftvarcon_inst%season_decid(p) == 1) .and. & + (currentSite%status <= 1)) then + currentPatch%seed_germination(p) = 0.0_r8 endif - if (EDPftvarcon_inst%stress_decid(p) == 1.and.currentSite%dstatus == 1)then - currentPatch%seed_germination(p) = 0.0_r8 + if ( (EDPftvarcon_inst%stress_decid(p) == 1) .and. & + (currentSite%dstatus <= 1)) then + currentPatch%seed_germination(p) = 0.0_r8 endif enddo @@ -1032,11 +1034,13 @@ subroutine recruitment( currentSite, currentPatch, bc_in ) call bstore_allom(temp_cohort%dbh,ft,temp_cohort%canopy_trim,b_store) temp_cohort%laimemory = 0.0_r8 - if (EDPftvarcon_inst%season_decid(temp_cohort%pft) == 1.and.currentSite%status == 1)then + if ( (EDPftvarcon_inst%season_decid(temp_cohort%pft) == 1) .and. & + (currentSite%status <= 1)) then temp_cohort%laimemory = b_leaf b_leaf = 0.0_r8 endif - if (EDPftvarcon_inst%stress_decid(temp_cohort%pft) == 1.and.currentSite%dstatus == 1)then + if ( (EDPftvarcon_inst%stress_decid(temp_cohort%pft) == 1) .and. & + (currentSite%dstatus <= 1)) then temp_cohort%laimemory = b_leaf b_leaf = 0.0_r8 endif diff --git a/main/EDTypesMod.F90 b/main/EDTypesMod.F90 index 08df70aea7..4c35718543 100644 --- a/main/EDTypesMod.F90 +++ b/main/EDTypesMod.F90 @@ -584,6 +584,10 @@ module EDTypesMod ! 1 = this site is in a cold-state where leaves should have fallen ! 2 = this site is in a warm-state where leaves are allowed to flush integer :: dstatus ! are leaves in this pixel on or off for drought decid + ! 0 = leaves off due to time exceedance + ! 1 = leaves off due to moisture avail + ! 2 = leaves on due to moisture avail + ! 3 = leaves on due to time exceedance integer :: ncd ! no chilling days:- real(r8) :: vegtemp_memory(num_vegtemp_mem) ! record of last 10 days temperature for senescence model. deg C integer :: cleafondate ! model date (day integer) of leaf on (cold):- From 1842b2de5ed1dcec975d4ab57c403957ce8fc1d5 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 30 Jan 2019 13:03:43 -0800 Subject: [PATCH 15/27] allowances for first year drought phenology timing --- biogeochem/EDPhysiologyMod.F90 | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 50bfa2be92..27f0d441fc 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -596,14 +596,25 @@ subroutine phenology( currentSite, bc_in ) ! In drought phenology, we often need to force the leaves to stay on or off as moisture fluctuates... ! dayssincedleafoff = 0 !if (currentSite%dstatus == 1 .or. currentSite%dstatus == 0)then - dayssincedleafoff = model_day_int - currentSite%dleafoffdate - !endif + + ! Calculate days since leaves have come off, but make a provision + ! for the first year of simulation, we have to assume a leaf drop + ! date to start, so if that is in the future, set it to last year + + if (model_day_int < currentSite%dleafoffdate) then + dayssincedleafoff = model_day_in - (currentSite%dleafoffdate-365) + else + dayssincedleafoff = model_day_int - currentSite%dleafoffdate + endif !dayssincedleafon = 0 !the leaves are on. How long have they been on? !if (currentSite%dstatus == 2 .or. currentSite%dstatus == 3)then - dayssincedleafon = model_day_int - currentSite%dleafondate - !endif + if (model_day_int < currentSite%dleafondate) then + dayssincedleafon = model_day_int - (currentSite%dleafondate-365) + else + dayssincedleafon = model_day_int - currentSite%dleafondate + endif ! LEAF ON: DROUGHT DECIDUOUS WETNESS ! Here, we used a window of oppurtunity to determine if we are From c65a6f6c6b2a4da763eb032af720144154f40b02 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 30 Jan 2019 13:04:34 -0800 Subject: [PATCH 16/27] typo in leaf drop date --- biogeochem/EDPhysiologyMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 27f0d441fc..3c3ccefacf 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -602,7 +602,7 @@ subroutine phenology( currentSite, bc_in ) ! date to start, so if that is in the future, set it to last year if (model_day_int < currentSite%dleafoffdate) then - dayssincedleafoff = model_day_in - (currentSite%dleafoffdate-365) + dayssincedleafoff = model_day_int - (currentSite%dleafoffdate-365) else dayssincedleafoff = model_day_int - currentSite%dleafoffdate endif From fe00e5b8ef50f1882b6dbc3dbecb07dd3f875a7e Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 31 Jan 2019 13:50:26 -0800 Subject: [PATCH 17/27] Add a reset of days since leaf on when leaves flush, so that leaf-off does not trip immediately after --- biogeochem/EDPhysiologyMod.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 3c3ccefacf..45866e5e16 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -638,6 +638,7 @@ subroutine phenology( currentSite, bc_in ) if ( mean_10day_liqvol >= ED_val_phen_drought_threshold ) then currentSite%dstatus = 2 ! set status to leaf-on currentSite%dleafondate = model_day_int ! save the model day we start flushing + dayssincedleafon = 0 endif endif @@ -647,6 +648,7 @@ subroutine phenology( currentSite, bc_in ) (dayssincedleafon > 365+30) ) then currentSite%dstatus = 3 ! force budburst! currentSite%dleafondate = model_day_int ! record leaf on date + dayssincedleafon = 0 endif ! LEAF OFF: DROUGHT DECIDUOUS LIFESPAN - if the leaf gets to From 6d48d68706f5f26b93631275664c04a567b9eb3d Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Mon, 11 Feb 2019 11:55:27 -0800 Subject: [PATCH 18/27] Small fixes to resolution between the phenology fixes and leaf age changes --- biogeochem/EDPhysiologyMod.F90 | 2 +- main/EDInitMod.F90 | 4 ++-- main/FatesHistoryInterfaceMod.F90 | 4 +--- main/FatesInventoryInitMod.F90 | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index ec0ecd550e..343a2da200 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -998,7 +998,7 @@ subroutine seed_germination( currentSite, currentPatch ) EDPftvarcon_inst%germination_timescale(p),max_germination) !set the germination only under the growing season...c.xu if ( (EDPftvarcon_inst%season_decid(p) == 1) .and. & - (currentSite%status <= 1)) then + (currentSite%cstatus <= 1)) then currentPatch%seed_germination(p) = 0.0_r8 endif if ( (EDPftvarcon_inst%stress_decid(p) == 1) .and. & diff --git a/main/EDInitMod.F90 b/main/EDInitMod.F90 index f3e1392031..6b81ce2411 100644 --- a/main/EDInitMod.F90 +++ b/main/EDInitMod.F90 @@ -433,13 +433,13 @@ subroutine init_cohorts( site_in, patch_in, bc_in) temp_cohort%laimemory = 0._r8 cstatus = leaves_on - if( EDPftvarcon_inst%season_decid(pft) == itrue .and. site_in%is_cold ) then + if( EDPftvarcon_inst%season_decid(pft) == itrue .and. site_in%cstatus < 2 ) then temp_cohort%laimemory = b_leaf b_leaf = 0._r8 cstatus = leaves_off endif - if ( EDPftvarcon_inst%stress_decid(pft) == itrue .and. site_in%is_drought ) then + if ( EDPftvarcon_inst%stress_decid(pft) == itrue .and. site_in%dstatus < 2 ) then temp_cohort%laimemory = b_leaf b_leaf = 0._r8 cstatus = leaves_off diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index 623d387b19..4e68bb5d2f 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -126,8 +126,6 @@ module FatesHistoryInterfaceMod integer, private :: ih_c_stomata_si integer, private :: ih_c_lblayer_si integer, private :: ih_fire_c_to_atm_si - integer, private :: ih_ed_to_bgc_this_edts_si - integer, private :: ih_ed_to_bgc_last_edts_si integer, private :: ih_totecosysc_si integer, private :: ih_totecosysc_old_si integer, private :: ih_totedc_si @@ -1591,7 +1589,7 @@ subroutine update_history_dyn(this,nc,nsites,sites) hio_canopy_spread_si(io_si) = sites(s)%spread ! Update the site statuses (stati?) - hio_site_cstatus_si(io_si) = real(sites(s)%status,r8) + hio_site_cstatus_si(io_si) = real(sites(s)%cstatus,r8) hio_site_dstatus_si(io_si) = real(sites(s)%dstatus,r8) !count number of days for leaves off diff --git a/main/FatesInventoryInitMod.F90 b/main/FatesInventoryInitMod.F90 index 338ac8618d..38c6083d2c 100644 --- a/main/FatesInventoryInitMod.F90 +++ b/main/FatesInventoryInitMod.F90 @@ -915,13 +915,13 @@ subroutine set_inventory_edcohort_type1(csite,bc_in,css_file_unit,npatches, & temp_cohort%laimemory = 0._r8 cstatus = leaves_on - if( EDPftvarcon_inst%season_decid(c_pft) == itrue .and. csite%is_cold ) then + if( EDPftvarcon_inst%season_decid(c_pft) == itrue .and. csite%cstatus < 2 ) then temp_cohort%laimemory = b_leaf b_leaf = 0._r8 cstatus = leaves_off endif - if ( EDPftvarcon_inst%stress_decid(c_pft) == itrue .and. csite%is_drought ) then + if ( EDPftvarcon_inst%stress_decid(c_pft) == itrue .and. csite%dstatus < 2) then temp_cohort%laimemory = b_leaf b_leaf = 0._r8 cstatus = leaves_off From b7212e3287fb0447b4bb47c5cfb35049d16959f5 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Mon, 11 Feb 2019 12:02:59 -0800 Subject: [PATCH 19/27] Fixing a call for drought stress as logical instead of integer flag --- main/EDMainMod.F90 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/EDMainMod.F90 b/main/EDMainMod.F90 index cc366cc0fe..fc40732db8 100644 --- a/main/EDMainMod.F90 +++ b/main/EDMainMod.F90 @@ -265,6 +265,7 @@ subroutine ed_integrate_state_variables(currentSite, bc_in ) real(r8) :: cohort_biomass_store ! remembers the biomass in the cohort for balance checking real(r8) :: dbh_old ! dbh of plant before daily PRT [cm] real(r8) :: hite_old ! height of plant before daily PRT [m] + logical :: is_drought ! logical for if the plant (site) is in a drought state !----------------------------------------------------------------------- @@ -338,9 +339,14 @@ subroutine ed_integrate_state_variables(currentSite, bc_in ) currentSite%flux_in = currentSite%flux_in + currentCohort%npp_acc * currentCohort%n - ! Conducte Maintenance Turnover (parteh) + ! Conduct Maintenance Turnover (parteh) call currentCohort%prt%CheckMassConservation(ft,3) - call PRTMaintTurnover(currentCohort%prt,ft,currentSite%is_drought) + if(currentSite%dstatus>1) then + is_drought = .false. + else + is_drought = .true. + end if + call PRTMaintTurnover(currentCohort%prt,ft,is_drought) call currentCohort%prt%CheckMassConservation(ft,4) ! Conduct Growth (parteh) From 61ea41237b0c64bbc5ff2e9e54675917dfb63177 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 13 Feb 2019 10:40:41 -0800 Subject: [PATCH 20/27] Add logic to cold phenology in first year started with normal timing. --- biogeochem/EDPhysiologyMod.F90 | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 343a2da200..b3bc99fe83 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -497,10 +497,23 @@ subroutine phenology( currentSite, bc_in ) currentSite%grow_deg_days = currentSite%grow_deg_days + bc_in%t_veg24_si - tfrz endif - ! HLM model day is the total number of days since simulation start - ! The leafoffdate and leafondates are all recorded in this unit + ! Calculate the number of days since the leaves last came on + ! and off. If this is the beginning of the simulation, that day might + ! not had occured yet, so set it to last year to get things rolling + + if (model_day_int < currentSite%cleafoffdate) then + dayssincecleafoff = model_day_int - (currentSite%cleafoffdate - 365) + else + dayssincecleafoff = model_day_int - currentSite%cleafoffdate + end if + + if (model_day_int < currentSite%cleafondate) then + dayssincecleafon = model_day_int - (currentSite%cleafondate-365) + else + dayssincecleafon = model_day_int - currentSite%cleafondate + end if + - dayssincecleafoff = model_day_int - currentSite%cleafoffdate !LEAF ON: COLD DECIDUOUS. Needs to !1) have exceeded the growing degree day threshold @@ -519,7 +532,7 @@ subroutine phenology( currentSite, bc_in ) if ( debug ) write(fates_log(),*) 'leaves on' endif !GDD - dayssincecleafon = model_day_int - currentSite%cleafondate + !LEAF OFF: COLD THRESHOLD From 3b14955ffb4c9774c8442a90a1c3ea0f29b5e901 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 14 Feb 2019 16:42:36 -0800 Subject: [PATCH 21/27] Changed drought phenology soil layer to match desired depth. Added a growing degrees zeroer --- biogeochem/EDPhysiologyMod.F90 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index b3bc99fe83..7ab62ad1e7 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -424,6 +424,7 @@ subroutine phenology( currentSite, bc_in ) real(r8) :: store_c ! storage carbon [kg] real(r8) :: struct_c ! structure carbon [kg] real(r8) :: gdd_threshold ! GDD accumulation function, + integer :: ilayer_swater ! Layer index for soil water ! which also depends on chilling days. integer :: ncdstart ! beginning of counting period for chilling degree days. integer :: gddstart ! beginning of counting period for growing degree days. @@ -433,11 +434,18 @@ subroutine phenology( currentSite, bc_in ) ! FIX(RGK 07/10/17) ! This is a band-aid on unusual code + real(r8),parameter :: dphen_soil_depth = 0.1 ! Use liquid soil water that is + ! closest to this depth [m] ! This is the integer model day. The first day of the simulation is 1, and it ! continues monotonically, indefinitely model_day_int = nint(hlm_model_day) + + ! Use the following layer index to calculate drought conditions + ilayer_swater = minloc(abs(bc_in%z_sisl(:)-dphen_soil_depth),dim=1) + + ! Parameter of drought decid leaf loss in mm in top layer...FIX(RF,032414) ! - this is arbitrary and poorly understood. Needs work. ED_ !Parameters: defaults from Botta et al. 2000 GCB,6 709-725 @@ -568,6 +576,7 @@ subroutine phenology( currentSite, bc_in ) if( (currentSite%cstatus == 2) .and. & (dayssincecleafoff > 400)) then ! remove leaves after a whole year ! when there is no 'off' period. + currentSite%grow_deg_days = 0._r8 currentSite%cstatus = 0 ! alter status of site to "not-cold deciduous" currentSite%cleafoffdate = model_day_int ! record leaf off date @@ -609,7 +618,7 @@ subroutine phenology( currentSite, bc_in ) do i_wmem = 1,numWaterMem-1 !shift memory along one currentSite%water_memory(numWaterMem+1-i_wmem) = currentSite%water_memory(numWaterMem-i_wmem) enddo - currentSite%water_memory(1) = bc_in%h2o_liqvol_sl(1) + currentSite%water_memory(1) = bc_in%h2o_liqvol_sl(ilayer_swater) ! Calculate the mean water content over the last 10 days (m3/m3) mean_10day_liqvol = sum(currentSite%water_memory(1:numWaterMem))/real(numWaterMem,r8) From 4678e923042526518f1659135a9119ecfa6a2f7e Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 15 Feb 2019 14:55:19 -0800 Subject: [PATCH 22/27] Fixed bug that was saving the doy to the phenology leaf-off date instead of the model day. Added protections that prevent leaf-flushing on drought decid trees from occuring within x (default=70) days from a forced leaf drop --- biogeochem/EDPhysiologyMod.F90 | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 7ab62ad1e7..afb1b19fdc 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -430,12 +430,18 @@ subroutine phenology( currentSite, bc_in ) integer :: gddstart ! beginning of counting period for growing degree days. real(r8) :: temp_in_C ! daily averaged temperature in celcius - real(r8), parameter :: canopy_leaf_lifespan = 365.0_r8 ! Mean lifespan canopy leaves - ! FIX(RGK 07/10/17) - ! This is a band-aid on unusual code - - real(r8),parameter :: dphen_soil_depth = 0.1 ! Use liquid soil water that is - ! closest to this depth [m] + integer, parameter :: canopy_leaf_lifespan = 365 ! Maximum lifespan of drought decid leaves + + integer, parameter :: min_daysoff_dforcedflush = 70 ! THis is the number of days that must had elapsed + ! since leaves had dropped, in order to forcably + ! flush leaves again. This does not impact flushing + ! due to real moisture constraints, and will prevent + ! drought deciduous in perennially wet environments + ! that have been forced to drop their leaves, from + ! flushing them back immediately. + + real(r8),parameter :: dphen_soil_depth = 0.1 ! Use liquid soil water that is + ! closest to this depth [m] ! This is the integer model day. The first day of the simulation is 1, and it ! continues monotonically, indefinitely @@ -670,10 +676,13 @@ subroutine phenology( currentSite, bc_in ) endif endif + ! If we still haven't done budburst by end of window ! force it! + if ( (currentSite%dstatus == 1 .or. currentSite%dstatus == 0) .and. & - (dayssincedleafon > 365+30) ) then + (dayssincedleafon > 365+30) .and. & + (dayssincedleafoff > min_daysoff_dforcedflush ) then currentSite%dstatus = 3 ! force budburst! currentSite%dleafondate = model_day_int ! record leaf on date dayssincedleafon = 0 @@ -683,12 +692,6 @@ subroutine phenology( currentSite, bc_in ) ! the end of its useful life. A*, E* ! i.e. Are the leaves rouhgly at the end of their lives? - ! (RGK-PHEN) SHOULD THIS BE REMOVED OR MODIFIED? - ! I FEEL LIKE THERE SHOULD BE SOME OTHER MECHANISM IN PLACE HERE - ! DROUGHT DECIDUOUS TREES THAT NEVER EXPERIENCE DROUGHT - ! MEDIATED LEAF DROP SHOULD BE UNFAIRLY COMPETITIVE RIGHT? - ! PERHAPS THIS CAN BE ADDRESSED BY LEAF-AGE BINS... - if ( (currentSite%dstatus == 2 .or. currentSite%dstatus == 3 ) .and. & (dayssincedleafon > canopy_leaf_lifespan) )then currentSite%dstatus = 0 !alter status of site to 'leaves off' @@ -702,8 +705,8 @@ subroutine phenology( currentSite, bc_in ) (model_day_int > numWaterMem) .and. & (mean_10day_liqvol <= ED_val_phen_drought_threshold) .and. & (dayssincedleafon > 100 ) ) then - currentSite%dstatus = 1 !alter status of site to 'leaves off' - currentSite%dleafoffdate = hlm_day_of_year !record leaf on date + currentSite%dstatus = 1 ! alter status of site to 'leaves off' + currentSite%dleafoffdate = model_day_int ! record leaf on date endif call phenology_leafonoff(currentSite) From 4d0821b18a7e000ecf1532f044b581fefe2d6190 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 15 Feb 2019 15:19:31 -0800 Subject: [PATCH 23/27] Tweaking phenology logic --- biogeochem/EDPhysiologyMod.F90 | 35 ++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index afb1b19fdc..c08463a532 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -676,17 +676,32 @@ subroutine phenology( currentSite, bc_in ) endif endif - - ! If we still haven't done budburst by end of window - ! force it! + ! LEAF ON: DROUGHT DECIDUOUS TIME EXCEEDANCE + ! If we still haven't done budburst by end of window, then force it + + ! If the status is 1, it means this site currently has + ! leaves off due to actual moisture limitations. + ! So we trigger bud-burst at the end of the month since + ! last year's bud-burst. + + if( currentSite%dstatus == 1 ) then + if ( dayssincedleafon > 365+30 ) then + currentSite%dstatus = 3 ! force budburst! + currentSite%dleafondate = model_day_int ! record leaf on date + dayssincedleafon = 0 + end if + end if - if ( (currentSite%dstatus == 1 .or. currentSite%dstatus == 0) .and. & - (dayssincedleafon > 365+30) .and. & - (dayssincedleafoff > min_daysoff_dforcedflush ) then - currentSite%dstatus = 3 ! force budburst! - currentSite%dleafondate = model_day_int ! record leaf on date - dayssincedleafon = 0 - endif + ! But if leaves are off due to time, then we enforce + ! a longer cool-down (because this is a perrenially wet system) + + if(currentSite%dstatus == 0 ) then + if (dayssincedleafoff > min_daysoff_dforcedflush) then + currentSite%dstatus = 3 ! force budburst! + currentSite%dleafondate = model_day_int ! record leaf on date + dayssincedleafon = 0 + end if + end if ! LEAF OFF: DROUGHT DECIDUOUS LIFESPAN - if the leaf gets to ! the end of its useful life. A*, E* From 9f034f2a161551e1ebda4e7d27e72fb215ac2cec Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 21 Feb 2019 14:56:29 -0800 Subject: [PATCH 24/27] Reverted the waiting time to trigger a forced flush for time-imposed leaf drop on drought deciduous to 1 month --- biogeochem/EDPhysiologyMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index c08463a532..fadaba2b2e 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -432,7 +432,7 @@ subroutine phenology( currentSite, bc_in ) integer, parameter :: canopy_leaf_lifespan = 365 ! Maximum lifespan of drought decid leaves - integer, parameter :: min_daysoff_dforcedflush = 70 ! THis is the number of days that must had elapsed + integer, parameter :: min_daysoff_dforcedflush = 30 ! THis is the number of days that must had elapsed ! since leaves had dropped, in order to forcably ! flush leaves again. This does not impact flushing ! due to real moisture constraints, and will prevent From b96f529dc7a168c179e98fc15e0fb7868e69b9dd Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 15 Apr 2019 16:34:37 -0700 Subject: [PATCH 25/27] Updates to PR #468 (phenology status timers) Fixed a few typos and some artifacts where `itrue` was changed to 1. Refactored the `cstatus` and `dstatus` checks to use any for a few cases. There might be more we can change. Fixes: PR #468 User interface changes?: No Code review: Ryan Knox Testing: none, not expected to compile --- biogeochem/EDPhysiologyMod.F90 | 27 ++++++++++++++------------- main/EDInitMod.F90 | 8 ++++---- main/EDTypesMod.F90 | 2 +- main/FatesHistoryInterfaceMod.F90 | 1 - 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index a0f605d69e..8fdd78dd90 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -106,6 +106,7 @@ module EDPhysiologyMod integer, parameter :: i_cdead = 6 ! Array index associated with structural carbon integer, parameter :: i_crepro = 7 ! Array index associated with reproductive carbon integer, parameter :: n_cplantpools = 7 ! Size of the carbon only integration framework + integer, parameter :: dleafon_drycheck = 100 ! Drought deciduous leaves max days on check parameter ! ============================================================================ @@ -566,7 +567,7 @@ subroutine phenology( currentSite, bc_in ) ! first flush, but if we dont ! clear this value, it will cause ! leaves to flush later in the year - currentSite%cstatus = 1 ! alter status of site to 'leaves on' + currentSite%cstatus = 1 ! alter status of site to 'leaves off' currentSite%cleafoffdate = model_day_int ! record leaf off date if ( debug ) write(fates_log(),*) 'leaves off' @@ -718,7 +719,7 @@ subroutine phenology( currentSite, bc_in ) if ( (currentSite%dstatus == 2 .or. currentSite%dstatus == 3 ) .and. & (model_day_int > numWaterMem) .and. & (mean_10day_liqvol <= ED_val_phen_drought_threshold) .and. & - (dayssincedleafon > 100 ) ) then + (dayssincedleafon > dleafon_drycheck ) ) then currentSite%dstatus = 1 ! alter status of site to 'leaves off' currentSite%dleafoffdate = model_day_int ! record leaf on date endif @@ -770,7 +771,7 @@ subroutine phenology_leafonoff(currentSite) ! for leaves. Time to signal flushing if (EDPftvarcon_inst%season_decid(ipft) == 1)then - if ( currentSite%cstatus > 1 )then ! we have just moved to leaves being on . + if ( currentSite%cstatus == 2 )then ! we have just moved to leaves being on . if (currentCohort%status_coh == leaves_off)then ! Are the leaves currently off? currentCohort%status_coh = leaves_on ! Leaves are on, so change status to ! stop flow of carbon out of bstore. @@ -793,7 +794,7 @@ subroutine phenology_leafonoff(currentSite) !COLD LEAF OFF if (currentSite%cstatus == 1 .or. currentSite%cstatus == 0)then !past leaf drop day? Leaves still on tree? - if (currentCohort%status_coh == 2)then ! leaves have not dropped + if (currentCohort%status_coh == leaves_on)then ! leaves have not dropped ! This sets the cohort to the "leaves off" flag @@ -851,7 +852,7 @@ subroutine phenology_leafonoff(currentSite) !DROUGHT LEAF OFF if (currentSite%dstatus == 1 .or. currentSite%dstatus == 0)then - if (currentCohort%status_coh == 2)then ! leaves have not dropped + if (currentCohort%status_coh == leaves_on)then ! leaves have not dropped ! This sets the cohort to the "leaves off" flag currentCohort%status_coh = leaves_off @@ -1030,12 +1031,12 @@ subroutine seed_germination( currentSite, currentPatch ) currentPatch%seed_germination(p) = min(currentSite%seed_bank(p) * & EDPftvarcon_inst%germination_timescale(p),max_germination) !set the germination only under the growing season...c.xu - if ( (EDPftvarcon_inst%season_decid(p) == 1) .and. & - (currentSite%cstatus <= 1)) then + if ( (EDPftvarcon_inst%season_decid(p) == itrue) .and. & + (any(currentSite%cstatus == [0,1]))) then currentPatch%seed_germination(p) = 0.0_r8 endif - if ( (EDPftvarcon_inst%stress_decid(p) == 1) .and. & - (currentSite%dstatus <= 1)) then + if ( (EDPftvarcon_inst%stress_decid(p) == itrue) .and. & + (any(currentSite%dstatus == [0,1]))) then currentPatch%seed_germination(p) = 0.0_r8 endif enddo @@ -1095,15 +1096,15 @@ subroutine recruitment( currentSite, currentPatch, bc_in ) cohortstatus = leaves_on temp_cohort%laimemory = 0.0_r8 - if ( (EDPftvarcon_inst%season_decid(temp_cohort%pft) == 1) .and. & - (currentSite%cstatus <= 1)) then + if ( (EDPftvarcon_inst%season_decid(temp_cohort%pft) == itrue) .and. & + (any(currentSite%cstatus == [0,1]))) then temp_cohort%laimemory = b_leaf b_leaf = 0.0_r8 cohortstatus = leaves_off endif - if ( (EDPftvarcon_inst%stress_decid(temp_cohort%pft) == 1) .and. & - (currentSite%dstatus <= 1)) then + if ( (EDPftvarcon_inst%stress_decid(temp_cohort%pft) == itrue) .and. & + (any(currentSite%dstatus == [0,1]))) then temp_cohort%laimemory = b_leaf b_leaf = 0.0_r8 cohortstatus = leaves_off diff --git a/main/EDInitMod.F90 b/main/EDInitMod.F90 index f8c47e9c3f..2784267f52 100644 --- a/main/EDInitMod.F90 +++ b/main/EDInitMod.F90 @@ -193,8 +193,8 @@ subroutine set_site_properties( nsites, sites) integer :: dstat ! drought status phenology flag real(r8) :: acc_NI real(r8) :: watermem - real(r8) :: cleafon ! DOY for cold-decid leaf-on, initial guess - real(r8) :: cleafoff ! DOY for cold-decid leaf-off, initial guess + integer :: cleafon ! DOY for cold-decid leaf-on, initial guess + integer :: cleafoff ! DOY for cold-decid leaf-off, initial guess integer :: dleafoff ! DOY for drought-decid leaf-off, initial guess integer :: dleafon ! DOY for drought-decid leaf-on, initial guess !---------------------------------------------------------------------- @@ -208,8 +208,8 @@ subroutine set_site_properties( nsites, sites) if ( hlm_is_restart == ifalse ) then GDD = 30.0_r8 - cleafon = 100.0_r8 - cleafoff = 300.0_r8 + cleafon = 100 + cleafoff = 300 cstat = 2 ! Leaves are on acc_NI = 0.0_r8 dstat = 2 ! Leaves are on diff --git a/main/EDTypesMod.F90 b/main/EDTypesMod.F90 index fb59f1d7fc..31aa507c4f 100644 --- a/main/EDTypesMod.F90 +++ b/main/EDTypesMod.F90 @@ -630,7 +630,7 @@ module EDTypesMod integer :: cleafondate ! model date (day integer) of leaf on (cold):- integer :: cleafoffdate ! model date (day integer) of leaf off (cold):- integer :: dleafondate ! model date (day integer) of leaf on drought:- - integer :: dleafoffdate ! model date (day integer) of leaf on drought:- + integer :: dleafoffdate ! model date (day integer) of leaf off drought:- real(r8) :: water_memory(numWaterMem) ! last 10 days of soil moisture memory... diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index 9131a49853..634c3c3ebd 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -1165,7 +1165,6 @@ subroutine set_history_var(this, vname, units, long, use_default, avgflag, vtype ! locals integer :: ub1, lb1, ub2, lb2 ! Bounds for allocating the var integer :: ityp - integer :: nonfates ! non-optional logical :: write_var From 40334e5d8d74929f1f97df2a2bafa21795a7725e Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 30 Apr 2019 15:43:23 -0600 Subject: [PATCH 26/27] Syntax improvements to site level phenology flags. Added named constants to status flags. --- biogeochem/EDPhysiologyMod.F90 | 97 ++++++++++++++++++++-------------- main/EDInitMod.F90 | 18 +++++-- main/EDMainMod.F90 | 4 +- main/EDTypesMod.F90 | 14 +++++ main/FatesInventoryInitMod.F90 | 10 +++- 5 files changed, 95 insertions(+), 48 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 8fdd78dd90..6215765a7f 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -37,6 +37,13 @@ module EDPhysiologyMod use EDTypesMod , only : leaves_on use EDTypesMod , only : leaves_off use EDTypesMod , only : min_n_safemath + use EDTypesMod , only : phen_cstat_nevercold + use EDTypesMod , only : phen_cstat_iscold + use EDTypesMod , only : phen_cstat_notcold + use EDTypesMod , only : phen_dstat_timeoff + use EDTypesMod , only : phen_dstat_moistoff + use EDTypesMod , only : phen_dstat_moiston + use EDTypesMod , only : phen_dstat_timeon use shr_log_mod , only : errMsg => shr_log_errMsg use FatesGlobals , only : fates_log @@ -537,11 +544,11 @@ subroutine phenology( currentSite, bc_in ) ! from ever re-flushing after they have reached their maximum age (thus ! preventing them from competing - if ( (currentSite%cstatus == 1 .or. currentSite%cstatus == 0) .and. & + if ( (currentSite%cstatus == phen_cstat_iscold .or. & + currentSite%cstatus == phen_cstat_nevercold) .and. & (currentSite%grow_deg_days > gdd_threshold) .and. & - (currentSite%nchilldays >= 1) .and. & - (dayssincecleafoff > ED_val_phen_mindayson)) then - currentSite%cstatus = 2 !alter status of site to 'leaves on' + (currentSite%nchilldays >= 1)) then + currentSite%cstatus = phen_cstat_notcold ! Set to not-cold status (leaves can come on) currentSite%cleafondate = model_day_int if ( debug ) write(fates_log(),*) 'leaves on' endif !GDD @@ -557,7 +564,7 @@ subroutine phenology( currentSite, bc_in ) !4) The day of simulation should be larger than the counting period. - if ( (currentSite%cstatus == 2) .and. & + if ( (currentSite%cstatus == phen_cstat_notcold) .and. & (model_day_int > num_vegtemp_mem) .and. & (ncolddays > ED_val_phen_ncolddayslim) .and. & (dayssincecleafon > ED_val_phen_mindayson) )then @@ -567,8 +574,8 @@ subroutine phenology( currentSite, bc_in ) ! first flush, but if we dont ! clear this value, it will cause ! leaves to flush later in the year - currentSite%cstatus = 1 ! alter status of site to 'leaves off' - currentSite%cleafoffdate = model_day_int ! record leaf off date + currentSite%cstatus = phen_cstat_iscold ! alter status of site to 'leaves off' + currentSite%cleafoffdate = model_day_int ! record leaf off date if ( debug ) write(fates_log(),*) 'leaves off' endif @@ -579,13 +586,15 @@ subroutine phenology( currentSite, bc_in ) ! when coupled with this fact will essentially prevent cold-deciduous ! plants from re-emerging in areas without at least some cold days - if( (currentSite%cstatus == 2) .and. & + if( (currentSite%cstatus == phen_cstat_notcold) .and. & (dayssincecleafoff > 400)) then ! remove leaves after a whole year ! when there is no 'off' period. currentSite%grow_deg_days = 0._r8 - currentSite%cstatus = 0 ! alter status of site to "not-cold deciduous" - currentSite%cleafoffdate = model_day_int ! record leaf off date + currentSite%cstatus = phen_cstat_nevercold ! alter status of site to imply that this + ! site is never really cold enough + ! for cold deciduous + currentSite%cleafoffdate = model_day_int ! record leaf off date if ( debug ) write(fates_log(),*) 'leaves off' endif @@ -643,7 +652,6 @@ subroutine phenology( currentSite, bc_in ) endif ! the leaves are on. How long have they been on? - ! if (currentSite%dstatus == 2 .or. currentSite%dstatus == 3)then if (model_day_int < currentSite%dleafondate) then dayssincedleafon = model_day_int - (currentSite%dleafondate-365) else @@ -660,7 +668,8 @@ subroutine phenology( currentSite, bc_in ) ! c) is the model day at least > 10 (let soil water spin-up) ! Note that cold-starts begin in the "leaf-on" ! status - if ( (currentSite%dstatus == 1 .or. currentSite%dstatus == 0) .and. & + if ( (currentSite%dstatus == phen_dstat_timeoff .or. & + currentSite%dstatus == phen_dstat_moistoff) .and. & (model_day_int > numWaterMem) .and. & (dayssincedleafon >= 365-30 .and. dayssincedleafon <= 365+30 ) .and. & (dayssincedleafoff > ED_val_phen_doff_time) ) then @@ -670,8 +679,8 @@ subroutine phenology( currentSite, bc_in ) ! time window... test if the moisture conditions allow for leaf-on if ( mean_10day_liqvol >= ED_val_phen_drought_threshold ) then - currentSite%dstatus = 2 ! set status to leaf-on - currentSite%dleafondate = model_day_int ! save the model day we start flushing + currentSite%dstatus = phen_dstat_moiston ! set status to leaf-on + currentSite%dleafondate = model_day_int ! save the model day we start flushing dayssincedleafon = 0 endif endif @@ -679,15 +688,16 @@ subroutine phenology( currentSite, bc_in ) ! LEAF ON: DROUGHT DECIDUOUS TIME EXCEEDANCE ! If we still haven't done budburst by end of window, then force it - ! If the status is 1, it means this site currently has + ! If the status is "phen_dstat_moistoff", it means this site currently has ! leaves off due to actual moisture limitations. ! So we trigger bud-burst at the end of the month since - ! last year's bud-burst. + ! last year's bud-burst. If this is imposed, then we set the new + ! status to indicate bud-burst was forced by timing - if( currentSite%dstatus == 1 ) then + if( currentSite%dstatus == phen_dstat_moistoff ) then if ( dayssincedleafon > 365+30 ) then - currentSite%dstatus = 3 ! force budburst! - currentSite%dleafondate = model_day_int ! record leaf on date + currentSite%dstatus = phen_dstat_timeon ! force budburst! + currentSite%dleafondate = model_day_int ! record leaf on date dayssincedleafon = 0 end if end if @@ -695,10 +705,10 @@ subroutine phenology( currentSite, bc_in ) ! But if leaves are off due to time, then we enforce ! a longer cool-down (because this is a perrenially wet system) - if(currentSite%dstatus == 0 ) then + if(currentSite%dstatus == phen_dstat_timeoff ) then if (dayssincedleafoff > min_daysoff_dforcedflush) then - currentSite%dstatus = 3 ! force budburst! - currentSite%dleafondate = model_day_int ! record leaf on date + currentSite%dstatus = phen_dstat_timeon ! force budburst! + currentSite%dleafondate = model_day_int ! record leaf on date dayssincedleafon = 0 end if end if @@ -707,21 +717,23 @@ subroutine phenology( currentSite, bc_in ) ! the end of its useful life. A*, E* ! i.e. Are the leaves rouhgly at the end of their lives? - if ( (currentSite%dstatus == 2 .or. currentSite%dstatus == 3 ) .and. & + if ( (currentSite%dstatus == phen_dstat_moiston .or. & + currentSite%dstatus == phen_dstat_timeon ) .and. & (dayssincedleafon > canopy_leaf_lifespan) )then - currentSite%dstatus = 0 !alter status of site to 'leaves off' - currentSite%dleafoffdate = model_day_int !record leaf on date + currentSite%dstatus = phen_dstat_timeoff !alter status of site to 'leaves off' + currentSite%dleafoffdate = model_day_int !record leaf on date endif ! LEAF OFF: DROUGHT DECIDUOUS DRYNESS - if the soil gets too dry, ! and the leaves have already been on a while... - if ( (currentSite%dstatus == 2 .or. currentSite%dstatus == 3 ) .and. & + if ( (currentSite%dstatus == phen_dstat_moiston .or. & + currentSite%dstatus == phen_dstat_timeon ) .and. & (model_day_int > numWaterMem) .and. & (mean_10day_liqvol <= ED_val_phen_drought_threshold) .and. & (dayssincedleafon > dleafon_drycheck ) ) then - currentSite%dstatus = 1 ! alter status of site to 'leaves off' - currentSite%dleafoffdate = model_day_int ! record leaf on date + currentSite%dstatus = phen_dstat_moistoff ! alter status of site to 'leaves off' + currentSite%dleafoffdate = model_day_int ! record leaf on date endif call phenology_leafonoff(currentSite) @@ -770,8 +782,8 @@ subroutine phenology_leafonoff(currentSite) ! The site level flags signify that it is no-longer too cold ! for leaves. Time to signal flushing - if (EDPftvarcon_inst%season_decid(ipft) == 1)then - if ( currentSite%cstatus == 2 )then ! we have just moved to leaves being on . + if (EDPftvarcon_inst%season_decid(ipft) == itrue)then + if ( currentSite%cstatus == phen_cstat_notcold )then ! we have just moved to leaves being on . if (currentCohort%status_coh == leaves_off)then ! Are the leaves currently off? currentCohort%status_coh = leaves_on ! Leaves are on, so change status to ! stop flow of carbon out of bstore. @@ -793,8 +805,10 @@ subroutine phenology_leafonoff(currentSite) endif ! growing season !COLD LEAF OFF - if (currentSite%cstatus == 1 .or. currentSite%cstatus == 0)then !past leaf drop day? Leaves still on tree? - if (currentCohort%status_coh == leaves_on)then ! leaves have not dropped + if (currentSite%cstatus == phen_cstat_nevercold .or. & + currentSite%cstatus == phen_cstat_iscold) then ! past leaf drop day? Leaves still on tree? + + if (currentCohort%status_coh == leaves_on) then ! leaves have not dropped ! This sets the cohort to the "leaves off" flag @@ -821,9 +835,10 @@ subroutine phenology_leafonoff(currentSite) ! Site level flag indicates it is no longer in drought condition ! deciduous plants can flush - if (EDPftvarcon_inst%stress_decid(ipft) == 1)then + if (EDPftvarcon_inst%stress_decid(ipft) == itrue )then - if (currentSite%dstatus == 2 .or. currentSite%dstatus == 3 )then + if (currentSite%dstatus == phen_dstat_moiston .or. & + currentSite%dstatus == phen_dstat_timeon )then ! we have just moved to leaves being on . if (currentCohort%status_coh == leaves_off)then @@ -851,8 +866,10 @@ subroutine phenology_leafonoff(currentSite) endif !currentSite status !DROUGHT LEAF OFF - if (currentSite%dstatus == 1 .or. currentSite%dstatus == 0)then - if (currentCohort%status_coh == leaves_on)then ! leaves have not dropped + if (currentSite%dstatus == phen_dstat_moistoff .or. & + currentSite%dstatus == phen_dstat_timeoff) then + + if (currentCohort%status_coh == leaves_on) then ! leaves have not dropped ! This sets the cohort to the "leaves off" flag currentCohort%status_coh = leaves_off @@ -1032,11 +1049,11 @@ subroutine seed_germination( currentSite, currentPatch ) EDPftvarcon_inst%germination_timescale(p),max_germination) !set the germination only under the growing season...c.xu if ( (EDPftvarcon_inst%season_decid(p) == itrue) .and. & - (any(currentSite%cstatus == [0,1]))) then + (any(currentSite%cstatus == [phen_cstat_nevercold,phen_cstat_iscold]))) then currentPatch%seed_germination(p) = 0.0_r8 endif if ( (EDPftvarcon_inst%stress_decid(p) == itrue) .and. & - (any(currentSite%dstatus == [0,1]))) then + (any(currentSite%dstatus == [phen_dstat_timeoff,phen_dstat_moistoff]))) then currentPatch%seed_germination(p) = 0.0_r8 endif enddo @@ -1097,14 +1114,14 @@ subroutine recruitment( currentSite, currentPatch, bc_in ) temp_cohort%laimemory = 0.0_r8 if ( (EDPftvarcon_inst%season_decid(temp_cohort%pft) == itrue) .and. & - (any(currentSite%cstatus == [0,1]))) then + (any(currentSite%cstatus == [phen_cstat_nevercold,phen_cstat_iscold]))) then temp_cohort%laimemory = b_leaf b_leaf = 0.0_r8 cohortstatus = leaves_off endif if ( (EDPftvarcon_inst%stress_decid(temp_cohort%pft) == itrue) .and. & - (any(currentSite%dstatus == [0,1]))) then + (any(currentSite%dstatus == [phen_dstat_timeoff,phen_dstat_moistoff]))) then temp_cohort%laimemory = b_leaf b_leaf = 0.0_r8 cohortstatus = leaves_off diff --git a/main/EDInitMod.F90 b/main/EDInitMod.F90 index 2784267f52..bba2cb139f 100644 --- a/main/EDInitMod.F90 +++ b/main/EDInitMod.F90 @@ -27,6 +27,12 @@ module EDInitMod use EDTypesMod , only : first_leaf_aclass use EDTypesMod , only : leaves_on use EDTypesMod , only : leaves_off + use EDTypesMod , only : phen_cstat_nevercold + use EDTypesMod , only : phen_cstat_iscold + use EDTypesMod , only : phen_dstat_timeoff + use EDTypesMod , only : phen_dstat_moistoff + use EDTypesMod , only : phen_cstat_notcold + use EDTypesMod , only : phen_dstat_moiston use FatesInterfaceMod , only : bc_in_type use FatesInterfaceMod , only : hlm_use_planthydro use FatesInterfaceMod , only : hlm_use_inventory_init @@ -210,9 +216,9 @@ subroutine set_site_properties( nsites, sites) GDD = 30.0_r8 cleafon = 100 cleafoff = 300 - cstat = 2 ! Leaves are on + cstat = phen_cstat_notcold ! Leaves are on acc_NI = 0.0_r8 - dstat = 2 ! Leaves are on + dstat = phen_dstat_moiston ! Leaves are on dleafoff = 300 dleafon = 100 watermem = 0.5_r8 @@ -437,13 +443,15 @@ subroutine init_cohorts( site_in, patch_in, bc_in) temp_cohort%laimemory = 0._r8 cstatus = leaves_on - if( EDPftvarcon_inst%season_decid(pft) == itrue .and. site_in%cstatus < 2 ) then + if( EDPftvarcon_inst%season_decid(pft) == itrue .and. & + any(site_in%cstatus == [phen_cstat_nevercold,phen_cstat_iscold])) then temp_cohort%laimemory = b_leaf b_leaf = 0._r8 cstatus = leaves_off endif - - if ( EDPftvarcon_inst%stress_decid(pft) == itrue .and. site_in%dstatus < 2 ) then + + if ( EDPftvarcon_inst%stress_decid(pft) == itrue .and. & + any(site_in%dstatus == [phen_dstat_timeoff,phen_dstat_moistoff])) then temp_cohort%laimemory = b_leaf b_leaf = 0._r8 cstatus = leaves_off diff --git a/main/EDMainMod.F90 b/main/EDMainMod.F90 index bdfab7e0ae..1125305c85 100644 --- a/main/EDMainMod.F90 +++ b/main/EDMainMod.F90 @@ -41,6 +41,8 @@ module EDMainMod use EDtypesMod , only : ed_patch_type use EDtypesMod , only : ed_cohort_type use EDTypesMod , only : AREA + use EDTypesMod , only : phen_dstat_moiston + use EDTypesMod , only : phen_dstat_timeon use FatesConstantsMod , only : itrue,ifalse use FatesConstantsMod , only : primaryforest, secondaryforest use FatesPlantHydraulicsMod , only : do_growthrecruiteffects @@ -361,7 +363,7 @@ subroutine ed_integrate_state_variables(currentSite, bc_in ) ! Conduct Maintenance Turnover (parteh) call currentCohort%prt%CheckMassConservation(ft,3) - if(currentSite%dstatus>1) then + if(any(currentSite%dstatus == [phen_dstat_moiston,phen_dstat_timeon])) then is_drought = .false. else is_drought = .true. diff --git a/main/EDTypesMod.F90 b/main/EDTypesMod.F90 index 31aa507c4f..633e365678 100644 --- a/main/EDTypesMod.F90 +++ b/main/EDTypesMod.F90 @@ -116,6 +116,20 @@ module EDTypesMod integer , parameter :: dtype_ifire = 2 ! index for fire generated disturbance event integer , parameter :: dtype_ilog = 3 ! index for logging generated disturbance event + + ! Phenology status flag definitions (cold type is cstat, dry type is dstat) + + integer, parameter :: phen_cstat_nevercold = 0 ! This (location/plant) has not experienced a cold period over a large number + ! of days, leaves are dropped and flagged as non-cold region + integer, parameter :: phen_cstat_iscold = 1 ! This (location/plant) is in a cold-state where leaves should have fallen + integer, parameter :: phen_cstat_notcold = 2 ! This site is in a warm-state where leaves are allowed to flush + + integer, parameter :: phen_dstat_timeoff = 0 ! Leaves off due to time exceedance (drought phenology) + integer, parameter :: phen_dstat_moistoff = 1 ! Leaves off due to moisture avail (drought phenology) + integer, parameter :: phen_dstat_moiston = 2 ! Leaves on due to moisture avail (drought phenology) + integer, parameter :: phen_dstat_timeon = 3 ! Leaves on due to time exceedance (drought phenology) + + ! SPITFIRE integer, parameter :: NCWD = 4 ! number of coarse woody debris pools (twig,s branch,l branch, trunk) integer , parameter :: NFSC = NCWD+2 ! number fuel size classes (4 cwd size classes, leaf litter, and grass) diff --git a/main/FatesInventoryInitMod.F90 b/main/FatesInventoryInitMod.F90 index 4e1b778aa6..52a6c9bb09 100644 --- a/main/FatesInventoryInitMod.F90 +++ b/main/FatesInventoryInitMod.F90 @@ -37,6 +37,10 @@ module FatesInventoryInitMod use EDTypesMod , only : equal_leaf_aclass use EDTypesMod , only : leaves_on use EDTypesMod , only : leaves_off + use EDTypesMod , only : phen_cstat_nevercold + use EDTypesMod , only : phen_cstat_iscold + use EDTypesMod , only : phen_dstat_timeoff + use EDTypesMod , only : phen_dstat_moistoff use EDPftvarcon , only : EDPftvarcon_inst use FatesConstantsMod, only : primaryforest @@ -916,13 +920,15 @@ subroutine set_inventory_edcohort_type1(csite,bc_in,css_file_unit,npatches, & temp_cohort%laimemory = 0._r8 cstatus = leaves_on - if( EDPftvarcon_inst%season_decid(c_pft) == itrue .and. csite%cstatus < 2 ) then + if( EDPftvarcon_inst%season_decid(c_pft) == itrue .and. & + any(csite%cstatus == [phen_cstat_nevercold,phen_cstat_iscold])) then temp_cohort%laimemory = b_leaf b_leaf = 0._r8 cstatus = leaves_off endif - if ( EDPftvarcon_inst%stress_decid(c_pft) == itrue .and. csite%dstatus < 2) then + if ( EDPftvarcon_inst%stress_decid(c_pft) == itrue .and. & + any(csite%dstatus == [phen_dstat_timeoff,phen_dstat_moistoff])) then temp_cohort%laimemory = b_leaf b_leaf = 0._r8 cstatus = leaves_off From 5420fb6039addbc3eaaf06177022bbac8df129f5 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Tue, 30 Apr 2019 16:25:34 -0600 Subject: [PATCH 27/27] Updated some history long-name syntax for phen status, added an explicit itrue in phenology. --- biogeochem/EDPhysiologyMod.F90 | 4 ++-- main/FatesHistoryInterfaceMod.F90 | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/biogeochem/EDPhysiologyMod.F90 b/biogeochem/EDPhysiologyMod.F90 index 6215765a7f..04969ca9f0 100644 --- a/biogeochem/EDPhysiologyMod.F90 +++ b/biogeochem/EDPhysiologyMod.F90 @@ -322,8 +322,8 @@ subroutine trim_canopy( currentSite ) !Leaf Cost kgC/m2/year-1 !decidous costs. - if (EDPftvarcon_inst%season_decid(ipft) == 1.or. & - EDPftvarcon_inst%stress_decid(ipft) == 1)then + if (EDPftvarcon_inst%season_decid(ipft) == itrue .or. & + EDPftvarcon_inst%stress_decid(ipft) == itrue )then ! Leaf cost at leaf level z accounting for sla profile (kgC/m2) currentCohort%leaf_cost = 1._r8/(sla_levleaf*1000.0_r8) diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index 634c3c3ebd..f9821b45f4 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -3385,14 +3385,14 @@ subroutine define_history_vars(this, initialize_variables) avgflag='A', vtype=patch_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_area_treespread_pa) - call this%set_history_var(vname='SITE_COLD_STATUS', units='1,2', & - long='Site level cold status, 1=too cold for leaves, 2=not-too cold', & + call this%set_history_var(vname='SITE_COLD_STATUS', units='0,1,2', & + long='Site level cold status, 0=not cold-dec, 1=too cold for leaves, 2=not-too cold', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=hlm_hio_ignore_val, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_site_cstatus_si ) - call this%set_history_var(vname='SITE_DROUGHT_STATUS', units='1,2', & - long='Site level drought status, 1=too dry for leaves, 2=not-too dry', & + call this%set_history_var(vname='SITE_DROUGHT_STATUS', units='0,1,2,3', & + long='Site level drought status, <2 too dry for leaves, >=2 not-too dry', & use_default='active', & avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=hlm_hio_ignore_val, upfreq=1, & ivar=ivar, initialize=initialize_variables, index = ih_site_dstatus_si)