Skip to content

Commit

Permalink
Added three new history variable dimensions
Browse files Browse the repository at this point in the history
Merge branch 'switch_pftvars_dims'

Added three new history variable dimensions: size, age, and PFT.

Previously you could add variables on a multiplexed size x PFT
dimension, but not just size, and just PFT was using the levsoi
dimension instead of its own dedicated dimension. Also there was no
way to output things binned by patch-age, and the multiplexed
dimension is a bit unwieldy such that none of those variables are
default-on. Since the dimension definitions straddle the FATES-HLM
interface, fixing these will be trickier to change once the interface
is in place; also we will soon want the mxpft that sets the length of
the PFT dimension to be a runtime-set parameter, so separating it from
nlevsoi removes a currently-implied dependency that mxpft must be less
than nlevsoi. In addition to adding these dimensions, I also pulled
all the old PFT-resolved variables off of the nlevsoi axis and onto
the new PFT axis, and added some new variables on the size and age
axes. These include a default-on basal area by size class diagnostic,
and some new diagnostics about the patch age distribution, npp, gpp,
and canopy and leaf areas resolved by patch age.

Fixes: #145

User interface changes?: No

Code review: went over most of the code with @rgknox

Testing:
  ckoven:
    Test suite: ed test suite on lawrencium-lr3, intel
    Test baseline: a5dc8da
    Test namelist changes: n/a
    Test answer changes: bit for bit
    Test summary: ALL PASS

  andre:
    Test suite: ed - yellowstone gnu, intel, pgi
                     hobart nag
    Test baseline: a1c3d20
    Test namelist changes: none
    Test answer changes: bit for bit - see note
    Test summary: ok, functionality tests pass, baselines ok.

    Test suite: clm_short - yellowstone gnu, intel, pgi
    Test baseline: clm4_5_12_r195
    Test namelist changes: none
    Test answer changes: bit for bit - see note
    Test summary: ok, functionality tests pass, baselines ok.

    NOTE: cprnc does not compare variables when the dimensions have
    changed. Since the dimensions of some varibles have changed with
    this work, those variables can not be confirmed to be bit for
    bit. Depending on the version of cprnc that is installed this
    skipping of variables is either silently ignored or triggers an
    error resulting in a test failure. The cprnc on hobart (and I
    assume lrc) ignore this difference. The cprnc on yellowstone
    reports these a test failures. Passing baseline comparisons on
    hobart and no RMS differences on yellowstone support that this is
    still bit for bit for the checked fields.
  • Loading branch information
bandre-ucar committed Feb 3, 2017
2 parents f31a2fe + 706df0a commit eec3a50
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 43 deletions.
6 changes: 4 additions & 2 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ subroutine create_patch(currentSite, new_patch, age, areap, spread_local,cwd_ag_

new_patch%siteptr => currentSite
new_patch%age = age
new_patch%age_class = 1
new_patch%area = areap
new_patch%spread = spread_local
new_patch%cwd_ag = cwd_ag_local
Expand Down Expand Up @@ -899,6 +900,7 @@ subroutine zero_patch(cp_p)
currentPatch%clm_pno = 999

currentPatch%age = nan
currentPatch%age_class = 1
currentPatch%area = nan
currentPatch%canopy_layer_lai(:) = nan
currentPatch%total_canopy_area = nan
Expand Down Expand Up @@ -935,8 +937,6 @@ subroutine zero_patch(cp_p)
currentPatch%lai = nan ! leaf area index of patch
currentPatch%spread(:) = nan ! dynamic ratio of dbh to canopy area.
currentPatch%pft_agb_profile(:,:) = nan
currentPatch%gpp = 0._r8
currentPatch%npp = 0._r8

! DISTURBANCE
currentPatch%disturbance_rates = 0._r8
Expand Down Expand Up @@ -1150,6 +1150,7 @@ subroutine fuse_2_patches(dp, rp)
! associated with the secnd patch
!
! !USES:
use EDTypesMod, only: ageclass_ed
!
! !ARGUMENTS:
type (ed_patch_type) , intent(inout), pointer :: dp ! Donor Patch
Expand All @@ -1169,6 +1170,7 @@ subroutine fuse_2_patches(dp, rp)

!area weighted average of ages & litter
rp%age = (dp%age * dp%area + rp%age * rp%area)/(dp%area + rp%area)
rp%age_class = count(rp%age-ageclass_ed.ge.0.0_r8)

do p = 1,numpft_ed
rp%seeds_in(p) = (rp%seeds_in(p)*rp%area + dp%seeds_in(p)*dp%area)/(rp%area + dp%area)
Expand Down
4 changes: 4 additions & 0 deletions main/EDMainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ subroutine ed_integrate_state_variables(currentSite, bc_in )
! FIX(SPM,032414) refactor so everything goes through interface
!
! !USES:
use EDTypesMod, only : ageclass_ed
!
! !ARGUMENTS:
type(ed_site_type) , intent(inout) :: currentSite
Expand Down Expand Up @@ -177,6 +178,9 @@ subroutine ed_integrate_state_variables(currentSite, bc_in )
currentPatch%patchno,currentPatch%area
endif

! check to see if the patch has moved to the next age class
currentPatch%age_class = count(currentPatch%age-ageclass_ed.ge.0.0_r8)

! Find the derivatives of the growth and litter processes.
call canopy_derivs(currentSite, currentPatch, bc_in)

Expand Down
21 changes: 17 additions & 4 deletions main/EDTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ module EDTypesMod
! real(r8), parameter, dimension(16) :: sclass_ed = (/0.0_r8,1.0_r8,2.0_r8,3.0_r8,4.0_r8,5.0_r8,10.0_r8,20.0_r8,30.0_r8,40.0_r8, &
! 50.0_r8,60.0_r8,70.0_r8,80.0_r8,90.0_r8,100.0_r8/)

real(r8), parameter, dimension(13) :: sclass_ed = (/0.0_r8,5.0_r8,10.0_r8,15.0_r8,20.0_r8,30.0_r8,40.0_r8, &
real(r8), parameter, dimension(nlevsclass_ed) :: sclass_ed = (/0.0_r8,5.0_r8,10.0_r8,15.0_r8,20.0_r8,30.0_r8,40.0_r8, &
50.0_r8,60.0_r8,70.0_r8,80.0_r8,90.0_r8,100.0_r8/)

integer, parameter :: nlevage_ed = 7 ! Number of patch-age classes for age structured analyses
real(r8), parameter, dimension(nlevage_ed) :: ageclass_ed = (/0.0_r8,1.0_r8,2._r8,5.0_r8,10.0_r8,20.0_r8,50.0_r8/)


! integer, parameter :: nlevsclass_ed = 17
! real(r8), parameter, dimension(17) :: sclass_ed = (/0.1_r8, 5.0_r8,10.0_r8,15.0_r8,20.0_r8,25.0_r8, &
Expand All @@ -99,13 +102,15 @@ module EDTypesMod
character(len = 10), parameter,dimension(5) :: char_list = (/"background","hydraulic ","carbon ","impact ","fire "/)


! These three vectors are used for history output mapping
! These vectors are used for history output mapping
real(r8) ,allocatable :: levsclass_ed(:) ! The lower bound on size classes for ED trees. This
! is used really for IO into the
! history tapes. It gets copied from
! the parameter array sclass_ed.
integer , allocatable :: pft_levscpf_ed(:)
integer , allocatable :: scls_levscpf_ed(:)
real(r8), allocatable :: levage_ed(:)
integer , allocatable :: levpft_ed(:)


! Control Parameters (cp_)
Expand Down Expand Up @@ -325,6 +330,7 @@ module EDTypesMod

! PATCH INFO
real(r8) :: age ! average patch age: years
integer :: age_class ! age class of the patch for history binning purposes
real(r8) :: area ! patch area: m2
integer :: countcohorts ! Number of cohorts in patch
integer :: ncl_p ! Number of occupied canopy layers
Expand Down Expand Up @@ -388,8 +394,6 @@ module EDTypesMod

! PHOTOSYNTHESIS
real(r8) :: psn_z(cp_nclmax,numpft_ed,cp_nlevcan) ! carbon assimilation in each canopy layer, pft, and leaf layer. umolC/m2/s
real(r8) :: gpp ! total patch gpp: KgC/m2/year
real(r8) :: npp ! total patch npp: KgC/m2/year

! ROOTS
real(r8), allocatable :: rootfr_ft(:,:) ! root fraction of each PFT in each soil layer:-
Expand Down Expand Up @@ -585,11 +589,20 @@ subroutine ed_hist_scpfmaps
allocate( levsclass_ed(1:nlevsclass_ed ))
allocate( pft_levscpf_ed(1:nlevsclass_ed*mxpft))
allocate(scls_levscpf_ed(1:nlevsclass_ed*mxpft))
allocate( levpft_ed(1:mxpft ))
allocate( levage_ed(1:nlevage_ed ))

! Fill the IO array of plant size classes
! For some reason the history files did not like
! a hard allocation of sclass_ed
levsclass_ed(:) = sclass_ed(:)

levage_ed(:) = ageclass_ed(:)

! make pft array
do ipft=1,mxpft
levpft_ed(ipft) = ipft
end do

! Fill the IO arrays that match pft and size class to their combined array
i=0
Expand Down
Loading

0 comments on commit eec3a50

Please sign in to comment.