Skip to content

Commit

Permalink
Merge remote-tracking branch 'ngeet/master' into andre-ed-params
Browse files Browse the repository at this point in the history
Note: both the branch and master have changed answers, so there is no
easy way to test the merge against a baseline.

Test suite: ed - yellowstone gnu, intel, pgi
               - hobart nag
Test baseline: none
Test namelist changes: yes, add fates_paramfile
Test answer changes: yes
Test summary: all tests pass

Test suite: clm_short - yellowstone gnu, intel, pgi
Test baseline: clm4_5_12_r195
Test namelist changes: none
Test answer changes: bit for bit
Test summary: all tests pass
  • Loading branch information
bandre-ucar committed Feb 15, 2017
2 parents 509fafa + cdb9db7 commit 3f3f16f
Show file tree
Hide file tree
Showing 28 changed files with 2,894 additions and 1,807 deletions.
4 changes: 2 additions & 2 deletions cime/cime_config/cesm/machines/config_compilers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ for mct, etc.
<compiler COMPILER="gnu" MACH="eddi">
<NETCDF_PATH>$(NETCDF_HOME)</NETCDF_PATH>
<ADD_CPPDEFS> -DLinux -DCPRGNU </ADD_CPPDEFS>
<ADD_FFLAGS> -ffree-line-length-132 </ADD_FFLAGS>
<ADD_FFLAGS DEBUG="TRUE"> -ffpe-trap=invalid,zero,overflow </ADD_FFLAGS> <!---finit-integer=0-->
<ADD_FFLAGS DEBUG="FALSE"> -ffree-line-length-132 </ADD_FFLAGS>
<ADD_FFLAGS DEBUG="TRUE"> -g -fbacktrace -fbounds-check -ffpe-trap=invalid,zero,overflow -Wline-truncation</ADD_FFLAGS> <!---finit-integer=0-->
<ADD_SLIBS> -L$(NETCDF_HOME)/lib/ -lnetcdff -lnetcdf -lcurl -llapack -lblas</ADD_SLIBS>
<GPTL_CPPDEFS> -DHAVE_VPRINTF -DHAVE_GETTIMEOFDAY </GPTL_CPPDEFS>
<ESMF_LIBDIR></ESMF_LIBDIR>
Expand Down
4 changes: 0 additions & 4 deletions cime/cime_config/cesm/machines/config_machines.xml
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,6 @@
</batch_system>
<mpirun mpilib="mpi-serial">
<executable></executable>
<arguments>
<arg name="num_tasks">-np {{ num_tasks }}</arg>
<arg name="tasks_per_node"> -npernode {{ tasks_per_node }}</arg>
</arguments>
</mpirun>
<mpirun mpilib="default">
<executable>mpirun</executable>
Expand Down
8 changes: 4 additions & 4 deletions components/clm/src/ED/biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,12 @@ subroutine canopy_structure( currentSite )
endif
!call terminate_cohorts(currentPatch)
if(promswitch == 1)then
! write(fates_log(),*) 'cohort loop',currentCohort%pft,currentCohort%indexnumber,currentPatch%patchno
! write(fates_log(),*) 'cohort loop',currentCohort%pft,currentPatch%patchno
endif
!----------- End of cohort splitting ------------------------------!
else
if(promswitch == 1)then
! write(fates_log(),*) 'cohort list',currentCohort%pft,currentCohort%indexnumber, &
! write(fates_log(),*) 'cohort list',currentCohort%pft, &
! currentCohort%canopy_layer,currentCohort%c_area
endif
endif
Expand All @@ -485,7 +485,7 @@ subroutine canopy_structure( currentSite )
!currentPatch%patchno,z,i,lower_cohort_switch
endif
if(promswitch == 1.and.associated(currentPatch%tallest))then
! write(fates_log(),*) 'cohorts',currentCohort%pft,currentCohort%indexnumber,currentPatch%patchno, &
! write(fates_log(),*) 'cohorts',currentCohort%pft,currentPatch%patchno, &
!currentCohort%c_area
endif
enddo !arealayer loop
Expand Down Expand Up @@ -1067,7 +1067,7 @@ subroutine leaf_area_profile( currentSite , snow_depth_si, frac_sno_eff_si)
currentCohort%c_area/currentPatch%total_canopy_area)
currentPatch%layer_height_profile(L,ft,iv) = currentPatch%layer_height_profile(L,ft,iv) + (remainder * fleaf * &
currentCohort%c_area/currentPatch%total_canopy_area*(layer_top_hite+layer_bottom_hite)/2.0_r8)
write(fates_log(), *) 'LHP', currentPatch%layer_height_profile(L,ft,iv)
if ( DEBUG ) write(fates_log(), *) 'LHP', currentPatch%layer_height_profile(L,ft,iv)
if(currentCohort%dbh <= 0._r8.or.currentCohort%n == 0._r8)then
write(fates_log(), *) 'ED: dbh or n is zero in clmedlink', currentCohort%dbh,currentCohort%n
endif
Expand Down
96 changes: 50 additions & 46 deletions components/clm/src/ED/biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ module EDCohortDynamicsMod
! !USES:
use abortutils , only : endrun
use FatesGlobals , only : fates_log
use FatesGlobals , only : freq_day
use FatesConstantsMod , only : r8 => fates_r8
use FatesConstantsMod , only : fates_unset_int
use shr_log_mod , only : errMsg => shr_log_errMsg
use EDPftvarcon , only : EDPftvarcon_inst
use EDEcophysContype , only : EDecophyscon
use EDGrowthFunctionsMod , only : c_area, tree_lai
use EDTypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type
use EDTypesMod , only : fusetol, cp_nclmax
use EDtypesMod , only : ncwd, maxcohortsperpatch, udata
use EDtypesMod , only : ncwd, maxcohortsperpatch
use EDtypesMod , only : sclass_ed,nlevsclass_ed,AREA
use EDtypesMod , only : min_npm2, min_nppatch, min_n_safemath
!
Expand Down Expand Up @@ -73,7 +75,6 @@ subroutine create_cohort(patchptr, pft, nn, hite, dbh, &
!----------------------------------------------------------------------

allocate(new_cohort)
udata%cohort_number = udata%cohort_number + 1 !give each cohort a unique number for checking cohort fusing routine.

call nan_cohort(new_cohort) ! Make everything in the cohort not-a-number
call zero_cohort(new_cohort) ! Zero things that need to be zeroed.
Expand All @@ -82,7 +83,8 @@ subroutine create_cohort(patchptr, pft, nn, hite, dbh, &
! Define cohort state variable
!**********************/

new_cohort%indexnumber = udata%cohort_number
new_cohort%indexnumber = fates_unset_int ! Cohort indexing was not thread-safe, setting
! bogus value for the time being (RGK-012017)
new_cohort%siteptr => patchptr%siteptr
new_cohort%patchptr => patchptr
new_cohort%pft = pft
Expand All @@ -109,7 +111,7 @@ subroutine create_cohort(patchptr, pft, nn, hite, dbh, &

if (new_cohort%dbh <= 0.0_r8 .or. new_cohort%n == 0._r8 .or. new_cohort%pft == 0 ) then
write(fates_log(),*) 'ED: something is zero in create_cohort', &
new_cohort%indexnumber,new_cohort%dbh,new_cohort%n, &
new_cohort%dbh,new_cohort%n, &
new_cohort%pft
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
Expand Down Expand Up @@ -184,6 +186,9 @@ subroutine allocate_live_biomass(cc_p,mode)
! accounts for the fact that live biomass may decline in the off-season,
! making leaf_memory unrealistic.
real(r8) :: ratio_balive ! ratio between root+shoot biomass now and root+shoot biomass when leaves fell off.
real(r8) :: new_bl
real(r8) :: new_br
real(r8) :: new_bsw

integer :: ft ! functional type
integer :: leaves_off_switch
Expand Down Expand Up @@ -218,69 +223,68 @@ subroutine allocate_live_biomass(cc_p,mode)
! Use different proportions if the leaves are on vs off
if(leaves_off_switch==0)then

! Tracking npp/gpp diagnostics only occur after growth derivatives is called
if(mode==1)then
! it will not be able to put out as many leaves as it had previous timestep
currentcohort%npp_leaf = currentcohort%npp_leaf + &
max(0.0_r8,currentcohort%balive*leaf_frac - currentcohort%bl)/udata%deltat
end if

currentcohort%bl = currentcohort%balive*leaf_frac
new_bl = currentcohort%balive*leaf_frac

new_br = EDpftvarcon_inst%froot_leaf(ft) * (currentcohort%balive + currentcohort%laimemory) * leaf_frac

new_bsw = EDecophyscon%sapwood_ratio(ft) * currentcohort%hite *(currentcohort%balive + &
currentcohort%laimemory)*leaf_frac

!diagnose the root and stem biomass from the functional balance hypothesis. This is used when the leaves are
!fully on.
if(mode==1)then
if(mode==1)then

currentcohort%npp_leaf = currentcohort%npp_leaf + &
max(0.0_r8,new_bl - currentcohort%bl) / freq_day

currentcohort%npp_froot = currentcohort%npp_froot + &
max(0._r8, EDPftvarcon_inst%froot_leaf(ft)*(currentcohort%balive+currentcohort%laimemory)*leaf_frac - &
currentcohort%br) / udata%deltat
max(0._r8,new_br - currentcohort%br) / freq_day

currentcohort%npp_bsw = max(0._r8,EDecophyscon%sapwood_ratio(ft) * currentcohort%hite *(currentcohort%balive + &
currentcohort%laimemory)*leaf_frac - currentcohort%bsw)/udata%deltat
currentcohort%npp_bsw = max(0.0_r8, new_bsw - currentcohort%bsw)/freq_day

currentcohort%npp_bdead = currentCohort%dbdeaddt

end if

currentcohort%br = EDPftvarcon_inst%froot_leaf(ft) * (currentcohort%balive + currentcohort%laimemory) * leaf_frac
currentcohort%bsw = EDecophyscon%sapwood_ratio(ft) * currentcohort%hite *(currentcohort%balive + &
currentcohort%laimemory)*leaf_frac


else ! Leaves are on (leaves_off_switch==1)

!the purpose of this section is to figure out the root and stem biomass when the leaves are off
!at this point, we know the former leaf mass (laimemory) and the current alive mass
!because balive may decline in the off-season, we need to adjust the root and stem biomass that are predicted
!from the laimemory, for the fact that we now might not have enough live biomass to support the hypothesized root mass
!thus, we use 'ratio_balive' to adjust br and bsw. Apologies that this is so complicated! RF


currentcohort%bl = 0.0_r8

currentcohort%bl = new_bl
currentcohort%br = new_br
currentcohort%bsw = new_bsw

else ! Leaves are off (leaves_off_switch==1)

!the purpose of this section is to figure out the root and stem biomass when the leaves are off
!at this point, we know the former leaf mass (laimemory) and the current alive mass
!because balive may decline in the off-season, we need to adjust the
!root and stem biomass that are predicted from the laimemory, for the fact that we now might
!not have enough live biomass to support the hypothesized root mass
!thus, we use 'ratio_balive' to adjust br and bsw. Apologies that this is so complicated! RF

ideal_balive = currentcohort%laimemory * EDPftvarcon_inst%froot_leaf(ft) + &
currentcohort%laimemory* EDecophyscon%sapwood_ratio(ft) * currentcohort%hite
currentcohort%br = EDPftvarcon_inst%froot_leaf(ft) * (ideal_balive + currentcohort%laimemory) * leaf_frac
currentcohort%bsw = EDecophyscon%sapwood_ratio(ft) * currentcohort%hite *(ideal_balive + &
currentcohort%laimemory)*leaf_frac

ratio_balive = currentcohort%balive / ideal_balive
currentcohort%br = currentcohort%br * ratio_balive
currentcohort%bsw = currentcohort%bsw * ratio_balive
ratio_balive = currentcohort%balive / ideal_balive

new_br = EDpftvarcon_inst%froot_leaf(ft) * (ideal_balive + currentcohort%laimemory) * &
leaf_frac * ratio_balive
new_bsw = EDecophyscon%sapwood_ratio(ft) * currentcohort%hite * &
(ideal_balive + currentcohort%laimemory) * leaf_frac * ratio_balive

! Diagnostics
if(mode==1)then

currentcohort%npp_froot = currentcohort%npp_froot + &
max(0.0_r8,EDPftvarcon_inst%froot_leaf(ft)*(ideal_balive + &
currentcohort%laimemory)*leaf_frac*ratio_balive-currentcohort%br)/udata%deltat
max(0.0_r8,new_br-currentcohort%br)/freq_day

currentcohort%npp_bsw = max(0.0_r8,EDecophyscon%sapwood_ratio(ft) * currentcohort%hite *(ideal_balive + &
currentcohort%laimemory)*leaf_frac*ratio_balive - currentcohort%bsw)/udata%deltat
currentcohort%npp_bsw = max(0.0_r8, new_bsw-currentcohort%bsw)/freq_day

currentcohort%npp_bdead = currentCohort%dbdeaddt

end if

currentcohort%bl = 0.0_r8
currentcohort%br = new_br
currentcohort%bsw = new_bsw

endif

if (abs(currentcohort%balive -currentcohort%bl- currentcohort%br - currentcohort%bsw)>1e-12) then
Expand Down Expand Up @@ -1006,8 +1010,7 @@ subroutine copy_cohort( currentCohort,copyc )
o => currentCohort
n => copyc

udata%cohort_number = udata%cohort_number + 1
n%indexnumber = udata%cohort_number
n%indexnumber = fates_unset_int

! VEGETATION STRUCTURE
n%pft = o%pft
Expand Down Expand Up @@ -1038,13 +1041,14 @@ 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
n%npp_acc = o%npp_acc

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%resp_tstep = o%resp_tstep
n%resp_acc = o%resp_acc
n%resp_acc_hold = o%resp_acc_hold
Expand Down
34 changes: 17 additions & 17 deletions components/clm/src/ED/biogeochem/EDGrowthFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module EDGrowthFunctionsMod
! ============================================================================

use shr_kind_mod , only : r8 => shr_kind_r8
use clm_varctl , only : iulog
use FatesGlobals , only : fates_log
use EDPftvarcon , only : EDPftvarcon_inst
use EDEcophysContype , only : EDecophyscon
use EDTypesMod , only : ed_cohort_type, cp_nlevcan, dinc_ed
Expand Down Expand Up @@ -76,7 +76,7 @@ real(r8) function Hite( cohort_in )
c = 0.37_r8

if(cohort_in%dbh <= 0._r8)then
write(iulog,*) 'ED: dbh less than zero problem!',cohort_in%indexnumber
write(fates_log(),*) 'ED: dbh less than zero problem!'
cohort_in%dbh = 0.1_r8
endif

Expand Down Expand Up @@ -106,7 +106,7 @@ real(r8) function Bleaf( cohort_in )
real(r8) :: slascaler ! changes the target biomass according to the SLA

if(cohort_in%dbh < 0._r8.or.cohort_in%pft == 0.or.cohort_in%dbh > 1000.0_r8)then
write(iulog,*) 'problems in bleaf',cohort_in%dbh,cohort_in%pft
write(fates_log(),*) 'problems in bleaf',cohort_in%dbh,cohort_in%pft
endif

if(cohort_in%dbh <= EDecophyscon%max_dbh(cohort_in%pft))then
Expand All @@ -117,7 +117,7 @@ real(r8) function Bleaf( cohort_in )
slascaler = 0.03_r8/EDPftvarcon_inst%slatop(cohort_in%pft)
bleaf = bleaf * slascaler

!write(iulog,*) 'bleaf',bleaf, slascaler,cohort_in%pft
!write(fates_log(),*) 'bleaf',bleaf, slascaler,cohort_in%pft

!Adjust for canopies that have become so deep that their bottom layer is not producing any carbon...
!nb this will change the allometry and the effects of this remain untested. RF. April 2014
Expand All @@ -141,7 +141,7 @@ real(r8) function tree_lai( cohort_in )
real(r8) :: slat ! the sla of the top leaf layer. m2/kgC

if( cohort_in%bl < 0._r8 .or. cohort_in%pft == 0 ) then
write(iulog,*) 'problem in treelai',cohort_in%bl,cohort_in%pft
write(fates_log(),*) 'problem in treelai',cohort_in%bl,cohort_in%pft
endif

if( cohort_in%status_coh == 2 ) then ! are the leaves on?
Expand All @@ -162,7 +162,7 @@ real(r8) function tree_lai( cohort_in )
! at the moments cp_nlevcan default is 40, which is very large, so exceeding this would clearly illustrate a
! huge error
if(cohort_in%treelai > cp_nlevcan*dinc_ed)then
write(iulog,*) 'too much lai' , cohort_in%treelai , cohort_in%pft , cp_nlevcan * dinc_ed
write(fates_log(),*) 'too much lai' , cohort_in%treelai , cohort_in%pft , cp_nlevcan * dinc_ed
endif

return
Expand All @@ -186,7 +186,7 @@ real(r8) function tree_sai( cohort_in )
sai_scaler = 0.05_r8 ! here, a high biomass of 20KgC per m2 gives us a high SAI of 1.0.

if( cohort_in%bdead < 0._r8 .or. cohort_in%pft == 0 ) then
write(iulog,*) 'problem in treesai',cohort_in%bdead,cohort_in%pft
write(fates_log(),*) 'problem in treesai',cohort_in%bdead,cohort_in%pft
endif

cohort_in%c_area = c_area(cohort_in) ! call the tree area
Expand All @@ -199,7 +199,7 @@ real(r8) function tree_sai( cohort_in )
! at the moments cp_nlevcan default is 40, which is very large, so exceeding this would clearly illustrate a
! huge error
if(cohort_in%treesai > cp_nlevcan*dinc_ed)then
write(iulog,*) 'too much sai' , cohort_in%treesai , cohort_in%pft , cp_nlevcan * dinc_ed
write(fates_log(),*) 'too much sai' , cohort_in%treesai , cohort_in%pft , cp_nlevcan * dinc_ed
endif

return
Expand All @@ -223,13 +223,13 @@ real(r8) function c_area( cohort_in )
real(r8) :: dbh ! Tree diameter at breat height. cm.

if (DEBUG_growth) then
write(iulog,*) 'z_area 1',cohort_in%dbh,cohort_in%pft
write(iulog,*) 'z_area 2',EDecophyscon%max_dbh
write(iulog,*) 'z_area 3',EDPftvarcon_inst%woody
write(iulog,*) 'z_area 4',cohort_in%n
write(iulog,*) 'z_area 5',cohort_in%patchptr%spread
write(iulog,*) 'z_area 6',cohort_in%canopy_layer
write(iulog,*) 'z_area 7',ED_val_grass_spread
write(fates_log(),*) 'z_area 1',cohort_in%dbh,cohort_in%pft
write(fates_log(),*) 'z_area 2',EDecophyscon%max_dbh
write(fates_log(),*) 'z_area 3',EDPftvarcon_inst%woody
write(fates_log(),*) 'z_area 4',cohort_in%n
write(fates_log(),*) 'z_area 5',cohort_in%patchptr%spread
write(fates_log(),*) 'z_area 6',cohort_in%canopy_layer
write(fates_log(),*) 'z_area 7',ED_val_grass_spread
end if

dbh = min(cohort_in%dbh,EDecophyscon%max_dbh(cohort_in%pft))
Expand Down Expand Up @@ -371,8 +371,8 @@ subroutine mortality_rates( cohort_in,cmort,hmort,bmort )
endif

else
write(iulog,*) 'dbh problem in mortality_rates', &
cohort_in%dbh,cohort_in%pft,cohort_in%n,cohort_in%canopy_layer,cohort_in%indexnumber
write(fates_log(),*) 'dbh problem in mortality_rates', &
cohort_in%dbh,cohort_in%pft,cohort_in%n,cohort_in%canopy_layer
endif

!mortality_rates = bmort + hmort + cmort
Expand Down
Loading

0 comments on commit 3f3f16f

Please sign in to comment.