Skip to content

Commit

Permalink
Merge pull request #2 from rgknox/spitfire_cleanup
Browse files Browse the repository at this point in the history
resolution of conflicts take 2
  • Loading branch information
jkshuman authored Mar 24, 2017
2 parents 81994bd + b722943 commit 1b8ea3b
Show file tree
Hide file tree
Showing 36 changed files with 3,722 additions and 856 deletions.
3 changes: 2 additions & 1 deletion components/clm/bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@ sub setup_logic_params_file {

if ( $physv->as_long() >= $physv->as_long("clm4_5") ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'paramfile',
'use_ed'=>$nl_flags->{'use_ed'}, 'phys'=>$nl_flags->{'phys'},
'phys'=>$nl_flags->{'phys'},
'use_flexibleCN'=>$nl_flags->{'use_flexibleCN'} );
} else {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fpftcon');
Expand Down Expand Up @@ -3367,6 +3367,7 @@ sub setup_logic_ed {

if ($physv->as_long() >= $physv->as_long("clm4_5") && value_is_true( $nl_flags->{'use_ed'}) ) {
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_ed_spitfire', 'use_ed'=>$nl_flags->{'use_ed'} );
add_default($test_files, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,10 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- The default filenames are given relative to the root directory
for the CLM2 data in the CESM distribution -->
<!-- Plant function types (relative to {csmdata}) -->
<paramfile phys="clm5_0" use_ed=".false.">lnd/clm2/paramdata/clm5_params.c160713.nc</paramfile>
<paramfile phys="clm4_5" use_ed=".false.">lnd/clm2/paramdata/clm_params.c160713.nc</paramfile>
<paramfile phys="clm4_5" use_ed=".true." >lnd/clm2/paramdata/clm_params_ed.c160808.nc</paramfile>
<paramfile phys="clm5_0">lnd/clm2/paramdata/clm5_params.c160713.nc</paramfile>
<paramfile phys="clm4_5">lnd/clm2/paramdata/clm_params.c160713.nc</paramfile>

<fates_paramfile phys="clm4_5">lnd/clm2/paramdata/fates_params.c170308.nc</fates_paramfile>

<!-- ======================================================================================== -->
<!-- clm 5.0 BGC nitrogen model -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@ Full pathname datafile with plant function type (PFT) constants combined with
constants for biogeochem modules
</entry>

<entry id="fates_paramfile" type="char*256" category="datasets"
input_pathname="abs" group="clm_inparm" valid_values="" >
Full pathname datafile with fates parameters
</entry>

<entry id="fsurdat" type="char*256" category="datasets"
input_pathname="abs" group="clm_inparm" valid_values="" >
Full pathname of surface data file.
Expand Down
121 changes: 83 additions & 38 deletions components/clm/src/ED/biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ module EDCanopyStructureMod

use FatesConstantsMod , only : r8 => fates_r8
use FatesGlobals , only : fates_log
use pftconMod , only : pftcon
use EDPftvarcon , only : EDPftvarcon_inst
use EDGrowthFunctionsMod , only : c_area
use EDCohortDynamicsMod , only : copy_cohort, terminate_cohorts, fuse_cohorts
use EDtypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type, ncwd
use EDTypesMod , only : nclmax
use EDTypesMod , only : nlevcan
use EDTypesMod , only : nlevleaf
use EDTypesMod , only : numpft_ed
use EDtypesMod , only : AREA
use FatesGlobals , only : endrun => fates_endrun
use FatesInterfaceMod , only : hlm_days_per_year

! CIME Globals
use shr_log_mod , only : errMsg => shr_log_errMsg
Expand Down Expand Up @@ -96,10 +98,10 @@ subroutine canopy_structure( currentSite )
real(r8) :: cc_loss
real(r8) :: lossarea
real(r8) :: newarea
real(r8) :: arealayer(nlevcan) ! Amount of plant area currently in each canopy layer
real(r8) :: sumdiff(nlevcan) ! The total of the exclusion weights for all cohorts in layer z
real(r8) :: arealayer(nlevleaf) ! Amount of plant area currently in each canopy layer
real(r8) :: sumdiff(nlevleaf) ! The total of the exclusion weights for all cohorts in layer z
real(r8) :: weight ! The amount of the total lost area that comes from this cohort
real(r8) :: sum_weights(nlevcan)
real(r8) :: sum_weights(nlevleaf)
real(r8) :: new_total_area_check
real(r8) :: missing_area, promarea,cc_gain,sumgain
integer :: promswitch,lower_cohort_switch
Expand Down Expand Up @@ -229,14 +231,33 @@ subroutine canopy_structure( currentSite )

enddo

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

currentPatch%root_litter(currentCohort%pft) = &
currentPatch%root_litter(currentCohort%pft) + &
(currentCohort%br+currentCohort%bstore)*currentCohort%n/currentPatch%area

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

currentPatch%root_litter(currentCohort%pft) = &
currentPatch%root_litter(currentCohort%pft) + &
(currentCohort%br+currentCohort%bstore)*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 c=1,ncwd
currentSite%CWD_AG_diagnostic_input_carbonflux(c) = &
currentSite%CWD_AG_diagnostic_input_carbonflux(c) &
+ currentCohort%n*(currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * ED_val_ag_biomass * hlm_days_per_year / AREA
currentSite%CWD_BG_diagnostic_input_carbonflux(c) = &
currentSite%CWD_BG_diagnostic_input_carbonflux(c) &
+ currentCohort%n*(currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * (1.0_r8 - ED_val_ag_biomass) * hlm_days_per_year / AREA
enddo

currentSite%leaf_litter_diagnostic_input_carbonflux(currentCohort%pft) = &
currentSite%leaf_litter_diagnostic_input_carbonflux(currentCohort%pft) + &
currentCohort%n * (currentCohort%bl) * hlm_days_per_year / AREA
currentSite%root_litter_diagnostic_input_carbonflux(currentCohort%pft) = &
currentSite%root_litter_diagnostic_input_carbonflux(currentCohort%pft) + &
currentCohort%n * (currentCohort%br+currentCohort%bstore) * hlm_days_per_year / AREA

currentCohort%n = 0.0_r8
currentCohort%c_area = 0._r8
else
Expand Down Expand Up @@ -280,13 +301,33 @@ subroutine canopy_structure( currentSite )

enddo

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

currentPatch%root_litter(currentCohort%pft) = &
currentPatch%root_litter(currentCohort%pft) + &
(currentCohort%br+currentCohort%bstore)*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 c=1,ncwd
currentSite%CWD_AG_diagnostic_input_carbonflux(c) = &
currentSite%CWD_AG_diagnostic_input_carbonflux(c) &
+ currentCohort%n*(currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * ED_val_ag_biomass * hlm_days_per_year / AREA
currentSite%CWD_BG_diagnostic_input_carbonflux(c) = &
currentSite%CWD_BG_diagnostic_input_carbonflux(c) &
+ currentCohort%n*(currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * (1.0_r8 - ED_val_ag_biomass) * hlm_days_per_year / AREA
enddo

currentSite%leaf_litter_diagnostic_input_carbonflux(currentCohort%pft) = &
currentSite%leaf_litter_diagnostic_input_carbonflux(currentCohort%pft) + &
currentCohort%n * (currentCohort%bl) * hlm_days_per_year / AREA
currentSite%root_litter_diagnostic_input_carbonflux(currentCohort%pft) = &
currentSite%root_litter_diagnostic_input_carbonflux(currentCohort%pft) + &
currentCohort%n * (currentCohort%br+currentCohort%bstore) * hlm_days_per_year / AREA

currentPatch%root_litter(currentCohort%pft) = &
currentPatch%root_litter(currentCohort%pft) + &
(currentCohort%br+currentCohort%bstore)*currentCohort%n/currentPatch%area
currentCohort%n = 0.0_r8
currentCohort%c_area = 0._r8

Expand Down Expand Up @@ -635,7 +676,7 @@ subroutine canopy_spread( currentSite )
! !LOCAL VARIABLES:
type (ed_cohort_type), pointer :: currentCohort
type (ed_patch_type) , pointer :: currentPatch
real(r8) :: arealayer(nlevcan) ! Amount of canopy in each layer.
real(r8) :: arealayer(nlevleaf) ! Amount of canopy in each layer.
real(r8) :: inc ! Arbitrary daily incremental change in canopy area
integer :: z
!----------------------------------------------------------------------
Expand All @@ -651,7 +692,7 @@ subroutine canopy_spread( currentSite )
currentCohort => currentPatch%tallest
do while (associated(currentCohort))
currentCohort%c_area = c_area(currentCohort)
if(pftcon%woody(currentCohort%pft) == 1)then
if(EDPftvarcon_inst%woody(currentCohort%pft) == 1)then
arealayer(currentCohort%canopy_layer) = arealayer(currentCohort%canopy_layer) + currentCohort%c_area
endif
currentCohort => currentCohort%shorter
Expand Down Expand Up @@ -694,11 +735,11 @@ subroutine canopy_summarization( nsites, sites, bc_in )
use FatesInterfaceMod , only : bc_in_type
use EDPatchDynamicsMod , only : set_patchno
use EDPatchDYnamicsMod , only : set_root_fraction
use EDCohortDynamicsMod , only : size_and_type_class_index
use EDTypesMod , only : sizetype_class_index
use EDGrowthFunctionsMod , only : tree_lai, c_area
use EDEcophysConType , only : EDecophyscon
use EDtypesMod , only : area
use pftconMod , only : pftcon
use EDPftvarcon , only : EDPftvarcon_inst

! !ARGUMENTS
integer , intent(in) :: nsites
Expand Down Expand Up @@ -750,8 +791,8 @@ subroutine canopy_summarization( nsites, sites, bc_in )

! Update the cohort's index within the size bin classes
! Update the cohort's index within the SCPF classification system
call size_and_type_class_index(currentCohort%dbh,currentCohort%pft, &
currentCohort%size_class,currentCohort%size_by_pft_class)
call sizetype_class_index(currentCohort%dbh,currentCohort%pft, &
currentCohort%size_class,currentCohort%size_by_pft_class)


currentCohort%b = currentCohort%balive+currentCohort%bdead+currentCohort%bstore
Expand All @@ -762,28 +803,32 @@ subroutine canopy_summarization( nsites, sites, bc_in )

if(currentCohort%canopy_layer==1)then
currentPatch%total_canopy_area = currentPatch%total_canopy_area + currentCohort%c_area
if(pftcon%woody(ft)==1)then
if(EDPftvarcon_inst%woody(ft)==1)then
currentPatch%total_tree_area = currentPatch%total_tree_area + currentCohort%c_area
endif
endif

! Check for erroneous zero values.
if(currentCohort%dbh <= 0._r8 .or. currentCohort%n == 0._r8)then
write(fates_log(),*) 'ED: dbh or n is zero in canopy_summarization', currentCohort%dbh,currentCohort%n
write(fates_log(),*) 'ED: dbh or n is zero in canopy_summarization', &
currentCohort%dbh,currentCohort%n
endif
if(currentCohort%pft == 0.or.currentCohort%canopy_trim <= 0._r8)then
write(fates_log(),*) 'ED: PFT or trim is zero in canopy_summarization',currentCohort%pft,currentCohort%canopy_trim
write(fates_log(),*) 'ED: PFT or trim is zero in canopy_summarization', &
currentCohort%pft,currentCohort%canopy_trim
endif
if(currentCohort%balive <= 0._r8)then
write(fates_log(),*) 'ED: balive is zero in canopy_summarization',currentCohort%balive
write(fates_log(),*) 'ED: balive is zero in canopy_summarization', &
currentCohort%balive
endif

currentCohort => currentCohort%taller

enddo ! ends 'do while(associated(currentCohort))

if ( currentPatch%total_canopy_area-currentPatch%area > 0.000001_r8 ) then
write(fates_log(),*) 'ED: canopy area bigger than area',currentPatch%total_canopy_area ,currentPatch%area
write(fates_log(),*) 'ED: canopy area bigger than area', &
currentPatch%total_canopy_area ,currentPatch%area
currentPatch%total_canopy_area = currentPatch%area
endif

Expand Down Expand Up @@ -1024,11 +1069,11 @@ subroutine leaf_area_profile( currentSite , snow_depth_si, frac_sno_eff_si)
do iv = 1,currentCohort%NV-1

! what is the height of this layer? (for snow burial purposes...)
! pftcon%vertical_canopy_frac(ft))! fudge - this should be pft specific but i cant get it to compile.
! EDPftvarcon_inst%vertical_canopy_frac(ft))! fudge - this should be pft specific but i cant get it to compile.
layer_top_hite = currentCohort%hite-((iv/currentCohort%NV) * currentCohort%hite * &
EDecophyscon%crown(currentCohort%pft) )
layer_bottom_hite = currentCohort%hite-(((iv+1)/currentCohort%NV) * currentCohort%hite * &
EDecophyscon%crown(currentCohort%pft)) ! pftcon%vertical_canopy_frac(ft))
EDecophyscon%crown(currentCohort%pft)) ! EDPftvarcon_inst%vertical_canopy_frac(ft))

fraction_exposed =1.0_r8

Expand Down Expand Up @@ -1057,10 +1102,10 @@ subroutine leaf_area_profile( currentSite , snow_depth_si, frac_sno_eff_si)

!Bottom layer
iv = currentCohort%NV
! pftcon%vertical_canopy_frac(ft))! fudge - this should be pft specific but i cant get it to compile.
! EDPftvarcon_inst%vertical_canopy_frac(ft))! fudge - this should be pft specific but i cant get it to compile.
layer_top_hite = currentCohort%hite-((iv/currentCohort%NV) * currentCohort%hite * &
EDecophyscon%crown(currentCohort%pft) )
! pftcon%vertical_canopy_frac(ft))
! EDPftvarcon_inst%vertical_canopy_frac(ft))
layer_bottom_hite = currentCohort%hite-(((iv+1)/currentCohort%NV) * currentCohort%hite * &
EDecophyscon%crown(currentCohort%pft))

Expand Down Expand Up @@ -1136,10 +1181,10 @@ subroutine leaf_area_profile( currentSite , snow_depth_si, frac_sno_eff_si)
/currentPatch%tlai_profile(L,ft,iv)
enddo

currentPatch%tlai_profile(L,ft,currentPatch%nrad(L,ft)+1: nlevcan) = 0._r8
currentPatch%tsai_profile(L,ft,currentPatch%nrad(L,ft)+1: nlevcan) = 0._r8
currentPatch%elai_profile(L,ft,currentPatch%nrad(L,ft)+1: nlevcan) = 0._r8
currentPatch%esai_profile(L,ft,currentPatch%nrad(L,ft)+1: nlevcan) = 0._r8
currentPatch%tlai_profile(L,ft,currentPatch%nrad(L,ft)+1: nlevleaf) = 0._r8
currentPatch%tsai_profile(L,ft,currentPatch%nrad(L,ft)+1: nlevleaf) = 0._r8
currentPatch%elai_profile(L,ft,currentPatch%nrad(L,ft)+1: nlevleaf) = 0._r8
currentPatch%esai_profile(L,ft,currentPatch%nrad(L,ft)+1: nlevleaf) = 0._r8

enddo
enddo
Expand Down
Loading

0 comments on commit 1b8ea3b

Please sign in to comment.