!///////////////////////////////////////////////////////////////////////////////////////
!// LPJ-GUESS INSTRUCTION SCRIPT FOR COHORT/INDIVIDUAL MODE
!// Global PFTs
!//
!// LPJ-GUESS 4.0 interim - with ecev3 edits
!// 
!///////////////////////////////////////////////////////////////////////////////////////


!///////////////////////////////////////////////////////////////////////////////////////
! Output files
!

outputdirectory "./output/"


! Prefined yearly output
! These files may be outcommented if their output is not required. 
file_cmass "cmass.out"
file_anpp "anpp.out"
file_agpp "agpp.out"
file_fpc "fpc.out"
file_aaet "aaet.out"
file_lai "lai.out"
file_cflux "cflux.out"
file_dens "dens.out"
file_runoff "tot_runoff.out"
file_cpool "cpool.out"
file_clitter "clitter.out"
file_firert "firert.out"
!file_aiso "aiso.out"
!file_amon "amon.out"
file_speciesheights "height.out"

file_nmass "nmass.out"
file_cton_leaf "cton_leaf.out"
!file_ngases "ngases.out"
file_nsources "nsources.out"
file_npool "npool.out"
file_nlitter "nlitter.out" 
file_nuptake "nuptake.out"
file_nflux "nflux.out"
!file_vmaxnlim "vmaxnlim.out"

! Monthly outputs
file_mnpp "mnpp.out"
file_mlai "mlai.out"
file_mrh "mrh.out"
file_mgpp "mgpp.out"
file_mra "mra.out"
file_mnee "mnee.out"
file_maet "maet.out"
!file_mpet "mpet.out"
!file_mevap "mevap.out"
!file_mintercep "mintercep.out"
file_mrunoff "mrunoff.out"
file_mwcont_upper "mwcont_upper.out"
file_mwcont_lower "mwcont_lower.out"
!file_miso "miso.out"
!file_mmon "mmon.out"
!///////////////////////////////////////////////////////////////////////////////////////



!///////////////////////////////////////////////////////////////////////////////////////
! Forcing Data & gridlists
! ecev3 - was in global_cru.ins

!param "file_gridlist" (str "gridlist.txt")

! Path needs updating
!param "file_co2"      (str "C:\DATA\J\MODELDATA\co2\co2_1901-2006.txt")
!param "file_cru"      (str "C:\DATA\J\MODELDATA\cru_1901_2006.bin")
!param "file_cru_misc" (str "C:\DATA\J\MODELDATA\cru_1901_2006misc.bin")

! N deposition (blank string to use constant pre-industrial level of 2 kgN/ha/year)
!param "file_ndep"     (str "c:/ndep/GlobalNitrogenDeposition.bin")
param "file_ndep"     (str "../GlobalNitrogenDeposition.bin")




!///////////////////////////////////////////////////////////////////////////////////////
!// RUN PARAMETERS AND OPTIONS 
!

! Settings recognised by Plib
! Run GUESS with -help option for list of keywords and their meanings

title 'LPJ-GUESS cohort mode - global pfts'

vegmode "cohort"		! "cohort", "individual" or "population"
nyear_spinup 500		! number of years to spin up the simulation for
ifcalcsla 1				! whether to calculate SLA from leaf longevity
						! (PFT-specific value can be specified in this file instead)
ifcalccton 1			! whether to calculate leaf C:N min from leaf longevity
						! (PFT-specific value can be specified in this file instead)
iffire 1				! whether to implement fire (1) or not (0)
npatch 25				! number of replicate patches to simulate
patcharea 1000			! patch area (m2)
estinterval 5			! years between establishment events in cohort mode
ifdisturb 1				! whether generic patch-destroying disturbances enabled
distinterval 100		! average return time for generic patch-destroying disturbances
						! Hickler et al. (2011) used 200
ifbgestab 1				! whether background establishment enabled
ifsme 1					! whether spatial mass effect enabled
ifstochestab 1			! whether establishment stochastic
ifstochmort 1			! whether mortality stochastic
ifcdebt 1				! whether to allow vegetation C storage (1) or not (0)
wateruptake "rootdist"  ! "wcont", "rootdist", "smart" or "speciesspecific",
                        ! see documentation for water_uptake()



!///////////////////////////////////////////////////////////////////////////////
! PROCESS SETTINGS SPECIFIC TO NITROGEN
!///////////////////////////////////////////////////////////////////////////////

ifcentury 1				! whether to use CENTURY SOM dynamics (mandatory for N cycling)
ifnlim 1				! whether plant growth limited by available N
freenyears 100			! number of years to spin up without N limitation (needed to build up a N pool)
nfix_a 0.102			! first term in N fixation eqn (Conservative 0.102, Central 0.234, Upper 0.367)
nfix_b 0.524			! second term in N fixation eqn (Conservative 0.524, Central -0.172, Upper -0.754)
nrelocfrac 0.5			! fraction of N retranslocated prior to leaf and root shedding


!///////////////////////////////////////////////////////////////////////////////
! SERIALIZATION SETTINGS - ecev3 - moved below
!///////////////////////////////////////////////////////////////////////////////
!state_year 500			! year to save/start state file (no setting = after spinup)
!restart 0				! whether to start from a state file
!save_state 0			! whether to save a state file
!state_path ""			! directory to put state files in


ifsmoothgreffmort 1			! whether to vary mort_greff smoothly with growth efficiency (1) 
						! or to use the standard step-function (0)  
						! greff_min values below calibrated for the smooth (1) option 
ifdroughtlimitedestab 0			! whether establishment is limited by growing season drought
						! guess2008 - species version has 1
ifrainonwetdaysonly 1			! whether to rain on wet days only (1), or to rain a bit every day (0)
ifbvoc 1                     		! whether to include BVOC calculations (1) or not (0)

!!!!!!!!!!!! landcover parameters !!!!!!!!!!!!!!					

run_landcover 1	      ! whether to use (and change) landcover fractions (1) or not (0)						
run_urban 0		      ! whether to simulate barren land (1) or not (0)	
run_crop 0		      ! whether to simulate crop vegetation (1) or not (0)
run_forest 0	      ! whether to simulate managed forest (1) or not (0)
run_pasture 1	      ! whether to simulate pasture (1) or not (0)
run_natural 1	      ! whether to simulate natural vegetation (1) or not (0)
run_peatland 0	      ! whether to simulate peatland (1) or not (0)

lcfrac_fixed 1        	! use landcover fractions (%) below (1) or read from input file (0)
lc_fixed_urban 0   	! URBAN
lc_fixed_cropland 0	! CROPLAND
lc_fixed_pasture 50   	! PASTURE
lc_fixed_forest 0   	! FOREST
lc_fixed_natural 50 	! NATURAL
lc_fixed_peatland 0 	! PEATLAND
equal_landcover_area 0	! divide gridcell into equal active landcover fractions

!///////////////////////////////////////////////////////////////////////////////////////


! ecev3 
! Parameters and options specific to LPJ-GUESS coupled to EC-Earth
!--------------------------------------------------------------------------------------------

ifslowharvestpool 0 	! ecev3

! Whether to use soil water content and soil temperature sent from IFS (1), or use GUESS' own
! hydrology (driven by precipitation) and analytic soil temperature (0).
param "ifssoilproperties" (num 1)

! Determine which RCP to use
! 0 - historical only (i.e. use file_co2 below)
! 1 - use ghg_rcp3PD.txt
! 2 - use ghg_rcp45.txt
! 3 - use ghg_rcp60.txt
! 4 - use ghg_rcp85.txt
param "nrcp" (num 0)


! State file name and directory 
! For saving and reading .bin files.
!state_path "./" 
param "state_path" (str "..") 	! directory containing the .bin state files
param "state_name" (str "lpjg")	! state filenames
param "restart" (num 1) ! 		! 1: restart from .bin files. 0: start from bare ground

! Path to IFS spinup data - MUST have trailing "/" (linux/unix systems) or "\" (Windows)
! NSC:
param "ifs_spinup_dir" (str "/nobackup/rossby15/sm_paumi/ecev3/processed/daily/")
! Paul's PC:
!param "ifs_spinup_dir" (str "C:\DATA\J\EC-Earth\Version3p1_output\se21\daily\")

! N deposition (default is pre-industrial level of 2 kgN/ha/year)
param "ndep" (num 2)

! Print Lon/Lat with extra precision. Default is 1
coordinates_precision 6

! Use distinct sand/silt/clay fractions for each IFS soil type in N code
textured_soil 1


!///////////////////////////////////////////////////////////////////////////////////////
!// PARAMETERS FOR PFTS
!// Run GUESS with -help option for list of keywords and their meanings

group "common" (

	! Parameters common to all PFTs

	lambda_max 0.8
	emax 5
	reprfrac 0.1
	wscal_min 0.35
	drought_tolerance 0.0001	
	! default value - ensures that this has little effect even if  
	! ifdroughtlimitedestab is turned on
	!landcover "natural" ! ecev3 - specify below
	turnover_harv_prod 1
)

group "tree" (

	! Parameters common to all trees

	common
	landcover "natural" ! ecev3
	lifeform "tree"
	crownarea_max 50	
	ltor_max 1
	turnover_root 0.7
	rootdist 0.6 0.4	
	k_allom2 60		
	k_allom3 0.67
	k_rp 1.6
	wooddens 200
	cton_root 29
	cton_sap 330
	nuptoroot 0.0028
	km_volume 0.000001477
	pathway "c3"
	respcoeff 1.0
	kest_repr 200
	kest_bg 0.1 	! 1 i guess2008
	kest_pres 1 	! 0 i guess2008
	k_chilla 0
	k_chillb 100
	k_chillk 0.05
	litterme 0.3
	harv_eff 0.7
	res_outtake 0.75
	harvest_slow_frac 0.33
	turnover_harv_prod 0.04
)

group "shrub" (	
	! Unchanged from species version
	common
	lifeform "tree"
	leafphysiognomy "broadleaf"
	crownarea_max 10
	ltor_max 1
	k_allom1 100
	k_allom2 5
	k_allom3 0.67
	k_rp 1.6
	wooddens 250
	!cton_leaf_min 16	
	cton_root 29
	cton_sap 330
	nuptoroot 0.0028
	km_volume 0.000001477
	fnstorage 0.3
	pathway "c3"
	kest_repr 200
	kest_bg 0.1
	kest_pres 1
	litterme 0.3
	rootdist 0.6 0.4
	longevity 100
)


group "grass" (

	! Parameters common to all grasses

	common
	lifeform "grass"
	leafphysiognomy "broadleaf"
	ltor_max 0.5
	rootdist 0.9 0.1  ! Fraction of fine roots in the upper and lower soil layers.
	gmin 0.5
	phenology "any"
	phengdd5ramp 100
	leaflong 1		! Leaf longevity (years)
	turnover_leaf 1
	turnover_root 0.7
	!cton_leaf_min 16
	cton_root 29
	nuptoroot 0.00551
	km_volume 0.000001876
	fnstorage 0.3
	litterme 0.2
	parff_min 1000000	
	fireresist 0.5
	intc 0.01
	ga 0.030

)


group "broadleaved" (

	! Parameters common to all broadleaved trees

	leafphysiognomy "broadleaf"
	!cton_leaf_min 16
	k_allom1 250
	k_latosa 6000
	gmin 0.5
	intc 0.02
	ga 0.040
)

group "needleleaved" (

	! Parameters common to all needleleaved trees

	leafphysiognomy "needleleaf"
	!cton_leaf_min 28
	k_allom1 150
	k_latosa 5000
	gmin 0.3
	intc 0.06
	ga 0.140
)

group "evergreen" (

	! Parameters common to all evergreen trees

	phenology "evergreen"
	fnstorage 0.05
	phengdd5ramp 0
)

group "summergreen" (

	! Parameters common to all summergreen trees

	phenology "summergreen"
	fnstorage 0.15
	phengdd5ramp 200
	leaflong 0.5
	turnover_leaf 1
)

group "boreal" (

	! Parameters common to all boreal trees

	pstemp_min -4
	pstemp_low 10
	pstemp_high 25
	pstemp_max 38
	respcoeff 1.0
)

group "temperate" (

	! Parameters common to all temperate trees

	pstemp_min -2
	pstemp_low 15
	pstemp_high 25
	pstemp_max 38
	respcoeff 1.0
)

group "tropical" (

	! Parameters common to all tropical trees

	tcmin_surv 15.5
	tcmin_est 15.5
	tcmax_est 1000   ! no limit
	twmin_est -1000  ! no limit
	gdd5min_est 0    ! no limit
	pstemp_min 2
	pstemp_low 25
	pstemp_high 30
	pstemp_max 55
	respcoeff 0.15	
)


! greff_min values below calibrated for the smooth (ifsmoothgreffmort 1) option 
group "shade_tolerant" (
	est_max 0.05					
	parff_min 350000			
	alphar 3.0          			
	greff_min 0.04				
	turnover_sap 0.05
)

! So far only trial values; not used in this global version
group "intermediate_shade_tolerant" (
	est_max 0.15					
	parff_min 2000000			
	alphar 7.0          			
	greff_min 0.06				
	turnover_sap 0.075
)

! From global version; values from orginal European version after "!"
group "shade_intolerant" (
	est_max 0.2					
	parff_min 2500000 
	alphar 10.0 
	greff_min 0.08
	turnover_sap 0.1
)



pft "BNE" (

	! Boreal needleleaved evergreen tree

	include 1
	tree
	needleleaved
	shade_tolerant
	evergreen
	boreal
	leaflong 3
	turnover_leaf 0.33
	tcmin_surv -31
	tcmin_est -30
	tcmax_est -1
	twmin_est 5
	gdd5min_est 500
	longevity 500
	fireresist 0.3
	eps_iso 8.0
	seas_iso 0
	eps_mon 4.8
	storfrac_mon 0.5
)


pft "BINE" (

	! Boreal needleleaved evergreen tree

	include 1
	tree
	needleleaved
	shade_intolerant
	evergreen
	boreal
	leaflong 3
	turnover_leaf 0.33
	tcmin_surv -31
	tcmin_est -30
	tcmax_est -1
	twmin_est 5
	gdd5min_est 500
	longevity 500
	fireresist 0.3
	eps_iso 8.0
	seas_iso 0
	eps_mon 4.8
	storfrac_mon 0.5
)


pft "BNS" (

	! Boreal needleleaved summergreen tree

	include 1
	tree
	needleleaved
	shade_intolerant
	summergreen
	boreal
	tcmin_surv -1000  ! no limit
	tcmin_est -1000   ! no limit
	tcmax_est -2
	twmin_est -1000   ! no limit
	twminusc 43       ! AA from TH 03-11 added this
	gdd5min_est 350	! Stefan added new value, old 500
	phengdd5ramp 100	! Stefan added new value, old 200
	longevity 300
	fireresist 0.3
	eps_iso 8.0
	seas_iso 1
	eps_mon 4.8
	storfrac_mon 0.5
)

pft "TeNE" (

	! Temperate needleleaved evergreen tree

	include 0
	tree
	needleleaved
	shade_intolerant ! cf Jun_oxy, Pin_hal in europe.ins
	evergreen
	temperate
	leaflong 3
	turnover_leaf 0.33
	tcmin_surv -2 ! As in Sitch et al. (2003), a little lower than TeBE
	tcmin_est -2 ! As in Sitch et al. (2003), a little lower than TeBE
	tcmax_est 10 ! Hickler et al. (2012) have 9 degC for Pin_hal
	twmin_est 5  ! low, since Hickler et al. (2012) have -1000 for Jun_oxy
	gdd5min_est 2000 !(Stefans value 900)2000 ! As TeBE, a little lower than Jun_oxy, Pin_hal in europe.ins
	longevity 300  ! Hickler et al. (2012) have 350 for Pin_hal
	fireresist 0.3 ! Hickler et al. (2012) have 0.2 for Pin_hal and 0.4 for Jun_oxy
	    eps_iso 8.0	!?????????????
        seas_iso 0	!?????????????
        eps_mon 4.8	!?????????????
        storfrac_mon 0.5	!?????
)

pft "TeBS" (

	! Shade-tolerant temperate broadleaved summergreen tree

	include 1
	tree
	broadleaved
	shade_tolerant
	summergreen
	temperate
	tcmin_surv -14
	tcmin_est -13
	tcmax_est 6
	twmin_est 5
	gdd5min_est 1100
	longevity 400
	fireresist 0.1
	eps_iso 45.0
	seas_iso 1
	eps_mon 1.6
	storfrac_mon 0.
)

pft "IBS" (

	! Shade-intolerant broadleaved summergreen tree

	include 1
	tree
	broadleaved
	shade_intolerant
	summergreen
	boreal
	tcmin_surv -30
	tcmin_est -30
	tcmax_est 7
	twmin_est -1000  !no limit
	gdd5min_est 350 !from TH 2010-03-10 AA
	longevity 300 !from TH 2010-04-07 was 300 AA
	fireresist 0.1
	eps_iso 45.0
	seas_iso 1
	eps_mon 1.6
	storfrac_mon 0.
)

pft "TeBE" (

	! Temperate broadleaved evergreen tree

	include 1
	tree
	broadleaved
	shade_tolerant
	evergreen
	temperate
	leaflong 3
	turnover_leaf 0.33
	tcmin_surv -1
	tcmin_est 0
	tcmax_est 18.8
	twmin_est 5
	gdd5min_est 2000
	longevity 300 !from TH 2010-04-07 was 350 AA
	fireresist 0.3
	eps_iso 24.0
	seas_iso 0
	eps_mon 1.6
	storfrac_mon 0.
)

pft "TrBE" (

	! Tropical broadleaved evergreen tree

	include 1
	tree
	broadleaved
	shade_tolerant
	evergreen
	tropical
	leaflong 2
	turnover_leaf 0.5
	longevity 500   !from Thomas H 2010-03-30 new 500 instead of 600 2010-04-07
	fireresist 0.1
	eps_iso 24.0
	seas_iso 0
	eps_mon 0.8
	storfrac_mon 0.
)


pft "TrIBE" (

	! Tropical broadleaved evergreen tree

	include 1
	tree
	broadleaved
	shade_intolerant
	evergreen
	tropical
	leaflong 2
	turnover_leaf 0.5
	longevity 200
	fireresist 0.1
	eps_iso 24.0
	seas_iso 0
	eps_mon 0.8
	storfrac_mon 0.

)


pft "TrBR" (

	! Tropical broadleaved raingreen tree

	include 1
	tree
	broadleaved
	shade_intolerant
	tropical
	phenology "raingreen"
	fnstorage 0.15
	leaflong 0.5
	turnover_leaf 1
	longevity 400    ! from Thomas h 2010-03-30
	fireresist 0.3
	eps_iso 45.0
	seas_iso 0
	eps_mon 2.4
	storfrac_mon 0.
)

pft "C3G" (

	! Cool (C3) grass

	include 1
	landcover "natural" ! ecev3
	grass
	pathway "c3"
	respcoeff 1.0
	pstemp_min -5
	pstemp_low 10
	pstemp_high 30
	pstemp_max 45
	tcmin_surv -1000	!no limit
	tcmin_est -1000 	!no limit
	tcmax_est 1000  	!no limit
	twmin_est -1000 	!no limit
	gdd5min_est 0   	!no limit
	eps_iso 16.0
	seas_iso 1
	eps_mon 1.6
	storfrac_mon 0.5
)

pft "C4G" (

	! Warm (C3) grass

	include 1
	landcover "natural" ! ecev3
	grass
	pathway "c4"
	respcoeff 0.15
	pstemp_min 6
	pstemp_low 20
	pstemp_high 45
	pstemp_max 55
	tcmin_surv 15.5
	tcmin_est 15.5
	tcmax_est 1000  !no limit
	twmin_est -1000 !no limit
	gdd5min_est 0   !no limit
	eps_iso 8.0
	seas_iso 0
	eps_mon 2.4
	storfrac_mon 0.5
)



! ecev3
pft "lowC3G" (

	! EC-Earth low tiles
	! Cool (C3) grass

	include 1
	landcover "pasture" ! ecev3
	grass
	pathway "c3"
	respcoeff 1.0
	pstemp_min -5
	pstemp_low 10
	pstemp_high 30
	pstemp_max 45
	tcmin_surv -1000	!no limit
	tcmin_est -1000 	!no limit
	tcmax_est 1000  	!no limit
	twmin_est -1000 	!no limit
	gdd5min_est 0   	!no limit
	eps_iso 16.0
	seas_iso 1
	eps_mon 1.6
	storfrac_mon 0.5
)

! ecev3
pft "lowC4G" (

	! Warm (C3) grass
	! EC-Earth low tiles

	include 1
	landcover "pasture" ! ecev3
	grass
	pathway "c4"
	respcoeff 0.15
	pstemp_min 6
	pstemp_low 20
	pstemp_high 45
	pstemp_max 55
	tcmin_surv 15.5
	tcmin_est 15.5
	tcmax_est 1000  !no limit
	twmin_est -1000 !no limit
	gdd5min_est 0   !no limit
	eps_iso 8.0
	seas_iso 0
	eps_mon 2.4
	storfrac_mon 0.5
)


