Skip to content

Commit

Permalink
Merge pull request #1 from NGEET/master
Browse files Browse the repository at this point in the history
update my fork with master
  • Loading branch information
aldivi authored Feb 9, 2020
2 parents d2f0907 + fbbcafd commit e9faf6a
Show file tree
Hide file tree
Showing 60 changed files with 10,121 additions and 5,721 deletions.
28 changes: 28 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -----------------------------------------------------------------------------------------------------
# Repo-wide git configuration file
#
# This file overrides the configurations specified below for all git users that have cloned this repo.
# This is primarily being implemented to allow users to develop code with any operating system (OS)
# preferred and mitigates potential problems with end of line (eol) character differences.
# -----------------------------------------------------------------------------------------------------

## Set the default end of line behavior (i.e. normalization to `lf` upon commit) for all files git recognizes as text
* text=auto

# Note that the above *only* applies to newly commited files. If the file previously existed with a `crlf` end of file
# and was checked out to local, then git will not change the eol character during check-in (i.e. commit). For
# windows users they will see a warning like this:
# warning: CRLF will be replaced by LF in functional_unit_testing/allometry/drive_allomtests.py.
# The file will have its original line endings in your working directory

## Explicitly declare to git which files should be normalized (i.e. treated as text files)
*.cdl text
*.F90 text
*.F90_in text
*.py text
*.sh text
*.txt text
*.xml text

## Declare to git which file types are binary files and should not have end of line modified
*.mod binary
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ Thumbs.db


# Old Files
*~
*~
# Editor specific setting files
*.vscode
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Those who wish to contribute code to FATES must have those changes integrated th
* It is best to create an issue to describe the work you are undertaking prior to starting. This helps the community sync with your efforts, prevents duplication of efforts, and science is not done in a vaccuum!
* Expect peers to interact, help, discuss and eventually approve your submission (pull-request)

## Joining Discussions and Meetings

In addition to the github discussions, we hold a roughly biweekly call, which covers both scientific and technical issues related to FATES. We use a google group to organize, schedule, and discuss these calls. Emails to the list are moderated and we try to be pretty ruthless about preventing anything other than this topic from appearing on it. To join, apply to the group here: https://groups.google.com/forum/#!forum/fates_model

## Things to Remember

* Make commits in logical units (i.e. group changes)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Functionally Assembled Terrestrial Ecosystem Simulator (“FATES”)

Copyright (c) 2016-2018, The Regents of the University of California, through Lawrence
Copyright (c) 2016-2020, The Regents of the University of California, through Lawrence
Berkeley National Laboratory, University Corporation for Atmospheric Research, Los Alamos
National Security, LLC (LANS), as operator of Los Alamos National Laboratory (LANL), and
President and Fellows of Harvard College. All rights reserved.
Expand Down
98 changes: 27 additions & 71 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ module EDCanopyStructureMod
use EDPftvarcon , only : EDPftvarcon_inst
use FatesAllometryMod , only : carea_allom
use EDCohortDynamicsMod , only : copy_cohort, terminate_cohorts, fuse_cohorts
use EDCohortDynamicsMod , only : InitPRTCohort
use EDCohortDynamicsMod , only : InitPRTObject
use EDCohortDynamicsMod , only : InitPRTBoundaryConditions
use EDCohortDynamicsMod , only : SendCohortToLitter
use FatesAllometryMod , only : tree_lai
use FatesAllometryMod , only : tree_sai
use EDtypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type, ncwd
use EDtypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type
use EDTypesMod , only : nclmax
use EDTypesMod , only : nlevleaf
use EDtypesMod , only : AREA
Expand Down Expand Up @@ -117,9 +119,7 @@ subroutine canopy_structure( currentSite , bc_in )
! !USES:

use EDParamsMod, only : ED_val_comp_excln
use EDtypesMod , only : ncwd
use EDTypesMod , only : min_patch_area
use EDTypesMod , only : val_check_ed_vars
use FatesInterfaceMod, only : bc_in_type
!
! !ARGUMENTS
Expand Down Expand Up @@ -193,7 +193,7 @@ subroutine canopy_structure( currentSite , bc_in )

! Its possible that before we even enter this scheme
! some cohort numbers are very low. Terminate them.
call terminate_cohorts(currentSite, currentPatch, 1)
call terminate_cohorts(currentSite, currentPatch, 1, 12)

! Calculate how many layers we have in this canopy
! This also checks the understory to see if its crown
Expand All @@ -206,12 +206,12 @@ subroutine canopy_structure( currentSite , bc_in )

! After demotions, we may then again have cohorts that are very very
! very sparse, remove them
call terminate_cohorts(currentSite, currentPatch, 1)
call terminate_cohorts(currentSite, currentPatch, 1,13)

call fuse_cohorts(currentSite, currentPatch, bc_in)

! Remove cohorts for various other reasons
call terminate_cohorts(currentSite, currentPatch, 2)
call terminate_cohorts(currentSite, currentPatch, 2,13)


! ---------------------------------------------------------------------------------------
Expand All @@ -230,12 +230,12 @@ subroutine canopy_structure( currentSite , bc_in )
end do

! Remove cohorts that are incredibly sparse
call terminate_cohorts(currentSite, currentPatch, 1)
call terminate_cohorts(currentSite, currentPatch, 1,14)

call fuse_cohorts(currentSite, currentPatch, bc_in)

! Remove cohorts for various other reasons
call terminate_cohorts(currentSite, currentPatch, 2)
call terminate_cohorts(currentSite, currentPatch, 2,14)

end if

Expand Down Expand Up @@ -331,7 +331,6 @@ end subroutine canopy_structure
subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr)

use EDParamsMod, only : ED_val_comp_excln
use EDtypesMod , only : ncwd
use SFParamsMod, only : SF_val_CWD_frac

! !ARGUMENTS
Expand Down Expand Up @@ -658,11 +657,17 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr)

allocate(copyc)

call InitPRTCohort(copyc)
! Initialize the PARTEH object and point to the
! correct boundary condition fields
copyc%prt => null()
call InitPRTObject(copyc%prt)
call InitPRTBoundaryConditions(copyc)

if( hlm_use_planthydro.eq.itrue ) then
call InitHydrCohort(currentSite,copyc)
endif
call copy_cohort(currentCohort, copyc)

call copy_cohort(currentCohort, copyc)

newarea = currentCohort%c_area - cc_loss
copyc%n = currentCohort%n*newarea/currentCohort%c_area
Expand Down Expand Up @@ -708,50 +713,10 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr)

if(currentCohort%canopy_layer>nclmax )then

! put the litter from the terminated cohorts into the fragmenting pools
do i_cwd=1,ncwd

currentPatch%CWD_AG(i_cwd) = currentPatch%CWD_AG(i_cwd) + &
(struct_c + sapw_c ) * &
EDPftvarcon_inst%allom_agb_frac(currentCohort%pft) * &
SF_val_CWD_frac(i_cwd)*currentCohort%n/currentPatch%area

currentPatch%CWD_BG(i_cwd) = currentPatch%CWD_BG(i_cwd) + &
(struct_c + sapw_c) * &
(1.0_r8-EDPftvarcon_inst%allom_agb_frac(currentCohort%pft)) * &
SF_val_CWD_frac(i_cwd)*currentCohort%n/currentPatch%area !litter flux per m2.

enddo

currentPatch%leaf_litter(currentCohort%pft) = &
currentPatch%leaf_litter(currentCohort%pft) + &
leaf_c * currentCohort%n/currentPatch%area ! leaf litter flux per m2.

currentPatch%root_litter(currentCohort%pft) = &
currentPatch%root_litter(currentCohort%pft) + &
(fnrt_c + store_c) * currentCohort%n/currentPatch%area

! keep track of the above fluxes at the site level as a
! CWD/litter input flux (in kg / site-m2 / yr)
do i_cwd=1,ncwd
currentSite%CWD_AG_diagnostic_input_carbonflux(i_cwd) = &
currentSite%CWD_AG_diagnostic_input_carbonflux(i_cwd) &
+ currentCohort%n * (struct_c + sapw_c) * &
SF_val_CWD_frac(i_cwd) * EDPftvarcon_inst%allom_agb_frac(currentCohort%pft) &
* hlm_days_per_year / AREA
currentSite%CWD_BG_diagnostic_input_carbonflux(i_cwd) = &
currentSite%CWD_BG_diagnostic_input_carbonflux(i_cwd) &
+ currentCohort%n * (struct_c + sapw_c) * &
SF_val_CWD_frac(i_cwd) * (1.0_r8 - &
EDPftvarcon_inst%allom_agb_frac(currentCohort%pft)) * hlm_days_per_year / AREA
enddo

currentSite%leaf_litter_diagnostic_input_carbonflux(currentCohort%pft) = &
currentSite%leaf_litter_diagnostic_input_carbonflux(currentCohort%pft) + &
currentCohort%n * leaf_c * hlm_days_per_year / AREA
currentSite%root_litter_diagnostic_input_carbonflux(currentCohort%pft) = &
currentSite%root_litter_diagnostic_input_carbonflux(currentCohort%pft) + &
currentCohort%n * (fnrt_c + store_c) * hlm_days_per_year / AREA
! put the litter from the terminated cohorts
! straight into the fragmenting pools
call SendCohortToLitter(currentSite,currentPatch, &
currentCohort,currentCohort%n)

currentCohort%n = 0.0_r8
currentCohort%c_area = 0.0_r8
Expand Down Expand Up @@ -1145,7 +1110,12 @@ subroutine PromoteIntoLayer(currentSite,currentPatch,i_lyr)

allocate(copyc)

call InitPRTCohort(copyc)
! Initialize the PARTEH object and point to the
! correct boundary condition fields
copyc%prt => null()
call InitPRTObject(copyc%prt)
call InitPRTBoundaryConditions(copyc)

if( hlm_use_planthydro.eq.itrue ) then
call InitHydrCohort(CurrentSite,copyc)
endif
Expand Down Expand Up @@ -1287,8 +1257,6 @@ subroutine canopy_summarization( nsites, sites, bc_in )

use FatesInterfaceMod , only : bc_in_type
use EDPatchDynamicsMod , only : set_patchno
use FatesAllometryMod , only : set_root_fraction
use FatesAllometryMod , only : i_hydro_rootprof_context
use FatesSizeAgeTypeIndicesMod, only : sizetype_class_index
use EDtypesMod , only : area
use EDPftvarcon , only : EDPftvarcon_inst
Expand Down Expand Up @@ -1330,18 +1298,6 @@ subroutine canopy_summarization( nsites, sites, bc_in )

do while(associated(currentPatch))

! Calculate rooting depth fractions for the patch x pft
! Note that we are calling for the root fractions in the hydrologic context.
! See explanation in FatesAllometryMod. In other locations, this
! function is called to return the profile of biomass as used for litter

do ft = 1, numpft
call set_root_fraction(currentPatch%rootfr_ft(ft,1:bc_in(s)%nlevsoil), ft, &
bc_in(s)%zi_sisl,lowerb=lbound(bc_in(s)%zi_sisl,1), &
icontext=i_hydro_rootprof_context)
end do


!zero cohort-summed variables.
currentPatch%total_canopy_area = 0.0_r8
currentPatch%total_tree_area = 0.0_r8
Expand Down
Loading

0 comments on commit e9faf6a

Please sign in to comment.