Skip to content

Commit

Permalink
Bugfix for zeroing data and indexing grperc
Browse files Browse the repository at this point in the history
Merge branch 'rgknox-bugfix36-bugfix4'

Simple fixes that address issues #36 and #4. The fix to issue #4 was
trivial. In the fix to #36 I also checked through the code to assess
under which conditions zero'ing variables such as tlai and tsai would
affect other non-ed parts of the code. The fix allows the zeroing of
the LAI/SAI variables and htop/hbot variables at the patch level
because ED is the only submodule that will currently touch
them. However, moving forward we must be very careful of how other
modules potentially use these patch vectors. It is possible that a
crop model may exist on the same column, and therefore we don't want
to interact with those patches. Although, as far as I know, ACME for
instance may put crops on another column (now, future). Either way,
the changes here should make that zeroing procedure more future proof
by only zeroing natural vegetation, and should also be more efficient
by not constantly zeroing things that don't need zeroing.

Fixes: #36 #4

User interface changes?: No

Code review: rgknox

Test suite: ed - lawrencium-lr3, intel; yellowstone, gnu, intel, pgi

Test baseline: 5421da5
Test namelist changes: none
Test answer changes: b4b

Test summary: pass except for expected fails, f19 and f09 restarts
  • Loading branch information
bandre-ucar committed May 20, 2016
2 parents 081925b + 224e662 commit 3eb784a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ subroutine trim_canopy( currentSite )
currentCohort%leaf_cost = 1._r8/(pftcon%slatop(currentCohort%pft)*1000.0_r8)
currentCohort%leaf_cost = currentCohort%leaf_cost + 1.0_r8/(pftcon%slatop(currentCohort%pft)*1000.0_r8) * &
pftcon%froot_leaf(currentCohort%pft) / EDecophyscon%root_long(currentCohort%pft)
currentCohort%leaf_cost = currentCohort%leaf_cost * (ED_val_grperc(1) + 1._r8)
currentCohort%leaf_cost = currentCohort%leaf_cost * (ED_val_grperc(currentCohort%pft) + 1._r8)
else !evergreen costs
currentCohort%leaf_cost = 1.0_r8/(pftcon%slatop(currentCohort%pft)* &
pftcon%leaf_long(currentCohort%pft)*1000.0_r8) !convert from sla in m2g-1 to m2kg-1
currentCohort%leaf_cost = currentCohort%leaf_cost + 1.0_r8/(pftcon%slatop(currentCohort%pft)*1000.0_r8) * &
pftcon%froot_leaf(currentCohort%pft) / EDecophyscon%root_long(currentCohort%pft)
currentCohort%leaf_cost = currentCohort%leaf_cost * (ED_val_grperc(1) + 1._r8)
currentCohort%leaf_cost = currentCohort%leaf_cost * (ED_val_grperc(currentCohort%pft) + 1._r8)
endif
if (currentCohort%year_net_uptake(z) < currentCohort%leaf_cost)then
if (currentCohort%canopy_trim > trim_limit)then
Expand Down
34 changes: 18 additions & 16 deletions main/EDCLMLinkMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,8 @@ subroutine ed_clm_link( this, bounds, ed_allsites_inst, ed_phenology_inst, &
real(r8) :: canopy_leaf_area ! total amount of leaf area in the vegetated area. m2.
integer :: sitecolumn(bounds%begg:bounds%endg)
logical :: istheresoil(bounds%begg:bounds%endg)
integer :: begp_fp, endp_fp ! Valid range of patch indices that are associated with
! FATES (F) for each parent (P) iteration (grid/column)
!----------------------------------------------------------------------

if ( DEBUG ) then
Expand Down Expand Up @@ -1034,31 +1036,31 @@ subroutine ed_clm_link( this, bounds, ed_allsites_inst, ed_phenology_inst, &
endif
enddo

! ============================================================================
! Zero the whole variable so we dont have ghost values when patch number declines.
! ============================================================================

clmpatch%is_veg(begp:endp) = .false.
clmpatch%is_bareground(begp:endp) = .false.
tlai(begp:endp) = 0.0_r8
elai(firstsoilpatch(g)) = 0.0_r8
tsai(firstsoilpatch(g)) = 0.0_r8
esai(firstsoilpatch(g)) = 0.0_r8
htop(begp:endp) = 0.0_r8
hbot(begp:endp) = 0.0_r8

do g = begg,endg

if(firstsoilpatch(g) >= 0.and.ed_allsites_inst(g)%istheresoil)then
ed_allsites_inst(g)%clmcolumn = sitecolumn(g)

! ============================================================================
! Zero the bare ground tile BGC variables.
! Valid Range for zero'ing here is the soil_patch and non crop patches
! If the crops are not turned on, don't worry, they were zero'd once and should
! not change again (RGK).
! firstsoilpatch(g) + numpft - numcft
! ============================================================================

tlai(firstsoilpatch(g)) = 0.0_r8
htop(firstsoilpatch(g)) = 0.0_r8
hbot(firstsoilpatch(g)) = 0.0_r8
begp_fp = firstsoilpatch(g)
endp_fp = firstsoilpatch(g) + numpft - numcft

clmpatch%is_veg(begp_fp:endp_fp) = .false.
clmpatch%is_bareground(begp_fp:endp_fp) = .false.
tlai(begp_fp:endp_fp) = 0.0_r8
htop(begp_fp:endp_fp) = 0.0_r8
hbot(begp_fp:endp_fp) = 0.0_r8
elai(begp_fp:endp_fp) = 0.0_r8
tsai(begp_fp:endp_fp) = 0.0_r8
esai(begp_fp:endp_fp) = 0.0_r8


patchn = 0
total_bare_ground = 0.0_r8
Expand Down

0 comments on commit 3eb784a

Please sign in to comment.