Skip to content

Commit

Permalink
Small bug fix on previous merge conflict. Changed index ordering on t…
Browse files Browse the repository at this point in the history
…emp photosynthesis arrays for performance. Added in a fix currently in another PR to help with testing (npp_acc in copy cohort).
  • Loading branch information
rgknox committed Jan 9, 2017
1 parent 492c1cb commit af3bb56
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
4 changes: 3 additions & 1 deletion components/clm/src/ED/biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1037,13 +1037,15 @@ subroutine copy_cohort( currentCohort,copyc )
n%gpp_acc_hold = o%gpp_acc_hold
n%gpp_acc = o%gpp_acc
n%gpp_tstep = o%gpp_tstep

n%npp_acc_hold = o%npp_acc_hold
n%npp_tstep = o%npp_tstep

if ( DEBUG ) write(fates_log(),*) 'EDcohortDyn Ia ',o%npp_acc
if ( DEBUG ) write(fates_log(),*) 'EDcohortDyn Ib ',o%resp_acc

n%npp_acc_hold = o%npp_acc_hold
n%npp_acc = o%npp_acc

n%resp_tstep = o%resp_tstep
n%resp_acc = o%resp_acc
n%resp_acc_hold = o%resp_acc_hold
Expand Down
41 changes: 23 additions & 18 deletions components/clm/src/ED/biogeophys/FatesPlantRespPhotosynthMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,25 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
! allocated for the maximum space of the two cases (numCohortsPerPatch)
! The "_z" suffix indicates these variables are discretized at the "leaf_layer"
! scale.
! Note: For these temporary arrays, we have the leaf layer dimension first
! and the canopy layer last. This order is chosen for efficiency. The arrays
! such as leaf area that are bound to the patch structure DO NOT follow this order
! as they are used in many other parts of the code with different looping, we
! are not modifying its order now.
! -----------------------------------------------------------------------------------

! leaf maintenance (dark) respiration (umol CO2/m**2/s) Double check this
real(r8) :: lmr_z(cp_nclmax,mxpft,cp_nlevcan)
real(r8) :: lmr_z(cp_nlevcan,mxpft,cp_nclmax)

! stomatal resistance s/m
real(r8) :: rs_z(cp_nclmax,mxpft,cp_nlevcan)
real(r8) :: rs_z(cp_nlevcan,mxpft,cp_nclmax)

! net leaf photosynthesis averaged over sun and shade leaves. (umol CO2/m**2/s)
real(r8) :: anet_av_z(cp_nclmax,mxpft,cp_nlevcan)
real(r8) :: anet_av_z(cp_nlevcan,mxpft,cp_nclmax)

! Mask used to determine which leaf-layer biophysical rates have been
! used already
logical :: rate_mask_z(cp_nclmax,mxpft,cp_nlevcan)
logical :: rate_mask_z(cp_nlevcan,mxpft,cp_nclmax)

real(r8) :: vcmax_z ! leaf layer maximum rate of carboxylation
! (umol co2/m**2/s)
Expand Down Expand Up @@ -342,7 +347,7 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
! not been done yet.
! ------------------------------------------------------------

if ( .not.rate_mask_z(cl,ft,iv) .or. use_fates_plant_hydro ) then
if ( .not.rate_mask_z(iv,ft,cl) .or. use_fates_plant_hydro ) then

if (use_fates_plant_hydro) then
write(fates_log(),*) 'use_fates_plant_hydro in EDTypes'
Expand Down Expand Up @@ -375,7 +380,7 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
nscaler, & ! in
ft, & ! in
bc_in(s)%t_veg_pa(ifp), & ! in
lmr_z(cl,ft,iv)) ! out
lmr_z(iv,ft,cl)) ! out

! Part VII: Calculate (1) maximum rate of carboxylation (vcmax),
! (2) maximum electron transport rate, (3) triose phosphate
Expand Down Expand Up @@ -428,12 +433,12 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
mm_kco2, & ! in
mm_ko2, & ! in
co2_cpoint, & ! in
lmr_z(cl,ft,iv), & ! in
lmr_z(iv,ft,cl), & ! in
currentPatch%psn_z(cl,ft,iv), & ! out
rs_z(cl,ft,iv), & ! out
anet_av_z(cl,ft,iv)) ! out
rs_z(iv,ft,cl), & ! out
anet_av_z(iv,ft,cl)) ! out

rate_mask_z(cl,ft,iv) = .true.
rate_mask_z(iv,ft,cl) = .true.
end if
end do

Expand All @@ -455,9 +460,9 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
nv = currentCohort%nv
call ScaleLeafLayerFluxToCohort(nv, & !in
currentPatch%psn_z(cl,ft,1:nv), & !in
lmr_z(cl,ft,1:nv), & !in
rs_z(cl,ft,1:nv), & !in
anet_av_z(cl,ft,1:nv), & !in
lmr_z(1:nv,ft,cl), & !in
rs_z(1:nv,ft,cl), & !in
anet_av_z(1:nv,ft,cl), & !in
currentPatch%elai_profile(cl,ft,1:nv), & !in
currentCohort%c_area, & !in
currentCohort%n, & !in
Expand All @@ -469,7 +474,7 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
currentCohort%rdark) !out

! Net Uptake does not need to be scaled, just transfer directly
currentCohort%ts_net_uptake(1:nv) = anet_av_z(cl,ft,1:nv) * umolC_to_kgC
currentCohort%ts_net_uptake(1:nv) = anet_av_z(1:nv,ft,cl) * umolC_to_kgC

else

Expand Down Expand Up @@ -1011,10 +1016,10 @@ end subroutine LeafLayerPhotosynthesis
! =====================================================================================

subroutine ScaleLeafLayerFluxToCohort(nv, & ! in currentCohort%nv
psn_llz, & ! in %psn_z(cl,ft,1:currentCohort%nv)
lmr_llz, & ! in lmr_z(cl,ft,1:currentCohort%nv)
rs_llz, & ! in rs_z(cl,ft,1:currentCohort%nv)
anet_av_llz, & ! in anet_av_z(cl,ft,1:currentCohort%nv)
psn_llz, & ! in %psn_z(1:currentCohort%nv,ft,cl)
lmr_llz, & ! in lmr_z(1:currentCohort%nv,ft,cl)
rs_llz, & ! in rs_z(1:currentCohort%nv,ft,cl)
anet_av_llz, & ! in anet_av_z(1:currentCohort%nv,ft,cl)
elai_llz, & ! in %elai_profile(cl,ft,1:currentCohort%nv)
c_area, & ! in currentCohort%c_area
nplant, & ! in currentCohort%n
Expand Down
4 changes: 2 additions & 2 deletions components/clm/src/ED/main/FatesInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ subroutine allocate_bcout(bc_out)

! Photosynthesis

allocate(bc_out%rssun_pa(numPatchesPerCol))
allocate(bc_out%rssha_pa(numPatchesPerCol))
allocate(bc_out%rssun_pa(maxPatchesPerCol))
allocate(bc_out%rssha_pa(maxPatchesPerCol))

! Canopy Radiation
allocate(bc_out%albd_parb(maxPatchesPerCol,cp_numSWb))
Expand Down

0 comments on commit af3bb56

Please sign in to comment.