diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index c22b5e12ff..83bcf09b2e 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -227,7 +227,7 @@ subroutine initialize2(ni,nj) 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 )) + allocate (wt_nat_patch (begg:endg, surfpft_lb:surfpft_ub )) ! Read list of Patches and their corresponding parameter values ! Independent of model resolution, Needs to stay before surfrd_get_data diff --git a/src/main/clm_varpar.F90 b/src/main/clm_varpar.F90 index 6b88961998..23b237d6f3 100644 --- a/src/main/clm_varpar.F90 +++ b/src/main/clm_varpar.F90 @@ -90,6 +90,12 @@ module clm_varpar integer, public :: natpft_ub ! In PATCH arrays, upper bound of Patches on the natural veg landunit integer, public :: natpft_size ! Number of Patches on natural veg landunit (including bare ground) + integer, public :: surfpft_lb ! Lower bound of PFTs in the surface file + ! synonymous with natpft_lb for non-fates and fates-sp + integer, public :: surfpft_ub ! Upper bound of PFTs in the surface file + ! synonymous with natpft_ub for non-fates and fates-sp + + ! The following variables pertain to arrays of all PFTs - e.g., those dimensioned (g, ! pft_index). These include unused CFTs that are merged into other CFTs. Thus, these ! variables do NOT give the actual number of CFTs on the crop landunit - that number @@ -158,26 +164,28 @@ subroutine clm_varpar_init(actual_maxsoil_patches, surf_numpft, surf_numcft) natpft_ub = natpft_lb + natpft_size - 1 cft_lb = natpft_ub + 1 cft_ub = cft_lb + cft_size - 1 - + surfpft_lb = natpft_lb + surfpft_ub = natpft_ub + else ! only true when FATES is active - natpft_size = surf_numpft+surf_numcft + natpft_size = maxsoil_patches cft_size = 0 natpft_lb = 0 - natpft_ub = surf_numpft+surf_numcft-1 + natpft_ub = natpft_lb + natpft_size - 1 cft_lb = 0 cft_ub = 0 + surfpft_lb = 0 + surfpft_ub = surf_numpft+surf_numcft-1 end if - if(.not.use_fates .or. use_fates_sp)then - if(natpft_ub .ne. maxveg) then - write(iulog,*) 'maxveg should match the upper bound for non-fates and fates-sp runs' - write(iulog,*) 'the surface dataset PFT+CFT indices (ie lsmft), yours: ',natpft_ub,maxveg - call shr_sys_abort(subname//' ERROR: conflict in maxveg and pft bounds') - end if + if(use_fates_sp .and. (natpft_ub .ne. maxveg) ) then + write(iulog,*) 'maxveg should match the upper bound for non-fates and fates-sp runs' + write(iulog,*) 'the surface dataset PFT+CFT indices (ie lsmft), yours: ',natpft_ub,maxveg + call shr_sys_abort(subname//' ERROR: conflict in maxveg and pft bounds') end if - + mxharvests = mxsowings + 1 ! TODO(wjs, 2015-10-04, bugz 2227) Using surf_numcft in this 'max' gives a significant diff --git a/src/main/surfrdMod.F90 b/src/main/surfrdMod.F90 index 66d4e87c00..e3ba66405c 100644 --- a/src/main/surfrdMod.F90 +++ b/src/main/surfrdMod.F90 @@ -564,7 +564,7 @@ subroutine surfrd_wtfates( ncid, begg, endg ) ! !USES: use clm_instur , only : wt_nat_patch, wt_lunit - use clm_varpar , only : cft_size, natpft_size + use clm_varpar , only : cft_size, surfpft_lb, surfpft_ub use landunit_varcon , only : istsoil, istcrop ! !ARGUMENTS: @@ -586,8 +586,8 @@ subroutine surfrd_wtfates( ncid, begg, endg ) call ncd_inqdlen(ncid, dimid, natpft_dimlen, 'natpft') ! double check that cft_dimlen+natpft_dimlen = natpft_size - if((cft_dimlen+natpft_dimlen).ne.natpft_size)then - call endrun( msg=' ERROR: PCT+CFT dimlen does not match natpft_size when fates is on'//errMsg(sourcefile, __LINE__)) + if((cft_dimlen+natpft_dimlen).ne.(surfpft_ub-surfpft_lb+1))then + call endrun( msg=' ERROR: PCT+CFT dimlen does not match array size for wt_nat_patch when fates is on'//errMsg(sourcefile, __LINE__)) end if allocate( array2d_cft(begg:endg,1:cft_dimlen) ) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 998b780c4b..9a04a9d66f 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -67,8 +67,7 @@ module CLMFatesInterfaceMod use clm_varcon , only : spval use clm_varcon , only : denice use clm_varcon , only : ispval - !use clm_varpar , only : natpft_size, cft_size - use clm_varpar , only : natpft_lb, natpft_ub + use clm_varpar , only : surfpft_lb,surfpft_ub use clm_varpar , only : numrad use clm_varpar , only : ivis use clm_varpar , only : inir @@ -694,7 +693,7 @@ subroutine init(this, bounds_proc ) ndecomp = col%nbedrock(c) - call allocate_bcin(this%fates(nc)%bc_in(s),col%nbedrock(c),ndecomp, num_harvest_inst,natpft_lb,natpft_ub) + call allocate_bcin(this%fates(nc)%bc_in(s),col%nbedrock(c),ndecomp, num_harvest_inst,surfpft_lb,surfpft_ub) call allocate_bcout(this%fates(nc)%bc_out(s),col%nbedrock(c),ndecomp) call zero_bcs(this%fates(nc),s) @@ -708,12 +707,12 @@ subroutine init(this, bounds_proc ) this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 ! initialize static layers for reduced complexity FATES versions from HLM ! maybe make this into a subroutine of it's own later. - do m = natpft_lb,natpft_ub - ft = m - natpft_lb + do m = surfpft_lb,surfpft_ub + ft = m - surfpft_lb this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) end do - if(abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(natpft_lb:natpft_ub))-1.0_r8).gt.1.0e-9)then + if(abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub))-1.0_r8).gt.1.0e-9)then write(iulog,*) 'pft_area error in interfc ',s, sum(this%fates(nc)%bc_in(s)%pft_areafrac(:))-1.0_r8 call endrun(msg=errMsg(sourcefile, __LINE__)) endif @@ -954,7 +953,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! in FATES. ! N.B. Fow now these are fixed values pending HLM updates. if(use_fates_sp)then - do ft = natpft_lb,natpft_ub + do ft = surfpft_lb,surfpft_ub ! here we are mapping from P space in the HLM to FT space in the sp_input arrays. p = ft + col%patchi(c) ! for an FT of 1 we want to use this%fates(nc)%bc_in(s)%hlm_sp_tlai(ft) = canopystate_inst%tlai_patch(p) @@ -1593,7 +1592,7 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, & if(use_fates_sp)then do s = 1,this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) - do ft = natpft_lb,natpft_ub !set of pfts in HLM + do ft = surfpft_lb,surfpft_ub !set of pfts in HLM ! here we are mapping from P space in the HLM to FT space in the sp_input arrays. p = ft + col%patchi(c) ! for an FT of 1 we want to use this%fates(nc)%bc_in(s)%hlm_sp_tlai(ft) = canopystate_inst%tlai_patch(p) @@ -1740,7 +1739,7 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & if(use_fates_sp)then do s = 1,this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) - do ft = natpft_lb,natpft_ub + do ft = surfpft_lb,surfpft_ub ! here we are mapping from P space in the HLM to FT space in the sp_input arrays. p = ft + col%patchi(c) ! for an FT of 1 we want to use this%fates(nc)%bc_in(s)%hlm_sp_tlai(ft) = canopystate_inst%tlai_patch(p)