@@ -809,6 +809,7 @@ subroutine set_inventory_edcohort_type1(csite,bc_in,css_file_unit,npatches, &
809809 real (r8 ) :: b_dead
810810 real (r8 ) :: b_store
811811 real (r8 ) :: a_sapwood ! area of sapwood at reference height [m2]
812+ integer :: i_pft, ncohorts_to_create
812813
813814
814815 character (len= 128 ),parameter :: wr_fmt = &
@@ -857,9 +858,9 @@ subroutine set_inventory_edcohort_type1(csite,bc_in,css_file_unit,npatches, &
857858 call endrun(msg= errMsg(sourcefile, __LINE__))
858859 end if
859860
860- if (c_pft <= 0 ) then
861+ if (c_pft < 0 ) then
861862 write (fates_log(), * ) ' inventory pft: ' ,c_pft
862- write (fates_log(), * ) ' The inventory produced a cohort with <= 0 pft index'
863+ write (fates_log(), * ) ' The inventory produced a cohort with <0 pft index'
863864 call endrun(msg= errMsg(sourcefile, __LINE__))
864865 end if
865866
@@ -886,64 +887,91 @@ subroutine set_inventory_edcohort_type1(csite,bc_in,css_file_unit,npatches, &
886887 write (fates_log(), * ) ' The inventory produced a cohort with very large density /m2'
887888 call endrun(msg= errMsg(sourcefile, __LINE__))
888889 end if
889-
890- allocate (temp_cohort) ! A temporary cohort is needed because we want to make
891- ! use of the allometry functions
892- ! Don't need to allocate leaf age classes (not used)
893890
894- temp_cohort% pft = c_pft
895- temp_cohort% n = c_nplant * cpatch% area
896- temp_cohort% dbh = c_dbh
897- call h_allom(c_dbh,c_pft,temp_cohort% hite)
898- temp_cohort% canopy_trim = 1.0_r8
891+ if (c_pft .eq. 0 ) then
892+ write (fates_log(), * ) ' inventory pft: ' ,c_pft
893+ write (fates_log(), * ) ' SPECIAL CASE TRIGGERED: PFT == 0 and therefore this subroutine'
894+ write (fates_log(), * ) ' will assign a cohort with n = n_orig/numpft to every cohort in range 1 to numpft'
895+ ncohorts_to_create = numpft
896+ else
897+ ncohorts_to_create = 1
898+ end if
899899
900- ! Calculate total above-ground biomass from allometry
900+ do i_pft = 1 ,ncohorts_to_create
901+ allocate (temp_cohort) ! A temporary cohort is needed because we want to make
902+ ! use of the allometry functions
903+ ! Don't need to allocate leaf age classes (not used)
901904
902- call bagw_allom(temp_cohort% dbh,c_pft,b_agw)
903- ! Calculate coarse root biomass from allometry
904- call bbgw_allom(temp_cohort% dbh,c_pft,b_bgw)
905-
906- ! Calculate the leaf biomass (calculates a maximum first, then applies canopy trim
907- ! and sla scaling factors)
908- call bleaf(temp_cohort% dbh,c_pft,temp_cohort% canopy_trim,b_leaf)
909-
910- ! Calculate fine root biomass
911- call bfineroot(temp_cohort% dbh,c_pft,temp_cohort% canopy_trim,b_fineroot)
912-
913- ! Calculate sapwood biomass
914- call bsap_allom(temp_cohort% dbh,c_pft,temp_cohort% canopy_trim, a_sapwood, b_sapwood)
915-
916- call bdead_allom( b_agw, b_bgw, b_sapwood, c_pft, b_dead )
905+ if (c_pft .ne. 0 ) then
906+ ! normal case: assign each cohort to its specified PFT
907+ temp_cohort% pft = c_pft
908+ else
909+ ! special case, make an identical cohort for each PFT
910+ temp_cohort% pft = i_pft
911+ endif
917912
918- call bstore_allom(temp_cohort% dbh, c_pft, temp_cohort% canopy_trim, b_store)
919-
920- temp_cohort% laimemory = 0._r8
921- cstatus = leaves_on
922-
923- if ( EDPftvarcon_inst% season_decid(c_pft) == itrue .and. &
924- any (csite% cstatus == [phen_cstat_nevercold,phen_cstat_iscold])) then
925- temp_cohort% laimemory = b_leaf
926- b_leaf = 0._r8
927- cstatus = leaves_off
928- endif
929-
930- if ( EDPftvarcon_inst% stress_decid(c_pft) == itrue .and. &
931- any (csite% dstatus == [phen_dstat_timeoff,phen_dstat_moistoff])) then
932- temp_cohort% laimemory = b_leaf
933- b_leaf = 0._r8
934- cstatus = leaves_off
935- endif
936-
937- ! Since spread is a canopy level calculation, we need to provide an initial guess here.
938- call create_cohort(csite, cpatch, c_pft, temp_cohort% n, temp_cohort% hite, temp_cohort% dbh, &
939- b_leaf, b_fineroot, b_sapwood, b_dead, b_store, &
940- temp_cohort% laimemory, cstatus, rstatus, temp_cohort% canopy_trim, &
941- 1 , csite% spread, equal_leaf_aclass, bc_in)
913+ temp_cohort% n = c_nplant * cpatch% area / real (ncohorts_to_create,r8 )
914+ temp_cohort% dbh = c_dbh
942915
943-
944- deallocate (temp_cohort) ! get rid of temporary cohort
916+ call h_allom(c_dbh,temp_cohort% pft,temp_cohort% hite)
917+ temp_cohort% canopy_trim = 1.0_r8
918+
919+ ! Calculate total above-ground biomass from allometry
920+
921+ call bagw_allom(temp_cohort% dbh,temp_cohort% pft,b_agw)
922+ ! Calculate coarse root biomass from allometry
923+ call bbgw_allom(temp_cohort% dbh,temp_cohort% pft,b_bgw)
924+
925+ ! Calculate the leaf biomass (calculates a maximum first, then applies canopy trim
926+ ! and sla scaling factors)
927+ call bleaf(temp_cohort% dbh,temp_cohort% pft,temp_cohort% canopy_trim,b_leaf)
928+
929+ ! Calculate fine root biomass
930+ call bfineroot(temp_cohort% dbh,temp_cohort% pft,temp_cohort% canopy_trim,b_fineroot)
931+
932+ ! Calculate sapwood biomass
933+ call bsap_allom(temp_cohort% dbh,temp_cohort% pft,temp_cohort% canopy_trim, a_sapwood, b_sapwood)
934+
935+ call bdead_allom( b_agw, b_bgw, b_sapwood, temp_cohort% pft, b_dead )
936+
937+ call bstore_allom(temp_cohort% dbh, temp_cohort% pft, temp_cohort% canopy_trim, b_store)
938+
939+ temp_cohort% laimemory = 0._r8
940+ cstatus = leaves_on
941+
942+
943+ if ( EDPftvarcon_inst% season_decid(temp_cohort% pft) == itrue .and. &
944+ any (csite% cstatus == [phen_cstat_nevercold,phen_cstat_iscold])) then
945+ temp_cohort% laimemory = b_leaf
946+ b_leaf = 0._r8
947+ cstatus = leaves_off
948+ endif
949+
950+ if ( EDPftvarcon_inst% stress_decid(temp_cohort% pft) == itrue .and. &
951+ any (csite% dstatus == [phen_dstat_timeoff,phen_dstat_moistoff])) then
952+ temp_cohort% laimemory = b_leaf
953+ b_leaf = 0._r8
954+ cstatus = leaves_off
955+ endif
956+
957+ ! Since spread is a canopy level calculation, we need to provide an initial guess here.
958+ if ( debug_inv) then
959+ write (fates_log(),* ) ' calling create_cohort: ' , temp_cohort% pft, temp_cohort% n, &
960+ temp_cohort% hite, temp_cohort% dbh, &
961+ b_leaf, b_fineroot, b_sapwood, b_dead, b_store, &
962+ temp_cohort% laimemory, cstatus, rstatus, temp_cohort% canopy_trim, &
963+ 1 , csite% spread
964+ endif
965+
966+ call create_cohort(csite, cpatch, temp_cohort% pft, temp_cohort% n, temp_cohort% hite, &
967+ temp_cohort% dbh, b_leaf, b_fineroot, b_sapwood, b_dead, b_store, &
968+ temp_cohort% laimemory, cstatus, rstatus, temp_cohort% canopy_trim, &
969+ 1 , csite% spread, equal_leaf_aclass, bc_in)
970+
971+ deallocate (temp_cohort) ! get rid of temporary cohort
972+ end do
945973
946974 return
947- end subroutine set_inventory_edcohort_type1
975+ end subroutine set_inventory_edcohort_type1
948976
949977end module FatesInventoryInitMod
0 commit comments