From b96f529dc7a168c179e98fc15e0fb7868e69b9dd Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 15 Apr 2019 16:34:37 -0700 Subject: [PATCH] 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