Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fates patch count controls #1766

Merged
merged 49 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6986334
Incremental changes to enable fates to drive the number of natveg pat…
rgknox May 20, 2022
72fbe0a
First pass of running/compiling fates with self-dictating patch counts
rgknox May 23, 2022
b3fbf23
Removed endrun from clm_varpar, circular dependency?
rgknox May 23, 2022
69bddf4
changing P32 test to P36 for improved core usage
glemieux May 23, 2022
b637526
Adjusting how maxcfts and maxnatpfts are defined with fates
rgknox May 24, 2022
57fe9ee
Merge branch 'fates-params-api23' of github.com:rgknox/ctsm into fate…
rgknox May 24, 2022
261eb28
Minor updates to fates-patch counting
rgknox May 25, 2022
d709a0f
fixed typo
rgknox May 25, 2022
d9db2b5
Added namelist hooks and interface for activating the tree damage mod…
rgknox May 27, 2022
3e86d6c
Added some placeholder code for harvest-product coupling in fates
rgknox May 27, 2022
8fc4b48
Merge branch 'ctsm5.1.dev098-branch' into fates-params-api23-dev98
rgknox May 27, 2022
ff247db
Small bug fix for fates surface file reads, temporary fates parameter…
rgknox May 29, 2022
da4d52a
Commented out clmfates wrapper code for product pools. Discussion wit…
rgknox May 31, 2022
cc8bc9a
Minor changes to how nat_wt_patch is calculated for fates
rgknox Jun 3, 2022
215864e
Updated default fates parameter file
rgknox Jun 8, 2022
243d26d
Add testmods for FATES and FATES-SP with Drydep and FATES and FATES-S…
ekluzek Jun 10, 2022
b039f49
Fixed location of default parameter file
rgknox Jun 10, 2022
b4e3acc
Added a tree damage test for fates
rgknox Jun 10, 2022
0e1a44f
removed clm_aux test for fates tree damage per Eriks suggestion
rgknox Jun 10, 2022
92226da
Reverted to base for SatellitePhenologyMod.F90 to removed whitespace …
rgknox Jun 10, 2022
b45cd84
Syntax and comment fixes for fates initialization logic. Added abort …
rgknox Jun 10, 2022
c4b16b1
Updates on comments
rgknox Jun 13, 2022
dfef51a
Switch a few cases of the use of ED in namelist documention for FATES…
ekluzek Jun 13, 2022
32c852f
Add a comment about requirement for ignore-warnings when FATES and Dr…
ekluzek Jun 13, 2022
461b8c1
Allowing calse to collapse in surfrdmod to be active with fates, again
rgknox Jun 14, 2022
cb71a47
Merge branch 'fates-params-api23' of github.com:rgknox/CTSM into fate…
ekluzek Jun 14, 2022
1558531
Modify the SP mode InterpMonthly call so will work with dry-depositio…
ekluzek Jun 14, 2022
f418d19
readAnnualVeg if dry-deposition even if FATES is on, and remove some …
ekluzek Jun 14, 2022
635cb1e
Make sure if FATES and DryDep is on SatellitePhenologyInit will be do…
ekluzek Jun 14, 2022
83433df
Work on comments a bit
ekluzek Jun 14, 2022
8fd708e
Add test that fails for FATES and n_dom_pfts
ekluzek Jun 14, 2022
3a20b10
Abort if FATES and n_dom_pft is on at the same time
ekluzek Jun 14, 2022
bc29236
Testing out new bounds system, adding surfpft_lb and ub
rgknox Jun 16, 2022
2d85b3e
Merge branch 'fates-params-api23' into fates_drydep_changes
ekluzek Jun 17, 2022
de1ca54
Minor code cleanup related to natpft_lb and natpft_ub having similar …
rgknox Jun 17, 2022
d3fa22b
Comment out the dry-dep change and add a note about it with the issue…
ekluzek Jun 17, 2022
37f25fb
Change if statements about drydep back to how they were before, but a…
ekluzek Jun 17, 2022
52e9ee1
Add a check that aborts if drydep or megan is on and FATES is on, out…
ekluzek Jun 17, 2022
b71d464
surfpft_lb and ub where required
ekluzek Jun 17, 2022
46e7697
This is required to get the FATES-SP drydep mode to work
ekluzek Jun 17, 2022
fc73c8a
Merge pull request #4 from ekluzek/fates_drydep_changes
rgknox Jun 19, 2022
1c66c59
reverted changes in subgridMod that were unused
rgknox Jun 19, 2022
7cb9f79
Removed misleading statement
rgknox Jun 19, 2022
1bc6e1e
Added intel compiler to tree damage test
rgknox Jun 20, 2022
92e98c7
Updating drydep check
rgknox Jun 20, 2022
a484ba1
Updated unit test to match args in clm_varpar
rgknox Jun 21, 2022
b75a508
Updated changelogs
rgknox Jun 21, 2022
6a4d9ed
Updated issues in the changelog
rgknox Jun 21, 2022
2ead5b8
Updated fates external pointer to sci.1.57.4_api.24.0.0
rgknox Jun 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Externals_CLM.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[fates]
local_path = src/fates
protocol = git
repo_url = https://github.com/NGEET/fates
tag = sci.1.56.0_api.23.0.0
repo_url = https://github.com/rgknox/fates
branch = params-maxpatch-logfinal
required = True

[externals_description]
Expand Down
4 changes: 2 additions & 2 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ sub setup_cmdl_fates_mode {
# dis-allow fates specific namelist items with non-fates runs
my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys",
"use_fates_cohort_age_tracking",
"use_fates_inventory_init","use_fates_fixed_biogeog","use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","use_fates_logging","fates_parteh_mode" );
"use_fates_inventory_init","use_fates_fixed_biogeog","use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","use_fates_logging","fates_parteh_mode","use_fates_tree_damage" );
# dis-allow fates specific namelist items with non-fates runs
foreach my $var ( @list ) {
if ( defined($nl->get_value($var)) ) {
Expand Down Expand Up @@ -4107,7 +4107,7 @@ sub setup_logic_fates {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'});
my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys",
"use_fates_inventory_init","use_fates_fixed_biogeog","use_fates_nocomp",
"use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking" );
"use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage" );
foreach my $var ( @list ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'},
'use_fates_sp'=>$nl_flags->{'use_fates_sp'} );
Expand Down
3 changes: 2 additions & 1 deletion bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- FATES default parameter file -->
<!-- ================================================================== -->

<fates_paramfile>lnd/clm2/paramdata/fates_params_api.22.1.0_12pft_c220307.nc</fates_paramfile>
<fates_paramfile>/glade/u/home/rgknox/ctsm/src/fates/parameter_files/fates_params_api.24.0.0_12pft_c220608.nc</fates_paramfile>
ekluzek marked this conversation as resolved.
Show resolved Hide resolved

<!-- ======================================================================================== -->
<!-- clm 5.0 BGC nitrogen model -->
Expand Down Expand Up @@ -2541,6 +2541,7 @@ lnd/clm2/surfdata_map/release-clm5.0.30/surfdata_ne0np4.CONUS.ne30x8_hist_78pfts
<!-- ===== FATES DEFAULTS =========== -->
<fates_spitfire_mode use_fates=".true.">0</fates_spitfire_mode>
<use_fates_planthydro use_fates=".true.">.false.</use_fates_planthydro>
<use_fates_tree_damage use_fates=".true.">.false.</use_fates_tree_damage>
<use_fates_cohort_age_tracking use_fates=".true.">.false.</use_fates_cohort_age_tracking>
<use_fates_ed_st3 use_fates=".true.">.false.</use_fates_ed_st3>
<use_fates_ed_prescribed_phys use_fates=".true.">.false.</use_fates_ed_prescribed_phys>
Expand Down
6 changes: 6 additions & 0 deletions bld/namelist_files/namelist_definition_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,12 @@ Switch deciding which nutrient model to use in FATES.
(Only relevant if FATES is on)
</entry>

<entry id="use_fates_tree_damage" type="logical" category="physics"
group="clm_inparm" valid_values="" value=".false.">
Toggle to turn on the tree damage module in FATES
(Only relevant if FATES is on)
</entry>

<entry id="fates_spitfire_mode" type="integer" category="physics"
group="clm_inparm" valid_values="0,1,2,3,4,5" value=".false.">
Turn on spitfire module to simulate fire by setting fates_spitfire_mode > 0.
Expand Down
2 changes: 1 addition & 1 deletion cime_config/testdefs/testlist_clm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@
<option name="comment">Short ERP debug FATES test for f19_g17 grid.</option>
</options>
</test>
<test name="ERP_D_P32x2_Ld3" grid="f19_g17" compset="I2000Clm50FatesCru" testmods="clm/FatesColdDef">
<test name="ERP_D_P36x2_Ld3" grid="f19_g17" compset="I2000Clm50FatesCru" testmods="clm/FatesColdDef">
<machines>
<machine name="cheyenne" compiler="intel" category="fates"/>
</machines>
Expand Down
11 changes: 11 additions & 0 deletions src/biogeochem/EDBGCDynMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ subroutine EDBGCDyn(bounds, &
call t_stopf('SoilBiogeochemLittVertTransp')
end if

!call FatesWrapWoodProducts(bounds, num_soilc, filter_soilc,c_products_inst)
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
!call t_startf('CNWoodProducts')
!call c_products_inst%UpdateProducts(bounds, &
! num_soilp, filter_soilp, &
! dwt_wood_product_gain_patch = cnveg_carbonflux_inst%dwt_wood_productc_gain_patch(begp:endp), &
! wood_harvest_patch = cnveg_carbonflux_inst%wood_harvestc_patch(begp:endp), &
! dwt_crop_product_gain_patch = cnveg_carbonflux_inst%dwt_crop_productc_gain_patch(begp:endp), &
! crop_harvest_to_cropprod_patch = cnveg_carbonflux_inst%crop_harvestc_to_cropprodc_patch(begp:endp))
!call t_stopf('CNWoodProducts')


end associate

end subroutine EDBGCDyn
Expand Down
4 changes: 2 additions & 2 deletions src/biogeochem/SatellitePhenologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ subroutine readAnnualVegetation (bounds, canopystate_inst)
write(iulog,*)trim(subname), 'ldomain%ns,ns,= ',ldomain%ns,ns
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

call check_dim_size(ncid, 'lsmpft', maxsoil_patches)

do k=1,12 !! loop over months and read vegetated data
Expand Down Expand Up @@ -392,7 +393,7 @@ subroutine readMonthlyVegetation (bounds, fveg, months, canopystate_inst)
!-----------------------------------------------------------------------

! Determine necessary indices

allocate(&
mlai(bounds%begg:bounds%endg,0:maxveg), &
msai(bounds%begg:bounds%endg,0:maxveg), &
Expand Down Expand Up @@ -452,7 +453,6 @@ subroutine readMonthlyVegetation (bounds, fveg, months, canopystate_inst)
mhvb2t(p,k) = 0._r8
end if
end do ! end of loop over patches

end do ! end of loop over months

call ncd_pio_closefile(ncid)
Expand Down
13 changes: 12 additions & 1 deletion src/main/clm_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,32 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
call t_stopf('interpMonthlyVeg')
endif

elseif(use_fates) then
ekluzek marked this conversation as resolved.
Show resolved Hide resolved

! FATES does not use any leaf/stem/htop data unless in satphen mode
if ( use_fates_sp) then
call t_startf('interpMonthlyVeg')
call interpMonthlyVeg(bounds_proc, canopystate_inst)
call t_stopf('interpMonthlyVeg')
end if

else

! Determine weights for time interpolation of monthly vegetation data.
! This also determines whether it is time to read new monthly vegetation and
! obtain updated leaf area index [mlai1,mlai2], stem area index [msai1,msai2],
! vegetation top [mhvt1,mhvt2] and vegetation bottom [mhvb1,mhvb2]. The
! weights obtained here are used in subroutine SatellitePhenology to obtain time
! interpolated values.
if (doalb .or. ( n_drydep > 0 .and. drydep_method == DD_XLND ) .or. use_fates_sp) then
if ( doalb .or. ( n_drydep > 0 .and. drydep_method == DD_XLND ) )then
call t_startf('interpMonthlyVeg')
call interpMonthlyVeg(bounds_proc, canopystate_inst)
call t_stopf('interpMonthlyVeg')
end if

end if


! ==================================================================================
! Determine decomp vertical profiles
!
Expand Down
72 changes: 47 additions & 25 deletions src/main/clm_initializeMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module clm_initializeMod
use PatchType , only : patch ! instance
use reweightMod , only : reweight_wrapup
use filterMod , only : allocFilters, filter, filter_inactive_and_active
use CLMFatesInterfaceMod , only : CLMFatesGlobals
use CLMFatesInterfaceMod , only : CLMFatesGlobals1,CLMFatesGlobals2
use CLMFatesInterfaceMod , only : CLMFatesTimesteps
use dynSubgridControlMod , only : dynSubgridControl_init, get_reset_dynbal_baselines
use SelfTestDriver , only : self_test_driver
Expand All @@ -40,7 +40,8 @@ module clm_initializeMod
public :: initialize2 ! Phase two initialization

integer :: actual_numcft ! numcft from sfc dataset

integer :: actual_numpft ! numpft from sfc dataset

!-----------------------------------------------------------------------
contains
!-----------------------------------------------------------------------
Expand Down Expand Up @@ -96,8 +97,19 @@ subroutine initialize1(dtime)

call control_init(dtime)
call ncd_pio_init()
call surfrd_get_num_patches(fsurdat, actual_maxsoil_patches, actual_numcft)
call clm_varpar_init(actual_maxsoil_patches, actual_numcft)
call surfrd_get_num_patches(fsurdat, actual_maxsoil_patches, actual_numpft, actual_numcft)

if(use_fates) then

! If fates is on, we override actual_maxsoil_patches. FATES dictates the
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
! number of patches per column. We still use numcft from the surface
! file though...

call CLMFatesGlobals1(actual_numpft, actual_numcft, actual_maxsoil_patches)

end if

call clm_varpar_init(actual_maxsoil_patches, actual_numpft, actual_numcft)
call decomp_cascade_par_init( NLFilename )
call clm_varcon_init( IsSimpleBuildTemp() )
call landunit_varcon_init()
Expand All @@ -119,6 +131,7 @@ subroutine initialize2(ni,nj)
use clm_varcon , only : spval
use clm_varpar , only : natpft_lb, natpft_ub, cft_lb, cft_ub, maxpatch_glc
use clm_varpar , only : nlevsno
use clm_varpar , only : natpft_size,cft_size
use clm_varctl , only : fsurdat
use clm_varctl , only : finidat, finidat_interp_source, finidat_interp_dest, fsurdat
use clm_varctl , only : use_cn, use_fates
Expand Down Expand Up @@ -210,36 +223,40 @@ subroutine initialize2(ni,nj)
! Allocate surface grid dynamic memory (just gridcell bounds dependent)
allocate (wt_lunit (begg:endg, max_lunit ))
allocate (urban_valid (begg:endg ))
allocate (wt_nat_patch (begg:endg, natpft_lb:natpft_ub ))
allocate (wt_cft (begg:endg, cft_lb:cft_ub ))
allocate (fert_cft (begg:endg, cft_lb:cft_ub ))
allocate (irrig_method (begg:endg, cft_lb:cft_ub ))
allocate (wt_glc_mec (begg:endg, maxpatch_glc ))
allocate (topo_glc_mec (begg:endg, maxpatch_glc ))
allocate (haslake (begg:endg ))
allocate (pct_urban_max(begg:endg, numurbl ))

allocate (wt_nat_patch (begg:endg, natpft_lb:natpft_ub ))

! Read list of Patches and their corresponding parameter values
! Independent of model resolution, Needs to stay before surfrd_get_data
call pftcon%Init()

! Read surface dataset and set up subgrid weight arrays
call surfrd_get_data(begg, endg, ldomain, fsurdat, actual_numcft)

! Ask Fates to evaluate its own dimensioning needs.
! This determines the total amount of space it requires in its largest
! dimension. We are currently calling that the "cohort" dimension, but
! it is really a utility dimension that captures the models largest
! size need.
! Sets:
! fates_maxElementsPerPatch
! fates_maxElementsPerSite (where a site is roughly equivalent to a column)
! (Note: fates_maxELementsPerSite is the critical variable used by CLM
! to allocate space)
! This also sets up various global constants in FATES
! ------------------------------------------------------------------------

call CLMFatesGlobals()
if(use_fates) then

! Ask Fates to evaluate its own dimensioning needs.
! This determines the total amount of space it requires in its largest
! dimension. We are currently calling that the "cohort" dimension, but
! it is really a utility dimension that captures the models largest
! size need.
! Sets:
! fates_maxElementsPerPatch
! fates_maxElementsPerSite (where a site is roughly equivalent to a column)
! (Note: fates_maxELementsPerSite is the critical variable used by CLM
! to allocate space)
! This also sets up various global constants in FATES
! ------------------------------------------------------------------------

call CLMFatesGlobals2()

end if

! Determine decomposition of subgrid scale landunits, columns, patches
call decompInit_clumps(ni, nj, glc_behavior)
Expand Down Expand Up @@ -425,12 +442,17 @@ subroutine initialize2(ni,nj)
if ( use_c13 .and. use_c13_timeseries ) then
call C13_init_TimeSeries()
end if

else
call SatellitePhenologyInit(bounds_proc)
! FATES OR Satellite phenology

if(use_fates_sp .or. .not.use_fates)then
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
call SatellitePhenologyInit(bounds_proc)
end if

! fates_spitfire_mode is assigned an integer value in the namelist
! see bld/namelist_files/namelist_definition_clm4_5.xml for details
if (fates_spitfire_mode > scalar_lightning) then
if(use_fates .and. (fates_spitfire_mode > scalar_lightning)) then
call clm_fates%Init2(bounds_proc, NLFilename)
end if
end if
Expand Down Expand Up @@ -591,7 +613,7 @@ subroutine initialize2(ni,nj)
! Read monthly vegetation
! Even if CN is on, and dry-deposition is active, read CLMSP annual vegetation
! to get estimates of monthly LAI
if ( n_drydep > 0 .and. drydep_method == DD_XLND )then
if ( n_drydep > 0 .and. drydep_method == DD_XLND .and. .not.use_fates )then
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
call readAnnualVegetation(bounds_proc, canopystate_inst)
if (nsrest == nsrStartup .and. finidat /= ' ') then
! Call interpMonthlyVeg for dry-deposition so that mlaidiff will be calculated
Expand All @@ -601,9 +623,9 @@ subroutine initialize2(ni,nj)
! If fates has satellite phenology enabled, get the monthly veg values
! prior to the first call to SatellitePhenology()
elseif ( use_fates_sp ) then
call interpMonthlyVeg(bounds_proc, canopystate_inst)
call interpMonthlyVeg(bounds_proc, canopystate_inst)
end if

! Determine gridcell averaged properties to send to atm
if (nsrest == nsrStartup) then
call t_startf('init_map2gc')
Expand Down
1 change: 1 addition & 0 deletions src/main/clm_varctl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ module clm_varctl
integer, public :: fates_spitfire_mode = 0
! 0 for no fire; 1 for constant ignitions; > 1 for external data (lightning and/or anthropogenic ignitions)
! see bld/namelist_files/namelist_definition_clm4_5.xml for details
logical, public :: use_fates_tree_damage = .false. ! true => turn on tree damage module
logical, public :: use_fates_logging = .false. ! true => turn on logging module
logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro
logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking
Expand Down
55 changes: 39 additions & 16 deletions src/main/clm_varpar.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module clm_varpar
integer, public :: nlayert ! number of VIC soil layer + 3 lower thermal layers
integer, public, parameter :: nvariants = 2 ! number of variants of PFT constants

integer, public :: maxveg ! # of pfts + cfts
integer, public :: maxveg ! # of pfts + cfts
integer, public :: maxpatch_urb= 5 ! max number of urban patches (columns) in urban landunit

integer, public :: maxsoil_patches ! # of pfts + cfts + bare ground; replaces maxpatch_pft, which is obsolete
Expand Down Expand Up @@ -110,25 +110,25 @@ module clm_varpar
contains

!------------------------------------------------------------------------------
subroutine clm_varpar_init(actual_maxsoil_patches, actual_numcft)
subroutine clm_varpar_init(actual_maxsoil_patches, surf_numpft, surf_numcft)
!
! !DESCRIPTION:
! Initialize module variables
!
! !ARGUMENTS:
implicit none
integer, intent(in) :: actual_maxsoil_patches ! value from surface dataset
integer, intent(in) :: actual_numcft ! Actual number of crops
integer, intent(in) :: actual_maxsoil_patches ! Number of soil patches to allocate
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
integer, intent(in) :: surf_numpft ! Number of PFTs in the surf dataset
integer, intent(in) :: surf_numcft ! Number of CFTs in the surf dataset
!
! !LOCAL VARIABLES:
!
integer :: j ! loop index
character(len=32) :: subname = 'clm_varpar_init' ! subroutine name
!------------------------------------------------------------------------------

! actual_maxsoil_patches and actual_numcft were read directly from the
! surface dataset
maxsoil_patches = actual_maxsoil_patches ! # of patches with bare ground

maxveg = maxsoil_patches - 1 ! # of patches without bare ground

! For arrays containing all Patches (natural veg & crop), determine lower and upper bounds
Expand All @@ -137,26 +137,49 @@ subroutine clm_varpar_init(actual_maxsoil_patches, actual_numcft)
! if create_crop_landunit=false)

if (create_crop_landunit) then
natpft_size = maxsoil_patches - actual_numcft ! includes bare ground
cft_size = actual_numcft

natpft_size = surf_numpft ! includes bare ground + natveg pfts
cft_size = surf_numcft
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
natpft_lb = 0
natpft_ub = natpft_lb + natpft_size - 1
cft_lb = natpft_ub + 1
cft_ub = cft_lb + cft_size - 1

else
natpft_size = maxsoil_patches ! includes bare ground

! FATES
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
! These values are used to create the wt_nat_patch
! array that is used by fates_sp and fixed biogeog.
! Also, the pft and cft vectors are concatenated into
! the natpft vector (wt_nat_patch), the wt_cft array is unused (size zero)
! The following values should not be used for allocating patch structures
! though. That should be handled completely by maxoil_patches and maxveg

natpft_size = surf_numpft+surf_numcft
cft_size = 0
end if
natpft_lb = 0
natpft_ub = surf_numpft+surf_numcft-1
cft_lb = 0
cft_ub = 0

natpft_lb = 0
natpft_ub = natpft_lb + natpft_size - 1
cft_lb = natpft_ub + 1
cft_ub = cft_lb + cft_size - 1
if(use_fates_sp)then
if(natpft_ub .ne. maxveg) then
write(iulog,*) 'when fates is in SP mode, maxveg should match the upper bound'
write(iulog,*) 'on the surface dataset PFT+CFT indices (ie lsmft), yours: ',natpft_ub,maxveg
! can't endrun due to circular dependencies?
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
end if
end if
ekluzek marked this conversation as resolved.
Show resolved Hide resolved

end if

mxharvests = mxsowings + 1

! TODO(wjs, 2015-10-04, bugz 2227) Using actual_numcft in this 'max' gives a significant
! TODO(wjs, 2015-10-04, bugz 2227) Using surf_numcft in this 'max' gives a significant
! overestimate of max_patch_per_col when use_crop is true. This should be reworked -
! or, better, removed from the code entirely (because it is a maintenance problem, and
! I can't imagine that looping idioms that use it help performance that much, and
! likely they hurt performance.)
max_patch_per_col= max(maxsoil_patches, actual_numcft, maxpatch_urb)
max_patch_per_col= max(maxsoil_patches, surf_numcft, maxpatch_urb)

nlevsoifl = 10
nlevurb = 5
Expand Down
Loading