@@ -2629,13 +2629,7 @@ subroutine CropPhase(bounds, num_pcropp, filter_pcropp, &
26292629 ! !DESCRIPTION:
26302630 ! Get the current phase of each crop patch.
26312631 !
2632- ! The returned values (in crop_phase) are from the set of cphase_* values defined in
2633- ! CropType. The returned values in crop_phase are only valid for patches where
2634- ! croplive is true; the values are undefined where croplive is false and should not be
2635- ! used there!
2636- !
2637- ! This has logic similar to that in CropPhenology. If you make changes here, you
2638- ! should also check if similar changes need to be made in CropPhenology.
2632+ ! See CropPhase_OnePatch for more information.
26392633 !
26402634 ! !ARGUMENTS:
26412635 type (bounds_type) , intent (in ) :: bounds
@@ -2652,37 +2646,60 @@ subroutine CropPhase(bounds, num_pcropp, filter_pcropp, &
26522646 !- ----------------------------------------------------------------------
26532647 SHR_ASSERT_ALL_FL((ubound (crop_phase) == [bounds% endp]), sourcefile, __LINE__)
26542648
2655- associate( &
2656- croplive = > crop_inst% croplive_patch , & ! Input: [logical (:) ] Flag, true if planted, not harvested
2657- hui = > crop_inst% hui_patch , & ! Input: [real(r8) (:) ] gdd since planting (gddplant)
2658- leafout = > crop_inst% gddtsoi_patch , & ! Input: [real(r8) (:) ] gdd from top soil layer temperature
2659- huileaf = > cnveg_state_inst% huileaf_patch , & ! Input: [real(r8) (:) ] heat unit index needed from planting to leaf emergence
2660- huigrain = > cnveg_state_inst% huigrain_patch & ! Input: [real(r8) (:) ] same to reach vegetative maturity
2661- )
2662-
26632649 do fp = 1 , num_pcropp
26642650 p = filter_pcropp(fp)
2665-
2666- if (croplive(p)) then
2667- ! Start with cphase_planted, but this might get changed in the later
2668- ! conditional blocks.
2669- crop_phase(p) = cphase_planted
2670- if (leafout(p) >= huileaf(p) .and. hui(p) < huigrain(p)) then
2671- crop_phase(p) = cphase_leafemerge
2672- else if (hui(p) >= huigrain(p)) then
2673- ! Since we know croplive is true, any hui greater than huigrain implies that
2674- ! we're in the grainfill stage: if we were passt gddmaturity then croplive
2675- ! would be false.
2676- crop_phase(p) = cphase_grainfill
2677- end if
2678- end if
2651+ call CropPhase_OnePatch( &
2652+ crop_phase(p), &
2653+ crop_inst% croplive_patch(p), &
2654+ crop_inst% gddtsoi_patch(p), &
2655+ crop_inst% hui_patch(p), &
2656+ cnveg_state_inst% huileaf_patch(p), &
2657+ cnveg_state_inst% huigrain_patch(p))
26792658 end do
26802659
2681- end associate
2682-
26832660 end subroutine CropPhase
26842661
26852662
2663+ !- ----------------------------------------------------------------------
2664+ subroutine CropPhase_OnePatch ( &
2665+ crop_phase , croplive , leafout , hui , huileaf , huigrain &
2666+ )
2667+ !
2668+ ! !DESCRIPTION:
2669+ ! Get the current phase of a crop patch.
2670+ !
2671+ ! The returned values (in crop_phase) are from the set of cphase_* values defined in
2672+ ! CropType. The returned values in crop_phase are only valid for patches where
2673+ ! croplive is true; the values are undefined where croplive is false and should not be
2674+ ! used there!
2675+ !
2676+ ! This has logic similar to that in CropPhenology. If you make changes here, you
2677+ ! should also check if similar changes need to be made in CropPhenology.
2678+ !
2679+ ! !ARGUMENTS:
2680+ real (r8 ), intent (inout ) :: crop_phase ! In/out: [real(r8)] crop phase
2681+ logical , intent (in ) :: croplive ! Input: [logical] Flag, true if planted, not harvested
2682+ real (r8 ), intent (in ) :: leafout ! Input: [real(r8)] gdd from top soil layer temperature
2683+ real (r8 ), intent (in ) :: hui ! Input: [real(r8)] gdd since planting (gddplant)
2684+ real (r8 ), intent (in ) :: huileaf ! Input: [real(r8)] heat unit index needed from planting to leaf emergence
2685+ real (r8 ), intent (in ) :: huigrain ! Input: [real(r8)] same to reach vegetative maturity
2686+
2687+ if (croplive) then
2688+ ! Start with cphase_planted, but this might get changed in the later
2689+ ! conditional blocks.
2690+ crop_phase = cphase_planted
2691+ if (leafout >= huileaf .and. hui < huigrain) then
2692+ crop_phase = cphase_leafemerge
2693+ else if (hui >= huigrain) then
2694+ ! Since we know croplive is true, any hui greater than huigrain implies that
2695+ ! we're in the grainfill stage: if we were past gddmaturity then croplive
2696+ ! would be false.
2697+ crop_phase = cphase_grainfill
2698+ end if
2699+ end if
2700+ end subroutine CropPhase_OnePatch
2701+
2702+
26862703 !- ----------------------------------------------------------------------
26872704 subroutine CropPhenologyInit (bounds )
26882705 !
0 commit comments