From 139afb5bbeded584c95733aa9bd7f29580c65d2f Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 Sep 2021 11:54:54 -0600 Subject: [PATCH 1/9] Removed redundant booleans from a conditional. --- src/biogeochem/CNPhenologyMod.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 2716accaf0..99303b319d 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -1927,7 +1927,6 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & a10tmin(p) > minplanttemp(ivt(p)) .and. & jday >= minplantjday(ivt(p),h) .and. & jday <= maxplantjday(ivt(p),h) .and. & - t10(p) /= spval .and. a10tmin(p) /= spval .and. & gdd820(p) /= spval .and. & gdd820(p) >= gddmin(ivt(p))) then From b1eff7eb9c21921ac5f7ce70cfbc288bc907d184 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 Sep 2021 16:17:41 -0600 Subject: [PATCH 2/9] Added logical variables for conditionals in non-winter-cereals planting. Should not result in behavior change. Setting up for de-duplication of code in next commit. --- src/biogeochem/CNPhenologyMod.F90 | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 99303b319d..105ef888fe 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -1687,6 +1687,8 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & real(r8) dayspyr ! days per year real(r8) crmcorn ! comparitive relative maturity for corn real(r8) ndays_on ! number of days to fertilize + logical do_plant_normal ! are the normal planting rules for non-winter cereals defined and satisfied? + logical do_plant_lastchance ! if not the above, what about relaxed rules for the last day of the planting window? !------------------------------------------------------------------------ associate( & @@ -1922,13 +1924,23 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & else ! not winter cereal... slevis: added distinction between NH and SH ! slevis: The idea is that jday will equal idop sooner or later in the year ! while the gdd part is either true or false for the year. - if (t10(p) /= spval.and. a10tmin(p) /= spval .and. & - t10(p) > planttemp(ivt(p)) .and. & - a10tmin(p) > minplanttemp(ivt(p)) .and. & - jday >= minplantjday(ivt(p),h) .and. & - jday <= maxplantjday(ivt(p),h) .and. & - gdd820(p) /= spval .and. & - gdd820(p) >= gddmin(ivt(p))) then + + ! srabin 2021-09-08. (No new behavior added; just allows for de-duplication of code.) + ! Are all the normal requirements for planting met? + do_plant_normal = t10(p) /= spval .and. a10tmin(p) /= spval .and. & + t10(p) > planttemp(ivt(p)) .and. & + a10tmin(p) > minplanttemp(ivt(p)) .and. & + jday >= minplantjday(ivt(p),h) .and. & + jday <= maxplantjday(ivt(p),h) .and. & + gdd820(p) /= spval .and. & + gdd820(p) >= gddmin(ivt(p)) + ! If not, but it's the last day of the planting window, what about relaxed rules? + do_plant_lastchance = (.not. do_plant_normal) .and. & + jday == maxplantjday(ivt(p),h) .and. & + gdd820(p) > 0._r8 .and. & + gdd820(p) /= spval + + if (do_plant_normal) then ! impose limit on growing season length needed ! for crop maturity - for cold weather constraints @@ -1984,8 +1996,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & ! If hit the max planting julian day -- go ahead and plant - else if (jday == maxplantjday(ivt(p),h) .and. gdd820(p) > 0._r8 .and. & - gdd820(p) /= spval ) then + else if (do_plant_lastchance) then croplive(p) = .true. cropplant(p) = .true. idop(p) = jday From da2ea9bd9a3eb47422edb0a2bc4ae3a726d77b2e Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 Sep 2021 16:22:36 -0600 Subject: [PATCH 3/9] De-duplicated code in non-winter-cereals planting. Again, should not result in any difference in behavior. Results should be bit-for-bit identical. Resolves #1479. --- src/biogeochem/CNPhenologyMod.F90 | 55 +++---------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 105ef888fe..a1f87a7cf3 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -1940,7 +1940,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & gdd820(p) > 0._r8 .and. & gdd820(p) /= spval - if (do_plant_normal) then + if (do_plant_normal .or. do_plant_lastchance) then ! impose limit on growing season length needed ! for crop maturity - for cold weather constraints @@ -1962,7 +1962,9 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & ivt(p) == nmiscanthus .or. ivt(p) == nirrig_miscanthus .or. & ivt(p) == nswitchgrass .or. ivt(p) == nirrig_switchgrass) then gddmaturity(p) = max(950._r8, min(gdd820(p)*0.85_r8, hybgdd(ivt(p)))) - gddmaturity(p) = max(950._r8, min(gddmaturity(p)+150._r8, 1850._r8)) + if (do_plant_normal) then + gddmaturity(p) = max(950._r8, min(gddmaturity(p)+150._r8, 1850._r8)) + end if end if if (ivt(p) == nswheat .or. ivt(p) == nirrig_swheat .or. & ivt(p) == ncotton .or. ivt(p) == nirrig_cotton .or. & @@ -1995,55 +1997,6 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & endif - ! If hit the max planting julian day -- go ahead and plant - else if (do_plant_lastchance) then - croplive(p) = .true. - cropplant(p) = .true. - idop(p) = jday - harvdate(p) = NOT_Harvested - - if (ivt(p) == ntmp_soybean .or. ivt(p) == nirrig_tmp_soybean .or. & - ivt(p) == ntrp_soybean .or. ivt(p) == nirrig_trp_soybean) then - gddmaturity(p) = min(gdd1020(p), hybgdd(ivt(p))) - end if - - if (ivt(p) == ntmp_corn .or. ivt(p) == nirrig_tmp_corn .or. & - ivt(p) == ntrp_corn .or. ivt(p) == nirrig_trp_corn .or. & - ivt(p) == nsugarcane .or. ivt(p) == nirrig_sugarcane .or. & - ivt(p) == nmiscanthus .or. ivt(p) == nirrig_miscanthus .or. & - ivt(p) == nswitchgrass .or. ivt(p) == nirrig_switchgrass) then - gddmaturity(p) = max(950._r8, min(gdd820(p)*0.85_r8, hybgdd(ivt(p)))) - end if - if (ivt(p) == nswheat .or. ivt(p) == nirrig_swheat .or. & - ivt(p) == ncotton .or. ivt(p) == nirrig_cotton .or. & - ivt(p) == nrice .or. ivt(p) == nirrig_rice) then - gddmaturity(p) = min(gdd020(p), hybgdd(ivt(p))) - end if - - leafc_xfer(p) = initial_seed_at_planting - leafn_xfer(p) = leafc_xfer(p) / leafcn(ivt(p)) ! with onset - crop_seedc_to_leaf(p) = leafc_xfer(p)/dt - crop_seedn_to_leaf(p) = leafn_xfer(p)/dt - - ! because leafc_xfer is set above rather than incremneted through the normal process, must also set its isotope - ! pools here. use totvegc_patch as the closest analogue if nonzero, and use initial value otherwise - if (use_c13) then - if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then - c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & - c13_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) - else - c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c13ratio - endif - endif - if (use_c14) then - if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then - c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & - c14_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) - else - c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c14ratio - endif - endif - else gddmaturity(p) = 0._r8 end if From 67a0edd8d491e17d04a12d14e651101fc297221c Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 9 Sep 2021 11:44:38 -0600 Subject: [PATCH 4/9] De-duplicated code in planting of winter cereals. --- src/biogeochem/CNPhenologyMod.F90 | 58 ++++++++----------------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index a1f87a7cf3..481663f669 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -1687,7 +1687,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & real(r8) dayspyr ! days per year real(r8) crmcorn ! comparitive relative maturity for corn real(r8) ndays_on ! number of days to fertilize - logical do_plant_normal ! are the normal planting rules for non-winter cereals defined and satisfied? + logical do_plant_normal ! are the normal planting rules defined and satisfied? logical do_plant_lastchance ! if not the above, what about relaxed rules for the last day of the planting window? !------------------------------------------------------------------------ @@ -1841,50 +1841,21 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & ! cropplant through the end of the year for a harvested crop. ! Also harvdate(p) should be harvdate(p,ivt(p)) and should be ! updated on Jan 1st instead of at harvest (slevis) - if (a5tmin(p) /= spval .and. & - a5tmin(p) <= minplanttemp(ivt(p)) .and. & - jday >= minplantjday(ivt(p),h) .and. & - (gdd020(p) /= spval .and. & - gdd020(p) >= gddmin(ivt(p)))) then - cumvd(p) = 0._r8 - hdidx(p) = 0._r8 - vf(p) = 0._r8 - croplive(p) = .true. - cropplant(p) = .true. - idop(p) = jday - harvdate(p) = NOT_Harvested - gddmaturity(p) = hybgdd(ivt(p)) - leafc_xfer(p) = initial_seed_at_planting - leafn_xfer(p) = leafc_xfer(p) / leafcn(ivt(p)) ! with onset - crop_seedc_to_leaf(p) = leafc_xfer(p)/dt - crop_seedn_to_leaf(p) = leafn_xfer(p)/dt - - ! because leafc_xfer is set above rather than incremneted through the normal process, must also set its isotope - ! pools here. use totvegc_patch as the closest analogue if nonzero, and use initial value otherwise - if (use_c13) then - if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then - c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & - c13_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) - else - c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c13ratio - endif - endif - if (use_c14) then - if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then - c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & - c14_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) - else - c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c14ratio - endif - endif - - ! latest possible date to plant winter cereal and after all other - ! crops were harvested for that year + ! srabin 2021-09-09. (No new behavior added; just allows for de-duplication of code.) + ! Are all the normal requirements for planting met? + do_plant_normal = a5tmin(p) /= spval .and. & + a5tmin(p) <= minplanttemp(ivt(p)) .and. & + jday >= minplantjday(ivt(p),h) .and. & + (gdd020(p) /= spval .and. & + gdd020(p) >= gddmin(ivt(p))) + ! If not, but it's the last day of the planting window, what about relaxed rules? + do_plant_lastchance = (.not. do_plant_normal) .and. & + jday >= maxplantjday(ivt(p),h) .and. & + gdd020(p) /= spval .and. & + gdd020(p) >= gddmin(ivt(p)) - else if (jday >= maxplantjday(ivt(p),h) .and. & - gdd020(p) /= spval .and. & - gdd020(p) >= gddmin(ivt(p))) then + if (do_plant_normal .or. do_plant_lastchance) then cumvd(p) = 0._r8 hdidx(p) = 0._r8 @@ -1917,6 +1888,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c14ratio endif endif + else gddmaturity(p) = 0._r8 end if From 315600af9ac7258bfbcec03d989fd154b7b989ea Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 9 Sep 2021 12:31:43 -0600 Subject: [PATCH 5/9] De-duplicated more crop planting code: new subroutine PlantCrop(). Performs planting-day operations used in both winter cereals and other crops. Should not change results, but this is untested. Not even sure if it compiles. --- src/biogeochem/CNPhenologyMod.F90 | 141 ++++++++++++++++++------------ 1 file changed, 83 insertions(+), 58 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 481663f669..fc5d306d15 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -1860,34 +1860,13 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & cumvd(p) = 0._r8 hdidx(p) = 0._r8 vf(p) = 0._r8 - croplive(p) = .true. - cropplant(p) = .true. - idop(p) = jday - harvdate(p) = NOT_Harvested - gddmaturity(p) = hybgdd(ivt(p)) - leafc_xfer(p) = initial_seed_at_planting - leafn_xfer(p) = leafc_xfer(p) / leafcn(ivt(p)) ! with onset - crop_seedc_to_leaf(p) = leafc_xfer(p)/dt - crop_seedn_to_leaf(p) = leafn_xfer(p)/dt + + PlantCrop(p, jday, crop_inst, & + cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & + cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & + c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) - ! because leafc_xfer is set above rather than incremneted through the normal process, must also set its isotope - ! pools here. use totvegc_patch as the closest analogue if nonzero, and use initial value otherwise - if (use_c13) then - if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then - c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & - c13_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) - else - c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c13ratio - endif - endif - if (use_c14) then - if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then - c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & - c14_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) - else - c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c14ratio - endif - endif + gddmaturity(p) = hybgdd(ivt(p)) else gddmaturity(p) = 0._r8 @@ -1914,12 +1893,10 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & if (do_plant_normal .or. do_plant_lastchance) then - ! impose limit on growing season length needed - ! for crop maturity - for cold weather constraints - croplive(p) = .true. - cropplant(p) = .true. - idop(p) = jday - harvdate(p) = NOT_Harvested + PlantCrop(p, jday, crop_inst, & + cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & + cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & + c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) ! go a specified amount of time before/after ! climatological date @@ -1944,31 +1921,6 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & gddmaturity(p) = min(gdd020(p), hybgdd(ivt(p))) end if - leafc_xfer(p) = initial_seed_at_planting - leafn_xfer(p) = leafc_xfer(p) / leafcn(ivt(p)) ! with onset - crop_seedc_to_leaf(p) = leafc_xfer(p)/dt - crop_seedn_to_leaf(p) = leafn_xfer(p)/dt - - ! because leafc_xfer is set above rather than incremneted through the normal process, must also set its isotope - ! pools here. use totvegc_patch as the closest analogue if nonzero, and use initial value otherwise - if (use_c13) then - if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then - c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & - c13_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) - else - c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c13ratio - endif - endif - if (use_c14) then - if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then - c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & - c14_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) - else - c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c14ratio - endif - endif - - else gddmaturity(p) = 0._r8 end if @@ -2258,6 +2210,79 @@ subroutine CropPhenologyInit(bounds) end subroutine CropPhenologyInit + !----------------------------------------------------------------------- + subroutine PlantCrop(p, jday, & + crop_inst, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & + cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & + c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) + ! + ! !DESCRIPTION: + ! + ! subroutine calculates initializes variables to what they should be upon + ! planting. Includes only operations that apply to all crop types; + ! additional operations need to happen in CropPhenology(). + + ! !USES: + use clm_varctl , only : use_c13, use_c14 + use clm_varcon , only : c13ratio, c14ratio + ! + ! !ARGUMENTS: + integer , intent(in) :: p ! PATCH index running over + integer , intent(in) :: jday ! julian day of the year + type(crop_type) , intent(inout) :: crop_inst + type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst + type(cnveg_nitrogenstate_type) , intent(inout) :: cnveg_nitrogenstate_inst + type(cnveg_carbonflux_type) , intent(inout) :: cnveg_carbonflux_inst + type(cnveg_nitrogenflux_type) , intent(inout) :: cnveg_nitrogenflux_inst + type(cnveg_carbonstate_type) , intent(inout) :: c13_cnveg_carbonstate_inst + type(cnveg_carbonstate_type) , intent(inout) :: c14_cnveg_carbonstate_inst + !------------------------------------------------------------------------ + + associate( & + croplive => crop_inst%croplive_patch , & ! Output: [logical (:) ] Flag, true if planted, not harvested + cropplant => crop_inst%cropplant_patch , & ! Output: [logical (:) ] Flag, true if crop may be planted + harvdate => crop_inst%harvdate_patch , & ! Output: [integer (:) ] harvest date + leafc_xfer => cnveg_carbonstate_inst%leafc_xfer_patch , & ! Output: [real(r8) (:) ] (gC/m2) leaf C transfer + leafn_xfer => cnveg_nitrogenstate_inst%leafn_xfer_patch , & ! Output: [real(r8) (:) ] (gN/m2) leaf N transfer + crop_seedc_to_leaf => cnveg_carbonflux_inst%crop_seedc_to_leaf_patch , & ! Output: [real(r8) (:) ] (gC/m2/s) seed source to leaf + crop_seedn_to_leaf => cnveg_nitrogenflux_inst%crop_seedn_to_leaf_patch, & ! Output: [real(r8) (:) ] (gN/m2/s) seed source to leaf + ) + + ! impose limit on growing season length needed + ! for crop maturity - for cold weather constraints + croplive(p) = .true. + cropplant(p) = .true. + idop(p) = jday + harvdate(p) = NOT_Harvested + + leafc_xfer(p) = initial_seed_at_planting + leafn_xfer(p) = leafc_xfer(p) / leafcn(ivt(p)) ! with onset + crop_seedc_to_leaf(p) = leafc_xfer(p)/dt + crop_seedn_to_leaf(p) = leafn_xfer(p)/dt + + ! because leafc_xfer is set above rather than incremneted through the normal process, must also set its isotope + ! pools here. use totvegc_patch as the closest analogue if nonzero, and use initial value otherwise + if (use_c13) then + if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then + c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & + c13_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) + else + c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c13ratio + endif + endif + if (use_c14) then + if ( cnveg_carbonstate_inst%totvegc_patch(p) .gt. 0._r8) then + c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * & + c14_cnveg_carbonstate_inst%totvegc_patch(p) / cnveg_carbonstate_inst%totvegc_patch(p) + else + c14_cnveg_carbonstate_inst%leafc_xfer_patch(p) = leafc_xfer(p) * c14ratio + endif + endif + + end associate + + end subroutine PlantCrop + !----------------------------------------------------------------------- subroutine vernalization(p, & canopystate_inst, temperature_inst, waterdiagnosticbulk_inst, cnveg_state_inst, crop_inst) From 554ba302f9401361f0cd44731cc5332557922c92 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 9 Sep 2021 16:24:52 -0600 Subject: [PATCH 6/9] Removed comments. --- src/biogeochem/CNPhenologyMod.F90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index fc5d306d15..0890150868 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -1842,7 +1842,6 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & ! Also harvdate(p) should be harvdate(p,ivt(p)) and should be ! updated on Jan 1st instead of at harvest (slevis) - ! srabin 2021-09-09. (No new behavior added; just allows for de-duplication of code.) ! Are all the normal requirements for planting met? do_plant_normal = a5tmin(p) /= spval .and. & a5tmin(p) <= minplanttemp(ivt(p)) .and. & @@ -1876,7 +1875,6 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & ! slevis: The idea is that jday will equal idop sooner or later in the year ! while the gdd part is either true or false for the year. - ! srabin 2021-09-08. (No new behavior added; just allows for de-duplication of code.) ! Are all the normal requirements for planting met? do_plant_normal = t10(p) /= spval .and. a10tmin(p) /= spval .and. & t10(p) > planttemp(ivt(p)) .and. & From 117a45af8bed5a0ab0eec1578b6af7b8da3a34a8 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 9 Sep 2021 16:26:55 -0600 Subject: [PATCH 7/9] Fixed calls of PlantCrop(). --- src/biogeochem/CNPhenologyMod.F90 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 0890150868..337a0a5dda 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -1860,10 +1860,10 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & hdidx(p) = 0._r8 vf(p) = 0._r8 - PlantCrop(p, jday, crop_inst, & - cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & - cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & - c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) + call PlantCrop(p, jday, crop_inst, & + cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & + cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & + c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) gddmaturity(p) = hybgdd(ivt(p)) @@ -1891,10 +1891,10 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & if (do_plant_normal .or. do_plant_lastchance) then - PlantCrop(p, jday, crop_inst, & - cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & - cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & - c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) + call PlantCrop(p, jday, crop_inst, & + cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & + cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & + c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) ! go a specified amount of time before/after ! climatological date From 88485748230bb54a02e8229644e13212abe0bd21 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Tue, 14 Sep 2021 12:18:19 -0600 Subject: [PATCH 8/9] Fixes needed for compiling. --- src/biogeochem/CNPhenologyMod.F90 | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 337a0a5dda..bd9a79b959 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -1860,7 +1860,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & hdidx(p) = 0._r8 vf(p) = 0._r8 - call PlantCrop(p, jday, crop_inst, & + call PlantCrop(p, leafcn(ivt(p)), jday, crop_inst, cnveg_state_inst, & cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) @@ -1891,7 +1891,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & if (do_plant_normal .or. do_plant_lastchance) then - call PlantCrop(p, jday, crop_inst, & + call PlantCrop(p, leafcn(ivt(p)), jday, crop_inst, cnveg_state_inst, & cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) @@ -2209,8 +2209,9 @@ subroutine CropPhenologyInit(bounds) end subroutine CropPhenologyInit !----------------------------------------------------------------------- - subroutine PlantCrop(p, jday, & - crop_inst, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & + subroutine PlantCrop(p, leafcn_in, jday, & + crop_inst, cnveg_state_inst, & + cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) ! @@ -2225,9 +2226,11 @@ subroutine PlantCrop(p, jday, & use clm_varcon , only : c13ratio, c14ratio ! ! !ARGUMENTS: - integer , intent(in) :: p ! PATCH index running over - integer , intent(in) :: jday ! julian day of the year + integer , intent(in) :: p ! PATCH index running over + real(r8) , intent(in) :: leafcn_in ! leaf C:N (gC/gN) of this patch's vegetation type (pftcon%leafcn(ivt(p))) + integer , intent(in) :: jday ! julian day of the year type(crop_type) , intent(inout) :: crop_inst + type(cnveg_state_type) , intent(inout) :: cnveg_state_inst type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst type(cnveg_nitrogenstate_type) , intent(inout) :: cnveg_nitrogenstate_inst type(cnveg_carbonflux_type) , intent(inout) :: cnveg_carbonflux_inst @@ -2236,14 +2239,15 @@ subroutine PlantCrop(p, jday, & type(cnveg_carbonstate_type) , intent(inout) :: c14_cnveg_carbonstate_inst !------------------------------------------------------------------------ - associate( & + associate( & croplive => crop_inst%croplive_patch , & ! Output: [logical (:) ] Flag, true if planted, not harvested cropplant => crop_inst%cropplant_patch , & ! Output: [logical (:) ] Flag, true if crop may be planted harvdate => crop_inst%harvdate_patch , & ! Output: [integer (:) ] harvest date + idop => cnveg_state_inst%idop_patch , & ! Output: [integer (:) ] date of planting leafc_xfer => cnveg_carbonstate_inst%leafc_xfer_patch , & ! Output: [real(r8) (:) ] (gC/m2) leaf C transfer leafn_xfer => cnveg_nitrogenstate_inst%leafn_xfer_patch , & ! Output: [real(r8) (:) ] (gN/m2) leaf N transfer crop_seedc_to_leaf => cnveg_carbonflux_inst%crop_seedc_to_leaf_patch , & ! Output: [real(r8) (:) ] (gC/m2/s) seed source to leaf - crop_seedn_to_leaf => cnveg_nitrogenflux_inst%crop_seedn_to_leaf_patch, & ! Output: [real(r8) (:) ] (gN/m2/s) seed source to leaf + crop_seedn_to_leaf => cnveg_nitrogenflux_inst%crop_seedn_to_leaf_patch & ! Output: [real(r8) (:) ] (gN/m2/s) seed source to leaf ) ! impose limit on growing season length needed @@ -2254,7 +2258,7 @@ subroutine PlantCrop(p, jday, & harvdate(p) = NOT_Harvested leafc_xfer(p) = initial_seed_at_planting - leafn_xfer(p) = leafc_xfer(p) / leafcn(ivt(p)) ! with onset + leafn_xfer(p) = leafc_xfer(p) / leafcn_in ! with onset crop_seedc_to_leaf(p) = leafc_xfer(p)/dt crop_seedn_to_leaf(p) = leafn_xfer(p)/dt From 539f60998fc50c4d65cb319a6f5777cbbb88b269 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Mon, 20 Sep 2021 10:11:00 -0600 Subject: [PATCH 9/9] Update ChangeLog --- doc/ChangeLog | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ doc/ChangeSum | 1 + 2 files changed, 56 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 716d2a460e..691a4b908e 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,59 @@ =============================================================== +Tag name: ctsm5.1.dev057 +Originator(s): Sam Rabin +Date: Mon Sep 20 10:07:26 MDT 2021 +One-line Summary: Consolidate duplicated crop phenology code + +Purpose and description of changes +---------------------------------- + +Consolidate duplicated code related to crop planting + + +Significant changes to scientifically-supported configurations +-------------------------------------------------------------- + +Does this tag change answers significantly for any of the following physics configurations? +(Details of any changes will be given in the "Answer changes" section below.) + + [Put an [X] in the box for any configuration with significant answer changes.] + +[ ] clm5_1 + +[ ] clm5_0 + +[ ] ctsm5_0-nwp + +[ ] clm4_5 + + +Bugs fixed or introduced +------------------------ +Issues fixed (include CTSM Issue #): +- Resolves ESCOMP/CTSM#1479 (Suggested cleanup in CropPhenology(): + Removing duplicated sowing code) + + +Testing summary: +---------------- + + regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): + + cheyenne ---- ok + izumi ------- ok + +Answer changes +-------------- + +Changes answers relative to baseline: NO + +Other details +------------- +Pull Requests that document the changes (include PR ids): +https://github.com/ESCOMP/CTSM/pull/1482 + +=============================================================== +=============================================================== Tag name: ctsm5.1.dev056 Originator(s): glemieux (Gregory Lemieux,,,) Date: Fri Sep 17 15:41:57 MDT 2021 diff --git a/doc/ChangeSum b/doc/ChangeSum index 836916d70f..eb50772bc5 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,5 +1,6 @@ Tag Who Date Summary ============================================================================================================================ + ctsm5.1.dev057 samrabin 09/20/2021 Consolidate duplicated crop phenology code ctsm5.1.dev056 glemieux 09/17/2021 FATES Satellite Phenology mode implemented ctsm5.1.dev055 slevis 09/10/2021 Updates to master_list_file.rst ctsm5.1.dev054 erik 09/02/2021 New parameters on paramsfile, many bit-for-bit changes, new history fields for IWUELN,VPD_2M, allow Medlyn Photosynthesis for non-PHS cases, fixes to HumanStressIndex