! =================================================================================================================================
! MODULE       : constantes
!
! CONTACT      : orchidee-help _at_ listes.ipsl.fr
!
! LICENCE      : IPSL (2006)
! This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
!
!>\BRIEF        "constantes" module contains subroutines to initialize most of the exernalized parameters. This module
!!              also make a use to the module constantes_var where the parameters are declared.
!!
!!\n DESCRIPTION: This module contains subroutines to initialize most of the exernalized parameters. This module
!!                also make a use to the module constantes_var where the parameters are declared.\n
!!                This module can be used to acces the subroutines and the constantes. The constantes declarations
!!                can also be used seperatly with "USE constantes_var".
!!
!! RECENT CHANGE(S): Didier Solyga : This module contains now all the externalized parameters of ORCHIDEE 
!!                   listed by modules which are not pft-dependent  
!!                   Josefine Ghattas 2013 : The declaration part has been extracted and moved to module constates_var
!!
!! REFERENCE(S)	: 
!! - Louis, Jean-Francois (1979), A parametric model of vertical eddy fluxes in the atmosphere. 
!! Boundary Layer Meteorology, 187-202.
!!
!! SVN          :
!! $HeadURL: svn://forge.ipsl.fr/orchidee/trunk/ORCHIDEE/src_parameters/constantes.f90 $
!! $Date: 2024-04-04 14:56:55 +0200 (jeu. 04 avril 2024) $
!! $Revision: 8524 $
!! \n
!_ ================================================================================================================================

MODULE constantes

  USE constantes_var
  USE defprec
  USE ioipsl_para, ONLY : getin_p, ipslerr_p
  USE mod_orchidee_para_var, ONLY : numout
  USE time, ONLY : one_day, dt_sechiba

  IMPLICIT NONE
  
CONTAINS


!! ================================================================================================================================
!! SUBROUTINE   : activate_sub_models
!!
!>\BRIEF         This subroutine reads the flags in the configuration file to
!! activate some sub-models like routing, irrigation, fire, herbivory, ...  
!!
!! DESCRIPTION  : None
!!
!! RECENT CHANGE(S): None
!!
!! MAIN OUTPUT VARIABLE(S): None
!!
!! REFERENCE(S) : None
!!
!! FLOWCHART    : None
!! \n
!_ ================================================================================================================================

  SUBROUTINE activate_sub_models()

    IMPLICIT NONE

    !! 0. Variables and parameters declaration

    !! 0.4 Local variables

    !_ ================================================================================================================================

    IF (ok_stomate) THEN

       !Config Key   = HERBIVORES
       !Config Desc  = herbivores allowed?
       !Config If    = OK_STOMATE 
       !Config Def   = n
       !Config Help  = With this variable, you can determine
       !Config         if herbivores are activated
       !Config Units = [FLAG]
       CALL getin_p('HERBIVORES', ok_herbivores)
       !
       !Config Key   = TREAT_EXPANSION
       !Config Desc  = treat expansion of PFTs across a grid cell?
       !Config If    = OK_STOMATE 
       !Config Def   = n
       !Config Help  = With this variable, you can determine
       !Config         whether we treat expansion of PFTs across a
       !Config         grid cell.
       !Config Units = [FLAG]
       CALL getin_p('TREAT_EXPANSION', treat_expansion)

       !Config Key   = SLA_DYN
       !Config Desc  = Account for a dynamic SLA
       !Config Def   = n
       !Config if    = OK_STOMATE
       !Config Help  = If this flag is set to true (y) then the SLA
       !Config         is computed dynamically, varying with leaf biomass
       !Config Units = [FLAG]
       CALL getin_p('SLA_DYN',sla_dyn)

       !Config Key   = LPJ_GAP_CONST_MORT
       !Config Desc  = Constant mortality
       !Config If    = OK_STOMATE AND NOT OK_DGVM
       !Config Def   = y/n depending on OK_DGVM
       !Config Help  = set to TRUE if constant mortality is to be activated
       !Config         
       !Config Units = [FLAG]

       ! Set Default value different if DGVM is activated.
       IF ( ok_dgvm ) THEN
          lpj_gap_const_mort=.FALSE.
       ELSE
          lpj_gap_const_mort=.TRUE.
       END IF
       CALL getin_p('LPJ_GAP_CONST_MORT', lpj_gap_const_mort)

       IF (ok_dgvm .AND. lpj_gap_const_mort) THEN
          CALL ipslerr_p(1,"activate_sub_models","Both OK_DGVM and LPJ_GAP_CONST_MORT are activated.",&
               "This combination is possible but unusual","The simulation will continue with these flags activated." )
       ELSEIF (.NOT. ok_dgvm  .AND. .NOT. lpj_gap_const_mort) THEN
           CALL ipslerr_p(3,"activate_sub_models", &
                "The combination of OK_DGVM=false and LPJ_GAP_CONST_MORT=false is not operational in this version", &
                "Some parts of the code should first be revised.","" )
       END IF

       !Config Key   = HARVEST_AGRI
       !Config Desc  = Harvest model for agricultural PFTs.
       !Config If    = OK_STOMATE 
       !Config Def   = y
       !Config Help  = Compute harvest above ground biomass for agriculture.
       !Config         Change daily turnover.
       !Config Units = [FLAG]
       CALL getin_p('HARVEST_AGRI', harvest_agri)
       !
       !Config Key   = FIRE_DISABLE
       !Config Desc  = no fire allowed
       !Config If    = OK_STOMATE 
       !Config Def   = y
       !Config Help  = With this variable, you can allow or not
       !Config         the estimation of CO2 lost by fire
       !Config Units = [FLAG]
       CALL getin_p('FIRE_DISABLE', disable_fire)
       !
       !Config Key   = SPINUP_ANALYTIC
       !Config Desc  = Activation of the analytic resolution of the spinup.
       !Config If    = OK_STOMATE
       !Config Def   = n
       !Config Help  = Activate this option if you want to solve the spinup by the Gauss-Jordan method.
       !Config Units = BOOLEAN    
       CALL getin_p('SPINUP_ANALYTIC',spinup_analytic)

    ENDIF


     !
     ! HACKS
     !
     !Config Key   = HACK_ENERBIL_HYDROL
     !Config Desc  = Flag to skip a particular block of code in mleb.f90 
     !Config If    = -
     !Config Def   = n
     !Config Help  = Flag to skip a particular block of code in mleb.f90 
     !               which results in incorrect results for large scale simulations.
     !Config Units = [FLAG]
     CALL getin_p('HACK_ENERBIL_HYDROL',hack_enerbil_hydrol)
     !
     !Config Key   = HACK_E_FRAC
     !Config Desc  = Bypass root length in the calculation of psi_soilroot 
     !Config If    = OK_HYDROL_ARCH
     !Config Def   = n
     !Config Help  = Bypass root length in the calculation of psi_soilroot 
     !Config Units = [FLAG]
     CALL getin_p('HACK_E_FRAC',hack_e_frac)
     
     !Config Key   = HACK_PGAP
     !Config Desc  = Flag to use Lambert Beer instead of Pgap 
     !Config If    = -
     !Config Def   = n
     !Config Help  = Flag to use Lambert Beer instead of Pgap to calculate veget. 
     !               Only for debugging as it may introduce inconsistencies.
     !Config Units = [FLAG]
     CALL getin_p('HACK_PGAP',hack_pgap)     

     !Config Key   = HACK_VESSEL_LOSS
     !Config Desc  = constant vessel_loss in hydraulic_rachitecture
     !Config If    = OK_VESSEL_MORTALITY
     !Config Def   = -9999
     !Config Help  = When set outside the range from 0 to 1 it will not be used.
     !Config Units = unitless
     CALL getin_p('HACK_VESSEL_LOSS',hack_vessel_loss)

     !Config Key   = HACK_VEGET_MAX_NEW
     !Config Desc  = Prescribe VEGET_MAX_NEW rather than reading from a map 
     !Config If    = -
     !Config Def   = n
     !Config Help  = Read veget_max_new from run.def. This is intended to 
     !               be used in combination with a restart file. It only 
     !               works once per simulation. It can be used to debug 
     !               simplified LCC test cases. See slowproc.f90 for more
     !               details. Only for debugging as it will introduce 
     !               inconsistencies.
     !Config Units = [FLAG]
     CALL getin_p('HACK_VEGET_MAX_NEW',hack_veget_max_new) 
     
     !Config Key   = HACK_KB_M1
     !Config Desc  = Use higher threshold for small lai in the calculation of kB_m1 in condveg
     !Config If    = -
     !Config Def   = n
     !Config Help  = 
     !Config Units = [FLAG]
     CALL getin_p('HACK_KB_M1',hack_kb_m1)

     !Config Key   = TRUSTING_HACK_AGE_CLASS
     !Config Desc  = Skip the calculation of redistributing biomass between age classes
     !Config If    = -
     !Config Def   = n
     !Config Help  = In age_class_distr their is a calculation that redistributes the 
     !               biomass between age classes. Although mass is conserved during this
     !               calculation it results in precision errors that propagate through
     !               the model calculations. In the trusting we have one test case that 
     !               helps to check the technical integrity of the age class distribution
     !               code: if the model is run without LCC and disturbances, A simulation
     !               without age classes should generate the exact same results as one with 
     !               age classes (but the dimensions of these simulations differ). If 
     !               biomass is recalculated this test fails. With this hack, the biomass is
     !               explicitly moved from one age class to another without any calculations
     !               and thus without any precision errors. With this hack set to .TRUE. 
     !               the model can be trusted for the age class code. This hack
     !               should not be used in simulation experiments as biomass
     !               from different age classes will NOT be merged but simply
     !               overwritten. If all goes well this should result in a mass
     !               balance error.
     !Config Units = [FLAG]
     CALL getin_p('TRUSTING_HACK_AGE_CLASS',trusting_hack_age_class)

     !
     ! Check consistency (see later)
     !
!!$        IF(.NOT.(ok_routing) .AND. (doirrigation .OR. dofloodplains)) THEN
!!$           CALL ipslerr_p(2,'activate_sub_models', &
!!$               &     'Problem :you tried to activate the irrigation and floodplains without activating the routing',&
!!$               &     'Are you sure ?', &
!!$               &     '(check your parameters).')
!!$        ENDIF

!!$        IF(.NOT.(ok_stomate) .AND. (ok_herbivores .OR. treat_expansion .OR. lpj_gap_const_mort &
!!$            & .OR. harvest_agri .OR. disable_fire)) THEN
!!$          CALL ipslerr_p(2,'activate_sub_models', &
!!$               &     'Problem : try to activate the following options : herbivory, treat_expansion, fire,',&
!!$               &     'harvest_agri and constant mortality without stomate activated.',&
!!$               &     '(check your parameters).')
!!$        ENDIF


  END SUBROUTINE activate_sub_models

!! ================================================================================================================================
!! SUBROUTINE   : veget_config
!!
!>\BRIEF         This subroutine reads the flags controlling the configuration for
!! the vegetation : impose_veg, veget_mpa, lai_map, etc...       
!!
!! DESCRIPTION  : None
!!
!! RECENT CHANGE(S): None
!!
!! MAIN OUTPUT VARIABLE(S): 
!!
!! REFERENCE(S) :
!!
!! FLOWCHART    :
!! \n
!_ ================================================================================================================================

  SUBROUTINE veget_config

    IMPLICIT NONE

    !! 0. Variables and parameters declaration

    !! 0.4 Local variables  
    CHARACTER(LEN=30)          :: veget_str         !! update frequency for landuse    
    INTEGER                    :: l
    INTEGER(i_std)             :: ier               !! Check errors in allocation
    INTEGER(i_std)             :: ilevel            !! Allocation indice

    !_ ================================================================================================================================


    !Config Key   = AGRICULTURE
    !Config Desc  = agriculture allowed?
    !Config If    = OK_SECHIBA or OK_STOMATE
    !Config Def   = y
    !Config Help  = With this variable, you can determine
    !Config         whether agriculture is allowed
    !Config Units = [FLAG]
    CALL getin_p('AGRICULTURE', agriculture)
    !
    !Config Key   = IMPOSE_VEG
    !Config Desc  = Should the vegetation be prescribed ?
    !Config If    = OK_SECHIBA or OK_STOMATE
    !Config Def   = n
    !Config Help  = This flag allows the user to impose a vegetation distribution
    !Config         and its characteristics. It is espacially interesting for 0D
    !Config         simulations. On the globe it does not make too much sense as
    !Config         it imposes the same vegetation everywhere
    !Config Units = [FLAG]
    CALL getin_p('IMPOSE_VEG', impveg)

    !Config Key   = IMPOSE_SOILT
    !Config Desc  = Should the soil type be prescribed ?
    !Config Def   = n
    !Config If    = 
    !Config Help  = This flag allows the user to impose a soil type distribution.
    !Config         It is espacially interesting for 0D
    !Config         simulations. On the globe it does not make too much sense as
    !Config         it imposes the same soil everywhere
    !Config Units = [FLAG]
    CALL getin_p('IMPOSE_SOILT', impsoilt)     

    !Config Key   = IMPOSE_SLOPE
    !Config Desc  = Should reinf_slope be prescribed ?
    !Config Def   = n
    !Config If    = 
    !Config Help  = This flag allows the user to impose a uniform fraction of  
    !Config         reinfiltrated surface runoff, with value REINF_SLOPE 
    !Config Units = [FLAG]
    CALL getin_p('IMPOSE_SLOPE', impslope)

    !Config Key   = IMPOSE_NINPUT_DEP
    !Config Desc  = Should the N inputs from atmospheric deposition be prescribed ?
    !Config Def   = n
    !Config If    = NOT IMPOSE_CN
    !Config Help  = This flag allows the user to impose N inputs from atmospheric deposition 
    !Config         It is espacially interesting for 0D
    !Config         simulations. On the globe it does not make too much sense as
    !Config         it imposes the same N inputs everywhere
    !Config Units = [FLAG]
    CALL getin_p('IMPOSE_NINPUT_DEP', impose_ninput_dep)     

    !Config Key   = IMPOSE_NINPUT_FERT
    !Config Desc  = Should the N inputs from fertilizer be prescribed ?
    !Config Def   = n
    !Config If    = -
    !Config Help  = This flag allows the user to impose N inputs from fertilizer application
    !Config         It is espacially interesting for 0D
    !Config         simulations. On the globe it does not make too much sense as
    !Config         it imposes the same N inputs everywhere
    !Config Units = [FLAG]
    CALL getin_p('IMPOSE_NINPUT_FERT', impose_ninput_fert)

    !Config Key   = IMPOSE_NINPUT_MANURE
    !Config Desc  = Should the N inputs from manure be prescribed ?
    !Config Def   = n
    !Config If    = -
    !Config Help  = This flag allows the user to impose N inputs from manure application
    !Config         It is espacially interesting for 0D
    !Config         simulations. On the globe it does not make too much sense as
    !Config         it imposes the same N inputs everywhere
    !Config Units = [FLAG]
    CALL getin_p('IMPOSE_NINPUT_MANURE', impose_ninput_manure)

    !Config Key   = IMPOSE_NINPUT_BNF
    !Config Desc  = Should the N inputs from biological nitrogen fixation (BNF) be prescribed ?
    !Config Def   = n
    !Config If    = -
    !Config Help  = This flag allows the user to impose N inputs from biological nitrogen fixation (BNF)
    !Config         It is espacially interesting for 0D
    !Config         simulations. On the globe it does not make too much sense as
    !Config         it imposes the same N inputs everywhere
    !Config Units = [FLAG]
    CALL getin_p('IMPOSE_NINPUT_BNF', impose_ninput_bnf)

    !Config Key   = TEST_GRID
    !Config Desc  = grid cell for which extra output is written to the out_execution file
    !Config If    = OK_STOMATE
    !Config Def   = 1
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('TEST_GRID',test_grid)   

    !Config Key   = TEST_PFT
    !Config Desc  = pft for which extra output is written to the out_execution file
    !Config If    = OK_STOMATE
    !Config Def   = 6
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('TEST_PFT',test_pft)   

    !Config Key   = MIN_CANOPY_HEIGHT_PRESCRIBED
    !Config Desc  = Starting height of the canopy
    !Config If    = READ_LAI=1
    !Config Def   = 10
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('MIN_CANOPY_HEIGHT_PRESCRIBED',min_canopy_height_prescribed)   

    !Config Key   = MAX_CANOPY_HEIGHT_PRESCRIBED
    !Config Desc  = Ending height of the canopy
    !Config If    = READ_LAI=1
    !Config Def   = 50
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('MAX_CANOPY_HEIGHT_PRESCRIBED',max_canopy_height_prescribed)   

    !Config Key   = CANOPY_DENSITY_PRESCRIBED
    !Config Desc  = Prescribeddensity of the canopy in ind/m^2
    !Config If    = READ_LAI=1
    !Config Def   = 0.15
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('CANOPY_DENSITY_PRESCRIBED',canopy_density_prescribed)   

    !Config Key   = MAXIMUM_LAI
    !Config Desc  = Maximum LAI over the year
    !Config If    = READ_LAI=1
    !Config Def   = 5
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('MAXIMUM_LAI',maximum_lai)   

    !Config Key   = MINIMUM_LAI
    !Config Desc  = Minimum LAI over the year
    !Config If    = READ_LAI=1
    !Config Def   = 0
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('MINIMUM_LAI',minimum_lai)   

    !Config Key   = PHENOLOGY_DOY_START
    !Config Desc  = Starting day of the growing of the leaves
    !Config If    = READ_LAI=1
    !Config Def   = 1
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('PHENOLOGY_DOY_START',phenology_doy_start)   

    !Config Key   = SENESCENCE_DOY_END
    !Config Desc  = Ending day of the dying of the leaves
    !Config If    = READ_LAI=1
    !Config Def   = 365
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('SENESCENCE_DOY_END',senescence_doy_end)   

    !Config Key   = PHENOLOGY_DELTA
    !Config Desc  = Delta of doy between start and end of phenology
    !Config If    = READ_LAI=1
    !Config Def   = 30
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('PHENOLOGY_DELTA',phenology_delta)

    !Config Key   = SENESCENCE_DELTA
    !Config Desc  = Delta of doy between start and end of senescence
    !Config If    = READ_LAI=1
    !Config Def   = 30
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('SENESCENCE_DELTA',senescence_delta)


    nlevels_tot = nlevels*nlai
    
    ALLOCATE(lvllai_prescribed(nlevels_tot),stat=ier)
    IF (ier /= 0) THEN
       CALL ipslerr_p(3,'veget_config','Problem in allocation lvllai_prescribed','','')
    ENDIF

    DO ilevel =1,nlevels_tot
       lvllai_prescribed(ilevel) = 0.0
    ENDDO

    !Config Key   = LVLLAI_PRESCRIBED
    !Config Desc  = LAI per level
    !Config If    = READ_LAI=1
    !Config Def   = 0.0
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('LVLLAI_PRESCRIBED',lvllai_prescribed)   

    !Config Key   = VEGET_UPDATE
    !Config Desc  = Update vegetation frequency: 0Y or 1Y
    !Config If    = 
    !Config Def   = 0Y
    !Config Help  = The veget datas will be update each this time step. Must be 0Y if IMPOSE_VEG=y.
    !Config Units = [years]
    veget_update=0
    WRITE(veget_str,'(a)') '0Y'
    CALL getin_p('VEGET_UPDATE', veget_str)
    l=INDEX(TRIM(veget_str),'Y')
    READ(veget_str(1:(l-1)),"(I2.2)") veget_update

    ! Coherence test : veget_update can only be 0 or 1
    IF (veget_update /= 0 .AND. veget_update /= 1) then
       WRITE(numout,*) "Error in veget_update=", veget_update
       CALL ipslerr_p(3,'veget_config','VEGET_UPDATE can only be 0Y or 1Y.',&
            'Please correcte run.def file for VEGET_UPDATE','')
    END IF

    
    ! Coherence test for impveg and veget_update. Land use change can not be activated with impveg.
    IF (impveg .AND. veget_update > 0) THEN
       WRITE(numout,*) 'veget_update=',veget_update,' is not coeherent with impveg=',impveg
       CALL ipslerr_p(3,'slowproc_init','Incoherent values between impveg and veget_update', &
            'VEGET_UPDATE must be equal to 0Y if IMPOSE_VEG=y (impveg=true)','')
    END IF  
  

    !Config Key   = VEGETMAP_RESET
    !Config Desc  = Flag to change vegetation map without activating LAND USE change for carbon fluxes. At the same time carbon related variables are reset to zero.
    !Config If    = 
    !Config Def   = n
    !Config Help  = Use this option to change vegetation map while keeping VEGET_UPDATE=0Y
    !Config Units = [FLAG] 
    CALL getin_p('VEGETMAP_RESET', vegetmap_reset)


    !Config Key   = NINPUT_REINIT
    !Config Desc  = booleen to indicate that a new N INPUT file will be used.
    !Config If    = -
    !Config Def   = y
    !Config Help  = When set to y, the counter for the year of data grabbed in
    !Config         the Nitrogen input files will be reset to be equal to that of
    !Config         the first year present in the input file.  
    !Config         Then it is possible to change N INPUT file.
    !Config         Only seems to be
    !Config         useful set to n when the Nitrogen input file contains multiple years?
    !Config Units = [FLAG] 
    CALL getin_p('NINPUT_REINIT', ninput_reinit)
    
    !Config Key   = NINPUT_YEAR
    !Config Desc  = Year of the N input map to be read
    !Config If    = -
    !Config Def   = 1
    !Config Help  = First year for N inputs vegetation
    !Config         If NINPUT_YEAR is set to 0, this means there is no time axis in the Nitrogen
    !Config         input map.  If there is a time axis, NINPUT_YEAR can be set to any four digit year.
    !Config         The code will look for an input file name corresponding to this year and
    !Config         take the data from this file.
    !Config Units = [FLAG] 
    CALL getin_p('NINPUT_YEAR', ninput_year_orig)
    
    !Config Key   = NINPUT_SUFFIX_YEAR
    !Config Desc  = Do the Ninput dataset have a 'year' suffix
    !Config If    = -
    !Config Def   = false
    !Config Help  = A flag to indicate if nitrogen input files have a year suffix (before .nc)
    !Config         If NINPUT_SUFFIX_YEAR is set to true, the code searches for a Nitrogen input file of the 
    !Config         format "filename_YEAR.nc" where YEAR is the NINPUT_YEAR
    !Config Units = [FLAG] 
    CALL getin_p('NINPUT_SUFFIX_YEAR', ninput_suffix_year)
        

  END SUBROUTINE veget_config


!! ================================================================================================================================
!! SUBROUTINE   : veget_config
!!
!>\BRIEF         This subroutine reads in the configuration file the imposed values of the parameters for all SECHIBA modules.  
!!
!! DESCRIPTION  : None
!!
!! RECENT CHANGE(S): None
!!
!! MAIN OUTPUT VARIABLE(S): 
!!
!! REFERENCE(S) :
!!
!! FLOWCHART    :
!! \n
!_ ================================================================================================================================

  SUBROUTINE config_sechiba_parameters

    IMPLICIT NONE

    !! 0. Variables and parameters declaration

    !! 0.4 Local variables
    REAL(r_std) :: nudge_tau_mc     !! Temporary variable read from run.def
    REAL(r_std) :: nudge_tau_snow   !! Temporary variable read from run.def
    INTEGER     :: ilevel           !! index

    !_ ================================================================================================================================

    ! Global : parameters used by many modules
    CALL getin_p('TESTPFT',testpft)


    !Config Key   = NSNOW
    !Config Desc  = The number of snow levels: 3 or 12
    !Config If    = OK_SECHIBA
    !Config Def   = 3
    !Config Help  = 
    !Config Units = [-]
    nsnow=3
    CALL getin_p('NSNOW',nsnow)
    IF (nsnow /= 3 .AND. nsnow /=12 ) CALL ipslerr_p(3,"config_sechiba_parameters","ERROR : NSNOW can only be 3 or 12.", &
                                                       "Change in orchidee.def", " ")

    !Config Key   = NICE
    !Config Desc  = The number of ice levels
    !Config If    = OK_ICE_SHEET
    !Config Def   = 8
    !Config Help  = 
    !Config Units = [-]
    nice=8
    CALL getin_p('NICE',nice)
    IF ( nice /=8 ) CALL ipslerr_p(3,"config_sechiba_parameters","ERROR : NICE can only be 8 for the moment.", &
         "Change in orchidee.def", " ")

    IF (ok_ice_sheet) THEN
       !Config Key   = FRAC_MIN_ICE
       !Config Desc  = Limit of fraction of ice in the grid cell where the ice mask is considered as 1
       !Config If    = OK_ICE_SHEET AND .NOT. READ_ICE_SHEET_MASK
       !Config Def   = 0.70
       !Config Help  = This value is used as a threashold when calculation the ice_sheet_mask from frac_nobio
       !Config Units = [-]
       frac_min_ice=0.70
       CALL getin_p('FRAC_MIN_ICE',frac_min_ice)

       !Config Key   = READ_ICE_SHEET_MASK
       !Config Desc  = Read the ice sheet mask from file instead for using frac_nobio
       !Config If    = OK_ICE_SHEET
       !Config Def   = n
       !Config Help  = When this flag is set to true, FRAC_MIN_ICE is not used
       !Config Units = [-]
       read_ice_sheet_mask=.FALSE.
       CALL getin_p("READ_ICE_SHEET_MASK", read_ice_sheet_mask)

    END IF


    !Config Key   = MAXMASS_SNOW
    !Config Desc  = The maximum mass of a snow
    !Config If    = OK_SECHIBA
    !Config Def   = 3000.
    !Config Help  = 
    !Config Units = [kg/m^2]  
    CALL getin_p('MAXMASS_SNOW',maxmass_snow)
    !
    !Config Key   = SNOWCRI
    !Config Desc  = Sets the amount above which only sublimation occures 
    !Config If    = OK_SECHIBA
    !Config Def   = 1.5
    !Config Help  = 
    !Config Units = [kg/m^2]  
    CALL getin_p('SNOWCRI',snowcri)
    !
    !! Initialization of sneige
    sneige = snowcri/mille
    !
    !Config Key   = MIN_WIND
    !Config Desc  = Minimum wind speed
    !Config If    = OK_SECHIBA
    !Config Def   = 0.1
    !Config Help  = 
    !Config Units = [m/s]
    CALL getin_p('MIN_WIND',min_wind)
    !
    !Config Key   = MAX_SNOW_AGE
    !Config Desc  = Maximum period of snow aging 
    !Config If    = OK_SECHIBA
    !Config Def   = 50.
    !Config Help  = 
    !Config Units = [days?]
    CALL getin_p('MAX_SNOW_AGE',max_snow_age)
    !
    !Config Key   = SNOW_TRANS
    !Config Desc  = Transformation time constant for snow
    !Config If    = OK_SECHIBA
    !Config Def   = 0.2
    !Config Help  = optimized on 04/07/2016
    !Config Units = [m]   
    CALL getin_p('SNOW_TRANS',snow_trans)
    !
    !Config Key   = SNOW_TRANS_NOBIO
    !Config Desc  = Transformation time constant for snow on nobio
    !Config If    = OK_SECHIBA
    !Config Def   = 1.
    !Config Help  = optimized on 18/02/2019
    !Config Units = [m]   
    CALL getin_p('SNOW_TRANS_NOBIO',snow_trans_nobio)
    !
    !Config Key   = SNOWA_AGED_NOBIO_VIS
    !Config Desc  = Minimum snow albedo value for nobio type after aging (dirty old snow), visible albedo
    !Config If    = OK_SECHIBA
    !Config Def   = 0.58
    !Config Help  = optimized on 30/06/2022
    !Config Units = [-]   
    CALL getin_p('SNOWA_AGED_NOBIO_VIS',snowa_aged_nobio_vis)
    !
    !Config Key   = SNOWA_AGED_NOBIO_NIR
    !Config Desc  = Minimum snow albedo value for nobio type after aging (dirty old snow), near infrared albedo
    !Config If    = OK_SECHIBA
    !Config Def   = 0.35
    !Config Help  = optimized on 30/06/2022
    !Config Units = [-]   
    CALL getin_p('SNOWA_AGED_NOBIO_NIR',snowa_aged_nobio_nir)
    !
    !Config Key   = SNOWA_DEC_NOBIO_VIS
    !Config Desc  = Decay rate of snow albedo value for nobio type, visible albedo
    !Config If    = OK_SECHIBA
    !Config Def   = 0.28
    !Config Help  = optimized on 30/06/2022
    !Config Units = [-]   
    CALL getin_p('SNOWA_DEC_NOBIO_VIS',snowa_dec_nobio_vis)
    !
    !Config Key   = SNOWA_DEC_NOBIO_NIR
    !Config Desc  = Decay rate of snow albedo value for nobio type, near infrared albedo
    !Config If    = OK_SECHIBA
    !Config Def   = 0.45
    !Config Help  = optimized on 30/06/2022
    !Config Units = [-]   
    CALL getin_p('SNOWA_DEC_NOBIO_NIR',snowa_dec_nobio_nir)
    
    !
    !Config Key   = OMG1
    !Config Desc  = Tuning constant for snow ageing on nobio areas
    !Config If    = OK_SECHIBA
    !Config Def   = 7.
    !Config Help  = optimized on 14/10/2020
    !Config Units = [-]   
    CALL getin_p('OMG1',omg1)
    !
    !Config Key   = OMG2
    !Config Desc  = Tuning constant for snow ageing on nobio areas
    !Config If    = OK_SECHIBA
    !Config Def   = 4.
    !Config Help  = optimized on 14/10/2020
    !Config Units = [-]   
    CALL getin_p('OMG2',omg2)

    
    !Config Key   = OK_NUDGE_MC
    !Config Desc  = Activate nudging of soil moisture
    !Config Def   = n
    !Config If    = 
    !Config Help  = 
    !Config Units = [FLAG]
    ok_nudge_mc = .FALSE.
    CALL getin_p('OK_NUDGE_MC', ok_nudge_mc)

    !Config Key   = NUDGE_TAU_MC
    !Config Desc  = Relaxation time for nudging of soil moisture expressed in fraction of the day
    !Config Def   = 1
    !Config If    = OK_NUDGE_MC
    !Config Help  = 
    !Config Units = [-]
    nudge_tau_mc = 1.0
    CALL getin_p('NUDGE_TAU_MC', nudge_tau_mc)
    IF (nudge_tau_mc < dt_sechiba/one_day) CALL ipslerr_p(3, 'hydrol_initialize', &
         'NUDGE_TAU_MC is smaller than the time step in sechiba which is not allowed.', &
         'Set NUDGE_TAU_MC higher or equal to dt_sechiba/one_day','')
    ! Calculate alpha to be used in hydrol
    alpha_nudge_mc = dt_sechiba/(one_day*nudge_tau_mc)
    IF (printlev>=2) WRITE(numout, *) 'ok_nudge_mc, nudge_tau_mc, alpha_nudge_mc =', &
         ok_nudge_mc, nudge_tau_mc, alpha_nudge_mc

    !Config Key   = OK_NUDGE_SNOW
    !Config Desc  = Activate nudging of snow variables
    !Config Def   = n
    !Config If    = 
    !Config Help  = 
    !Config Units = [FLAG]
    ok_nudge_snow = .FALSE.
    CALL getin_p('OK_NUDGE_SNOW', ok_nudge_snow)

    !Config Key   = NUDGE_TAU_SNOW
    !Config Desc  = Relaxation time for nudging of snow variables
    !Config Def   = 1
    !Config If    = OK_NUDGE_SNOW
    !Config Help  = 
    !Config Units = [-]
    nudge_tau_snow = 1.0
    CALL getin_p('NUDGE_TAU_SNOW', nudge_tau_snow)
    IF (nudge_tau_snow < dt_sechiba/one_day) CALL ipslerr_p(3, 'hydrol_initialize', &
         'NUDGE_TAU_SNOW is smaller than the time step in sechiba which is not allowed.', &
         'Set NUDGE_TAU_SNOW higher or equal to dt_sechiba/one_day','')
    ! Calculate alpha to be used in hydrol
    alpha_nudge_snow = dt_sechiba/(one_day*nudge_tau_snow)
    IF (printlev>=2) WRITE(numout, *) 'ok_nudge_snow, nudge_tau_snow, alpha_nudge_snow =', &
         ok_nudge_snow, nudge_tau_snow, alpha_nudge_snow


    !Config Key   = NUDGE_INTERPOL_WITH_XIOS
    !Config Desc  = Activate reading and interpolation with XIOS for nudging fields
    !Config Def   = n
    !Config If    = OK_NUDGE_MC or OK_NUDGE_SNOW
    !Config Help  = 
    !Config Units = [FLAG]
    nudge_interpol_with_xios = .FALSE.
    CALL getin_p('NUDGE_INTERPOL_WITH_XIOS', nudge_interpol_with_xios)

    !-
    ! condveg
    !-
    !
    !Config Key   = HEIGHT_DISPLACEMENT
    !Config Desc  = Magic number which relates the height to the displacement height.
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.75
    !Config Help  = 
    !Config Units = [m]  
    CALL getin_p('HEIGHT_DISPLACEMENT',height_displacement)
    !
    !Config Key   = Z0_BARE
    !Config Desc  = bare soil roughness length
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.01 
    !Config Help  = 
    !Config Units = [m]   
    CALL getin_p('Z0_BARE',z0_bare)
    !
    !Config Key   = Z0_ICE
    !Config Desc  = ice roughness length
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.001
    !Config Help  = 
    !Config Units = [m]   
    CALL getin_p('Z0_ICE',z0_ice)
    !
    !Config Key   = OK_SNOW_ALBEDO_CLM3
    !Config Desc  = Calculate the snow albedo according to CLM3
    !Config If    = OK_SECHIBA 
    !Config Def   = TRUE
    !Config Help  = 
    !Config Units = [FLAG]
    CALL getin_p('OK_SNOW_ALBEDO_CLM3',ok_snow_albedo_clm3)

    IF (ok_snow_albedo_clm3) THEN
       !
       !Config Key   = ALB_SNOW_0_VIS
       !Config Desc  = Albedo for VIS of fresh snow
       !Config If    = OK_SECHIBA 
       !Config Def   = 0.95 
       !Config Help  = 
       !Config Units = [-]
       CALL getin_p('ALB_SNOW_0_VIS',alb_snow_0(ivis))
       !
       !Config Key   = ALB_SNOW_0_NIR
       !Config Desc  = Albedo for NIR of fresh snow
       !Config If    = OK_SECHIBA 
       !Config Def   = 0.65
       !Config Help  = 
       !Config Units = [-]
       CALL getin_p('ALB_SNOW_0_NIR',alb_snow_0(inir))
       !
       !Config Key   = C_ALBEDO_VIS
       !Config Desc  = constant in albedo calculation
       !Config If    = OK_SECHIBA 
       !Config Def   = 0.2 
       !Config Help  = 
       !Config Units = [-]
       CALL getin_p('C_ALBEDO_VIS',c_albedo(ivis))
       !
       !Config Key   = C_ALBEDO_NIR
       !Config Desc  = constant in albedo calculation
       !Config If    = OK_SECHIBA 
       !Config Def   = 0.65
       !Config Help  = 
       !Config Units = [-] 
       CALL getin_p('C_ALBEDO_NIR',c_albedo(inir))

    ENDIF
    !
    !Config Key   = TCST_SNOWA
    !Config Desc  = Time constant of the albedo decay of snow
    !Config If    = OK_SECHIBA 
    !Config Def   = 10.0 
    !Config Help  = 
    !Config Units = [days]
    CALL getin_p('TCST_SNOWA',tcst_snowa)
    !
    !Config Key   = TCST_SNOWA_NOBIO
    !Config Desc  = Time constant of the albedo decay of snow for nobio
    !Config If    = OK_SECHIBA 
    !Config Def   = 2.0 
    !Config Help  = optimized on 18/02/2019
    !Config Units = [days]
    CALL getin_p('TCST_SNOWA_NOBIO',tcst_snowa_nobio)
    !
    !Config Key   = SNOWCRI_ALB
    !Config Desc  = Critical value for computation of snow albedo
    !Config If    = OK_SECHIBA
    !Config Def   = 2. 
    !Config Help  = 
    !Config Units = [cm]  
    CALL getin_p('SNOWCRI_ALB',snowcri_alb)
    !
    !
    !Config Key   = VIS_DRY
    !Config Desc  = The correspondance table for the soil color numbers and their albedo 
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.24, 0.22, 0.20, 0.18, 0.16, 0.14, 0.12, 0.10, 0.27
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('VIS_DRY',vis_dry)
    !
    !Config Key   = NIR_DRY
    !Config Desc  = The correspondance table for the soil color numbers and their albedo 
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.48, 0.44, 0.40, 0.36, 0.32, 0.28, 0.24, 0.20, 0.55
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('NIR_DRY',nir_dry)
    !
    !Config Key   = VIS_WET 
    !Config Desc  = The correspondance table for the soil color numbers and their albedo
    !Config If    = OK_SECHIBA  
    !Config Def   = 0.12, 0.11, 0.10, 0.09, 0.08, 0.07, 0.06, 0.05, 0.15
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('VIS_WET',vis_wet)
    !
    !Config Key   = NIR_WET
    !Config Desc  = The correspondance table for the soil color numbers and their albedo 
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.24, 0.22, 0.20, 0.18, 0.16, 0.14, 0.12, 0.10, 0.31
    !Config Help  = 
    !Config Units = [-]    
    CALL getin_p('NIR_WET',nir_wet)
    !
    !Config Key   = ALBSOIL_VIS
    !Config Desc  = 
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.18, 0.16, 0.16, 0.15, 0.12, 0.105, 0.09, 0.075, 0.25
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('ALBSOIL_VIS',albsoil_vis)
    !
    !Config Key   = ALBSOIL_NIR 
    !Config Desc  = 
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.36, 0.34, 0.34, 0.33, 0.30, 0.25, 0.20, 0.15, 0.45
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('ALBSOIL_NIR',albsoil_nir)
    !-
    !
    !Config Key   = ALB_DEADLEAF 
    !Config Desc  = albedo of dead leaves, VIS+NIR 
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.12, 0.35
    !Config Help  = 
    !Config Units = [-]     
    CALL getin_p('ALB_DEADLEAF',alb_deadleaf)
    !
    !Config Key   = ALB_ICE
    !Config Desc  = albedo of ice, VIS+NIR
    !Config If    = OK_SECHIBA
    !Config Def   = 0.60, 0.20
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('ALB_ICE',alb_ice)
    !
    !Config Key   = ZSICOEF1
    !Config Desc  = Thickness of ice levels
    !Config If    = OK_ICE_SHEET
    !Config Def   = 0.01, 0.05, 0.15, 0.5, 1., 5., 10., 50.
    !Config Help  = 
    !Config Units = [m]
    CALL getin_p('ZSICOEF1',zsicoef1)
    
    !
    ! Get the fixed snow albedo if needed
    !
    !Config Key   = CONDVEG_SNOWA
    !Config Desc  = The snow albedo used by SECHIBA
    !Config Def   = 1.E+20
    !Config if    = OK_SECHIBA
    !Config Help  = This option allows the user to impose a snow albedo.
    !Config         Default behaviour is to use the model of snow albedo
    !Config         developed by Chalita (1993).
    !Config Units = [-]
    CALL getin_p('CONDVEG_SNOWA',fixed_snow_albedo)
    !
    !Config Key   = ALB_BARE_MODEL
    !Config Desc  = Switch bare soil albedo dependent (if TRUE) on soil wetness
    !Config Def   = n
    !Config if    = OK_SECHIBA
    !Config Help  = If TRUE, the model for bare soil albedo is the old formulation.
    !Config         Then it depend on the soil dry or wetness. If FALSE, it is the 
    !Config         new computation that is taken, it is the mean of soil albedo.
    !Config Units = [FLAG]
    CALL getin_p('ALB_BARE_MODEL',alb_bare_model)
    !
    !Config Key   = ALB_BG_MODIS
    !Config Desc  = Read bare soil albedo from file with background MODIS data
    !Config Def   = n
    !Config if    = OK_SECHIBA
    !Config Help  = If TRUE, the bare soil albedo is read from file
    !Config         based on background MODIS data.  
    !Config         If FALSE, computaion depends on ALB_BARE_MODEL
    !Config Units = [FLAG]
    CALL getin_p('ALB_BG_MODIS',alb_bg_modis)
    !
    !Config Key   = IMPOSE_AZE
    !Config Desc  = Should the surface parameters be prescribed
    !Config Def   = n
    !Config if    = OK_SECHIBA
    !Config Help  = This flag allows the user to impose the surface parameters
    !Config         (Albedo Roughness and Emissivity). It is espacially interesting for 0D
    !Config         simulations. On the globe it does not make too much sense as
    !Config         it imposes the same vegetation everywhere
    !Config Units = [FLAG]
    CALL getin_p('IMPOSE_AZE',impaze)
    !
    IF(impaze) THEN
       !
       !Config Key   = CONDVEG_Z0
       !Config Desc  = Surface roughness
       !Config Def   = 0.15
       !Config If    = IMPOSE_AZE
       !Config Help  = Surface rougness to be used on the point if a 0-dim version
       !Config         of SECHIBA is used. Look at the description of the forcing  
       !Config         data for the correct value.
       !Config Units = [m]
       CALL getin_p('CONDVEG_Z0', z0_scal)  
       !
       !Config Key   = ROUGHHEIGHT
       !Config Desc  = Height to be added to the height of the first level
       !Config Def   = 0.0
       !Config If    = IMPOSE_AZE
       !Config Help  = ORCHIDEE assumes that the atmospheric level height is counted
       !Config         from the zero wind level. Thus to take into account the roughness
       !Config         of tall vegetation we need to correct this by a certain fraction
       !Config         of the vegetation height. This is called the roughness height in
       !Config         ORCHIDEE talk.
       !Config Units = [m] 
       CALL getin_p('ROUGHHEIGHT', roughheight_scal)
       ! 
       !Config Key   = CONDVEG_ALBVIS
       !Config Desc  = SW visible albedo for the surface
       !Config Def   = 0.25
       !Config If    = IMPOSE_AZE
       !Config Help  = Surface albedo in visible wavelengths to be used 
       !Config         on the point if a 0-dim version of SECHIBA is used. 
       !Config         Look at the description of the forcing data for 
       !Config         the correct value.
       !Config Units = [-]
       CALL getin_p('CONDVEG_ALBVIS', albedo_scal(ivis))
       !
       !Config Key   = CONDVEG_ALBNIR
       !Config Desc  = SW near infrared albedo for the surface
       !Config Def   = 0.25
       !Config If    = IMPOSE_AZE
       !Config Help  = Surface albedo in near infrared wavelengths to be used 
       !Config         on the point if a 0-dim version of SECHIBA is used. 
       !Config         Look at the description of the forcing data for 
       !Config         the correct value.
       !Config Units = [-]  
       CALL getin_p('CONDVEG_ALBNIR', albedo_scal(inir))
       !
       !Config Key   = CONDVEG_EMIS
       !Config Desc  = Emissivity of the surface for LW radiation
       !Config Def   = 1.0
       !Config If    = IMPOSE_AZE
       !Config Help  = The surface emissivity used for compution the LE emission
       !Config         of the surface in a 0-dim version. Values range between 
       !Config         0.97 and 1.. The GCM uses 0.98.
       !Config Units = [-] 
       CALL getin_p('CONDVEG_EMIS', emis_scal)
    ENDIF

    CALL getin_p('NEW_WATSTRESS',new_watstress)
    IF(new_watstress) THEN
       CALL getin_p('ALPHA_WATSTRESS',alpha_watstress)
    ENDIF

    !
    !Config Key   = ROUGH_DYN
    !Config Desc  = Account for a dynamic roughness height
    !Config Def   = y
    !Config if    = OK_SECHIBA
    !Config Help  = If this flag is set to true (y) then the roughness
    !Config         height is computed dynamically, varying with LAI
    !Config Units = [FLAG]
    CALL getin_p('ROUGH_DYN',rough_dyn)

    IF ( rough_dyn ) THEN
       
       !Config Key   = USE_RATIO_Z0M_Z0H
       !Config Desc  = To impose a constant ratio as in ROUGH_DYN=F
       !Config Def   = TRUE
       !Config If    = ROUGH_DYN
       !Config Help  = 
       !Config Units = [-] 
       CALL getin_p('USE_RATIO_Z0M_Z0H', use_ratio_z0m_z0h)

       !
       !Config Key   = C1
       !Config Desc  = Constant used in the formulation of the ratio of 
       !Config         the ratio of friction velocity to the wind speed
       !Config         at the canopy top 
       !Config         See Ershadi et al. (2015) for more info
       !Config Def   = 0.32
       !Config If    = ROUGH_DYN
       !Config Help  = 
       !Config Units = [-] 
       CALL getin_p('C1', c1)
       !
       !Config Key   = C2
       !Config Desc  = Constant used in the formulation of the ratio of 
       !Config         the ratio of friction velocity to the wind speed
       !Config         at the canopy top 
       !Config         See Ershadi et al. (2015) for more info
       !Config Def   = 0.264
       !Config If    = ROUGH_DYN
       !Config Help  = 
       !Config Units = [-] 
       CALL getin_p('C2', c2)
       !
       !Config Key   = C3
       !Config Desc  = Constant used in the formulation of the ratio of 
       !Config         the ratio of friction velocity to the wind speed
       !Config         at the canopy top 
       !Config         See Ershadi et al. (2015) for more info
       !Config Def   = 15.1
       !Config If    = ROUGH_DYN
       !Config Help  = 
       !Config Units = [-] 
       CALL getin_p('C3', c3)
       !
       !Config Key   = Cdrag_foliage
       !Config Desc  = Drag coefficient of the foliage
       !Config         See Ershadi et al. (2015) and Su et al. (2001) 
       !Config         for more info
       !Config Def   = 0.2
       !Config If    = ROUGH_DYN
       !Config Help  = 
       !Config Units = [-] 
       CALL getin_p('CDRAG_FOLIAGE', Cdrag_foliage)
       !
       !Config Key   = Ct
       !Config Desc  = Heat transfer coefficient of the leaf
       !Config         See Ershadi et al. (2015) and Su et al. (2001) 
       !Config         for more info
       !Config Def   = 0.01
       !Config If    = ROUGH_DYN
       !Config Help  = 
       !Config Units = [-] 
       CALL getin_p('CT', Ct)
       !
       !Config Key   = Prandtl
       !Config Desc  = Prandtl number used in the calculation of Ct*
       !Config         See Su et al. (2001) for more info
       !Config Def   = 0.71
       !Config If    = ROUGH_DYN
       !Config Help  = 
       !Config Units = [-] 
       CALL getin_p('PRANDTL', Prandtl)
    ENDIF
    !- 
    ! Variables related to the explicitsnow module
    !-
    !Config Key = xansmax 
    !Config Desc = maximum snow albedo
    !Config If = OK_SECHIBA
    !Config Def = 0.85
    !Config Help = 
    !Config Units = [-] 
    CALL getin_p('XANSMAX',xansmax)
    !
    !Config Key = xansmin 
    !Config Desc = minimum snow albedo
    !Config If = OK_SECHIBA
    !Config Def = 0.50
    !Config Help = 
    !Config Units = [-] 
    CALL getin_p('XANSMIN',xansmin)
    !
    !Config Key = xans_todry 
    !Config Desc = albedo decay rate for the dry snow 
    !Config If = OK_SECHIBA
    !Config Def = 0.008
    !Config Help = 
    !Config Units = [S-1] 
    CALL getin_p('XANSDRY',xans_todry)
    !
    !Config Key = xans_t 
    !Config Desc = albedo decay rate for the wet snow 
    !Config If = OK_SECHIBA
    !Config Def = 0.24
    !Config Help = 
    !Config Units = [S-1] 
    CALL getin_p('XANS_T',xans_t)

    !Config Key = xrhosmax 
    !Config Desc = maximum snow density 
    !Config If = OK_SECHIBA
    !Config Def = 750
    !Config Help = 
    !Config Units = [-] 
    CALL getin_p('XRHOSMAX',xrhosmax)
    !
    !Config Key = xwsnowholdmax1
    !Config Desc = snow holding capacity 1
    !Config If = OK_SECHIBA
    !Config Def = 0.03
    !Config Help = 
    !Config Units = [-] 
    CALL getin_p('XWSNOWHOLDMAX1',xwsnowholdmax1)
    !
    !Config Key = xwsnowholdmax2
    !Config Desc = snow holding capacity 2
    !Config If = OK_SECHIBA
    !Config Def = 0.10
    !Config Help = 
    !Config Units = [-] 
    CALL getin_p('XWSNOWHOLDMAX2',xwsnowholdmax2)
    !
    !Config Key = xsnowrhohold 
    !Config Desc = snow density 
    !Config If = OK_SECHIBA
    !Config Def = 200.0
    !Config Help = 
    !Config Units = [kg/m3] 
    CALL getin_p('XSNOWRHOHOLD',xsnowrhohold)
    ! 
    !Config Key = ZSNOWTHRMCOND1
    !Config Desc = Thermal conductivity Coef 1
    !Config If = OK_SECHIBA
    !Config Def = 0.02 
    !Config Help = 
    !Config Units = [W/m/K] 
    CALL getin_p('ZSNOWTHRMCOND1',ZSNOWTHRMCOND1)
    !
    !Config Key = ZSNOWTHRMCOND2
    !Config Desc = Thermal conductivity Coef 2
    !Config If = OK_SECHIBA
    !Config Def = 2.5E-6
    !Config Help = 
    !Config Units = [W m5/(kg2 K)] 
    CALL getin_p('ZSNOWTHRMCOND2',ZSNOWTHRMCOND2)
    !
    !Config Key = ZSNOWTHRMCOND_AVAP
    !Config Desc = Thermal conductivity Coef 1 water vapor
    !Config If = OK_SECHIBA
    !Config Def = -0.06023
    !Config Help = 
    !Config Units = [W/m/K] 
    CALL getin_p('ZSNOWTHRMCOND_AVAP',ZSNOWTHRMCOND_AVAP)
    !
    !Config Key = ZSNOWTHRMCOND_BVAP
    !Config Desc = Thermal conductivity Coef 2 water vapor
    !Config If = OK_SECHIBA
    !Config Def = -2.5425
    !Config Help = 
    !Config Units = [W/m] 
    CALL getin_p('ZSNOWTHRMCOND_BVAP',ZSNOWTHRMCOND_BVAP)
    !
    !Config Key = ZSNOWTHRMCOND_CVAP
    !Config Desc = Thermal conductivity Coef 3 water vapor
    !Config If = OK_SECHIBA
    !Config Def = -289.99
    !Config Help = 
    !Config Units = [K] 
    CALL getin_p('ZSNOWTHRMCOND_CVAP',ZSNOWTHRMCOND_CVAP)

    !Snow compaction factors
    !Config Key = ZSNOWCMPCT_RHOD
    !Config Desc = Snow compaction coefficent
    !Config If = OK_SECHIBA
    !Config Def = 150.0
    !Config Help = 
    !Config Units = [kg/m3]
    CALL getin_p('ZSNOWCMPCT_RHOD',ZSNOWCMPCT_RHOD)

    !Config Key = ZSNOWCMPCT_ACM
    !Config Desc = Coefficent for the thermal conductivity
    !Config If = OK_SECHIBA
    !Config Def = 2.8e-6
    !Config Help = 
    !Config Units = [1/s]
    CALL getin_p('ZSNOWCMPCT_ACM',ZSNOWCMPCT_ACM)

    !Config Key = ZSNOWCMPCT_BCM
    !Config Desc = Coefficent for the thermal conductivity
    !Config If = OK_SECHIBA
    !Config Def = 0.04
    !Config Help = 
    !Config Units = [1/K]
    CALL getin_p('ZSNOWCMPCT_BCM',ZSNOWCMPCT_BCM)

    !Config Key = ZSNOWCMPCT_CCM
    !Config Desc = Coefficent for the thermal conductivity
    !Config If = OK_SECHIBA
    !Config Def = 460.
    !Config Help = 
    !Config Units = [m3/kg] 
    CALL getin_p('ZSNOWCMPCT_CCM',ZSNOWCMPCT_CCM)

    !Config Key = ZSNOWCMPCT_V0
    !Config Desc = Vapor coefficent for the thermal conductivity
    !Config If = OK_SECHIBA
    !Config Def = 3.7e7
    !Config Help = 
    !Config Units = [Pa/s]
    CALL getin_p('ZSNOWCMPCT_V0',ZSNOWCMPCT_V0)

    !Config Key = ZSNOWCMPCT_VT
    !Config Desc = Vapor coefficent for the thermal conductivity
    !Config If = OK_SECHIBA
    !Config Def = 0.081
    !Config Help = 
    !Config Units = [1/K]
    CALL getin_p('ZSNOWCMPCT_VT',ZSNOWCMPCT_VT)

    !Config Key = ZSNOWCMPCT_VR
    !Config Desc = Vapor coefficent for the thermal conductivity
    !Config If = OK_SECHIBA
    !Config Def = 0.018
    !Config Help = 
    !Config Units = [m3/kg]
    CALL getin_p('ZSNOWCMPCT_VR',ZSNOWCMPCT_VR)

    !Config Key = ZSNOWCMPCT_W0
    !Config Desc = Vapor coefficent for the thermal conductivity when T > 264K
    !Config If = OK_SECHIBA
    !Config Def = 2.0e7
    !Config Help = 
    !Config Units = [Pa/s]
    CALL getin_p('ZSNOWCMPCT_W0',ZSNOWCMPCT_W0)

    !Config Key = ZSNOWCMPCT_WT
    !Config Desc = Vapor coefficent for the thermal conductivity when T > 264
    !Config If = OK_SECHIBA
    !Config Def = 0.35
    !Config Help = 
    !Config Units = [1/K]
    CALL getin_p('ZSNOWCMPCT_WT',ZSNOWCMPCT_WT)

    !Config Key = ZSNOWCMPCT_WR
    !Config Desc = Vapor coefficent for the thermal conductivity when T > 264
    !Config If = OK_SECHIBA
    !Config Def = 0.01
    !Config Help = 
    !Config Units = [m3/kg]
    CALL getin_p('ZSNOWCMPCT_WR',ZSNOWCMPCT_WR)

    !Config Key = xrhosref
    !Config Desc = Reference density used in the viscosity calculation
    !Config If = OK_SECHIBA
    !Config Def = 250
    !Config Help = 
    !Config Units = [kg/m3]
    CALL getin_p('XRHOSREF',xrhosref)

    !Config Key = xrhosmob
    !Config Desc = Reference density for the calculation of the mobility index
    !Config If = OK_SECHIBA
    !Config Def = 295
    !Config Help = 
    !Config Units = [kg/m3]
    CALL getin_p('XRHOSMOB',xrhosmob)

    !Config Key = xrhoswind
    !Config Desc = Density threshold for wind-driven compaction 
    !Config If = OK_SECHIBA
    !Config Def = 350
    !Config Help = 
    !Config Units = [kg/m3]
    CALL getin_p('XRHOSWIND',xrhoswind)

    !Config Key = ZSNOWCMPCT_X0
    !Config Desc = Viscosity coefficient 
    !Config If = OK_SECHIBA
    !Config Def = 7.82237e6
    !Config Help = 
    !Config Units = [Pa/s]
    CALL getin_p('ZSNOWCMPCT_X0',ZSNOWCMPCT_X0)

    !Config Key = ZSNOWCMPCT_XT
    !Config Desc = Viscosity coefficient 
    !Config If = OK_SECHIBA
    !Config Def = 0.1
    !Config Help = 
    !Config Units = [1/K]
    CALL getin_p('ZSNOWCMPCT_XT',ZSNOWCMPCT_XT)

    !Config Key = ZSNOWCMPCT_XR
    !Config Desc = Viscosity coefficient 
    !Config If = OK_SECHIBA
    !Config Def = 0.023
    !Config Help = 
    !Config Units = [m3/kg]
    CALL getin_p('ZSNOWCMPCT_XR',ZSNOWCMPCT_XR)

    !Config Key = DTref
    !Config Desc = temperature reference used for the viscosity calculation 
    !Config If = OK_SECHIBA
    !Config Def = 5.0
    !Config Help = 
    !Config Units = [K]
    CALL getin_p('DTREF',DTref)

    !Config Key = ACMPCT
    !Config Desc = Coefficient used for the calculatio of the wind-driven compaction index 
    !Config If = OK_SECHIBA
    !Config Def = 2.868
    !Config Help = 
    !Config Units = [-]
    CALL getin_p('ACMPCT',ACMPCT)

    !Config Key = BCMPCT
    !Config Desc = Coefficient used for the calculatio of the wind-driven compaction index 
    !Config If = OK_SECHIBA
    !Config Def = 0.085
    !Config Help = 
    !Config Units = [s/m]
    CALL getin_p('BCMPCT',BCMPCT)

    !Config Key = KCMPCT
    !Config Desc = Coefficient used for the calculatio of the wind-driven compaction index 
    !Config If = OK_SECHIBA
    !Config Def = 1.25
    !Config Help = 
    !Config Units = [-]
    CALL getin_p('KCMPCT',KCMPCT)

    !Config Key = a_tau
    !Config Desc = Coefficient used for the calculatio of the compaction rate
    !Config If = OK_SECHIBA
    !Config Def = 10
    !Config Help = 
    !Config Units = [-]
    CALL getin_p('A_TAU',a_tau)

    !Config Key = b_tau
    !Config Desc = Coefficient used for the calculatio of the compaction rate
    !Config If = OK_SECHIBA
    !Config Def = 3.25
    !Config Help = 
    !Config Units = [-]
    CALL getin_p('B_TAU',b_tau)

    !Config Key = Amob
    !Config Desc = Coefficient used for the calculatio of the mobility index
    !Config If = OK_SECHIBA
    !Config Def = 1.25
    !Config Help = 
    !Config Units = [-]
    CALL getin_p('AMOB',Amob)
    
    !Config Key = ZICETHRMCOND1
    !Config Desc = Ice Thermal conductivity Coef 1
    !Config If = OK_SECHIBA
    !Config Def = 6.727
    !Config Help = 
    !Config Units = [W/m/K] 
    CALL getin_p('ZICETHRMCOND1',ZICETHRMCOND1)
    
    !Config Key = ZICETHRMCOND2
    !Config Desc = Ice Thermal conductivity Coef 2
    !Config If = OK_SECHIBA
    !Config Def = -0.0041
    !Config Help = 
    !Config Units = [W/m/K] 
    CALL getin_p('ZICETHRMCOND2',ZICETHRMCOND2)
    
    !Config Key = ZICETHRMHEAT1
    !Config Desc = Ice Thermal heat capacity Coef 1
    !Config If = OK_SECHIBA
    !Config Def = 2115.3
    !Config Help = 
    !Config Units = [W/m/K] 
    CALL getin_p('ZICETHRMHEAT1',ZICETHRMHEAT1)
    
    !Config Key = ZICETHRMHEAT2
    !Config Desc = Ice Thermal heat capacity Coef 2
    !Config If = OK_SECHIBA
    !Config Def = 7.79293
    !Config Help = 
    !Config Units = [W/m/K] 
    CALL getin_p('ZICETHRMHEAT2',ZICETHRMHEAT2)


    !
    ! Variables related to crop irrigation
    !  

    !Config Key   = IRRIG_DOSMAX
    !Config Desc  = The maximum irrigation water injected per hour (kg.m^{-2}/hour)
    !Config If    = DO_IRRIGATION AND old_irrig_scheme = FALSE
    !Config Def   = 3.
    !Config Help  =
    !Config Units = [kg.m^{-2}/hour]
    CALL getin_p('IRRIG_DOSMAX',irrig_dosmax)

    !Config Key   = CUM_DH_THR
    !Config Desc  = Threshold depth to define root zone, and calculate water deficit for irrigation
    !Config If    = DO_IRRIGATION AND OLD_IRRIG_SCHEME = FALSE
    !Config Def   = 0.64
    !Config Help  =
    !Config Units = [m]
    CALL getin_p('CUM_DH_THR',cum_dh_thr)

    !Crop irrigation
    !Config Key   = IRRIGATED_SOILTILE
    !Config Desc  = Do we introduce a new soil tile for irrigated croplands?
    !Config If    = DO_IRRIGATION AND old_irrig_scheme = FALSE
    !Config Def   = n
    !Config Help  =
    !Config Units = [FLAG]
    CALL getin_p('IRRIGATED_SOILTILE',irrigated_soiltile)

    !
    !Config Key   = OLD_IRRIG_SCHEME
    !Config Desc  = Do we run with the old irrigation scheme?
    !Config If    = DO_IRRIGATION
    !Config Def   = n
    !Config Help  =
    !Config Units = [FLAG]
    CALL getin_p('OLD_IRRIG_SCHEME',old_irrig_scheme)

    !   To run with new irrigation scheme
    !Config Key   = IRRIG_ST
    !Config Desc  = Which is the soil tile with irrigation flux
    !Config If    = DO_IRRIGATION and old_irrig_scheme = FALSE and IRRIGATED_SOILTILE = FALSE
    !Config Def   = 3
    !Config Help  =
    !Config Units = []
    CALL getin_p('IRRIG_ST',irrig_st)

    !  To run with NEW irrigation scheme
    !Config Key   = AVAIL_RESERVE
    !Config Desc  = Max. fraction of routing reservoir volume that can be used for irrigation
    !Config If    = DO_IRRIGATION and old_irrig_scheme = FALSE
    !Config Def   = 0.9,0.9,0.9
    !Config Help  =
    !Config Units = []
    CALL getin_p('AVAIL_RESERVE',avail_reserve)

    !  To run with NEW irrigation scheme
    !Config Key   = BETA_IRRIG
    !Config Desc  = Threshold multiplier of Target SM to calculate root deficit
    !Config If    = DO_IRRIGATION and OLD_IRRIG_SCHEME = FALSE
    !Config Def   = 0.9
    !Config Help  =
    !Config Units = []
    CALL getin_p('BETA_IRRIG',beta_irrig)
    !
    !   To run with new irrigation scheme
    !Config Key   = LAI_IRRIG_MIN
    !Config Desc  = Min. LAI (Leaf Area Index) to trigger irrigation
    !Config If    = DO_IRRIGATION and old_irrig_scheme = FALSE and IRRIGATED_SOILTILE = FALSE
    !Config Def   = 0.1
    !Config Help  =
    !Config Units = [m2/m2]
    CALL getin_p('LAI_IRRIG_MIN',lai_irrig_min)

    !   To run with new irrigation scheme
    !Config Key   = IRRIG_MAP_DYNAMIC_FLAG
    !Config Desc  = Do we use a dynamic irrig map?
    !Config If    = DO_IRRIGATION
    !Config Def   = n
    !Config Help  =
    !Config Units = [FLAG]
    CALL getin_p('IRRIG_MAP_DYNAMIC_FLAG',irrig_map_dynamic_flag)

    !   To run with new irrigation scheme
    !Config Key   = SELECT_SOURCE_IRRIG
    !Config Desc  = Do we use the new priorization scheme, based on maps of equipped area with surface water?
    !Config If    = DO_IRRIGATION
    !Config Def   = n
    !Config Help  =
    !Config Units = [FLAG]
    CALL getin_p('SELECT_SOURCE_IRRIG',select_source_irrig)

    !Config Key   = REINFILTR_IRRIGFIELD
    !Config Desc  = Reinfiltrate all/part of runoff in crop soil tile
    !Config If    = DO_IRRIGATION
    !Config Def   = n
    !Config Help  =
    !Config Units = [FLAG]
    CALL getin_p('REINFILTR_IRRIGFIELD',Reinfiltr_IrrigField)

    !   Externalized reinf_slope for reinfiltration in irrigated cropland
    !Config Key   = reinf_slope_cropParam
    !Config Desc  = DO_IRRIGATION
    !Config If    = DO_IRRIGATION = T, REINFILTR_IRRIGFIELD = T
    !Config Def   = 0.8
    !Config Help  =
    !Config Units = [FRACTION 0-1]
    CALL getin_p('REINF_SLOPE_CROPPARAM',reinf_slope_cropParam)

    !   Externalized for available volume to adduction
    !Config Key   = a_stream_adduction  
    !Config Desc  = DO_IRRIGATION
    !Config If    = DO_IRRIGATION = T
    !Config Def   = 0.05
    !Config Help  =
    !Config Units = [FRACTION 0-1]
    CALL getin_p('A_STREAM_ADDUCTION',a_stream_adduction)


    !Surface resistance
    !
    !Config Key = CB
    !Config Desc = Constant of the Louis scheme 
    !Config If = OK_SECHIBA
    !Config Def = 5.0
    !Config Help = 
    !Config Units = [-] 
    CALL getin_p('CB',cb)
    !
    !Config Key = CC
    !Config Desc = Constant of the Louis scheme 
    !Config If = OK_SECHIBA
    !Config Def = 5.0
    !Config Help = 
    !Config Units = [-] 
    CALL getin_p('CC',cc)
    !
    !Config Key = CD
    !Config Desc = Constant of the Louis scheme 
    !Config If = OK_SECHIBA
    !Config Def = 5.0
    !Config Help = 
    !Config Units = [-] 
    CALL getin_p('CD',cd)
    !
    !Config Key = RAYT_CSTE
    !Config Desc = Constant in the computation of surface resistance  
    !Config If = OK_SECHIBA
    !Config Def = 125
    !Config Help = 
    !Config Units = [W.m^{-2}] 
    CALL getin_p('RAYT_CSTE',rayt_cste)
    !
    !Config Key = DEFC_PLUS
    !Config Desc = Constant in the computation of surface resistance  
    !Config If = OK_SECHIBA
    !Config Def = 23.E-3
    !Config Help = 
    !Config Units = [K.W^{-1}] 
    CALL getin_p('DEFC_PLUS',defc_plus)
    !
    !Config Key = DEFC_MULT
    !Config Desc = Constant in the computation of surface resistance  
    !Config If = OK_SECHIBA
    !Config Def = 1.5
    !Config Help = 
    !Config Units = [K.W^{-1}] 
    CALL getin_p('DEFC_MULT',defc_mult)

    !+++CHECK+++
    ! We can add some consistency checks and possibly
    ! simplify the definition of the canopy layering 
    ! (reduce the number of variables)
    !
    ! Configuration : The number of canopy levels to use in 
    !                 the albedo and energy budget
    !
    !Config Key   = NLAI
    !Config Desc  = Number of photosyntheis canopy levels 
    !Config If    = OK_SECHIBA
    !Config Def   = 10
    !Config Help  = The number of canopy levels to be used in 
    !               per enegy budget canopy level photosynthesis 
    !Config Units = [-]
    CALL getin_p("NLAI",nlai)
    IF (printlev>=1) WRITE(numout,'(I4,A)') nlai,' levels are used for each canopy ' &
         // 'level to calculate photosynthesis.'
    
    ! This is a variable that we'll pass around for convenience, in particular
    ! when going into a subroutine.
    nlevels_tot = nlevels * nlai
    DO ilevel=1,nlevels
       IF (printlev>=1) WRITE(numout,*) 'Albedo canopy level ',ilevel,&
            ' has a lower boundary at ',z_level(ilevel),' meters.'
    ENDDO
    
    ! Sets the levels for the energy calculations based on the
    ! ENERGY_CONTROL flag. 
    IF( ENERGY_CONTROL .LE. 3 ) THEN        ! single layer
       
       jnlvls = 1
       jnlvls_under = 0
       jnlvls_canopy = 1
       jnlvls_over = 0    
       
    ELSEIF( ENERGY_CONTROL .EQ. 4 ) THEN   ! multi-layer
       
       jnlvls = 29
       jnlvls_under = 10
       jnlvls_canopy = 10
        jnlvls_over = 9
        
     ELSEIF( ENERGY_CONTROL .EQ. 5 ) THEN  ! run.def specified
        !Config Key   = JNLVLS
        !Config Desc  = number of photosyntheis canopy levels 
        !Config If    = OK_SECHIBA
        !Config Def   = 29
        !Config Help  = The total number of layers in the 
        !Config       = multi-layer energy budget calculations
        !Config Units = [-]
        jnlvls = 29
        CALL getin_p("JNLVLS",jnlvls)
        
        !Config Key   = JNLVLS_UNDER
        !Config Desc  = number of energy layers under the canopy 
        !Config If    = OK_SECHIBA
        !Config Def   = 10
        !Config Help  = Number of energy layers under the canopy
        !Config       = used for multi-layer energy budget calculations
        !Config Units = [-]
        jnlvls_under = 10
        CALL getin_p("JNLVLS_UNDER",jnlvls_under)

        !Config Key   = JNLVLS_CANOPY
        !Config Desc  = number of energy layers in the canopy 
        !Config If    = OK_SECHIBA
        !Config Def   = 10
        !Config Help  = Number of energy, albedo and photosynthesis 
        !Config       = layers in the canopy used for multi-layer 
        !Confog       = energy budget calculations
        !Config Units = [-]
        jnlvls_canopy = 9
        CALL getin_p("JNLVLS_CANOPY",jnlvls_canopy)

        !Config Key   = JNLVLS_OVER
        !Config Desc  = number of energy layers over the canopy 
        !Config If    = OK_SECHIBA
        !Config Def   = 10
        !Config Help  = Number of energy layers over the canopy
        !Config       = used for multi-layer energy budget calculations
        !Config Units = [-]
        jnlvls_over = 10
        CALL getin_p("JNLVLS_OVER",jnlvls_over)
     ENDIF ! (ENERGY_CONTROL)

     IF (printlev>=1) WRITE(numout,*)'The set JNLVLS levels', jnlvls, jnlvls_under,jnlvls_canopy,jnlvls_over 

     !Config Key   = NLEV_TOP
     !Config Desc  = Maximum number of canopy levels that are 
     !               used to construct the "top" layer of the 
     !               canopy. The top layer is used in the 
     !               calculation transpiration. 
     !               Should not exceed nlai
     !Config If    = OK_SECHIBA
     !Config Def   = 10
     !Config Help  = 
     !Config Units = [-]
     nlev_top = 10
     CALL getin_p('NLEV_TOP',nlev_top)        
     IF(nlev_top .GT. nlai) THEN
        nlev_top = nlai
        IF (printlev>=1) WRITE(numout,*) 'The numbers of levels in the "top" was '
        IF (printlev>=1) WRITE(numout,*) '  larger than the total number of levels'
        IF (printlev>=1) WRITE(numout,*) '  AUTO CORRECT: nlev_top now = ',nlev_top
     ENDIF

     !+++++++++++

     !
     !-
     ! diffuco 
     !-
     !
     !Config Key   = LAIMAX
     !Config Desc  = Maximum LAI
     !Config If    = OK_SECHIBA
     !Config Def   = 
     !Config Help  = 
     !Config Units = [m^2/m^2]   
     CALL getin_p('LAIMAX',laimax)
     !
     !Config Key   = DEW_VEG_POLY_COEFF
     !Config Desc  = coefficients of the polynome of degree 5 for the dew
     !Config If    = OK_SECHIBA
     !Config Def   = 0.887773, 0.205673, 0.110112, 0.014843, 0.000824, 0.000017 
     !Config Help  = 
     !Config Units = [-]   
     CALL getin_p('DEW_VEG_POLY_COEFF',dew_veg_poly_coeff)
     !
     !Config Key   = DOWNREGULATION_CO2
     !Config Desc  = Activation of CO2 downregulation
     !Config If    = OK_SECHIBA
     !Config Def   = y
     !Config Help  = 
     !Config Units = [FLAG]   
     CALL getin_p('DOWNREGULATION_CO2',downregulation_co2)
     !
     !Config Key   = DOWNREGULATION_CO2_BASELEVEL
     !Config Desc  = CO2 base level
     !Config If    = OK_SECHIBA 
     !Config Def   = 380.
     !Config Help  = 
     !Config Units = [ppm]   
     CALL getin_p('DOWNREGULATION_CO2_BASELEVEL',downregulation_co2_baselevel)
    
     !Config Key   = GB_REF
     !Config Desc  = Leaf bulk boundary layer resistance
     !Config If    = 
     !Config Def   = 1./25.
     !Config Help  = 
     !Config Units = [s m-1]   
     CALL getin_p('GB_REF',gb_ref)

    !Config Key   = BULK_DEFAULT
    !Config Desc  = default bulk density
    !Config If    = OK_SECHIBA 
    !Config Def   = 1000.0
    !Config Help  = The bulk density is the weight of soil in a
    !Config         given volume.  This default is used if no other value
    !Config         is found in the restart file.
    !Config Units = [kg/m3]   
    CALL getin_p('BULK_DEFAULT',bulk_default)
    
    !Config Key   = PH_DEFAULT
    !Config Desc  = default soil pH
    !Config If    = OK_SECHIBA 
    !Config Def   = 5.5
    !Config Help  = Gives the value of the soil pH if a value is not
    !Config         found in the restart file.
    !Config Units = [-]   
    CALL getin_p('PH_DEFAULT',ph_default)

    !
    !Config Key   = MIN_VEGFRAC 
    !Config Desc  = Minimal fraction of mesh a vegetation type can occupy 
    !Config If    = OK_SECHIBA 
    !Config Def   = 0.001 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('MIN_VEGFRAC',min_vegfrac)

    IF (min_vegfrac.LT.min_stomate) THEN
       
       ! In slowproc_adjust_delta_veget_max several series of IF-statements implicitly
       ! assume that min_vegfarc > min_stomate. If this is not the case strange things
       ! may happen. These strange things woul probably surface as a mass balance problem
       ! or a problem with conserving the surface areas of a pixel. It is a very easy
       ! inconsistency to catch at this point. It may be much harder to understand 
       ! what is going wrong if the model is used with an inconstent min_vegfrac value.
       WRITE(numout,*) 'min_vegfrac and min_stomate ', min_vegfrac, min_stomate
       CALL ipslerr_p(3,'Check your run.def','min_vegfrac should be larger than min_stomate',&
            'If not several of the IF-statements in slowproc_adjust_delta_veget_max',&
            'may not work as intended')

    END IF
    !
    !Config Key   = STEMPDIAG_BID 
    !Config Desc  = only needed for an initial LAI if there is no restart file
    !Config If    = OK_SECHIBA 
    !Config Def   = 280.
    !Config Help  = 
    !Config Units = [K]
    CALL getin_p('STEMPDIAG_BID',stempdiag_bid)
 
    !
    !Config Key   = MIN_N
    !Config Desc  = Minimum allowable n_mineralisation in som_dynamics
    !Config If    = OK_STOMATE
    !Config Def   = 0.0001
    !Config Help  =
    !Config Units = gNH4-N/m^2/day
    CALL getin_p('MIN_N',min_n)    
    !
    !Config Key   = MAX_CN
    !Config Desc  = Maximum allowable ratio of som_input_total(:,icarbon)
    !               to som_input_total(:,initrogen).
    !Config If    = OK_STOMATE
    !Config Def   = 250
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('MAX_CN',max_cn)
    !
    !Config Key   = SNC
    !Config Desc  = Structural nitrogen concentration
    !Config If    = OK_STOMATE
    !Config Def   = 0.004
    !Config Help  = Structural nitrogen [gN gC-1] based on C:N of dead wood 
    !               (White et al., 2000) assuming carbon dry matter ratio of 0.5
    !Config Units = [gN gC-1]
    CALL getin_p('SNC',snc)
    !
    !Config Key   = SUGAR_LOAD_MIN
    !Config Desc  = Lower bound for sugar loading when used to regulate NUE
    !Config If    = OK_STOMATE
    !Config Def   = 0.0
    !Config Help  = Sugar loading is a ratio that will be contained between
    !               sugar_load_min and sugar_load_max. If it is 1 all is perfect
    !Config Units = [-]
    CALL getin_p('SUGAR_LOAD_MIN',sugar_load_min)
    !
    !Config Key   = SUGAR_LOAD_MAX
    !Config Desc  = Upper bound for sugar loading when used to regulate NUE
    !Config If    = OK_STOMATE
    !Config Def   = 1.0
    !Config Help  = Sugar loading is a ratio that will be contained between
    !               sugar_load_min and sugar_load_max. If it is 1 all is perfect
    !Config Units = [-]
    CALL getin_p('SUGAR_LOAD_MAX',sugar_load_max)
    !-
    !Config Key   = NCIRC
    !Config Desc  = Number of basal area classes in allocation scheme
    !               circ classes could be considered as cohorts within a stand 
    !Config If    = OK_STOMATE, OK_SECHIBA 
    !Config Def   = 2 
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('NCIRC',ncirc)
    !
    !Config Key   = SLOPE_RA
    !Config Desc  = Reduction factor to make resp_maint less temperature sensitive
    !Config If    = OK_STOMATE
    !Config Def   = 1.
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('SLOPE_RA',slope_ra)
    !
    !Config Key   = LAIEFF_SOLAR_ANGLE
    !Config Desc  = The solar zenith angle for effective LAI
    !Config If    = OK_SECHIBA
    !Config Def   = 60
    !Config Help  = The solar zenith angle used in the calculation of the 
    !               effective LAI. Pinty recommends a value of 60 degrees.
    !Config Units = [degrees]
    laieff_solar_angle=60.0_r_std
    CALL getin_p('LAIEFF_SOLAR_ANGLE',laieff_solar_angle) 
    IF (printlev>=1) WRITE(numout,*) 'Maximum number of optimization steps'//&
         'tried for albedo n-layer optimization [degrees]: ',laieff_solar_angle
    ! convert to radians
    laieff_solar_angle=laieff_solar_angle/180.0_r_std*pi 
    !
    !Config Key   = LAIEFF_ZERO_CUTOFF
    !Config Desc  = Cutoff for effective lai values
    !Config If    = OK_SECHIBA
    !Config Def   = 0.0000001
    !Config Help  = This is an arbitrary cutoff to make sure we don't pass 
    !               zero values of crown diameter and trunk diameter
    !               to a subroutine that will choke on them
    !Config Units = [-]
    laieff_zero_cutoff=0.0000001_r_std
    CALL getin_p('LAIEFF_ZERO_CUTOFF',laieff_zero_cutoff) 
    IF (printlev>=1) WRITE(numout,*) 'A minimum threshold for trunk and crown '//&
         'diameters for numerical stability: ',laieff_zero_cutoff
    !
    !Config Key   = DIRECT_LIGHT_WEIGHT
    !Config Desc  = The weighting factor to weight different sources of light
    !Config If    = OK_SECHIBA
    !Config Def   = 0.5
    !Config Help  = The weighting factor used in the calculation of the
    !               albedo and canopy absorbed light from different sources.
    !               Currently LDMZ and forcing files don't have information
    !               on the amount of solar radiation hitting the canopy 
    !               directly from the sun (collimated) or first reflected off
    !               clouds and aerosols.  But these values are calculated in
    !               the albedo routines.  We combine them into a single
    !               value with a simple weighting controlled by this variable.
    !               We select a value of 0.5 because we don't know what will
    !               be generally applicable.
    !Config Units = [degrees]
    direct_light_weight=0.5_r_std
    CALL getin_p('direct_light_weight',direct_light_weight) 
    IF (printlev>=1) WRITE(numout,*) 'Weighting fraction for calculating the total'//&
         'albedo and absorbed light from direct and diffuse sources [-]: ',direct_light_weight

    !Config Key   = MAINT_RESP_CONTROL
    !Config Desc  = Sets the approach to calculate Rm
    !Config If    = OK_SECHIBA
    !Config Def   = 'cn'
    !Config Help  =  Choose between two options to calculate the maint respiration. If
    !                set to 'nitrogen' the plant nitrogen pools and temperature will 
    !                drive maint_resp. If set to 'c/n', maint_resp will be adjusted for 
    !                the expected c/n ratio of the plant biomass. Also the temperature 
    !                control itself is calculated according to Krinner et al 2005 instead
    !                of Sitch et al 2003.
    !Config Units = [-]
    maint_resp_control='cn'
    CALL getin_p('MAINT_RESP_CONTROL',maint_resp_control) 
    IF (printlev>=1) WRITE(numout,*) 'Maintenance respiration is based on ',maint_resp_control
    !
    !Config Key   = CROWN_PACKING
    !Config Desc  = Packing efficiency of the crowns within the canopy space
    !Config If    = OK_SECHIBA
    !Config Def   = 1.
    !Config Help  = The crowns are assumed to be ellipsoids. The sum of all the
    !               individual crown volumes may exceed the entire canopys space
    !               given by the surface*height. If this happens the crown dimensions
    !               (the axes of the ellipsoids) will be recalculated. This 
    !               calculation assume a packing efficiency. Note that close-packing
    !               of spheres has a maximum efficiency of 0.74 (listed as some mental 
    !               guidance). Lower packing efficiencies will result in more gaps and
    !               has consequences for all variables that rely on veget.
    !Config Units = [-]
    CALL getin_p('CROWN_PACKING',crown_packing)

    IF (test_dynamic_max_height) THEN
       !
       !Config Key   = ALPHA_HEIGHT_PRECIP
       !Config Desc  = alpha parameter in height-precipitation relationship
       !Config If    = HACK_DYNAMIC_HEIGHT
       !Config Def   = 3.22
       !Config Help  = alpha parameter in height-precipitation relationship
       !               Fitted on the GEDI and CRUJRA data by using
       !               svn/TOOLS/FIT_TREEHEIGHT_PRECIPITATION/dynamic_tree_height.py
       !Config Units = [m]
       CALL getin_p('ALPHA_HEIGHT_PRECIP',alpha_height_precip)
       !
       !Config Key   = BETA_HEIGHT_PRECIP
       !Config Desc  = beta parameter in height-precipitation relationship
       !Config If    = HACK_DYNAMIC_HEIGHT
       !Config Def   = 0.33877
       !Config Help  = alpha parameter in height-precipitation relationship
       !               Fitted on the GEDI and CRUJRA data by using
       !               svn/TOOLS/FIT_TREEHEIGHT_PRECIPITATION/dynamic_tree_height.py
       !Config Units = [-]
       CALL getin_p('BETA_HEIGHT_PRECIP',beta_height_precip)
    END IF

  END SUBROUTINE config_sechiba_parameters


!! ================================================================================================================================
!! SUBROUTINE   : config_co2_parameters 
!!
!>\BRIEF        This subroutine reads in the configuration file all the parameters
!!
!! DESCRIPTION  : None
!!
!! RECENT CHANGE(S): None
!!
!! MAIN OUTPUT VARIABLE(S): None 
!!
!! REFERENCE(S) :
!!
!! FLOWCHART    :
!! \n
!_ ================================================================================================================================

  SUBROUTINE config_co2_parameters

    IMPLICIT NONE

    !! 0. Variables and parameters declaration

    !! 0.4 Local variables

    !_ ================================================================================================================================

    !
    !Config Key   = LAI_LEVEL_DEPTH
    !Config Desc  = 
    !Config If    = 
    !Config Def   = 0.15
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('LAI_LEVEL_DEPTH',lai_level_depth)
    !
    !Config Key   = Oi
    !Config Desc  = Intercellular oxygen partial pressure
    !Config If    = 
    !Config Def   = 210000.
    !Config Help  = See Legend of Figure 6 of Yin et al. (2009)
    !Config Units = [ubar]  
    CALL getin_p('Oi',Oi)

    !Config Key   = THRESHOLD_C13_ASSIM
    !Config Desc  = If assimilation falls below this threshold the delta_c13 is set to zero 
    !Config If    = OK_C13
    !Config Def   = 0.01 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('THRESHOLD_C13_ASSIM',threshold_c13_assim)
    !
    !Config Key   = C13_A
    !Config Desc  = Coefficient for fractionation occurring due to diffusion in air 
    !Config If    = OK_C13
    !Config Def   = 0.01 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('C13_A',c13_a)
    !
    !Config Key   = C13_B
    !Config Desc  = Coefficient for fractionation caused by carboxylation 
    !Config If    = OK_C13
    !Config Def   = 0.01 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('C13_B',c13_b)

  END SUBROUTINE config_co2_parameters


!! ================================================================================================================================
!! SUBROUTINE   : config_stomate_parameters 
!!
!>\BRIEF        This subroutine reads in the configuration file all the parameters 
!! needed when stomate is activated (ie : when OK_STOMATE is set to true).
!!
!! DESCRIPTION  : None
!!
!! RECENT CHANGE(S): None
!!
!! MAIN OUTPUT VARIABLE(S): 
!!
!! REFERENCE(S) :
!!
!! FLOWCHART    :
!! \n
!_ ================================================================================================================================

  SUBROUTINE config_stomate_parameters

    IMPLICIT NONE

    !! 0. Variables and parameters declaration

    !! 0.4 Local variables
    LOGICAL                          :: l_error     !! Check errors in allocation
    INTEGER(i_std)                   :: ier         !! Check errors in allocation
    INTEGER(i_std)                   :: iout        !! Index
    CHARACTER(LEN=2)                 :: striout     !! string suffix indicating output diameter class 

    !_ ================================================================================================================================

     l_error = .FALSE.

    !Config Key   = EXP_KF
    !Config Desc  = Exponential of the sensitivity of k_latosa to tree height
    !Config If    = OK_STOMATE
    !Config Def   = 1.0
    !Config Help  = Exponential used to tune the sensitivity of k_latosa to tree 
    !               height. 
    !Config Units = [-]   
    CALL getin_p('EXP_KF',exp_kf)

    !-
    ! constraints_parameters
    !-
    !
    !Config Key   = TOO_LONG 
    !Config Desc  = longest sustainable time without regeneration (vernalization)
    !Config If    = OK_STOMATE
    !Config Def   = 5.
    !Config Help  = 
    !Config Units = [days]   
    CALL getin_p('TOO_LONG',too_long)

    !-
    ! fire parameters
    !-
    !
    !Config Key   = TAU_FIRE 
    !Config Desc  = Time scale for memory of the fire index (days). Validated for one year in the DGVM. 
    !Config If    = OK_STOMATE 
    !Config Def   = 30.
    !Config Help  = 
    !Config Units = [days]    
    CALL getin_p('TAU_FIRE',tau_fire)
    !
    !Config Key   = LITTER_CRIT
    !Config Desc  = Critical litter quantity for fire
    !Config If    = OK_STOMATE 
    !Config Def   = 200.
    !Config Help  = 
    !Config Units = [gC/m^2]  
    CALL getin_p('LITTER_CRIT',litter_crit)

    !Config Key   = FIRE_RESIST_LIGNIN
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.5
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('FIRE_RESIST_LIGNIN',fire_resist_lignin)

    !Config Key   = CO2FRAC
    !Config Desc  = What fraction of a burned plant compartment goes into the atmosphere
    !Config If    = OK_STOMATE 
    !Config Def   = 0.95, 0.95, 0., 0.3, 0., 0., 0.95, 0.95
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('CO2FRAC',co2frac)
    !
    !Config Key   = BCFRAC_COEFF
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.3, 1.3, 88.2 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('BCFRAC_COEFF',bcfrac_coeff)
    !
    !Config Key   = FIREFRAC_COEFF 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.45, 0.8, 0.6, 0.13
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('FIREFRAC_COEFF',firefrac_coeff)

    !Config Key   = REF_GREFF
    !Config Desc  = Asymptotic maximum mortality rate
    !Config If    = OK_STOMATE 
    !Config Def   = 0.035
    !Config Help  = Set asymptotic maximum mortality rate from Sitch 2003
    !Config         (they use 0.01) (year^{-1})
    !Config Units = [1/year]  
    CALL getin_p('REF_GREFF',ref_greff)
    !-
    ! allocation parameters
    !-
    !Config Key   = RESERVE_TIME_TREE 
    !Config Desc  = maximum time during which reserve is used (trees) 
    !Config If    = OK_STOMATE 
    !Config Def   = 30.
    !Config Help  = 
    !Config Units = [days]    
    CALL getin_p('RESERVE_TIME_TREE',reserve_time_tree)
    !
    !Config Key   = RESERVE_TIME_GRASS 
    !Config Desc  = maximum time during which reserve is used (grasses) 
    !Config If    = OK_STOMATE 
    !Config Def   = 20. 
    !Config Help  = 
    !Config Units = [days]   
    CALL getin_p('RESERVE_TIME_GRASS',reserve_time_grass)

    !-
    ! data parameters
    !
    !Config Key   = PRECIP_CRIT 
    !Config Desc  = minimum precip
    !Config If    = OK_STOMATE 
    !Config Def   = 100.
    !Config Help  = 
    !Config Units = [mm/year]  
    CALL getin_p('PRECIP_CRIT',precip_crit)
    !
    !Config Key   = GDD_CRIT_ESTAB
    !Config Desc  = minimum gdd for establishment of saplings
    !Config If    = OK_STOMATE 
    !Config Def   = 150. 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('GDD_CRIT_ESTAB',gdd_crit_estab)
    !
    !Config Key   = FPC_CRIT
    !Config Desc  = critical fpc, needed for light competition and establishment
    !Config If    = OK_STOMATE 
    !Config Def   = 0.95
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('FPC_CRIT',fpc_crit)
    !
    !Config Key   = ALPHA_GRASS
    !Config Desc  = sapling characteristics : alpha's
    !Config If    = OK_STOMATE 
    !Config Def   = 0.5
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('ALPHA_GRASS',alpha_grass)
    !
    !Config Key   = ALPHA_TREE
    !Config Desc  = sapling characteristics : alpha's 
    !Config If    = OK_STOMATE 
    !Config Def   = 1.
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('ALPHA_TREE',alpha_tree)

    !Config Key   = STRUCT_TO_LEAVES
    !Config Desc  = Fraction of structural carbon in grass and crops as a share of the leaf
    ! carbon pool. Only used for grasses and crops (thus NOT for trees)
    !Config If    = OK_STOMATE 
    !Config Def   = 0.05
    !Config Help  = NOTE: the line using this variable is
    !Config         commented out in r5976, and thus this variable is
    !Config         not used.
    !Config Units = [-]   
    CALL getin_p(' STRUCT_TO_LEAVES',struct_to_leaves)

    !Config Key   = LABILE_TO_TOTAL
    !Config Desc  = Fraction of the labile pool in trees, grasses and crops as a share of the
    ! total carbon pool (accounting for the N-content of the different tissues).
    !Config If    = OK_STOMATE 
    !Config Def   = 0.01
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('LABILE_TO_TOTAL',labile_to_total)

    !Config Key   = TAU_HUM_MONTH
    !Config Desc  = time scales for phenology and other processes
    !Config If    = OK_STOMATE 
    !Config Def   = 20. 
    !Config Help  = 
    !Config Units = [days]  
    CALL getin_p('TAU_HUM_MONTH',tau_hum_month)
    !
    !Config Key   = TAU_HUM_WEEK
    !Config Desc  = time scales for phenology and other processes
    !Config If    = OK_STOMATE 
    !Config Def   = 7.
    !Config Help  = 
    !Config Units = [days]   
    CALL getin_p('TAU_HUM_WEEK',tau_hum_week)
    !
    !Config Key   = TAU_T2M_MONTH
    !Config Desc  = time scales for phenology and other processes
    !Config If    = OK_STOMATE 
    !Config Def   = 20.
    !Config Help  = 
    !Config Units = [days]     
    CALL getin_p('TAU_T2M_MONTH',tau_t2m_month)
    !
    !Config Key   = TAU_T2M_WEEK
    !Config Desc  = time scales for phenology and other processes
    !Config If    = OK_STOMATE 
    !Config Def   = 7.
    !Config Help  = 
    !Config Units = [days]   
    CALL getin_p('TAU_T2M_WEEK',tau_t2m_week)
    !
    !Config Key   = TAU_TSOIL_MONTH 
    !Config Desc  = time scales for phenology and other processes
    !Config If    = OK_STOMATE 
    !Config Def   = 20. 
    !Config Help  = 
    !Config Units = [days]     
    CALL getin_p('TAU_TSOIL_MONTH',tau_tsoil_month)
    !
    !Config Key   = TAU_GPP_WEEK 
    !Config Desc  = time scales for phenology and other processes
    !Config If    = OK_STOMATE 
    !Config Def   = 7. 
    !Config Help  = 
    !Config Units = [days]   
    CALL getin_p('TAU_GPP_WEEK',tau_gpp_week)
    !
    !Config Key   = TAU_GDD
    !Config Desc  = time scales for phenology and other processes
    !Config If    = OK_STOMATE 
    !Config Def   = 40. 
    !Config Help  = 
    !Config Units = [days]   
    CALL getin_p('TAU_GDD',tau_gdd)
    !
    !Config Key   = TAU_NGD
    !Config Desc  = time scales for phenology and other processes
    !Config If    = OK_STOMATE 
    !Config Def   = 43.
    !Config Help  = 
    !Config Units = [days]   
    CALL getin_p('TAU_NGD',tau_ngd)
    !
    !Config Key   = COEFF_TAU_LONGTERM
    !Config Desc  = time scales for phenology and other processes
    !Config If    = OK_STOMATE 
    !Config Def   = 3. 
    !Config Help  = 
    !Config Units = [days]   
    CALL getin_p('COEFF_TAU_LONGTERM',coeff_tau_longterm)
    !-
    !
    !Config Key   = BM_SAPL_CARBRES 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 5. 
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('BM_SAPL_CARBRES',bm_sapl_carbres)
    !
    !Config Key   = BM_SAPL_SAPABOVE
    !Config Desc  = 
    !Config If    = OK_STOMATE
    !Config Def   = 0.5 
    !Config Help  = 
    !Config Units = [-]    
    CALL getin_p('BM_SAPL_SAPABOVE',bm_sapl_sapabove)
    !
    !Config Key   = BM_SAPL_HEARTABOVE 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 2.
    !Config Help  = 
    !Config Units = [-]    
    CALL getin_p('BM_SAPL_HEARTABOVE',bm_sapl_heartabove)
    !
    !Config Key   = BM_SAPL_HEARTBELOW 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 2. 
    !Config Help  = 
    !Config Units = [-]    
    CALL getin_p('BM_SAPL_HEARTBELOW',bm_sapl_heartbelow)

    !Config Key   = BM_SAPL_LABILE 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 5. 
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('BM_SAPL_LABILE',bm_sapl_labile)

    !Config Key   = INIT_SAPL_MASS_LABILE
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 5. 
    !Config Help  = 
    !Config Units = [-]    
    CALL getin_p('INIT_SAPL_MASS_LABILE',init_sapl_mass_labile)

    !Config Key   = INIT_SAPL_MASS_LEAF_NAT
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.1 
    !Config Help  = 
    !Config Units = [-]    
    CALL getin_p('INIT_SAPL_MASS_LEAF_NAT',init_sapl_mass_leaf_nat)
    !
    !Config Key   = INIT_SAPL_MASS_LEAF_AGRI
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 1. 
    !Config Help  = 
    !Config Units = [-]    
    CALL getin_p('INIT_SAPL_MASS_LEAF_AGRI',init_sapl_mass_leaf_agri)
    !
    !Config Key   = INIT_SAPL_MASS_CARBRES
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 5. 
    !Config Help  = 
    !Config Units = [-]    
    CALL getin_p('INIT_SAPL_MASS_CARBRES',init_sapl_mass_carbres)
    !
    !Config Key   = INIT_SAPL_MASS_ROOT
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.1 
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('INIT_SAPL_MASS_ROOT',init_sapl_mass_root)
    !
    !Config Key   = INIT_SAPL_MASS_FRUIT
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.3 
    !Config Help  = 
    !Config Units = [-]    
    CALL getin_p('INIT_SAPL_MASS_FRUIT',init_sapl_mass_fruit)
    !
    !Config Key   = CN_SAPL_INIT 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.5 
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('CN_SAPL_INIT',cn_sapl_init)
    !
    !Config Key   = MIGRATE_TREE 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 10000.
    !Config Help  = 
    !Config Units = [m/year]   
    CALL getin_p('MIGRATE_TREE',migrate_tree)
    !
    !Config Key   = MIGRATE_GRASS
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 10000.
    !Config Help  = 
    !Config Units = [m/year]   
    CALL getin_p('MIGRATE_GRASS',migrate_grass)
    !
    !Config Key   = LAI_INITMIN_TREE
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.3
    !Config Help  = 
    !Config Units = [m^2/m^2]  
    CALL getin_p('LAI_INITMIN_TREE',lai_initmin_tree)
    !
    !Config Key   = LAI_INITMIN_GRASS 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.1
    !Config Help  = 
    !Config Units = [m^2/m^2]    
    CALL getin_p('LAI_INITMIN_GRASS',lai_initmin_grass)
    !
    !Config Key   = DIA_COEFF
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 4., 0.5
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('DIA_COEFF',dia_coeff)
    !
    !Config Key   = BM_SAPL_LEAF
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 4., 4., 0.8, 5. 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('BM_SAPL_LEAF',bm_sapl_leaf)

    !-
    ! litter parameters
    !-

    !Config Key   = CN
    !Config Desc  = C/N ratio
    !Config If    = OK_STOMATE 
    !Config Def   = 40., 40., 40., 40., 40., 40., 40., 40.
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('CN',CN_fix)

    !Config Key   = FRAC_SOIL_STRUCT_SUA
    !Config Desc  = frac_soil(istructural,isurface,iabove)
    !Config If    = OK_STOMATE 
    !Config Def   = 0.55
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('FRAC_SOIL_STRUCT_SUA',frac_soil_struct_sua)

    !Config Key   = FRAC_SOIL_STRUCT_AA
    !Config Desc  = frac_soil(istructural,iactive,iabove)
    !Config If    = OK_STOMATE 
    !Config Def   = 0.4
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('FRAC_SOIL_STRUCT_AA',frac_soil_struct_aa)

    !Config Key   = FRAC_SOIL_METAB_SUA 
    !Config Desc  = frac_soil(imetabolic,isurface,iabove) 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.4 
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('FRAC_SOIL_METAB_SUA',frac_soil_metab_sua)

    !Config Key   = FRAC_SOIL_METAB_AA 
    !Config Desc  = frac_soil(imetabolic,iactive,iabove) 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.4 
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('FRAC_SOIL_METAB_AA',frac_soil_metab_aa)

    !Config Key   = TURN_METABOLIC
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.066
    !Config Help  = 
    !Config Units = [years] 
    CALL getin_p('TURN_METABOLIC',turn_metabolic)

    !Config Key   = TURN_STRUCT 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.245 
    !Config Help  = 
    !Config Units = [years]
    CALL getin_p('TURN_STRUCT',turn_struct)

    !Config Key   = TURN_WOODY
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.75
    !Config Help  = 
    !Config Units = [years]
    CALL getin_p('TURN_WOODY',turn_woody)

    !Config Key   = TURN_SNAG
    !Config Desc  = Decomposition / Turnover of snag pool to soil organic matter
    !Config If    = OK_STOMATE 
    !Config Def   = 0.00133
    !Config Help  = Turnover of the snag litter pool. This value should be lower
    !Config Help  = than the TURN_SNAG_FALL. If not, the interest of introducing
    !Config       = a snag pool disappears
    !Config Units = [years]
    CALL getin_p('TURN_SNAG',turn_snag)
    
    !Config Key   = TURN_SNAG_FALL
    !Config Desc  = Snag fall / Turnover of snag pool to woody litter pool
    !Config If    = OK_STOMATE 
    !Config Def   = 0.133
    !Config Help  = This is the rate for a flux from litter to litter 
    !Config       = (snag to woody)
    !Config Units = [years]
    CALL getin_p('TURN_SNAG_FALL',turn_snag_fall)

    !Config Key   = METABOLIC_REF_FRAC
    !Config Desc  =
    !Config If    = OK_STOMATE 
    !Config Def   = 0.85  
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('METABOLIC_REF_FRAC',metabolic_ref_frac)

    !Config Key   = Z_DECOMP
    !Config Desc  = scaling depth for soil activity
    !Config If    = OK_STOMATE 
    !Config Def   = 0.2
    !Config Help  = 
    !Config Units = [m]   
    CALL getin_p('Z_DECOMP',z_decomp)

    !Config Key   = FRAC_SOIL_STRUCT_A 
    !Config Desc  = frac_soil(istructural,iactive,ibelow)
    !Config If    = OK_STOMATE 
    !Config Def   = 0.45
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('FRAC_SOIL_STRUCT_AB',frac_soil_struct_ab)
    !
    !Config Key   = FRAC_SOIL_STRUCT_SA
    !Config Desc  = frac_soil(istructural,islow,iabove)
    !Config If    = OK_STOMATE
    !Config Def   = 0.7  
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('FRAC_SOIL_STRUCT_SA',frac_soil_struct_sa)
    !
    !Config Key   = FRAC_SOIL_STRUCT_SB
    !Config Desc  = frac_soil(istructural,islow,ibelow) 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.7  
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('FRAC_SOIL_STRUCT_SB',frac_soil_struct_sb)
    !
    !Config Key   = FRAC_SOIL_METAB_AB 
    !Config Desc  = frac_soil(imetabolic,iactive,ibelow)
    !Config If    = OK_STOMATE 
    !Config Def   = 0.45  
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('FRAC_SOIL_METAB_AB',frac_soil_metab_ab)
    !
    !
    !Config Key   = METABOLIC_LN_RATIO
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.018  
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('METABOLIC_LN_RATIO',metabolic_LN_ratio) 
    !
    !Config Key   = SOIL_Q10
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.69 (=ln2)
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('SOIL_Q10',soil_Q10)
    !
    !Config Key   = SOIL_Q10_UPTAKE
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.69 (=ln2)
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('SOIL_Q10_UPTAKE',soil_Q10_uptake)
    !
    !Config Key   = TSOIL_REF
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 30. 
    !Config Help  = 
    !Config Units = [C]   
    CALL getin_p('TSOIL_REF',tsoil_ref)
    !
    !Config Key   = LITTER_STRUCT_COEF 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 3. 
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('LITTER_STRUCT_COEF',litter_struct_coef)
    !
    !Config Key   = MOIST_COEFF
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 1.1, 2.4, 0.29
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('MOIST_COEFF',moist_coeff)
    !
    !Config Key   = MOISTCONT_MIN
    !Config Desc  = minimum soil wetness to limit the heterotrophic respiration
    !Config If    = OK_STOMATE 
    !Config Def   = 0.25
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('MOISTCONT_MIN',moistcont_min)
    !
    !Config Key   = FINEROOTDEPTH_RATIO
    !Config Desc  = the ratio of fine root to overall root e-folding depth (for C inputs)
    !Config If    = OK_STOMATE and OK_SOIL_CARBON_DISCRETIZATION 
    !Config Def   = 0.5
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('FINEROOTDEPTH_RATIO',finerootdepthratio)
    !
    !Config Key   = ALTROOT_RATIO
    !Config Desc  = the maximum ratio of fine root depth to active layer thickness (for C inputs)
    !Config If    = OK_STOMATE and OK_SOIL_CARBON_DISCRETIZATION 
    !Config Def   = 0.5
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('ALTROOT_RATIO',altrootratio)
    !
    !
    !Config Key   = FRAC_WOODY
    !Config Desc  = Coefficient for determining the lignin fraction of woody litter
    !Config If    = OK_STOMATE
    !Config Def   = 0.65
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('FRAC_WOODY',frac_woody)
    !
    !Config Key   = FRAC_SNAG
    !Config Desc  = Coefficient for determining the lignin fraction of snag litter
    !Config If    = OK_STOMATE
    !Config Def   = 0.65
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('FRAC_SNAG',frac_snag)
      

    !-
    ! lpj parameters
    !-
    !
    !Config Key   = FRAC_TURNOVER_DAILY 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.55
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('FRAC_TURNOVER_DAILY',frac_turnover_daily)   

    !-
    ! npp parameters
    !-
    !
    !Config Key   = TAX_MAX
    !Config Desc  = maximum fraction of allocatable biomass used for maintenance respiration
    !Config If    = OK_STOMATE 
    !Config Def   = 0.8
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('TAX_MAX',tax_max) 

    !-
    ! phenology parameters
    !-
    !Config Key   = MIN_GROWTHINIT_TIME 
    !Config Desc  = minimum time since last beginning of a growing season
    !Config If    = OK_STOMATE 
    !Config Def   = 300. 
    !Config Help  = 
    !Config Units = [days]  
    CALL getin_p('MIN_GROWTHINIT_TIME',min_growthinit_time)
    !
    !Config Key   = GDDNCD_REF 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 964. 
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('GDDNCD_REF',gddncd_ref)
    !
    !Config Key   = GDDNCD_CURVE
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.0058 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('GDDNCD_CURVE',gddncd_curve)
    !
    !Config Key   = GDDNCD_OFFSET
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 12.8. 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('GDDNCD_OFFSET',gddncd_offset)
    !-
    ! respiration parameters
    !-
    !
    !Config Key   = MAINT_RESP_MIN_VMAX
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.3
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('MAINT_RESP_MIN_VMAX',maint_resp_min_vmax)  
    !
    !Config Key   = MAINT_RESP_COEFF 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 1.4 
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('MAINT_RESP_COEFF',maint_resp_coeff)

    !-
    ! soilcarbon parameters 
    !-
    !Config Key   = ACTIVE_TO_PASS_CLAY_FRAC
    !Config Desc  = 
    !Config if    = OK_STOMATE 
    !Config Def   = 0.68  
    !Config Help  =
    !Config Units = [-] 
    CALL getin_p('ACTIVE_TO_PASS_CLAY_FRAC',active_to_pass_clay_frac)


    !Config Key   = ACTIVE_TO_PASS_REF_FRAC
    !Config Desc  = Fixed fraction from Active to Passive pool
    !Config if    = OK_STOMATE 
    !Config Def   = 0.003
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('ACTIVE_TO_PASS_REF_FRAC',active_to_pass_ref_frac)  
    !
    !Config Key   = SURF_TO_SLOW_REF_FRAC
    !Config Desc  = Fixed fraction from Surface to Slow pool
    !Config if    = OK_STOMATE 
    !Config Def   = 0.4
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('SURF_TO_SLOW_REF_FRAC',surf_to_slow_ref_frac)  
    !
    !Config Key   = ACTIVE_TO_CO2_REF_FRAC
    !Config Desc  = Fixed fraction from Active pool to CO2 emission
    !Config if    = OK_STOMATE 
    !Config Def   = 0.85
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('ACTIVE_TO_CO2_REF_FRAC',active_to_co2_ref_frac)  
    !
    !Config Key   = SLOW_TO_PASS_REF_FRAC
    !Config Desc  = Fixed fraction from Slow to Passive pool
    !Config if    = OK_STOMATE 
    !Config Def   = 0.003
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('SLOW_TO_PASS_REF_FRAC',slow_to_pass_ref_frac)  
    !
    !Config Key   = SLOW_TO_CO2_REF_FRAC
    !Config Desc  = Fixed fraction from Slow pool to CO2 emission
    !Config if    = OK_STOMATE 
    !Config Def   = 0.55
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('SLOW_TO_CO2_REF_FRAC',slow_to_co2_ref_frac)  
    !
    !Config Key   = PASS_TO_ACTIVE_REF_FRAC
    !Config Desc  = Fixed fraction from Passive to Active pool
    !Config if    = OK_STOMATE 
    !Config Def   = 0.45
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('PASS_TO_ACTIVE_REF_FRAC',pass_to_active_ref_frac)  
    !
    !Config Key   = PASS_TO_SLOW_REF_FRAC
    !Config Desc  = Fixed fraction from Passive to Slow pool
    !Config if    = OK_STOMATE 
    !Config Def   = 0.
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('PASS_TO_SLOW_REF_FRAC',pass_to_slow_ref_frac)  
    !
    !Config Key   = ACTIVE_TO_CO2_CLAY_SILT_FRAC
    !Config Desc  = Clay-Silt-dependant fraction from Active pool to CO2 emission
    !Config if    = OK_STOMATE 
    !Config Def   = 0.68
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('ACTIVE_TO_CO2_CLAY_SILT_FRAC',active_to_co2_clay_silt_frac)  
    !
    !Config Key   = SLOW_TO_PASS_CLAY_FRAC
    !Config Desc  = Clay-dependant fraction from Slow to Passive pool
    !Config if    = OK_STOMATE 
    !Config Def   = -0.009
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('SLOW_TO_PASS_CLAY_FRAC',slow_to_pass_clay_frac)  
    !
    !Config Key   = SOM_TURN_IACTIVE
    !Config Desc  = turnover in active pool
    !Config if    = OK_STOMATE 
    !Config Def   = 7.3
    !Config Help  =
    !Config Units =  [year-1] 
    CALL getin_p('SOM_TURN_IACTIVE',som_turn_iactive)
    !
    !Config Key   = SOM_TURN_ISLOW
    !Config Desc  = turnover in slow pool
    !Config if    = OK_STOMATE 
    !Config Def   = 0.2
    !Config Help  =
    !Config Units = [year-1]
    CALL getin_p('SOM_TURN_ISLOW',som_turn_islow)
    !
    !Config Key   = SOM_TURN_IPASSIVE
    !Config Desc  = turnover in passive pool
    !Config if    = OK_STOMATE 
    !Config Def   = 0.0045
    !Config Help  = 
    !Config Units = [year-1] 
    CALL getin_p('SOM_TURN_IPASSIVE',som_turn_ipassive)
    !
    !Config Key   = FSLOW
    !Config Desc  = converting factor from active to slow pool turnover
    !Config if    = OK_STOMATE and OK_SOIL_CARBON_DISCRETIZATION
    !Config Def   = 37
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('FSLOW',fslow)
    !
    !Config Key   = FPASSIVE
    !Config Desc  = converting factor from active to slow pool turnover
    !Config if    = OK_STOMATE and OK_SOIL_CARBON_DISCRETIZATION
    !Config Def   = 1617.45 
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('FPASSIVE',fpassive)
    !
    !Config Key   = STOMATE_TAU
    !Config Desc  = turnover of the active pool 
    !Config if    = OK_STOMATE and OK_SOIL_CARBON_DISCRETIZATION
    !Config Def   = 4.699E6
    !Config Help  = 
    !Config Units = [seconds] 
    CALL getin_p('STOMATE_TAU',stomate_tau)
    !
    !Config Key   = DEPTH_MODIFIER
    !Config Desc  = turnover rate modifier depending on depth
    !Config if    = OK_STOMATE and OK_SOIL_CARBON_DISCRETIZATION
    !Config Def   = 1.E6
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('DEPTH_MODIFIER',depth_modifier)
    !
    !Config Key   = SOM_TURN_IACTIVE_CLAY_FRAC
    !Config Desc  = clay-dependant parameter impacting on turnover rate of active pool - Tm parameter of Parton et al. 1993 (-)
    !Config if    = OK_STOMATE 
    !Config Def   = 0.75
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('SOM_TURN_IACTIVE_CLAY_FRAC',som_turn_iactive_clay_frac)
    !
    !Config Key   = SOM_INIT_ACTIVE
    !Config Desc  = Initial active SOM carbon 
    !Config if    = OK_STOMATE
    !Config Def   = 1000
    !Config Help  = Putting some carbon in the soil speeds-up the spinup. As 
    !               this carbon comes with some soil nitrogen it also helps
    !               to grow vegetation when starting from scratch
    !Config Units = [g m-2]
    CALL getin_p('SOM_INIT_ACTIVE',som_init_active)
    !
    !Config Key   = SOM_INIT_SLOW
    !Config Desc  = Initial slow SOM carbon
    !Config if    = OK_STOMATE
    !Config Def   = 3000
    !Config Help  = Putting some carbon in the soil speeds-up the spinup. As 
    !               this carbon comes with some soil nitrogen it also helps
    !               to grow vegetation when starting from scratch
    !Config Units = [g m-2]
    CALL getin_p('SOM_INIT_SLOW',som_init_slow)
    !
    !Config Key   = SOM_INIT_PASSIVE
    !Config Desc  = Initial passive SOM carbon
    !Config if    = OK_STOMATE
    !Config Def   = 3000
    !Config Help  = Putting some carbon in the soil speeds-up the spinup. As 
    !               this carbon comes with some soil nitrogen it also helps
    !               to grow vegetation when starting from scratch
    !Config Units = [g m-2]
    CALL getin_p('SOM_INIT_PASSIVE',som_init_passive)
    !
    !Config Key   = SOM_INIT_SURFACE
    !Config Desc  = Initial surface SOM carbon
    !Config if    = OK_STOMATE
    !Config Def   = 1000
    !Config Help  =
    !Config Units = [g m-2]
    CALL getin_p('SOM_INIT_SURFACE',som_init_surface)
    !
    !Config Key   = CN_TARGET_IACTIVE_REF
    !Config Desc  = CN target ratio of active pool for soil min N = 0
    !Config if    = OK_STOMATE 
    !Config Def   = 15.
    !Config Help  = Putting some carbon in the soil speeds-up the spinup. As 
    !               this carbon comes with some soil nitrogen it also helps
    !               to grow vegetation when starting from scratch
    !Config Units = [-] 
    CALL getin_p('CN_TARGET_IACTIVE_REF',CN_target_iactive_ref)
    !
    !Config Key   = CN_TARGET_ISLOW_REF
    !Config Desc  = CN target ratio of slow pool for soil min N = 0
    !Config if    = OK_STOMATE 
    !Config Def   = 20.
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('CN_TARGET_ISLOW_REF',CN_target_islow_ref)
    !
    !Config Key   = CN_TARGET_IPASSIVE_REF
    !Config Desc  = CN target ratio of passive pool for soil min N = 0
    !Config if    = OK_STOMATE 
    !Config Def   = 10.
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('CN_TARGET_IPASSIVE_REF',CN_target_ipassive_ref)
    !
    !Config Key   = CN_TARGET_IACTIVE_NMIN
    !Config Desc  = CN target ratio change per mineral N unit (g m-2) for active pool 
    !Config if    = OK_STOMATE 
    !Config Def   = -6.
    !Config Help  = 
    !Config Units = [(g m-2)-1] 
    CALL getin_p('CN_TARGET_IACTIVE_NMIN',CN_target_iactive_Nmin)
    !
    !Config Key   = CN_TARGET_ISLOW_NMIN
    !Config Desc  = CN target ratio change per mineral N unit (g m-2) for slow pool 
    !Config if    = OK_STOMATE 
    !Config Def   = -4.
    !Config Help  = 
    !Config Units = [(g m-2)-1] 
    CALL getin_p('CN_TARGET_ISLOW_NMIN',CN_target_islow_Nmin)
    !
    !Config Key   = CN_TARGET_IPASSIVE_NMIN
    !Config Desc  = CN target ratio change per mineral N unit (g m-2) for passive pool 
    !Config if    = OK_STOMATE 
    !Config Def   = -1.5
    !Config Help  = 
    !Config Units = [(g m-2)-1] 
    CALL getin_p('CN_TARGET_IPASSIVE_NMIN',CN_target_ipassive_Nmin)

    ! soil nitrogen dynamic parameters
    !-
    !Config Key   = H_SAXTON
    !Config Desc  = Coefficient h for computing soil moisture content at saturation
    !Config If    = OK_STOMATE 
    !Config Def   = 0.332
    !Config Help  = Used for soil porosity when calculating the maximum
    !Config         pore volume of the soil in to calculate the 
    !Config         volumetric fraction of aneorobic microsites (ANVF) in 
    !Config         the soil, which gives an idea of how much aneorobic 
    !Config         bacteria can be transforming soil nitrogen.
    !Config Units = [m^3/m^3]  
    CALL getin_p('H_SAXTON',h_saxton)
    !-
    !Config Key   = J_SAXTON
    !Config Desc  = Coefficient j for computing soil moisture content at saturation
    !Config If    = OK_STOMATE 
    !Config Def   = -7.251*1e-4 
    !Config Help  = Used for soil porosity when calculating the maximum
    !Config         pore volume of the soil in to calculate the 
    !Config         volumetric fraction of aneorobic microsites (ANVF) in 
    !Config         the soil, which gives an idea of how much aneorobic 
    !Config         bacteria can be transforming soil nitrogen
    !Config Units = [m^3/m^3]  
    CALL getin_p('J_SAXTON',j_saxton)
    !-
    !Config Key   = K_SAXTON
    !Config Desc  = Coefficient k for computing soil moisture content at saturation
    !Config If    = OK_STOMATE 
    !Config Def   = O.1276
    !Config Help  = Used for soil porosity when calculating the maximum
    !Config         pore volume of the soil in to calculate the 
    !Config         volumetric fraction of aneorobic microsites (ANVF) in 
    !Config         the soil, which gives an idea of how much aneorobic 
    !Config         bacteria can be transforming soil nitrogen
    !Config Units = [m^3/m^3]  
    CALL getin_p('K_SAXTON',k_saxton)
    !-
    !Config Key   = DIFFUSIONO2_POWER_1
    !Config Desc  = Power used in the equation defining the diffusion of oxygen in soil
    !Config If    = OK_STOMATE 
    !Config Def   = 3.33
    !Config Help  = Diffusion of oxygen determines how well anerobic bacteria
    !Config         bacteria can live in the soil, which impacts the nitrogen
    !Config         dynamics.  This is taken from the literature.
    !Config Units = [-]  
    CALL getin_p('DIFFUSIONO2_POWER_1',diffusionO2_power_1)
    !-
    !Config Key   = DIFFUSIONO2_POWER_2
    !Config Desc  = Power used in the equation defining the diffusion of oxygen in soil
    !Config If    = OK_STOMATE 
    !Config Def   = 2.0
    !Config Help  = Diffusion of oxygen determines how well anerobic bacteria
    !Config         bacteria can live in the soil, which impacts the nitrogen
    !Config         dynamics.  This is taken from the literature.
    !Config Units = [-]  
    CALL getin_p('DIFFUSIONO2_POWER_2',diffusionO2_power_2)
    !-
    !Config Key   = F_NOFROST
    !Config Desc  = Temperature-related Factor impacting on Oxygen diffusion rate
    !Config If    = OK_STOMATE 
    !Config Def   = 1.2
    !Config Help  = Diffusion of oxygen determines how well anerobic bacteria
    !Config         bacteria can live in the soil, which impacts the nitrogen
    !Config         dynamics.  This is taken from the literature.
    !Config Units = [-]  
    CALL getin_p('F_NOFROST',F_nofrost)
    !-
    !Config Key   = F_FROST
    !Config Desc  = Temperature-related Factor impacting on Oxygen diffusion rate
    !Config If    = OK_STOMATE 
    !Config Def   = 0.8
    !Config Help  = Diffusion of oxygen determines how well anerobic bacteria
    !Config         bacteria can live in the soil, which impacts the nitrogen
    !Config         dynamics.  This is taken from the literature.
    !Config Units = [-]  
    CALL getin_p('F_FROST',F_frost)
    !-
    !Config Key   = A_ANVF
    !Config Desc  = Coefficient used in the calculation of Volumetric fraction of anaerobic microsites
    !Config If    = OK_STOMATE 
    !Config Def   = 0.85
    !Config Help  = Anerobic bacteria grow in soil microsites, which impact 
    !Config         nitrogen dynamics.  The equation using these parameters
    !Config         is from the literature, but no values are given in the
    !Config         paper.  This value is taken from a previous version of
    !Config         the code.
    !Config Units = [-]  
    CALL getin_p('A_ANVF',a_anvf)
    !-
    !Config Key   = B_ANVF
    !Config Desc  = Coefficient used in the calculation of Volumetric fraction of anaerobic microsites
    !Config If    = OK_STOMATE 
    !Config Def   = 1.
    !Config Help  = Anerobic bacteria grow in soil microsites, which impact 
    !Config         nitrogen dynamics.  The equation using these parameters
    !Config         is from the literature, but no values are given in the
    !Config         paper.  This value is taken from a previous version of
    !Config         the code.
    !Config Units = [-]  
    CALL getin_p('B_ANVF',b_anvf)
    !-
    !Config Key   = A_FIXNH4
    !Config Desc  = Coefficient used in the calculation of the Fraction of adsorbed NH4+
    !Config If    = OK_STOMATE 
    !Config Def   = 0.41
    !Config Help  = In particular, this seems to be for the calculation of
    !Config         adsorption onto soil clays.  Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('A_FIXNH4',a_FixNH4)
    !-
    !Config Key   = B_FIXNH4
    !Config Desc  = Coefficient used in the calculation of the Fraction of adsorbed NH4+
    !Config If    = OK_STOMATE 
    !Config Def   = -0.47
    !Config Help  = In particular, this seems to be for the calculation of
    !Config         adsorption onto soil clays.  Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('B_FIXNH4',b_FixNH4)
    !-
    !Config Key   = CLAY_MAX
    !Config Desc  = Coefficient used in the calculation of the Fraction of adsorbed NH4+
    !Config If    = OK_STOMATE 
    !Config Def   = 0.63
    !Config Help  = In particular, this seems to be for the calculation of
    !Config         adsorption onto soil clays.  Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('CLAY_MAX',clay_max)
    !-
    !Config Key   = FW_NIT_0
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to soil moisture
    !Config If    = OK_STOMATE 
    !Config Def   = -0.0243
    !Config Help  = Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('FW_NIT_0',fw_nit_0)
    !-
    !Config Key   = FW_NIT_1
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to soil moisture
    !Config If    = OK_STOMATE 
    !Config Def   = 0.9975
    !Config Help  = Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('FW_NIT_1',fw_nit_1)
    !-
    !Config Key   = FW__NIT_2
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to soil moisture
    !Config If    = OK_STOMATE 
    !Config Def   = -5.5368
    !Config Help  = Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('FW_NIT_2',fw_nit_2)
    !-
    !Config Key   = FW_NIT_3
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to soil moisture
    !Config If    = OK_STOMATE 
    !Config Def   = 17.651
    !Config Help  = Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('FW_NIT_3',fw_nit_3)
    !-
    !Config Key   = FW_NIT_4
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to soil moisture
    !Config If    = OK_STOMATE 
    !Config Def   = -12.904
    !Config Help  = Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('FW_NIT_4',fw_nit_4)
    !-
    !Config Key   = FT_NIT_0
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = -0.0233
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FT_NIT_0',ft_nit_0)
    !-
    !Config Key   = FT_NIT_1
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = 0.3094
    !Config Help  = Taken from the literature.  NOTE: Zhang et al 2002 fold 
    !Config         in the factor 0.1 with the parameter for the term linear 
    !Config         in temperature (ft_nit_1), while we group it with the soil
    !Config         temperature as per the rest of the terms.  Checking 
    !Config         the parameter values, this leads to a first impression 
    !Config         that they differ by a factor of 10, when in reality the 
    !Config         same overall result is calculated.
    !Config Units = [-]  
    CALL getin_p('FT_NIT_1',ft_nit_1)
    !-
    !Config Key   = FT_NIT_2
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = -0.2234
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FT_NIT_2',ft_nit_2)
    !-
    !Config Key   = FT_NIT_3
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = 0.1566
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FT_NIT_3',ft_nit_3)
    !-
    !Config Key   = FT_NIT_4
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = -0.0272
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FT_NIT_4',ft_nit_4)
    !-
    !Config Key   = FPH_0
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to pH
    !Config If    = OK_STOMATE 
    !Config Def   = -1.2314
    !Config Help  = Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('FPH_0',fph_0)
    !-
    !Config Key   = FPH_1
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to pH
    !Config If    = OK_STOMATE 
    !Config Def   = 0.7347
    !Config Help  = Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('FPH_1',fph_1)
    !-
    !Config Key   = FPH_2
    !Config Desc  = Coefficient used in the calculation of the Response of Nitrification to pH
    !Config If    = OK_STOMATE 
    !Config Def   = -0.0604
    !Config Help  = Taken from the literature.
    !Config Units = [-]  
    CALL getin_p('FPH_2',fph_2)
    !-
    !Config Key   = FTV_0
    !Config Desc  = Coefficient used in the calculation of the response of NO2 or NO production during nitrificationof to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = 2.72
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FTV_0',ftv_0)
    !-
    !Config Key   = FTV_1
    !Config Desc  = Coefficient used in the calculation of the response of NO2 or NO production during nitrificationof to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = 34.6
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FTV_1',ftv_1)
    !-
    !Config Key   = FTV_2
    !Config Desc  = Coefficient used in the calculation of the response of NO2 or NO production during nitrificationof to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = 9615.
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FTV_2',ftv_2)
    !-
    !Config Key   = K_NITRIF
    !Config Desc  = Nitrification rate at 20 ◦C and field capacity
    !Config If    = OK_STOMATE 
    !Config Def   = 2.0
    !Config Help  = The literature value is 0.2, Schmid et al., 2001
    !Config         (https://doi.org/10.1023/A:1012694218748)
    !Config         However, the value in OCN appears to be 2.0.  We keep
    !Config         the OCN value (see stomate_soilcarbon.f90 for more info).
    !Config Units = [day**-1]  
    CALL getin_p('K_NITRIF',k_nitrif)
    !-
    !Config Key   = N2O_NITRIF_P
    !Config Desc  = Reference n2o production per N-NO3 produced g N-N2O
    !Config If    = OK_STOMATE 
    !Config Def   = 0.0006
    !Config Help  = Taken from Zhang et al., 2002 - Appendix A p. 102
    !Config Units = [gN-N2O (gN-NO3)-1]  
    CALL getin_p('N2O_NITRIF_P',n2o_nitrif_p)
    !-
    !Config Key   = NO_NITRIF_P
    !Config Desc  = Reference NO production per N-NO3 produced g N-N2O
    !Config If    = OK_STOMATE 
    !Config Def   = 0.0025
    !Config Help  = Taken from Zhang et al., 2002 - Appendix A p. 102
    !Config Units = [gN-NO (gN-NO3)-1]  
    CALL getin_p('NO_NITRIF_P',no_nitrif_p)
    !-
    !Config Key   = CHEMO_T0
    !Config Desc  = Coefficient used in the calculation of the Response of NO production from chemodenitrification to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = -31494
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('CHEMO_T0',chemo_t0)
    !-
    !Config Key   = CHEMO_PH0
    !Config Desc  = Coefficient used in the calculation of the Response of NO production from chemodenitrification to pH
    !Config If    = OK_STOMATE 
    !Config Def   = -1.62
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('CHEMO_PH0',chemo_ph0)
    !-
    !Config Key   = CHEMO_0
    !Config Desc  = Coefficient used in the calculation of NO production from chemodenitrification
    !Config If    = OK_STOMATE 
    !Config Def   = 30.
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('CHEMO_0',chemo_0)
    !-
    !Config Key   = CHEMO_1
    !Config Desc  = Coefficient used in the calculation of NO production from chemodenitrification
    !Config If    = OK_STOMATE 
    !Config Def   = 16565
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('CHEMO_1',chemo_1)
    !-
    !Config Key   = FT_DENIT_0
    !Config Desc  = Coefficient used in the response of relative growth rate of total denitrifiers to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = 2.
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FT_DENIT_0',ft_denit_0)
    !-
    !Config Key   = FT_DENIT_1
    !Config Desc  = Coefficient used in the response of relative growth rate of total denitrifiers to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = 22.5
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FT_DENIT_1',ft_denit_1)
    !-
    !Config Key   = FT_DENIT_2
    !Config Desc  = Coefficient used in the response of relative growth rate of total denitrifiers to Temperature
    !Config If    = OK_STOMATE 
    !Config Def   = 10
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FT_DENIT_2',ft_denit_2)
    !-
    !Config Key   = FPH_NO3_0
    !Config Desc  = Coefficient used in the response of relative growth rate of NO3 denitrifiers to pH
    !Config If    = OK_STOMATE 
    !Config Def   = 4.25
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FPH_NO3_0',fph_no3_0)
    !-
    !Config Key   = FPH_NO3_1
    !Config Desc  = Coefficient used in the response of relative growth rate of NO3 denitrifiers to pH
    !Config If    = OK_STOMATE 
    !Config Def   = 0.5
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FPH_NO3_1',fph_no3_1)
    !-
    !Config Key   = FPH_NO_0
    !Config Desc  = Coefficient used in the response of relative growth rate of NO denitrifiers to pH
    !Config If    = OK_STOMATE 
    !Config Def   = 5.25
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FPH_NO_0',fph_no_0)
    !-
    !Config Key   = FPH_NO_1
    !Config Desc  = Coefficient used in the response of relative growth rate of NO denitrifiers to pH
    !Config If    = OK_STOMATE 
    !Config Def   = 1.
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FPH_NO_1',fph_no_1)
    !-
    !Config Key   = FPH_N2O_0
    !Config Desc  = Coefficient used in the response of relative growth rate of N2O denitrifiers to pH
    !Config If    = OK_STOMATE 
    !Config Def   = 6.25
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FPH_N2O_0',fph_n2o_0)
    !-
    !Config Key   = FPH_N2O_1
    !Config Desc  = Coefficient used in the response of relative growth rate of N2O denitrifiers to pH
    !Config If    = OK_STOMATE 
    !Config Def   = 1.5
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FPH_N2O_1',fph_n2o_1)
    !-
    !Config Key   = KN
    !Config Desc  = Half Saturation of N oxydes 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.083
    !Config Help  =
    !Config Units = [kgN/m**3]  
    CALL getin_p('KN',Kn)
    !-
    !Config Key   = CTE_BACT
    !Config Desc  = Denitrification activiy of bacteria     
    !Config If    = OK_STOMATE
    !Config Def   = 0.00005
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('CTE_BACT',cte_bact)
    !-
    !Config Key   = MU_NO3_MAX
    !Config Desc  = Maximum Relative growth rate of NO3 denitrifiers
    !Config If    = OK_STOMATE 
    !Config Def   = 0.67
    !Config Help  =
    !Config Units = [hour**-1]  
    CALL getin_p('MU_NO3_MAX',mu_no3_max)
    !-
    !Config Key   = MU_NO_MAX
    !Config Desc  = Maximum Relative growth rate of NO denitrifiers
    !Config If    = OK_STOMATE 
    !Config Def   = 0.34
    !Config Help  =
    !Config Units = [hour**-1]  
    CALL getin_p('MU_NO_MAX',mu_no_max)
    !-
    !Config Key   = MU_N2O_MAX
    !Config Desc  = Maximum Relative growth rate of N2O denitrifiers
    !Config If    = OK_STOMATE 
    !Config Def   = 0.34
    !Config Help  =
    !Config Units = [hour**-1]  
    CALL getin_p('MU_N2O_MAX',mu_n2o_max)
    !-
    !Config Key   = Y_NO3
    !Config Desc  = Maximum growth yield of NO3 denitrifiers on N oxydes
    !Config If    = OK_STOMATE 
    !Config Def   = 0.401
    !Config Help  =
    !Config Units = [kgC / kgN]  
    CALL getin_p('Y_NO3',Y_no3)
    !-
    !Config Key   = Y_NO
    !Config Desc  = Maximum growth yield of NO denitrifiers on N oxydes
    !Config If    = OK_STOMATE 
    !Config Def   = 0.428
    !Config Help  =
    !Config Units = [kgC / kgN]  
    CALL getin_p('Y_NO',Y_no)
    !-
    !Config Key   = Y_N2O
    !Config Desc  = Maximum growth yield of N2O denitrifiers on N oxydes
    !Config If    = OK_STOMATE 
    !Config Def   = 0.151
    !Config Help  =
    !Config Units = [kgC / kgN]  
    CALL getin_p('Y_N2O',Y_n2O)
    !-
    !Config Key   = M_NO3
    !Config Desc  = Maintenance coefficient on NO3
    !Config If    = OK_STOMATE 
    !Config Def   = 0.09
    !Config Help  =
    !Config Units = [kgN / kgC / hour]  
    CALL getin_p('M_NO3',M_no3)
    !-
    !Config Key   = M_NO
    !Config Desc  = Maintenance coefficient on NO
    !Config If    = OK_STOMATE 
    !Config Def   = 0.035
    !Config Help  =
    !Config Units = [kgN / kgC / hour]  
    CALL getin_p('M_NO',M_no)
    !-
    !Config Key   = M_N2O
    !Config Desc  = Maintenance coefficient on N2O
    !Config If    = OK_STOMATE 
    !Config Def   = 0.079
    !Config Help  =
    !Config Units = [kgN / kgC / hour]  
    CALL getin_p('M_N2O',M_n2o)
    !-
    !Config Key   = MAINT_C
    !Config Desc  = Maintenance coefficient of carbon
    !Config If    = OK_STOMATE 
    !Config Def   = 0.0076
    !Config Help  =
    !Config Units = [kgC / kgC / hour]  
    CALL getin_p('MAINT_C',Maint_c)
    !-
    !Config Key   = YC
    !Config Desc  = Maximum growth yield on soluble carbon
    !Config If    = OK_STOMATE 
    !Config Def   = 0.503
    !Config Help  =
    !Config Units = [kgC / kgC ]  
    CALL getin_p('YC',Yc)
    !-
    !Config Key   = F_CLAY_0
    !Config Desc  = Coefficient used in the eq. defining the response of N-emission to clay fraction
    !Config If    = OK_STOMATE 
    !Config Def   = 0.13
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('F_CLAY_0',F_clay_0)
    !-
    !Config Key   = F_CLAY_1
    !Config Desc  = Coefficient used in the eq. defining the response of N-emission to clay fraction
    !Config If    = OK_STOMATE 
    !Config Def   = -0.079
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('F_CLAY_1',F_clay_1)
    !-
    !Config Key   = RATIO_NH4_FERT
    !Config Desc  = Proportion of ammonium in the fertilizers (ammo-nitrate) 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.875
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('RATIO_NH4_FERT',ratio_nh4_fert)
    !-
    !Config Key   = CN_RATIO_MANURE
    !Config Desc  = C:N ratio of organic fertilizers coming from Fuchs,et al,
    !Effets agronomiques attendus de l’épandage des Mafor sur les écosystèmes
    !agricoles et forestiers, Valoris. des matières Fertil. d’origine résiduaire
    !sur les sols à usage Agric. ou For., 364–567 [online] mean over table 3-1-1
    !Config If    = OK_STOMATE 
    !Config Def   = 13.7
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('CN_RATIO_MANURE',cn_ratio_manure)
    !-
    !-
    ! Arrays
    !-
    !Config Key   = K_N_MIN
    !Config Desc  = [NH4+] and [NO3-] for which the Nuptake equals vmax/2. 
    !Config If    = OK_STOMATE 
    !Config Def   = 30. 30.
    !Config Help  =
    !Config Units = [umol per litter]  
    CALL getin_p('K_N_min',K_N_min)
    !-
    !Config Key   = LOW_K_N_MIN
    !Config Desc  = Rate of N uptake not associated with Michaelis- Menten Kinetics for Ammonium
    !Config If    = OK_STOMATE 
    !Config Def   = 0.0002 0.0002
    !Config Help  =
    !Config Units = [umol**-1]  
    CALL getin_p('LOW_K_N_min',low_K_N_min)

    !Config Key   = EMM_FAC
    !Config Desc  = Factor for reducing NH3 emission  
    !Config If    = OK_NCYCLE
    !Config Def   = 0.2
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('EMM_FAC',emm_fac)

    !Config Key   = FACT_KN_NO
    !Config Desc  = Factor for adusting kn constant for NOx production
    !Config If    = OK_NCYCLE
    !Config Def   = 0.012
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FACT_KN_NO',fact_kn_no)

    !Config Key   = FACT_KN_N2O
    !Config Desc  = Factor for adusting kn constant for N2O production
    !Config If    = OK_NCYCLE
    !Config Def   = 0.04
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FACT_KN_N2O',fact_kn_n2o)

    !Config Key   = KFWDENIT
    !Config Desc  = Factor for adjusting sensitivity of denitrification to water content
    !Config If    = OK_NCYCLE
    !Config Def   = -5.
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('KFWDENIT',kfwdenit)

    !Config Key   = FWDENITFC
    !Config Desc  = Value at field capacity of the sensitivity function of denitrification to water content
    !Config If    = OK_NCYCLE
    !Config Def   = 0.05
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('FWDENITFC',fwdenitfc)

    !Config Key   = FRACN_DRAINAGE
    !Config Desc  = Fraction of NH3/NO3 loss by drainage 
    !Config If    = OK_NCYCLE
    !Config Def   = 1.0
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FRACN_DRAINAGE',fracn_drainage)

    !Config Key   = FRACN_RUNOFF
    !Config Desc  = Fraction of NH3/NO3 loss by runoff
    !Config If    = OK_NCYCLE
    !Config Def   = 0.3
    !Config Help  =
    !Config Units = [-]  
    CALL getin_p('FRACN_RUNOFF',fracn_runoff)

    !-
    !Config Key   = LEAF_N_DMAX
    !Config Desc  = ?????????????
    !Config If    = OK_STOMATE 
    !Config Def   = 0.25
    !Config Help  =
    !Config Units = ???
    CALL getin_p('LEAF_N_DMAX',DMAX)

    !-
    !Config Key   = P_N_UPTAKE
    !Config Desc  = Minimum value of the correction factor for plant N uptake
    !               case of enough N in the reserve
    !Config If    = OK_STOMATE 
    !Config Def   = 0.6
    !Config Help  =
    !Config Units = [-]
    CALL getin_p('P_N_UPTAKE',p_n_uptake)

    !-
    ! growth_fun_all
    !
    !Config Key   = SYNC_THRESHOLD
    !Config Desc  = The threshold value for a warning when we sync biomass
    !Config If    = OK_STOMATE 
    !Config Def   = 0.1 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('SYNC_THRESHOLD',sync_threshold)
    !
    !Config Key   = MAX_DELTA_KF
    !Config Desc  = Maximum change in KF from one time step to another
    !Config If    = OK_STOMATE 
    !Config Def   = 0.1 
    !Config Help  = 
    !Config Units = [m]  
    CALL getin_p('MAX_DELTA_KF',max_delta_KF)
    !

    !
    !Config Key   = MAINT_FROM_GPP
    !Config Desc  = Some carbon needs to remain to support the growth, hence, 
    !               respiration will be limited. In this case resp_maint 
    !               (gC m-2 dt-1) should not be more than 80% (::maint_from_gpp) 
    !               of the GPP (gC m-2 s-1)
    !Config If    = OK_STOMATE 
    !Config Def   = 0.8
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('MAINT_FROM_GPP',maint_from_gpp)


    !-
    ! turnover parameters
    !-
    !
    !Config Key   = NEW_TURNOVER_TIME_REF
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 20. 
    !Config Help  = 
    !Config Units = [days]  
    CALL getin_p('NEW_TURNOVER_TIME_REF',new_turnover_time_ref)

    !-
    ! vmax parameters
    !-
    !
    !Config Key   = VMAX_OFFSET 
    !Config Desc  = offset (minimum relative vcmax)
    !Config If    = OK_STOMATE 
    !Config Def   = 0.3
    !Config Help  = offset (minimum vcmax/vmax_opt)
    !Config Units = [-]  
    CALL getin_p('VMAX_OFFSET',vmax_offset)
    !
    !Config Key   = LEAFAGE_FIRSTMAX
    !Config Desc  = leaf age at which vmax attains vcmax_opt (in fraction of critical leaf age)
    !Config If    = OK_STOMATE 
    !Config Def   = 0.03 
    !Config Help  = relative leaf age at which vmax attains vcmax_opt
    !Config Units = [-] 
    CALL getin_p('LEAFAGE_FIRSTMAX',leafage_firstmax)
    !
    !Config Key   = LEAFAGE_LASTMAX 
    !Config Desc  = leaf age at which vmax falls below vcmax_opt (in fraction of critical leaf age) 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.5 
    !Config Help  = relative leaf age at which vmax falls below vcmax_opt
    !Config Units = [-]  
    CALL getin_p('LEAFAGE_LASTMAX',leafage_lastmax)
    !
    !Config Key   = LEAFAGE_OLD 
    !Config Desc  = leaf age at which vmax attains its minimum (in fraction of critical leaf age)
    !Config If    = OK_STOMATE 
    !Config Def   = 1.
    !Config Help  = relative leaf age at which vmax attains its minimum
    !Config Units = [-]  
    CALL getin_p('LEAFAGE_OLD',leafage_old)
    !
    !-
    ! season parameters
    !-
    !
    !Config Key   = GPPFRAC_DORMANCE 
    !Config Desc  = rapport maximal GPP/GGP_max pour dormance
    !Config If    = OK_STOMATE 
    !Config Def   = 0.2 
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('GPPFRAC_DORMANCE',gppfrac_dormance)
    !
    !Config Key   = TAU_CLIMATOLOGY
    !Config Desc  = tau for "climatologic variables 
    !Config If    = OK_STOMATE 
    !Config Def   = 20
    !Config Help  = 
    !Config Units = [days]
    CALL getin_p('TAU_CLIMATOLOGY',tau_climatology)
    !
    !Config Key   = HVC1 
    !Config Desc  = parameters for herbivore activity
    !Config If    = OK_STOMATE 
    !Config Def   = 0.019
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('HVC1',hvc1)
    !
    !Config Key   = HVC2 
    !Config Desc  = parameters for herbivore activity 
    !Config If    = OK_STOMATE 
    !Config Def   = 1.38
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('HVC2',hvc2)
    !
    !Config Key   = LEAF_FRAC_HVC
    !Config Desc  = parameters for herbivore activity 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.33
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('LEAF_FRAC_HVC',leaf_frac_hvc)
    !
    !Config Key   = TLONG_REF_MAX
    !Config Desc  = maximum reference long term temperature 
    !Config If    = OK_STOMATE 
    !Config Def   = 303.1
    !Config Help  = 
    !Config Units = [K]  
    CALL getin_p('TLONG_REF_MAX',tlong_ref_max)
    !
    !Config Key   = TLONG_REF_MIN 
    !Config Desc  = minimum reference long term temperature 
    !Config If    = OK_STOMATE 
    !Config Def   = 253.1
    !Config Help  = 
    !Config Units = [K]  
    CALL getin_p('TLONG_REF_MIN',tlong_ref_min)
    !
    !Config Key   = NCD_MAX_YEAR
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 3. 
    !Config Help  = NCD : Number of Chilling Days
    !Config Units = [days]
    CALL getin_p('NCD_MAX_YEAR',ncd_max_year)
    !
    !Config Key   = NGD_THRESHOLD 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = -5. 
    !Config Help  = NGD : Growing Degree-Day since midwinter
    !Config Units = [days] 
    CALL getin_p('NGD_THRESHOLD',ngd_threshold)
    !
    !Config Key   = GREEN_AGE_EVER 
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 2. 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('GREEN_AGE_EVER',green_age_ever)
    !
    !Config Key   = GREEN_AGE_DEC
    !Config Desc  = 
    !Config If    = OK_STOMATE 
    !Config Def   = 0.5 
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('GREEN_AGE_DEC',green_age_dec)


    !Config Key   = NGD_MIN_DORMANCE
    !Config Desc  = Minimum length (days) of the dormance period for species with the ngd phenology type
    !Config If    = OK_STOMATE 
    !Config Def   = 90.
    !Config Help  = 
    !Config Units = [days] 
    CALL getin_p('NGD_MIN_DORMANCE',ngd_min_dormance)
 
    
    !Config Key   = NAGEC
    !Config Desc  = Number of age classes
    !Config If    = OK_STOMATE 
    !Config Def   = 1 
    !Config Help  = Number of age classes in forestry and lcchange
    !               age classes could be considered age classes across stands 
    !               in the same pixel. They help to describe landscape heterogeneity
    !               they are most useful when land cover change is used.
    !Config Units = [-]
    nagec = 1
    CALL getin_p('NAGEC',nagec)
    !
    
    ALLOCATE(age_class_bound(nagec),stat=ier)
    l_error = l_error .OR. (ier /= 0)
    IF (l_error) THEN
       WRITE(numout,*) 'Memory allocation error for age_class_bound. We stop. We need nagec words',nagec
       STOP 'constantes.f90'
    ENDIF
    ! 
    !Config Key   = AGE_CLASS_BOUND
    !Config Desc  = Boundaries of the age classes
    !Config If    = OK_STOMATE 
    !Config Def   = 5.0 
    !Config Help  = The number of age class bounds should be identical
    !               to NAGEC. Two sets of default values are provided.
    !Config Units = [m]
    IF(nagec == 4)THEN
       age_class_bound(1) = 0.07
       age_class_bound(2) = 0.20
       age_class_bound(3) = 0.40
       age_class_bound(4) = 5.00
    ELSEIF(nagec == 1)THEN
       age_class_bound(1) = 5.00
    ELSE
       age_class_bound(:) = -9999.
    ENDIF
    CALL getin_p('AGE_CLASS_BOUND',age_class_bound)

    IF (age_class_bound(1) == -9999.) THEN
       WRITE(numout,*) 'The code does not contain default values for age_class_bound'
       WRITE(numout,*) 'for this number of age classes (nagec) ',nagec
       CALL ipslerr_p (3,'constantes.f90', 'Define age class bounds',&
            'add default values in constantes.f90',& 
            'or add values in the orchidee_pft.def')
    END IF

    ! Check for inconsistent configuration
    IF (spinup_analytic .AND. veget_update .GT.0 .AND. nagec .GT.1) THEN
       WRITE(numout,*) 'Use the analytical spinup, ',spinup_analytic
       WRITE(numout,*) 'Use land cover changes, ',veget_update
       WRITE(numout,*) 'Number of age classes, ',nagec
       CALL ipslerr_p(3,'The spinup cannot handle land cover changes',&
            'and age classes at the same time',&
            'If you really need a spinup with lcc you will have to',&
            'further develop the code in age_class_distr (sapiens_lcchange.f90)')
    END IF
    !
    !Config Key   = MIN_WATER_STRESS
    !Config Desc  = Minimal value for wstress_fac
    !Config If    = OK_STOMATE 
    !Config Def   = 0.1 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('MIN_WATER_STRESS',min_water_stress)
    !
    !Config Key   = NDIA_HARVEST
    !Config Desc  = Number of basal area classes in which the harvest is stored
    !Config If    = OK_STOMATE 
    !Config Def   = 5 
    !Config Help  = Number of basal area classes in which the harvest
    !               is stored. This is useful when harvest is further
    !               used in a wood-use module
    !Config Units = [-]
    ndia_harvest = 5
    CALL getin_p('NDIA_HARVEST',ndia_harvest)
    !
    !Config Key   = MAX_HARVEST_DIA
    !Config Desc  = The maximum diamter of tree which can be harvested
    !Config If    = OK_STOMATE 
    !Config Def   = 1.0
    !Config Help  = The maximum diamter of tree which can be 
    !               harvested.  Notice that we will create a class 
    !               that is one size larger than this to make sure
    !               we keep track of all the wood.
    !Config Units = [m]
    CALL getin_p('MAX_HARVEST_DIA',max_harvest_dia) 

    !Config Key   = N_PAI
    !Config Desc  = Number of years used for the calculation of the periodic annual increment
    !Config If    = OK_STOMATE 
    !Config Def   = 5 
    !Config Help  = 
    !Config Units = [-]
    CALL getin_p('N_PAI',n_pai)
    !
    !Config Key   = NTREES_PROFIT
    !Config Desc  = Number of trees below which the forest will be cut and replanted
    !Config If    = FOREST_MANAGEMENT  
    !Config Def   = 100 
    !Config Help  = Fewer trees than ntrees_profit is considered no
    !               longer profitable. Hence the stand will be cut 
    !               and replaced. It mimics disturbance in unmanaged forests
    !               and it prevents forest from becoming unrealistically old.
    !Config Units = [number of trees]
    ntrees_profit=1
    CALL getin_p('NTREES_PROFIT',ntrees_profit)
    !
    ! If we don't read the new species from a map, we will use veget_max
    ! instead. So we will replant with the current species. This will
    ! only happen if species_change_force equals -9999. If 
    ! species_change_force has a different value in the run.def that
    ! value will be used. Note that species_change_force is intended for
    ! testing and debugging.
    !Config Key   = SPECIES_CHANGE_FORCE
    !Config Desc  = New species after a final cut for testing and debugging only
    !Config If    = OK_STOMATE
    !Config Def   = -9999
    !Config Help  = If we don't read the new species from a map, we will use veget_max
    !               instead. So we will replant with the current species. This will
    !               only happen if species_change_force equals -9999. If 
    !               species_change_force has a different value in the run.def that
    !               value will be used. Note that species_change_force is intended for
    !               testing and debugging.
    !Config Units = [PFT number]
    species_change_force=-9999
    CALL getin_p('SPECIES_CHANGE_FORCE',species_change_force)

    !Config Key   = FM_CHANGE_FORCE
    !Config Desc  = New management after a final cut for testing and debugging only
    !Config If    = OK_STOMATE, LCHANGE_SPECIES
    !Config Def   = ifm_none
    !Config Help  = If we don't read the new speciesFM strategies from a map, we 
    !               will force it with this variable. Following a harvest all
    !               management will be set to unmanaged.
    !Config Units = [1, 2, 3 or 4; unitless]
    fm_change_force = ifm_none
    CALL getin_p('FM_CHANGE_FORCE',fm_change_force)      

    ! Bark beetle attack module
    !Config Key   = nb_years_bgi
    !Config Desc  = numbers of years over which bark beetle generation index is calculated
    !Config If    = OK_PEST, OK_STOMATE
    !Config Def   = 3
    !Config Help  = numbers we have to average to calculate the bark beetle
    !generation index. use in beetle damage module
    !Config Units = [years]
    nb_years_bgi = 3
    CALL getin_p('NB_YEARS_BGI',nb_years_bgi)

    !-
    ! windthrow
    !-
    !Config Key   = DAILY_MAX_TUNE
    !Config Desc  = Non linear tuning factor for daily maximum wind speed used in windthrow module
    !Config If    = OK_WINDTHROW, stomate main program
    !Config Def   = 1.000
    !Config Help  =
    !Config Units = [-]
    daily_max_tune = 1.000
    CALL getin_p('DAILY_MAX_TUNE',daily_max_tune)

    !Config Key   = ELEVATE_WIND
    !Config Desc  = Non linear tuning factor for daily maximum wind speed used
    !in windthrow module
    !Config If    = OK_WINDTHROW, stomate main program
    !Config Def   = 10.0
    !Config Help  =
    !Config Units = [-]
    elevate_wind = 10.0
    CALL getin_p('ELEVATE_WIND',elevate_wind)

    !Config Key   = H_THRESHOLD_WIND
    !Config Desc  = Ratio of height threshold to pipe_tune2 for truncating wind damage
    !Config If    = OK_WINDTHROW, stomate main program
    !Config Def   = 0.3
    !Config Help  =
    !Config Units = [-]
    h_threshold_wind = 0.3
    CALL getin_p('H_THRESHOLD_WIND',h_threshold_wind)

    !Config Key   = WIND_SPEED_STORM_THR
    !Config Desc  = the wind speed threshold above which is_storm flag is set to TRUE 
    !Config If    = OK_WINDTHROW, stomate main program
    !Config Def   = 20.000
    !Config Help  =
    !Config Units = meter per second 
    wind_speed_storm_thr = 20.000
    CALL getin_p('WIND_SPEED_STORM_THR',wind_speed_storm_thr)

    !Config Key   = WIND_DAYS
    !Config Desc  = the number of days to save sum of wind speed overtime  
    !Config If    = OK_WINDTHROW, stomate main program
    !Config Def   = 3
    !Config Help  =
    !Config Units = day
    wind_days = 3
    CALL getin_p('WIND_DAYS',wind_days)

    !Config Key   = WIND_SUM_THRESHOLD
    !Config Desc  = Threshold for the sum of wind_days of wind speed for all
    ! time stpe to calculate wind damage 
    !Config If    = OK_WINDTHROW, stomate main program
    !Config Def   = 200
    !Config Help  =
    !Config Units = m/s
    CALL getin_p('WIND_SUM_THRESHOLD',wind_sum_threshold)

    !Config Key   = WIND_RATIO_THRESHOLD
    !Config Desc  = Threshold for the ratio of wind to longterm wind for each
    ! time stpe to sum ratios
    !Config If    = OK_WINDTHROW, stomate main program
    !Config Def   = 2.5
    !Config Help  =
    !Config Units = -
    CALL getin_p('WIND_RATIO_THRESHOLD',wind_ratio_threshold)

    !Config Key   = NB_DAYS_STORM
    !Config Desc  = the number of days at which the max wind speed is less than wind_speed_storm_thr
    !Config If    = OK_WINDTHROW, stomate main program
    !Config Def   = 5
    !Config Help  =
    !Config Units = days
    nb_days_storm = 5
    CALL getin_p('NB_DAYS_STORM',nb_days_storm)

    !Config Key   = FORCED_CLEAR_CUT
    !Config Desc  = Use to force a clear cut at a specific year during a simulation.
    !Config If    = OK_STOMATE
    !Config Def   = .FALSE.
    !Config Help  = 
    !Config Units = year
    forced_clear_cut= .FALSE.
    CALL getin_p('FORCED_CLEAR_CUT',forced_clear_cut)

    !Config Key   = NOUTDIACLASS
    !Config Desc  = Number of diameter classes in the output files
    !Config If    = OK_STOMATE
    !Config Def   = 16
    !Config Help  = ncirc is the number of circumference classes
    !               ORCHIDEE. For tree demography it could be more 
    !               convenient to get the results in diameter
    !               classes with fixed boundaries.
    !Config Units = [-]
    CALL getin_p('NOUTDIACLASS',noutdiaclass)

    ALLOCATE(out_dia_class(noutdiaclass+1),stat=ier)
    l_error = l_error .OR. (ier /= 0)
    IF (l_error) THEN
       WRITE(numout,*) 'Memory allocation error for out_dia_class. We stop. We need nagec words',noutdiaclass
       STOP 'constantes.f90'
    ENDIF

    !Config Key   = OUT_DIA_CLASS
    !Config Desc  = Boundaries of diameter classes in the output files
    !Config If    = OK_STOMATE
    !Config Def   = zero, .01, .05, .1, .15, .2, .3, .4, .5, .6, .7, .8, .9, 1., 1.5, 2., 9.9
    !Config Help  = Boundaries of the diameter classes used in an
    !               additional output file. Given the way this part is
    !               coded, this list should start with zero and end with
    !               a very high and thus unlikely diameter. The length of
    !               the list is thus noutdiaclass+1.
    !Config Units = [m]  
    IF (noutdiaclass.EQ.16) THEN
       out_dia_class =   (/  0.0, 0.01, 0.05, 0.1, 0.15, 0.2, 0.3, &      
                 0.4,  0.5,  0.6, 0.7,  0.8, 0.9, 1.0, &  
                 1.5,  2.0,  9.9 /)   
    ELSEIF(noutdiaclass.GT.16) THEN
       CALL ipslerr_p(3,'not enough output variables have been defined', &
            'only 16 diameter classes have been defined for xios', &
            'have a look at src_xml and define more classes in the', &
            'field and file definition files')
    ELSE
       out_dia_class(:) = -9999
    END IF
    CALL getin_p('OUT_DIA_CLASS',out_dia_class)
   
    IF (out_dia_class(1).EQ.-9999) THEN
       WRITE(numout,*) 'The code does not contain default values for out_dia_class'
       WRITE(numout,*) 'for this number of output diameter classes (noutdiaclass) ', noutdiaclass
       CALL ipslerr_p (3,'constantes.f90', 'Define bounds of output diameter classes',&
            'add default values in constantes.f90','or add values in the orchidee_pft.def')
    END IF
    DO iout = 2,noutdiaclass+1
       WRITE(striout,'(I2.2)') iout-1
       WRITE(numout,*) 'OUT_CLASS '//TRIM(striout), &
            ' in XIOS contains trees with diameters' 
       WRITE(numout,*) 'between ',out_dia_class(iout-1),' and ', &
            out_dia_class(iout)
    END DO

    !Config Key   = USE_HEIGHT_DOM
    !Config Desc  = Use the dominant vegetation height instead of the average height when calculating roughness length
    !Config If    = OK_STOMATE
    !Config Def   = .FALSE.
    !Config Help  = This is a somewhat odd switch, since it impacts sechiba
    !               but can only be used when stomate is activated.
    !Config Units = [-]
    use_height_dom= .FALSE.
    CALL getin_p('USE_HEIGHT_DOM',use_height_dom)

    !Config Key   = ERR_ACT
    !Config Desc  = Action following an error
    !Config If    = OK_STOMATE
    !Config Def   = 1
    !Config Help  = The code distinguishes between two options to check for mass balance
    !               problems:
    !               ERR_ACT = 1 is recommended when running global
    !               long-term simulations. Under this option, mass balance closure is
    !               checked for all biogeochemical processes but only at the highest level
    !               thus stomate.f90 and stomate_lpj.f90. Although the mass balance checks
    !               are not very expensive in terms of computer time, skipping the numerous
    !               lower level checks is expected to save some time. Under this option the
    !               mass balance error is only written to the history file. No information
    !               is provided in which subroutine the problem occurred.
    !               ERR_ACT = 2
    !               is recommended when developing and testing the model. Now the mass
    !               balance is explicitly checked in stomate.f90, stomate_lpj.f90 and all
    !               its subroutines. Under this option the mass balance error is written to
    !               the history file and if the mass balance is not closed, the warning
    !               message will indicate in which subroutine the problem likely
    !               originated. 
    !               ERR_ACT = 3 is recommended when having a problem with
    !               mass balance closure. The mass balance is explicitly checked in
    !               stomate.f90, stomate_lpj.f90 and all its subroutines. If a mass balance
    !               occurs, the model is stopped. 
    !               ERR_ACT = 4 is for mass balance enthousiasts.
    !               If the model crashed on a mass balance issue in stomate_growth_fun_all
    !               this setting will activate intermediate checks. Intermediate checks may 
    !               help to narrow down in which part of the code the problem occurs. It also
    !               activates nbp consistency checks for those interested in better defining
    !               nep, nbp and tracing all the C and N in stomate_lpj.f90
    !Config Units = [1: write to history file, 2: warn and write to history file, and 3&4: stop the model]
    err_act = 1
    CALL getin_p('ERR_ACT',err_act)

    SELECT CASE (err_act)
    CASE(1)
        IF (printlev>=2) WRITE(numout,*) 'ERR_ACT=1: Many ipserr messages related to conservation problems will be skipped'
        plev = 0
    CASE(2)
        IF (printlev>=2) WRITE(numout,*) 'ERR_ACT=2: In case of a conservation problem the user will be warned'
        plev = 2
    CASE(3, 4)
        IF (printlev>=2) WRITE(numout,*) 'ERR_ACT=3 or 4: In case of a conservation problem the model will be stopped'
        plev = 3
    CASE DEFAULT
        CALL ipslerr_p(3,'Error in constantes.f90',&
            'Unknown value for ERR_ACT',&
            'Not clear how to treat errors','')   
    ENDSELECT

    !Config Key   = OK_FORCE_PHENO
    !Config Desc  = Use to force phenology when the conditions are not suitable
    !Config If    = OK_STOMATE
    !Config Def   = .TRUE.
    !Config Help  = Temperature phenology is very predictable and happens every year but
    !               moisture-driven phenology is less stable because the conditions
    !               may not be satisfied during 12 months resulting in a year without
    !               a canopy. If the model has passed the average budbreak day by a
    !               prescribed PFT-specific offset (::force_pheno), budbreak will be forced
    !               (given the condition that buds are avaialble)
    !Config Units = [-]
    CALL getin_p('OK_FORCE_PHENO',ok_force_pheno)

  END SUBROUTINE config_stomate_parameters

!! ================================================================================================================================
!! SUBROUTINE   : config_dgvm_parameters 
!!
!>\BRIEF        This subroutine reads in the configuration file all the parameters 
!! needed when the DGVM model is activated (ie : when ok_dgvm is set to true).
!!
!! DESCRIPTION  : None
!!
!! RECENT CHANGE(S): None
!!
!! MAIN OUTPUT VARIABLE(S): 
!!
!! REFERENCE(S) :
!!
!! FLOWCHART    :
!! \n
!_ ================================================================================================================================

  SUBROUTINE config_dgvm_parameters   

    IMPLICIT NONE

    !! 0. Variables and parameters declaration

    !! 0.4 Local variables

    !_ ================================================================================================================================    

    !-
    ! establish parameters
    !-
    !
    !Config Key   = ESTAB_MAX_TREE
    !Config Desc  = Maximum tree establishment rate 
    !Config If    = OK_DGVM
    !Config Def   = 0.12 
    !Config Help  = 
    !Config Units = [-]   
    CALL getin_p('ESTAB_MAX_TREE',estab_max_tree)
    !
    !Config Key   = ESTAB_MAX_GRASS
    !Config Desc  = Maximum grass establishment rate
    !Config If    = OK_DGVM
    !Config Def   = 0.12 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('ESTAB_MAX_GRASS',estab_max_grass)
    !
    !Config Key   = ESTABLISH_SCAL_FACT
    !Config Desc  = 
    !Config If    = OK_DGVM 
    !Config Def   = 5.
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('ESTABLISH_SCAL_FACT',establish_scal_fact)
    !
    !Config Key   = MAX_TREE_COVERAGE 
    !Config Desc  = 
    !Config If    = OK_DGVM 
    !Config Def   = 0.98
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('MAX_TREE_COVERAGE',max_tree_coverage)
    !
    !Config Key   = IND_0_ESTAB
    !Config Desc  = 
    !Config If    = OK_DGVM 
    !Config Def   = 0.2
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('IND_0_ESTAB',ind_0_estab)

    !-
    ! light parameters
    !-
    !
    !Config Key   = ANNUAL_INCREASE
    !Config Desc  = for diagnosis of fpc increase, compare today's fpc to last year's maximum (T) or to fpc of last time step (F)?
    !Config If    = OK_DGVM
    !Config Def   = y
    !Config Help  = 
    !Config Units = [FLAG]
    CALL getin_p('ANNUAL_INCREASE',annual_increase)
    !
    !Config Key   = MIN_COVER 
    !Config Desc  = For trees, minimum fraction of crown area occupied 
    !Config If    = OK_DGVM
    !Config Def   = 0.05 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('MIN_COVER',min_cover)

    !-
    ! pftinout parameters
    !
    !Config Key   = IND_0 
    !Config Desc  = initial density of individuals
    !Config If    = OK_DGVM
    !Config Def   = 0.02 
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('IND_0',ind_0)
    !
    !Config Key   = MIN_AVAIL
    !Config Desc  = minimum availability
    !Config If    = OK_DGVM
    !Config Def   = 0.01
    !Config Help  = 
    !Config Units = [-]  
    CALL getin_p('MIN_AVAIL',min_avail)
    !
    !Config Key   = RIP_TIME_MIN
    !Config Desc  = 
    !Config If    = OK_DGVM
    !Config Def   = 1.25 
    !Config Help  = 
    !Config Units = [year]  
    CALL getin_p('RIP_TIME_MIN',RIP_time_min)
    !
    !Config Key   = NPP_LONGTERM_INIT
    !Config Desc  = 
    !Config If    = OK_DGVM
    !Config Def   = 10.
    !Config Help  = 
    !Config Units = [gC/m^2/year]
    CALL getin_p('NPP_LONGTERM_INIT',npp_longterm_init)
    !
    !Config Key   = EVERYWHERE_INIT
    !Config Desc  = 
    !Config If    = OK_DGVM
    !Config Def   = 0.05 
    !Config Help  = 
    !Config Units = [-] 
    CALL getin_p('EVERYWHERE_INIT',everywhere_init)

  END SUBROUTINE config_dgvm_parameters

END MODULE constantes
