Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/AA_make
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/AA_make	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/AA_make	(revision 405)
@@ -0,0 +1,152 @@
+#-
+#- $Id$
+#-
+MODS1 = dim2_driver.f90 \
+        weather.f90 \
+        readdim2.f90 \
+        teststomate.f90 \
+        forcesoil.f90 \
+        getprec.f90
+
+orchidee_ol:
+	$(M_K) all_libs
+	$(M_K) m_orchidee_ol
+	@echo orchidee_ol is OK
+
+m_orchidee_ol: $(BINDIR)/orchidee_ol
+#-Q- intel m_orchidee_ol: WORK_MOD $(BINDIR)/orchidee_ol
+$(BINDIR)/orchidee_ol: \
+  $(SXIOIPSL_LIB) $(SXPARAM_LIB) $(SXPARALLEL_LIB) $(SXORGLOB_LIB) $(SXSTOMATE_LIB) $(SXSECHIBA_LIB) \
+  $(MODEL_LIB)(weather.o) $(MODEL_LIB)(readdim2.o) \
+  $(MODEL_LIB)(dim2_driver.o)
+	$(A_G) $(MODEL_LIB) dim2_driver.o
+	$(F_L) -o $(BINDIR)/orchidee_ol dim2_driver.o $(L_O) \
+          $(SXMODEL_LIB) $(SXSECHIBA_LIB) $(SXSTOMATE_LIB) \
+          $(SXPARALLEL_LIB) $(SXORGLOB_LIB) $(SXPARAM_LIB) $(SXIOIPSL_LIB) $(NCDF_LIB) 
+	$(RM) dim2_driver.o
+
+teststomate:
+	$(M_K) all_libs
+	$(M_K) m_teststomate
+	@echo teststomate is OK
+
+m_teststomate: $(BINDIR)/teststomate
+$(BINDIR)/teststomate: \
+  $(SXIOIPSL_LIB) $(SXPARALLEL_LIB) $(SXPARAM_LIB) $(SXORGLOB_LIB) $(SXSTOMATE_LIB) $(SXSECHIBA_LIB) \
+  $(MODEL_LIB)(teststomate.o)
+	$(A_G) $(MODEL_LIB) teststomate.o
+	$(F_L) -o $(BINDIR)/teststomate teststomate.o $(L_O) \
+          $(SXMODEL_LIB) $(SXSECHIBA_LIB) $(SXSTOMATE_LIB) \
+          $(SXPARALLEL_LIB) $(SXORGLOB_LIB) $(SXPARAM_LIB) $(SXIOIPSL_LIB) $(NCDF_LIB)
+	$(RM) teststomate.o
+
+forcesoil:
+	$(M_K) all_libs
+	$(M_K) m_forcesoil
+	@echo m_forcesoil is OK
+
+m_forcesoil: $(BINDIR)/forcesoil
+$(BINDIR)/forcesoil: \
+  $(SXIOIPSL_LIB) $(SXPARALLEL_LIB) $(SXPARAM_LIB) $(SXORGLOB_LIB) $(SXSTOMATE_LIB) $(SXSECHIBA_LIB) \
+  $(MODEL_LIB)(forcesoil.o)
+	$(A_G) $(MODEL_LIB) forcesoil.o
+	$(F_L) -o $(BINDIR)/forcesoil forcesoil.o $(L_O) \
+          $(SXMODEL_LIB) $(SXSECHIBA_LIB) $(SXSTOMATE_LIB) \
+          $(SXPARALLEL_LIB) $(SXORGLOB_LIB) $(SXPARAM_LIB) $(SXIOIPSL_LIB) $(NCDF_LIB)
+	$(RM) forcesoil.o
+#-Q- intel
+#-Q- intel WORK_MOD:
+#-Q- intel 	$(RM) work.pcl
+#-Q- intel 	@echo "work.pc" > work.pcl
+#-Q- intel 	@echo "../ORCHIDEE/src_parameters/work.pc" >> work.pcl
+#-Q- intel 	@echo "../ORCHIDEE/src_global/work.pc" >> work.pcl
+#-Q- intel 	@echo "../ORCHIDEE/src_stomate/work.pc" >> work.pcl
+#-Q- intel 	@echo "../ORCHIDEE/src_sechiba/work.pc" >> work.pcl
+#-Q- intel 	@echo "../IOIPSL/src/work.pc" >> work.pcl
+
+config:
+	$(M_K) libioipsl
+	$(M_K) m_config
+
+m_config: $(SXIOIPSL_LIB)
+	(cd ../IOIPSL/src; $(M_K) -f Makefile config)
+	(cd ../ORCHIDEE/src_parameters; $(M_K) -f Makefile config)
+	(cd ../ORCHIDEE/src_parallel; $(M_K) -f Makefile config)
+	(cd ../ORCHIDEE/src_global; $(M_K) -f Makefile config)
+	(cd ../ORCHIDEE/src_sechiba; $(M_K) -f Makefile config)
+	(cd ../ORCHIDEE/src_stomate; $(M_K) -f Makefile config)
+	$(BINDIR)/Fparser -main -name ORCHIDEE_OL $(MODS1)
+	$(SCPDIR)/build_tkmenus
+	./config.tk
+	$(RM) Config.*
+
+checkprec:
+	$(M_K) libparameters
+	$(M_K) m_checkprec
+
+m_checkprec: $(BINDIR)/checkprec
+$(BINDIR)/checkprec:  \
+  $(SXPARAM_LIB) $(MODEL_LIB)(getprec.o)
+	$(A_G) $(MODEL_LIB) getprec.o
+	$(F_L) -o $(BINDIR)/checkprec getprec.o $(L_O) \
+          $(SXMODEL_LIB) $(PARAMETERS_LIB)
+	$(BINDIR)/checkprec
+	$(RM) getprec.o
+
+all_libs:
+	$(M_K) libioipsl
+	$(M_K) libparallel
+	$(M_K) libparameters
+	$(M_K) liborglob
+	$(M_K) libstomate
+	$(M_K) libsechiba
+
+libioipsl:
+	(cd ../IOIPSL/src; $(M_K) -f Makefile)
+
+libparameters:
+	(cd ../ORCHIDEE/src_parameters; $(M_K) -f Makefile)
+
+libparallel:
+	(cd ../ORCHIDEE/src_parallel; $(M_K) -f Makefile)
+
+liborglob:
+	(cd ../ORCHIDEE/src_global; $(M_K) -f Makefile)
+
+libstomate:
+	(cd ../ORCHIDEE/src_stomate; $(M_K) -f Makefile)
+
+libsechiba:
+	(cd ../ORCHIDEE/src_sechiba; $(M_K) -f Makefile)
+
+clean:
+	(cd ../IOIPSL/src; $(M_K) -f Makefile clean)
+	(cd ../ORCHIDEE/src_parameters; $(M_K) -f Makefile clean)
+	(cd ../ORCHIDEE/src_parallel; $(M_K) -f Makefile clean)
+	(cd ../ORCHIDEE/src_global; $(M_K) -f Makefile clean)
+	(cd ../ORCHIDEE/src_sechiba; $(M_K) -f Makefile clean)
+	(cd ../ORCHIDEE/src_stomate; $(M_K) -f Makefile clean)
+	$(RM) *.o core $(MODEL_LIB)
+
+cleanORC:
+	(cd ../ORCHIDEE/src_parameters; $(M_K) -f Makefile clean)
+	(cd ../ORCHIDEE/src_parallel; $(M_K) -f Makefile clean)
+	(cd ../ORCHIDEE/src_global; $(M_K) -f Makefile clean)
+	(cd ../ORCHIDEE/src_sechiba; $(M_K) -f Makefile clean)
+	(cd ../ORCHIDEE/src_stomate; $(M_K) -f Makefile clean)
+	$(RM) $(MODEL_LIB)
+
+$(MODEL_LIB)(%.o): %.f90
+	$(F_C) $(F_O) -I$(NCDF_INC) $*.f90
+	$(A_C) $(MODEL_LIB) $*.o
+#-Q- sxnec 	$(A_X) $(SXMODEL_LIB) $*.o
+#-Q- sxnec 	-mv $*.mod $(MODDIR)
+#-Q- sx6nec 	$(A_X) $(SXMODEL_LIB) $*.o
+#-Q- sx6nec 	-mv $*.mod $(MODDIR)
+#-Q- sx8mercure	-mv $*.mod $(MODDIR)
+#-Q- sx9mercure	-mv $*.mod $(MODDIR)
+#-Q- sx8brodie 	$(A_X) $(SXMODEL_LIB) $*.o
+#-Q- sx8brodie 	-mv $*.mod $(MODDIR)
+#-Q- solaris 	-mv $*.mod $(MODDIR)
+	$(RM) $*.o
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/AA_make.ldef
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/AA_make.ldef	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/AA_make.ldef	(revision 405)
@@ -0,0 +1,49 @@
+#-
+#- $Id$
+#-
+SHELL = /bin/sh
+#---------------------------------------------------------------------
+LIBDIR = ../../lib
+MODDIR = $(LIBDIR)
+BINDIR = ../../bin
+SCPDIR = ../../scripts
+ORDIR  = ../ORCHIDEE
+#---------------------------------------------------------------------
+MODEL_LIB = $(LIBDIR)/liborchidee.a
+SXMODEL_LIB = $(MODEL_LIB)
+#-Q- sxnec SXMODEL_LIB = $(LIBDIR)/libsxorchidee.a
+#-Q- sx6nec SXMODEL_LIB = $(LIBDIR)/libsxorchidee.a
+#-Q- sx8brodie SXMODEL_LIB = $(LIBDIR)/libsxorchidee.a
+#-
+IOIPSL_LIB = $(LIBDIR)/libioipsl.a
+SXIOIPSL_LIB = $(IOIPSL_LIB)
+#-
+PARAM_LIB = $(LIBDIR)/libparameters.a
+SXPARAM_LIB = $(PARAM_LIB)
+#-Q- sxnec SXPARAM_LIB = $(LIBDIR)/libsxparameters.a
+#-Q- sx6nec SXPARAM_LIB = $(LIBDIR)/libsxparameters.a
+#-Q- sx8brodie SXPARAM_LIB = $(LIBDIR)/libsxparameters.a
+#-
+PARALLEL_LIB = $(LIBDIR)/libparallel.a
+SXPARALLEL_LIB = $(PARALLEL_LIB)
+#-Q- sxnec SXPARALLEL_LIB = $(LIBDIR)/libsxparallel.a
+#-Q- sx6nec SXPARALLEL_LIB = $(LIBDIR)/libsxparallel.a
+#-Q- sx8brodie SXPARALLEL_LIB = $(LIBDIR)/libsxparallel.a
+#-
+ORGLOB_LIB = $(LIBDIR)/liborglob.a
+SXORGLOB_LIB = $(ORGLOB_LIB)
+#-Q- sxnec  SXORGLOB_LIB = $(LIBDIR)/libsxorglob.a
+#-Q- sx6nec SXORGLOB_LIB = $(LIBDIR)/libsxorglob.a
+#-Q- sx8brodie SXORGLOB_LIB = $(LIBDIR)/libsxorglob.a
+#-
+SECHIBA_LIB = $(LIBDIR)/libsechiba.a
+SXSECHIBA_LIB = $(SECHIBA_LIB)
+#-Q- sxnec SXSECHIBA_LIB = $(LIBDIR)/libsxsechiba.a
+#-Q- sx6nec SXSECHIBA_LIB = $(LIBDIR)/libsxsechiba.a
+#-Q- sx8brodie SXSECHIBA_LIB = $(LIBDIR)/libsxsechiba.a
+#-
+STOMATE_LIB = $(LIBDIR)/libstomate.a
+SXSTOMATE_LIB = $(STOMATE_LIB)
+#-Q- sxnec SXSTOMATE_LIB = $(LIBDIR)/libsxstomate.a
+#-Q- sx6nec SXSTOMATE_LIB = $(LIBDIR)/libsxstomate.a
+#-Q- sx8brodie SXSTOMATE_LIB = $(LIBDIR)/libsxstomate.a
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/Job_ENSEMBLE
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/Job_ENSEMBLE	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/Job_ENSEMBLE	(revision 405)
@@ -0,0 +1,360 @@
+#!/bin/ksh
+
+# $Date: 2010/06/25 19:03:52 $
+# $Author: ssipsl $
+# $Revision: 1.13 $
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
+
+#D--------------------------------------------------------------------==
+#D--------------------------------------------------------------------==
+#D-
+#D-                      Job to launch ENSEMBLE spinup simulations
+#D-
+#D--------------------------------------------------------------------==
+#D--------------------------------------------------------------------==
+#D-
+#                       Job inspired from Sönke Zaehle "site_new.def" job
+#                       #################################################
+
+
+
+MODIPSL=/work/cont003/p86manci/TEST_LIB_trunk_04-03-11
+libIGCM=${MODIPSL}/libIGCM
+
+# All SubJobs in SPINUP in ONE OR MORE YEARS run (must be used with libIGCM branches/AllPostFred). 
+
+
+
+#D--------------------------------------------------------------------==
+#D-                   -1. User modification place
+#D--------------------------------------------------------------------==
+
+#D- Increased verbosity (1, 2, 3)
+#Verbosity=3
+
+#D-
+# --------------------------------------------------------------------
+#D- ! Optionnal features /!\ Use with care !
+# --------------------------------------------------------------------
+
+#D- Low level debug : to bypass lib test checks and stack construction
+#D- Default=true
+DEBUG_debug=false
+
+#D- Set DEBUG_sys to false to disable output calls of function
+#D- Default=true
+#DEBUG_sys=false
+
+#D- Turn in dry run mode ? (0,1,2,3)
+#D- Default=0
+#DRYRUN=3
+# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
+# -------------------------------------------------------------------------------------
+# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+# |          |  Cp/Exe param files |            |  Chmod  |                           |
+# |          |      Qsub           |            |         |                           |
+# -------------------------------------------------------------------------------------
+# |    0     |       yes           |    yes     |  yes    |      yes                  |
+# -------------------------------------------------------------------------------------
+# |    1     |       yes           |    yes     |  yes    |      no                   |
+# -------------------------------------------------------------------------------------
+# |    2     |       yes           |    yes     |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+# |    3     |       yes           |    no      |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+
+
+#D-
+#D--------------------------------------------------------------------==
+#D-                   0. System Environment 
+#D-                      - Define variables for Number of processors
+#D-                      - Define MPI variables
+#D-                      - Define batch scheduler variables
+#D-                      - Source IGCM Library
+#D-                      - Get RESOLution in .resol file (temporary)
+#D--------------------------------------------------------------------==
+
+#D--------------------------------------------------------------------==
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+        ( ${DEBUG_debug} ) && IGCM_debug_Check
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+       ( ${DEBUG_debug} ) && IGCM_card_Check
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+       ( ${DEBUG_debug} ) && IGCM_date_Check
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+
+
+R_BC=${R_IN}/BC
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+
+. ${SUBMIT_DIR}/ensemble.ksh
+
+ENSEMBLE_initialize
+
+function correct_duree
+{
+    # Ths function compute the nearest multiple of dyear near duree
+    typeset duree dyear
+    duree=$1
+    dyear=$2
+    if [ $(( duree % dyear )) -gt 0 ] ; then
+	echo $(( ( duree / dyear + 1 ) * dyear ))
+    else
+	echo ${duree}
+    fi
+}
+
+# Path for all skeleton SubJob scripts to SPINUP directory
+Skeleton_Path=$( cd ../; pwd )
+
+isite=1
+index=0
+echo ${isite} ${NumSites}
+while [ ${isite} -le ${NumSites} ] ; do
+    
+    site=${ensemble_CONFIG_Sites[$index]}
+    echo "   ------------------------"
+    echo "   SPINUP for Site : ${site}"
+
+    DATE0_YEAR=${ensemble_CONFIG_Sites[ $(( index + ColumnYear )) ]}
+    TIME_YEAR=${ensemble_CONFIG_Sites[ $(( index + ColumnLength )) ]}
+
+#######################################################
+# Script internal settings
+# nothing to be modified below this line
+######################################################ä
+
+# Copy the SPINUP directory
+    SubJobName=${site}${config_UserChoices_JobName}
+    New_SUBMIT_DIR=${SUBMIT_DIR}/${SubJobName}
+    IGCM_sys_Cp -Rp ../SPINUP ${New_SUBMIT_DIR}
+#     ls -la ${New_SUBMIT_DIR}
+#     cat ${New_SUBMIT_DIR}/config.card
+#     echo "---"
+
+    # Install this directory
+    # modifications on config.card
+    MyJobName=${config_UserChoices_JobName}
+    IGCM_card_DefineVariableFromOption ${New_SUBMIT_DIR}/config.card UserChoices JobName
+    OldJobName=${config_UserChoices_JobName}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobName ${SubJobName}
+    config_UserChoices_JobName=${MyJobName}
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices TagName
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices TagName ${config_UserChoices_TagName}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices CalendarType ${config_UserChoices_CalendarType}
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobClass ${config_UserChoices_JobClass}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot}
+    sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card
+    IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card 
+
+    # Give path for all skeleton SubJob scripts to SPINUP directory
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices SubJobPath ${Skeleton_Path}
+
+    # All SubJobs in SPINUP in one or more years (must be used with libIGCM branches/AllPostFred). 
+    # It is the length of the forcing file.
+    if [ X"${config_UserChoices_CalendarType}" = X"360d" ] ; then
+    	This_Job_DateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))1230
+    	This_Job_HumanDateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))-12-30
+    else
+    	This_Job_DateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))1231
+    	This_Job_HumanDateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))-12-31
+    fi
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateBegin ${DATE0_YEAR}-01-01
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodLength ${TIME_YEAR}Y
+
+    # DateEnd is defined by SpinUp job itself (it will be modified in config.card).
+    # but to get all SpinUp Job loops, we have to add at least a number of years greater
+    # than those that will be modified in config.card. Default is 150.00.00 years more for SpinUp.
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateEnd $(( DATE0_YEAR + 150 ))-01-01
+
+    # Infinit SPINUP Job :
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodNb 99999
+
+    # SRF section : first restart and post-treatments 
+    typeset option
+    for option in ${config_SRF[*]} ; do
+	eval value=\${config_SRF_${option}}
+	eval echo ${option} ${value}
+	if [ X${value} != X ] ; then
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF ${option} \${config_SRF_${option}}
+	fi
+    done
+    if [ X"${ensemble_UserChoices_ok_stomate}" = "Xy" ] ; then
+	for option in ${config_SBG[*]} ; do
+	    eval value=\${config_SBG_${option}}
+	    eval echo ${option} ${value}
+	    if [ X${value} != X ] ; then
+		eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG ${option} \${config_SBG_${option}}
+	    fi
+	done
+    fi
+
+    # modifications on spinup.card 
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobForcingFile List "(${ensemble_CONFIG_ForcingPath}/${ensemble_CONFIG_Sites[$(( index + ColumnFilename ))]}, forcing_file.nc)"
+
+    typeset option
+    for option in ${ensemble_UserChoices[*]} ; do
+	eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices ${option} \${ensemble_UserChoices_${option}}
+    done
+
+    # Max levels for ENSEMBLE
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices sechiba_LEVEL 10
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices stomate_LEVEL 10
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices DRIVER_NORESTART y
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices DRIVER_TIMELENGTH n
+
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_nostomate $( correct_duree ${ensemble_SPINUP_duree_nostomate} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_inistomate $( correct_duree ${ensemble_SPINUP_duree_inistomate} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_offlineini $( correct_duree ${ensemble_SPINUP_duree_offlineini} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices n_iter ${ensemble_SPINUP_n_iter}
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_sechiba $( correct_duree ${ensemble_SPINUP_duree_sechiba} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_stomate $( correct_duree ${ensemble_SPINUP_duree_stomate} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_carbonsol $( correct_duree ${ensemble_SPINUP_duree_carbonsol} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_final $( correct_duree ${ensemble_SPINUP_duree_final} ${TIME_YEAR} )
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices BoundaryFilesListNonDel y
+
+    # TimeSeries : ALMAOUTPUT for SECHIBA
+    typeset option
+    for option in ${config_SubJobPost[*]} ; do
+	eval value=\${config_SubJobPost_${option}}
+	eval echo ${option} ${value}
+	if [ X${value} != X ] ; then
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SubJobPost ${option} \${config_SubJobPost_${option}}
+	fi
+    done
+
+    # modifications on Job script
+    rm ${New_SUBMIT_DIR}/Job_${OldJobName}
+    IGCM_sys_Cp ${SUBMIT_DIR}/Job_${MyJobName} ${New_SUBMIT_DIR}/Job_${SubJobName}
+
+    sed -e "s/ ${MyJobName}/ ${SubJobName}/" \
+	-e "s/Script_Output_${MyJobName}/Script_Output_${SubJobName}/" \
+	${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_
+    IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName}
+    chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName}
+
+
+    # modification on parameter files
+    IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/sechiba.def ${New_SUBMIT_DIR}/PARAM/sechiba.def
+    IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/stomate.def ${New_SUBMIT_DIR}/PARAM/stomate.def
+    IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/driver.def ${New_SUBMIT_DIR}/PARAM/driver.def
+
+    eval first_option=${ensemble_SubJobParams[0]} > /dev/null 2>&1
+    if [ X${first_option} != X"Error:" ] ; then
+	IGCM_card_DefineArrayFromSection ${New_SUBMIT_DIR}/COMP/spinup.card SubJobParams
+	eval first_option=${spinup_SubJobParams[0]} > /dev/null 2>&1
+	    
+	typeset option option_ PARAM_FILE
+	for option in ${ensemble_SubJobParams[*]} ; do
+	    PARAM_FILE=$( echo ${option} | awk -F_ '{print $1}' )
+	    echo "For parameter file ${PARAM_FILE}.def"
+	    option_=$( echo ${option} | sed -e "s/${PARAM_FILE}_//" )
+	    eval echo "${option_}="\${ensemble_SubJobParams_${option}}
+	    case ${PARAM_FILE} in
+		sechiba)
+		    eval SECHIBA_sed ${option_} \${ensemble_SubJobParams_${option}}
+		    ;;
+		stomate)
+		    eval STOMATE_sed ${option_} \${ensemble_SubJobParams_${option}}
+		    ;;
+		driver)
+		    eval DRIVER_sed ${option_} \${ensemble_SubJobParams_${option}}
+		    ;;
+	    esac
+
+	    if [ X${first_option} != X"Error:" ] ; then
+		for option_ in ${spinup_SubJobParams[*]} ; do
+		    if [ X${option} == X${option_} ] ; then
+			eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobParams ${option} \${ensemble_SubJobParams_${option}}
+		    fi
+		done
+	    fi
+	done
+    fi
+
+    (( iphys = 0 ))
+    (( indext = index + 4 ))
+    while [ $iphys -lt ${ensemble_CONFIG_NbSitesParam} ] ; do
+	
+	# Detect if physical parameter has 
+        #  array description or line per PFT description in the parameter file
+	SearchParam=""
+	${ensemble_CONFIG_CompSitesParam[${iphys}]}_grep ${ensemble_CONFIG_NameSitesParam[${iphys}]}
+
+	case ${SearchParam} in
+	    undefined)
+		echo "ERROR : parameter ${ensemble_CONFIG_NameSitesParam[${iphys}]} doen't exist in ${ensemble_CONFIG_CompSitesParam[${iphys}]} parameter file !"
+		echo "You must correct NameSiteParam option in ensemble.card file or add new parameter in component.def file"
+		echo "We must STOP here."
+		exit 1
+		;;
+	    value)
+		${ensemble_CONFIG_CompSitesParam[${iphys}]}_sed ${ensemble_CONFIG_NameSitesParam[${iphys}]} ${ensemble_CONFIG_Sites[$(( indext )) ]}
+		(( indext = indext + 1 ))
+		;;
+	    line)
+		ipft=1
+		while [ $ipft -le ${NbPFTs} ] ; do
+		    if [ $ipft -lt 10 ] ; then
+			numpft=0${ipft}
+		    else
+			numpft=${ipft}
+		    fi
+	    
+		    ${ensemble_CONFIG_CompSitesParam[${iphys}]}_sed ${ensemble_CONFIG_NameSitesParam[${iphys}]}__${numpft} ${ensemble_CONFIG_Sites[$(( indext )) ]}
+		    (( indext = indext + 1 ))
+		    (( ipft = ipft + 1 ))
+		done
+		;;
+	    vector)
+		unset ValueSiteParams
+		ipft=0
+		while [ $ipft -lt ${NbPFTs} ] ; do
+		    ValueSiteParams[${ipft}]=${ensemble_CONFIG_Sites[$(( indext )) ]}
+		    (( indext = indext + 1 ))
+		    (( ipft = ipft + 1 ))
+		done
+		${ensemble_CONFIG_CompSitesParam[${iphys}]}_sed ${ensemble_CONFIG_NameSitesParam[${iphys}]} "${ValueSiteParams[*]}"
+		;;
+	esac
+
+	(( iphys = iphys + 1 ))
+    done
+
+    IGCM_debug_Verif_Exit
+
+# Lauch the SPINUP Job :
+
+    echo "#!/bin/ksh" > ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "MODIPSL=${MODIPSL}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "libIGCM=${libIGCM}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "cd ${New_SUBMIT_DIR}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "export SUBMIT_DIR=${New_SUBMIT_DIR}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo ". ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo ". ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "export Script_Output=Script_Output_${SubJobName}.000001" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "export config_UserChoices_JobName=${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "export CumulPeriod=1" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+#    echo "nohup Job_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "IGCM_sys_Qsub Job_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+
+    if [ ${DRYRUN} -le 1 ] ; then
+	chmod u+x ${RUN_DIR_PATH}/SubJob${site}.ksh
+	nohup ${RUN_DIR_PATH}/SubJob${site}.ksh 
+    fi
+
+    IGCM_debug_Verif_Exit
+
+    (( isite=isite+1 ))
+    (( index=index+NumInfosBySite ))
+done
+
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/PARAM/driver.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/PARAM/driver.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/PARAM/driver.def	(revision 405)
@@ -0,0 +1,298 @@
+#
+#**************************************************************************
+#                    Namelist for ORCHIDEE_OL
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of DRIVER
+#**************************************************************************
+
+# Flag for debug information
+# This option allows to switch on the output of debug
+#         information without recompiling the code.
+DEBUG_INFO = n
+#default = n
+
+
+#---------------------------------------------------------------------
+# Forcing file name
+# Name of file containing the forcing data
+# This is the name of the file which should be opened
+# for reading the forcing data of the dim0 model.
+# The format of the file has to be netCDF and COADS
+# compliant. Cabauw.nc, islscp_for.nc, WG_cru.nc
+FORCING_FILE = forcing_file.nc
+# default = islscp_for.nc
+
+# split time step :
+#---------------------------------------------------------------------
+
+# Splits the timestep imposed by the forcing
+# With this value the time step of the forcing
+#  will be devided. In principle this can be run
+#  in explicit mode but it is strongly suggested
+#  to use the implicit method so that the
+#  atmospheric forcing has a smooth evolution.
+SPLIT_DT = 12
+# default = 12
+
+#  Time in the forcing file at which the model is started.
+#  This time give the point in time at which the model
+#  should be started. 
+#  If exists, the date of the restart file is use.
+#  The FORMAT of this date can be either of the following :
+#  n   : time step n within the forcing file
+#  nS  : n seconds after the first time-step in the file
+#  nD  : n days after the first time-step
+#  nM  : n month after the first time-step (year of 365 days)
+#  nY  : n years after the first time-step (year of 365 days)
+#      Or combinations :
+#  nYmM: n years and m month
+TIME_SKIP = 0
+# default = 0
+
+# Spread the precipitation.
+# Spread the precipitaiton over n steps of the splited forcing time step. 
+#  This is ONLY applied if the forcing time step has been splited (SPLIT_DT).
+#  If the value indicated is greater than SPLIT_DT, SPLIT_DT is used for it.
+SPRED_PREC = 1
+# default = 1
+
+
+
+
+
+# Input and output restart file for the driver
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by the driver
+# This variable give the  name for
+#  the restart file. The restart software within
+#  IOIPSL will add .nc if needed
+RESTART_FILEOUT = driver_rest_out.nc
+# default = driver_rest_out.nc
+
+
+#**************************************************************************
+#                             Area location
+#**************************************************************************
+#  The model will use the smalest regions from
+#  region specified here and the one of the forcing file.
+
+# Western limit of region
+# Western limit of the region we are 
+#  interested in. Between -180 and +180 degrees
+LIMIT_WEST = -180.
+# default = -180.
+
+# Eastern limit of region
+# Eastern limit of the region we are
+#  interested in. Between -180 and +180 degrees
+LIMIT_EAST = 180.
+# default = 180.
+
+# Northern limit of region
+# Northern limit of the region we are
+#  interested in. Between +90 and -90 degrees
+LIMIT_NORTH = 90.
+# default = 90.
+
+# Southern limit of region
+# Southern limit of the region we are
+#  interested in. Between 90 and -90 degrees
+LIMIT_SOUTH = -90.
+# default = -90.
+
+##**************************************************************************
+#                       Simulation parameters
+#**************************************************************************
+
+# method of forcing
+# A method is proposed by which the first atmospheric
+#   level is not directly forced by observations but
+#   relaxed with a time constant towards observations.
+#   For the moment the methods tends to smooth too much
+#   the diurnal cycle and introduces a time shift.
+#   A more sophisticated method is needed.
+RELAXATION = n
+# default = n
+
+# Time constant of the relaxation layer RELAXATION
+# The time constant associated to the atmospheric
+#  conditions which are going to be computed
+#  in the relaxed layer. To avoid too much
+#  damping the value should be larger than 1000.
+RELAX_A = 1000.
+# default = 1000.0
+
+# Height at which T and Q are given
+# The atmospheric variables (temperature and specific
+#  humidity) are measured at a specific level.
+#  The height of this level is needed to compute
+#  correctly the turbulent transfer coefficients.
+#  Look at the description of the forcing
+#  DATA for the correct value.
+HEIGHT_LEV1 = 2.0
+# default  = 2.0
+
+# Height at which the wind is given
+# The height at which wind is needed to compute
+#  correctly the turbulent transfer coefficients.
+HEIGHT_LEVW = 10.0
+# default  = 10.0
+
+#---------------------------------------------------------------------
+# Weather generator or not :
+#---------------------------------------------------------------------
+
+# Allow weather generator to create data.
+# This flag allows the forcing-reader to generate
+#  synthetic data if the data in the file is too sparse
+#  and the temporal resolution would not be enough to
+#  run the model.
+ALLOW_WEATHERGEN = n
+# default = n
+
+# North-South Resolution
+# If ALLOW_WEATHERGEN
+# North-South Resolution of the region we are
+#  interested in. In degrees
+MERID_RES = 2.
+# default = 2.
+
+# East-West Resolution
+# If ALLOW_WEATHERGEN
+# East-West Resolution of the region we are
+#  interested in. In degrees
+ZONAL_RES = 2.
+# default = 2.
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+# If this is set to 1, the weather generator
+#   uses the monthly mean values for daily means.
+#   If it is set to 0, the weather generator
+#   uses statistical relationships to derive daily
+#   values from monthly means.
+IPPREC = 0
+# default = 0
+
+# Interpolation  or not IF split is larger than 1
+# Choose IF you wish to interpolate linearly or not.
+NO_INTER = y
+INTER_LIN = n
+# default :
+#  NO_INTER = y
+#  INTER_LIN = n
+
+# Exact monthly precipitation
+# If ALLOW_WEATHERGEN
+# If this is set to y, the weather generator
+#   will generate pseudo-random precipitations
+#   whose monthly mean is exactly the prescribed one.
+#   In this case, the daily precipitation (for rainy
+#   days) is constant (that is, some days have 0 precip,
+#   the other days have precip = Precip_month/n_precip,
+#   where n_precip is the prescribed number of rainy days
+#   per month).
+WEATHGEN_PRECIP_EXACT = n
+# default = n
+
+# Calling frequency of weather generator (s)
+# Determines how often the weather generator
+#  is called (time step in s). Should be equal
+#  to or larger than Sechiba's time step (say,
+#  up to 6 times Sechiba's time step or so).
+DT_WEATHGEN = 1800.
+# default = 1800.
+
+# Conserve net radiation in the forcing
+# When the interpolation is used the net radiation
+#  provided by the forcing is not conserved anymore.
+#  This should be avoided and thus this option should
+#  be TRUE (y).
+#  This option is not used for short-wave if the
+#  time-step of the forcing is longer than an hour.
+#  It does not make sense to try and reconstruct
+#  a diurnal cycle and at the same time conserve the 
+#  incoming solar radiation.
+NETRAD_CONS = y
+# default = y
+
+# Write weather from generator into a forcing file
+# This flag makes the weather generator dump its
+#  generated weather into a forcing file which can
+#  then be used to get the same forcing on different
+#  machines. This only works correctly if there is
+#  a restart file (otherwise the forcing at the first
+#  time step is slightly wrong).
+DUMP_WEATHER = n
+# default = n
+
+# Name of the file that contains
+#  the weather from generator
+# If DUMP_WEATHER
+DUMP_WEATHER_FILE = weather_dump.nc
+# default = 'weather_dump.nc'
+
+# Dump weather data on gathered grid
+# If 'y', the weather data are gathered
+#  for all land points.
+# If DUMP_WEATHER
+DUMP_WEATHER_GATHERED = y
+# default = y
+
+
+# Read Orbital Parameters
+
+# Eccentricity Effect
+# Use prescribed values
+# IF ALLOW_WEATHERGEN
+ECCENTRICITY = 0.016724
+# default = 0.016724
+
+# Longitude of perihelie
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+PERIHELIE = 102.04
+# default = 102.04
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+OBLIQUITY = 23.446
+# default = 23.446
+
+#**************************************************************************
+# length of simulation :
+#---------------------------------------------------------------------
+# Length of the integration in time.
+# Length of integration. By default the entire length
+#        of the forcing is used. The FORMAT of this date can
+#        be either of the following :
+# n   : time step n within the forcing file
+# nS  : n seconds after the first time-step in the file
+# nD  : n days after the first time-step
+# nM  : n month after the first time-step (year of 365 days)
+# nY  : n years after the first time-step (year of 365 days)
+#        Or combinations :
+# nYmM: n years and m month
+TIME_LENGTH = default
+# default = depend on the time length and the number of time step in forcing file
+#         = itau_len = itau_fin-itau_dep
+
+
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/PARAM/sechiba.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/PARAM/sechiba.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/PARAM/sechiba.def	(revision 405)
@@ -0,0 +1,817 @@
+#
+#**************************************************************************
+#                    Namelist for SECHIBA
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of SECHIBA
+#**************************************************************************
+
+# ORCHIDEE will print more messages
+# This flag permits to print more debug messages in the run.
+LONGPRINT = n
+#default = n
+
+#---------------------------------------------------------------------
+
+# Should the output follow the ALMA convention
+# If this logical flag is set to true the model
+#  will output all its data according to the ALMA 
+#  convention. It is the recommended way to write
+#  data out of ORCHIDEE.
+ALMA_OUTPUT = n
+# default = n
+
+# To reset the time coming from SECHIBA restart file
+# This option allows the model to override the time
+#  found in the restart file of SECHIBA with the time
+#  of the first call. That is the restart time of the GCM.
+SECHIBA_reset_time = n
+# default = n
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+# Name of file from which the vegetation map is to be read
+# If !IMPOSE_VEG
+# If LAND_USE 
+#   default = pft_new.nc
+#   The name of the file to be opened to read a vegetation
+#   map (in pft) is to be given here. 
+# If !LAND_USE
+#   default = ../surfmap/carteveg5km.nc
+#   The name of the file to be opened to read the vegetation
+#   map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#   map which is derived from the IGBP one. We assume that we have
+#   a classification in 87 types. This is Olson modified by Viovy.
+VEGETATION_FILE = PFTmap.nc
+
+
+# Name of file from which the bare soil albedo
+# If !IMPOSE_AZE
+# The name of the file to be opened to read the soil types from 
+#  which we derive then the bare soil albedos. This file is 1x1 
+#  deg and based on the soil colors defined by Wilson and Henderson-Seller.
+SOILALB_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Name of file from which soil types are read
+# If !IMPOSE_VEG
+# The name of the file to be opened to read the soil types. 
+#  The data from this file is then interpolated to the grid of
+#  of the model. The aim is to get fractions for sand loam and
+#  clay in each grid box. This information is used for soil hydrology
+#  and respiration.
+SOILTYPE_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Input and output restart file for SECHIBA :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+SECHIBA_restart_in = NONE
+# default = NONE
+
+# Name of restart files to be created by SECHIBA
+# This variable give the name for the restart files. 
+#  The restart software within IOIPSL will add .nc if needed.
+SECHIBA_rest_out = sechiba_rest_out.nc
+# default = sechiba_rest_out.nc
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+
+# ORCHIDEE will write out its forcing to a file
+# This flag allows to write to a file all the variables
+#  which are used to force the land-surface. The file 
+#  has exactly the same format than a normal off-line forcing
+#  and thus this forcing can be used for forcing ORCHIDEE.
+ORCHIDEE_WATCHOUT = n
+# default = n
+
+# Filenane for the ORCHIDEE forcing file
+# If ORCHIDEE_WATCHOUT
+# This is the name of the file in which the
+#  forcing used here will be written for later use. 
+WATCHOUT_FILE = orchidee_watchout.nc
+# default = orchidee_watchout.nc
+
+# ORCHIDEE will write out with this frequency
+# If ORCHIDEE_WATCHOUT
+# This flag indicates the frequency of the write of the variables. 
+DT_WATCHOUT = 1800
+# default = dt
+
+# Output file name :
+#---------------------------------------------------------------------
+# Name of file in which the output is going
+# This file is going to be created by the model
+#  to be written
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+OUTPUT_FILE = sechiba_history.nc
+# default = cabauw_out.nc
+
+# Flag to switch on histfile 2 for SECHIBA (hi-frequency ?)
+# This Flag switch on the second SECHIBA writing for hi (or low) 
+#  frequency writing. This second output is optional and not written
+#  by default.
+SECHIBA_HISTFILE2 = FALSE
+# default  = FALSE
+
+# Name of file in which the output number 2 is going
+#   to be written
+# If SECHIBA_HISTFILE2
+# This file is going to be created by the model
+#   and will contain the output 2 from the model.
+SECHIBA_OUTPUT_FILE2 = sechiba_out_2.nc
+# default  = sechiba_out_2.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# SECHIBA history output level (0..10)
+# Chooses the list of variables in the history file. 
+#  Values between 0: nothing is written; 10: everything is 
+#  written are available More details can be found on the web under documentation.
+#  web under documentation.
+SECHIBA_HISTLEVEL = 5
+# default = 5
+
+# SECHIBA history 2 output level (0..10)
+# If SECHIBA_HISTFILE2
+# Chooses the list of variables in the history file. 
+#   Values between 0: nothing is written; 10: everything is 
+#   written are available More details can be found on the web under documentation.
+#   web under documentation.
+# First level contains all ORCHIDEE outputs.
+SECHIBA_HISTLEVEL2 = 1
+# default = 1
+
+# Write frequency for output files (SECHIBA in seconds) :
+#---------------------------------------------------------------------
+# Frequency in seconds at which to WRITE output
+# This variables gives the frequency the output of
+#  the model should be written into the netCDF file.
+#  It does not affect the frequency at which the
+#  operations such as averaging are done.
+WRITE_STEP = 86400.0
+# default = 86400.0
+
+# Frequency in seconds at which to WRITE output
+# If SECHIBA_HISTFILE2
+# This variables gives the frequency the output 2 of
+#   the model should be written into the netCDF file.
+#   It does not affect the frequency at which the
+#   operations such as averaging are done.
+#   That is IF the coding of the calls to histdef
+#   are correct !
+WRITE_STEP2 = 1800.0
+# default = 1800.0
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate CO2?
+# set to TRUE if photosynthesis is to be activated
+STOMATE_OK_CO2 = n
+# default = n
+
+# Flag to force the value of atmospheric CO2 for vegetation.
+# If this flag is set to true, the ATM_CO2 parameter is used
+#  to prescribe the atmospheric CO2.
+# This Flag is only use in couple mode.
+FORCE_CO2_VEG = FALSE
+# default = FALSE
+
+# Value for atm CO2.
+# If FORCE_CO2_VEG (in not forced mode)
+# Value to prescribe the atm CO2.
+#  For pre-industrial simulations, the value is 286.2 .
+#  348. for 1990 year.
+ATM_CO2 = 350.
+# default = 350.
+
+
+#
+#**************************************************************************
+#          NEW OPTIONS FOR RESTARTS in versions up to 1.9.3
+#**************************************************************************
+#
+## sechiba
+soilcap=n
+soilflx=n
+shumdiag=n
+runoff=n
+drainage=n
+
+## diffuco
+raero=n
+qsatt=n
+cdrag=n
+
+## enerbil
+evapot_corr=n
+temp_sol_new=n
+
+## hydrolc
+dss=n
+hdry=n
+
+## thermosoil
+cgrnd=n
+dgrnd=n
+z1=n
+pcapa=n
+pcapa_en=n
+pkappa=n
+zdz1=n
+zdz2=n
+temp_sol_beg=n
+
+# parameters describing the surface (vegetation + soil) :
+#---------------------------------------------------------------------
+#
+# Should the vegetation be prescribed
+# This flag allows the user to impose a vegetation distribution
+#  and its characterisitcs. It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_VEG = n
+# default = n
+
+# Flag to use old "interpolation" of vegetation map.
+# IF NOT IMPOSE_VEG and NOT LAND_USE
+#  If you want to recover the old (ie orchidee_1_2 branch) 
+#   "interpolation" of vegetation map.
+SLOWPROC_VEGET_OLD_INTERPOL = n
+# default = n
+
+# Vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEG__01 = 0.2
+SECHIBA_VEG__02 = 0.0
+SECHIBA_VEG__03 = 0.0
+SECHIBA_VEG__04 = 0.0
+SECHIBA_VEG__05 = 0.0
+SECHIBA_VEG__06 = 0.0
+SECHIBA_VEG__07 = 0.0
+SECHIBA_VEG__08 = 0.0
+SECHIBA_VEG__09 = 0.0
+SECHIBA_VEG__10 = 0.8
+SECHIBA_VEG__11 = 0.0
+SECHIBA_VEG__12 = 0.0
+SECHIBA_VEG__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# Maximum vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEGMAX__01 = 0.2
+SECHIBA_VEGMAX__02 = 0.0
+SECHIBA_VEGMAX__03 = 0.0
+SECHIBA_VEGMAX__04 = 0.0
+SECHIBA_VEGMAX__05 = 0.0
+SECHIBA_VEGMAX__06 = 0.0
+SECHIBA_VEGMAX__07 = 0.0
+SECHIBA_VEGMAX__08 = 0.0
+SECHIBA_VEGMAX__09 = 0.0
+SECHIBA_VEGMAX__10 = 0.8
+SECHIBA_VEGMAX__11 = 0.0
+SECHIBA_VEGMAX__12 = 0.0
+SECHIBA_VEGMAX__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# LAI for all vegetation types (0-dim mode)
+# If IMPOSE_VEG
+# The maximum LAI used in the 0dim mode. The values should be found
+#  in the restart file. The new values of LAI will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SECHIBA_LAI__01 = 0.
+SECHIBA_LAI__02 = 8.
+SECHIBA_LAI__03 = 8.
+SECHIBA_LAI__04 = 4.
+SECHIBA_LAI__05 = 4.5
+SECHIBA_LAI__06 = 4.5
+SECHIBA_LAI__07 = 4.
+SECHIBA_LAI__08 = 4.5
+SECHIBA_LAI__09 = 4.
+SECHIBA_LAI__10 = 2.
+SECHIBA_LAI__11 = 2.
+SECHIBA_LAI__12 = 2.
+SECHIBA_LAI__13 = 2.
+# default = 0., 8., 8., 4., 4.5, 4.5, 4., 4.5, 4., 2., 2., 2., 2.
+
+# Height for all vegetation types (m)
+# If IMPOSE_VEG
+# The height used in the 0dim mode. The values should be found
+#  in the restart file. The new values of height will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SLOWPROC_HEIGHT__01 = 0.
+SLOWPROC_HEIGHT__02 = 50.
+SLOWPROC_HEIGHT__03 = 50.
+SLOWPROC_HEIGHT__04 = 30.
+SLOWPROC_HEIGHT__05 = 30.
+SLOWPROC_HEIGHT__06 = 30.
+SLOWPROC_HEIGHT__07 = 20.
+SLOWPROC_HEIGHT__08 = 20.
+SLOWPROC_HEIGHT__09 = 20.
+SLOWPROC_HEIGHT__10 = .2
+SLOWPROC_HEIGHT__11 = .2
+SLOWPROC_HEIGHT__12 = .4
+SLOWPROC_HEIGHT__13 = .4
+# default = 0., 30., 30., 20., 20., 20., 15., 15., 15., .5, .6, 1.0, 1.0
+
+
+# Fraction of the 3 soil types (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction for the 3 soil types
+#  in the mesh in the following order : sand loam and clay.
+SOIL_FRACTIONS__01 = 0.28
+SOIL_FRACTIONS__02 = 0.52
+SOIL_FRACTIONS__03 = 0.20
+# default = 0.28, 0.52, 0.20
+
+# Temperature used for the initial guess of LAI
+# If there is no LAI in the restart file, we may need
+#  a temperature that is used to guess the initial LAI.
+SLOWPROC_LAI_TEMPDIAG = 280.
+# default = 280.
+
+# Soil level (m) used for canopy development 
+# If STOMATE is not activated.
+# The temperature at this soil depth is used to determine the LAI when
+#   STOMATE is not activated.
+SECHIBA_ZCANOP = 0.5
+# default = 0.5
+
+# Fraction of other surface types within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of ice, lakes, etc. is read from the restart file. If
+#  it is not found there we will use the values provided here.
+#  For the moment, there is only ice.
+SECHIBA_FRAC_NOBIO = 0.0
+# default = 0.0
+
+# Fraction of the clay fraction (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction of clay in the grid box.
+CLAY_FRACTION = 0.2
+# default = 0.2
+
+# Should the surface parameters be prescribed
+# This flag allows the user to impose the surface parameters
+#  (Albedo Roughness and Emissivity). It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_AZE = n
+# default = n
+
+# Emissivity of the surface for LW radiation
+# If IMPOSE_AZE
+# The surface emissivity used for compution the LE emission
+#  of the surface in a 0-dim version. Values range between 
+#  0.97 and 1.. The GCM uses 0.98.
+CONDVEG_EMIS = 1.0
+# default = 1.0
+
+# SW visible albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in visible wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBVIS = 0.25
+# default = 0.25
+
+# SW near infrared albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in near infrared wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBNIR = 0.25
+# default = 0.25
+
+# Average method for z0
+# If this flag is set to true (y) then the neutral Cdrag
+#  is averaged instead of the log(z0). This should be
+#  the prefered option. We still wish to keep the other
+#  option so we can come back if needed. If this is
+#  desired then one should set Z0CDRAG_AVE = n
+Z0CDRAG_AVE = y
+# default = y
+
+# Surface roughness (m)
+# If IMPOSE_AZE
+# Surface rougness to be used on the point if a 0-dim version
+#  of SECHIBA is used. Look at the description of the forcing  
+#  data for the correct value.
+CONDVEG_Z0 = 0.15
+# default = 0.15_stnd
+
+# Height to be added to the height of the first level (m)
+# If IMPOSE_AZE
+# ORCHIDEE assumes that the atmospheric level height is counted
+#  from the zero wind level. Thus to take into account the roughness
+#  of tall vegetation we need to correct this by a certain fraction
+#  of the vegetation height. This is called the roughness height in
+#  ORCHIDEE talk.
+ROUGHHEIGHT = 0.0
+# default = 0.0
+
+# The snow albedo used by SECHIBA
+# This option allows the user to impose a snow albedo.
+#  Default behaviour is to use the model of snow albedo
+#  developed by Chalita (1993).
+CONDVEG_SNOWA = default
+# default = use the model of snow albedo developed by Chalita
+
+# Switch bare soil albedo dependent (if TRUE) on soil wetness
+# If TRUE, the model for bare soil albedo is the old formulation.
+#  Then it depend on the soil dry or wetness. If FALSE, it is the 
+#  new computation that is taken, it is only function of soil color.
+ALB_BARE_MODEL = FALSE
+# default = FALSE
+
+# Initial snow mass if not found in restart
+# The initial value of snow mass if its value is not found
+#   in the restart file. This should only be used if the model is 
+#   started without a restart file.
+HYDROL_SNOW = 0.0
+# default = 0.0
+
+
+# Initial snow age if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOWAGE = 0.0
+# default = 0.0
+
+# Initial snow amount on ice, lakes, etc. if not found in restart
+# The initial value of snow if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO = 0.0
+# default = 0.0
+
+# Initial snow age on ice, lakes, etc. if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO_AGE = 0.0
+# default = 0.0
+
+# Initial dry soil height if not found in restart for ORCHIDEE_1.3 to 1.5 Tags only.
+# The initial value of dry soil height if its value is not found
+# in the restart file. This should only be used if the model is 
+# started without a restart file.
+HYDROL_HDRY = 0.0
+# default = 0.0
+
+# Initial soil moisture stress if not found in restart
+# The initial value of soil moisture stress if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_HUMR = 1.0
+# default = 1.0
+
+# Total depth of soil reservoir
+HYDROL_SOIL_DEPTH = 2.
+# default = 2.
+
+# Root profile
+# Default values were defined for 2 meters soil depth.
+# For 4 meters soil depth, you may use those ones :
+# 5., .4, .4, 1., .8, .8, 1., 1., .8, 4., 1., 4., 1.
+HYDROL_HUMCSTE = 5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+# default =  5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+
+# Initial restart deep soil moisture if not found in restart
+# The initial value of deep soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. Default behaviour is a saturated soil.
+HYDROL_BQSB = default
+# default = Maximum quantity of water (Kg/M3) * Total depth of soil reservoir = 150. * 2
+
+# Initial upper soil moisture if not found in restart
+# The initial value of upper soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_GQSB = 0.0
+# default = 0.0
+
+# Initial upper reservoir depth if not found in restart
+# The initial value of upper reservoir depth if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_DSG = 0.0
+# default = 0.0
+
+# Initial dry soil above upper reservoir if not found in restart
+# The initial value of dry soil above upper reservoir if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. The default behaviour
+#  is to compute it from the variables above. Should be OK most of 
+#  the time.
+HYDROL_DSP = default
+# default = Total depth of soil reservoir - HYDROL_BQSB / Maximum quantity of water (Kg/M3) = 0.0
+
+# Initial water on canopy if not found in restart
+# The initial value of moisture on canopy if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_QSV = 0.0
+# default = 0.0
+
+# Soil moisture on each soil tile and levels
+# The initial value of mc if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_MOISTURE_CONTENT = 0.3
+# default = 0.3
+
+# US_NVM_NSTM_NSLM
+# The initial value of us (relative moisture) if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+US_INIT = 0.0
+# default = 0.0
+
+# Coefficient for free drainage at bottom
+# The initial value of free drainage if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+FREE_DRAIN_COEF = 1.0, 1.0, 1.0
+# default = 1.0, 1.0, 1.0
+
+# Bare soil evap on each soil if not found in restart
+# The initial value of bare soils evap if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+EVAPNU_SOIL = 0.0
+# default = 0.0
+
+# Initial temperature if not found in restart
+# The initial value of surface temperature if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+ENERBIL_TSURF = 280.
+# default = 280.
+
+# Initial Soil Potential Evaporation
+# The initial value of soil potential evaporation if its value 
+#  is not found in the restart file. This should only be used if
+#  the model is started without a restart file. 
+ENERBIL_EVAPOT = 0.0
+# default = 0.0
+
+# Initial soil temperature profile if not found in restart
+# The initial value of the temperature profile in the soil if 
+#   its value is not found in the restart file. This should only 
+#   be used if the model is started without a restart file. Here
+#   we only require one value as we will assume a constant 
+#   throughout the column.
+THERMOSOIL_TPRO = 280.
+# default = 280.
+
+# Initial leaf CO2 level if not found in restart
+# The initial value of leaf_ci if its value is not found
+#  in the restart file. This should only be used if the model is
+#  started without a restart file.
+DIFFUCO_LEAFCI = 233.
+# default = 233.
+
+
+# Keep cdrag coefficient from gcm.
+# Set to .TRUE. if you want q_cdrag coming from GCM.
+#  Keep cdrag coefficient from gcm for latent and sensible heat fluxes.
+#  TRUE if q_cdrag on initialization is non zero (FALSE for off-line runs).
+CDRAG_FROM_GCM = n
+# default =  IF q_cdrag == 0 ldq_cdrag_from_gcm = .FALSE. ELSE .TRUE.
+
+
+# Artificial parameter to increase or decrease canopy resistance
+# Add from Nathalie - the 28 of March 2006 - advice from Fred Hourdin
+# By PFT.
+RVEG_PFT = 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.
+# default = 1.
+
+
+# Interception reservoir coefficient.
+# Transforms leaf area index into size of interception reservoir
+#  for slowproc_derivvar or stomate.
+SECHIBA_QSINT = 0.1
+# default = 0.1
+
+#**************************************************************************
+# LAI
+#**************************************************************************
+
+# Read the LAI map
+# It is possible to read a 12 month LAI map which will
+#  then be interpolated to daily values as needed.
+#  If n => type_of_lai (constant_veg.f90)
+#     - mean    : lai(ji,jv) = undemi * (llaimax(jv) + llaimin(jv))
+#     - inter   : llaimin(jv) + tempfunc(stempdiag(ji,lcanop)) * (llaimax(jv) - llaimin(jv))
+LAI_MAP = n
+# default = n
+
+# Name of file from which the vegetation map is to be read
+# If LAI_MAP
+# The name of the file to be opened to read the LAI
+#  map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#  map which is derived from a Nicolas VIOVY one. 
+LAI_FILE = lai2D.nc
+# default = ../surfmap/lai2D.nc
+
+# Flag to use old "interpolation" of LAI
+# If LAI_MAP
+# If you want to recover the old (ie orchidee_1_2 branch) 
+# "interpolation" of LAI map.
+SLOWPROC_LAI_OLD_INTERPOL = n
+# default = n
+
+#**************************************************************************
+# LAND_USE
+#**************************************************************************
+
+# Read a land_use vegetation map
+# pft values are needed, max time axis is 293
+LAND_USE = y
+# default = n
+
+# Year of the land_use vegetation map readed
+# year off the pft map.
+# default is 133 for year 1982  (as 1982 - 1850 + 1 = 133)
+# If LAND_USE
+VEGET_YEAR = 1
+# default = 133
+
+# booleen to indicate that a new LAND USE file will be used (since 1.9.5 version).
+# The parameter is used to bypass veget_year count 
+# and reinitialize it with VEGET_YEAR parameter.
+# Then it is possible to change LAND USE file.
+# If LAND_USE
+VEGET_REINIT = y
+# default = n
+
+# Update vegetation frequency (since 2.0 version)
+# The veget datas will be update each this time step.
+# If LAND_USE
+VEGET_UPDATE = 0Y
+# default = 1Y
+
+# treat land use modifications
+# With this variable, you can use a Land Use map
+# to simulate anthropic modifications such as   
+# deforestation.                                
+# If LAND_USE
+LAND_COVER_CHANGE = n
+# default = y
+
+#**************************************************************************
+
+# agriculture allowed?
+# With this variable, you can determine
+#  whether agriculture is allowed
+AGRICULTURE = y
+# default = y
+
+#**************************************************************************
+
+# Time within the day simulated
+# This is the time spent simulating the current day. This variable is
+#  prognostic as it will trigger all the computations which are
+#  only done once a day.
+SECHIBA_DAY = 0.0
+# default = 0.0
+
+# Time step of STOMATE and other slow processes
+# Time step (s) of regular update of vegetation
+#  cover, LAI etc. This is also the time step
+#  of STOMATE.
+DT_SLOW = 86400.
+# default = un_jour = 86400.
+
+#**************************************************************************
+
+# Allows to switch on the multilayer hydrology of CWRR
+# This flag allows the user to decide if the vertical
+#  hydrology should be treated using the multi-layer 
+#  diffusion scheme adapted from CWRR by Patricia de Rosnay.
+#  by default the Choisnel hydrology is used.
+HYDROL_CWRR = n
+# default = n
+
+# do horizontal diffusion?
+# If TRUE, then water can diffuse horizontally between
+#  the PFTs' water reservoirs.
+HYDROL_OK_HDIFF = n
+# default = n
+ 
+
+# time scale (s) for horizontal diffusion of water
+# If HYDROL_OK_HDIFF
+# Defines how fast diffusion occurs horizontally between
+#  the individual PFTs' water reservoirs. If infinite, no
+#  diffusion.
+HYDROL_TAU_HDIFF = 86400.
+# default = 86400.
+
+# Percent of precip that is not intercepted by the canopy (only for TAG 1.6).
+# During one rainfall event, PERCENT_THROUGHFALL% of the incident rainfall
+#  will get directly to the ground without being intercepted.
+PERCENT_THROUGHFALL = 30.
+# default = 30.
+
+# Percent by PFT of precip that is not intercepted by the canopy (since TAG 1.8).
+# During one rainfall event, PERCENT_THROUGHFALL_PFT% of the incident rainfall
+#  will get directly to the ground without being intercepted, for each PFT..
+PERCENT_THROUGHFALL_PFT = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+# default = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+
+# Decides if we route the water or not
+# This flag allows the user to decide if the runoff
+#  and drainage should be routed to the ocean
+#  and to downstream grid boxes.
+RIVER_ROUTING = n
+# default = n
+
+# Name of file which contains the routing information
+# The file provided here should allow the routing module to
+#  read the high resolution grid of basins and the flow direction 
+#  from one mesh to the other.
+ROUTING_FILE = routing.nc
+# default = routing.nc
+
+# Time step of the routing scheme
+# If RIVER_ROUTING
+# This values gives the time step in seconds of the routing scheme. 
+#   It should be multiple of the main time step of ORCHIDEE. One day
+#   is a good value.
+ROUTING_TIMESTEP = 86400
+# default = 86400
+
+# Number of rivers 
+# If RIVER_ROUTING
+# This parameter chooses the number of largest river basins
+#  which should be treated as independently as rivers and not
+#  flow into the oceans as diffusion coastal flow.
+ROUTING_RIVERS = 50
+# default = 50
+
+# Should we compute an irrigation flux 
+# This parameters allows the user to ask the model
+#  to compute an irigation flux. This performed for the
+#  on very simple hypothesis. The idea is to have a good
+#  map of irrigated areas and a simple function which estimates
+#  the need to irrigate.
+DO_IRRIGATION = n
+# default = n
+
+# Name of file which contains the map of irrigated areas
+# If IRRIGATE
+# The name of the file to be opened to read the field
+#  with the area in m^2 of the area irrigated within each
+#  0.5 0.5 deg grid box. The map currently used is the one
+#  developed by the Center for Environmental Systems Research 
+#  in Kassel (1995).
+IRRIGATION_FILE = irrigated.nc
+# default = irrigated.nc
+
+# Should we include floodplains 
+# This parameters allows the user to ask the model
+#  to take into account the flood plains and return 
+#  the water into the soil moisture. It then can go 
+#  back to the atmopshere. This tried to simulate 
+#  internal deltas of rivers.
+DO_FLOODPLAINS = n
+# default = n
+
+#**************************************************************************
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/PARAM/stomate.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/PARAM/stomate.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/PARAM/stomate.def	(revision 405)
@@ -0,0 +1,206 @@
+#
+#**************************************************************************
+#                    Namelist for STOMATE
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of STOMATE
+#**************************************************************************
+
+# Model chatting level
+# level of online diagnostics in STOMATE (0-4)
+# With this variable, you can determine how much online information STOMATE
+#  gives during the run. 0 means virtually no info.
+BAVARD = 1
+# default = 1
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+
+# Name of file from which the reference
+# The name of the file to be opened to read
+#  temperature is read
+#  the reference surface temperature.
+#  The data from this file is then interpolated
+#  to the grid of the model.
+#  The aim is to get a reference temperature either
+#  to initialize the corresponding prognostic model
+#  variable correctly (ok_dgvm = TRUE) or to impose it
+#  as boundary condition (ok_dgvm = FALSE)
+REFTEMP_FILE = reftemp.nc
+# default = reftemp.nc
+# Input and output restart file for STOMATE :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions of STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened of STOMATE
+#   to extract the initial values of all prognostic values of STOMATE.
+STOMATE_RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened
+#        to write the final values of all prognostic values
+#        of STOMATE.
+STOMATE_RESTART_FILEOUT = stomate_rest_out.nc
+# default = stomate_restart.nc
+
+# Forcing files for TESTSTOMATE and FORCESOIL
+#---------------------------------------------------------------------
+
+# Name of STOMATE's forcing file
+# Name that will be given to STOMATE's offline forcing file
+STOMATE_FORCING_NAME = stomate_forcing.nc
+#default = NONE
+
+# Size of STOMATE forcing data in memory (MB)
+# This variable determines how many
+#  forcing states will be kept in memory.
+#  Must be a compromise between memory
+#  use and frequeny of disk access.
+STOMATE_FORCING_MEMSIZE = 50
+# default = 50
+
+# Name of STOMATE's carbon forcing file
+# Name that will be given to STOMATE's carbon offline forcing file
+STOMATE_CFORCING_NAME = stomate_Cforcing.nc
+# default = NONE
+
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+# STOMATE does minimum service
+# set to TRUE if you want STOMATE to read
+#  and write its start files and keep track
+#  of longer-term biometeorological variables.
+#  This is useful if OK_STOMATE is not set,
+#  but if you intend to activate STOMATE later.
+#  In that case, this run can serve as a 
+#  spinup for longer-term biometeorological
+#  variables.
+STOMATE_WATCHOUT = n
+# default = n
+
+
+# Output file name :
+#---------------------------------------------------------------------
+
+# Name of file in which STOMATE's output is going to be written
+# This file is going to be created by the model
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+STOMATE_OUTPUT_FILE = stomate_history.nc
+# default = stomate_history.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# STOMATE history output level (0..10)
+#  0: nothing is written; 10: everything is written
+STOMATE_HISTLEVEL = 10
+# default = 10
+
+# STOMATE_IPCC_OUTPUT_FILE
+# This file is going to be created by the model
+#    and will contain the output from the model.
+#    This file is a truly COADS compliant netCDF file.
+#    It will be generated by the hist software from
+#    the IOIPSL package.
+# Name of file in which STOMATE's output is going
+# to be written
+STOMATE_IPCC_OUTPUT_FILE = stomate_ipcc_history.nc
+# default = stomate_ipcc_history.nc
+
+# STOMATE_IPCC_HIST_DT
+# Time step of the STOMATE IPCC history file
+# STOMATE IPCC history time step (d)
+STOMATE_IPCC_HIST_DT = 0.
+# default = 0.
+
+# Write frequency for output files (STOMATE in days) :
+#---------------------------------------------------------------------
+
+# STOMATE history time step (d)
+# Time step of the STOMATE history file
+# Care : this variable must be higher than DT_SLOW
+STOMATE_HIST_DT = 10.
+# default = 10.
+
+
+#---------------------------------------------------------------------
+# FORCESOIL CARBON spin up parametrization
+#---------------------------------------------------------------------
+
+# Number of time steps per year for carbon spinup.
+FORCESOIL_STEP_PER_YEAR = 12
+# default = 12
+
+# Number of years saved for carbon spinup.
+FORCESOIL_NB_YEAR = 1
+# default = 1
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate STOMATE?
+# set to TRUE if STOMATE is to be activated
+STOMATE_OK_STOMATE = n
+# default = n
+
+# Activate DGVM?
+# set to TRUE if Dynamic Vegetation DGVM is to be activated
+STOMATE_OK_DGVM = n
+# default = n
+
+# Index of grid point for online diagnostics
+# This is the index of the grid point which will be used for online diagnostics.
+STOMATE_DIAGPT = 1
+# default = 1
+
+# constant tree mortality
+# If yes, then a constant mortality is applied to trees. 
+#  Otherwise, mortality is a function of the trees' 
+#  vigour (as in LPJ).
+LPJ_GAP_CONST_MORT = y
+# default = y
+
+# no fire allowed
+# With this variable, you can allow or not
+#  the estimation of CO2 lost by fire
+FIRE_DISABLE = n
+# default = n
+
+#**************************************************************************
+
+# Harvert model for agricol PFTs.
+# Compute harvest above ground biomass for agriculture.
+# Change daily turnover.
+HARVEST_AGRI = y
+# default = y
+
+# herbivores allowed?
+# With this variable, you can activate herbivores 
+HERBIVORES = n
+# default = n
+
+# treat expansion of PFTs across a grid cell?
+# With this variable, you can determine
+#  whether we treat expansion of PFTs across a
+#  grid cell.
+TREAT_EXPANSION = n
+# default = n
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/config.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/config.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/config.card	(revision 405)
@@ -0,0 +1,86 @@
+#
+# This is config.card file for restart with an NEW libIGCM simulation tree.
+#
+#====================================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+#========================================================================
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=Ens
+LongName="ENSEMBLE Spinup : test en changeant HYDROL_SOIL_DEPTH et HYDROL_HUMCSTE."
+TagName=OL2
+#============================
+#-- leap, noleap, 360d
+CalendarType= gregorian
+#-- Start and End of Job
+#-- "YYYY-MM-DD"
+DateBegin=1850-01-01
+DateEnd=1999-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength= 1Y
+PeriodNb= 1
+#============================
+#-- PBS Class (required on brodie mono/multi)
+JobClass=mono
+#JobClass=multi
+#============================
+#-- Total Number of Processors (minimum is 2 for a coupled configuration)
+JobNumProcTot=8
+#============================
+#-- Run Options : here for oasis coupling
+JobRunOptions='"-n "${NUM_PROC}'
+#Platine : JobRunOptions='"-n "${NUM_PROC}'
+#mercure : JobRunOptions='-f'
+
+#========================================================================
+#========================================================================
+#D-- SRF options passed to SuRFace (SECHIBA) subjobs
+[SRF]
+WriteFrequency="1M"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1997-12-31
+# Define restart simulation name
+RestartJobName=SPINUP
+RestartPath=${ARCHIVE}/${LOGIN}/IGCM_OUT/${config_UserChoices_TagName}
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#D-- Surface BioGeochemistry ( STOMATE ) subjobs
+[SBG]
+WriteFrequency="1M"
+Restart= n
+#-- Last day of the experience used as restart
+RestartDate= 1900-12-31
+# Define restart simulation name
+RestartJobName= SPINUP
+RestartPath=${ARCHIVE}/${LOGIN}/IGCM_OUT/${config_UserChoices_TagName}
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#D-- Post-treatment options passed to SubJobs on all sites
+# WARNING : You can use thoses options only if you set CONSERVE=y in fluxnet.card
+[SubJobPost]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=10Y
+#D- Do we rebuild parallel output from archive (use NONE to use SCRATCHDIR as buffer)
+RebuildFromArchive=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency= 10Y
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency= 20Y
+#D- Offset for seasonal average first start dates ; same unit as SeasonalFrequency
+#D- Usefull if you do not want to consider the first X simulation's years
+SeasonalFrequencyOffset=0
+
+#========================================================================
+#========================================================================
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/ensemble.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/ensemble.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/ensemble.card	(revision 405)
@@ -0,0 +1,169 @@
+[CONFIG]
+# - Forcing files path
+ForcingPath=${R_BC}/OOL/${config_UserChoices_TagName}/NCC
+
+# - Number of PFTs :
+NbPFTs= 13
+
+# - Information on the sites to be treated :
+#   * Number of physical parameters on each sites per PFTs
+NbSitesParam= 2
+# 4 first parameters are Name, Forcing file, Begin date, Number of years in forcing file
+
+#   * ORCHIDEE name for physical parameters on each sites
+#   PFT (IMPOSE_VEG), \
+#   initial LAI (IMPOSE_VEG)
+NameSitesParam= ( HYDROL_SOIL_DEPTH, HYDROL_HUMCSTE )
+
+#   * Name of component for each physical parameter described in NameSitesParam
+#     (in SECHIBA, STOMATE, DRIVER)
+CompSitesParam= ( SECHIBA, SECHIBA )
+
+
+# Sites descriptions :
+# Number
+NbSites=2
+#       Abbrv,  Filename ,      Inital year (for gregorian calendar) , Length (Y),  \
+#param 1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13
+Sites= ( NCC2, ncc_for_${year}.nc   ,          1950,                         1    , \
+         2.0, \
+         5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.) \
+\
+       ( NCC4, ncc_for_${year}.nc   ,          1950,                         1     , \
+         4.0, \
+         5., .4, .4, 1., .8, .8, 1., 1., .8, 4., 1., 4., 1.)
+
+# The following tables of parameters for SECHIBA
+# are in the following order :
+#
+#    1 - Bare soil
+#    2 - tropical  broad-leaved evergreen
+#    3 - tropical  broad-leaved raingreen
+#    4 - temperate needleleaf   evergreen
+#    5 - temperate broad-leaved evergreen
+#    6 - temperate broad-leaved summergreen
+#    7 - boreal    needleleaf   evergreen
+#    8 - boreal    broad-leaved summergreen
+#    9 - boreal    needleleaf   summergreen
+#   10 -           C3           grass
+#   11 -           C4           grass
+#   12 -           C3           agriculture
+#   13 -           C4           agriculture
+
+[SPINUP]
+    # SPINUP configuration : 
+    # ----------------------
+# !! Step of time in N Years !!
+# !! The spinup will change if the ensemble file contains more than one year !!
+#    ( N = Number of years contain in ensemble forcing file ) 
+#     each Year * N
+
+# Initialisation for spin-up :
+# orchidee with sechiba alone (!!! if ok_stomate == n !!!)
+duree_nostomate=0
+# orchidee with stomate
+duree_inistomate=20
+# teststomate (only if duree_nostomate or duree_inistomate > 0)
+duree_offlineini=0
+
+# Loop configuration for spin-up :
+# The whole job is restarted n_iter times
+n_iter=2
+# orchidee with sechiba (and stomate if ok_stomate=y below)
+duree_sechiba=20
+# teststomate
+duree_stomate=400
+# forcesoil
+duree_carbonsol=5000
+
+# Finalization for spin-up :
+# all orchidee
+duree_final=20
+# This last parameter must be non-zero.
+
+
+[UserChoices]
+
+#
+###-- STOMATE flag
+#
+ok_stomate=y
+#
+###-- OK_CO2 flag
+#
+ok_co2=y
+
+#
+###-- LAI flag
+#
+lai_map=n
+
+#
+###-- fix vÃ©gÃ©tation flag
+#
+impose_veg=n
+
+#
+###-- historical vegetation maps
+#
+land_use=n
+
+#
+###-- ROUTING flag
+#
+ok_routing=n
+
+#
+###-- NEW HYDROL CWRR flag
+#
+ok_newhydrol=n
+
+#
+## DEBUG mode for SPINUP 
+#
+# This mode keep all SPINUP directory in ARCHIVE
+# If disable, all ARCHIVE is automaticly cleaned.
+# 
+DEBUG_SPIN=y
+# If you don't want to keep old spinup steps, but last one
+CONSERVE=y
+
+[SubJobParams]
+# You can specify here any parameters to be modified in sechiba.def, stomate.def or driver.def for SpinUp Subjobs.
+# NEW : due to split of orchidee.def in component specific parameter files,
+#       you must add here a prefix for the specific parameter file.
+driver_DEBUG_INFO=n
+sechiba_LONGPRINT=n
+stomate_BAVARD=0
+driver_ALLOW_WEATHERGEN=n
+sechiba_SECHIBA_reset_time=y
+
+# ensemble files have hour frequency values. NCC files
+driver_SPLIT_DT=12
+driver_SPRED_PREC=3
+
+
+# Western limit of region
+# Western limit of the region we are 
+#  interested in. Between -180 and +180 degrees
+driver_LIMIT_WEST = -4.
+# default = -180.
+
+# Eastern limit of region
+# Eastern limit of the region we are
+#  interested in. Between -180 and +180 degrees
+driver_LIMIT_EAST = 16.
+# default = 180.
+
+# Northern limit of region
+# Northern limit of the region we are
+#  interested in. Between +90 and -90 degrees
+driver_LIMIT_NORTH = 60.
+# default = 90.
+
+# Southern limit of region
+# Southern limit of the region we are
+#  interested in. Between 90 and -90 degrees
+driver_LIMIT_SOUTH = 40.
+
+sechiba_ROUTING=y
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/ensemble.ksh
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/ensemble.ksh	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/ensemble.ksh	(revision 405)
@@ -0,0 +1,279 @@
+#!/bin/ksh
+
+#D--------------------------------------------------------------------==
+
+function ENSEMBLE_initialize
+{
+    IGCM_debug_PushStack "ENSEMBLE_initialize"
+
+    # config.card : 
+    # -------------
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices
+    typeset option
+    for option in ${config_UserChoices[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option}
+    done
+    
+    DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
+    IGCM_date_GetYearMonth ${DateBegin} year month
+    
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SubJobPost
+    typeset option
+    for option in ${config_SubJobPost[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SubJobPost ${option}
+    done
+    
+    # Subjobs configuration : 
+    # -----------------------
+
+    # 1) UserChoices section of ensemble.card
+
+    # This section groups standard options to be passed to ORCHIDEE.
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/ensemble.card UserChoices
+    set +A ensemble_UserChoices -- ${ensemble_UserChoices[*]} > /dev/null 2>&1
+    typeset option
+    for option in ${ensemble_UserChoices[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/ensemble.card UserChoices ${option}
+    done
+
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SRF
+    typeset option
+    for option in ${config_SRF[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF ${option}
+    done
+    if [ X"${ensemble_UserChoices_ok_stomate}" = "Xy" ] ; then
+	IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SBG
+	typeset option
+	for option in ${config_SBG[*]} ; do
+	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG ${option}
+	done
+    fi
+    
+    # 2) CONFIG section :
+    # This section is the ENSEMBLE configuration :
+    # - Forcing files path
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/ensemble.card CONFIG ForcingPath
+
+    # - List of the sites/information to be treated :
+    #   * Number of PFTs
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/ensemble.card CONFIG NbPFTs
+    NbPFTs=${ensemble_CONFIG_NbPFTs}
+
+    #   * Number of physical parameters on each sites per PFTs
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/ensemble.card CONFIG NbSitesParam
+    #   * ORCHIDEE name for physical parameters on each sites
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/ensemble.card CONFIG NameSitesParam
+    #   * Sites descriptions
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/ensemble.card CONFIG NbSites
+    echo "NbSites : " ${ensemble_CONFIG_NbSites[*]}
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/ensemble.card CONFIG Sites
+    echo "Sites : " ${ensemble_CONFIG_Sites[*]}
+    #   * Components for each physical parameter described in NameSitesParam
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/ensemble.card CONFIG CompSitesParam
+
+    echo ${ensemble_CONFIG_Sites[*]}
+
+    # Number of sites :
+    NumSites=${ensemble_CONFIG_NbSites}
+
+    # Number of columns by site in variable site : name, filename, length, + Parameters
+    NumInfosBySite=$(( ${#ensemble_CONFIG_Sites[*]} / NumSites ))
+
+    rest=$(( ${#ensemble_CONFIG_Sites[*]} % NumSites ))
+    if [ rest -ne 0 ] ; then
+	echo "Error CONFIG : number of parameters per site is not correct "
+	echo "Total Number of parameters " ${#ensemble_CONFIG_Sites[*]} " != NumSites " ${NumSites} "x NumInfosBySite " ${NumInfosBySite}
+	echo "rest = " ${rest}
+	exit 1
+    fi
+    # Num of Columns : name, filename, length, + ${NbPFTs} PFT
+    ColumnName=0
+    ColumnFilename=1
+    ColumnYear=2
+    ColumnLength=3
+
+    # 3) SPINUP section : files path and spinup parameters
+    # This section groups specific options for SPINUP :
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/ensemble.card SPINUP
+    set +A ensemble_SPINUP -- ${ensemble_SPINUP[*]} > /dev/null 2>&1
+    typeset option
+    for option in ${ensemble_SPINUP[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/ensemble.card SPINUP ${option}
+    done
+
+    # 4) Subjob orchidee.def parametrisation : SubJobParams in ensemble.card
+    # This section give flags to put in orchidee.def of Subjobs.
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/ensemble.card SubJobParams
+    set +A ensemble_SubJobParams -- ${ensemble_SubJobParams[*]} > /dev/null 2>&1
+    eval first_option=${ensemble_SubJobParams[0]} > /dev/null 2>&1
+    if [ X${first_option} != X"Error:" ] ; then
+	typeset option
+	for option in ${ensemble_SubJobParams[*]} ; do
+	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/ensemble.card SubJobParams ${option}
+	done
+    fi
+
+    IGCM_debug_PopStack "ENSEMBLE_initialize"
+}
+
+# Function to sed parameter files in Subjob dirs
+# For sechiba.def :
+function SECHIBA_sed
+{
+    IGCM_debug_PushStack "SECHIBA_sed"
+    
+    if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then
+	sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	    ${New_SUBMIT_DIR}/PARAM/sechiba.def > ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp
+	RET=$?
+	echo "SECHIBA_sed : ${1} ${2}"
+	\mv ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp ${New_SUBMIT_DIR}/PARAM/sechiba.def
+    fi
+
+    IGCM_debug_PopStack "SECHIBA_sed"
+    return $RET
+}
+
+# For stomate.def :
+function STOMATE_sed
+{
+    IGCM_debug_PushStack "STOMATE_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	${New_SUBMIT_DIR}/PARAM/stomate.def > ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp
+    RET=$?
+    echo "STOMATE_sed : ${1} ${2}"
+    \mv ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp ${New_SUBMIT_DIR}/PARAM/stomate.def
+    
+    IGCM_debug_PopStack "STOMATE_sed"
+    return $RET
+}
+
+# For driver.def :
+function DRIVER_sed
+{
+    IGCM_debug_PushStack "DRIVER_sed"
+    
+    if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then
+	sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	    ${New_SUBMIT_DIR}/PARAM/driver.def > ${New_SUBMIT_DIR}/PARAM/driver.def.tmp
+	RET=$?
+	echo "DRIVER_sed : ${1} ${2}"
+	\mv ${New_SUBMIT_DIR}/PARAM/driver.def.tmp ${New_SUBMIT_DIR}/PARAM/driver.def
+    fi
+
+    IGCM_debug_PopStack "DRIVER_sed"
+    return $RET
+}
+
+
+# Function to grep parameter files in Subjob dirs
+# They search for the argmument value in the file.
+# The result of the function is given in ${SearchParam} global variable :
+# * "line" if the parameter is a vector defined line per line with the form 
+#   PARAM__1=value1
+#   PARAM__2=value2
+#   etc...
+# * "vector" if the parameter is defined with the form
+#   PARAM=value1[,] value2[,] etc...
+# * "value" if the parameter is a single value
+#   PARAM=value
+# * "undefined" if the parameter is not definied in the parameters file
+#   This should give an error in the script.
+
+# For sechiba.def :
+function SECHIBA_grep
+{
+    IGCM_debug_PushStack "SECHIBA_grep"
+    typeset Output
+    Output[0]=""
+    if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then
+	set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def )
+	if [ X${Output[0]} != X ] ; then
+	    SearchParam=line
+	else
+	    set +A Output -- $( grep "^${1}\ *=\ *[^[:blank:]][^[:blank:]]*\ [^[:blank:]][^[:blank:]]*.*" ${New_SUBMIT_DIR}/PARAM/sechiba.def )
+	    if [ X${Output[0]} != X ] ; then
+		SearchParam=vector
+	    else
+		set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def )
+		if [ X${Output[0]} != X ] ; then
+		    SearchParam=value
+		else
+		    SearchParam=undefined
+		fi
+	    fi
+	fi
+    else
+	SearchParam=undefined
+        echo "$@ : file not found !!"
+    fi
+    IGCM_debug_PopStack "SECHIBA_grep"
+    return $RET
+}
+
+# For stomate.def :
+function STOMATE_grep
+{
+    IGCM_debug_PushStack "STOMATE_grep"
+    typeset Output
+    Output[0]=""
+
+    if [ -f ${New_SUBMIT_DIR}/PARAM/stomate.def ] ; then
+	set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def )
+	if [ X${Output[0]} != X ] ; then
+	    SearchParam=line
+	else
+	    set +A Output -- $( grep "^${1}\ *=\ *[^[:blank:]][^[:blank:]]*\ [^[:blank:]][^[:blank:]]*.*" ${New_SUBMIT_DIR}/PARAM/stomate.def )
+	    if [ X${Output[0]} != X ] ; then
+		SearchParam=vector
+	    else
+		set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def )
+		if [ X${Output[0]} != X ] ; then
+		    SearchParam=value
+		else
+		    SearchParam=undefined
+	        fi
+	    fi
+	fi
+    else
+	SearchParam=undefined
+        echo "$@ : file not found !!"
+    fi
+
+    IGCM_debug_PopStack "STOMATE_grep"
+    return $RET
+}
+
+# For driver.def :
+function DRIVER_grep
+{
+    IGCM_debug_PushStack "DRIVER_grep"
+    typeset Output
+    Output[0]=""
+    if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then
+	set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def )
+	if [ X${Output[0]} != X ] ; then
+	    SearchParam=line
+	else
+	    set +A Output -- $( grep "^${1}\ *=\ *[^[:blank:]][^[:blank:]]*\ [^[:blank:]][^[:blank:]]*.*" ${New_SUBMIT_DIR}/PARAM/driver.def )
+	    if [ X${Output[0]} != X ] ; then
+		SearchParam=vector
+	    else
+		set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def )
+		if [ X${Output[0]} != X ] ; then
+		    SearchParam=value
+		else
+		    SearchParam=undefined
+		fi
+	    fi
+	fi
+    else
+	SearchParam=undefined
+        echo "$@ : file not found !!"
+    fi
+
+    IGCM_debug_PopStack "DRIVER_grep"
+    return $RET
+}
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/install
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/install	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/ENSEMBLE/install	(revision 405)
@@ -0,0 +1,10 @@
+#!/bin/ksh
+# $Id: install,v 1.2 2008/12/03 11:32:45 ssipsl Exp $
+
+d_n=$(dirname ${0}); 
+
+F_MOD=$(cd ${d_n}'/../../..';/bin/pwd;)
+\sed -e "s%::modipsl::%${F_MOD}%" \
+     Job_ENSEMBLE > Job_ENSEMBLE_
+\mv Job_ENSEMBLE_ Job_ENSEMBLE
+\chmod u+x Job_ENSEMBLE
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/AA_job
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/AA_job	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/AA_job	(revision 405)
@@ -0,0 +1,887 @@
+#-Q- sxnec ##################
+#-Q- sxnec ## SXNEC IDRIS  ##
+#-Q- sxnec ##################
+#-Q- sxnec #@$-r :XXX:XXX:XXX:             # job name
+#-Q- sxnec #@$-me                          # send a mail when execution ends
+#-Q- sxnec #@$-eo                          # glue standard error and output
+#-Q- sxnec #@$-lT 1:00:00                  # total time limit
+#-Q- sxnec #@$-lt 1:00:00                  # processor time limit
+#-Q- sxnec #@$-lM 3Gb                      # memory limit
+#-Q- sxnec #@$-o sortie_XXXXXXX.1          # output file name
+#-Q- sxnec #@$-jo                          # sum up performances
+#-Q- sx6nec ##################
+#-Q- sx6nec ## SX6NEC   CEA ##
+#-Q- sx6nec ##################
+#-Q- sx6nec #PBS -N :XXX:XXX:XXX:          # job name
+#-Q- sx6nec #PBS -j o                      # glue standard error and output
+#-Q- sx6nec #PBS -o sortie_XXXXXXX.1       # output file name
+#-Q- sx6nec #PBS -S /usr/bin/ksh           # shell type
+#-Q- sx6nec #PBS -l memsz_job=3gb          # memory limit
+#-Q- sx6nec #PBS -l cputim_job=1:00:00     # time limit
+#-Q- fjvpp ####################
+#-Q- fjvpp ## FJVPP 5000 CEA ##
+#-Q- fjvpp ####################
+#-Q- fjvpp #@$-r :XXX:XXX:XXX:             # job name
+#-Q- fjvpp #@$-me                          # send a mail when execution ends
+#-Q- fjvpp #@$-eo                          # glue standard error and output
+#-Q- fjvpp #@$-lT 1:00:00                  # total time limit
+#-Q- fjvpp #@$-lt 1:00:00                  # processor time limit
+#-Q- fjvpp #@$-lM 3Gb                      # memory limit
+#-Q- fjvpp #@$-o RRRRRRR/sortie_XXXXXXX.1  # output file name
+#-Q- fjvpp #@$-ko                          # output listing on the disk
+#-Q- fjvpp #@$-s /bin/ksh                  # shell type
+#
+#
+########################################################################
+##
+##      Execution script for ORCHIDEE OFFLINE
+## $HeadURL$ 
+## $Date$
+## $Author$
+## $Revision$
+##
+##      Rachid BENSHILA & Patricia CADULE
+##      Original ressources : 
+##                         Lancement Coupleur : Oasis team
+##                         Lancement ORCA : Olivier Marti
+##                         Lancement LMDZ : Laurent Fairhead
+##                         Systeme de relances :  Olivier Marti
+##                         Atlas : Sebastien Denvil
+##                         And inspiration from Gerhard Krinner
+#########################################################################
+##-- print the commands before and after their interpretation by
+##-- the shell
+date
+set -vx
+##
+
+		#=============================================#
+		#       BEGINNING OF USER MODIFICATIONS        #
+		#=============================================#
+
+#########################################################################
+##
+##    1. Current Modifications 
+##
+#########################################################################
+##
+###-- Experience name
+#
+CEXPER=XXXXXXX
+#
+###-- Forcing File (omitting .nc)
+#
+F_FILE=WG_cru
+#
+###-- Run.def (omitting .def)
+#
+F_RUN=orchidee 
+#
+###-- Simulation length
+#
+units=Y               # time unit
+
+duree_nostomate=0     # orchidee
+duree_offlineini=0    # teststomate
+duree_inistomate=0    # orchidee with stomate
+
+n_iter=0              # iteration 
+duree_sechiba=0       # orchidee
+duree_stomate=0       # teststomate
+
+duree_carbonsol=0     # forcesoil
+duree_final=1         # orchidee
+#
+###-- Postprocessing
+#
+OK_DIAG=n
+#
+###-- Vegetation flags
+#
+ok_co2=y
+ok_stomate=n
+ok_dgvm=n
+#
+###-- Restart if necessary (absolute pathname)
+#
+no_restart=y
+RESTART_SECH=
+RESTART_STOM=
+RESTART_DRI=
+#
+###-- Some current flags
+#
+OK_WEATHER=y
+resolution_LON=1
+resolution_LAT=1
+limit_west=-180
+limit_east=180
+limit_north=90
+limit_south=-90
+
+sechistlev=5
+sechistdt=2592000
+stohistlev_sto=2
+stohistlev_sec=10
+stohistdt_sto=60
+stohistdt_sec=15
+
+sechiba_hist=sechiba_history.nc
+stomate_hist=stomate_history.nc
+
+moteur_dem=driver_start.nc
+moteur_redem=driver_restart.nc
+sechiba_dem=sechiba_start.nc
+sechiba_redem=sechiba_restart.nc
+stomate_dem=stomate_start.nc
+stomate_redem=stomate_restart.nc
+#
+#########################################################################
+##
+##    2. Advanced modifications
+##
+#########################################################################
+##
+###-- Forcing and other files are stored together in this repository, you can specify yours
+#
+#-Q- sxnec R_STOCKAGE="gaya:/u/rech/ces/rces803/FORCAGE_OL"
+#-Q- sx6nec R_STOCKAGE="/dmnfs/p86bensh/FORCAGE_OL"
+#-Q- fjvpp R_STOCKAGE="/G/nymphea0/dmnfs/p86bensh/FORCAGE_OL"
+#-- Original files : //dods.idris.fr/rpsl003
+#
+###-- Flags you should not touch 
+#
+OK_SITE=n
+#
+###-- Execution repository
+#
+MODIPSL=MMMMMMM
+R_EXE=${MODIPSL}/bin
+R_UTILITAIRES=${MODIPSL}/modeles/ORCHIDEE_OL/Utilitaire
+JOB=${CEXPER}
+#
+###-- A flag to add a level in your output repository
+###-- for example for different experiences with the same Job 
+#
+#FLAG= 
+#
+###-- Flag you should not touch (automatically set) 
+#
+OK_SITE=n
+#
+
+		#=============================================#
+		#          END OF USER MODIFICATIONS          #
+		#=============================================#
+
+
+#########################################################################
+##
+##    3. Repositories definition
+##
+#########################################################################
+###--  Data repository for input/output
+#
+R_DONNEES=/tmp/DATA/${CEXPER}
+#-Q- sxnec R_DONNEES=${WORKDIR}/DATA/${CEXPER}
+#-Q- sx6nec R_DONNEES=${SCRATCHDIR}/DATA/${CEXPER}
+#-Q- fjvpp R_DONNEES=${SCRATCHDIR}/DATA/${CEXPER}
+R_FICHIERS=SORTIES_CPL_IPSL/${CEXPER}
+#
+R_ENTREE_ORCHIDEE_OL=${R_DONNEES}/Entree/ORCHIDEE_OL
+R_SORTIE_ORCHIDEE_OL=${R_DONNEES}/Sortie/ORCHIDEE_OL
+R_FIC_ORCHIDEE_OL=${R_FICHIERS}/ORCHIDEE_OL
+#
+R_FIC_MORE=${R_FICHIERS}/More
+R_FIC_OUT=${R_FICHIERS}/Out
+R_FIC_EXE=${R_FICHIERS}/Exe
+R_FIC_MORE_U=${R_FIC_MORE}/Util
+
+#
+if [ ! -d ${R_DONNEES} ]; then
+  mkdir -p ${R_ENTREE_ORCHIDEE_OL}
+  mkdir -p ${R_SORTIE_ORCHIDEE_OL}
+fi
+#
+#-Q- sxnec mkdir -p ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}
+#-Q- sx6nec mkdir -p ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}
+
+###--  Some shell functions
+#- function to change the run.def
+remplace()
+{
+sed "/$1/D" run.def > r2
+cat <<END >>r2 
+$1=$2 
+END
+mv r2 run.def
+}
+
+#- commands for files transfers
+PUT="echo PUT"
+GET="echo GET"
+#-Q- sxnec PUT=mfput
+#-Q- sx6nec PUT=putfer 
+#-Q- fjvpp PUT=putcosmos
+#-Q- sxnec GET=mfget
+#-Q- sx6nec GET=getfer 
+#-Q- fjvpp GET=getcosmos
+#-Q- sxnec RSH='rsh rhodes exec /bin/ksh'
+#-Q- sx6nec RSH='rsh mercure exec /bin/ksh'
+#-Q- fjvpp RSH='remsh ixia exec /bin/ksh'
+#
+demigr="echo demigr"
+#-Q- fjvpp  demigr="/usr/local/bin/dmget"
+#-Q- sxnec  demigr="/usr/local/bin/mfget"
+#-Q- sx6nec demigr="dmget"
+
+MKDIR="mkdir"
+#-Q- fjvpp MKDIR="/usr/X11R6/bin/mkdirhier"
+#- creation de repertoire sur le serveur fichier sur Fujitsu seulement
+#-Q- fjvpp RMKDIR="mkdir -p ${DMFDIR}/"
+#-Q- fjvpp ${RMKDIR}/${R_FIC_ORCHIDEE_OL}
+#-Q- fjvpp DPUT () { ( [ -d "AAAAAAA/$2" ] || ${RMKDIR}/$2 ) & ( ${PUT} $1 $2/$3 ) }
+#-Q- sxnec DPUT () { ( ${PUT} $1 $2/$3 ) }
+#-Q- sx6nec RMKDIR="mkdir -p AAAAAAA"
+#-Q- sx6nec DPUT () { ( [ -d "AAAAAAA/$2" ] || ${RMKDIR}/$2 ) && ( ${PUT} $1 AAAAAAA/$2/$3 ) }
+#-Q- fjvpp DGET () { ( ${GET} $2/$1 $3/$1 ) }
+#-Q- sxnec DGET () { ( ${GET} $2/$1 $3/$1 ) }
+#-Q- sx6nec DGET () { ( ${GET} $2/$1 $3/$1 ) }
+
+#-Q- fjvpp ${RMKDIR}/${R_FIC_ORCHIDEE_OL}
+#-Q- fjvpp ${RMKDIR}/${R_FIC_EXE}
+#-Q- fjvpp ${RMKDIR}/${R_FIC_MORE}
+#-Q- fjvpp ${RMKDIR}/${R_FIC_MORE}"/"${FLAG}
+#-Q- fjvpp ${RMKDIR}/${R_FIC_OUT}
+#-Q- fjvpp ${RMKDIR}/${R_FIC_OUT"/"${FLAG}}
+#-Q- fjvpp ${RMKDIR}/${R_FIC_MORE_U}
+#
+
+###--  Work space (temporary)
+TMP=/tmp/${CEXPER}
+#-Q- sxnec TMP=${TMPDIR}/${CEXPER}
+#-Q- sx6nec ${MKDIR} ${SCRATCHDIR}/${CEXPER}
+#-Q- sx6nec TMP=${SCRATCHDIR}/${CEXPER}/${FLAG}
+#-Q- fjvpp ${MKDIR} ${SCRATCHDIR}/${CEXPER}
+#-Q- fjvpp TMP=${SCRATCHDIR}/${CEXPER}/${FLAG}
+#
+#-- Ceation if needed
+[ -d ${TMP} ] || ${MKDIR} ${TMP}
+#
+#########################################################################
+##
+##    4. Get initial files
+##
+#########################################################################
+##
+#-- Check if they are present 
+#--
+#-Q- sxnec Rapatrie () { [ -f $1/$2 ] || ( rcp ${R_STOCKAGE}/$2 $1 ;) }
+#-Q- sx6nec Rapatrie () { [ -f $1/$2 ] || ( getfer  ${R_STOCKAGE}/$2 $1 ;) }
+#-Q- fjvpp Rapatrie () { [ -f $1/$2 ] || ( cp  ${R_STOCKAGE}/$2 $1 ;) }
+#
+Rapatrie ${R_ENTREE_ORCHIDEE_OL} carteveg5km.nc || exit 1
+Rapatrie ${R_ENTREE_ORCHIDEE_OL} irrigated.nc 
+Rapatrie ${R_ENTREE_ORCHIDEE_OL} routing.nc || exit 1
+Rapatrie ${R_ENTREE_ORCHIDEE_OL} soils_param.nc || exit 1
+Rapatrie ${R_ENTREE_ORCHIDEE_OL} reftemp.nc || exit 1
+Rapatrie ${R_ENTREE_ORCHIDEE_OL} lai2D.nc || exit 1
+#
+##
+#-- We get the restart files if needed
+if [ "${no_restart}" = "n" ]
+then
+#-Q- sxnec rcp $RESTART_SECH ${R_ENTREE_ORCHIDEE_OL}/$sechiba_dem
+#-Q- sxnec rcp $RESTART_STOM ${R_ENTREE_ORCHIDEE_OL}/$stomate_dem
+#-Q- sxnec rcp RESTART_DRI ${R_ENTREE_ORCHIDEE_OL}/$moteur_dem
+#-Q- sx6nec getfer $RESTART_SECH ${R_ENTREE_ORCHIDEE_OL}/$sechiba_dem
+#-Q- sx6nec getfer $RESTART_STOM ${R_ENTREE_ORCHIDEE_OL}/$stomate_dem
+#-Q- sx6nec getfer $RESTART_DRI ${R_ENTREE_ORCHIDEE_OL}/$moteur_dem
+#-Q- fjvpp cp $RESTART_SECH ${R_ENTREE_ORCHIDEE_OL}/$sechiba_dem
+#-Q- fjvpp cp $RESTART_STOM ${R_ENTREE_ORCHIDEE_OL}/$stomate_dem
+#-Q- fjvpp cp $RESTART_DRI ${R_ENTREE_ORCHIDEE_OL}/$moteur_dem
+fi
+
+#########################################################################
+##
+##    5. Initialisations from the forcing file
+##
+#########################################################################
+##
+
+Rapatrie ${R_ENTREE_ORCHIDEE_OL} ${F_FILE}.nc || exit 1
+
+#-- If it is not a weather generator, we ask for the dates
+if [ -z "${JOUR_DEBUT_EXP}" ] && [ -z "${MOIS_DEBUT_EXP}" ] && [ -z "${AN_DEBUT_EXP}" ] && [ -z "${JOURS}" ] && [ -z "${MOIS}" } ] && [ -z "${ANS}" ] && [ -z "${JOUR_FINAL_EXP}" ] && [ -z "${MOIS_FINAL_EXP}" ] && [ -z "${AN_FINAL_EXP}" ] && [ "${OK_WEATHER}" = "n" ]
+
+then
+ [ -f ${R_UTILITAIRES}/recup_date.py ] && cp ${R_UTILITAIRES}/recup_date.py .
+#-Q- sxnec rcp rhodes:${R_UTILITAIRES}/recup_date.py .
+chmod +rx recup_date.py
+[ -f ${R_UTILITAIRES}/calend365.py ] && cp ${R_UTILITAIRES}/calend365.py .
+#-Q- sxnec rcp rhodes:${R_UTILITAIRES}/calend365.py .
+chmod +rx calend365.py
+[ -f ${R_UTILITAIRES}/sortie_date.py ] && cp ${R_UTILITAIRES}/sortie_date.py .
+#-Q- sxnec rcp rhodes:${R_UTILITAIRES}/sortie_date.py . 
+chmod +rx sortie_date.py
+ 
+DPUT recup_date.py ${R_FIC_MORE_U} recup_date.py
+DPUT calend365.py ${R_FIC_MORE_U} calend365.py
+DPUT sortie_date.py ${R_FIC_MORE_U} sortie_date.py
+
+${RSH}<<EOL
+export R_FIC_MORE_U=${R_FIC_MORE_U}
+export F_FILE=${F_FILE}
+export R_STOCKAGE=${R_STOCKAGE}
+cd AAAAAAA/${R_FIC_MORE_U}
+#-Q- fjvpp . /home/p86cadul/CDAT/cdat.login_ksh 
+#-Q- fjvpp /home/p86jype/CDAT/versions/CDAT_3.3_15_alpha/bin/python sortie_date.py ${R_STOCKAGE}/${F_FILE}.nc > fic.date
+#-Q- sxnec . /home/rech/ces/rces803/cdat.login_ksh
+#-Q- sxnec /home_b/rech/ces/rces599/PYTHON/CDAT/bin/python sortie_date.py ${R_STOCKAGE}/${F_FILE}.nc > fic.date
+#-Q- sx6nec export PATH=/workdir/p25jype/CDAT/versions/CDAT_4.0b1_16_ia64/bin:$PATH
+#-Q- sx6nec/workdir/p25jype/CDAT/versions/CDAT_4.0b1_16_ia64/bin/python sortie_date.py$ {R_STOCKAGE}/${F_FILE}.nc > fic.date
+EOL
+ 
+R_EXPER=${QSUB_WORKDIR:-${PWD}}	
+DGET fic.date ${R_FIC_MORE_U} ${R_EXPER} 
+AN_DEBUT_EXP=`awk '{print $1}' ${R_EXPER}/fic.date`
+MOIS_DEBUT_EXP=`awk '{print $2}' ${R_EXPER}/fic.date`   
+JOUR_DEBUT_EXP=`awk '{print $3}' ${R_EXPER}/fic.date`
+STEP_SEC=`awk '{print $4}' ${R_EXPER}/fic.date`
+TSTEP=`awk '{print $5}' ${R_EXPER}/fic.date`
+D_JOB_JOUR=`awk '{print $6}' ${R_EXPER}/fic.date`
+AN_FINAL_EXP=`awk '{print $7}' ${R_EXPER}/fic.date`
+MOIS_FINAL_EXP=`awk '{print $8}' ${R_EXPER}/fic.date`
+JOUR_FINAL_EXP=`awk '{print $9}' ${R_EXPER}/fic.date`
+fi
+DATE_DEBUT_EXP=$( printf "%04s%02s%02s\n" ${AN_DEBUT_EXP} ${MOIS_DEBUT_EXP} ${JOUR_DEBUT_EXP} )
+DATE_FINAL_EXP=$( printf "%04s%02s%02s\n" ${AN_FINAL_EXP} ${MOIS_FINAL_EXP} ${JOUR_FINAL_EXP} )
+
+# DATES is empty but could be used for future run
+DATES=
+if [ "${OK_SITE}" = "y" ] 
+then DATES=${DATE_DEBUT_EXP}_${DATE_FINAL_EXP}_
+fi
+#########################################################################
+##
+##    6. Pre-Processing
+##
+#########################################################################
+
+# ==============================================================================
+# Copy the atlas files if necessary
+# ==============================================================================
+if [ "${OK_DIAG}" = "y" ]
+then
+#-Q- sxnec rcp rhodes:${R_UTILITAIRES}/AA_atlas .
+#-Q- sx6nec cp ${R_UTILITAIRES}/AA_atlas .
+#-Q- fjvpp cp  ${R_UTILITAIRES}/AA_atlas .
+#-Q- sxnec sed -e "s,^#-Q- sxnec *,," AA_atlas | grep -v '^#-Q- ' > Job_atlas 
+#-Q- sx6nec sed -e "s,^#-Q- sx6nec *,," AA_atlas | grep -v '^#-Q- ' > Job_atlas 
+#-Q- fjvpp sed -e "s,^#-Q- fjvpp *,," AA_atlas | grep -v '^#-Q- ' > Job_atlas 
+rm -f AA_atlas
+DPUT Job_atlas ${R_FIC_MORE_U} Job_atlas
+fi
+
+if [ "${OK_SITE}" = "y" ]
+then
+#-Q- sxnec rcp rhodes:${R_UTILITAIRES}/Job_atlas .
+#-Q- sx6nec cp ${R_UTILITAIRES}/Job_atlas .
+#-Q- fjvpp cp  ${R_UTILITAIRES}/Job_atlas .
+DPUT Job_atlas ${R_FIC_MORE_U} Job_atlas
+#-Q- sxnec rcp rhodes:${R_UTILITAIRES}/Cabauw.cfg .
+#-Q- sx6nec cp ${R_UTILITAIRES}/Cabauw.cfg .
+#-Q- fjvpp cp  ${R_UTILITAIRES}/Cabauw.cfg .
+DPUT Cabauw.cfg ${R_FIC_MORE_U} Cabauw.cfg
+fi
+
+# =============================================================================
+# Time loop : this part should be useful to built a job following IPSL_CM4_v1
+# =============================================================================
+##-- repertoire de controle des enchainements
+#-Q- sxnec R_EXPER=${QSUB_WORKDIR:-${PWD}}
+#-Q- sx6nec R_EXPER=${MODIPSL}/modeles/ORCHIDEE_OL/EXP00 
+#cd ${R_EXPER}
+##
+##- creation de ${JOB}.suivi qui contient la date du run en cours ou du run
+##- en attente et de ${JOB}.log qui contient la trace des exeutions
+##
+#DATE_DEBUT_EXP=$( printf "%04s%02s%02s\n" ${AN_DEBUT_EXP} ${MOIS_DEBUT_EXP} ${JOUR_DEBUT_EXP} )
+#DATE_FIN_EXP=$( printf "%04s%02s%02s\n" ${AN_FINAL_EXP} ${MOIS_FINAL_EXP} ${JOUR_FINAL_EXP} )
+#
+#if [ ! -f "${JOB}.suivi" ]
+#then
+#    JOUR_DEB_JOB=${JOUR_DEBUT_EXP} ; MOIS_DEB_JOB=${MOIS_DEBUT_EXP} ; AN_DEB_JOB=${AN_DEBUT_EXP}
+#    NUMERO=1
+#cat <<EOF >${JOB}.suivi
+#${AN_DEB_JOB} ${MOIS_DEB_JOB} ${JOUR_DEB_JOB} ${NUMERO}
+#EOF
+#echo `date` " Begining of Experience : " ${JOB} " in directory :" ${R_EXPER} > ${JOB}.log
+#fi
+#
+#cat ${JOB}.suivi | read AN_DEB_JOB MOIS_DEB_JOB JOUR_DEB_JOB NUMERO
+#echo ${AN_DEB_JOB} ${MOIS_DEB_JOB} ${JOUR_DEB_JOB}
+#echo "`date` $AN_DEB_JOB $MOIS_DEB_JOB $JOUR_DEB_JOB begin" >> ${JOB}.log
+##--
+
+# ==============================================================================
+# Copy thz binary files
+# ==============================================================================
+if [ -z ${TMP} ]; then
+  echo " the variable TMP is empty !!!" 
+  exit
+fi
+cd ${TMP} || exit
+#- Clean the work space
+rm -f *
+# ----------------- ORCHIDEE_OL ---------------------
+[ -f ${R_EXE}/orchidee_ol ] && cp ${R_EXE}/orchidee_ol orchidee.e
+[ -f ${R_EXE}/teststomate ] && cp ${R_EXE}/teststomate teststomate.e
+[ -f ${R_EXE}/forcesoil ] && cp ${R_EXE}/forcesoil forcesoil.e
+#-Q- sxnec rcp rhodes:${R_EXE}/orchidee_ol orchidee.e && chmod +x orchidee.e
+#-Q- sxnec rcp rhodes:${R_EXE}/teststomate teststomate.e && chmod +x teststomate.e
+#-Q- sxnec rcp rhodes:${R_EXE}/forcesoil forcesoil.e && chmod +x forcesoil.e
+  DPUT orchidee.e ${R_FIC_EXE}/${FLAG} ${CEXPER}_"${DATES}"orchidee.e
+  DPUT teststomate.e ${R_FIC_EXE}/${FLAG} ${CEXPER}_"${DATES}"teststomate.e
+  DPUT forcesoil.e ${R_FIC_EXE}/${FLAG} ${CEXPER}_"${DATES}"forcesoil.e
+# ==============================================================================
+# Copy the map
+# ==============================================================================
+cp ${R_ENTREE_ORCHIDEE_OL}/lai2D.nc .
+cp ${R_ENTREE_ORCHIDEE_OL}/carteveg5km.nc .
+cp ${R_ENTREE_ORCHIDEE_OL}/irrigated.nc . 
+cp ${R_ENTREE_ORCHIDEE_OL}/routing.nc . 
+cp ${R_ENTREE_ORCHIDEE_OL}/soils_param.nc .
+cp ${R_ENTREE_ORCHIDEE_OL}/reftemp.nc .
+cp ${R_ENTREE_ORCHIDEE_OL}/${F_FILE}.nc .
+if [ "${no_restart}" = "n" ]
+then
+cp ${R_ENTREE_ORCHIDEE_OL}/$sechiba_dem .
+cp ${R_ENTREE_ORCHIDEE_OL}/$stomate_dem .
+cp ${R_ENTREE_ORCHIDEE_OL}/$moteur_dem .
+fi
+
+# Copy the run.def
+# ==============================================================================
+cp ${R_EXPER}/${F_RUN}.def run.def
+
+remplace OUTPUT_FILE $sechiba_hist
+remplace STOMATE_OUTPUT_FILE $stomate_hist
+
+# change the flags in the run.def
+remplace RESTART_FILEIN $moteur_dem
+remplace RESTART_FILEOUT $moteur_redem
+remplace SECHIBA_restart_in $sechiba_dem
+remplace SECHIBA_rest_out $sechiba_redem
+remplace STOMATE_RESTART_FILEIN $stomate_dem
+remplace STOMATE_RESTART_FILEOUT $stomate_redem
+
+if  [ "${OK_SITE}" = "n" ]
+then
+remplace FORCING_FILE ${F_FILE}.nc
+remplace SECHIBA_HISTLEVEL $sechistlev
+remplace WRITE_STEP $sechistdt
+remplace ALLOW_WEATHERGEN $OK_WEATHER
+remplace MERID_RES $resolution_LON
+remplace ZONAL_RES $resolution_LAT
+remplace LIMIT_WEST $limit_west
+remplace LIMIT_EAST $limit_east
+remplace LIMIT_NORTH $limit_north
+remplace LIMIT_SOUTH $limit_south
+
+fi
+
+ls -alF
+
+# loop counter
+let annee=0
+
+#########################################################################
+##
+##    7. Here comes the run
+##
+#########################################################################
+#
+#-Q- sxnec # nb d erreurs admises sur le NEC
+#-Q- sxnec export F_ERRCNT=999999
+#-Q- sx6nec # nb d erreurs admises sur le NEC
+#-Q- sx6nec export F_ERRCNT=999999
+#-Q- sx6nec export MPIPROGINF=all
+#-Q- sx6nec # nb max de caracteres par ligne dans le fichier d'output 
+#-Q- sx6nec export F_SYSLEN=5000
+#-Q- sxnec unset F_PROGINF
+#-Q- sx6nec unset MPIPROGINF
+ls -alF
+ls -lrt
+
+# when we do not have any restart file
+#
+if [ $no_restart = 'y' ] ; then
+
+let annee=0
+
+let iter=0
+  
+remplace RESTART_FILEIN NONE
+remplace SECHIBA_restart_in NONE
+remplace STOMATE_RESTART_FILEIN NONE
+
+if [ $duree_nostomate -ne 0 ] ; then
+
+let annee=$annee+$duree_nostomate
+
+echo "we do "$duree_nostomate "year(s) without stomate to create a restart file"
+  
+remplace STOMATE_OK_CO2 $ok_co2
+remplace STOMATE_OK_STOMATE n
+remplace STOMATE_OK_DGVM n
+remplace STOMATE_WATCHOUT y
+  
+remplace TIME_LENGTH $duree_nostomate$units
+  
+time ./orchidee.e > out_orchidee"${annee}"
+
+# save the job output file
+DPUT out_orchidee"${annee}" ${R_FIC_OUT}"/"${FLAG} .
+# save the run.def
+cp used_run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_used_run.def
+DPUT used_run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_used_run.def
+cp run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_run.def
+DPUT run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_run.def
+# save history files
+DPUT $sechiba_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_sechiba_history.nc
+mv  $sechiba_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_sechiba_history.nc
+[ -f $stomate_hist ] && DPUT $stomate_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+[ -f $stomate_hist ] && mv  $stomate_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+# rename restart files
+mv $moteur_redem $moteur_dem
+mv $sechiba_redem $sechiba_dem
+[ -f $stomate_redem ] && mv $stomate_redem $stomate_dem
+# save restart files
+DPUT $moteur_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${moteur_dem}
+DPUT $sechiba_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${sechiba_dem}
+[ -f $stomate_dem ] && DPUT $stomate_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${stomate_dem}
+
+if [ "${OK_WEATHER}" = "y" ] ; then
+remplace RESTART_FILEIN $moteur_dem
+fi
+remplace SECHIBA_restart_in $sechiba_dem
+remplace STOMATE_RESTART_FILEIN $stomate_dem
+
+fi	# duree_nostomate
+
+remplace STOMATE_WATCHOUT n
+
+if [ $duree_offlineini -ne 0 ] ; then
+ 
+let annee=$annee+$duree_offlineini
+ 
+remplace STOMATE_OK_STOMATE y
+remplace STOMATE_OK_DGVM n
+remplace STOMATE_HISTLEVEL $stohistlev_sto
+remplace STOMATE_HIST_DT $stohistdt_sto
+
+echo "We do "$duree_offlineini "year(s) with teststomate, without DGVM, for spinup."
+
+remplace TIME_LENGTH $duree_offlineini$units
+
+time ./teststomate.e > out_testomate"${annee}" 
+
+# save job output file
+DPUT out_testomate"${annee}" ${R_FIC_OUT}"/"${FLAG} .
+# save the run.def
+cp used_run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_used_run.def
+DPUT used_run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_used_run.def
+cp run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_run.def
+DPUT run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_run.def
+# save history files
+DPUT $stomate_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+mv  $stomate_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+# rename restart files
+mv $moteur_redem $moteur_dem
+mv $sechiba_redem $sechiba_dem
+mv $stomate_redem $stomate_dem
+# save restart files
+DPUT $moteur_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${moteur_dem}
+DPUT $sechiba_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${sechiba_dem}
+DPUT $stomate_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${stomate_dem}
+
+if [ "${OK_WEATHER}" = "y" ] ; then
+remplace RESTART_FILEIN $moteur_dem
+fi
+remplace SECHIBA_restart_in $sechiba_dem
+remplace STOMATE_RESTART_FILEIN $stomate_dem
+
+fi	# duree_offlineini
+
+if [ $duree_inistomate -ne 0 ] ; then
+
+let annee=$annee+$duree_inistomate
+
+remplace STOMATE_OK_STOMATE y
+remplace STOMATE_OK_DGVM n
+remplace STOMATE_HISTLEVEL $stohistlev_sec
+remplace STOMATE_HIST_DT $stohistdt_sec
+
+echo "We do "$duree_inistomate "year(s) with stomate, without DGVM, for spinup." 
+ 
+remplace TIME_LENGTH $duree_inistomate$units
+ 
+time ./orchidee.e > out_orchidee"${annee}"
+
+# save job output file    
+DPUT out_orchidee"${annee}" ${R_FIC_OUT}"/"${FLAG} . 
+# save the run.def
+cp used_run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_used_run.def
+DPUT used_run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_used_run.def
+cp run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_run.def
+DPUT run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_run.def
+# save history files
+DPUT $sechiba_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_sechiba_history.nc
+mv  $sechiba_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_sechiba_history.nc
+[ -f $stomate_hist ] && DPUT $stomate_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+[ -f $stomate_hist ] && mv  $stomate_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+# rename restart files
+mv $moteur_redem $moteur_dem
+mv $sechiba_redem $sechiba_dem
+[ -f $stomate_redem ] && mv $stomate_redem $stomate_dem
+# save restart files
+DPUT $moteur_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${moteur_dem}
+DPUT $sechiba_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${sechiba_dem}
+[ -f $stomate_dem ] && DPUT $stomate_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${stomate_dem}
+
+if [ "${OK_WEATHER}" = "y" ] ; then
+remplace RESTART_FILEIN $moteur_dem
+fi
+remplace SECHIBA_restart_in $sechiba_dem
+remplace STOMATE_RESTART_FILEIN $stomate_dem
+
+fi	# duree_inistomate
+
+fi	# no_restart
+
+# after the restart part
+#
+if  [ "${OK_SITE}" = "n" ]
+then
+remplace STOMATE_OK_STOMATE $ok_stomate
+remplace STOMATE_OK_DGVM $ok_dgvm
+fi
+
+# iteration counter
+let i=0
+
+while [ $i -lt $n_iter ] ; do
+
+let i=i+1
+
+echo
+echo =====================
+echo ITERATION : $i
+echo =====================
+
+if [ $duree_sechiba -ne 0 ] ; then
+
+# start with orchidee_ol
+  
+echo 
+echo orchidee_ol
+echo 
+
+let annee=$annee+$duree_sechiba
+  
+if  [ "${OK_SITE}" = "n" ]
+then
+    remplace TIME_LENGTH $duree_sechiba$units
+else
+remplace TIME_LENGTH 1Y
+remplace WRITE_STEP 86400
+fi
+remplace STOMATE_HISTLEVEL $stohistlev_sec
+remplace STOMATE_HIST_DT $stohistdt_sec
+  
+time ./orchidee.e > out_orchidee"${annee}"
+
+# save job output file
+DPUT out_orchidee"${annee}" ${R_FIC_OUT}"/"${FLAG} .
+# save the run.def
+cp used_run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_used_run.def
+DPUT used_run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_used_run.def
+cp run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_run.def
+DPUT run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_run.def
+# on sauvegarde les fichiers d'histoire
+DPUT $sechiba_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_sechiba_history.nc
+mv  $sechiba_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_sechiba_history.nc
+[ -f $stomate_hist ] && DPUT $stomate_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+[ -f $stomate_hist ] && mv  $stomate_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+# rename restart files
+mv $moteur_redem $moteur_dem
+mv $sechiba_redem $sechiba_dem
+[ -f $stomate_redem ] && mv $stomate_redem $stomate_dem
+# save restart files
+DPUT $moteur_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${moteur_dem}
+DPUT $sechiba_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${sechiba_dem}
+[ -f $stomate_dem ] && DPUT $stomate_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${stomate_dem}
+
+fi	#duree_sechiba 
+
+# at least now
+remplace STOMATE_RESTART_FILEIN $stomate_dem
+remplace SECHIBA_restart_in $sechiba_dem
+
+if [ $duree_stomate -ne 0 ] ; then
+
+# follow with teststomate
+
+echo
+echo teststomate
+echo
+
+let annee=$annee+$duree_stomate
+
+remplace TIME_LENGTH $duree_stomate$units
+
+remplace STOMATE_HISTLEVEL $stohistlev_sto
+remplace STOMATE_HIST_DT $stohistdt_sto
+
+time ./teststomate.e > out_teststomate"${annee}"
+
+# save job output file
+DPUT out_teststomate"${annee}" ${R_FIC_OUT}"/"${FLAG} .
+# save the run.def
+cp used_run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_used_run.def
+DPUT used_run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_used_run.def
+cp run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_run.def
+DPUT run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_run.def
+# save history files
+DPUT $stomate_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+mv  $stomate_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_stomate_history.nc
+# rename restart files
+mv $moteur_redem $moteur_dem
+mv $sechiba_redem $sechiba_dem
+mv $stomate_redem $stomate_dem
+# save restart files
+DPUT $moteur_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${moteur_dem}
+DPUT $sechiba_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${sechiba_dem}
+DPUT $stomate_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${stomate_dem}
+
+fi	# duree_stomate
+done    #n_iter
+
+if [ $duree_carbonsol -ne 0 ] ; then
+
+# end with forcesoil
+
+echo
+echo forcesoil
+echo
+
+let annee=$annee+$duree_carbonsol
+
+remplace TIME_LENGTH $duree_carbonsol$units
+
+time ./forcesoil.e > out_forcesoil"${annee}"
+
+# save job output file
+DPUT out_forcesoil"${annee}" ${R_FIC_OUT}"/"${FLAG} . 
+# save the run.def
+cp used_run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_used_run.def
+DPUT used_run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_used_run.def
+cp run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_run.def
+DPUT run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_run.def
+# rename restart file for stomate
+mv $stomate_redem $stomate_dem
+# save restart file for stomate
+DPUT $stomate_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${stomate_dem}
+
+fi	# duree_carbonsol
+ 
+
+if [ $duree_final -ne 0 ] ; then
+
+# on finit avec orchidee_ol
+
+echo
+echo "We do "$duree_final "year(s) to have a happy end"
+echo
+
+let annee=$annee+$duree_final
+ 
+echo
+echo orchidee_ol
+echo
+ 
+if  [ "${OK_SITE}" = "n" ]
+then
+remplace TIME_LENGTH $duree_final$units
+else
+remplace TIME_LENGTH default
+remplace WRITE_STEP 1800
+fi
+remplace STOMATE_HISTLEVEL $stohistlev_sec
+remplace STOMATE_HIST_DT $stohistdt_sec
+
+time ./orchidee.e > out_orchidee"${annee}"
+
+# save job output file
+DPUT out_orchidee"${annee}" ${R_FIC_OUT}"/"${FLAG} . 
+# save the run.def
+cp used_run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_used_run.def
+DPUT used_run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_used_run.def
+cp run.def ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_run.def
+DPUT run.def ${R_FIC_MORE}"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_run.def
+# save history files
+DPUT $sechiba_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_sechiba_history.nc
+mv  $sechiba_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_sechiba_history.nc
+[ -f $stomate_hist ] && DPUT $stomate_hist ${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG} ${CEXPER}_${DATES}${annee}_stomate_history.nc
+[ -f $stomate_hist ] && mv  $stomate_hist ${R_SORTIE_ORCHIDEE_OL}"/"${FLAG}/${CEXPER}_"${DATES}"${annee}_stomate_history.nc 
+# rename restart files
+mv $moteur_redem $moteur_dem
+mv $sechiba_redem $sechiba_dem
+[ -f $stomate_redem ] && mv $stomate_redem $stomate_dem 
+# on sauvegarde les fichiers de redemarrage
+DPUT $moteur_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${moteur_dem}
+DPUT $sechiba_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${sechiba_dem}
+[ -f $stomate_dem ] && DPUT $stomate_dem ${R_FIC_ORCHIDEE_OL}"/"Restart"/"${FLAG} ${CEXPER}_"${DATES}"${annee}_${stomate_dem}
+ 
+fi	#duree_final
+
+#########################################################################
+##
+##    9. Output
+##
+#########################################################################
+
+#-Q- sxnec qcat -o ${QSUB_REQID} > ${CEXPER}"${DATES}"_${FLAG}_job_output
+#-Q- fjvpp qcat -o ${QSUB_REQID} > ${CEXPER}"${DATES}"${FLAG}_job_output
+#-Q- sx6nec VAR=$(echo ${PBS_JOBID} | sed -e "s@.*:\(.*\)\..*@\1@")
+#-Q- sx6nec rsh mercure -n "export TMP=${TMP} ; cd ${TMP} ; /usr/local/TX7/bin/qcat ${VAR} > ${CEXPER}"${DATES}"${FLAG}_job_output"
+DPUT ${CEXPER}"${DATES}"${FLAG}_job_output ${R_FIC_OUT} ${CEXPER}"${DATES}"${FLAG}_job_output
+
+#########################################################################
+##
+##    10. Post Processing
+##
+#########################################################################
+#
+
+if  [ "${OK_SITE}" = "y" ] || [ "${OK_DIAG}" = "y" ] 
+then
+${RSH}<<EOL
+export R_FIC_ORCHIDEE_OL=${R_FIC_ORCHIDEE_OL}
+export R_FIC_MORE_U=${R_FIC_MORE_U}
+export FLAG=${FLAG}
+export CEXPER=${CEXPER}
+export F_FILE=${F_FILE}
+export DATES=${DATES}
+export AN_DEBUT_EXP=${AN_DEBUT_EXP}
+export AN_FINAL_EXP=${AN_FINAL_EXP}
+export CEXPER=${CEXPER}
+export NITER_MAX=${annee}
+export OK_SITE=${OK_SITE}
+cd AAAAAAA/${R_FIC_MORE_U}
+#-Q- sxnec  /usr/local/bin/qsub -x Job_atlas
+#-Q- sx6nec /usr/bin/nqsII/qsub  -q scalaire -V Job_atlas
+#-Q- fjvpp /usr/local/bin/qsub -x Job_atlas
+EOL
+fi
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/job.run
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/job.run	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/job.run	(revision 405)
@@ -0,0 +1,156 @@
+#!/bin/ksh
+#  $Header: /home/ssipsl/CVSREP/ORCHIDEE_OL/EXP00/job.run,v 1.3 2004/10/22 14:48:49 ssipsl Exp $
+##  @$-q test
+##  @$-lT 3600
+##  @$-lM 0mb
+##  @$-eo
+## Job de soumission de ORCHIDEE_OL
+##  
+##
+##      Rachid BENSHILA & Patricia CADULE
+##########################################################
+#
+#        DEFINITIONS DES OPTIONS
+#
+##########################################################
+##
+                #- Saisie et validation des options
+x_q='';
+x_t="";
+x_s="Cabauw";
+x_f="SECHIBA";
+x_n="0";
+x_e="Test";
+while getopts :hqt:s:f:n:d:e: V
+  do
+    case $V in
+      (h)  echo "Usage    : "${b_n} \
+		" [-h] [-q] [-t h]  [-s x] [-f y] [-n nbre] [-e exp]";
+	   echo " -h       : help";
+	   echo " -q       : quiet";
+	   echo " -t h     : target host_name";
+	   echo " -s x     : Site";
+	   echo " -f y     : Flag";
+	   echo " -n nbre  : Initialization";
+	   echo " -e exp   : Experience name";
+	   echo "Defaults  : -t local_host";
+	   echo "Defaults  : -s Cabauw";
+	   echo "Defaults  : -f SECHIBA";
+	   echo "Defaults  : -n 0";
+	   echo "Defaults  : -e Test ";
+	   exit 0;;
+      (q)  x_q=1;;
+      (t)  x_t=${OPTARG};;
+      (s)  x_s=${OPTARG};;
+      (f)  x_f=${OPTARG};;
+      (n)  x_n=${OPTARG};;
+      (e)  x_e=${OPTARG};;
+      (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
+	   exit 2;;
+      (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
+	   exit 2;;
+    esac
+  done
+##
+#########################################################################
+##
+##       Initialisation  
+##
+#########################################################################
+##
+## BEGINING OF USER MODIFICATIONS
+##
+####################
+# Experience dates #
+####################  
+##
+##-- First day of experience
+#JOUR_DEBUT_EXP=1  ; MOIS_DEBUT_EXP=1  ; AN_DEBUT_EXP=1987
+##--
+##-- Last day of experience
+#JOUR_FINAL_EXP=31  ; MOIS_FINAL_EXP=12 ; AN_FINAL_EXP=1987
+##--
+##--  Job lenght
+#JOURS=0 ; MOIS=0 ; ANS=1
+##
+####################
+# Job iteration    #
+####################
+##
+#NITER_MAX=5
+##
+########################
+# Nom du repertoire    #
+########################
+##
+#D_NAME=Test
+##
+##############################
+##                           #
+## END OF USER MODIFICATIONS #
+##                           #
+##############################
+D_NAME=${x_e}
+##-- fichier de forcage
+F_FILE=${x_s}
+export F_FILE=${F_FILE}
+##-- iteration
+NITER_MAX=${x_n}
+##-- flag    
+if [ ${x_f} = all ]; then
+x_f="SECHIBA OK_CO2 OK_STOMATE"
+fi;
+typeset -R rach
+set -A rach 3 ${x_f}
+
+##-- repertoire de stockage et de lancement, plate-forme
+R_STOCKAGE=""
+
+if [ '\?'${x_t} = '\?' ]; then
+x_t=`../../../util/w_i_h`  ;
+fi
+
+if [ "${x_t}" = "sxnec" ]; then
+rsh uqbar mkdir ${WORKDIR}/${D_NAME}
+R_STOCKAGE="/u/rech/ces/rces803/FORCAGE_OL"
+R_SH="rsh uqbar  -n "
+R_SUB=${WORKDIR}/${D_NAME}
+QSUB="qsub -x"
+elif [ "${x_t}" = "fjvpp" ]; then
+R_STOCKAGE="/G/nymphea0/dmnfs/p86bensh/FORCAGE_OL"
+R_SH="remsh nymphea0 -n "
+R_SUB=${QSUB_WORKDIR:-${PWD}}
+QSUB="qsub -x"
+elif [ "${x_t}" = "sx6nec" ]; then
+R_STOCKAGE="/dmnfs/p86bensh/FORCAGE_OL"
+R_SH="rsh mercure0  "
+R_SUB=${QSUB_WORKDIR:-${PWD}}
+QSUB="/usr/bin/nqsII/qsub -q prod -V"
+fi
+export R_STOCKAGE=${R_STOCKAGE}
+
+##Scripts d'Atlas
+if [ ! -f ../Utilitaire/Job_atlas ]; then
+sed -e "s,^#-Q- "${x_t}" *,," ../Utilitaire/AA_atlas | grep -v '^#-Q- ' > ../Utilitaire/Job_atlas 
+fi
+
+##-- repertoire de controle des enchainements
+ x_m=$(pwd) 
+for i in 1 2 3
+do
+if [ -n "${rach[i]}" ] 
+ then
+  ../../../util/ins_script -t ${x_t} -n ${F_FILE}_${rach[i]}
+   make -f make_ORCHIDEE ${rach[i]}  || exit 1
+   sed -e "s/F_FILE=WG_cru/F_FILE=${F_FILE}/g" -e "s/#FLAG=/FLAG=${rach[i]}/g" -e "s/OK_SITE=n/OK_SITE=y/g" -e "s/F_RUN=orchidee/F_RUN=${F_FILE}_${rach[i]}/g" -e "s/CEXPER=${F_FILE}_${rach[i]}/CEXPER=${D_NAME}/g" -e "s/OK_WEATHER=y/OK_WEATHER=n/g" -e "s/duree_sechiba=0/duree_sechiba=1/g" -e "s/n_iter=0/n_iter=${x_n}/g" Job_${F_FILE}_${rach[i]} >Job_${rach[i]}.tmp 
+   mv Job_${rach[i]}.tmp Job_${F_FILE}_${rach[i]}
+ if [ "${x_q}" != 1 ]; then
+   if [ "${x_t}" = "sxnec" ]; then
+	ftput -h uqbar $(pwd)/Job_${F_FILE}_${rach[i]} ${WORKDIR}/${D_NAME}/Job_${F_FILE}_${rach[i]} || exit 1
+	ftput -h uqbar $(pwd)/${F_FILE}_${rach[i]}.def ${WORKDIR}/${D_NAME}/${F_FILE}_${rach[i]}.def || exit 1
+       fi
+       ${R_SH} "export F_FILE=${F_FILE} ; export FLAG=${rach[i]} ; export JOUR_DEBUT_EXP=${JOUR_DEBUT_EXP} ; export MOIS_DEBUT_EXP=${MOIS_DEBUT_EXP} ; export AN_DEBUT_EXP=${AN_DEBUT_EXP} ; export JOUR_FINAL_EXP=${JOUR_FINAL_EXP} ; export MOIS_FINAL_EXP=${MOIS_FINAL_EXP} ;  export AN_FINAL_EXP=${AN_FINAL_EXP} ; export JOURS=${JOURS} ; export MOIS=${MOIS} ; export ANS=${ANS} ; export NITER_MAX=${NITER_MAX} ; export D_NAME=${D_NAME}  ; export F_RUN=${F_FILE}_${rach[i]} ; cd ${R_SUB} ;  ${QSUB} Job_${F_FILE}_${rach[i]}"
+     fi   
+    fi
+    done
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/make_ORCHIDEE
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/make_ORCHIDEE	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/make_ORCHIDEE	(revision 405)
@@ -0,0 +1,32 @@
+#- 
+#---------------------------------------------------------------------
+#- Creation des elements relatifs a ORCHIDEE :
+#-      ORCHIDEE (creation du run.def en fonction du flag)
+##      $Header: /home/ssipsl/CVSREP/ORCHIDEE_OL/EXP00/make_ORCHIDEE,v 1.2 2004/03/29 12:17:43 ssipsl Exp $
+##
+##      Rachid BENSHILA & Patricia CADULE
+#---------------------------------------------------------------------
+#!/bin/ksh
+#---------------------------------------------------------------------
+# This script aims to construct a run.def for pre-defined namelist available at dods.ipsl.jussieu.fr/orchidee
+# You can add some flags using sed
+# Example : sed -e "s/# STOMATE_OK_STOMATE is not set/STOMATE_OK_STOMATE=y/g" -e "s/HYDROL_CWRR=n/HYDROL_CWRR=y/g" $${F_FILE}.def
+
+all : SECHIBA OK_CO2 OK_STOMATE
+
+SECHIBA :
+	( cp ${R_STOCKAGE}/${F_FILE}.def ${F_FILE}.def ; cp $${F_FILE}.def  ${F_FILE}_SECHIBA.def ;)
+	rm  -f ${F_FILE}.def
+
+OK_CO2 :
+	( cp ${R_STOCKAGE}/${F_FILE}.def ${F_FILE}.def  ; sed "s/# STOMATE_OK_CO2 is not set/STOMATE_OK_CO2=y/g" $${F_FILE}.def > ${F_FILE}_OK_CO2.def ;)
+	rm  -f ${F_FILE}.def
+
+
+OK_STOMATE :
+	( cp ${R_STOCKAGE}/${F_FILE}.def ${F_FILE}.def ; sed "s/# STOMATE_OK_STOMATE is not set/STOMATE_OK_STOMATE=y/g" $${F_FILE}.def > ${F_FILE}_OK_STOMATE.def;)
+	rm  -f ${F_FILE}.def
+
+
+
+ 
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/orchidee.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/orchidee.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/EXP00/orchidee.def	(revision 405)
@@ -0,0 +1,131 @@
+#
+# Namelist for ORCHIDEE
+#
+#
+#************************************************************************************
+# Parametrization :
+#------------------------------------------------------------------------------------
+STOMATE_OK_CO2=y
+STOMATE_OK_STOMATE=n
+STOMATE_OK_DGVM=n
+LPJ_GAP_CONST_MORT=y
+#
+# Model chatting level
+#------------------------------------------------------------------------------------
+BAVARD=1
+ALMA_OUTPUT=n
+# To reset the time coming from SECHIBA restart file
+#------------------------------------------------------------------------------------
+SECHIBA_reset_time=y
+#
+#************************************************************************************
+#          Files : incoming / forcing / restart /output
+#************************************************************************************
+# Ancillary files :
+#------------------------------------------------------------------------------------
+VEGETATION_FILE=carteveg5km.nc
+SOILALB_FILE=soils_param.nc
+SOILTYPE_FILE=soils_param.nc
+ROUTING_FILE=routing.nc
+REFTEMP_FILE=reftemp.nc
+LAI_FILE=lai2D.nc
+#
+# Forcing file name
+FORCING_FILE=Cabauw.nc
+#
+# Input and output restart file for the driver
+#------------------------------------------------------------------------------------
+RESTART_FILEIN=default
+RESTART_FILEOUT=driver_rest_out.nc
+#
+# Input and output restart file for SECHIBA :
+#------------------------------------------------------------------------------------
+SECHIBA_restart_in=NONE
+SECHIBA_rest_out=sechiba_rest_out.nc
+#
+# Input and output restart file for STOMATE :
+#------------------------------------------------------------------------------------
+STOMATE_RESTART_FILEIN=NONE
+STOMATE_RESTART_FILEOUT=stomate_rest_out.nc
+#
+# Forcing files for TESTSTOMATE and FORCESOIL
+#------------------------------------------------------------------------------------
+STOMATE_FORCING_NAME=stomate_forcing.nc
+STOMATE_CFORCING_NAME=stomate_Cforcing.nc
+#
+# Output file name (SECHIBA puis STOMATE) :
+#------------------------------------------------------------------------------------
+OUTPUT_FILE=sechiba_history.nc
+STOMATE_OUTPUT_FILE=stomate_history.nc
+#
+# Write levels for outputs files (number of variables) :
+#------------------------------------------------------------------------------------
+SECHIBA_HISTLEVEL=5
+STOMATE_HISTLEVEL=10
+#
+# Write frequency for output files (SECHIBA in seconds et
+# STOMATE in days) :
+#------------------------------------------------------------------------------------
+WRITE_STEP=1800.0
+STOMATE_HIST_DT=10.
+#
+#************************************************************************************
+#                             Area location
+#************************************************************************************
+LIMIT_WEST=-180.
+LIMIT_EAST=180.
+LIMIT_NORTH=90.
+LIMIT_SOUTH=-90.
+##************************************************************************************
+#                       Simulation parameters
+#************************************************************************************
+# Weather generator or not :
+#------------------------------------------------------------------------------------
+ALLOW_WEATHERGEN=y
+IPPREC=0
+DT_WEATHGEN=1800.
+WEATHGEN_PRECIP_EXACT=n
+DUMP_WEATHER=n
+INTER_LIN=n
+#
+# lenth of simulation :
+#------------------------------------------------------------------------------------
+TIME_LENGTH=default
+#
+# split time step :
+#------------------------------------------------------------------------------------
+SPLIT_DT=1
+TIME_SKIP=0
+#
+# parameters describing the surface (vegetation + soil) :
+#------------------------------------------------------------------------------------
+#
+SLOWPROC_LAI_TEMPDIAG=280.
+#
+
+CONDVEG_SNOWA=default
+#
+# surface initializtion :
+ENERBIL_TSURF=280.
+HYDROL_SNOW=0.0
+HYDROL_SNOWAGE=0.0
+HYDROL_SNOW_NOBIO=0.0
+HYDROL_SNOW_NOBIO_AGE=0.0
+HYDROL_HDRY=0.0
+HYDROL_HUMR=1.0
+HYDROL_BQSB=default
+HYDROL_GQSB=0.0
+HYDROL_DSG=0.0
+HYDROL_DSP=default
+HYDROL_QSV=0.0
+THERMOSOIL_TPRO=280.
+DIFFUCO_LEAFCI=233.
+
+# read the LAI :
+LAI_MAP=n
+
+HYDROL_CWRR=n
+AGRICULTURE=n
+
+RIVER_ROUTING=n
+ROUTING_RIVERS=50
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/Job_FLUXNET_validation
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/Job_FLUXNET_validation	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/Job_FLUXNET_validation	(revision 405)
@@ -0,0 +1,367 @@
+#!/bin/ksh
+
+# $Date: 2010/06/25 19:03:52 $
+# $Author: ssipsl $
+# $Revision: 1.13 $
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
+
+#D--------------------------------------------------------------------==
+#D--------------------------------------------------------------------==
+#D-
+#D-                      Job to launch FLUXNET spinup simulations
+#D-
+#D--------------------------------------------------------------------==
+#D--------------------------------------------------------------------==
+#D-
+#                       Job inspired from Sönke Zaehle "site_new.def" job
+#                       #################################################
+
+
+
+MODIPSL=::modipsl::
+libIGCM=${MODIPSL}/libIGCM
+
+# All SubJobs in SPINUP in ONE OR MORE YEARS run (must be used with libIGCM branches/AllPostFred). 
+
+
+
+#D--------------------------------------------------------------------==
+#D-                   -1. User modification place
+#D--------------------------------------------------------------------==
+
+#D- Increased verbosity (1, 2, 3)
+#Verbosity=3
+
+#D-
+# --------------------------------------------------------------------
+#D- ! Optionnal features /!\ Use with care !
+# --------------------------------------------------------------------
+
+#D- Low level debug : to bypass lib test checks and stack construction
+#D- Default=true
+DEBUG_debug=false
+
+#D- Set DEBUG_sys to false to disable output calls of function
+#D- Default=true
+#DEBUG_sys=false
+
+#D- Turn in dry run mode ? (0,1,2,3)
+#D- Default=0
+#DRYRUN=3
+# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
+# -------------------------------------------------------------------------------------
+# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+# |          |  Cp/Exe param files |            |  Chmod  |                           |
+# |          |      Qsub           |            |         |                           |
+# -------------------------------------------------------------------------------------
+# |    0     |       yes           |    yes     |  yes    |      yes                  |
+# -------------------------------------------------------------------------------------
+# |    1     |       yes           |    yes     |  yes    |      no                   |
+# -------------------------------------------------------------------------------------
+# |    2     |       yes           |    yes     |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+# |    3     |       yes           |    no      |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+
+
+#D-
+#D--------------------------------------------------------------------==
+#D-                   0. System Environment 
+#D-                      - Define variables for Number of processors
+#D-                      - Define MPI variables
+#D-                      - Define batch scheduler variables
+#D-                      - Source IGCM Library
+#D-                      - Get RESOLution in .resol file (temporary)
+#D--------------------------------------------------------------------==
+
+#D--------------------------------------------------------------------==
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+        ( ${DEBUG_debug} ) && IGCM_debug_Check
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+       ( ${DEBUG_debug} ) && IGCM_card_Check
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+       ( ${DEBUG_debug} ) && IGCM_date_Check
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+
+
+#set -vx
+R_BC=${R_IN}/BC
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+
+. ${SUBMIT_DIR}/fluxnet.ksh
+
+FLUXNET_initialize
+
+function correct_duree
+{
+    # Ths function compute the nearest multiple of dyear near duree
+    typeset duree dyear
+    duree=$1
+    dyear=$2
+    if [ $(( duree % dyear )) -gt 0 ] ; then
+	echo $(( ( duree / dyear + 1 ) * dyear ))
+    else
+	echo ${duree}
+    fi
+}
+
+# Path for all skeleton SubJob scripts to SPINUP directory
+Skeleton_Path=$( cd ../; pwd )
+
+isite=1
+index=0
+echo ${isite} ${NumSites}
+while [ ${isite} -le ${NumSites} ] ; do
+    
+    site=${fluxnet_FLUXNET_Sites[$index]}
+    echo "   ------------------------"
+    echo "   SPINUP for Site : ${site}"
+
+    DATE0_YEAR=${fluxnet_FLUXNET_Sites[ $(( index + ColumnYear )) ]}
+    TIME_YEAR=${fluxnet_FLUXNET_Sites[ $(( index + ColumnLength )) ]}
+
+#######################################################
+# Script internal settings
+# nothing to be modified below this line
+######################################################ä
+
+# Copy the SPINUP directory
+    SubJobName=${site}${config_UserChoices_JobName}
+    New_SUBMIT_DIR=${SUBMIT_DIR}/${SubJobName}
+    IGCM_sys_Cp -Rp ../SPINUP ${New_SUBMIT_DIR}
+#     ls -la ${New_SUBMIT_DIR}
+#     cat ${New_SUBMIT_DIR}/config.card
+#     echo "---"
+
+    # Install this directory
+    # modifications on config.card
+    MyJobName=${config_UserChoices_JobName}
+    IGCM_card_DefineVariableFromOption ${New_SUBMIT_DIR}/config.card UserChoices JobName
+    OldJobName=${config_UserChoices_JobName}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobName ${SubJobName}
+    config_UserChoices_JobName=${MyJobName}
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices TagName
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices TagName ${config_UserChoices_TagName}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices CalendarType ${config_UserChoices_CalendarType}
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobClass ${config_UserChoices_JobClass}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot}
+    sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card
+    IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card 
+
+    # Give path for all skeleton SubJob scripts to SPINUP directory
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices SubJobPath ${Skeleton_Path}
+
+    # All SubJobs in SPINUP in one or more years (must be used with libIGCM branches/AllPostFred). 
+    # It is the length of the forcing file.
+    if [ X"${config_UserChoices_CalendarType}" = X"360d" ] ; then
+    	This_Job_DateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))1230
+    	This_Job_HumanDateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))-12-30
+    else
+    	This_Job_DateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))1231
+    	This_Job_HumanDateEnd=$(( DATE0_YEAR + TIME_YEAR - 1 ))-12-31
+    fi
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateBegin ${DATE0_YEAR}-01-01
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodLength ${TIME_YEAR}Y
+
+    # DateEnd is defined by SpinUp job itself (it will be modified in config.card).
+    # but to get all SpinUp Job loops, we have to add at least a number of years greater
+    # than those that will be modified in config.card. Default is 150.00.00 years more for SpinUp.
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateEnd $(( DATE0_YEAR + 150 ))-01-01
+
+    # Infinit SPINUP Job :
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodNb 99999
+
+    # SRF section : first restart and post-treatments 
+    typeset option
+    for option in ${config_SRF[*]} ; do
+	eval value=\${config_SRF_${option}}
+	eval echo ${option} ${value}
+	if [ X${value} != X ] ; then
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF ${option} \${config_SRF_${option}}
+	fi
+    done
+    if [ X"${fluxnet_UserChoices_ok_stomate}" = "Xy" ] ; then
+	for option in ${config_SBG[*]} ; do
+	    eval value=\${config_SBG_${option}}
+	    eval echo ${option} ${value}
+	    if [ X${value} != X ] ; then
+		eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG ${option} \${config_SBG_${option}}
+	    fi
+	done
+    fi
+
+    # modifications on spinup.card 
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobForcingFile List "(${fluxnet_FLUXNET_FluxnetPath}/${fluxnet_FLUXNET_Sites[$(( index + ColumnFilename ))]}, forcing_file.nc)"
+
+    typeset option
+    for option in ${fluxnet_UserChoices[*]} ; do
+	eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices ${option} \${fluxnet_UserChoices_${option}}
+    done
+    # No routing for FLUXNET
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices ok_routing n
+
+    # Max levels for FLUXNET
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices sechiba_LEVEL 10
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices stomate_LEVEL 10
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices DRIVER_NORESTART y
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices DRIVER_TIMELENGTH n
+
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_nostomate $( correct_duree ${fluxnet_SPINUP_duree_nostomate} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_inistomate $( correct_duree ${fluxnet_SPINUP_duree_inistomate} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_offlineini $( correct_duree ${fluxnet_SPINUP_duree_offlineini} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices n_iter ${fluxnet_SPINUP_n_iter}
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_sechiba $( correct_duree ${fluxnet_SPINUP_duree_sechiba} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_stomate $( correct_duree ${fluxnet_SPINUP_duree_stomate} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_carbonsol $( correct_duree ${fluxnet_SPINUP_duree_carbonsol} ${TIME_YEAR} )
+    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices duree_final $( correct_duree ${fluxnet_SPINUP_duree_final} ${TIME_YEAR} )
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices BoundaryFilesListNonDel y
+
+    # TimeSeries : ALMAOUTPUT for SECHIBA
+    typeset option
+    for option in ${config_SubJobPost[*]} ; do
+	eval value=\${config_SubJobPost_${option}}
+	eval echo ${option} ${value}
+	if [ X${value} != X ] ; then
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SubJobPost ${option} \${config_SubJobPost_${option}}
+	fi
+    done
+#    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF TimeSeriesFrequency ${TIME_YEAR}Y
+#    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF TimeSeriesFrequency NONE
+    set -A sechiba_TimeSeriesVars2D -- nobiofrac SWnet LWnet Qh Qle Qg Qf DelSurfHeat DelColdCont Snowf Rainf Evap \
+                                     Qs Qsb Qsm DelSoilMoist DelSWE DelIntercept AvgSurfT RadT Albedo SWE SoilMoist SoilWet SoilTemp PotEvap \
+                                     ECanop TVeg ESoil RootMoist SubSnow ACond SnowFrac SAlbedo SnowDepth dis
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobPost sechiba_TimeSeriesVars2D "("$( echo ${sechiba_TimeSeriesVars2D[@]} | sed -e "s/ /,/g" )")"
+    set -A sechiba_TimeSeriesVars3D -- vegetfrac maxvegetfrac GPP
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobPost sechiba_TimeSeriesVars3D "("$( echo ${sechiba_TimeSeriesVars3D[@]} | sed -e "s/ /,/g" )")"
+
+    # modifications on Job script
+    rm ${New_SUBMIT_DIR}/Job_${OldJobName}
+    IGCM_sys_Cp ${SUBMIT_DIR}/Job_${MyJobName} ${New_SUBMIT_DIR}/Job_${SubJobName}
+
+    sed -e "s/ ${MyJobName}/ ${SubJobName}/" \
+	-e "s/Script_Output_${MyJobName}/Script_Output_${SubJobName}/" \
+	${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_
+    IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName}
+    chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName}
+
+
+    # modification on parameter files
+    IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/sechiba.def ${New_SUBMIT_DIR}/PARAM/sechiba.def
+    IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/stomate.def ${New_SUBMIT_DIR}/PARAM/stomate.def
+    IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/driver.def ${New_SUBMIT_DIR}/PARAM/driver.def
+
+    eval first_option=${fluxnet_SubJobParams[0]} > /dev/null 2>&1
+    if [ X${first_option} != X"Error:" ] ; then
+	IGCM_card_DefineArrayFromSection ${New_SUBMIT_DIR}/COMP/spinup.card SubJobParams
+	eval first_option=${spinup_SubJobParams[0]} > /dev/null 2>&1
+	    
+	typeset option option_ PARAM_FILE
+	for option in ${fluxnet_SubJobParams[*]} ; do
+	    PARAM_FILE=$( echo ${option} | awk -F_ '{print $1}' )
+	    echo "For parameter file ${PARAM_FILE}.def"
+	    option_=$( echo ${option} | sed -e "s/${PARAM_FILE}_//" )
+	    eval echo "${option_}="\${fluxnet_SubJobParams_${option}}
+	    case ${PARAM_FILE} in
+		sechiba)
+		    eval SECHIBA_sed ${option_} \${fluxnet_SubJobParams_${option}}
+		    ;;
+		stomate)
+		    eval STOMATE_sed ${option_} \${fluxnet_SubJobParams_${option}}
+		    ;;
+		driver)
+		    eval DRIVER_sed ${option_} \${fluxnet_SubJobParams_${option}}
+		    ;;
+	    esac
+
+	    if [ X${first_option} != X"Error:" ] ; then
+		for option_ in ${spinup_SubJobParams[*]} ; do
+		    if [ X${option} == X${option_} ] ; then
+			eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card SubJobParams ${option} \${fluxnet_SubJobParams_${option}}
+		    fi
+		done
+	    fi
+	done
+    fi
+
+    # Replace vegetation
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/spinup.card UserChoices impose_veg y
+
+    (( iphys = 0 ))
+    while [ $iphys -lt ${fluxnet_FLUXNET_NbSitesParam} ] ; do
+	
+	# Detect if physical parameter has 
+        #  array description or line per PFT description in the parameter file
+	SearchParam=""
+	${fluxnet_FLUXNET_CompSitesParam[${iphys}]}_grep ${fluxnet_FLUXNET_NameSitesParam[${iphys}]}
+
+	case ${SearchParam} in
+	    undefined)
+		echo "ERROR : parameter ${fluxnet_FLUXNET_NameSitesParam[${iphys}]} doen't exist in ${fluxnet_FLUXNET_CompSitesParam[${iphys}]} parameter file !"
+		echo "You must correct NameSiteParam option in fluxnet.card file or add new parameter in component.def file"
+		echo "We must STOP here."
+		exit 1
+		;;
+	    line)
+		ipft=1
+		while [ $ipft -le ${NbPFTs} ] ; do
+		    if [ $ipft -lt 10 ] ; then
+			numpft=0${ipft}
+		    else
+			numpft=${ipft}
+		    fi
+	    
+		    ${fluxnet_FLUXNET_CompSitesParam[${iphys}]}_sed ${fluxnet_FLUXNET_NameSitesParam[${iphys}]}__${numpft} ${fluxnet_FLUXNET_Sites[$(( index + 4 + ( iphys * NbPFTs ) + ipft - 1 )) ]}
+		    (( ipft = ipft + 1 ))
+		done
+		;;
+	    vector)
+		unset ValueSiteParams
+		ipft=0
+		while [ $ipft -lt ${NbPFTs} ] ; do
+		    ValueSiteParams[${ipft}]=${fluxnet_FLUXNET_Sites[$(( index + 4 + ( iphys * NbPFTs ) + ipft - 1 )) ]}
+		    (( ipft = ipft + 1 ))
+		done
+		${fluxnet_FLUXNET_CompSitesParam[${iphys}]}_sed ${fluxnet_FLUXNET_NameSitesParam[${iphys}]} "${ValueSiteParams[*]}"
+		;;
+	esac
+
+	(( iphys = iphys + 1 ))
+    done
+
+    IGCM_debug_Verif_Exit
+
+# Lauch the SPINUP Job :
+
+    echo "#!/bin/ksh" > ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "MODIPSL=${MODIPSL}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "libIGCM=${libIGCM}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "cd ${New_SUBMIT_DIR}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "export SUBMIT_DIR=${New_SUBMIT_DIR}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo ". ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo ". ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "export Script_Output=out_qsub_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "export config_UserChoices_JobName=${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "export CumulPeriod=1" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+#    echo "nohup Job_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+    echo "IGCM_sys_Qsub Job_${SubJobName}" >> ${RUN_DIR_PATH}/SubJob${site}.ksh
+
+    if [ ${DRYRUN} -le 1 ] ; then
+	chmod u+x ${RUN_DIR_PATH}/SubJob${site}.ksh
+	nohup ${RUN_DIR_PATH}/SubJob${site}.ksh 
+    fi
+
+    IGCM_debug_Verif_Exit
+
+    (( isite=isite+1 ))
+    (( index=index+NumInfosBySite ))
+done
+
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/Job_Post_FLUXNET
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/Job_Post_FLUXNET	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/Job_Post_FLUXNET	(revision 405)
@@ -0,0 +1,157 @@
+#!/bin/ksh
+
+# $Date: 2010/06/25 18:48:26 $
+# $Author: ssipsl $
+# $Revision: 1.5 $
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
+
+#D--------------------------------------------------------------------==
+#D--------------------------------------------------------------------==
+#D-
+#D-                      Job to launch FLUXNET spinup simulations
+#D-
+#D--------------------------------------------------------------------==
+#D--------------------------------------------------------------------==
+#D-
+#                       Job inspired from SÃ¶nke Zaehle "site_new.def" job
+#                       #################################################
+
+
+
+MODIPSL=::modipsl::
+libIGCM=${MODIPSL}/libIGCM
+
+# All SubJobs in SPINUP in ONE OR MORE YEARS run (must be used with libIGCM branches/AllPostFred). 
+
+
+
+#D--------------------------------------------------------------------==
+#D-                   -1. User modification place
+#D--------------------------------------------------------------------==
+
+#D- Increased verbosity (1, 2, 3)
+#Verbosity=3
+
+#D-
+# --------------------------------------------------------------------
+#D- ! Optionnal features /!\ Use with care !
+# --------------------------------------------------------------------
+
+#D- Low level debug : to bypass lib test checks and stack construction
+#D- Default=true
+DEBUG_debug=false
+
+#D- Set DEBUG_sys to false to disable output calls of function
+#D- Default=true
+#DEBUG_sys=false
+
+#D- Turn in dry run mode ? (0,1,2,3)
+#D- Default=0
+#DRYRUN=3
+# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
+# -------------------------------------------------------------------------------------
+# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+# |          |  Cp/Exe param files |            |  Chmod  |                           |
+# |          |      Qsub           |            |         |                           |
+# -------------------------------------------------------------------------------------
+# |    0     |       yes           |    yes     |  yes    |      yes                  |
+# -------------------------------------------------------------------------------------
+# |    1     |       yes           |    yes     |  yes    |      no                   |
+# -------------------------------------------------------------------------------------
+# |    2     |       yes           |    yes     |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+# |    3     |       yes           |    no      |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+
+
+#D-
+#D--------------------------------------------------------------------==
+#D-                   0. System Environment 
+#D-                      - Define variables for Number of processors
+#D-                      - Define MPI variables
+#D-                      - Define batch scheduler variables
+#D-                      - Source IGCM Library
+#D-                      - Get RESOLution in .resol file (temporary)
+#D--------------------------------------------------------------------==
+
+#D--------------------------------------------------------------------==
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+        ( ${DEBUG_debug} ) && IGCM_debug_Check
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+       ( ${DEBUG_debug} ) && IGCM_card_Check
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+       ( ${DEBUG_debug} ) && IGCM_date_Check
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+
+#set -vx
+R_BC=${R_IN}/BC
+
+. ${SUBMIT_DIR}/fluxnet.ksh
+
+FLUXNET_initialize
+
+
+# Launch ATLAS syncho : we have to wait for the last job !
+
+# ATLAS fix parameters :
+# Atlas Name : 
+AtlasCfg=${fluxnet_SPINUP_AtlasCfg}
+#atlas_FLUXNET.cfg
+
+# observation_file
+observation_file_path=${fluxnet_SPINUP_observation_file_path}
+
+# old history file
+reference_file_path=${fluxnet_SPINUP_reference_file_path}
+
+# Modulo for SpinUp years
+Modulo=${fluxnet_SPINUP_Modulo}
+
+ATLAS_ARGS="${AtlasCfg} ${observation_file_path} ${reference_file_path} ${Modulo}"
+
+isite=1
+index=0
+while [ ${isite} -le ${NumSites} ] ; do
+
+    site=${fluxnet_FLUXNET_Sites[$index]}
+    echo $site
+
+    # We test if the END step was moved in SpinUp/SPIN/Output directory.
+    # Then we are sure the last historical SpinUp step has finished (HIST)...
+
+    # Define name of the END SubJob (FIN) in SpinUp
+    if [ ${fluxnet_SPINUP_duree_final} -gt 0 ] ; then
+	BeforeLastJob=${site}${config_UserChoices_JobName}FIN
+    else
+	echo "We must have an \"duree_final\" non zero to get historical run and post-treatment"
+	exit 1
+    fi
+
+    # Wait for the end of the last job :
+    ((isleep=0))
+    while [ ! -d ${R_OUT}/${config_UserChoices_TagName}/${site}${config_UserChoices_JobName}/SPIN/Output/${BeforeLastJob} ] ; do
+	ls -la ${R_OUT}/${config_UserChoices_TagName}/${site}${config_UserChoices_JobName}/SPIN/Output/${BeforeLastJob}
+	sleep 20
+	((isleep=isleep+1))
+	if [ isleep -gt 200 ] ; then
+	    break ;
+	fi
+    done
+
+    TIME_YEAR=${fluxnet_FLUXNET_Sites[ $(( index + ColumnLength )) ]}
+    YEAR=${fluxnet_FLUXNET_Sites[ $(( index + ColumnYear )) ]}
+
+    # Launch post-treatment for SPINUP !
+    echo "****"
+    echo "Launch post-treatment for SPINUP for site ${site} !"
+    nohup ${SUBMIT_DIR}/post_FLUXNET ${MODIPSL} ${site} ${TIME_YEAR} ${YEAR} ${ATLAS_ARGS} > ${SUBMIT_DIR}/out_post_${site} 2>&1 &
+    echo "****"
+
+    (( isite=isite+1 ))
+    (( index=index+NumInfosBySite ))
+done
+
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/LISEZMOI
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/LISEZMOI	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/LISEZMOI	(revision 405)
@@ -0,0 +1,51 @@
+Lancer une simulation avec Site Fluxnet
+=======================================
+
+ Presentation du rÃ©pertoire FLUXNET/ 
+ ***********************************
+ (aprÃšs "ins_job" - voir documentation sur l'installation des scripts)
+ Les fichiers de configurations 
+ a) Comme tous les scripts associÃ©s Ã  libIGCM,
+    il contient les fichiers 
+    - config.card : contient les informations de JobName, TagName, Dates et Restart.
+    - un Job_${JobName} (par dÃ©faut Job_Sp) : contient la carte PBS utilisÃ©es pour tous les SPINUP.
+    - un fichier run.card.init qui permettra le suivit des lancements de SPINUP.
+ b) la carte de configuration fluxnet.card : les informations sur la liste des sites, leur type et
+    les paramÃštres associÃ©s Ã  tous les SPINUP.
+ c) le fichier de paramÃštre d'ORCHIDEE : orchidee.def
+
+ Les utilitaires suivants ne doivent pas Ãªtre modifiÃ©s :
+ d) le job "maÃ®tre" Job_FLUXNET_validation
+ e) le job "maÃ®tre" pour les post-traitements Job_Post_FLUXNET
+ f) les scripts d'atlas atlas_FLUXNET.cfg et atlas_FLUXNET_soenke.cfg
+ g) le script d'installation install 
+ h) les bibliothÃšques fluxnet.ksh et post_FLUXNET
+
+
+ Les Ã©tapes suivantes doivent Ãªtre effectuÃ©es :
+ **********************************************
+ 1) Pour crÃ©er une simulation vous devez modifier le fichier config.card
+    - JobName=Sp
+    - TagName=OL2 (si besoin)
+    - WriteFrequency="1800s"
+    - Restart=n
+    - TimeSeriesFrequency= NONE (si besoin)
+
+ 2) Puis vous devez effacer les fichier Job_Sp et run.card.init
+
+ 4) Ensuite, il faut crÃ©Ã© le job avec le bon JobName, et les bons chemins :
+  myprompt> cd ??/modipsl/util
+  myprompt> ./ins_job
+    Pour installer correctement les Jobs Job_FLUXNET_validation et Job_Post_FLUXNET :
+  myprompt> cd ??/modipsl/modeles/ORCHIDEE_OL/FLUXNET
+  myprompt> ./install
+
+ 5) Il faut penser Ã  modifier carte PBS dans le nouveau Job_${JobName} 
+    (paramÃštres dÃ©pendant de la machine de calcul)
+
+ 6) Pour finir, Ã©xÃ©cutez simplement Job_FLUXNET_validation; conseillÃ© :
+  myprompt> ksh
+  # nohup ./Job_FLUXNET_validation > out_Job 2>&1 &
+
+ 7) Ã la fin des SPINUPs, Ã©xÃ©cutez simplement Job_Post_FLUXNET; conseillÃ© :
+  # nohup ./Job_Post_FLUXNET > out_Post 2>&1 &
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/PARAM/driver.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/PARAM/driver.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/PARAM/driver.def	(revision 405)
@@ -0,0 +1,298 @@
+#
+#**************************************************************************
+#                    Namelist for ORCHIDEE_OL
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of DRIVER
+#**************************************************************************
+
+# Flag for debug information
+# This option allows to switch on the output of debug
+#         information without recompiling the code.
+DEBUG_INFO = n
+#default = n
+
+
+#---------------------------------------------------------------------
+# Forcing file name
+# Name of file containing the forcing data
+# This is the name of the file which should be opened
+# for reading the forcing data of the dim0 model.
+# The format of the file has to be netCDF and COADS
+# compliant. Cabauw.nc, islscp_for.nc, WG_cru.nc
+FORCING_FILE = forcing_file.nc
+# default = islscp_for.nc
+
+# split time step :
+#---------------------------------------------------------------------
+
+# Splits the timestep imposed by the forcing
+# With this value the time step of the forcing
+#  will be devided. In principle this can be run
+#  in explicit mode but it is strongly suggested
+#  to use the implicit method so that the
+#  atmospheric forcing has a smooth evolution.
+SPLIT_DT = 12
+# default = 12
+
+#  Time in the forcing file at which the model is started.
+#  This time give the point in time at which the model
+#  should be started. 
+#  If exists, the date of the restart file is use.
+#  The FORMAT of this date can be either of the following :
+#  n   : time step n within the forcing file
+#  nS  : n seconds after the first time-step in the file
+#  nD  : n days after the first time-step
+#  nM  : n month after the first time-step (year of 365 days)
+#  nY  : n years after the first time-step (year of 365 days)
+#      Or combinations :
+#  nYmM: n years and m month
+TIME_SKIP = 0
+# default = 0
+
+# Spread the precipitation.
+# Spread the precipitaiton over n steps of the splited forcing time step. 
+#  This is ONLY applied if the forcing time step has been splited (SPLIT_DT).
+#  If the value indicated is greater than SPLIT_DT, SPLIT_DT is used for it.
+SPRED_PREC = 1
+# default = 1
+
+
+
+
+
+# Input and output restart file for the driver
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by the driver
+# This variable give the  name for
+#  the restart file. The restart software within
+#  IOIPSL will add .nc if needed
+RESTART_FILEOUT = driver_rest_out.nc
+# default = driver_rest_out.nc
+
+
+#**************************************************************************
+#                             Area location
+#**************************************************************************
+#  The model will use the smalest regions from
+#  region specified here and the one of the forcing file.
+
+# Western limit of region
+# Western limit of the region we are 
+#  interested in. Between -180 and +180 degrees
+LIMIT_WEST = -180.
+# default = -180.
+
+# Eastern limit of region
+# Eastern limit of the region we are
+#  interested in. Between -180 and +180 degrees
+LIMIT_EAST = 180.
+# default = 180.
+
+# Northern limit of region
+# Northern limit of the region we are
+#  interested in. Between +90 and -90 degrees
+LIMIT_NORTH = 90.
+# default = 90.
+
+# Southern limit of region
+# Southern limit of the region we are
+#  interested in. Between 90 and -90 degrees
+LIMIT_SOUTH = -90.
+# default = -90.
+
+##**************************************************************************
+#                       Simulation parameters
+#**************************************************************************
+
+# method of forcing
+# A method is proposed by which the first atmospheric
+#   level is not directly forced by observations but
+#   relaxed with a time constant towards observations.
+#   For the moment the methods tends to smooth too much
+#   the diurnal cycle and introduces a time shift.
+#   A more sophisticated method is needed.
+RELAXATION = n
+# default = n
+
+# Time constant of the relaxation layer RELAXATION
+# The time constant associated to the atmospheric
+#  conditions which are going to be computed
+#  in the relaxed layer. To avoid too much
+#  damping the value should be larger than 1000.
+RELAX_A = 1000.
+# default = 1000.0
+
+# Height at which T and Q are given
+# The atmospheric variables (temperature and specific
+#  humidity) are measured at a specific level.
+#  The height of this level is needed to compute
+#  correctly the turbulent transfer coefficients.
+#  Look at the description of the forcing
+#  DATA for the correct value.
+HEIGHT_LEV1 = 2.0
+# default  = 2.0
+
+# Height at which the wind is given
+# The height at which wind is needed to compute
+#  correctly the turbulent transfer coefficients.
+HEIGHT_LEVW = 10.0
+# default  = 10.0
+
+#---------------------------------------------------------------------
+# Weather generator or not :
+#---------------------------------------------------------------------
+
+# Allow weather generator to create data.
+# This flag allows the forcing-reader to generate
+#  synthetic data if the data in the file is too sparse
+#  and the temporal resolution would not be enough to
+#  run the model.
+ALLOW_WEATHERGEN = n
+# default = n
+
+# North-South Resolution
+# If ALLOW_WEATHERGEN
+# North-South Resolution of the region we are
+#  interested in. In degrees
+MERID_RES = 2.
+# default = 2.
+
+# East-West Resolution
+# If ALLOW_WEATHERGEN
+# East-West Resolution of the region we are
+#  interested in. In degrees
+ZONAL_RES = 2.
+# default = 2.
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+# If this is set to 1, the weather generator
+#   uses the monthly mean values for daily means.
+#   If it is set to 0, the weather generator
+#   uses statistical relationships to derive daily
+#   values from monthly means.
+IPPREC = 0
+# default = 0
+
+# Interpolation  or not IF split is larger than 1
+# Choose IF you wish to interpolate linearly or not.
+NO_INTER = y
+INTER_LIN = n
+# default :
+#  NO_INTER = y
+#  INTER_LIN = n
+
+# Exact monthly precipitation
+# If ALLOW_WEATHERGEN
+# If this is set to y, the weather generator
+#   will generate pseudo-random precipitations
+#   whose monthly mean is exactly the prescribed one.
+#   In this case, the daily precipitation (for rainy
+#   days) is constant (that is, some days have 0 precip,
+#   the other days have precip = Precip_month/n_precip,
+#   where n_precip is the prescribed number of rainy days
+#   per month).
+WEATHGEN_PRECIP_EXACT = n
+# default = n
+
+# Calling frequency of weather generator (s)
+# Determines how often the weather generator
+#  is called (time step in s). Should be equal
+#  to or larger than Sechiba's time step (say,
+#  up to 6 times Sechiba's time step or so).
+DT_WEATHGEN = 1800.
+# default = 1800.
+
+# Conserve net radiation in the forcing
+# When the interpolation is used the net radiation
+#  provided by the forcing is not conserved anymore.
+#  This should be avoided and thus this option should
+#  be TRUE (y).
+#  This option is not used for short-wave if the
+#  time-step of the forcing is longer than an hour.
+#  It does not make sense to try and reconstruct
+#  a diurnal cycle and at the same time conserve the 
+#  incoming solar radiation.
+NETRAD_CONS = y
+# default = y
+
+# Write weather from generator into a forcing file
+# This flag makes the weather generator dump its
+#  generated weather into a forcing file which can
+#  then be used to get the same forcing on different
+#  machines. This only works correctly if there is
+#  a restart file (otherwise the forcing at the first
+#  time step is slightly wrong).
+DUMP_WEATHER = n
+# default = n
+
+# Name of the file that contains
+#  the weather from generator
+# If DUMP_WEATHER
+DUMP_WEATHER_FILE = weather_dump.nc
+# default = 'weather_dump.nc'
+
+# Dump weather data on gathered grid
+# If 'y', the weather data are gathered
+#  for all land points.
+# If DUMP_WEATHER
+DUMP_WEATHER_GATHERED = y
+# default = y
+
+
+# Read Orbital Parameters
+
+# Eccentricity Effect
+# Use prescribed values
+# IF ALLOW_WEATHERGEN
+ECCENTRICITY = 0.016724
+# default = 0.016724
+
+# Longitude of perihelie
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+PERIHELIE = 102.04
+# default = 102.04
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+OBLIQUITY = 23.446
+# default = 23.446
+
+#**************************************************************************
+# length of simulation :
+#---------------------------------------------------------------------
+# Length of the integration in time.
+# Length of integration. By default the entire length
+#        of the forcing is used. The FORMAT of this date can
+#        be either of the following :
+# n   : time step n within the forcing file
+# nS  : n seconds after the first time-step in the file
+# nD  : n days after the first time-step
+# nM  : n month after the first time-step (year of 365 days)
+# nY  : n years after the first time-step (year of 365 days)
+#        Or combinations :
+# nYmM: n years and m month
+TIME_LENGTH = default
+# default = depend on the time length and the number of time step in forcing file
+#         = itau_len = itau_fin-itau_dep
+
+
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/PARAM/sechiba.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/PARAM/sechiba.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/PARAM/sechiba.def	(revision 405)
@@ -0,0 +1,817 @@
+#
+#**************************************************************************
+#                    Namelist for SECHIBA
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of SECHIBA
+#**************************************************************************
+
+# ORCHIDEE will print more messages
+# This flag permits to print more debug messages in the run.
+LONGPRINT = n
+#default = n
+
+#---------------------------------------------------------------------
+
+# Should the output follow the ALMA convention
+# If this logical flag is set to true the model
+#  will output all its data according to the ALMA 
+#  convention. It is the recommended way to write
+#  data out of ORCHIDEE.
+ALMA_OUTPUT = n
+# default = n
+
+# To reset the time coming from SECHIBA restart file
+# This option allows the model to override the time
+#  found in the restart file of SECHIBA with the time
+#  of the first call. That is the restart time of the GCM.
+SECHIBA_reset_time = n
+# default = n
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+# Name of file from which the vegetation map is to be read
+# If !IMPOSE_VEG
+# If LAND_USE 
+#   default = pft_new.nc
+#   The name of the file to be opened to read a vegetation
+#   map (in pft) is to be given here. 
+# If !LAND_USE
+#   default = ../surfmap/carteveg5km.nc
+#   The name of the file to be opened to read the vegetation
+#   map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#   map which is derived from the IGBP one. We assume that we have
+#   a classification in 87 types. This is Olson modified by Viovy.
+VEGETATION_FILE = PFTmap.nc
+
+
+# Name of file from which the bare soil albedo
+# If !IMPOSE_AZE
+# The name of the file to be opened to read the soil types from 
+#  which we derive then the bare soil albedos. This file is 1x1 
+#  deg and based on the soil colors defined by Wilson and Henderson-Seller.
+SOILALB_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Name of file from which soil types are read
+# If !IMPOSE_VEG
+# The name of the file to be opened to read the soil types. 
+#  The data from this file is then interpolated to the grid of
+#  of the model. The aim is to get fractions for sand loam and
+#  clay in each grid box. This information is used for soil hydrology
+#  and respiration.
+SOILTYPE_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Input and output restart file for SECHIBA :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+SECHIBA_restart_in = NONE
+# default = NONE
+
+# Name of restart files to be created by SECHIBA
+# This variable give the name for the restart files. 
+#  The restart software within IOIPSL will add .nc if needed.
+SECHIBA_rest_out = sechiba_rest_out.nc
+# default = sechiba_rest_out.nc
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+
+# ORCHIDEE will write out its forcing to a file
+# This flag allows to write to a file all the variables
+#  which are used to force the land-surface. The file 
+#  has exactly the same format than a normal off-line forcing
+#  and thus this forcing can be used for forcing ORCHIDEE.
+ORCHIDEE_WATCHOUT = n
+# default = n
+
+# Filenane for the ORCHIDEE forcing file
+# If ORCHIDEE_WATCHOUT
+# This is the name of the file in which the
+#  forcing used here will be written for later use. 
+WATCHOUT_FILE = orchidee_watchout.nc
+# default = orchidee_watchout.nc
+
+# ORCHIDEE will write out with this frequency
+# If ORCHIDEE_WATCHOUT
+# This flag indicates the frequency of the write of the variables. 
+DT_WATCHOUT = 1800
+# default = dt
+
+# Output file name :
+#---------------------------------------------------------------------
+# Name of file in which the output is going
+# This file is going to be created by the model
+#  to be written
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+OUTPUT_FILE = sechiba_history.nc
+# default = cabauw_out.nc
+
+# Flag to switch on histfile 2 for SECHIBA (hi-frequency ?)
+# This Flag switch on the second SECHIBA writing for hi (or low) 
+#  frequency writing. This second output is optional and not written
+#  by default.
+SECHIBA_HISTFILE2 = FALSE
+# default  = FALSE
+
+# Name of file in which the output number 2 is going
+#   to be written
+# If SECHIBA_HISTFILE2
+# This file is going to be created by the model
+#   and will contain the output 2 from the model.
+SECHIBA_OUTPUT_FILE2 = sechiba_out_2.nc
+# default  = sechiba_out_2.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# SECHIBA history output level (0..10)
+# Chooses the list of variables in the history file. 
+#  Values between 0: nothing is written; 10: everything is 
+#  written are available More details can be found on the web under documentation.
+#  web under documentation.
+SECHIBA_HISTLEVEL = 5
+# default = 5
+
+# SECHIBA history 2 output level (0..10)
+# If SECHIBA_HISTFILE2
+# Chooses the list of variables in the history file. 
+#   Values between 0: nothing is written; 10: everything is 
+#   written are available More details can be found on the web under documentation.
+#   web under documentation.
+# First level contains all ORCHIDEE outputs.
+SECHIBA_HISTLEVEL2 = 1
+# default = 1
+
+# Write frequency for output files (SECHIBA in seconds) :
+#---------------------------------------------------------------------
+# Frequency in seconds at which to WRITE output
+# This variables gives the frequency the output of
+#  the model should be written into the netCDF file.
+#  It does not affect the frequency at which the
+#  operations such as averaging are done.
+WRITE_STEP = 86400.0
+# default = 86400.0
+
+# Frequency in seconds at which to WRITE output
+# If SECHIBA_HISTFILE2
+# This variables gives the frequency the output 2 of
+#   the model should be written into the netCDF file.
+#   It does not affect the frequency at which the
+#   operations such as averaging are done.
+#   That is IF the coding of the calls to histdef
+#   are correct !
+WRITE_STEP2 = 1800.0
+# default = 1800.0
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate CO2?
+# set to TRUE if photosynthesis is to be activated
+STOMATE_OK_CO2 = n
+# default = n
+
+# Flag to force the value of atmospheric CO2 for vegetation.
+# If this flag is set to true, the ATM_CO2 parameter is used
+#  to prescribe the atmospheric CO2.
+# This Flag is only use in couple mode.
+FORCE_CO2_VEG = FALSE
+# default = FALSE
+
+# Value for atm CO2.
+# If FORCE_CO2_VEG (in not forced mode)
+# Value to prescribe the atm CO2.
+#  For pre-industrial simulations, the value is 286.2 .
+#  348. for 1990 year.
+ATM_CO2 = 350.
+# default = 350.
+
+
+#
+#**************************************************************************
+#          NEW OPTIONS FOR RESTARTS in versions up to 1.9.3
+#**************************************************************************
+#
+## sechiba
+soilcap=n
+soilflx=n
+shumdiag=n
+runoff=n
+drainage=n
+
+## diffuco
+raero=n
+qsatt=n
+cdrag=n
+
+## enerbil
+evapot_corr=n
+temp_sol_new=n
+
+## hydrolc
+dss=n
+hdry=n
+
+## thermosoil
+cgrnd=n
+dgrnd=n
+z1=n
+pcapa=n
+pcapa_en=n
+pkappa=n
+zdz1=n
+zdz2=n
+temp_sol_beg=n
+
+# parameters describing the surface (vegetation + soil) :
+#---------------------------------------------------------------------
+#
+# Should the vegetation be prescribed
+# This flag allows the user to impose a vegetation distribution
+#  and its characterisitcs. It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_VEG = n
+# default = n
+
+# Flag to use old "interpolation" of vegetation map.
+# IF NOT IMPOSE_VEG and NOT LAND_USE
+#  If you want to recover the old (ie orchidee_1_2 branch) 
+#   "interpolation" of vegetation map.
+SLOWPROC_VEGET_OLD_INTERPOL = n
+# default = n
+
+# Vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEG__01 = 0.2
+SECHIBA_VEG__02 = 0.0
+SECHIBA_VEG__03 = 0.0
+SECHIBA_VEG__04 = 0.0
+SECHIBA_VEG__05 = 0.0
+SECHIBA_VEG__06 = 0.0
+SECHIBA_VEG__07 = 0.0
+SECHIBA_VEG__08 = 0.0
+SECHIBA_VEG__09 = 0.0
+SECHIBA_VEG__10 = 0.8
+SECHIBA_VEG__11 = 0.0
+SECHIBA_VEG__12 = 0.0
+SECHIBA_VEG__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# Maximum vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEGMAX__01 = 0.2
+SECHIBA_VEGMAX__02 = 0.0
+SECHIBA_VEGMAX__03 = 0.0
+SECHIBA_VEGMAX__04 = 0.0
+SECHIBA_VEGMAX__05 = 0.0
+SECHIBA_VEGMAX__06 = 0.0
+SECHIBA_VEGMAX__07 = 0.0
+SECHIBA_VEGMAX__08 = 0.0
+SECHIBA_VEGMAX__09 = 0.0
+SECHIBA_VEGMAX__10 = 0.8
+SECHIBA_VEGMAX__11 = 0.0
+SECHIBA_VEGMAX__12 = 0.0
+SECHIBA_VEGMAX__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# LAI for all vegetation types (0-dim mode)
+# If IMPOSE_VEG
+# The maximum LAI used in the 0dim mode. The values should be found
+#  in the restart file. The new values of LAI will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SECHIBA_LAI__01 = 0.
+SECHIBA_LAI__02 = 8.
+SECHIBA_LAI__03 = 8.
+SECHIBA_LAI__04 = 4.
+SECHIBA_LAI__05 = 4.5
+SECHIBA_LAI__06 = 4.5
+SECHIBA_LAI__07 = 4.
+SECHIBA_LAI__08 = 4.5
+SECHIBA_LAI__09 = 4.
+SECHIBA_LAI__10 = 2.
+SECHIBA_LAI__11 = 2.
+SECHIBA_LAI__12 = 2.
+SECHIBA_LAI__13 = 2.
+# default = 0., 8., 8., 4., 4.5, 4.5, 4., 4.5, 4., 2., 2., 2., 2.
+
+# Height for all vegetation types (m)
+# If IMPOSE_VEG
+# The height used in the 0dim mode. The values should be found
+#  in the restart file. The new values of height will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SLOWPROC_HEIGHT__01 = 0.
+SLOWPROC_HEIGHT__02 = 50.
+SLOWPROC_HEIGHT__03 = 50.
+SLOWPROC_HEIGHT__04 = 30.
+SLOWPROC_HEIGHT__05 = 30.
+SLOWPROC_HEIGHT__06 = 30.
+SLOWPROC_HEIGHT__07 = 20.
+SLOWPROC_HEIGHT__08 = 20.
+SLOWPROC_HEIGHT__09 = 20.
+SLOWPROC_HEIGHT__10 = .2
+SLOWPROC_HEIGHT__11 = .2
+SLOWPROC_HEIGHT__12 = .4
+SLOWPROC_HEIGHT__13 = .4
+# default = 0., 30., 30., 20., 20., 20., 15., 15., 15., .5, .6, 1.0, 1.0
+
+
+# Fraction of the 3 soil types (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction for the 3 soil types
+#  in the mesh in the following order : sand loam and clay.
+SOIL_FRACTIONS__01 = 0.28
+SOIL_FRACTIONS__02 = 0.52
+SOIL_FRACTIONS__03 = 0.20
+# default = 0.28, 0.52, 0.20
+
+# Temperature used for the initial guess of LAI
+# If there is no LAI in the restart file, we may need
+#  a temperature that is used to guess the initial LAI.
+SLOWPROC_LAI_TEMPDIAG = 280.
+# default = 280.
+
+# Soil level (m) used for canopy development 
+# If STOMATE is not activated.
+# The temperature at this soil depth is used to determine the LAI when
+#   STOMATE is not activated.
+SECHIBA_ZCANOP = 0.5
+# default = 0.5
+
+# Fraction of other surface types within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of ice, lakes, etc. is read from the restart file. If
+#  it is not found there we will use the values provided here.
+#  For the moment, there is only ice.
+SECHIBA_FRAC_NOBIO = 0.0
+# default = 0.0
+
+# Fraction of the clay fraction (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction of clay in the grid box.
+CLAY_FRACTION = 0.2
+# default = 0.2
+
+# Should the surface parameters be prescribed
+# This flag allows the user to impose the surface parameters
+#  (Albedo Roughness and Emissivity). It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_AZE = n
+# default = n
+
+# Emissivity of the surface for LW radiation
+# If IMPOSE_AZE
+# The surface emissivity used for compution the LE emission
+#  of the surface in a 0-dim version. Values range between 
+#  0.97 and 1.. The GCM uses 0.98.
+CONDVEG_EMIS = 1.0
+# default = 1.0
+
+# SW visible albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in visible wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBVIS = 0.25
+# default = 0.25
+
+# SW near infrared albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in near infrared wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBNIR = 0.25
+# default = 0.25
+
+# Average method for z0
+# If this flag is set to true (y) then the neutral Cdrag
+#  is averaged instead of the log(z0). This should be
+#  the prefered option. We still wish to keep the other
+#  option so we can come back if needed. If this is
+#  desired then one should set Z0CDRAG_AVE = n
+Z0CDRAG_AVE = y
+# default = y
+
+# Surface roughness (m)
+# If IMPOSE_AZE
+# Surface rougness to be used on the point if a 0-dim version
+#  of SECHIBA is used. Look at the description of the forcing  
+#  data for the correct value.
+CONDVEG_Z0 = 0.15
+# default = 0.15_stnd
+
+# Height to be added to the height of the first level (m)
+# If IMPOSE_AZE
+# ORCHIDEE assumes that the atmospheric level height is counted
+#  from the zero wind level. Thus to take into account the roughness
+#  of tall vegetation we need to correct this by a certain fraction
+#  of the vegetation height. This is called the roughness height in
+#  ORCHIDEE talk.
+ROUGHHEIGHT = 0.0
+# default = 0.0
+
+# The snow albedo used by SECHIBA
+# This option allows the user to impose a snow albedo.
+#  Default behaviour is to use the model of snow albedo
+#  developed by Chalita (1993).
+CONDVEG_SNOWA = default
+# default = use the model of snow albedo developed by Chalita
+
+# Switch bare soil albedo dependent (if TRUE) on soil wetness
+# If TRUE, the model for bare soil albedo is the old formulation.
+#  Then it depend on the soil dry or wetness. If FALSE, it is the 
+#  new computation that is taken, it is only function of soil color.
+ALB_BARE_MODEL = FALSE
+# default = FALSE
+
+# Initial snow mass if not found in restart
+# The initial value of snow mass if its value is not found
+#   in the restart file. This should only be used if the model is 
+#   started without a restart file.
+HYDROL_SNOW = 0.0
+# default = 0.0
+
+
+# Initial snow age if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOWAGE = 0.0
+# default = 0.0
+
+# Initial snow amount on ice, lakes, etc. if not found in restart
+# The initial value of snow if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO = 0.0
+# default = 0.0
+
+# Initial snow age on ice, lakes, etc. if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO_AGE = 0.0
+# default = 0.0
+
+# Initial dry soil height if not found in restart for ORCHIDEE_1.3 to 1.5 Tags only.
+# The initial value of dry soil height if its value is not found
+# in the restart file. This should only be used if the model is 
+# started without a restart file.
+HYDROL_HDRY = 0.0
+# default = 0.0
+
+# Initial soil moisture stress if not found in restart
+# The initial value of soil moisture stress if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_HUMR = 1.0
+# default = 1.0
+
+# Total depth of soil reservoir
+HYDROL_SOIL_DEPTH = 4.
+# default = 2.
+
+# Root profile
+# Default values were defined for 2 meters soil depth.
+# For 4 meters soil depth, you may use those ones :
+# 5., .4, .4, 1., .8, .8, 1., 1., .8, 4., 1., 4., 1.
+HYDROL_HUMCSTE = 5., .4, .4, 1., .8, .8, 1., 1., .8, 4., 1., 4., 1.
+# default =  5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+
+# Initial restart deep soil moisture if not found in restart
+# The initial value of deep soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. Default behaviour is a saturated soil.
+HYDROL_BQSB = default
+# default = Maximum quantity of water (Kg/M3) * Total depth of soil reservoir = 150. * 2
+
+# Initial upper soil moisture if not found in restart
+# The initial value of upper soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_GQSB = 0.0
+# default = 0.0
+
+# Initial upper reservoir depth if not found in restart
+# The initial value of upper reservoir depth if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_DSG = 0.0
+# default = 0.0
+
+# Initial dry soil above upper reservoir if not found in restart
+# The initial value of dry soil above upper reservoir if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. The default behaviour
+#  is to compute it from the variables above. Should be OK most of 
+#  the time.
+HYDROL_DSP = default
+# default = Total depth of soil reservoir - HYDROL_BQSB / Maximum quantity of water (Kg/M3) = 0.0
+
+# Initial water on canopy if not found in restart
+# The initial value of moisture on canopy if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_QSV = 0.0
+# default = 0.0
+
+# Soil moisture on each soil tile and levels
+# The initial value of mc if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_MOISTURE_CONTENT = 0.3
+# default = 0.3
+
+# US_NVM_NSTM_NSLM
+# The initial value of us (relative moisture) if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+US_INIT = 0.0
+# default = 0.0
+
+# Coefficient for free drainage at bottom
+# The initial value of free drainage if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+FREE_DRAIN_COEF = 1.0, 1.0, 1.0
+# default = 1.0, 1.0, 1.0
+
+# Bare soil evap on each soil if not found in restart
+# The initial value of bare soils evap if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+EVAPNU_SOIL = 0.0
+# default = 0.0
+
+# Initial temperature if not found in restart
+# The initial value of surface temperature if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+ENERBIL_TSURF = 280.
+# default = 280.
+
+# Initial Soil Potential Evaporation
+# The initial value of soil potential evaporation if its value 
+#  is not found in the restart file. This should only be used if
+#  the model is started without a restart file. 
+ENERBIL_EVAPOT = 0.0
+# default = 0.0
+
+# Initial soil temperature profile if not found in restart
+# The initial value of the temperature profile in the soil if 
+#   its value is not found in the restart file. This should only 
+#   be used if the model is started without a restart file. Here
+#   we only require one value as we will assume a constant 
+#   throughout the column.
+THERMOSOIL_TPRO = 280.
+# default = 280.
+
+# Initial leaf CO2 level if not found in restart
+# The initial value of leaf_ci if its value is not found
+#  in the restart file. This should only be used if the model is
+#  started without a restart file.
+DIFFUCO_LEAFCI = 233.
+# default = 233.
+
+
+# Keep cdrag coefficient from gcm.
+# Set to .TRUE. if you want q_cdrag coming from GCM.
+#  Keep cdrag coefficient from gcm for latent and sensible heat fluxes.
+#  TRUE if q_cdrag on initialization is non zero (FALSE for off-line runs).
+CDRAG_FROM_GCM = n
+# default =  IF q_cdrag == 0 ldq_cdrag_from_gcm = .FALSE. ELSE .TRUE.
+
+
+# Artificial parameter to increase or decrease canopy resistance
+# Add from Nathalie - the 28 of March 2006 - advice from Fred Hourdin
+# By PFT.
+RVEG_PFT = 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.
+# default = 1.
+
+
+# Interception reservoir coefficient.
+# Transforms leaf area index into size of interception reservoir
+#  for slowproc_derivvar or stomate.
+SECHIBA_QSINT = 0.1
+# default = 0.1
+
+#**************************************************************************
+# LAI
+#**************************************************************************
+
+# Read the LAI map
+# It is possible to read a 12 month LAI map which will
+#  then be interpolated to daily values as needed.
+#  If n => type_of_lai (constant_veg.f90)
+#     - mean    : lai(ji,jv) = undemi * (llaimax(jv) + llaimin(jv))
+#     - inter   : llaimin(jv) + tempfunc(stempdiag(ji,lcanop)) * (llaimax(jv) - llaimin(jv))
+LAI_MAP = n
+# default = n
+
+# Name of file from which the vegetation map is to be read
+# If LAI_MAP
+# The name of the file to be opened to read the LAI
+#  map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#  map which is derived from a Nicolas VIOVY one. 
+LAI_FILE = lai2D.nc
+# default = ../surfmap/lai2D.nc
+
+# Flag to use old "interpolation" of LAI
+# If LAI_MAP
+# If you want to recover the old (ie orchidee_1_2 branch) 
+# "interpolation" of LAI map.
+SLOWPROC_LAI_OLD_INTERPOL = n
+# default = n
+
+#**************************************************************************
+# LAND_USE
+#**************************************************************************
+
+# Read a land_use vegetation map
+# pft values are needed, max time axis is 293
+LAND_USE = y
+# default = n
+
+# Year of the land_use vegetation map readed
+# year off the pft map.
+# default is 133 for year 1982  (as 1982 - 1850 + 1 = 133)
+# If LAND_USE
+VEGET_YEAR = 1
+# default = 133
+
+# booleen to indicate that a new LAND USE file will be used (since 1.9.5 version).
+# The parameter is used to bypass veget_year count 
+# and reinitialize it with VEGET_YEAR parameter.
+# Then it is possible to change LAND USE file.
+# If LAND_USE
+VEGET_REINIT = y
+# default = n
+
+# Update vegetation frequency (since 2.0 version)
+# The veget datas will be update each this time step.
+# If LAND_USE
+VEGET_UPDATE = 0Y
+# default = 1Y
+
+# treat land use modifications
+# With this variable, you can use a Land Use map
+# to simulate anthropic modifications such as   
+# deforestation.                                
+# If LAND_USE
+LAND_COVER_CHANGE = n
+# default = y
+
+#**************************************************************************
+
+# agriculture allowed?
+# With this variable, you can determine
+#  whether agriculture is allowed
+AGRICULTURE = y
+# default = y
+
+#**************************************************************************
+
+# Time within the day simulated
+# This is the time spent simulating the current day. This variable is
+#  prognostic as it will trigger all the computations which are
+#  only done once a day.
+SECHIBA_DAY = 0.0
+# default = 0.0
+
+# Time step of STOMATE and other slow processes
+# Time step (s) of regular update of vegetation
+#  cover, LAI etc. This is also the time step
+#  of STOMATE.
+DT_SLOW = 86400.
+# default = un_jour = 86400.
+
+#**************************************************************************
+
+# Allows to switch on the multilayer hydrology of CWRR
+# This flag allows the user to decide if the vertical
+#  hydrology should be treated using the multi-layer 
+#  diffusion scheme adapted from CWRR by Patricia de Rosnay.
+#  by default the Choisnel hydrology is used.
+HYDROL_CWRR = n
+# default = n
+
+# do horizontal diffusion?
+# If TRUE, then water can diffuse horizontally between
+#  the PFTs' water reservoirs.
+HYDROL_OK_HDIFF = n
+# default = n
+ 
+
+# time scale (s) for horizontal diffusion of water
+# If HYDROL_OK_HDIFF
+# Defines how fast diffusion occurs horizontally between
+#  the individual PFTs' water reservoirs. If infinite, no
+#  diffusion.
+HYDROL_TAU_HDIFF = 86400.
+# default = 86400.
+
+# Percent of precip that is not intercepted by the canopy (only for TAG 1.6).
+# During one rainfall event, PERCENT_THROUGHFALL% of the incident rainfall
+#  will get directly to the ground without being intercepted.
+PERCENT_THROUGHFALL = 30.
+# default = 30.
+
+# Percent by PFT of precip that is not intercepted by the canopy (since TAG 1.8).
+# During one rainfall event, PERCENT_THROUGHFALL_PFT% of the incident rainfall
+#  will get directly to the ground without being intercepted, for each PFT..
+PERCENT_THROUGHFALL_PFT = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+# default = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+
+# Decides if we route the water or not
+# This flag allows the user to decide if the runoff
+#  and drainage should be routed to the ocean
+#  and to downstream grid boxes.
+RIVER_ROUTING = n
+# default = n
+
+# Name of file which contains the routing information
+# The file provided here should allow the routing module to
+#  read the high resolution grid of basins and the flow direction 
+#  from one mesh to the other.
+ROUTING_FILE = routing.nc
+# default = routing.nc
+
+# Time step of the routing scheme
+# If RIVER_ROUTING
+# This values gives the time step in seconds of the routing scheme. 
+#   It should be multiple of the main time step of ORCHIDEE. One day
+#   is a good value.
+ROUTING_TIMESTEP = 86400
+# default = 86400
+
+# Number of rivers 
+# If RIVER_ROUTING
+# This parameter chooses the number of largest river basins
+#  which should be treated as independently as rivers and not
+#  flow into the oceans as diffusion coastal flow.
+ROUTING_RIVERS = 50
+# default = 50
+
+# Should we compute an irrigation flux 
+# This parameters allows the user to ask the model
+#  to compute an irigation flux. This performed for the
+#  on very simple hypothesis. The idea is to have a good
+#  map of irrigated areas and a simple function which estimates
+#  the need to irrigate.
+DO_IRRIGATION = n
+# default = n
+
+# Name of file which contains the map of irrigated areas
+# If IRRIGATE
+# The name of the file to be opened to read the field
+#  with the area in m^2 of the area irrigated within each
+#  0.5 0.5 deg grid box. The map currently used is the one
+#  developed by the Center for Environmental Systems Research 
+#  in Kassel (1995).
+IRRIGATION_FILE = irrigated.nc
+# default = irrigated.nc
+
+# Should we include floodplains 
+# This parameters allows the user to ask the model
+#  to take into account the flood plains and return 
+#  the water into the soil moisture. It then can go 
+#  back to the atmopshere. This tried to simulate 
+#  internal deltas of rivers.
+DO_FLOODPLAINS = n
+# default = n
+
+#**************************************************************************
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/PARAM/stomate.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/PARAM/stomate.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/PARAM/stomate.def	(revision 405)
@@ -0,0 +1,206 @@
+#
+#**************************************************************************
+#                    Namelist for STOMATE
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of STOMATE
+#**************************************************************************
+
+# Model chatting level
+# level of online diagnostics in STOMATE (0-4)
+# With this variable, you can determine how much online information STOMATE
+#  gives during the run. 0 means virtually no info.
+BAVARD = 1
+# default = 1
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+
+# Name of file from which the reference
+# The name of the file to be opened to read
+#  temperature is read
+#  the reference surface temperature.
+#  The data from this file is then interpolated
+#  to the grid of the model.
+#  The aim is to get a reference temperature either
+#  to initialize the corresponding prognostic model
+#  variable correctly (ok_dgvm = TRUE) or to impose it
+#  as boundary condition (ok_dgvm = FALSE)
+REFTEMP_FILE = reftemp.nc
+# default = reftemp.nc
+# Input and output restart file for STOMATE :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions of STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened of STOMATE
+#   to extract the initial values of all prognostic values of STOMATE.
+STOMATE_RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened
+#        to write the final values of all prognostic values
+#        of STOMATE.
+STOMATE_RESTART_FILEOUT = stomate_rest_out.nc
+# default = stomate_restart.nc
+
+# Forcing files for TESTSTOMATE and FORCESOIL
+#---------------------------------------------------------------------
+
+# Name of STOMATE's forcing file
+# Name that will be given to STOMATE's offline forcing file
+STOMATE_FORCING_NAME = stomate_forcing.nc
+#default = NONE
+
+# Size of STOMATE forcing data in memory (MB)
+# This variable determines how many
+#  forcing states will be kept in memory.
+#  Must be a compromise between memory
+#  use and frequeny of disk access.
+STOMATE_FORCING_MEMSIZE = 50
+# default = 50
+
+# Name of STOMATE's carbon forcing file
+# Name that will be given to STOMATE's carbon offline forcing file
+STOMATE_CFORCING_NAME = stomate_Cforcing.nc
+# default = NONE
+
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+# STOMATE does minimum service
+# set to TRUE if you want STOMATE to read
+#  and write its start files and keep track
+#  of longer-term biometeorological variables.
+#  This is useful if OK_STOMATE is not set,
+#  but if you intend to activate STOMATE later.
+#  In that case, this run can serve as a 
+#  spinup for longer-term biometeorological
+#  variables.
+STOMATE_WATCHOUT = n
+# default = n
+
+
+# Output file name :
+#---------------------------------------------------------------------
+
+# Name of file in which STOMATE's output is going to be written
+# This file is going to be created by the model
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+STOMATE_OUTPUT_FILE = stomate_history.nc
+# default = stomate_history.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# STOMATE history output level (0..10)
+#  0: nothing is written; 10: everything is written
+STOMATE_HISTLEVEL = 10
+# default = 10
+
+# STOMATE_IPCC_OUTPUT_FILE
+# This file is going to be created by the model
+#    and will contain the output from the model.
+#    This file is a truly COADS compliant netCDF file.
+#    It will be generated by the hist software from
+#    the IOIPSL package.
+# Name of file in which STOMATE's output is going
+# to be written
+STOMATE_IPCC_OUTPUT_FILE = stomate_ipcc_history.nc
+# default = stomate_ipcc_history.nc
+
+# STOMATE_IPCC_HIST_DT
+# Time step of the STOMATE IPCC history file
+# STOMATE IPCC history time step (d)
+STOMATE_IPCC_HIST_DT = 0.
+# default = 0.
+
+# Write frequency for output files (STOMATE in days) :
+#---------------------------------------------------------------------
+
+# STOMATE history time step (d)
+# Time step of the STOMATE history file
+# Care : this variable must be higher than DT_SLOW
+STOMATE_HIST_DT = 10.
+# default = 10.
+
+
+#---------------------------------------------------------------------
+# FORCESOIL CARBON spin up parametrization
+#---------------------------------------------------------------------
+
+# Number of time steps per year for carbon spinup.
+FORCESOIL_STEP_PER_YEAR = 12
+# default = 12
+
+# Number of years saved for carbon spinup.
+FORCESOIL_NB_YEAR = 1
+# default = 1
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate STOMATE?
+# set to TRUE if STOMATE is to be activated
+STOMATE_OK_STOMATE = n
+# default = n
+
+# Activate DGVM?
+# set to TRUE if Dynamic Vegetation DGVM is to be activated
+STOMATE_OK_DGVM = n
+# default = n
+
+# Index of grid point for online diagnostics
+# This is the index of the grid point which will be used for online diagnostics.
+STOMATE_DIAGPT = 1
+# default = 1
+
+# constant tree mortality
+# If yes, then a constant mortality is applied to trees. 
+#  Otherwise, mortality is a function of the trees' 
+#  vigour (as in LPJ).
+LPJ_GAP_CONST_MORT = y
+# default = y
+
+# no fire allowed
+# With this variable, you can allow or not
+#  the estimation of CO2 lost by fire
+FIRE_DISABLE = n
+# default = n
+
+#**************************************************************************
+
+# Harvert model for agricol PFTs.
+# Compute harvest above ground biomass for agriculture.
+# Change daily turnover.
+HARVEST_AGRI = y
+# default = y
+
+# herbivores allowed?
+# With this variable, you can activate herbivores 
+HERBIVORES = n
+# default = n
+
+# treat expansion of PFTs across a grid cell?
+# With this variable, you can determine
+#  whether we treat expansion of PFTs across a
+#  grid cell.
+TREAT_EXPANSION = n
+# default = n
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/atlas_FLUXNET.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/atlas_FLUXNET.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/atlas_FLUXNET.cfg	(revision 405)
@@ -0,0 +1,162 @@
+#!/bin/ksh
+#set -vx
+
+#**************************************************************
+# Author: Martial Mancip, Nicolas Vuichard
+# Contact: Nioclas.Vuichard@lsce.jussieu.fr
+# $Date:
+# $Name$
+# $Revision$
+# History:
+# Modification: Martial Mancip
+#
+#**************************************************************
+
+input=$@
+paper=-p
+quality=cx1800
+#cx800 cx1200
+#frequency=1:12:6
+echo $input
+#reference_file=RRRRRRR
+#validation directory=VVVVVVV
+debug=
+#-d
+
+# Ratio one day over time step
+one_day=86400
+ratio=$(( one_day/1800 ))
+
+ssbx=481
+
+#----------------------
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "PFT distribution" -o  pft ORCHIDEE_pft.jnl \
+                                                                      "\"PFT distribution\" RRRRRRR inputfile MAXVEGETFRAC"
+
+
+# Smooth over sbx values
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Sensible heat flux : diff with obs" -o  fluxsens_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Sensible heat flux : diff with obs\" VVVVVVV RRRRRRR inputfile Qh Qh $FYEAR \"W/m2\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Latent heat flux : diff with obs" -o  fluxlat_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Latent heat flux : diff with obs\" VVVVVVV RRRRRRR inputfile Qle Qle $FYEAR \"W/m2\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Surface Temperature : diff with obs" -o  tsoil_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Surface Temperature : diff with obs\" VVVVVVV RRRRRRR inputfile TSOIL (AvgSurfT-273.15)  $FYEAR \"degC\" $ssbx "
+
+# slowproc :  veget(ji,jv) = veget_max(ji,jv) * ( 1. - exp( - lai(ji,jv) * ext_coef(jv) ) )
+# =>          lai = - ln( 1. - veget/veget_max) / ext_coef
+ext_coef=0.5
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "LAI : lai mean with tsoil/4 obs" -o  lai_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"lai : lai mean with tsoil/4\" VVVVVVV RRRRRRR inputfile (tsoil/4) (0.-maxvegetfrac*ln(1.-vegetfrac/maxvegetfrac)/$ext_coef) $FYEAR \"1\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Potential evapotranspiration : diff with obs" -o  epot_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Potential evapotranspiration : diff with obs\" VVVVVVV RRRRRRR inputfile (ET*${ratio}) (PotEvap*${one_day})  $FYEAR \"mm/d\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Soil moisture stress : diff with obs" -o  humr_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Soil moisture stress : diff with obs\" VVVVVVV RRRRRRR inputfile RH humrel  $FYEAR \"%\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Soil moisture content 1 : diff with obs" -o  humr1_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Soil moisture content 1 : diff with obs\" VVVVVVV RRRRRRR inputfile SWC humrel  $FYEAR \"%\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "lwnet : diff with obs" -o  lwnet_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"lwnet : diff with obs\" VVVVVVV RRRRRRR inputfile LWnet LWnet  $FYEAR \"%\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "swnet : diff with obs" -o  swnet_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"swnet : diff with obs\" VVVVVVV RRRRRRR inputfile SWnet SWnet  $FYEAR \"%\" $ssbx "
+
+
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "netrad : diff with obs" -o  netrad_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                       "\"netrad : diff with obs\" VVVVVVV RRRRRRR inputfile netrad (LWnet+SWnet)  $FYEAR \"%\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "gpp : diff with obs" -o  gpp_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"gpp : diff with obs\" VVVVVVV RRRRRRR inputfile GPP GPP*maxvegetfrac*1800) $FYEAR \"gC/m2/day\" $ssbx"
+#                                                                     "\"gpp : diff with obs\" VVVVVVV RRRRRRR inputfile (GPP*${ratio}) (GPP*${one_day}) $FYEAR \"gC/m2/day\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "nee : diff with obs" -o  nee_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                        "\"nee : diff with obs\" VVVVVVV RRRRRRR inputfile (NEE*${ratio}) (NEE*${one_day}) $FYEAR \"gC/m2/day\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Ecosystem respiration : diff with obs" -o  reco_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                        "\"Ecosystem respiration\" VVVVVVV RRRRRRR inputfile (Reco*${ratio}) ((maint_resp+hetero_resp+growth_resp)*${one_day})  $FYEAR \"gC/m2/day\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "nee : diff with obs" -o  nee_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"nee : diff with obs\" VVVVVVV RRRRRRR inputfile NEE (NEE*maxvegetfrac*1800) $FYEAR \"gC/m2/day\" $ssbx "
+
+# Annual cumulative values
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Sensible heat flux : Annual diff with obs" -o  fluxsens_year ORCHIDEE_3yeardif.jnl \
+                                                                      "\"Sensible heat flux : Annual diff with obs\" VVVVVVV RRRRRRR inputfile Qh Qh $FYEAR $DUREE \"W/m2\" ave"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Latent heat flux : Annual diff with obs" -o  fluxlat_year ORCHIDEE_3yeardif.jnl \
+                                                                      "\"Latent heat flux : Annual diff with obs\" VVVVVVV RRRRRRR inputfile Qle Qle $FYEAR $DUREE \"W/m2\" ave"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Surface Temperature : Annual diff with obs" -o  tsoil_year ORCHIDEE_3yeardif.jnl \
+                                                                      "\"Surface Temperature : Annual diff with obs\" VVVVVVV RRRRRRR inputfile TSOIL (AvgSurfT-273.15) $FYEAR $DUREE \"degC\" ave"
+
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" != "SECHIBA" ]; then
+
+    echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "gpp : Annual diff with obs" -o  gpp_year ORCHIDEE_3yeardif.jnl \
+                                                                          "\"gpp : Annual diff with obs\" VVVVVVV RRRRRRR inputfile (GPP) (GPP*1800) $FYEAR $DUREE \"gC/m2/an\" sum"
+
+fi
+
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" = "OK_STOMATE" ]; then
+
+    echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "nee : Annual diff with obs" -o  nee_year ORCHIDEE_3yeardif.jnl \
+                                                                          "\"nee : Annual diff with obs\" VVVVVVV RRRRRRR inputfile (NEE) (NEE*1800) $FYEAR $DUREE \"gC/m2/an\" sum"
+
+    echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Ecosystem respiration : Annual diff with obs" -o  reco_year ORCHIDEE_3yeardif.jnl \
+                                                                          "\"Ecosystem respiration : Annual diff with obs\" VVVVVVV RRRRRRR inputfile (Reco) ((maint_resp+hetero_resp+growth_resp)*1800) $FYEAR $DUREE \"gC/m2/an\" sum"
+fi
+
+
+#Â Diurnal cycle
+
+let ANNEE=0
+while [ $ANNEE -lt $DUREE ]; do
+  let ANNEE2=$ANNEE+1
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Sensible heat flux : climatologie_${ANNEE2}" -o  fluxsens_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Sensible heat flux\" VVVVVVV RRRRRRR inputfile Qh Qh sloop"
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Latent heat flux : climatologie_${ANNEE2}" -o  fluxlat_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Latent heat flux\" VVVVVVV RRRRRRR inputfile Qle Qle sloop"
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Surface Temperature : climatologie_${ANNEE2}" -o  tsoil_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Surface Temperature\" VVVVVVV RRRRRRR inputfile TSOIL (AvgSurfT-273.15) sloop"
+
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "LAI : climatologie_${ANNEE2}" -o  lai_day ORCHIDEE_12day.jnl \
+                                                                                               "\"LAI\" VVVVVVV RRRRRRR inputfile (tsoil/4) (0.-maxvegetfrac*ln(1.-vegetfrac/maxvegetfrac)/$ext_coef) sloop"
+  if [ "${F_FILE}" = "Cabauw" ]; then
+
+      echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "lwnet : climatologie_${ANNEE2}" -o  lwnet_day ORCHIDEE_12day.jnl "\"lwnet\" VVVVVVV RRRRRRR inputfile LWnet lwnet  sloop"
+
+      echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "swnet : climatologie_${ANNEE2}" -o  swnet_day ORCHIDEE_12day.jnl "\"swnet\" VVVVVVV RRRRRRR inputfile SWnet swnet sloop"
+
+  else
+
+      echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "netrad : climatologie_${ANNEE2}" -o  netrad_day ORCHIDEE_12day.jnl "\"netrad\" VVVVVVV RRRRRRR inputfile netrad SWnet+lwnet sloop"
+
+  fi
+  
+  if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" != "SECHIBA" ]; then
+
+      echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "gpp : climatologie_${ANNEE2}" -o  gpp_day ORCHIDEE_12day.jnl \
+                                                                                                   "\"GPP\" VVVVVVV RRRRRRR inputfile GPP (GPP*maxvegetfrac*1800) sloop" 
+#                                                                                                   "\"GPP\" VVVVVVV RRRRRRR inputfile (GPP*${ratio}) (GPP*${one_day}) sloop" 
+
+  fi
+  if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" = "OK_STOMATE" ]; then
+
+      echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "nee : climatologie_${ANNEE2}" -o  nee_day ORCHIDEE_12day.jnl \
+                                                                                                   "\"nee\" VVVVVVV RRRRRRR inputfile NEE NEE*maxvegetfrac*1800 sloop" 
+
+  fi
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Ecosystem respiration : climatologie_${ANNEE2}" -o reco_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Ecosystem respiration\" VVVVVVV RRRRRRR inputfile (Reco*${ratio}) ((maint_resp+hetero_resp+growth_resp)*${one_day}) sloop"
+
+  let ANNEE=$ANNEE+1
+done
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/atlas_FLUXNET_LATHUILE.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/atlas_FLUXNET_LATHUILE.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/atlas_FLUXNET_LATHUILE.cfg	(revision 405)
@@ -0,0 +1,130 @@
+#!/bin/ksh
+#set -vx
+
+#**************************************************************
+# Author: Martial Mancip, Nicolas Vuichard
+# Contact: Nioclas.Vuichard@lsce.jussieu.fr
+# $Date:
+# $Name$
+# $Revision$
+# History:
+# Modification: Nicolas Vuichard
+#
+#**************************************************************
+
+input=$@
+paper=-p
+quality=cx1800
+#cx800 cx1200
+#frequency=1:12:6
+echo $input
+#reference_file=RRRRRRR
+#validation directory=VVVVVVV
+debug=
+#-d
+
+# Ratio one day over time step
+one_day=86400
+ratio=$(( one_day/1800 ))
+
+ssbx=481
+
+#----------------------
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "PFT distribution" -o  pft ORCHIDEE_pft.jnl \
+                                                                      "\"PFT distribution\" RRRRRRR inputfile MAXVEGETFRAC"
+
+
+# Smooth over sbx values
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Sensible heat flux : diff with obs" -o  fluxsens_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Sensible heat flux : diff with obs\" VVVVVVV RRRRRRR inputfile Fh Qh $FYEAR \"W/m2\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Latent heat flux : diff with obs" -o  fluxlat_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Latent heat flux : diff with obs\" VVVVVVV RRRRRRR inputfile Fle Qle $FYEAR \"W/m2\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Surface Temperature : diff with obs" -o  tsoil_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                       "\"Surface Temperature : diff with obs\" VVVVVVV RRRRRRR inputfile TSOIL (AvgSurfT-273.15)  $FYEAR \"degC\" $ssbx "
+
+# slowproc :  veget(ji,jv) = veget_max(ji,jv) * ( 1. - exp( - lai(ji,jv) * ext_coef(jv) ) )
+# =>          lai = - ln( 1. - veget/veget_max) / ext_coef
+ext_coef=0.5
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "LAI : lai mean with tsoil/4 obs" -o  lai_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"lai : lai mean with tsoil/4\" VVVVVVV RRRRRRR inputfile (tsoil/4) (0.-maxvegetfrac*ln(1.-vegetfrac/maxvegetfrac)/$ext_coef) $FYEAR \"1\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Potential evapotranspiration : diff with obs" -o  epot_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Potential evapotranspiration : diff with obs\" VVVVVVV RRRRRRR inputfile (ET*${ratio}) (PotEvap*${one_day})  $FYEAR \"mm/d\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Soil moisture stress : diff with obs" -o  humr_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Soil moisture stress : diff with obs\" VVVVVVV RRRRRRR inputfile RH humrel  $FYEAR \"%\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Soil moisture content 1 : diff with obs" -o  humr1_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Soil moisture content 1 : diff with obs\" VVVVVVV RRRRRRR inputfile SWC humrel  $FYEAR \"%\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "gpp : diff with obs" -o  gpp_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                           "\"gpp : diff with obs\" VVVVVVV RRRRRRR inputfile (GPP*${ratio}) (GPP*${one_day}) $FYEAR \"gC/m2/day\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "nee : diff with obs" -o  nee_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"nee : diff with obs\" VVVVVVV RRRRRRR inputfile (NEE*${ratio}) (NEE*${one_day}) $FYEAR \"gC/m2/day\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Ecosystem respiration : diff with obs" -o  reco_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Ecosystem respiration\" VVVVVVV RRRRRRR inputfile (Reco*${ratio}) ((maint_resp+hetero_resp+growth_resp)*${one_day})  $FYEAR \"gC/m2/day\" $ssbx "
+
+
+# Annual cumulative values
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Sensible heat flux : Annual diff with obs" -o  fluxsens_year ORCHIDEE_3yeardif.jnl \
+                                                                      "\"Sensible heat flux : Annual diff with obs\" VVVVVVV RRRRRRR inputfile Fh Qh $FYEAR $DUREE \"W/m2\" ave"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Latent heat flux : Annual diff with obs" -o  fluxlat_year ORCHIDEE_3yeardif.jnl \
+                                                                      "\"Latent heat flux : Annual diff with obs\" VVVVVVV RRRRRRR inputfile Fle Qle $FYEAR $DUREE \"W/m2\" ave"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Surface Temperature : Annual diff with obs" -o  tsoil_year ORCHIDEE_3yeardif.jnl \
+                                                                      "\"Surface Temperature : Annual diff with obs\" VVVVVVV RRRRRRR inputfile TSOIL (AvgSurfT-273.15) $FYEAR $DUREE \"degC\" ave"
+
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" != "SECHIBA" ]; then
+
+    echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "gpp : Annual diff with obs" -o  gpp_year ORCHIDEE_3yeardif.jnl \
+                                                                          "\"gpp : Annual diff with obs\" VVVVVVV RRRRRRR inputfile (GPP) (GPP*1800) $FYEAR $DUREE \"gC/m2/an\" sum"
+
+fi
+
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" = "OK_STOMATE" ]; then
+
+    echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "nee : Annual diff with obs" -o  nee_year ORCHIDEE_3yeardif.jnl \
+                                                                          "\"nee : Annual diff with obs\" VVVVVVV RRRRRRR inputfile (NEE) (NEE*1800) $FYEAR $DUREE \"gC/m2/an\" sum"
+
+    echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Ecosystem respiration : Annual diff with obs" -o  reco_year ORCHIDEE_3yeardif.jnl \
+                                                                          "\"Ecosystem respiration : Annual diff with obs\" VVVVVVV RRRRRRR inputfile (Reco) ((maint_resp+hetero_resp+growth_resp)*1800) $FYEAR $DUREE \"gC/m2/an\" sum"
+fi
+
+
+#Â Diurnal cycle
+
+let ANNEE=0
+while [ $ANNEE -lt $DUREE ]; do
+  let ANNEE2=$ANNEE+1
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Sensible heat flux : climatologie_${ANNEE2}" -o  fluxsens_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Sensible heat flux\" VVVVVVV RRRRRRR inputfile Fh Qh sloop"
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Latent heat flux : climatologie_${ANNEE2}" -o  fluxlat_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Latent heat flux\" VVVVVVV RRRRRRR inputfile Fle Qle sloop"
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Surface Temperature : climatologie_${ANNEE2}" -o  tsoil_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Surface Temperature\" VVVVVVV RRRRRRR inputfile TSOIL (AvgSurfT-273.15) sloop"
+
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "LAI : climatologie_${ANNEE2}" -o  lai_day ORCHIDEE_12day.jnl \
+                                                                                               "\"LAI\" VVVVVVV RRRRRRR inputfile (tsoil/4) (0.-maxvegetfrac*ln(1.-vegetfrac/maxvegetfrac)/$ext_coef) sloop"
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "gpp : climatologie_${ANNEE2}" -o  gpp_day ORCHIDEE_12day.jnl \
+                                                                                               "\"GPP\" VVVVVVV RRRRRRR inputfile (GPP*${ratio}) (GPP*${one_day}) sloop" 
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "nee : climatologie_${ANNEE2}" -o  nee_day ORCHIDEE_12day.jnl \
+                                                                                               "\"nee\" VVVVVVV RRRRRRR inputfile (NEE*${ratio}) (NEE*${one_day}) sloop" 
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Ecosystem respiration : climatologie_${ANNEE2}" -o reco_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Ecosystem respiration\" VVVVVVV RRRRRRR inputfile (Reco*${ratio}) ((maint_resp+hetero_resp+growth_resp)*${one_day}) sloop"
+
+  let ANNEE=$ANNEE+1
+done
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/atlas_FLUXNET_soenke.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/atlas_FLUXNET_soenke.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/atlas_FLUXNET_soenke.cfg	(revision 405)
@@ -0,0 +1,130 @@
+#!/bin/ksh
+#set -vx
+
+#**************************************************************
+# Author: Martial Mancip, Nicolas Vuichard
+# Contact: Nioclas.Vuichard@lsce.jussieu.fr
+# $Date:
+# $Name$
+# $Revision$
+# History:
+# Modification: Nicolas Vuichard
+#
+#**************************************************************
+
+input=$@
+paper=-p
+quality=cx1800
+#cx800 cx1200
+#frequency=1:12:6
+echo $input
+#reference_file=RRRRRRR
+#validation directory=VVVVVVV
+debug=
+#-d
+
+# Ratio one day over time step
+one_day=86400
+ratio=$(( one_day/1800 ))
+
+ssbx=481
+
+#----------------------
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "PFT distribution" -o  pft ORCHIDEE_pft.jnl \
+                                                                      "\"PFT distribution\" RRRRRRR inputfile MAXVEGETFRAC"
+
+
+# Smooth over sbx values
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Sensible heat flux : diff with obs" -o  fluxsens_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Sensible heat flux : diff with obs\" VVVVVVV RRRRRRR inputfile Fh Qh $FYEAR \"W/m2\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Latent heat flux : diff with obs" -o  fluxlat_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Latent heat flux : diff with obs\" VVVVVVV RRRRRRR inputfile Fle Qle $FYEAR \"W/m2\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Surface Temperature : diff with obs" -o  tsoil_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                       "\"Surface Temperature : diff with obs\" VVVVVVV RRRRRRR inputfile TSOIL (AvgSurfT-273.15)  $FYEAR \"degC\" $ssbx "
+
+# slowproc :  veget(ji,jv) = veget_max(ji,jv) * ( 1. - exp( - lai(ji,jv) * ext_coef(jv) ) )
+# =>          lai = - ln( 1. - veget/veget_max) / ext_coef
+ext_coef=0.5
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "LAI : lai mean with tsoil/4 obs" -o  lai_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"lai : lai mean with tsoil/4\" VVVVVVV RRRRRRR inputfile (tsoil/4) (0.-maxvegetfrac*ln(1.-vegetfrac/maxvegetfrac)/$ext_coef) $FYEAR \"1\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Potential evapotranspiration : diff with obs" -o  epot_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Potential evapotranspiration : diff with obs\" VVVVVVV RRRRRRR inputfile (ET*${ratio}) (PotEvap*${one_day})  $FYEAR \"mm/d\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Soil moisture stress : diff with obs" -o  humr_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Soil moisture stress : diff with obs\" VVVVVVV RRRRRRR inputfile RH humrel  $FYEAR \"%\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Soil moisture content 1 : diff with obs" -o  humr1_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Soil moisture content 1 : diff with obs\" VVVVVVV RRRRRRR inputfile SWC humrel  $FYEAR \"%\" $ssbx "
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "gpp : diff with obs" -o  gpp_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"gpp : diff with obs\" VVVVVVV RRRRRRR inputfile ((Acan-Reco)*${ratio}) (GPP*${one_day}) $FYEAR \"gC/m2/day\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "nee : diff with obs" -o  nee_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"nee : diff with obs\" VVVVVVV RRRRRRR inputfile (NEE*${ratio}) (NEE*${one_day}) $FYEAR \"gC/m2/day\" $ssbx"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Ecosystem respiration : diff with obs" -o  reco_sbx ORCHIDEE_3sbxdif.jnl \
+                                                                      "\"Ecosystem respiration\" VVVVVVV RRRRRRR inputfile (Reco*${ratio}) ((maint_resp+hetero_resp+growth_resp)*${one_day})  $FYEAR \"gC/m2/day\" $ssbx "
+
+
+# Annual cumulative values
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Sensible heat flux : Annual diff with obs" -o  fluxsens_year ORCHIDEE_3yeardif.jnl \
+                                                                      "\"Sensible heat flux : Annual diff with obs\" VVVVVVV RRRRRRR inputfile Fh Qh $FYEAR $DUREE \"W/m2\" ave"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Latent heat flux : Annual diff with obs" -o  fluxlat_year ORCHIDEE_3yeardif.jnl \
+                                                                      "\"Latent heat flux : Annual diff with obs\" VVVVVVV RRRRRRR inputfile Fle Qle $FYEAR $DUREE \"W/m2\" ave"
+
+echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Surface Temperature : Annual diff with obs" -o  tsoil_year ORCHIDEE_3yeardif.jnl \
+                                                                      "\"Surface Temperature : Annual diff with obs\" VVVVVVV RRRRRRR inputfile TSOIL (AvgSurfT-273.15) $FYEAR $DUREE \"degC\" ave"
+
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" != "SECHIBA" ]; then
+
+    echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "gpp : Annual diff with obs" -o  gpp_year ORCHIDEE_3yeardif.jnl \
+                                                                          "\"gpp : Annual diff with obs\" VVVVVVV RRRRRRR inputfile (GPP) (GPP*1800) $FYEAR $DUREE \"gC/m2/an\" sum"
+
+fi
+
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" = "OK_STOMATE" ]; then
+
+    echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "nee : Annual diff with obs" -o  nee_year ORCHIDEE_3yeardif.jnl \
+                                                                          "\"nee : Annual diff with obs\" VVVVVVV RRRRRRR inputfile (NEE) (NEE*1800) $FYEAR $DUREE \"gC/m2/an\" sum"
+
+    echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -p -i "Ecosystem respiration : Annual diff with obs" -o  reco_year ORCHIDEE_3yeardif.jnl \
+                                                                          "\"Ecosystem respiration : Annual diff with obs\" VVVVVVV RRRRRRR inputfile (Reco) ((maint_resp+hetero_resp+growth_resp)*1800) $FYEAR $DUREE \"gC/m2/an\" sum"
+fi
+
+
+#Â Diurnal cycle
+
+let ANNEE=0
+while [ $ANNEE -lt $DUREE ]; do
+  let ANNEE2=$ANNEE+1
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Sensible heat flux : climatologie_${ANNEE2}" -o  fluxsens_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Sensible heat flux\" VVVVVVV RRRRRRR inputfile Fh Qh sloop"
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Latent heat flux : climatologie_${ANNEE2}" -o  fluxlat_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Latent heat flux\" VVVVVVV RRRRRRR inputfile Fle Qle sloop"
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Surface Temperature : climatologie_${ANNEE2}" -o  tsoil_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Surface Temperature\" VVVVVVV RRRRRRR inputfile TSOIL (AvgSurfT-273.15) sloop"
+
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "LAI : climatologie_${ANNEE2}" -o  lai_day ORCHIDEE_12day.jnl \
+                                                                                               "\"LAI\" VVVVVVV RRRRRRR inputfile (tsoil/4) (0.-maxvegetfrac*ln(1.-vegetfrac/maxvegetfrac)/$ext_coef) sloop"
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "gpp : climatologie_${ANNEE2}" -o  gpp_day ORCHIDEE_12day.jnl \
+                                                                                               "\"GPP\" VVVVVVV RRRRRRR inputfile ((Acan-Reco)*${ratio}) (GPP*${one_day}) sloop" 
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "nee : climatologie_${ANNEE2}" -o  nee_day ORCHIDEE_12day.jnl \
+                                                                                               "\"nee\" VVVVVVV RRRRRRR inputfile (NEE*${ratio}) (NEE*${one_day}) sloop" 
+
+  echo $input | ferretloop - ${debug} --ps2gif_option "-g $quality" -s ${ANNEE}:${ANNEE}:1 -p -i "Ecosystem respiration : climatologie_${ANNEE2}" -o reco_day ORCHIDEE_12day.jnl \
+                                                                                               "\"Ecosystem respiration\" VVVVVVV RRRRRRR inputfile (Reco*${ratio}) ((maint_resp+hetero_resp+growth_resp)*${one_day}) sloop"
+
+  let ANNEE=$ANNEE+1
+done
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/config.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/config.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/config.card	(revision 405)
@@ -0,0 +1,85 @@
+#
+# This is config.card file for restart with an NEW libIGCM simulation tree.
+#
+#====================================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+#========================================================================
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=Sp
+LongName="Spin Up for ORCHIDEE. See spinup.card for options."
+TagName=OL2
+#============================
+#-- leap, noleap, 360d
+CalendarType= gregorian
+#-- Start and End of Job
+#-- "YYYY-MM-DD"
+DateBegin=0000-01-01
+DateEnd=0999-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength= 1Y
+PeriodNb= 1
+#============================
+#-- PBS Class (required on brodie mono/multi)
+JobClass=mono
+#JobClass=multi
+#============================
+#-- Total Number of Processors (minimum is 2 for a coupled configuration)
+JobNumProcTot=1
+#============================
+#-- Run Options : here for oasis coupling
+JobRunOptions='"-np "${NUM_PROC}" -max_np "${NUM_PROC}'
+#JobRunOptions='"-np "${NUM_PROC}'
+
+#========================================================================
+#========================================================================
+#D-- SRF options passed to SuRFace (SECHIBA) subjobs
+[SRF]
+WriteFrequency="1800s"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1997-12-31
+# Define restart simulation name
+RestartJobName=SPINUP
+RestartPath=${ARCHIVE}/${LOGIN}/IGCM_OUT/${config_UserChoices_TagName}
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#D-- Surface BioGeochemistry ( STOMATE ) subjobs
+[SBG]
+WriteFrequency="1M"
+Restart= n
+#-- Last day of the experience used as restart
+RestartDate= 1900-12-31
+# Define restart simulation name
+RestartJobName= SPINUP
+RestartPath=${ARCHIVE}/${LOGIN}/IGCM_OUT/${config_UserChoices_TagName}
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#D-- Post-treatment options passed to SubJobs on all sites
+# WARNING : You can use thoses options only if you set CONSERVE=y in fluxnet.card
+[SubJobPost]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=NONE
+#D- Do we rebuild parallel output from archive (use NONE to use SCRATCHDIR as buffer)
+RebuildFromArchive=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency= NONE
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency= NONE
+#D- Offset for seasonal average first start dates ; same unit as SeasonalFrequency
+#D- Usefull if you do not want to consider the first X simulation's years
+SeasonalFrequencyOffset=0
+
+#========================================================================
+#========================================================================
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/fluxnet.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/fluxnet.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/fluxnet.card	(revision 405)
@@ -0,0 +1,121 @@
+[FLUXNET]
+# - Fluxnet files path
+FluxnetPath=/home/orchidee01/vuichard/Input_Fluxnet
+
+# - Number of PFTs :
+NbPFTs= 13
+
+#**** Information on the sites to be treated *************************
+#  Number of parameters to modify for each site
+NbSitesParam= 1
+#  Name of the parameters to modify for on each site
+NameSitesParam= ( SECHIBA_VEGMAX )
+#  Name of the component for each parameter described in NameSitesParam (either, SECHIBA, STOMATE, or DRIVER)
+CompSitesParam= ( SECHIBA )
+
+# Sites descriptions
+# 4 first parameters are Name, Forcing file, Initial Year, Number of years in forcing file
+# following parameters are NameSitesParam
+Sites= ( NL-Loo, NL-Loo.nc,  1996,                                 11, \
+     0,   0,   0, 0.8,   0,   0,   0,   0,   0, 0.2,   0,   0,   0.) \
+ \
+       ( DE-Hai, DE-Hai.nc,  2000,                                  7, \
+     0,   0,   0,   0,    0, 0.8,   0,   0,   0, 0.2,   0,   0,   0) \
+ \
+       ( BW-Ma1, BW-Ma1.nc,  1999,                                  3, \
+    0.1, 0.2,   0,   0,   0,   0,   0,   0,   0, 0.7,   0,   0,   0) \
+ \
+       ( FI-Sod, FI-Sod.nc,  2000,                                  7, \
+      0,   0,   0,   0,   0,   0, 0.8,   0,   0, 0.2,   0,   0,   0) \
+ \
+       ( BR-Sa1, BR-Sa1.nc,  2002,                                  3, \
+      0, 0.8,   0,   0,   0,   0,   0,   0,   0, 0.2,   0,   0,   0) \
+ \
+       ( RU-Zot, RU-Zot.nc,  2002,                                  3, \
+     0,   0,   0,   0,   0,   0, 0.8,   0,   0, 0.2,   0,   0,   0) \
+ \
+        ( BR-Ma2, BR-Ma2.nc,  2002,                                  5, \
+      0, 0.8,   0,   0,   0,   0,   0,   0,   0, 0.2,   0,   0,   0)
+
+# To fill the VEGMAX for each site
+# here below is the standard PFT list
+#
+#    1 - Bare soil
+#    2 - tropical  broad-leaved evergreen
+#    3 - tropical  broad-leaved raingreen
+#    4 - temperate needleleaf   evergreen
+#    5 - temperate broad-leaved evergreen
+#    6 - temperate broad-leaved summergreen
+#    7 - boreal    needleleaf   evergreen
+#    8 - boreal    broad-leaved summergreen
+#    9 - boreal    needleleaf   summergreen
+#   10 -           C3           grass
+#   11 -           C4           grass
+#   12 -           C3           agriculture
+#   13 -           C4           agriculture
+
+[SPINUP]
+# Initialisation for spin-up :
+# orchidee with sechiba alone (!!! if ok_stomate == n !!!)
+duree_nostomate=0
+# orchidee with stomate
+duree_inistomate=1
+# teststomate (only if duree_inistomate > 0)
+duree_offlineini=0
+
+# Loop over ORCHIDEE runs (used for spin-up)
+# The whole job is restarted n_iter times
+n_iter=1
+# orchidee with sechiba (and stomate if ok_stomate=y below)
+duree_sechiba=500
+# teststomate
+duree_stomate=0
+# forcesoil
+duree_carbonsol=10000
+
+# Final run (full ORCHIDEE)
+# This last parameter must be non-zero.
+duree_final=200
+
+
+    # POST configuration : 
+    # --------------------
+# Atlas Name : 
+AtlasCfg=atlas_FLUXNET_LATHUILE.cfg
+
+# Observation_file
+observation_file_path='/home/orchidee01/vuichard/Input_Fluxnet/${Site}.nc'
+
+# History file of former ORCHIDEE runs (Reference) to compare with the current simulations
+reference_file_path='/home/orchidee01/vuichard/ORCHIDEE_1951/IGCM_OUT/OL2/Fluxnet_Vuichard/${Site}_sechiba_hist.nc'
+
+# Modulo for SpinUp years
+# by default, only one ATLAS-DIFF will be created 
+# between the last step and the first one.
+#Modulo=15
+
+
+[UserChoices]
+# stomate activated or not ?
+ok_stomate=y
+# Photosynthesis activated or not ?
+ok_co2=y
+# New hydrology (deRosnay) activated or not ?
+ok_newhydrol=n
+
+# DEBUG mode for SPINUP 
+#
+# This mode keep all SPINUP directory in ARCHIVE
+# If disable, all ARCHIVE is automaticly cleaned.
+DEBUG_SPIN=n
+# If you don't want to keep old spinup steps, but last one
+CONSERVE=n 
+
+[SubJobParams]
+# You can specify here any parameters to be modified in sechiba.def, stomate.def or driver.def
+# due to split of orchidee.def in component specific parameter files,
+# you must add here a prefix for the specific parameter file.
+stomate_BAVARD=0
+sechiba_ALMA_OUTPUT=y
+sechiba_SECHIBA_reset_time=y
+driver_SPLIT_DT=1
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/fluxnet.ksh
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/fluxnet.ksh	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/fluxnet.ksh	(revision 405)
@@ -0,0 +1,255 @@
+#!/bin/ksh
+
+#D--------------------------------------------------------------------==
+
+function FLUXNET_initialize
+{
+    IGCM_debug_PushStack "FLUXNET_initialize"
+
+    # config.card : 
+    # -------------
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices
+    typeset option
+    for option in ${config_UserChoices[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option}
+    done
+    
+    DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
+    IGCM_date_GetYearMonth ${DateBegin} year month
+    
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SubJobPost
+    typeset option
+    for option in ${config_SubJobPost[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SubJobPost ${option}
+    done
+    
+    # Subjobs configuration : 
+    # -----------------------
+
+    # 1) UserChoices section of fluxnet.card
+
+    # This section groups standard options to be passed to ORCHIDEE.
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card UserChoices
+    set +A fluxnet_UserChoices -- ${fluxnet_UserChoices[*]} > /dev/null 2>&1
+    typeset option
+    for option in ${fluxnet_UserChoices[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card UserChoices ${option}
+    done
+
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SRF
+    typeset option
+    for option in ${config_SRF[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF ${option}
+    done
+    if [ X"${fluxnet_UserChoices_ok_stomate}" = "Xy" ] ; then
+	IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SBG
+	typeset option
+	for option in ${config_SBG[*]} ; do
+	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG ${option}
+	done
+    fi
+    
+    # 2) FLUXNET section :
+
+    # This section groups specific options for FLUXNET spinup :
+    # - Fluxnet files path
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET FluxnetPath
+
+    # - List of the sites/information to be treated :
+    #   * Number of PFTs
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NbPFTs
+    NbPFTs=${fluxnet_FLUXNET_NbPFTs}
+
+    #   * Number of physical parameters on each sites per PFTs
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NbSitesParam
+    #   * ORCHIDEE name for physical parameters on each sites
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NameSitesParam
+    #   * Sites descriptions
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET Sites
+    #   * Components for each physical parameter described in NameSitesParam
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET CompSitesParam
+
+    echo ${fluxnet_FLUXNET_Sites[*]}
+
+    # Number of columns by site in variable site : name, filename, length, + ${NbPFTs} PFT
+    NumInfosBySite=$(( 4 + ( NbPFTs * fluxnet_FLUXNET_NbSitesParam ) ))
+
+    # Number of sites :
+    NumSites=$(( ${#fluxnet_FLUXNET_Sites[*]} / NumInfosBySite ))
+    # Num of Columns : name, filename, length, + ${NbPFTs} PFT
+    ColumnName=0
+    ColumnFilename=1
+    ColumnYear=2
+    ColumnLength=3
+
+    # 3) SPINUP section : files path and spinup parameters
+    # This section groups specific options for SPINUP :
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card SPINUP
+    set +A fluxnet_SPINUP -- ${fluxnet_SPINUP[*]} > /dev/null 2>&1
+    typeset option
+    for option in ${fluxnet_SPINUP[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card SPINUP ${option}
+    done
+
+    # 4) Subjob orchidee.def parametrisation : SubJobParams in fluxnet.card
+    # This section give flags to put in orchidee.def of Subjobs.
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card SubJobParams
+    set +A fluxnet_SubJobParams -- ${fluxnet_SubJobParams[*]} > /dev/null 2>&1
+    eval first_option=${fluxnet_SubJobParams[0]} > /dev/null 2>&1
+    if [ X${first_option} != X"Error:" ] ; then
+	typeset option
+	for option in ${fluxnet_SubJobParams[*]} ; do
+	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card SubJobParams ${option}
+	done
+    fi
+
+    IGCM_debug_PopStack "FLUXNET_initialize"
+}
+
+# Function to sed parameter files in Subjob dirs
+# For sechiba.def :
+function SECHIBA_sed
+{
+    IGCM_debug_PushStack "SECHIBA_sed"
+    
+    if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then
+	sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	    ${New_SUBMIT_DIR}/PARAM/sechiba.def > ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp
+	RET=$?
+	echo "SECHIBA_sed : ${1} ${2}"
+	\mv ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp ${New_SUBMIT_DIR}/PARAM/sechiba.def
+    fi
+
+    IGCM_debug_PopStack "SECHIBA_sed"
+    return $RET
+}
+
+# For stomate.def :
+function STOMATE_sed
+{
+    IGCM_debug_PushStack "STOMATE_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	${New_SUBMIT_DIR}/PARAM/stomate.def > ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp
+    RET=$?
+    echo "STOMATE_sed : ${1} ${2}"
+    \mv ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp ${New_SUBMIT_DIR}/PARAM/stomate.def
+    
+    IGCM_debug_PopStack "STOMATE_sed"
+    return $RET
+}
+
+# For driver.def :
+function DRIVER_sed
+{
+    IGCM_debug_PushStack "DRIVER_sed"
+    
+    if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then
+	sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	    ${New_SUBMIT_DIR}/PARAM/driver.def > ${New_SUBMIT_DIR}/PARAM/driver.def.tmp
+	RET=$?
+	echo "DRIVER_sed : ${1} ${2}"
+	\mv ${New_SUBMIT_DIR}/PARAM/driver.def.tmp ${New_SUBMIT_DIR}/PARAM/driver.def
+    fi
+
+    IGCM_debug_PopStack "DRIVER_sed"
+    return $RET
+}
+
+
+# Function to grep parameter files in Subjob dirs
+# They search for the argmument value in the file.
+# The result of the function is given in ${SearchParam} global variable :
+# * "line" if the parameter is defined with the form 
+#   PARAM__1=value1
+#   PARAM__2=value2
+#   etc...
+# * "vector" if the parameter is defined with the form
+#   PARAM=value1 value2 etc...
+# * "undefined" if the parameter is not definied in the parameters file
+#   This should give an error in the script.
+
+# For sechiba.def :
+function SECHIBA_grep
+{
+    IGCM_debug_PushStack "SECHIBA_grep"
+    typeset Output
+
+    if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then
+	set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def )
+	if [ X${Output[0]} != X ] ; then
+	    SearchParam=line
+	else
+	    unset Output
+	    set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def )
+	    if [ X${Output[0]} != X ] ; then
+		SearchParam=vector
+	    else
+		SearchParam=undefined
+	    fi
+	fi
+    else
+	SearchParam=undefined
+        echo "$@ : file not found !!"
+    fi
+
+    IGCM_debug_PopStack "SECHIBA_grep"
+    return $RET
+}
+
+# For stomate.def :
+function STOMATE_grep
+{
+    IGCM_debug_PushStack "STOMATE_grep"
+    typeset Output
+
+    if [ -f ${New_SUBMIT_DIR}/PARAM/stomate.def ] ; then
+	set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def )
+	if [ X${Output[0]} != X ] ; then
+	    SearchParam=line
+	else
+	    unset Output
+	    set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def )
+	    if [ X${Output[0]} != X ] ; then
+		SearchParam=vector
+	    else
+		SearchParam=undefined
+	    fi
+	fi
+    else
+	SearchParam=undefined
+        echo "$@ : file not found !!"
+    fi
+
+    IGCM_debug_PopStack "STOMATE_grep"
+    return $RET
+}
+
+# For driver.def :
+function DRIVER_grep
+{
+    IGCM_debug_PushStack "DRIVER_grep"
+    typeset Output
+
+    if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then
+	set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def )
+	if [ X${Output[0]} != X ] ; then
+	    SearchParam=line
+	else
+	    unset Output
+	    set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def )
+	    if [ X${Output[0]} != X ] ; then
+		SearchParam=vector
+	    else
+		SearchParam=undefined
+	    fi
+	fi
+    else
+	SearchParam=undefined
+        echo "$@ : file not found !!"
+    fi
+
+    IGCM_debug_PopStack "DRIVER_grep"
+    return $RET
+}
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/fluxnet_LATHUILE.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/fluxnet_LATHUILE.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/fluxnet_LATHUILE.card	(revision 405)
@@ -0,0 +1,190 @@
+[FLUXNET]
+# - Fluxnet files path
+FluxnetPath=${R_BC}/OOL/${config_UserChoices_TagName}/LATHUILE/AR5_TEST/FORCING
+
+# - Number of PFTs :
+NbPFTs= 13
+
+# - Information on the sites to be treated :
+#   * Number of physical parameters on each sites per PFTs
+NbSitesParam= 2
+# 4 first parameters are Name, Forcing file, Begin date, Number of years in forcing file
+
+#   * ORCHIDEE name for physical parameters on each sites
+#   PFT (IMPOSE_VEG), \
+#   initial LAI (IMPOSE_VEG)
+NameSitesParam= ( SECHIBA_VEGMAX, SECHIBA_LAI )
+# by Default : 
+# 1) first line is for PFT
+# 2) second line is for LAI default for SLOWPROC lai model with : 
+#    llaimax = 0.,  8.,  8.,  4., 4.5, 4.5,  4., 4.5,  4.,  2.,  2.,  2.,  2.)
+
+#   * Name of component for each physical parameter described in NameSitesParam
+#     (in SECHIBA, STOMATE, DRIVER)
+CompSitesParam= ( SECHIBA, SECHIBA )
+
+
+# - Information on the sites to be treated :
+# first line is for PFT
+# second line is for LAI default for SLOWPROC lai model : llaimax = 0.,  8.,  8.,  4., 4.5, 4.5,  4., 4.5,  4.,  2.,  2.,  2.,  2.)
+#       Abbrv,  Filename ,      Inital year (for gregorian calendar) , Length (Y),  \
+#   PFT (IMPOSE_VEG), \
+#   initial LAI (IMPOSE_VEG)
+#      1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13
+Sites= ( BW-Ma1, BW-Ma1.nc,  1999,                                  3, \
+     0.,   0, 0.4,   0,   0,   0,   0,   0,   0,   0, 0.6,   0,  0, \
+     0.,  8.,  8.,  4., 4.5, 4.5,  4., 4.5,  4.,  2.,  2.,  2.,  2.) \
+\
+       ( BR-Sa1, BR-Sa1.nc,  2002,                                  3, \
+     0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, \
+     0.,  8.,  8.,  4., 4.5, 4.5,  4., 4.5,  4.,  2.,  2.,  2.,  2.) \
+\
+        ( BR-Ma2, BR-Ma2.nc,  2002,                                 5, \
+     0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, \
+     0.,  8.,  8.,  4., 4.5, 4.5,  4., 4.5,  4.,  2.,  2.,  2.,  2.) \
+\
+       ( NL-Loo, NL-Loo.nc,  1996,                                 11, \
+     0,   0,   0, 0.8,   0,   0,   0,   0,   0, 0.2,   0,   0,   0, \
+     0.,  8.,  8.,  4., 4.5, 4.5,  4., 4.5,  4.,  2.,  2.,  2.,  2.) \
+\
+       ( DE-Hai, DE-Hai.nc,  2000,                                  7, \
+     0,   0,   0,   0,    0, 0.8,   0,   0,   0, 0.2,   0,   0,   0, \
+     0.,  8.,  8.,  4., 4.5, 4.5,  4., 4.5,  4.,  2.,  2.,  2.,  2.) \
+\
+       ( FI-Sod, FI-Sod.nc,  2000,                                  7, \
+     0,   0,   0,   0,   0,   0, 0.8,   0,   0, 0.2,   0,   0,   0, \
+     0.,  8.,  8.,  4., 4.5, 4.5,  4., 4.5,  4.,  2.,  2.,  2.,  2.) \
+\
+       ( RU-Zot, RU-Zot.nc,  2002,                                  3, \
+     0,   0,   0,   0,   0,   0, 0.8,   0,   0, 0.2,   0,   0,   0, \
+     0.,  8.,  8.,  4., 4.5, 4.5,  4., 4.5,  4.,  2.,  2.,  2.,  2.)
+# lat		lon		site	sand	silt	clay	pft1	pft2	pft3	pft4	pft5	pft6	pft7	pft8	pft9	pft10	pft11	pft12	pft13
+# 51.07929993	10.45199966	DE-Hai	0.03667	0.54	0.42333	0	0	0	0	0	0.8	0	0	0	0.2	0	0	0
+# 60.80080032	89.35079956	RU-Zot	0.82	0.12	0.06	0	0	0	0	0	0	0.8	0	0	0.2	0	0	0
+# -19.91550064	23.56049919	BW-Ma1	0.82	0.12	0.06	0.1	0.2	0	0	0	0	0	0	0	0.7	0	0	0
+# 67.36190033	26.63780022	FI-Sod	0.9	0.09	0.01	0	0	0	0	0	0	0.8	0	0	0.2	0	0	0
+# 52.16790009	5.743959904	NL-Loo	0.58	0.32	0.1	0	0	0	0.8	0	0	0	0	0	0.2	0	0	0
+# -2.609100103	-60.20930099	BR-Ma2	0.25	0.1	0.65	0	0.8	0	0	0	0	0	0	0	0.2	0	0	0
+# -2.856669903	-54.95890045	BR-Sa1	0.35	0.1	0.55	0	0.8	0	0	0	0	0	0	0	0.2	0	0	0
+
+#\
+#       ( ??, ??.nc   ,     2000,     0     , \
+#     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, \
+#                                   0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) \
+#\
+
+
+# The following tables of parameters for SECHIBA
+# are in the following order :
+#
+#    1 - Bare soil
+#    2 - tropical  broad-leaved evergreen
+#    3 - tropical  broad-leaved raingreen
+#    4 - temperate needleleaf   evergreen
+#    5 - temperate broad-leaved evergreen
+#    6 - temperate broad-leaved summergreen
+#    7 - boreal    needleleaf   evergreen
+#    8 - boreal    broad-leaved summergreen
+#    9 - boreal    needleleaf   summergreen
+#   10 -           C3           grass
+#   11 -           C4           grass
+#   12 -           C3           agriculture
+#   13 -           C4           agriculture
+
+[SPINUP]
+    # SPINUP configuration : 
+    # ----------------------
+# !! Step of time in N Years !!
+# !! The spinup will change if the fluxnet file contains more than one year !!
+#    ( N = Number of years contain in fluxnet forcing file ) 
+#     each Year * N
+
+# Initialisation for spin-up :
+# orchidee with sechiba alone (!!! if ok_stomate == n !!!)
+duree_nostomate=0
+# orchidee with stomate
+duree_inistomate=1
+# teststomate (only if duree_nostomate or duree_inistomate > 0)
+duree_offlineini=0
+
+# Loop configuration for spin-up :
+# The whole job is restarted n_iter times
+n_iter=1
+# orchidee with sechiba (and stomate if ok_stomate=y below)
+duree_sechiba=500
+# teststomate
+duree_stomate=0
+# forcesoil
+duree_carbonsol=10000
+
+# Finalization for spin-up :
+# all orchidee
+duree_final=20
+# This last parameter must be non-zero.
+
+
+    # POST configuration : 
+    # --------------------
+# ATLAS fix parameters :
+# Atlas Name : 
+AtlasCfg=atlas_FLUXNET_LATHUILE.cfg
+#atlas_FLUXNET.cfg
+#atlas_FLUXNET_soenke.cfg
+
+# observation_file
+observation_file_path='/home/orchidee01/vuichard/AR5/OBS/${Site}.synth.hourly.allvars.nc'
+#'${R_BC}/OOL/${config_UserChoices_TagName}/LATHUILE/AR5_TEST/OBS/${Site}.synth.hourly.allvars.nc'
+
+# old history file
+reference_file_path='/home/orchidee01/vuichard/IGCM_OUT/OL2/LATHUILE_HIST_2m/${Site}_3_sechiba_hist.nc'
+# 3 choices : SECHIBA, OK_CO2, OK_STOMATE
+#'/dmnfs/cont003/p86manci/VALID_OL/SECHIBA/${Site}_sechiba_hist.nc'
+#'/dmnfs/cont003/p86manci/VALID_OL/OK_CO2/${Site}_sechiba_hist.nc'
+#'/dmnfs/cont003/p86manci/VALID_OL/OK_STOMATE/${Site}_sechiba_hist.nc'
+
+# Modulo for SpinUp years
+# by default, only one ATLAS-DIFF will be created 
+# between the last step and the first one.
+#Modulo=15
+
+
+[UserChoices]
+
+#
+###-- STOMATE flag
+#
+ok_stomate=y
+#
+###-- OK_CO2 flag
+#
+ok_co2=y
+
+#
+###-- NEW HYDROL CWRR flag
+#
+ok_newhydrol=n
+
+#
+## DEBUG mode for SPINUP 
+#
+# This mode keep all SPINUP directory in ARCHIVE
+# If disable, all ARCHIVE is automaticly cleaned.
+# 
+DEBUG_SPIN=n
+# If you don't want to keep old spinup steps, but last one
+CONSERVE=y
+
+[SubJobParams]
+# You can specify here any parameters to be modified in sechiba.def, stomate.def or driver.def for SpinUp Subjobs.
+# NEW : due to split of orchidee.def in component specific parameter files,
+#       you must add here a prefix for the specific parameter file.
+driver_DEBUG_INFO=n
+sechiba_LONGPRINT=n
+stomate_BAVARD=0
+sechiba_ALMA_OUTPUT=y
+driver_ALLOW_WEATHERGEN=n
+sechiba_SECHIBA_reset_time=y
+## To begin with half water stress
+#sechiba_HYDROL_HUMR=0.5
+# FLUXNET files have hour frequency values.
+driver_SPLIT_DT=1
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/install
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/install	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/install	(revision 405)
@@ -0,0 +1,15 @@
+#!/bin/ksh
+# $Id: install,v 1.2 2008/12/03 11:32:45 ssipsl Exp $
+
+d_n=$(dirname ${0}); 
+
+F_MOD=$(cd ${d_n}'/../../..';/bin/pwd;)
+\sed -e "s%::modipsl::%${F_MOD}%" \
+     Job_FLUXNET_validation > Job_FLUXNET_validation_
+\mv Job_FLUXNET_validation_ Job_FLUXNET_validation
+\chmod u+x Job_FLUXNET_validation
+
+\sed -e "s%::modipsl::%${F_MOD}%" \
+     Job_Post_FLUXNET > Job_Post_FLUXNET_
+\mv Job_Post_FLUXNET_ Job_Post_FLUXNET
+\chmod u+x Job_Post_FLUXNET
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/post_FLUXNET
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/post_FLUXNET	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FLUXNET/post_FLUXNET	(revision 405)
@@ -0,0 +1,220 @@
+#!/bin/ksh
+
+########################################################################
+
+#D- Flag to determine if this job in a standalone mode
+#D- Default : value from AA_job if any
+StandAlone=${StandAlone:=true}
+
+#D- Increased verbosity (1, 2, 3)
+#D- Default : value from AA_job if any
+Verbosity=${Verbosity:=3}
+
+#D- Low level debug : to bypass lib test checks and stack construction
+#D- Default : value from AA_job if any
+DEBUG_debug=${DEBUG_debug:=false}
+
+#RUN_DIR_PATH=${RUN_DIR_PATH:=/tmp/tmp$$}
+
+########################################################################
+
+MODIPSL=$1
+libIGCM=${libIGCM:=${MODIPSL}/libIGCM}
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+
+########################################################################
+#set -vx
+########################################################################
+# Script input parameters
+
+# Site name
+SiteArg=$2
+Site=${SiteArg:=Gu}
+# Time in years in file for this site :
+DureeArg=$3
+export DUREE=${DureeArg:=1}
+
+# First year in file for this site :
+FirstArg=$4
+export FYEAR=${FirstArg:=1}
+
+
+# Atlas Name : 
+AtlasCfgArg=$5
+AtlasCfg=${AtlasCfgArg:=atlas_FLUXNET.cfg}
+
+# observation_file
+observation_file_pathArg=$6
+observation_file_path=${observation_file_pathArg:='${R_IN}/BC/OOL/${config_UserChoices_TagName}/FLUXNET/OLD/${Site}.nc'}
+#/home/mancip/IGCM/BC/OOL/OL2/FLUXNET/OBS/${Site}_obs_gapfilled.nc
+
+# old history file
+reference_file_pathArg=$7
+reference_file_path=${reference_file_pathArg:='/home/mancip/PROG/IPSL/VALID_OL/SECHIBA/${Site}_sechiba_hist.nc'}
+
+# Modulo for SpinUp years 
+ModuloArg=$8
+
+#if [ ${DEBUG_debug} = true ] ; then
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+echo "RUN_DIR_PATH ${RUN_DIR_PATH} ok."
+#fi
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+if [ ${StandAlone} = true ] ; then
+    CARD_DIR=${SUBMIT_DIR}
+else
+    CARD_DIR=${RUN_DIR_PATH}/$( basename ${SUBMIT_DIR} )
+    IGCM_sys_Get_Master ${SUBMIT_DIR} ${RUN_DIR_PATH}
+fi
+
+#
+# First of all
+#
+IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card UserChoices
+typeset option
+for option in ${config_UserChoices[*]} ; do
+    IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option}
+done
+#
+echo
+IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
+IGCM_debug_PrintVariables 3 config_UserChoices_JobName
+if [ 3 -le ${Verbosity} ] ; then
+    echo "--------------Debug3-->" "config_UserChoices_LongName="
+    echo "--------------Debug3-->" \"${config_UserChoices_LongName}\"
+fi
+IGCM_debug_PrintVariables 3 config_UserChoices_TagName
+IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType
+IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin
+IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
+IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength
+echo
+
+
+# FLAG = SECHIBA, OK_STOMATE
+IGCM_card_DefineVariableFromOption ${CARD_DIR}/fluxnet.card UserChoices ok_stomate
+if [ X${fluxnet_UserChoices_ok_stomate} = Xn ] ; then
+    export FLAG=SECHIBA
+else
+    export FLAG=OK_STOMATE
+fi
+
+#==================================
+
+SpinUpJob=${Site}${config_UserChoices_JobName}
+
+R_BC=${R_IN}/BC
+R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${SpinUpJob}/SPIN
+
+# look at files
+IGCM_card_DefineVariableFromOption ${CARD_DIR}/fluxnet.card UserChoices DEBUG_SPIN
+if [ X${fluxnet_UserChoices_DEBUG_SPIN} = Xn ] ; then
+    set -A liste_fichiers_with_path -- $( \ls -rt ${R_SAVE}/Output/${SpinUpJob}*/SRF/Output/MO/*_sechiba_history.nc ${R_OUT}/${config_UserChoices_TagName}/${SpinUpJob}HIST/SRF/Output/MO/*_sechiba_history.nc )
+else 
+    set -A liste_fichiers_with_path -- $( \ls -rt ${R_OUT}/${config_UserChoices_TagName}/${SpinUpJob}*/SRF/Output/MO/*_sechiba_history.nc )
+fi
+
+ii=0
+for file in ${liste_fichiers_with_path[@]} ; do
+    liste_fichiers[$ii]=$( echo ${file} | xargs basename )
+    (( ii = ii + 1 ))
+done
+echo ${liste_fichiers[*]}
+
+# Get and sed atlas
+IGCM_sys_Cp ${CARD_DIR}/${AtlasCfg} ./atlas.cfg
+
+# Set default Modulo parameter to the last file
+eval NbFiles=${#liste_fichiers[@]}
+echo "NbFiles=" $NbFiles
+Modulo=${ModuloArg:=$(( NbFiles - 1 ))}
+
+# Get last time_axis patch
+Last_Patch_File=$( ls -t ${libIGCM}/libIGCM_post/IGCM_Patch_*_histcom_time_axis.ksh | tail -1 )
+#echo "source patch file : ${Last_Patch_File}"
+# . ${Last_Patch_File}
+# Last_Patch=$( echo ${Last_Patch_File} | sed -e "s&${libIGCM}/libIGCM_post/\(.*\)\.ksh&\1&" )
+#echo "We will apply the patch on all sechiba files : "  ${Last_Patch}
+
+# Apply atlas
+ii=0
+for file in ${liste_fichiers[*]} ; do 
+
+    DirFile=$( dirname ${liste_fichiers_with_path[$ii]} )
+    echo ${DirFile}
+
+    # First apply the last time_axis patch
+#     IGCM_sys_Cd ${DirFile}
+#     ${Last_Patch} ${file}
+#     # clean dir
+#     rm out_rsync
+#     # Then return to RUN_DIR_PATH
+#     IGCM_sys_Cd ${RUN_DIR_PATH}
+    
+    if [ $ii -eq 0 ]  ; then
+	file_=${file}
+        # copy files we need for ATLAS
+	IGCM_sys_Cp -p ${liste_fichiers_with_path[$ii]} .
+    fi
+    echo "!!!!!!!!!!!!!!!!!"
+    echo ${file}
+    export F_FILE=${Site}
+    echo $ii "Modulo : " $( expr $ii \% $Modulo )
+    if [ $ii -gt 0 ] && [ X$( expr $ii \% $Modulo ) = X0 ] ; then
+
+        # copy files we need for ATLAS
+	IGCM_sys_Cp -Rp ${liste_fichiers_with_path[$ii]} .
+
+	reference_file=${file_}
+	eval observation_file=${observation_file_path}
+	echo "ATLAS DIFF for files : " ${file} ${reference_file} ${observation_file}
+
+	#cat atlas.cfg
+	sed -e "s,RRRRRRR,${reference_file},g" -e "s,VVVVVVV,${observation_file},g" atlas.cfg > atlas_.cfg
+	#cat atlas_.cfg
+	AtlasPath=$( echo ${file} | sed -e 's/_1M_sechiba_history.nc//' )
+	atlas -o ATLAS_DIFF_${AtlasPath} atlas_.cfg ${file}
+
+        # Save files
+	IGCM_sys_Put_Dir ATLAS_DIFF_${AtlasPath} ${R_SAVE}
+#	IGCM_sys_Rm -Rf ATLAS_DIFF_${AtlasPath} 
+	echo "&&&&&&&&&&&&&&&&!"
+
+	file_=${file}
+    fi
+    (( ii=ii+1 ))
+done
+eval reference_file=${reference_file_path}
+sed -e "s,RRRRRRR,${reference_file},g" -e "s,VVVVVVV,${observation_file},g" atlas.cfg > atlas_.cfg
+
+echo "REFERENCE ATLAS for file : " ${file} ${reference_file} ${observation_file}
+atlas -o ATLAS_FIN_${AtlasPath}_ref atlas_.cfg ${file}
+
+# Save files
+IGCM_sys_Put_Dir ATLAS_FIN_${AtlasPath}_ref ${R_SAVE}
+
+IGCM_sys_Rm -Rf ATLAS_FIN_${AtlasPath}_ref
+
+
+
+# # Get and Apply Patch
+# . ${MODIPSL}/libIGCM/libIGCM_post/IGCM_Patch_20070220_histcom_time_axis.ksh
+# for file in ${liste_fichiers[*]} ; do 
+#     IGCM_Patch_20070220_histcom_time_axis ${file}
+# done
+
+# # look at files
+# echo "after Patch" IGCM_Patch_20070220_histcom_time_axis
+# \ls -lrt  *_sechiba_history.nc
+
+# Concat files
+#IGCM_sys_ncrcat -o ${SpinUpJob}_1M_sechiba_history.nc ${liste_fichiers[*]}
+
+IGCM_sys_Rm -Rf  ${liste_fichiers[*]}
+
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/COMP/stomate.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/COMP/stomate.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/COMP/stomate.card	(revision 405)
@@ -0,0 +1,33 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+# resolution of forcing file (not used yet)
+RESOL=OOL360180
+stomate_LEVEL=7
+
+[InitialStateFiles]
+List=	()
+	
+[BoundaryFiles]
+List=	()
+ListNonDel= (${config_SBG_RestartPath}/${config_SBG_RestartJobName}/SBG/Restart/${config_SBG_RestartJobName}_${Date_Restarts}_stomate_Cforcing.nc, stomate_Cforcing.nc)\
+            (${R_BC}/SRF/${config_UserChoices_TagName}/reftemp.nc, .)
+
+[SmoothFiles]
+List=	()
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/stomate.def, .) \
+	(${SUBMIT_DIR}/PARAM/driver.def, .) \
+	(${SUBMIT_DIR}/PARAM/run.def, .)
+
+[RestartFiles]
+# List restart that have to be saved/restored each loop (file out, saved, and in) :
+List=	(stomate_rest_out.nc, stomate_rest.nc, stomate_rest_in.nc)
+
+[OutputText]
+List=   (used_stomate.def, used_driver.def, used_run.def, out_forcesoil, out_orchidee)
+
+[OutputFiles]
+List=	()
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/COMP/stomate.driver
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/COMP/stomate.driver	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/COMP/stomate.driver	(revision 405)
@@ -0,0 +1,149 @@
+#!/bin/ksh
+
+#D- Driver du script pour STOMATE FORCESOIL
+
+function STOMATE_sed
+{
+    IGCM_debug_PushStack "STOMATE_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	stomate.def > stomate.def.tmp
+    RET=$?
+    echo "STOMATE_sed : ${1} ${2}"
+    \mv stomate.def.tmp stomate.def
+    
+    IGCM_debug_PopStack "STOMATE_sed"
+    return $RET
+}
+
+function DRIVER_sed
+{
+    IGCM_debug_PushStack "DRIVER_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	driver.def > driver.def.tmp
+    RET=$?
+    echo "DRIVER_sed : ${1} ${2}"
+    \mv driver.def.tmp driver.def
+    
+    IGCM_debug_PopStack "DRIVER_sed"
+    return $RET
+}
+
+#-----------------------------------------------------------------
+function SBG_Initialize
+{
+    IGCM_debug_PushStack "SBG_Initialize"
+
+    RESOL=${forcesoil_UserChoices_RESOL}
+
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG RestartDate
+    Date_Restarts=$( IGCM_date_ConvertFormatToGregorian ${config_SBG_RestartDate} )
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG RestartJobName
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG RestartPath    
+
+    NUM_PROC=1
+#D- Number of processors used for lmdz and oasis coupler computed from PBS variable
+    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
+	NUM_PROC=${BATCH_NUM_PROC_TOT}
+    fi
+    echo BATCH_NUM_PROC_TOT=${BATCH_NUM_PROC_TOT}
+    echo NUM_PROC=${NUM_PROC}
+
+    if ( [ X${BATCH_NUM_PROC_TOT} != X ] && [ "${BATCH_NUM_PROC_TOT}" -gt 1 ] ) ; then
+	MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND}
+    fi
+
+    echo "ORCHIDEE Tag : " ${config_UserChoices_TagName}
+
+    IGCM_debug_PopStack "SBG_Initialize"
+}
+
+#-----------------------------------------------------------------
+function SBG_PeriodStart
+{
+    IGCM_debug_PushStack "SBG_PeriodStart"
+
+    IGCM_debug_PopStack "SBG_PeriodStart"
+}
+
+#-----------------------------------------------------------------
+function SBG_Update
+{
+    IGCM_debug_PushStack "SBG_Update"
+
+    typeset STOMATE_WRITE_STEP
+
+    case ${config_SBG_WriteFrequency} in
+	*Y|*y) 
+	    WriteInYears=$( echo ${config_SBG_WriteFrequency} | awk -F '[yY]' '{print $1}' )
+	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+	    (( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears )) ;;
+	1M|1m) 
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		STOMATE_WRITE_STEP=-1.
+		;;
+	*M|*m) 
+		STOMATE_WRITE_STEP=-1.
+		;;
+	    *)
+		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
+	    esac
+	    ;;
+	*M|*m) 
+	    WriteInMonths=$( echo ${config_SBG_WriteFrequency} | awk -F '[mM]' '{print $1}' )
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+		(( STOMATE_WRITE_STEP = 30 )) ;;
+	    *M|*m)
+		PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
+		(( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInMonths / PeriodLengthInMonths )) ;;
+	    *)
+		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
+	    esac
+	    ;;
+	5D|5d) 
+	    (( STOMATE_WRITE_STEP = 5 )) ;;
+	1D|1d) 
+	    (( STOMATE_WRITE_STEP = 1 )) ;;
+	*s)
+	    WriteInSeconds=$( echo ${config_SBG_WriteFrequency} | awk -F '[s]' '{print $1}' )
+	    (( STOMATE_WRITE_STEP = 1 )) ;;
+	*) 
+	    IGCM_debug_Exit "SBG_Update " ${config_SBG_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
+	    IGCM_debug_Verif_Exit ;;
+    esac
+
+    STOMATE_sed STOMATE_OK_STOMATE y
+    STOMATE_sed STOMATE_OK_CO2 y
+
+    STOMATE_sed STOMATE_HIST_DT ${STOMATE_WRITE_STEP}
+    STOMATE_sed STOMATE_HISTLEVEL ${stomate_UserChoices_stomate_LEVEL}
+    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SBG_Restart}" = "n" ] ) ; then
+	echo "Error in forcesoil !"
+	echo "You must use some old restarts with this job." 
+	echo "We will stop here."
+	IGCM_debug_Exit "YOU MUST USE SOME OLD RESTARTS WITH THE JOB FORCESOIL." 
+	IGCM_debug_Verif_Exit
+    else
+	STOMATE_sed STOMATE_RESTART_FILEIN stomate_rest_in.nc
+	STOMATE_sed STOMATE_CFORCING_NAME stomate_Cforcing.nc
+    fi
+
+    DRIVER_sed TIME_LENGTH ${PeriodLengthInYears}Y
+#    DRIVER_sed TIME_SKIP ${OldSimulationLengthInDays}D
+
+    IGCM_debug_PopStack "SBG_Update"
+}
+
+#-----------------------------------------------------------------
+function SBG_Finalize
+{
+    IGCM_debug_PushStack "SBG_Finalize"
+
+    echo FINALIZE SBG !!!
+
+    IGCM_debug_PopStack "SBG_Finalize"
+}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/PARAM/driver.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/PARAM/driver.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/PARAM/driver.def	(revision 405)
@@ -0,0 +1,44 @@
+#
+#**************************************************************************
+#                    Namelist for TESTSTOMATE
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#**************************************************************************
+# length of simulation :
+#---------------------------------------------------------------------
+# Length of the integration in time.
+# Length of integration. By default the entire length
+#        of the forcing is used. The FORMAT of this date can
+#        be either of the following :
+# n   : time step n within the forcing file
+# nS  : n seconds after the first time-step in the file
+# nD  : n days after the first time-step
+# nM  : n month after the first time-step (year of 365 days)
+# nY  : n years after the first time-step (year of 365 days)
+#        Or combinations :
+# nYmM: n years and m month
+TIME_LENGTH = default
+# default = depend on the time length and the number of time step in forcing file
+#         = itau_len = itau_fin-itau_dep
+
+#  Time in the forcing file at which the model is started.
+#  This time give the point in time at which the model
+#  should be started. 
+#  If exists, the date of the restart file is use.
+#  The FORMAT of this date can be either of the following :
+#  n   : time step n within the forcing file
+#  nS  : n seconds after the first time-step in the file
+#  nD  : n days after the first time-step
+#  nM  : n month after the first time-step (year of 365 days)
+#  nY  : n years after the first time-step (year of 365 days)
+#      Or combinations :
+#  nYmM: n years and m month
+TIME_SKIP = 0
+# default = 0
+
+
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/PARAM/run.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/PARAM/run.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/PARAM/run.def	(revision 405)
@@ -0,0 +1,4 @@
+# $Id: run.def,v 1.1 2010/10/11 14:13:57 ssipsl Exp $
+#
+INCLUDEDEF=driver.def
+INCLUDEDEF=stomate.def
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/PARAM/stomate.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/PARAM/stomate.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/PARAM/stomate.def	(revision 405)
@@ -0,0 +1,205 @@
+#
+#**************************************************************************
+#                    Namelist for STOMATE
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of STOMATE
+#**************************************************************************
+
+# Model chatting level
+# level of online diagnostics in STOMATE (0-4)
+# With this variable, you can determine how much online information STOMATE
+#  gives during the run. 0 means virtually no info.
+BAVARD = 1
+# default = 1
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+
+# Name of file from which the reference
+# The name of the file to be opened to read
+#  temperature is read
+#  the reference surface temperature.
+#  The data from this file is then interpolated
+#  to the grid of the model.
+#  The aim is to get a reference temperature either
+#  to initialize the corresponding prognostic model
+#  variable correctly (ok_dgvm = TRUE) or to impose it
+#  as boundary condition (ok_dgvm = FALSE)
+REFTEMP_FILE = reftemp.nc
+# default = reftemp.nc
+# Input and output restart file for STOMATE :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions of STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened of STOMATE
+#   to extract the initial values of all prognostic values of STOMATE.
+STOMATE_RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened
+#        to write the final values of all prognostic values
+#        of STOMATE.
+STOMATE_RESTART_FILEOUT = stomate_rest_out.nc
+# default = stomate_restart.nc
+
+# Forcing files for TESTSTOMATE and FORCESOIL
+#---------------------------------------------------------------------
+
+# Name of STOMATE's forcing file
+# Name that will be given to STOMATE's offline forcing file
+STOMATE_FORCING_NAME = stomate_forcing.nc
+#default = NONE
+
+# Size of STOMATE forcing data in memory (MB)
+# This variable determines how many
+#  forcing states will be kept in memory.
+#  Must be a compromise between memory
+#  use and frequeny of disk access.
+STOMATE_FORCING_MEMSIZE = 50
+# default = 50
+
+# Name of STOMATE's carbon forcing file
+# Name that will be given to STOMATE's carbon offline forcing file
+STOMATE_CFORCING_NAME = stomate_Cforcing.nc
+# default = NONE
+
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+# STOMATE does minimum service
+# set to TRUE if you want STOMATE to read
+#  and write its start files and keep track
+#  of longer-term biometeorological variables.
+#  This is useful if OK_STOMATE is not set,
+#  but if you intend to activate STOMATE later.
+#  In that case, this run can serve as a 
+#  spinup for longer-term biometeorological
+#  variables.
+STOMATE_WATCHOUT = n
+# default = n
+
+
+# Output file name :
+#---------------------------------------------------------------------
+
+# Name of file in which STOMATE's output is going to be written
+# This file is going to be created by the model
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+STOMATE_OUTPUT_FILE = stomate_history.nc
+# default = stomate_history.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# STOMATE history output level (0..10)
+#  0: nothing is written; 10: everything is written
+STOMATE_HISTLEVEL = 10
+# default = 10
+
+# STOMATE_IPCC_OUTPUT_FILE
+# This file is going to be created by the model
+#    and will contain the output from the model.
+#    This file is a truly COADS compliant netCDF file.
+#    It will be generated by the hist software from
+#    the IOIPSL package.
+# Name of file in which STOMATE's output is going
+# to be written
+STOMATE_IPCC_OUTPUT_FILE = stomate_ipcc_history.nc
+# default = stomate_ipcc_history.nc
+
+# STOMATE_IPCC_HIST_DT
+# Time step of the STOMATE IPCC history file
+# STOMATE IPCC history time step (d)
+STOMATE_IPCC_HIST_DT = 0.
+# default = 0.
+
+# Write frequency for output files (STOMATE in days) :
+#---------------------------------------------------------------------
+
+# STOMATE history time step (d)
+# Time step of the STOMATE history file
+# Care : this variable must be higher than DT_SLOW
+STOMATE_HIST_DT = 10.
+# default = 10.
+
+#---------------------------------------------------------------------
+# FORCESOIL CARBON spin up parametrization
+#---------------------------------------------------------------------
+
+# Number of time steps per year for carbon spinup.
+FORCESOIL_STEP_PER_YEAR = 12
+# default = 12
+
+# Number of years saved for carbon spinup.
+FORCESOIL_NB_YEAR = 1
+# default = 1
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate STOMATE?
+# set to TRUE if STOMATE is to be activated
+STOMATE_OK_STOMATE = n
+# default = n
+
+# Activate DGVM?
+# set to TRUE if Dynamic Vegetation DGVM is to be activated
+STOMATE_OK_DGVM = n
+# default = n
+
+# Index of grid point for online diagnostics
+# This is the index of the grid point which will be used for online diagnostics.
+STOMATE_DIAGPT = 1
+# default = 1
+
+# constant tree mortality
+# If yes, then a constant mortality is applied to trees. 
+#  Otherwise, mortality is a function of the trees' 
+#  vigour (as in LPJ).
+LPJ_GAP_CONST_MORT = y
+# default = y
+
+# no fire allowed
+# With this variable, you can allow or not
+#  the estimation of CO2 lost by fire
+FIRE_DISABLE = n
+# default = n
+
+#**************************************************************************
+
+# Harvert model for agricol PFTs.
+# Compute harvest above ground biomass for agriculture.
+# Change daily turnover.
+HARVEST_AGRI = y
+# default = y
+
+# herbivores allowed?
+# With this variable, you can activate herbivores 
+HERBIVORES = n
+# default = n
+
+# treat expansion of PFTs across a grid cell?
+# With this variable, you can determine
+#  whether we treat expansion of PFTs across a
+#  grid cell.
+TREAT_EXPANSION = n
+# default = n
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/config.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/config.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/FORCESOIL/config.card	(revision 405)
@@ -0,0 +1,99 @@
+#
+# This is config.card file for restart with an NEW libIGCM simulation tree.
+#
+#====================================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+#========================================================================
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=ForceSo
+LongName="Please, explain here what is this simulation for"
+TagName=OL2
+#============================
+#-- leap, noleap, 360d
+CalendarType=360d
+#-- Start and End of Job
+#-- "YYYY-MM-DD"
+DateBegin=1980-01-01
+DateEnd=1989-12-30
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength=10Y
+#============================
+#-- PBS Class (required on brodie mono/multi)
+#JobClass=mono
+JobClass=multi
+#============================
+#-- Total Number of Processors (minimum is 2 for a coupled configuration)
+#JobNumProcTot=2
+JobNumProcTot=4
+#============================
+#-- Run Options : here for oasis coupling
+JobRunOptions='"-np "${NUM_PROC}" -max_np "${NUM_PROC}'
+#JobRunOptions='"-np "${NUM_PROC}'
+#============================
+PeriodNb=1
+
+#========================================================================
+#D-- ListOfComponents -
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+SBG= (stomate, orchidee_1_9_5_1)
+
+#========================================================================
+#D-- Executable -
+[Executable]
+Name=forcesoil
+#D- For each component, Real name of executable, Name of executable for oasis
+SBG= (forcesoil, forcesoil)
+
+#========================================================================
+#D-- Restarts -
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule=n
+#D- Last day of the experience used as restart
+RestartDate=1979-12-31
+#D- Define restart simulation name (=> JOB_OS)
+RestartJobName=TESTFORCE
+#D- Path Server Group Login (=> PSGL)
+RestartPath=${ARCHIVE}/IGCM_OUT
+# Attention login depend de la machine
+
+#========================================================================
+#D-- Post -
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=NONE
+#D- Optimization of rebuid
+RebuildFromArchive=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency=NONE
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency=NONE
+#D- Offset for seasonal average first start dates ; same unit as SeasonalFrequency
+#D- Usefull if you do not want to consider the first X simulation's years
+SeasonalFrequencyOffset= 0
+
+#========================================================================
+#D-- SRF - STOMATE
+[SBG]
+WriteFrequency="1M"
+Restart=y
+#-- Last day of the experience used as restart
+RestartDate=1979-12-30
+# Define restart simulation name
+RestartJobName=TESTFORCE
+RestartPath=${ARCHIVE}/${LOGIN}/IGCM_OUT
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/orchidee_ol.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/orchidee_ol.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/orchidee_ol.card	(revision 405)
@@ -0,0 +1,36 @@
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+# resolution of forcing file (not used yet)
+RESOL=OOL360180
+# If you want to use the same forcing file
+NORESTART=n
+# If you want use config.card PeriodLength for TIME_LENGTH
+TIMELENGTH=y
+
+[InitialStateFiles]
+List=	
+
+[BoundaryFiles]
+List=	(${R_BC}/OOL/${config_UserChoices_TagName}/NCC/ncc_for_${year}.nc, forcing_file.nc)
+ListNonDel= ()
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/driver.def, .) \
+    (${SUBMIT_DIR}/PARAM/run.def, .)
+
+[RestartFiles]
+# List restart that have to be saved/restored each loop (file out, saved, and in) :
+List=	(driver_rest_out.nc,  driver_rest.nc,  driver_rest_in.nc)
+# \
+#    (used_run.def, used_run.def, used_run_in.def)
+# Uncomment previous lines to be sure to STOP if something was wrong in ORCHIDEE.
+
+[OutputText]
+List=   (used_driver.def, used_run.def, out_orchidee_ol)
+# avec la // : out_orchidee_*
+
+[OutputFiles]
+List=	
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/orchidee_ol.driver
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/orchidee_ol.driver	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/orchidee_ol.driver	(revision 405)
@@ -0,0 +1,89 @@
+#!/bin/ksh
+
+#D- Driver du script pour ORCHIDEE_OL (off-line)
+
+function DRIVER_sed
+{
+    IGCM_debug_PushStack "DRIVER_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	driver.def > driver.def.tmp
+    RET=$?
+    echo "DRIVER_sed : ${1} ${2}"
+    \mv driver.def.tmp driver.def
+    
+    IGCM_debug_PopStack "DRIVER_sed"
+    return $RET
+}
+
+#-----------------------------------------------------------------
+function OOL_Initialize
+{
+    IGCM_debug_PushStack "OOL_Initialize"
+
+    NUM_PROC=1
+#D- Number of processors used for lmdz and oasis coupler computed from PBS variable
+    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
+	NUM_PROC=${BATCH_NUM_PROC_TOT}
+    fi
+    echo BATCH_NUM_PROC_TOT=${BATCH_NUM_PROC_TOT}
+    echo NUM_PROC=${NUM_PROC}
+
+    if ( [ X${BATCH_NUM_PROC_TOT} != X ] && [ "${BATCH_NUM_PROC_TOT}" -gt 1 ] ) ; then
+	MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND}
+    fi
+
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/COMP/orchidee_ol.card UserChoices
+    RESOL=${orchidee_ol_UserChoices_RESOL}
+
+    IGCM_debug_PopStack "OOL_Initialize"
+}
+
+#-----------------------------------------------------------------
+function OOL_Update
+{
+    IGCM_debug_PushStack "OOL_Update"
+
+    if [ X"${orchidee_ol_UserChoices_TIMELENGTH}" = Xy ] ; then
+	case ${config_UserChoices_PeriodLength} in
+	    *Y|*y|*M|*m|*D|*d)
+		DRIVER_sed TIME_LENGTH ${PeriodLengthInDays}D
+		;;
+	    *s)
+		DRIVER_sed TIME_LENGTH ${config_UserChoices_PeriodLength}
+	esac
+    fi
+
+    if ( ${FirstInitialize} ) ; then
+	if ( [ "${config_OOL_Restart}" = "y" ] ) ; then
+	    DRIVER_sed RESTART_FILEIN driver_rest_in.nc
+	else
+	    DRIVER_sed TIME_SKIP $( IGCM_date_DaysBetweenGregorianDate ${DateBegin} ${year}0101 )D
+	fi
+    else
+	if [ X${orchidee_ol_UserChoices_NORESTART} = Xn ] ; then
+	    DRIVER_sed RESTART_FILEIN driver_rest_in.nc
+	else
+	    if [ ${DRYRUN} -le 2 ] ; then
+		IGCM_sys_Rm driver_rest_in.nc
+	    fi
+	    DRIVER_sed RESTART_FILEIN NONE
+	fi
+    fi
+
+#    IGCM_sys_Put_Out run.def ${R_OUT_OOL}/${PREFIX}_run.def
+    FileToBeDeleted[${#FileToBeDeleted[@]}]=run.def
+    FileToBeDeleted[${#FileToBeDeleted[@]}]=driver.def
+
+    IGCM_debug_PopStack "OOL_Update"
+}
+
+#-----------------------------------------------------------------
+function OOL_Finalize
+{
+    IGCM_debug_PushStack "OOL_Finalize"
+
+    echo FINALIZE OOL !!!
+
+    IGCM_debug_PopStack "OOL_Finalize"
+}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/sechiba.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/sechiba.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/sechiba.card	(revision 405)
@@ -0,0 +1,77 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+LAIMAP=n
+IMPOSE_VEG=n
+# if IMPOSE_VEG = n
+LAND_USE=n
+# if LAND_USE=y
+VEGET_UPDATE=1Y
+# if LAND_USE=n and we want to use carteveg5km.nc for maxvegetfrac map.
+# (instead of default PFTmap_1850to2005_AR5_LUHa.rc2 below)
+OLD_VEGET=n
+ROUTING=n
+NEWHYDROL=n
+OKCO2=y
+sechiba_LEVEL=6
+
+[InitialStateFiles]
+List=       (${R_INIT}/SRF/${config_UserChoices_TagName}/routing.nc, .),     \
+            (${R_INIT}/SRF/${config_UserChoices_TagName}/soils_param.nc, .), \
+            (${R_INIT}/SRF/${config_UserChoices_TagName}/irrigated.nc, .), \
+            (${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2/PFTmap_IPCC_${year}.nc, PFTmap.nc)
+# ,   \
+# 	(${R_INIT}/SRF/${config_UserChoices_TagName}/floodplains.nc, .), \
+# 	(${R_INIT}/SRF/${config_UserChoices_TagName}/cartepente2d_15min.nc, .)
+
+[BoundaryFiles]
+#List=	(${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2/PFTmap_IPCC_${year_p1}.nc, .)
+List=	()
+ListNonDel= (${R_BC}/SRF/${config_UserChoices_TagName}/lai2D_03.nc, lai2D.nc)
+#If you want to come back to old BIG LAND USE file (to run on multipple years, just one time with LAND USE activated), you must 
+# 1) empty BC list and INIT first PFTmap lines
+# 2) and suppress previous ListNonDel line and ucomment next one :
+#ListNonDel= (${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2.nc, PFTmap.nc) \
+#             (${R_BC}/SRF/${config_UserChoices_TagName}/lai2D_03.nc, lai2D.nc)
+# See also same comment in sechiba.driver.
+
+[SmoothFiles]
+List=()
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/sechiba.def, .)
+
+[RestartFiles]
+# List restart that have to be saved/restored each loop (file out, saved, and in) :
+List=	(sechiba_rest_out.nc, sechiba_rest.nc, sechiba_rest_in.nc)
+
+[OutputText]
+List=   (used_sechiba.def, out_orchidee)
+
+[OutputFiles]
+List=	(sechiba_history.nc, ${R_OUT_SRF_O_M}/${PREFIX}_1M_sechiba_history.nc, Post_1M_sechiba_history), \
+        (sechiba_out_2.nc, ${R_OUT_SRF_O_H}/${PREFIX}_HF_sechiba_out_2.nc, Post_HF_sechiba_out_2), \
+        (orchidee_watchout.nc, ${R_OUT_SRF_O_M}/${PREFIX}_1M_watchout.nc, NONE)
+
+[Post_1M_sechiba_history]
+Patches = ()
+GatherWithInternal= (lon, lat, veget, time_counter, time_counter_bnds, Areas, Contfrac)
+TimeSeriesVars2D = (nobiofrac, alb_nir, alb_vis, bqsb, evap, fluxlat, fluxsens, gqsb, netrad, qair, rain, runoff, snow, snownobio, snowf, subli, tair, temp_sol, tsol_max, tsol_min, drainage,mrsos, mrso, mrros, mrro, prveg, evspsblveg, evspsblsoi, tran, treeFrac, grassFrac, cropFrac, baresoilFrac, residualFrac)
+# ALMAOUTPUT
+#TimeSeriesVars2D = (nobiofrac, SWnet, LWnet, Qh, Qle, Qg, Qf, DelSurfHeat, DelColdCont, Snowf, Rainf, Evap, Qs, Qsb, Qsm, DelSoilMoist, DelSWE, DelIntercept, AvgSurfT, RadT, Albedo, SWE, SoilMoist, SoilWet, SoilTemp, PotEvap, ESoil, ECanop, TVeg, RootMoist, SubSnow, ACond, SnowFrac, SAlbedo, SnowDepth, dis, GPP)
+ChunckJob2D = NONE
+TimeSeriesVars3D = (lai, maxvegetfrac, vegetfrac, ptn, nee)
+# ALMAOUTPUT
+#TimeSeriesVars3D = (ECanop, TVeg, GPP, CO2FLUX)
+ChunckJob3D = NONE
+Seasonal=ON
+
+[Post_HF_sechiba_out_2]
+Patches= ()
+GatherWithInternal= (lon, lat, veget, time_counter, time_counter_bnds, Areas, Contfrac)
+TimeSeriesVars2D= (mrsos, mrro)
+ChunckJob2D= 50Y
+TimeSeriesVars3D= (ptn)
+ChunckJob3D= 10Y
+Seasonal= OFF
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/sechiba.driver
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/sechiba.driver	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/COMP/sechiba.driver	(revision 405)
@@ -0,0 +1,174 @@
+#!/bin/ksh
+
+#D- Driver du script pour SECHIBA
+
+function SECHIBA_sed
+{
+    IGCM_debug_PushStack "SECHIBA_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	sechiba.def > sechiba.def.tmp
+    RET=$?
+    echo "SECHIBA_sed : ${1} ${2}"
+    \mv sechiba.def.tmp sechiba.def
+    
+    IGCM_debug_PopStack "SECHIBA_sed"
+    return $RET
+}
+
+#-----------------------------------------------------------------
+function SRF_Initialize
+{
+    IGCM_debug_PushStack "SRF_Initialize"
+
+    echo "ORCHIDEE Tag : " ${config_UserChoices_TagName}
+
+    RESOL_SRF=ALL
+    
+    typeset frequency
+    for frequency in ${config_SRF_WriteFrequency} ; do
+        case ${frequency} in
+            HF|hf) SRF_ok_hf=y ;;
+        esac
+    done
+
+    if [ X${sechiba_UserChoices_LAND_USE} = Xy ] ; then
+      sed -e 's&#List=\(.*\)PFTmap\(.*\)year_p1\(.*\)&List=\1PFTmap\2year_p1\3&' ${SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+      IGCM_sys_Mv sechiba.card.tmp ${SUBMIT_DIR}/COMP/sechiba.card
+    fi
+
+    if [ X${sechiba_UserChoices_IMPOSE_VEG} = Xy ] ; then
+      sed -e 's&\(List.*=\)*\([[:space:]]*(*\).*PFTmap.*\${year}.*.nc,.*)&\1\2)&' ${SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+      IGCM_sys_Mv sechiba.card.tmp ${SUBMIT_DIR}/COMP/sechiba.card
+    fi
+
+    IGCM_debug_PopStack "SRF_Initialize"
+}
+
+#-----------------------------------------------------------------
+# Optionnal function executed at the beginning of the main loop, 
+# after IGCM_config_PeriodStart see libIGCM/AA_job. 
+# It may be used to set special variables used in forward lists
+function SRF_PeriodStart
+{
+    IGCM_debug_PushStack "SRF_PeriodStart"
+    IGCM_debug_PopStack "SRF_PeriodStart"
+}
+
+#-----------------------------------------------------------------
+function SRF_Update
+{
+    IGCM_debug_PushStack "SRF_Update"
+
+    typeset SECHIBA_WRITE_STEP
+
+    # Get WriteFrenquecies from config.card for SECHIBA
+    SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) 
+    case ${SRF_WriteFrequency} in
+	*Y|*y) 
+	    WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' )
+	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+	    (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) ;;
+	1M)
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		SECHIBA_WRITE_STEP=-1.
+		;;
+	    *M|*m)
+		SECHIBA_WRITE_STEP=-1.
+		;;
+	    *)
+		(( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
+		;;
+	    esac
+	    ;;
+	*M|*m) 
+	    WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' )
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+		(( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12 ))
+		;;
+	    *M|*m)
+		PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
+		(( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths  * 86400 / PeriodLengthInMonths  ))
+		;;
+	    *)
+		(( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
+		;;
+	    esac
+	    ;;
+	5D|5d) 
+	    (( SECHIBA_WRITE_STEP = 5 * 86400 )) ;;
+	1D|1d) 
+	    (( SECHIBA_WRITE_STEP = 86400 )) ;;
+	*s)
+	    WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' )
+	    (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;;
+	*) 
+	    IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
+	    IGCM_debug_Verif_Exit ;;
+    esac
+    SECHIBA_sed WRITE_STEP ${SECHIBA_WRITE_STEP}
+    SECHIBA_sed SECHIBA_HISTLEVEL ${sechiba_UserChoices_sechiba_LEVEL}
+
+    # Outputs HF in HISTFILE2 if required
+    if [ X${SRF_ok_hf} = Xy ] ; then
+	SECHIBA_sed SECHIBA_HISTFILE2 y
+	SECHIBA_sed SECHIBA_HISTLEVEL2 1
+	SECHIBA_sed WRITE_STEP2 10800.0
+    fi
+
+    SECHIBA_sed STOMATE_OK_CO2 ${sechiba_UserChoices_OKCO2}
+
+    SECHIBA_sed RIVER_ROUTING ${sechiba_UserChoices_ROUTING}
+    SECHIBA_sed HYDROL_CWRR ${sechiba_UserChoices_NEWHYDROL}
+
+    if [ X${sechiba_UserChoices_IMPOSE_VEG} = Xn ] ; then
+	if [ X${sechiba_UserChoices_LAND_USE} = Xy ] ; then
+	    SECHIBA_sed VEGET_UPDATE ${sechiba_UserChoices_VEGET_UPDATE}
+
+            ##MM : cutting PFTmaps of ORCHIDEE : for first year without restart, we must use this year map
+            ##     WARNING : the next year map must be avaible and the december month, then this device will
+            ##               only work with PeriodLength scrictly less than 1Y.
+            # If you want to come back to old BIG LAND USE file
+            # (to run on multipple years, just one time with LAND USE activated), 
+            # you must 
+            # comment all next 8 lines and check correct parameters in sechiba.def file
+            # for your LAND USE specific file.
+	    SECHIBA_sed VEGET_REINIT y
+	    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SRF_Restart}" = "n" ] ) ; then
+		SECHIBA_sed VEGET_YEAR 1
+	    else
+		SECHIBA_sed VEGET_YEAR 0
+		IGCM_sys_Mv -f PFTmap_IPCC_${year_p1}.nc PFTmap.nc
+	    fi
+	elif [ X${sechiba_UserChoices_OLD_VEGET} = Xy ] ; then
+	    SECHIBA_sed LAND_USE n
+	fi
+    else
+	SECHIBA_sed IMPOSE_VEG y
+    fi
+
+    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SRF_Restart}" = "n" ] ) ; then
+	SECHIBA_sed SECHIBA_reset_time y
+    else
+	SECHIBA_sed SECHIBA_restart_in sechiba_rest_in.nc
+	SECHIBA_sed SECHIBA_reset_time y
+    fi
+    FileToBeDeleted[${#FileToBeDeleted[@]}]=sechiba.def
+
+    IGCM_debug_PopStack "SRF_Update"
+}
+
+#-----------------------------------------------------------------
+function SRF_Finalize
+{
+    IGCM_debug_PushStack "SRF_Finalize"
+
+    #IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def
+
+    echo FINALIZE SRF !!!
+
+    IGCM_debug_PopStack "SRF_Finalize"
+}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/PARAM/driver.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/PARAM/driver.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/PARAM/driver.def	(revision 405)
@@ -0,0 +1,298 @@
+#
+#**************************************************************************
+#                    Namelist for ORCHIDEE_OL
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of DRIVER
+#**************************************************************************
+
+# Flag for debug information
+# This option allows to switch on the output of debug
+#         information without recompiling the code.
+DEBUG_INFO = n
+#default = n
+
+
+#---------------------------------------------------------------------
+# Forcing file name
+# Name of file containing the forcing data
+# This is the name of the file which should be opened
+# for reading the forcing data of the dim0 model.
+# The format of the file has to be netCDF and COADS
+# compliant. Cabauw.nc, islscp_for.nc, WG_cru.nc
+FORCING_FILE = forcing_file.nc
+# default = islscp_for.nc
+
+# split time step :
+#---------------------------------------------------------------------
+
+# Splits the timestep imposed by the forcing
+# With this value the time step of the forcing
+#  will be devided. In principle this can be run
+#  in explicit mode but it is strongly suggested
+#  to use the implicit method so that the
+#  atmospheric forcing has a smooth evolution.
+SPLIT_DT = 12
+# default = 12
+
+#  Time in the forcing file at which the model is started.
+#  This time give the point in time at which the model
+#  should be started. 
+#  If exists, the date of the restart file is use.
+#  The FORMAT of this date can be either of the following :
+#  n   : time step n within the forcing file
+#  nS  : n seconds after the first time-step in the file
+#  nD  : n days after the first time-step
+#  nM  : n month after the first time-step (year of 365 days)
+#  nY  : n years after the first time-step (year of 365 days)
+#      Or combinations :
+#  nYmM: n years and m month
+TIME_SKIP = 0
+# default = 0
+
+# Spread the precipitation.
+# Spread the precipitaiton over n steps of the splited forcing time step. 
+#  This is ONLY applied if the forcing time step has been splited (SPLIT_DT).
+#  If the value indicated is greater than SPLIT_DT, SPLIT_DT is used for it.
+SPRED_PREC = 1
+# default = 1
+
+
+
+
+
+# Input and output restart file for the driver
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by the driver
+# This variable give the  name for
+#  the restart file. The restart software within
+#  IOIPSL will add .nc if needed
+RESTART_FILEOUT = driver_rest_out.nc
+# default = driver_rest_out.nc
+
+
+#**************************************************************************
+#                             Area location
+#**************************************************************************
+#  The model will use the smalest regions from
+#  region specified here and the one of the forcing file.
+
+# Western limit of region
+# Western limit of the region we are 
+#  interested in. Between -180 and +180 degrees
+LIMIT_WEST = -180.
+# default = -180.
+
+# Eastern limit of region
+# Eastern limit of the region we are
+#  interested in. Between -180 and +180 degrees
+LIMIT_EAST = 180.
+# default = 180.
+
+# Northern limit of region
+# Northern limit of the region we are
+#  interested in. Between +90 and -90 degrees
+LIMIT_NORTH = 90.
+# default = 90.
+
+# Southern limit of region
+# Southern limit of the region we are
+#  interested in. Between 90 and -90 degrees
+LIMIT_SOUTH = -90.
+# default = -90.
+
+##**************************************************************************
+#                       Simulation parameters
+#**************************************************************************
+
+# method of forcing
+# A method is proposed by which the first atmospheric
+#   level is not directly forced by observations but
+#   relaxed with a time constant towards observations.
+#   For the moment the methods tends to smooth too much
+#   the diurnal cycle and introduces a time shift.
+#   A more sophisticated method is needed.
+RELAXATION = n
+# default = n
+
+# Time constant of the relaxation layer RELAXATION
+# The time constant associated to the atmospheric
+#  conditions which are going to be computed
+#  in the relaxed layer. To avoid too much
+#  damping the value should be larger than 1000.
+RELAX_A = 1000.
+# default = 1000.0
+
+# Height at which T and Q are given
+# The atmospheric variables (temperature and specific
+#  humidity) are measured at a specific level.
+#  The height of this level is needed to compute
+#  correctly the turbulent transfer coefficients.
+#  Look at the description of the forcing
+#  DATA for the correct value.
+HEIGHT_LEV1 = 2.0
+# default  = 2.0
+
+# Height at which the wind is given
+# The height at which wind is needed to compute
+#  correctly the turbulent transfer coefficients.
+HEIGHT_LEVW = 10.0
+# default  = 10.0
+
+#---------------------------------------------------------------------
+# Weather generator or not :
+#---------------------------------------------------------------------
+
+# Allow weather generator to create data.
+# This flag allows the forcing-reader to generate
+#  synthetic data if the data in the file is too sparse
+#  and the temporal resolution would not be enough to
+#  run the model.
+ALLOW_WEATHERGEN = n
+# default = n
+
+# North-South Resolution
+# If ALLOW_WEATHERGEN
+# North-South Resolution of the region we are
+#  interested in. In degrees
+MERID_RES = 2.
+# default = 2.
+
+# East-West Resolution
+# If ALLOW_WEATHERGEN
+# East-West Resolution of the region we are
+#  interested in. In degrees
+ZONAL_RES = 2.
+# default = 2.
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+# If this is set to 1, the weather generator
+#   uses the monthly mean values for daily means.
+#   If it is set to 0, the weather generator
+#   uses statistical relationships to derive daily
+#   values from monthly means.
+IPPREC = 0
+# default = 0
+
+# Interpolation  or not IF split is larger than 1
+# Choose IF you wish to interpolate linearly or not.
+NO_INTER = y
+INTER_LIN = n
+# default :
+#  NO_INTER = y
+#  INTER_LIN = n
+
+# Exact monthly precipitation
+# If ALLOW_WEATHERGEN
+# If this is set to y, the weather generator
+#   will generate pseudo-random precipitations
+#   whose monthly mean is exactly the prescribed one.
+#   In this case, the daily precipitation (for rainy
+#   days) is constant (that is, some days have 0 precip,
+#   the other days have precip = Precip_month/n_precip,
+#   where n_precip is the prescribed number of rainy days
+#   per month).
+WEATHGEN_PRECIP_EXACT = n
+# default = n
+
+# Calling frequency of weather generator (s)
+# Determines how often the weather generator
+#  is called (time step in s). Should be equal
+#  to or larger than Sechiba's time step (say,
+#  up to 6 times Sechiba's time step or so).
+DT_WEATHGEN = 1800.
+# default = 1800.
+
+# Conserve net radiation in the forcing
+# When the interpolation is used the net radiation
+#  provided by the forcing is not conserved anymore.
+#  This should be avoided and thus this option should
+#  be TRUE (y).
+#  This option is not used for short-wave if the
+#  time-step of the forcing is longer than an hour.
+#  It does not make sense to try and reconstruct
+#  a diurnal cycle and at the same time conserve the 
+#  incoming solar radiation.
+NETRAD_CONS = y
+# default = y
+
+# Write weather from generator into a forcing file
+# This flag makes the weather generator dump its
+#  generated weather into a forcing file which can
+#  then be used to get the same forcing on different
+#  machines. This only works correctly if there is
+#  a restart file (otherwise the forcing at the first
+#  time step is slightly wrong).
+DUMP_WEATHER = n
+# default = n
+
+# Name of the file that contains
+#  the weather from generator
+# If DUMP_WEATHER
+DUMP_WEATHER_FILE = weather_dump.nc
+# default = 'weather_dump.nc'
+
+# Dump weather data on gathered grid
+# If 'y', the weather data are gathered
+#  for all land points.
+# If DUMP_WEATHER
+DUMP_WEATHER_GATHERED = y
+# default = y
+
+
+# Read Orbital Parameters
+
+# Eccentricity Effect
+# Use prescribed values
+# IF ALLOW_WEATHERGEN
+ECCENTRICITY = 0.016724
+# default = 0.016724
+
+# Longitude of perihelie
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+PERIHELIE = 102.04
+# default = 102.04
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+OBLIQUITY = 23.446
+# default = 23.446
+
+#**************************************************************************
+# length of simulation :
+#---------------------------------------------------------------------
+# Length of the integration in time.
+# Length of integration. By default the entire length
+#        of the forcing is used. The FORMAT of this date can
+#        be either of the following :
+# n   : time step n within the forcing file
+# nS  : n seconds after the first time-step in the file
+# nD  : n days after the first time-step
+# nM  : n month after the first time-step (year of 365 days)
+# nY  : n years after the first time-step (year of 365 days)
+#        Or combinations :
+# nYmM: n years and m month
+TIME_LENGTH = default
+# default = depend on the time length and the number of time step in forcing file
+#         = itau_len = itau_fin-itau_dep
+
+
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/PARAM/run.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/PARAM/run.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/PARAM/run.def	(revision 405)
@@ -0,0 +1,4 @@
+# $Id: run.def,v 1.1 2010/10/11 13:37:16 ssipsl Exp $
+#
+INCLUDEDEF=driver.def
+INCLUDEDEF=sechiba.def
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/PARAM/sechiba.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/PARAM/sechiba.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/PARAM/sechiba.def	(revision 405)
@@ -0,0 +1,817 @@
+#
+#**************************************************************************
+#                    Namelist for SECHIBA
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of SECHIBA
+#**************************************************************************
+
+# ORCHIDEE will print more messages
+# This flag permits to print more debug messages in the run.
+LONGPRINT = n
+#default = n
+
+#---------------------------------------------------------------------
+
+# Should the output follow the ALMA convention
+# If this logical flag is set to true the model
+#  will output all its data according to the ALMA 
+#  convention. It is the recommended way to write
+#  data out of ORCHIDEE.
+ALMA_OUTPUT = n
+# default = n
+
+# To reset the time coming from SECHIBA restart file
+# This option allows the model to override the time
+#  found in the restart file of SECHIBA with the time
+#  of the first call. That is the restart time of the GCM.
+SECHIBA_reset_time = n
+# default = n
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+# Name of file from which the vegetation map is to be read
+# If !IMPOSE_VEG
+# If LAND_USE 
+#   default = pft_new.nc
+#   The name of the file to be opened to read a vegetation
+#   map (in pft) is to be given here. 
+# If !LAND_USE
+#   default = ../surfmap/carteveg5km.nc
+#   The name of the file to be opened to read the vegetation
+#   map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#   map which is derived from the IGBP one. We assume that we have
+#   a classification in 87 types. This is Olson modified by Viovy.
+VEGETATION_FILE = PFTmap.nc
+
+
+# Name of file from which the bare soil albedo
+# If !IMPOSE_AZE
+# The name of the file to be opened to read the soil types from 
+#  which we derive then the bare soil albedos. This file is 1x1 
+#  deg and based on the soil colors defined by Wilson and Henderson-Seller.
+SOILALB_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Name of file from which soil types are read
+# If !IMPOSE_VEG
+# The name of the file to be opened to read the soil types. 
+#  The data from this file is then interpolated to the grid of
+#  of the model. The aim is to get fractions for sand loam and
+#  clay in each grid box. This information is used for soil hydrology
+#  and respiration.
+SOILTYPE_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Input and output restart file for SECHIBA :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+SECHIBA_restart_in = NONE
+# default = NONE
+
+# Name of restart files to be created by SECHIBA
+# This variable give the name for the restart files. 
+#  The restart software within IOIPSL will add .nc if needed.
+SECHIBA_rest_out = sechiba_rest_out.nc
+# default = sechiba_rest_out.nc
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+
+# ORCHIDEE will write out its forcing to a file
+# This flag allows to write to a file all the variables
+#  which are used to force the land-surface. The file 
+#  has exactly the same format than a normal off-line forcing
+#  and thus this forcing can be used for forcing ORCHIDEE.
+ORCHIDEE_WATCHOUT = n
+# default = n
+
+# Filenane for the ORCHIDEE forcing file
+# If ORCHIDEE_WATCHOUT
+# This is the name of the file in which the
+#  forcing used here will be written for later use. 
+WATCHOUT_FILE = orchidee_watchout.nc
+# default = orchidee_watchout.nc
+
+# ORCHIDEE will write out with this frequency
+# If ORCHIDEE_WATCHOUT
+# This flag indicates the frequency of the write of the variables. 
+DT_WATCHOUT = 1800
+# default = dt
+
+# Output file name :
+#---------------------------------------------------------------------
+# Name of file in which the output is going
+# This file is going to be created by the model
+#  to be written
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+OUTPUT_FILE = sechiba_history.nc
+# default = cabauw_out.nc
+
+# Flag to switch on histfile 2 for SECHIBA (hi-frequency ?)
+# This Flag switch on the second SECHIBA writing for hi (or low) 
+#  frequency writing. This second output is optional and not written
+#  by default.
+SECHIBA_HISTFILE2 = FALSE
+# default  = FALSE
+
+# Name of file in which the output number 2 is going
+#   to be written
+# If SECHIBA_HISTFILE2
+# This file is going to be created by the model
+#   and will contain the output 2 from the model.
+SECHIBA_OUTPUT_FILE2 = sechiba_out_2.nc
+# default  = sechiba_out_2.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# SECHIBA history output level (0..10)
+# Chooses the list of variables in the history file. 
+#  Values between 0: nothing is written; 10: everything is 
+#  written are available More details can be found on the web under documentation.
+#  web under documentation.
+SECHIBA_HISTLEVEL = 5
+# default = 5
+
+# SECHIBA history 2 output level (0..10)
+# If SECHIBA_HISTFILE2
+# Chooses the list of variables in the history file. 
+#   Values between 0: nothing is written; 10: everything is 
+#   written are available More details can be found on the web under documentation.
+#   web under documentation.
+# First level contains all ORCHIDEE outputs.
+SECHIBA_HISTLEVEL2 = 1
+# default = 1
+
+# Write frequency for output files (SECHIBA in seconds) :
+#---------------------------------------------------------------------
+# Frequency in seconds at which to WRITE output
+# This variables gives the frequency the output of
+#  the model should be written into the netCDF file.
+#  It does not affect the frequency at which the
+#  operations such as averaging are done.
+WRITE_STEP = 86400.0
+# default = 86400.0
+
+# Frequency in seconds at which to WRITE output
+# If SECHIBA_HISTFILE2
+# This variables gives the frequency the output 2 of
+#   the model should be written into the netCDF file.
+#   It does not affect the frequency at which the
+#   operations such as averaging are done.
+#   That is IF the coding of the calls to histdef
+#   are correct !
+WRITE_STEP2 = 1800.0
+# default = 1800.0
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate CO2?
+# set to TRUE if photosynthesis is to be activated
+STOMATE_OK_CO2 = n
+# default = n
+
+# Flag to force the value of atmospheric CO2 for vegetation.
+# If this flag is set to true, the ATM_CO2 parameter is used
+#  to prescribe the atmospheric CO2.
+# This Flag is only use in couple mode.
+FORCE_CO2_VEG = FALSE
+# default = FALSE
+
+# Value for atm CO2.
+# If FORCE_CO2_VEG (in not forced mode)
+# Value to prescribe the atm CO2.
+#  For pre-industrial simulations, the value is 286.2 .
+#  348. for 1990 year.
+ATM_CO2 = 350.
+# default = 350.
+
+
+#
+#**************************************************************************
+#          NEW OPTIONS FOR RESTARTS in versions up to 1.9.3
+#**************************************************************************
+#
+## sechiba
+soilcap=n
+soilflx=n
+shumdiag=n
+runoff=n
+drainage=n
+
+## diffuco
+raero=n
+qsatt=n
+cdrag=n
+
+## enerbil
+evapot_corr=n
+temp_sol_new=n
+
+## hydrolc
+dss=n
+hdry=n
+
+## thermosoil
+cgrnd=n
+dgrnd=n
+z1=n
+pcapa=n
+pcapa_en=n
+pkappa=n
+zdz1=n
+zdz2=n
+temp_sol_beg=n
+
+# parameters describing the surface (vegetation + soil) :
+#---------------------------------------------------------------------
+#
+# Should the vegetation be prescribed
+# This flag allows the user to impose a vegetation distribution
+#  and its characterisitcs. It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_VEG = n
+# default = n
+
+# Flag to use old "interpolation" of vegetation map.
+# IF NOT IMPOSE_VEG and NOT LAND_USE
+#  If you want to recover the old (ie orchidee_1_2 branch) 
+#   "interpolation" of vegetation map.
+SLOWPROC_VEGET_OLD_INTERPOL = n
+# default = n
+
+# Vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEG__01 = 0.2
+SECHIBA_VEG__02 = 0.0
+SECHIBA_VEG__03 = 0.0
+SECHIBA_VEG__04 = 0.0
+SECHIBA_VEG__05 = 0.0
+SECHIBA_VEG__06 = 0.0
+SECHIBA_VEG__07 = 0.0
+SECHIBA_VEG__08 = 0.0
+SECHIBA_VEG__09 = 0.0
+SECHIBA_VEG__10 = 0.8
+SECHIBA_VEG__11 = 0.0
+SECHIBA_VEG__12 = 0.0
+SECHIBA_VEG__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# Maximum vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEGMAX__01 = 0.2
+SECHIBA_VEGMAX__02 = 0.0
+SECHIBA_VEGMAX__03 = 0.0
+SECHIBA_VEGMAX__04 = 0.0
+SECHIBA_VEGMAX__05 = 0.0
+SECHIBA_VEGMAX__06 = 0.0
+SECHIBA_VEGMAX__07 = 0.0
+SECHIBA_VEGMAX__08 = 0.0
+SECHIBA_VEGMAX__09 = 0.0
+SECHIBA_VEGMAX__10 = 0.8
+SECHIBA_VEGMAX__11 = 0.0
+SECHIBA_VEGMAX__12 = 0.0
+SECHIBA_VEGMAX__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# LAI for all vegetation types (0-dim mode)
+# If IMPOSE_VEG
+# The maximum LAI used in the 0dim mode. The values should be found
+#  in the restart file. The new values of LAI will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SECHIBA_LAI__01 = 0.
+SECHIBA_LAI__02 = 8.
+SECHIBA_LAI__03 = 8.
+SECHIBA_LAI__04 = 4.
+SECHIBA_LAI__05 = 4.5
+SECHIBA_LAI__06 = 4.5
+SECHIBA_LAI__07 = 4.
+SECHIBA_LAI__08 = 4.5
+SECHIBA_LAI__09 = 4.
+SECHIBA_LAI__10 = 2.
+SECHIBA_LAI__11 = 2.
+SECHIBA_LAI__12 = 2.
+SECHIBA_LAI__13 = 2.
+# default = 0., 8., 8., 4., 4.5, 4.5, 4., 4.5, 4., 2., 2., 2., 2.
+
+# Height for all vegetation types (m)
+# If IMPOSE_VEG
+# The height used in the 0dim mode. The values should be found
+#  in the restart file. The new values of height will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SLOWPROC_HEIGHT__01 = 0.
+SLOWPROC_HEIGHT__02 = 50.
+SLOWPROC_HEIGHT__03 = 50.
+SLOWPROC_HEIGHT__04 = 30.
+SLOWPROC_HEIGHT__05 = 30.
+SLOWPROC_HEIGHT__06 = 30.
+SLOWPROC_HEIGHT__07 = 20.
+SLOWPROC_HEIGHT__08 = 20.
+SLOWPROC_HEIGHT__09 = 20.
+SLOWPROC_HEIGHT__10 = .2
+SLOWPROC_HEIGHT__11 = .2
+SLOWPROC_HEIGHT__12 = .4
+SLOWPROC_HEIGHT__13 = .4
+# default = 0., 30., 30., 20., 20., 20., 15., 15., 15., .5, .6, 1.0, 1.0
+
+
+# Fraction of the 3 soil types (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction for the 3 soil types
+#  in the mesh in the following order : sand loam and clay.
+SOIL_FRACTIONS__01 = 0.28
+SOIL_FRACTIONS__02 = 0.52
+SOIL_FRACTIONS__03 = 0.20
+# default = 0.28, 0.52, 0.20
+
+# Temperature used for the initial guess of LAI
+# If there is no LAI in the restart file, we may need
+#  a temperature that is used to guess the initial LAI.
+SLOWPROC_LAI_TEMPDIAG = 280.
+# default = 280.
+
+# Soil level (m) used for canopy development 
+# If STOMATE is not activated.
+# The temperature at this soil depth is used to determine the LAI when
+#   STOMATE is not activated.
+SECHIBA_ZCANOP = 0.5
+# default = 0.5
+
+# Fraction of other surface types within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of ice, lakes, etc. is read from the restart file. If
+#  it is not found there we will use the values provided here.
+#  For the moment, there is only ice.
+SECHIBA_FRAC_NOBIO = 0.0
+# default = 0.0
+
+# Fraction of the clay fraction (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction of clay in the grid box.
+CLAY_FRACTION = 0.2
+# default = 0.2
+
+# Should the surface parameters be prescribed
+# This flag allows the user to impose the surface parameters
+#  (Albedo Roughness and Emissivity). It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_AZE = n
+# default = n
+
+# Emissivity of the surface for LW radiation
+# If IMPOSE_AZE
+# The surface emissivity used for compution the LE emission
+#  of the surface in a 0-dim version. Values range between 
+#  0.97 and 1.. The GCM uses 0.98.
+CONDVEG_EMIS = 1.0
+# default = 1.0
+
+# SW visible albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in visible wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBVIS = 0.25
+# default = 0.25
+
+# SW near infrared albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in near infrared wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBNIR = 0.25
+# default = 0.25
+
+# Average method for z0
+# If this flag is set to true (y) then the neutral Cdrag
+#  is averaged instead of the log(z0). This should be
+#  the prefered option. We still wish to keep the other
+#  option so we can come back if needed. If this is
+#  desired then one should set Z0CDRAG_AVE = n
+Z0CDRAG_AVE = y
+# default = y
+
+# Surface roughness (m)
+# If IMPOSE_AZE
+# Surface rougness to be used on the point if a 0-dim version
+#  of SECHIBA is used. Look at the description of the forcing  
+#  data for the correct value.
+CONDVEG_Z0 = 0.15
+# default = 0.15_stnd
+
+# Height to be added to the height of the first level (m)
+# If IMPOSE_AZE
+# ORCHIDEE assumes that the atmospheric level height is counted
+#  from the zero wind level. Thus to take into account the roughness
+#  of tall vegetation we need to correct this by a certain fraction
+#  of the vegetation height. This is called the roughness height in
+#  ORCHIDEE talk.
+ROUGHHEIGHT = 0.0
+# default = 0.0
+
+# The snow albedo used by SECHIBA
+# This option allows the user to impose a snow albedo.
+#  Default behaviour is to use the model of snow albedo
+#  developed by Chalita (1993).
+CONDVEG_SNOWA = default
+# default = use the model of snow albedo developed by Chalita
+
+# Switch bare soil albedo dependent (if TRUE) on soil wetness
+# If TRUE, the model for bare soil albedo is the old formulation.
+#  Then it depend on the soil dry or wetness. If FALSE, it is the 
+#  new computation that is taken, it is only function of soil color.
+ALB_BARE_MODEL = FALSE
+# default = FALSE
+
+# Initial snow mass if not found in restart
+# The initial value of snow mass if its value is not found
+#   in the restart file. This should only be used if the model is 
+#   started without a restart file.
+HYDROL_SNOW = 0.0
+# default = 0.0
+
+
+# Initial snow age if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOWAGE = 0.0
+# default = 0.0
+
+# Initial snow amount on ice, lakes, etc. if not found in restart
+# The initial value of snow if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO = 0.0
+# default = 0.0
+
+# Initial snow age on ice, lakes, etc. if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO_AGE = 0.0
+# default = 0.0
+
+# Initial dry soil height if not found in restart for ORCHIDEE_1.3 to 1.5 Tags only.
+# The initial value of dry soil height if its value is not found
+# in the restart file. This should only be used if the model is 
+# started without a restart file.
+HYDROL_HDRY = 0.0
+# default = 0.0
+
+# Initial soil moisture stress if not found in restart
+# The initial value of soil moisture stress if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_HUMR = 1.0
+# default = 1.0
+
+# Total depth of soil reservoir
+HYDROL_SOIL_DEPTH = 2.
+# default = 2.
+
+# Root profile
+# Default values were defined for 2 meters soil depth.
+# For 4 meters soil depth, you may use those ones :
+# 5., .4, .4, 1., .8, .8, 1., 1., .8, 4., 1., 4., 1.
+HYDROL_HUMCSTE = 5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+# default =  5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+
+# Initial restart deep soil moisture if not found in restart
+# The initial value of deep soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. Default behaviour is a saturated soil.
+HYDROL_BQSB = default
+# default = Maximum quantity of water (Kg/M3) * Total depth of soil reservoir = 150. * 2
+
+# Initial upper soil moisture if not found in restart
+# The initial value of upper soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_GQSB = 0.0
+# default = 0.0
+
+# Initial upper reservoir depth if not found in restart
+# The initial value of upper reservoir depth if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_DSG = 0.0
+# default = 0.0
+
+# Initial dry soil above upper reservoir if not found in restart
+# The initial value of dry soil above upper reservoir if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. The default behaviour
+#  is to compute it from the variables above. Should be OK most of 
+#  the time.
+HYDROL_DSP = default
+# default = Total depth of soil reservoir - HYDROL_BQSB / Maximum quantity of water (Kg/M3) = 0.0
+
+# Initial water on canopy if not found in restart
+# The initial value of moisture on canopy if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_QSV = 0.0
+# default = 0.0
+
+# Soil moisture on each soil tile and levels
+# The initial value of mc if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_MOISTURE_CONTENT = 0.3
+# default = 0.3
+
+# US_NVM_NSTM_NSLM
+# The initial value of us (relative moisture) if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+US_INIT = 0.0
+# default = 0.0
+
+# Coefficient for free drainage at bottom
+# The initial value of free drainage if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+FREE_DRAIN_COEF = 1.0, 1.0, 1.0
+# default = 1.0, 1.0, 1.0
+
+# Bare soil evap on each soil if not found in restart
+# The initial value of bare soils evap if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+EVAPNU_SOIL = 0.0
+# default = 0.0
+
+# Initial temperature if not found in restart
+# The initial value of surface temperature if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+ENERBIL_TSURF = 280.
+# default = 280.
+
+# Initial Soil Potential Evaporation
+# The initial value of soil potential evaporation if its value 
+#  is not found in the restart file. This should only be used if
+#  the model is started without a restart file. 
+ENERBIL_EVAPOT = 0.0
+# default = 0.0
+
+# Initial soil temperature profile if not found in restart
+# The initial value of the temperature profile in the soil if 
+#   its value is not found in the restart file. This should only 
+#   be used if the model is started without a restart file. Here
+#   we only require one value as we will assume a constant 
+#   throughout the column.
+THERMOSOIL_TPRO = 280.
+# default = 280.
+
+# Initial leaf CO2 level if not found in restart
+# The initial value of leaf_ci if its value is not found
+#  in the restart file. This should only be used if the model is
+#  started without a restart file.
+DIFFUCO_LEAFCI = 233.
+# default = 233.
+
+
+# Keep cdrag coefficient from gcm.
+# Set to .TRUE. if you want q_cdrag coming from GCM.
+#  Keep cdrag coefficient from gcm for latent and sensible heat fluxes.
+#  TRUE if q_cdrag on initialization is non zero (FALSE for off-line runs).
+CDRAG_FROM_GCM = n
+# default =  IF q_cdrag == 0 ldq_cdrag_from_gcm = .FALSE. ELSE .TRUE.
+
+
+# Artificial parameter to increase or decrease canopy resistance
+# Add from Nathalie - the 28 of March 2006 - advice from Fred Hourdin
+# By PFT.
+RVEG_PFT = 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.
+# default = 1.
+
+
+# Interception reservoir coefficient.
+# Transforms leaf area index into size of interception reservoir
+#  for slowproc_derivvar or stomate.
+SECHIBA_QSINT = 0.1
+# default = 0.1
+
+#**************************************************************************
+# LAI
+#**************************************************************************
+
+# Read the LAI map
+# It is possible to read a 12 month LAI map which will
+#  then be interpolated to daily values as needed.
+#  If n => type_of_lai (constant_veg.f90)
+#     - mean    : lai(ji,jv) = undemi * (llaimax(jv) + llaimin(jv))
+#     - inter   : llaimin(jv) + tempfunc(stempdiag(ji,lcanop)) * (llaimax(jv) - llaimin(jv))
+LAI_MAP = n
+# default = n
+
+# Name of file from which the vegetation map is to be read
+# If LAI_MAP
+# The name of the file to be opened to read the LAI
+#  map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#  map which is derived from a Nicolas VIOVY one. 
+LAI_FILE = lai2D.nc
+# default = ../surfmap/lai2D.nc
+
+# Flag to use old "interpolation" of LAI
+# If LAI_MAP
+# If you want to recover the old (ie orchidee_1_2 branch) 
+# "interpolation" of LAI map.
+SLOWPROC_LAI_OLD_INTERPOL = n
+# default = n
+
+#**************************************************************************
+# LAND_USE
+#**************************************************************************
+
+# Read a land_use vegetation map
+# pft values are needed, max time axis is 293
+LAND_USE = y
+# default = n
+
+# Year of the land_use vegetation map readed
+# year off the pft map.
+# default is 133 for year 1982  (as 1982 - 1850 + 1 = 133)
+# If LAND_USE
+VEGET_YEAR = 1
+# default = 133
+
+# booleen to indicate that a new LAND USE file will be used (since 1.9.5 version).
+# The parameter is used to bypass veget_year count 
+# and reinitialize it with VEGET_YEAR parameter.
+# Then it is possible to change LAND USE file.
+# If LAND_USE
+VEGET_REINIT = y
+# default = n
+
+# Update vegetation frequency (since 2.0 version)
+# The veget datas will be update each this time step.
+# If LAND_USE
+VEGET_UPDATE = 0Y
+# default = 1Y
+
+# treat land use modifications
+# With this variable, you can use a Land Use map
+# to simulate anthropic modifications such as   
+# deforestation.                                
+# If LAND_USE
+LAND_COVER_CHANGE = n
+# default = y
+
+#**************************************************************************
+
+# agriculture allowed?
+# With this variable, you can determine
+#  whether agriculture is allowed
+AGRICULTURE = y
+# default = y
+
+#**************************************************************************
+
+# Time within the day simulated
+# This is the time spent simulating the current day. This variable is
+#  prognostic as it will trigger all the computations which are
+#  only done once a day.
+SECHIBA_DAY = 0.0
+# default = 0.0
+
+# Time step of STOMATE and other slow processes
+# Time step (s) of regular update of vegetation
+#  cover, LAI etc. This is also the time step
+#  of STOMATE.
+DT_SLOW = 86400.
+# default = un_jour = 86400.
+
+#**************************************************************************
+
+# Allows to switch on the multilayer hydrology of CWRR
+# This flag allows the user to decide if the vertical
+#  hydrology should be treated using the multi-layer 
+#  diffusion scheme adapted from CWRR by Patricia de Rosnay.
+#  by default the Choisnel hydrology is used.
+HYDROL_CWRR = n
+# default = n
+
+# do horizontal diffusion?
+# If TRUE, then water can diffuse horizontally between
+#  the PFTs' water reservoirs.
+HYDROL_OK_HDIFF = n
+# default = n
+ 
+
+# time scale (s) for horizontal diffusion of water
+# If HYDROL_OK_HDIFF
+# Defines how fast diffusion occurs horizontally between
+#  the individual PFTs' water reservoirs. If infinite, no
+#  diffusion.
+HYDROL_TAU_HDIFF = 86400.
+# default = 86400.
+
+# Percent of precip that is not intercepted by the canopy (only for TAG 1.6).
+# During one rainfall event, PERCENT_THROUGHFALL% of the incident rainfall
+#  will get directly to the ground without being intercepted.
+PERCENT_THROUGHFALL = 30.
+# default = 30.
+
+# Percent by PFT of precip that is not intercepted by the canopy (since TAG 1.8).
+# During one rainfall event, PERCENT_THROUGHFALL_PFT% of the incident rainfall
+#  will get directly to the ground without being intercepted, for each PFT..
+PERCENT_THROUGHFALL_PFT = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+# default = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+
+# Decides if we route the water or not
+# This flag allows the user to decide if the runoff
+#  and drainage should be routed to the ocean
+#  and to downstream grid boxes.
+RIVER_ROUTING = n
+# default = n
+
+# Name of file which contains the routing information
+# The file provided here should allow the routing module to
+#  read the high resolution grid of basins and the flow direction 
+#  from one mesh to the other.
+ROUTING_FILE = routing.nc
+# default = routing.nc
+
+# Time step of the routing scheme
+# If RIVER_ROUTING
+# This values gives the time step in seconds of the routing scheme. 
+#   It should be multiple of the main time step of ORCHIDEE. One day
+#   is a good value.
+ROUTING_TIMESTEP = 86400
+# default = 86400
+
+# Number of rivers 
+# If RIVER_ROUTING
+# This parameter chooses the number of largest river basins
+#  which should be treated as independently as rivers and not
+#  flow into the oceans as diffusion coastal flow.
+ROUTING_RIVERS = 50
+# default = 50
+
+# Should we compute an irrigation flux 
+# This parameters allows the user to ask the model
+#  to compute an irigation flux. This performed for the
+#  on very simple hypothesis. The idea is to have a good
+#  map of irrigated areas and a simple function which estimates
+#  the need to irrigate.
+DO_IRRIGATION = n
+# default = n
+
+# Name of file which contains the map of irrigated areas
+# If IRRIGATE
+# The name of the file to be opened to read the field
+#  with the area in m^2 of the area irrigated within each
+#  0.5 0.5 deg grid box. The map currently used is the one
+#  developed by the Center for Environmental Systems Research 
+#  in Kassel (1995).
+IRRIGATION_FILE = irrigated.nc
+# default = irrigated.nc
+
+# Should we include floodplains 
+# This parameters allows the user to ask the model
+#  to take into account the flood plains and return 
+#  the water into the soil moisture. It then can go 
+#  back to the atmopshere. This tried to simulate 
+#  internal deltas of rivers.
+DO_FLOODPLAINS = n
+# default = n
+
+#**************************************************************************
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/POST/monitoring01_sechiba.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/POST/monitoring01_sechiba.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/POST/monitoring01_sechiba.cfg	(revision 405)
@@ -0,0 +1,68 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann@cea.fr
+# $Date$
+# $Name$
+# $Revision$
+# History:
+# Modification:
+#**************************************************************
+
+##################################################################################################################
+#-----------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#-----------------------------------------------------------------------------------------------------------------
+#
+#   field = name of the field to monitore 
+#   files patterns = pattern of the files used to monitore the field (must be discriminant) 
+#   files additionnal = additionnal files accessible by $FER_DATA
+#   operations = operations to calculate the field 
+#   title = variable title
+#   units = variable units
+#   calcul of area = expression to use for the weight average
+#
+# Notes:
+#   - Comment lines begin by # character.
+#   - Separator between fields is | character.
+#   - Operations must use the ferret syntax, if several files are used precise with the syntax d=x to refer to the x dataset.
+#     They must be enclosed by parenthesis if more than one variable is used.
+#   - files patterns,files additionnal,operations,title,units must be enclosed with character ". 
+#     Use "" if empty.
+#   - Fields will be presented through an html page with thumbnails global, north, south, land, ocean.
+#     Use a field name with one of these pattern to display it under the corresponding thumbnail.
+#
+##################################################################################################################
+
+color=E7FFAB
+smooth=12
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+evap_lands     | "evap"            |  ""               | "evap[d=1]"                      | "Evaporation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+temp_sol_lands | "temp_sol"        |  ""               | "temp_sol[d=1]"                  | "TSOL (LANDS)"                 | "K/d"    | "Areas[d=1]*Contfrac[d=1]"
+humidity_lands | "bqsb gqsb"       |  ""               | "(bqsb[d=1]+gqsb[d=2])"            | "Total Soil Moisture  (LANDS)" | "1"      | "Areas[d=1]*Contfrac[d=1]"
+fluxsens_lands | "fluxsens"        |  ""               | "fluxsens[d=1]"                  | "Sensible Flux (LANDS)"        | "W/m^2"  | "Areas[d=1]*Contfrac[d=1]"
+albedo_lands   | "alb_vis alb_nir" |  ""               | "((alb_vis[d=1]+alb_nir[d=2])*0.5)"| "Mean Albedo (LANDS)"          | "1"      | "Areas[d=1]*Contfrac[d=1]"
+subli_lands    | "subli"           |  ""               | "subli[d=1]"                     | "Sublimation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+snow_lands     | "snow"            |  ""               | "snow[d=1]"                      | "Snow Mass (LANDS)"            | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snownobio_lands | "snownobio"      |  ""               | "snownobio[d=1]"                 | "Snow Other Surfaces (LANDS)"  | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snowf_lands    | "snowf"           |  ""               | "snowf[d=1]"                     | "Snowfall (LANDS)"             | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+vegetn_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=2:9]"           | "veget natural (LANDS)"        | "1"      | "2"
+vegetg_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=10:11]"         | "veget natural grass (LANDS)"  | "1"      | "2"
+vegeta_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=12:13]"         | "veget agriculture (LANDS)"    | "1"      | "2"
+maxveget_lands | "maxvegetfrac"   |  ""              | "((maxvegetfrac[d=1,K=12]+maxvegetfrac[d=1,K=13])*Areas[d=1]*Contfrac[d=1]/1e12)" | "maxveget surface[pft=12+13] "  | "Mkm^2"  | "2"
+nee_lands      | "nee maxvegetfrac" |  ""              | "(nee[d=1]*365*86400*maxvegetfrac[d=2]*Areas[d=1]*Contfrac[d=1]/1e15)"  | "Net Ecosystem Exchange"    | "PgC/yr" | "2"
+lai_lands      | "lai"              |  ""              | "(lai[d=1,K=2:13])"                      | "lai (LANDS)"      | "1"      | "2"
+# lai2_lands     | "lai"              |  ""              | "(lai[d=1,K=2])" | "lai (LANDS)"      | "1"      | "2"
+# lai3_lands     | "lai"              |  ""              | "(lai[d=1,K=3])" | "lai (LANDS)"      | "1"      | "2"
+# lai4_lands     | "lai"              |  ""              | "(lai[d=1,K=4])" | "lai (LANDS)"      | "1"      | "2"
+# lai5_lands     | "lai"              |  ""              | "(lai[d=1,K=5])" | "lai (LANDS)"      | "1"      | "2"
+# lai6_lands     | "lai"              |  ""              | "(lai[d=1,K=6])" | "lai (LANDS)"      | "1"      | "2"
+# lai7_lands     | "lai"              |  ""              | "(lai[d=1,K=7])" | "lai (LANDS)"      | "1"      | "2"
+# lai8_lands     | "lai"              |  ""              | "(lai[d=1,K=8])" | "lai (LANDS)"      | "1"      | "2"
+# lai9_lands     | "lai"              |  ""              | "(lai[d=1,K=9])" | "lai (LANDS)"      | "1"      | "2"
+# lai10_lands    | "lai"              |  ""              | "(lai[d=1,K=10])" | "lai (LANDS)"     | "1"      | "2"
+# lai11_lands    | "lai"              |  ""              | "(lai[d=1,K=11])" | "lai (LANDS)"     | "1"      | "2"
+# lai12_lands    | "lai"              |  ""              | "(lai[d=1,K=12])" | "lai (LANDS)"     | "1"      | "2"
+# lai13_lands    | "lai"              |  ""              | "(lai[d=1,K=13])" | "lai (LANDS)"     | "1"      | "2"
+#------------------------------------------------------------------------------------------------------------------------------------------------------
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/POST/monitoring01_sechiba_LAND_USE_and_LAI_PFTs.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/POST/monitoring01_sechiba_LAND_USE_and_LAI_PFTs.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/POST/monitoring01_sechiba_LAND_USE_and_LAI_PFTs.cfg	(revision 405)
@@ -0,0 +1,69 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann@cea.fr
+# $Date$
+# $Name$
+# $Revision$
+# History:
+# Modification:
+#**************************************************************
+
+##################################################################################################################
+#-----------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#-----------------------------------------------------------------------------------------------------------------
+#
+#   field = name of the field to monitore 
+#   files patterns = pattern of the files used to monitore the field (must be discriminant) 
+#   files additionnal = additionnal files accessible by $FER_DATA
+#   operations = operations to calculate the field 
+#   title = variable title
+#   units = variable units
+#   calcul of area = expression to use for the weight average
+#
+# Notes:
+#   - Comment lines begin by # character.
+#   - Separator between fields is | character.
+#   - Operations must use the ferret syntax, if several files are used precise with the syntax d=x to refer to the x dataset.
+#     They must be enclosed by parenthesis if more than one variable is used.
+#   - files patterns,files additionnal,operations,title,units must be enclosed with character ". 
+#     Use "" if empty.
+#   - Fields will be presented through an html page with thumbnails global, north, south, land, ocean.
+#     Use a field name with one of these pattern to display it under the corresponding thumbnail.
+#
+##################################################################################################################
+
+color=E7FFAB
+smooth=12
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+evap_lands     | "evap"            |  ""               | "evap[d=1]"                      | "Evaporation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+temp_sol_lands | "temp_sol"        |  ""               | "temp_sol[d=1]"                  | "TSOL (LANDS)"                 | "K/d"    | "Areas[d=1]*Contfrac[d=1]"
+humidity_lands | "bqsb gqsb"       |  ""               | "(bqsb[d=1]+gqsb[d=2])"            | "Total Soil Moisture  (LANDS)" | "1"      | "Areas[d=1]*Contfrac[d=1]"
+fluxsens_lands | "fluxsens"        |  ""               | "fluxsens[d=1]"                  | "Sensible Flux (LANDS)"        | "W/m^2"  | "Areas[d=1]*Contfrac[d=1]"
+albedo_lands   | "alb_vis alb_nir" |  ""               | "((alb_vis[d=1]+alb_nir[d=2])*0.5)"| "Mean Albedo (LANDS)"          | "1"      | "Areas[d=1]*Contfrac[d=1]"
+subli_lands    | "subli"           |  ""               | "subli[d=1]"                     | "Sublimation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+snow_lands     | "snow"            |  ""               | "snow[d=1]"                      | "Snow Mass (LANDS)"            | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snownobio_lands | "snownobio"      |  ""               | "snownobio[d=1]"                 | "Snow Other Surfaces (LANDS)"  | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snowf_lands    | "snowf"           |  ""               | "snowf[d=1]"                     | "Snowfall (LANDS)"             | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+vegetn_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=2:9]"           | "veget natural (LANDS)"        | "1"      | "2"
+vegetg_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=10:11]"         | "veget natural grass (LANDS)"  | "1"      | "2"
+vegeta_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=12:13]"         | "veget agriculture (LANDS)"    | "1"      | "2"
+maxveget_lands | "maxvegetfrac"    |  ""               | "maxvegetfrac[d=1,K=12:13]"      | "vegetmax[pft=12,13] (LANDS)"      | "1"      | "2"
+maxveget_forcing | "maxvegetfrac"   |  ""              | "((maxvegetfrac[d=1,K=12]+maxvegetfrac[d=1,K=13])*Areas[d=1]*Contfrac[d=1]/1e12)" | "maxveget surface[pft=12,13] "  | "Mkm^2"  | "2"
+lai_lands      | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=2:13]*maxvegetfrac[d=2,K=2:13])"  | "lai (LANDS)"      | "1"      | "2"
+nee_lands      | "nee maxvegetfrac" |  ""              | "(nee[d=1]*365*86400*maxvegetfrac[d=2]*Areas[d=1]*Contfrac[d=1]/1e15)"  | "Net Ecosystem Exchange"    | "PgC/yr" | "2"
+lai2_lands     | "lai"              |  ""              | "(lai[d=1,K=2])" | "lai (LANDS)"      | "1"      | "2"
+lai3_lands     | "lai"              |  ""              | "(lai[d=1,K=3])" | "lai (LANDS)"      | "1"      | "2"
+lai4_lands     | "lai"              |  ""              | "(lai[d=1,K=4])" | "lai (LANDS)"      | "1"      | "2"
+lai5_lands     | "lai"              |  ""              | "(lai[d=1,K=5])" | "lai (LANDS)"      | "1"      | "2"
+lai6_lands     | "lai"              |  ""              | "(lai[d=1,K=6])" | "lai (LANDS)"      | "1"      | "2"
+lai7_lands     | "lai"              |  ""              | "(lai[d=1,K=7])" | "lai (LANDS)"      | "1"      | "2"
+lai8_lands     | "lai"              |  ""              | "(lai[d=1,K=8])" | "lai (LANDS)"      | "1"      | "2"
+lai9_lands     | "lai"              |  ""              | "(lai[d=1,K=9])" | "lai (LANDS)"      | "1"      | "2"
+lai10_lands    | "lai"              |  ""              | "(lai[d=1,K=10])" | "lai (LANDS)"     | "1"      | "2"
+lai11_lands    | "lai"              |  ""              | "(lai[d=1,K=11])" | "lai (LANDS)"     | "1"      | "2"
+lai12_lands    | "lai"              |  ""              | "(lai[d=1,K=12])" | "lai (LANDS)"     | "1"      | "2"
+lai13_lands    | "lai"              |  ""              | "(lai[d=1,K=13])" | "lai (LANDS)"     | "1"      | "2"
+#------------------------------------------------------------------------------------------------------------------------------------------------------
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/config.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/config.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/config.card	(revision 405)
@@ -0,0 +1,114 @@
+#
+# This is config.card file for restart with an NEW libIGCM simulation tree.
+#
+#====================================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+#========================================================================
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=SECHIBA
+LongName="Please, explain here what is this simulation for"
+TagName=OL2
+#============================
+#-- leap, noleap, 360d
+CalendarType=gregorian
+#-- Start and End of Job
+#-- "YYYY-MM-DD"
+DateBegin=1982-01-01
+DateEnd=1982-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength=1M
+#============================
+#-- PBS Class (required on brodie mono/multi)
+#JobClass=mono
+JobClass=multi
+#============================
+#-- Total Number of Processors (minimum is 2 for a coupled configuration)
+#JobNumProcTot=2
+JobNumProcTot=4
+#============================
+#-- Run Options : here for oasis coupling
+JobRunOptions='"-np "${NUM_PROC}" -max_np "${NUM_PROC}'
+#JobRunOptions='"-np "${NUM_PROC}'
+#============================
+PeriodNb=12
+
+#========================================================================
+#D-- ListOfComponents -
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+SRF= (sechiba, orchidee_1_9_5_1)
+OOL= (orchidee_ol, OOL_1_9_5_1)
+
+#========================================================================
+#D-- Executable -
+[Executable]
+Name=orchidee_ol
+#D- For each component, Real name of executable, Name of executable for oasis
+SRF= ("", "")
+OOL= (orchidee_ol, orchidee_ol)
+
+#========================================================================
+#D-- Restarts -
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule=n
+#D- Last day of the experience used as restart
+RestartDate=1981-12-31
+#D- Define restart simulation name (=> JOB_OS)
+RestartJobName=CD1
+#D- Path Server Group Login (=> PSGL)
+RestartPath=${ARCHIVE}/IGCM_OUT/OL2
+# Attention login depend de la machine
+
+#========================================================================
+#D-- Post -
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=5Y
+#D- Optimization of rebuid
+RebuildFromArchive=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency=10Y
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency=10Y
+#D- Offset for seasonal average first start dates ; same unit as SeasonalFrequency
+#D- Usefull if you do not want to consider the first X simulation's years
+SeasonalFrequencyOffset= 0
+
+#========================================================================
+#D-- SRF - SECHIBA
+[SRF]
+WriteFrequency="1M"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=2L18
+RestartPath=${ARCHIVE}/IGCM_OUT/OL2
+#-- Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
+#D-- OOL -
+[OOL]
+WriteFrequency="1M"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=2L18
+RestartPath=${ARCHIVE}/${LOGIN}/SORTIES_CPL_IPSL
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/config.card.OldName
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/config.card.OldName	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC/config.card.OldName	(revision 405)
@@ -0,0 +1,113 @@
+#
+# This is config.card file for restart with an NEW libIGCM simulation tree.
+#
+#====================================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+#========================================================================
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=SECHIBA
+LongName=ORCHIDEE_OL_HEAD
+TagName=OL2
+#============================
+#-- leap, noleap, 360d
+CalendarType=gregorian
+#-- Début et fin de Job
+#-- "YYYY-MM-DD"
+DateBegin=1982-01-01
+DateEnd=1982-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength=1M
+#============================
+#-- PBS Class (required on brodie mono/multi)
+#JobClass=mono
+JobClass=multi
+#============================
+#-- Total Number of Processors (minimum is 2 for a coupled configuration)
+#JobNumProcTot=2
+JobNumProcTot=4
+#============================
+#-- Run Options : here for oasis coupling
+JobRunOptions='"-np "${NUM_PROC}" -max_np "${NUM_PROC}'
+#JobRunOptions='"-np "${NUM_PROC}'
+#============================
+PeriodNb=12
+
+#========================================================================
+#D-- ListOfComponents -
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+SRF= (orchidee, HEAD)
+OOL= (orchidee_ol, HEAD)
+
+#========================================================================
+#D-- Executable -
+[Executable]
+Name=orchidee_ol
+#D- For each component, Real name of executable, Name of executable for oasis
+SRF= ("", "")
+OOL= (orchidee_ol, orchidee_ol)
+
+#========================================================================
+#D-- Restarts -
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule=n
+#D- Last day of the experience used as restart
+RestartDate=1981-12-31
+#D- Define restart simulation name (=> JOB_OS)
+RestartJobName=2L18           
+#D- Path Server Group Login (=> PSGL)
+RestartPath=${ARCHIVE}/${LOGIN}/SORTIES_CPL_IPSL
+# Attention login depend de la machine
+
+#========================================================================
+#D-- Post -
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=NONE
+#D- If you want to monitor variables, this flag determines
+#D- frequency of post-processing submission
+MonitoringFrequency=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency=10Y
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency=10Y
+
+
+#========================================================================
+#D-- SRF -
+[SRF]
+WriteFrequency="1M"
+Restart=y
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=2L18
+RestartPath=${ARCHIVE}/${LOGIN}/SORTIES_CPL_IPSL
+#-- Old component name for restart (if empty, use new name)
+OldName="Srf"
+
+#========================================================================
+#D-- OOL -
+[OOL]
+WriteFrequency="1M"
+Restart=y
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=2L18
+RestartPath=${ARCHIVE}/${LOGIN}/SORTIES_CPL_IPSL
+# Old component name for restart (if empty, use new name)
+OldName="driver"
+
+#========================================================================
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/orchidee_ol.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/orchidee_ol.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/orchidee_ol.card	(revision 405)
@@ -0,0 +1,36 @@
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+# resolution of forcing file (not used yet)
+RESOL=OOL360180
+# If you want to use the same forcing file
+NORESTART=n
+# If you want use config.card PeriodLength for TIME_LENGTH
+TIMELENGTH=y
+
+[InitialStateFiles]
+List=	
+
+[BoundaryFiles]
+List=	(${R_BC}/OOL/${config_UserChoices_TagName}/NCC/ncc_for_${year}.nc, forcing_file.nc)
+ListNonDel= ()
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/driver.def, .) \
+    (${SUBMIT_DIR}/PARAM/run.def, .)
+
+[RestartFiles]
+# List restart that have to be saved/restored each loop (file out, saved, and in) :
+List=	(driver_rest_out.nc,  driver_rest.nc,  driver_rest_in.nc)
+# \
+#    (used_run.def, used_run.def, used_run_in.def)
+# Uncomment previous lines to be sure to STOP if something was wrong in ORCHIDEE.
+
+[OutputText]
+List=   (used_driver.def, used_run.def, out_orchidee_ol)
+# avec la // : out_orchidee_*
+
+[OutputFiles]
+List=	
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/orchidee_ol.driver
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/orchidee_ol.driver	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/orchidee_ol.driver	(revision 405)
@@ -0,0 +1,89 @@
+#!/bin/ksh
+
+#D- Driver du script pour ORCHIDEE_OL (off-line)
+
+function DRIVER_sed
+{
+    IGCM_debug_PushStack "DRIVER_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	driver.def > driver.def.tmp
+    RET=$?
+    echo "DRIVER_sed : ${1} ${2}"
+    \mv driver.def.tmp driver.def
+    
+    IGCM_debug_PopStack "DRIVER_sed"
+    return $RET
+}
+
+#-----------------------------------------------------------------
+function OOL_Initialize
+{
+    IGCM_debug_PushStack "OOL_Initialize"
+
+    NUM_PROC=1
+#D- Number of processors used for lmdz and oasis coupler computed from PBS variable
+    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
+	NUM_PROC=${BATCH_NUM_PROC_TOT}
+    fi
+    echo BATCH_NUM_PROC_TOT=${BATCH_NUM_PROC_TOT}
+    echo NUM_PROC=${NUM_PROC}
+
+    if ( [ X${BATCH_NUM_PROC_TOT} != X ] && [ "${BATCH_NUM_PROC_TOT}" -gt 1 ] ) ; then
+	MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND}
+    fi
+
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/COMP/orchidee_ol.card UserChoices
+    RESOL=${orchidee_ol_UserChoices_RESOL}
+
+    IGCM_debug_PopStack "OOL_Initialize"
+}
+
+#-----------------------------------------------------------------
+function OOL_Update
+{
+    IGCM_debug_PushStack "OOL_Update"
+
+    if [ X"${orchidee_ol_UserChoices_TIMELENGTH}" = Xy ] ; then
+	case ${config_UserChoices_PeriodLength} in
+	    *Y|*y|*M|*m|*D|*d)
+		DRIVER_sed TIME_LENGTH ${PeriodLengthInDays}D
+		;;
+	    *s)
+		DRIVER_sed TIME_LENGTH ${config_UserChoices_PeriodLength}
+	esac
+    fi
+
+    if ( ${FirstInitialize} ) ; then
+	if ( [ "${config_OOL_Restart}" = "y" ] ) ; then
+	    DRIVER_sed RESTART_FILEIN driver_rest_in.nc
+	else
+	    DRIVER_sed TIME_SKIP $( IGCM_date_DaysBetweenGregorianDate ${DateBegin} ${year}0101 )D
+	fi
+    else
+	if [ X${orchidee_ol_UserChoices_NORESTART} = Xn ] ; then
+	    DRIVER_sed RESTART_FILEIN driver_rest_in.nc
+	else
+	    if [ ${DRYRUN} -le 2 ] ; then
+		IGCM_sys_Rm driver_rest_in.nc
+	    fi
+	    DRIVER_sed RESTART_FILEIN NONE
+	fi
+    fi
+
+#    IGCM_sys_Put_Out run.def ${R_OUT_OOL}/${PREFIX}_run.def
+    FileToBeDeleted[${#FileToBeDeleted[@]}]=run.def
+    FileToBeDeleted[${#FileToBeDeleted[@]}]=driver.def
+
+    IGCM_debug_PopStack "OOL_Update"
+}
+
+#-----------------------------------------------------------------
+function OOL_Finalize
+{
+    IGCM_debug_PushStack "OOL_Finalize"
+
+    echo FINALIZE OOL !!!
+
+    IGCM_debug_PopStack "OOL_Finalize"
+}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/sechiba.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/sechiba.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/sechiba.card	(revision 405)
@@ -0,0 +1,76 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+LAIMAP=n
+IMPOSE_VEG=n
+# if IMPOSE_VEG = n
+LAND_USE=n
+# if LAND_USE=y
+VEGET_UPDATE=1Y
+# if LAND_USE=n and we want to use carteveg5km.nc for maxvegetfrac map.
+# (instead of default PFTmap_1850to2005_AR5_LUHa.rc2 below)
+OLD_VEGET=n
+ROUTING=n
+NEWHYDROL=n
+OKCO2=y
+sechiba_LEVEL=11
+
+[InitialStateFiles]
+List=       (${R_INIT}/SRF/${config_UserChoices_TagName}/routing.nc, .),     \
+            (${R_INIT}/SRF/${config_UserChoices_TagName}/soils_param.nc, .), \
+            (${R_INIT}/SRF/${config_UserChoices_TagName}/irrigated.nc, .), \
+            (${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2/PFTmap_IPCC_${year}.nc, PFTmap.nc)
+# ,   \
+# 	(${R_INIT}/SRF/${config_UserChoices_TagName}/floodplains.nc, .), \
+# 	(${R_INIT}/SRF/${config_UserChoices_TagName}/cartepente2d_15min.nc, .)
+	
+[BoundaryFiles]
+#List=	(${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2/PFTmap_IPCC_${year_p1}.nc, .)
+List=	()
+ListNonDel= ()
+#If you want to come back to old BIG LAND USE file (to run on multipple years, just one time with LAND USE activated), you must 
+# 1) empty BC list and INIT first PFTmap lines
+# 2) and suppress previous ListNonDel line and ucomment next one :
+#ListNonDel= (${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2.nc, PFTmap.nc)
+# See also same comment in sechiba.driver.
+
+[SmoothFiles]
+List=()
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/sechiba.def, .)
+
+[RestartFiles]
+# List restart that have to be saved/restored each loop (file out, saved, and in) :
+List=	(sechiba_rest_out.nc, sechiba_rest.nc, sechiba_rest_in.nc)
+
+[OutputText]
+List=   (used_sechiba.def, out_orchidee)
+
+[OutputFiles]
+List=	(sechiba_history.nc, ${R_OUT_SRF_O_M}/${PREFIX}_1M_sechiba_history.nc, Post_1M_sechiba_history), \
+        (sechiba_out_2.nc, ${R_OUT_SRF_O_H}/${PREFIX}_HF_sechiba_out_2.nc, Post_HF_sechiba_out_2), \
+        (orchidee_watchout.nc, ${R_OUT_SRF_O_M}/${PREFIX}_1M_watchout.nc, NONE)
+
+[Post_1M_sechiba_history]
+Patches = ()
+GatherWithInternal= (lon, lat, veget, time_counter, time_counter_bnds, Areas, Contfrac)
+TimeSeriesVars2D = (nobiofrac, alb_nir, alb_vis, bqsb, evap, fluxlat, fluxsens, gqsb, netrad, qair, rain, runoff, snow, snownobio, snowf, subli, tair, temp_sol, tsol_max, tsol_min, drainage,mrsos, mrso, mrros, mrro, prveg, evspsblveg, evspsblsoi, tran, treeFrac, grassFrac, cropFrac, baresoilFrac, residualFrac)
+# ALMAOUTPUT
+#TimeSeriesVars2D = (nobiofrac, SWnet, LWnet, Qh, Qle, Qg, Qf, DelSurfHeat, DelColdCont, Snowf, Rainf, Evap, Qs, Qsb, Qsm, DelSoilMoist, DelSWE, DelIntercept, AvgSurfT, RadT, Albedo, SWE, SoilMoist, SoilWet, SoilTemp, PotEvap, ESoil, ECanop, TVeg, RootMoist, SubSnow, ACond, SnowFrac, SAlbedo, SnowDepth, dis, GPP)
+ChunckJob2D = NONE
+TimeSeriesVars3D = (lai, maxvegetfrac, vegetfrac, ptn, nee)
+# ALMAOUTPUT
+#TimeSeriesVars3D = (ECanop, TVeg, GPP, CO2FLUX)
+ChunckJob3D = NONE
+Seasonal=ON
+
+[Post_HF_sechiba_out_2]
+Patches= ()
+GatherWithInternal= (lon, lat, veget, time_counter, time_counter_bnds, Areas, Contfrac)
+TimeSeriesVars2D= (mrsos, mrro)
+ChunckJob2D= 50Y
+TimeSeriesVars3D= (ptn)
+ChunckJob3D= 10Y
+Seasonal= OFF
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/sechiba.driver
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/sechiba.driver	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/sechiba.driver	(revision 405)
@@ -0,0 +1,172 @@
+#!/bin/ksh
+
+#D- Driver du script pour SECHIBA
+
+function SECHIBA_sed
+{
+    IGCM_debug_PushStack "SECHIBA_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	sechiba.def > sechiba.def.tmp
+    RET=$?
+    echo "SECHIBA_sed : ${1} ${2}"
+    \mv sechiba.def.tmp sechiba.def
+    
+    IGCM_debug_PopStack "SECHIBA_sed"
+    return $RET
+}
+
+#-----------------------------------------------------------------
+function SRF_Initialize
+{
+    IGCM_debug_PushStack "SRF_Initialize"
+
+    echo "ORCHIDEE Tag : " ${config_UserChoices_TagName}
+
+    RESOL_SRF=ALL
+    
+    typeset frequency
+    for frequency in ${config_SRF_WriteFrequency} ; do
+        case ${frequency} in
+            HF|hf) SRF_ok_hf=y ;;
+        esac
+    done
+
+    if [ X${sechiba_UserChoices_LAND_USE} = Xy ] ; then
+      sed -e 's&#List=\(.*\)PFTmap\(.*\)year_p1\(.*\)&List=\1PFTmap\2year_p1\3&' ${SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+      IGCM_sys_Mv sechiba.card.tmp ${SUBMIT_DIR}/COMP/sechiba.card
+    fi
+
+    if [ X${sechiba_UserChoices_IMPOSE_VEG} = Xy ] ; then
+      sed -e 's&\(List.*=\)*\([[:space:]]*(*\).*PFTmap.*\${year}.*.nc,.*)&\1\2)&' ${SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+      IGCM_sys_Mv sechiba.card.tmp ${SUBMIT_DIR}/COMP/sechiba.card
+    fi
+
+    IGCM_debug_PopStack "SRF_Initialize"
+}
+
+#-----------------------------------------------------------------
+# Optionnal function executed at the beginning of the main loop, 
+# after IGCM_config_PeriodStart see libIGCM/AA_job. 
+# It may be used to set special variables used in forward lists
+function SRF_PeriodStart
+{
+    IGCM_debug_PushStack "SRF_PeriodStart"
+    IGCM_debug_PopStack "SRF_PeriodStart"
+}
+
+#-----------------------------------------------------------------
+function SRF_Update
+{
+    IGCM_debug_PushStack "SRF_Update"
+
+    typeset SECHIBA_WRITE_STEP
+
+    # Get WriteFrenquecies from config.card for SECHIBA
+    SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) 
+    case ${SRF_WriteFrequency} in
+	*Y|*y) 
+	    WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' )
+	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+	    (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) ;;
+	1M)
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		SECHIBA_WRITE_STEP=-1.
+		;;
+	    *M|*m)
+		SECHIBA_WRITE_STEP=-1.
+		;;
+	    *)
+		(( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
+		;;
+	    esac
+	    ;;
+	*M|*m) 
+	    WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' )
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+		(( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12 ))
+		;;
+	    *M|*m)
+		PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
+		(( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths  * 86400 / PeriodLengthInMonths  ))
+		;;
+	    *)
+		(( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
+		;;
+	    esac
+	    ;;
+	5D|5d) 
+	    (( SECHIBA_WRITE_STEP = 5 * 86400 )) ;;
+	1D|1d) 
+	    (( SECHIBA_WRITE_STEP = 86400 )) ;;
+	*s)
+	    WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' )
+	    (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;;
+	*) 
+	    IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
+	    IGCM_debug_Verif_Exit ;;
+    esac
+    SECHIBA_sed WRITE_STEP ${SECHIBA_WRITE_STEP}
+    SECHIBA_sed SECHIBA_HISTLEVEL ${sechiba_UserChoices_sechiba_LEVEL}
+
+    # Outputs HF in HISTFILE2 if required
+    [ X${SRF_ok_hf} = Xy ] && SECHIBA_sed SECHIBA_HISTFILE2 y
+    SECHIBA_sed SECHIBA_HISTLEVEL2 1
+    SECHIBA_sed WRITE_STEP2 10800.0
+
+    SECHIBA_sed STOMATE_OK_CO2 ${sechiba_UserChoices_OKCO2}
+
+    SECHIBA_sed RIVER_ROUTING ${sechiba_UserChoices_ROUTING}
+    SECHIBA_sed HYDROL_CWRR ${sechiba_UserChoices_NEWHYDROL}
+
+    if [ X${sechiba_UserChoices_IMPOSE_VEG} = Xn ] ; then
+	if [ X${sechiba_UserChoices_LAND_USE} = Xy ] ; then
+	    SECHIBA_sed VEGET_UPDATE ${sechiba_UserChoices_VEGET_UPDATE}
+
+            ##MM : cutting PFTmaps of ORCHIDEE : for first year without restart, we must use this year map
+            ##     WARNING : the next year map must be avaible and the december month, then this device will
+            ##               only work with PeriodLength scrictly less than 1Y.
+            # If you want to come back to old BIG LAND USE file
+            # (to run on multipple years, just one time with LAND USE activated), 
+            # you must 
+            # comment all next 8 lines and check correct parameters in sechiba.def file
+            # for your LAND USE specific file.
+	    SECHIBA_sed VEGET_REINIT y
+	    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SRF_Restart}" = "n" ] ) ; then
+		SECHIBA_sed VEGET_YEAR 1
+	    else
+		SECHIBA_sed VEGET_YEAR 0
+		IGCM_sys_Mv -f PFTmap_IPCC_${year_p1}.nc PFTmap.nc
+	    fi
+	elif [ X${sechiba_UserChoices_OLD_VEGET} = Xy ] ; then
+	    SECHIBA_sed LAND_USE n
+	fi
+    else
+	SECHIBA_sed IMPOSE_VEG y
+    fi
+
+    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SRF_Restart}" = "n" ] ) ; then
+	SECHIBA_sed SECHIBA_reset_time y
+    else
+	SECHIBA_sed SECHIBA_restart_in sechiba_rest_in.nc
+	SECHIBA_sed SECHIBA_reset_time y
+    fi
+    FileToBeDeleted[${#FileToBeDeleted[@]}]=sechiba.def
+
+    IGCM_debug_PopStack "SRF_Update"
+}
+
+#-----------------------------------------------------------------
+function SRF_Finalize
+{
+    IGCM_debug_PushStack "SRF_Finalize"
+
+    #IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def
+
+    echo FINALIZE SRF !!!
+
+    IGCM_debug_PopStack "SRF_Finalize"
+}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/stomate.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/stomate.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/stomate.card	(revision 405)
@@ -0,0 +1,51 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+stomate_LEVEL=10
+
+[InitialStateFiles]
+List=   ()
+
+[BoundaryFiles]
+List=	()
+ListNonDel= (${R_BC}/SRF/${config_UserChoices_TagName}/reftemp.nc, .)
+
+[SmoothFiles]
+List=	()
+
+[ParametersFiles]
+List=   (${SUBMIT_DIR}/PARAM/stomate.def, .)
+
+[RestartFiles]
+# List restart that have to be saved/restored each loop (file out, saved, and in) :
+List=	(stomate_rest_out.nc, stomate_rest.nc, stomate_rest_in.nc)
+# \
+#	(stomate_forcing.nc, stomate_forcing.nc, stomate_forcing.nc) \
+#	(stomate_Cforcing.nc, stomate_Cforcing.nc, stomate_Cforcing.nc)
+
+
+[OutputText]
+List=   (used_stomate.def)
+
+[OutputFiles]
+List=	(stomate_history.nc, ${R_OUT_SBG_O_M}/${PREFIX}_1M_stomate_history.nc, Post_1M_stomate_history) \
+    (stomate_ipcc_history.nc, ${R_OUT_SBG_O_M}/${PREFIX}_1M_stomate_ipcc_history.nc, Post_1M_stomate_ipcc_history)
+
+[Post_1M_stomate_history]
+Patches= ()
+GatherWithInternal= (lon, lat, PFT, time_counter, Areas)
+TimeSeriesVars2D= (T2M_MONTH,CONTFRAC,RESOLUTION_X,RESOLUTION_Y,CONVFLUX,CFLUX_PROD10,CFLUX_PROD100,CO2FLUX_MONTHLY_SUM,HARVEST_ABOVE)
+ChunckJob2D = NONE
+TimeSeriesVars3D= (CO2FLUX,LAI,VEGET,VEGET_MAX,NPP,GPP,HET_RESP,MAINT_RESP,GROWTH_RESP,AGE,HEIGHT,TOTAL_M,TOTAL_BM_LITTER,TOTAL_SOIL_CARB,ADAPTATION,REGENERATION)
+ChunckJob3D = NONE
+Seasonal=ON
+
+[Post_1M_stomate_ipcc_history]
+Patches= ()
+GatherWithInternal= (lon, lat, PFT, time_counter, Areas)
+TimeSeriesVars2D=(cVeg, cLitter, cSoil, cProduct, cMassVariation, lai, gpp, ra, npp, rh, fFire, fHarvest, fLuc, nbp, fVegLitter, fLitterSoil, cLeaf, cWood, cRoot, cMisc, cLitterAbove, cLitterBelow, cSoilFast, cSoilMedium, cSoilSlow, landCoverFrac, treeFracPrimDec, treeFracPrimEver, c3PftFrac, c4PftFrac, rGrowth, rMaint, nppLeaf, nppWood, nppRoot, nep)
+ChunckJob2D = NONE
+TimeSeriesVars3D=()
+ChunckJob3D = NONE
+Seasonal=ON
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/stomate.driver
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/stomate.driver	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/COMP/stomate.driver	(revision 405)
@@ -0,0 +1,132 @@
+#!/bin/ksh
+
+#D- Driver du script pour STOMATE
+
+function STOMATE_sed
+{
+    IGCM_debug_PushStack "STOMATE_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	stomate.def > stomate.def.tmp
+    RET=$?
+    echo "STOMATE_sed : ${1} ${2}"
+    \mv stomate.def.tmp stomate.def
+    
+    IGCM_debug_PopStack "STOMATE_sed"
+    return $RET
+}
+
+#-----------------------------------------------------------------
+function SBG_Initialize
+{
+    IGCM_debug_PushStack "SBG_Initialize"
+
+    RESOL_SBG=ALL
+
+    typeset frequency
+    for frequency in ${config_SBG_WriteFrequency} ; do
+        case ${frequency} in
+            HF|hf) SBG_ok_hf=y ;;
+        esac
+    done
+    
+    IGCM_debug_PopStack "SBG_Initialize"
+}
+
+#-----------------------------------------------------------------
+function SBG_PeriodStart
+{
+    IGCM_debug_PushStack "SBG_PeriodStart"
+
+    IGCM_debug_PopStack "SBG_PeriodStart"
+}
+
+#-----------------------------------------------------------------
+function SBG_Update
+{
+    IGCM_debug_PushStack "SBG_Update"
+
+    typeset STOMATE_WRITE_STEP
+
+    case ${config_SBG_WriteFrequency} in
+	*Y|*y) 
+	    WriteInYears=$( echo ${config_SBG_WriteFrequency} | awk -F '[yY]' '{print $1}' )
+	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+	    (( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears )) ;;
+	1M|1m) 
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		STOMATE_WRITE_STEP=-1.
+		;;
+	    *M|*m)
+		STOMATE_WRITE_STEP=-1.
+		;;
+	    *)
+		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
+	    esac
+	    ;;
+	*M|*m) 
+	    WriteInMonths=$( echo ${config_SBG_WriteFrequency} | awk -F '[mM]' '{print $1}' )
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+		(( STOMATE_WRITE_STEP = 30 )) ;;
+	    *M|*m)
+		PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
+		(( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInMonths / PeriodLengthInMonths )) ;;
+	    *)
+		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
+	    esac
+	    ;;
+	5D|5d) 
+	    (( STOMATE_WRITE_STEP = 5 )) ;;
+	1D|1d) 
+	    (( STOMATE_WRITE_STEP = 1 )) ;;
+	*s)
+	    WriteInSeconds=$( echo ${config_SBG_WriteFrequency} | awk -F '[s]' '{print $1}' )
+	    (( STOMATE_WRITE_STEP = 1 )) ;;
+	*) 
+	    IGCM_debug_Exit "SBG_Update " ${config_SBG_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
+	    IGCM_debug_Verif_Exit ;;
+    esac
+
+    STOMATE_sed STOMATE_OK_STOMATE y
+
+    STOMATE_sed STOMATE_HIST_DT ${STOMATE_WRITE_STEP}
+    STOMATE_sed STOMATE_HISTLEVEL ${stomate_UserChoices_stomate_LEVEL}
+    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SBG_Restart}" = "n" ] ) ; then
+	echo "STOMATE : without restart"
+    else
+	STOMATE_sed STOMATE_RESTART_FILEIN stomate_rest_in.nc
+    fi
+
+    if [ X${SBG_ok_hf} = Xy ] ; then 
+	STOMATE_sed STOMATE_IPCC_HIST_DT 1D
+    else
+	STOMATE_sed STOMATE_IPCC_HIST_DT ${STOMATE_WRITE_STEP}
+    fi
+
+    IGCM_debug_PopStack "SBG_Update"
+}
+
+#-----------------------------------------------------------------
+function SBG_Finalize
+{
+    IGCM_debug_PushStack "SBG_Finalize"
+
+    typeset NbDaysDone NbYearsDone
+
+#     NbDaysDone=$( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} )
+#     NbYearsDone=$(( NbDaysDone / 360 ))
+    
+#     echo $NbDaysDone, $NbYearsDone, $(( NbYearsDone % 10 ))
+#    if [ $(( NbYearsDone % 10 )) = 0 ] ; then
+    if [ $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateEnd} ) -ge 0 ] ; then
+	IGCM_sys_Put_Out stomate_Cforcing.nc ${R_OUT_SBG_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_stomate_Cforcing.nc
+	IGCM_sys_Put_Out stomate_forcing.nc  ${R_OUT_SBG_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_stomate_forcing.nc
+	rm -f stomate_Cforcing.nc
+	rm -f stomate_forcing.nc
+    fi
+
+    IGCM_debug_PopStack "SBG_Finalize"
+}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/driver.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/driver.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/driver.def	(revision 405)
@@ -0,0 +1,298 @@
+#
+#**************************************************************************
+#                    Namelist for ORCHIDEE_OL
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of DRIVER
+#**************************************************************************
+
+# Flag for debug information
+# This option allows to switch on the output of debug
+#         information without recompiling the code.
+DEBUG_INFO = n
+#default = n
+
+
+#---------------------------------------------------------------------
+# Forcing file name
+# Name of file containing the forcing data
+# This is the name of the file which should be opened
+# for reading the forcing data of the dim0 model.
+# The format of the file has to be netCDF and COADS
+# compliant. Cabauw.nc, islscp_for.nc, WG_cru.nc
+FORCING_FILE = forcing_file.nc
+# default = islscp_for.nc
+
+# split time step :
+#---------------------------------------------------------------------
+
+# Splits the timestep imposed by the forcing
+# With this value the time step of the forcing
+#  will be devided. In principle this can be run
+#  in explicit mode but it is strongly suggested
+#  to use the implicit method so that the
+#  atmospheric forcing has a smooth evolution.
+SPLIT_DT = 12
+# default = 12
+
+#  Time in the forcing file at which the model is started.
+#  This time give the point in time at which the model
+#  should be started. 
+#  If exists, the date of the restart file is use.
+#  The FORMAT of this date can be either of the following :
+#  n   : time step n within the forcing file
+#  nS  : n seconds after the first time-step in the file
+#  nD  : n days after the first time-step
+#  nM  : n month after the first time-step (year of 365 days)
+#  nY  : n years after the first time-step (year of 365 days)
+#      Or combinations :
+#  nYmM: n years and m month
+TIME_SKIP = 0
+# default = 0
+
+# Spread the precipitation.
+# Spread the precipitaiton over n steps of the splited forcing time step. 
+#  This is ONLY applied if the forcing time step has been splited (SPLIT_DT).
+#  If the value indicated is greater than SPLIT_DT, SPLIT_DT is used for it.
+SPRED_PREC = 1
+# default = 1
+
+
+
+
+
+# Input and output restart file for the driver
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by the driver
+# This variable give the  name for
+#  the restart file. The restart software within
+#  IOIPSL will add .nc if needed
+RESTART_FILEOUT = driver_rest_out.nc
+# default = driver_rest_out.nc
+
+
+#**************************************************************************
+#                             Area location
+#**************************************************************************
+#  The model will use the smalest regions from
+#  region specified here and the one of the forcing file.
+
+# Western limit of region
+# Western limit of the region we are 
+#  interested in. Between -180 and +180 degrees
+LIMIT_WEST = -180.
+# default = -180.
+
+# Eastern limit of region
+# Eastern limit of the region we are
+#  interested in. Between -180 and +180 degrees
+LIMIT_EAST = 180.
+# default = 180.
+
+# Northern limit of region
+# Northern limit of the region we are
+#  interested in. Between +90 and -90 degrees
+LIMIT_NORTH = 90.
+# default = 90.
+
+# Southern limit of region
+# Southern limit of the region we are
+#  interested in. Between 90 and -90 degrees
+LIMIT_SOUTH = -90.
+# default = -90.
+
+##**************************************************************************
+#                       Simulation parameters
+#**************************************************************************
+
+# method of forcing
+# A method is proposed by which the first atmospheric
+#   level is not directly forced by observations but
+#   relaxed with a time constant towards observations.
+#   For the moment the methods tends to smooth too much
+#   the diurnal cycle and introduces a time shift.
+#   A more sophisticated method is needed.
+RELAXATION = n
+# default = n
+
+# Time constant of the relaxation layer RELAXATION
+# The time constant associated to the atmospheric
+#  conditions which are going to be computed
+#  in the relaxed layer. To avoid too much
+#  damping the value should be larger than 1000.
+RELAX_A = 1000.
+# default = 1000.0
+
+# Height at which T and Q are given
+# The atmospheric variables (temperature and specific
+#  humidity) are measured at a specific level.
+#  The height of this level is needed to compute
+#  correctly the turbulent transfer coefficients.
+#  Look at the description of the forcing
+#  DATA for the correct value.
+HEIGHT_LEV1 = 2.0
+# default  = 2.0
+
+# Height at which the wind is given
+# The height at which wind is needed to compute
+#  correctly the turbulent transfer coefficients.
+HEIGHT_LEVW = 10.0
+# default  = 10.0
+
+#---------------------------------------------------------------------
+# Weather generator or not :
+#---------------------------------------------------------------------
+
+# Allow weather generator to create data.
+# This flag allows the forcing-reader to generate
+#  synthetic data if the data in the file is too sparse
+#  and the temporal resolution would not be enough to
+#  run the model.
+ALLOW_WEATHERGEN = n
+# default = n
+
+# North-South Resolution
+# If ALLOW_WEATHERGEN
+# North-South Resolution of the region we are
+#  interested in. In degrees
+MERID_RES = 2.
+# default = 2.
+
+# East-West Resolution
+# If ALLOW_WEATHERGEN
+# East-West Resolution of the region we are
+#  interested in. In degrees
+ZONAL_RES = 2.
+# default = 2.
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+# If this is set to 1, the weather generator
+#   uses the monthly mean values for daily means.
+#   If it is set to 0, the weather generator
+#   uses statistical relationships to derive daily
+#   values from monthly means.
+IPPREC = 0
+# default = 0
+
+# Interpolation  or not IF split is larger than 1
+# Choose IF you wish to interpolate linearly or not.
+NO_INTER = y
+INTER_LIN = n
+# default :
+#  NO_INTER = y
+#  INTER_LIN = n
+
+# Exact monthly precipitation
+# If ALLOW_WEATHERGEN
+# If this is set to y, the weather generator
+#   will generate pseudo-random precipitations
+#   whose monthly mean is exactly the prescribed one.
+#   In this case, the daily precipitation (for rainy
+#   days) is constant (that is, some days have 0 precip,
+#   the other days have precip = Precip_month/n_precip,
+#   where n_precip is the prescribed number of rainy days
+#   per month).
+WEATHGEN_PRECIP_EXACT = n
+# default = n
+
+# Calling frequency of weather generator (s)
+# Determines how often the weather generator
+#  is called (time step in s). Should be equal
+#  to or larger than Sechiba's time step (say,
+#  up to 6 times Sechiba's time step or so).
+DT_WEATHGEN = 1800.
+# default = 1800.
+
+# Conserve net radiation in the forcing
+# When the interpolation is used the net radiation
+#  provided by the forcing is not conserved anymore.
+#  This should be avoided and thus this option should
+#  be TRUE (y).
+#  This option is not used for short-wave if the
+#  time-step of the forcing is longer than an hour.
+#  It does not make sense to try and reconstruct
+#  a diurnal cycle and at the same time conserve the 
+#  incoming solar radiation.
+NETRAD_CONS = y
+# default = y
+
+# Write weather from generator into a forcing file
+# This flag makes the weather generator dump its
+#  generated weather into a forcing file which can
+#  then be used to get the same forcing on different
+#  machines. This only works correctly if there is
+#  a restart file (otherwise the forcing at the first
+#  time step is slightly wrong).
+DUMP_WEATHER = n
+# default = n
+
+# Name of the file that contains
+#  the weather from generator
+# If DUMP_WEATHER
+DUMP_WEATHER_FILE = weather_dump.nc
+# default = 'weather_dump.nc'
+
+# Dump weather data on gathered grid
+# If 'y', the weather data are gathered
+#  for all land points.
+# If DUMP_WEATHER
+DUMP_WEATHER_GATHERED = y
+# default = y
+
+
+# Read Orbital Parameters
+
+# Eccentricity Effect
+# Use prescribed values
+# IF ALLOW_WEATHERGEN
+ECCENTRICITY = 0.016724
+# default = 0.016724
+
+# Longitude of perihelie
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+PERIHELIE = 102.04
+# default = 102.04
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+OBLIQUITY = 23.446
+# default = 23.446
+
+#**************************************************************************
+# length of simulation :
+#---------------------------------------------------------------------
+# Length of the integration in time.
+# Length of integration. By default the entire length
+#        of the forcing is used. The FORMAT of this date can
+#        be either of the following :
+# n   : time step n within the forcing file
+# nS  : n seconds after the first time-step in the file
+# nD  : n days after the first time-step
+# nM  : n month after the first time-step (year of 365 days)
+# nY  : n years after the first time-step (year of 365 days)
+#        Or combinations :
+# nYmM: n years and m month
+TIME_LENGTH = default
+# default = depend on the time length and the number of time step in forcing file
+#         = itau_len = itau_fin-itau_dep
+
+
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/run.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/run.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/run.def	(revision 405)
@@ -0,0 +1,5 @@
+# $Id: run.def,v 1.1 2010/10/06 15:09:33 ssipsl Exp $
+#
+INCLUDEDEF=driver.def
+INCLUDEDEF=sechiba.def
+INCLUDEDEF=stomate.def
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/sechiba.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/sechiba.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/sechiba.def	(revision 405)
@@ -0,0 +1,817 @@
+#
+#**************************************************************************
+#                    Namelist for SECHIBA
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of SECHIBA
+#**************************************************************************
+
+# ORCHIDEE will print more messages
+# This flag permits to print more debug messages in the run.
+LONGPRINT = n
+#default = n
+
+#---------------------------------------------------------------------
+
+# Should the output follow the ALMA convention
+# If this logical flag is set to true the model
+#  will output all its data according to the ALMA 
+#  convention. It is the recommended way to write
+#  data out of ORCHIDEE.
+ALMA_OUTPUT = n
+# default = n
+
+# To reset the time coming from SECHIBA restart file
+# This option allows the model to override the time
+#  found in the restart file of SECHIBA with the time
+#  of the first call. That is the restart time of the GCM.
+SECHIBA_reset_time = n
+# default = n
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+# Name of file from which the vegetation map is to be read
+# If !IMPOSE_VEG
+# If LAND_USE 
+#   default = pft_new.nc
+#   The name of the file to be opened to read a vegetation
+#   map (in pft) is to be given here. 
+# If !LAND_USE
+#   default = ../surfmap/carteveg5km.nc
+#   The name of the file to be opened to read the vegetation
+#   map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#   map which is derived from the IGBP one. We assume that we have
+#   a classification in 87 types. This is Olson modified by Viovy.
+VEGETATION_FILE = PFTmap.nc
+
+
+# Name of file from which the bare soil albedo
+# If !IMPOSE_AZE
+# The name of the file to be opened to read the soil types from 
+#  which we derive then the bare soil albedos. This file is 1x1 
+#  deg and based on the soil colors defined by Wilson and Henderson-Seller.
+SOILALB_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Name of file from which soil types are read
+# If !IMPOSE_VEG
+# The name of the file to be opened to read the soil types. 
+#  The data from this file is then interpolated to the grid of
+#  of the model. The aim is to get fractions for sand loam and
+#  clay in each grid box. This information is used for soil hydrology
+#  and respiration.
+SOILTYPE_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Input and output restart file for SECHIBA :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+SECHIBA_restart_in = NONE
+# default = NONE
+
+# Name of restart files to be created by SECHIBA
+# This variable give the name for the restart files. 
+#  The restart software within IOIPSL will add .nc if needed.
+SECHIBA_rest_out = sechiba_rest_out.nc
+# default = sechiba_rest_out.nc
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+
+# ORCHIDEE will write out its forcing to a file
+# This flag allows to write to a file all the variables
+#  which are used to force the land-surface. The file 
+#  has exactly the same format than a normal off-line forcing
+#  and thus this forcing can be used for forcing ORCHIDEE.
+ORCHIDEE_WATCHOUT = n
+# default = n
+
+# Filenane for the ORCHIDEE forcing file
+# If ORCHIDEE_WATCHOUT
+# This is the name of the file in which the
+#  forcing used here will be written for later use. 
+WATCHOUT_FILE = orchidee_watchout.nc
+# default = orchidee_watchout.nc
+
+# ORCHIDEE will write out with this frequency
+# If ORCHIDEE_WATCHOUT
+# This flag indicates the frequency of the write of the variables. 
+DT_WATCHOUT = 1800
+# default = dt
+
+# Output file name :
+#---------------------------------------------------------------------
+# Name of file in which the output is going
+# This file is going to be created by the model
+#  to be written
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+OUTPUT_FILE = sechiba_history.nc
+# default = cabauw_out.nc
+
+# Flag to switch on histfile 2 for SECHIBA (hi-frequency ?)
+# This Flag switch on the second SECHIBA writing for hi (or low) 
+#  frequency writing. This second output is optional and not written
+#  by default.
+SECHIBA_HISTFILE2 = FALSE
+# default  = FALSE
+
+# Name of file in which the output number 2 is going
+#   to be written
+# If SECHIBA_HISTFILE2
+# This file is going to be created by the model
+#   and will contain the output 2 from the model.
+SECHIBA_OUTPUT_FILE2 = sechiba_out_2.nc
+# default  = sechiba_out_2.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# SECHIBA history output level (0..10)
+# Chooses the list of variables in the history file. 
+#  Values between 0: nothing is written; 10: everything is 
+#  written are available More details can be found on the web under documentation.
+#  web under documentation.
+SECHIBA_HISTLEVEL = 5
+# default = 5
+
+# SECHIBA history 2 output level (0..10)
+# If SECHIBA_HISTFILE2
+# Chooses the list of variables in the history file. 
+#   Values between 0: nothing is written; 10: everything is 
+#   written are available More details can be found on the web under documentation.
+#   web under documentation.
+# First level contains all ORCHIDEE outputs.
+SECHIBA_HISTLEVEL2 = 1
+# default = 1
+
+# Write frequency for output files (SECHIBA in seconds) :
+#---------------------------------------------------------------------
+# Frequency in seconds at which to WRITE output
+# This variables gives the frequency the output of
+#  the model should be written into the netCDF file.
+#  It does not affect the frequency at which the
+#  operations such as averaging are done.
+WRITE_STEP = 86400.0
+# default = 86400.0
+
+# Frequency in seconds at which to WRITE output
+# If SECHIBA_HISTFILE2
+# This variables gives the frequency the output 2 of
+#   the model should be written into the netCDF file.
+#   It does not affect the frequency at which the
+#   operations such as averaging are done.
+#   That is IF the coding of the calls to histdef
+#   are correct !
+WRITE_STEP2 = 1800.0
+# default = 1800.0
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate CO2?
+# set to TRUE if photosynthesis is to be activated
+STOMATE_OK_CO2 = n
+# default = n
+
+# Flag to force the value of atmospheric CO2 for vegetation.
+# If this flag is set to true, the ATM_CO2 parameter is used
+#  to prescribe the atmospheric CO2.
+# This Flag is only use in couple mode.
+FORCE_CO2_VEG = FALSE
+# default = FALSE
+
+# Value for atm CO2.
+# If FORCE_CO2_VEG (in not forced mode)
+# Value to prescribe the atm CO2.
+#  For pre-industrial simulations, the value is 286.2 .
+#  348. for 1990 year.
+ATM_CO2 = 350.
+# default = 350.
+
+
+#
+#**************************************************************************
+#          NEW OPTIONS FOR RESTARTS in versions up to 1.9.3
+#**************************************************************************
+#
+## sechiba
+soilcap=n
+soilflx=n
+shumdiag=n
+runoff=n
+drainage=n
+
+## diffuco
+raero=n
+qsatt=n
+cdrag=n
+
+## enerbil
+evapot_corr=n
+temp_sol_new=n
+
+## hydrolc
+dss=n
+hdry=n
+
+## thermosoil
+cgrnd=n
+dgrnd=n
+z1=n
+pcapa=n
+pcapa_en=n
+pkappa=n
+zdz1=n
+zdz2=n
+temp_sol_beg=n
+
+# parameters describing the surface (vegetation + soil) :
+#---------------------------------------------------------------------
+#
+# Should the vegetation be prescribed
+# This flag allows the user to impose a vegetation distribution
+#  and its characterisitcs. It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_VEG = n
+# default = n
+
+# Flag to use old "interpolation" of vegetation map.
+# IF NOT IMPOSE_VEG and NOT LAND_USE
+#  If you want to recover the old (ie orchidee_1_2 branch) 
+#   "interpolation" of vegetation map.
+SLOWPROC_VEGET_OLD_INTERPOL = n
+# default = n
+
+# Vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEG__01 = 0.2
+SECHIBA_VEG__02 = 0.0
+SECHIBA_VEG__03 = 0.0
+SECHIBA_VEG__04 = 0.0
+SECHIBA_VEG__05 = 0.0
+SECHIBA_VEG__06 = 0.0
+SECHIBA_VEG__07 = 0.0
+SECHIBA_VEG__08 = 0.0
+SECHIBA_VEG__09 = 0.0
+SECHIBA_VEG__10 = 0.8
+SECHIBA_VEG__11 = 0.0
+SECHIBA_VEG__12 = 0.0
+SECHIBA_VEG__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# Maximum vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEGMAX__01 = 0.2
+SECHIBA_VEGMAX__02 = 0.0
+SECHIBA_VEGMAX__03 = 0.0
+SECHIBA_VEGMAX__04 = 0.0
+SECHIBA_VEGMAX__05 = 0.0
+SECHIBA_VEGMAX__06 = 0.0
+SECHIBA_VEGMAX__07 = 0.0
+SECHIBA_VEGMAX__08 = 0.0
+SECHIBA_VEGMAX__09 = 0.0
+SECHIBA_VEGMAX__10 = 0.8
+SECHIBA_VEGMAX__11 = 0.0
+SECHIBA_VEGMAX__12 = 0.0
+SECHIBA_VEGMAX__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# LAI for all vegetation types (0-dim mode)
+# If IMPOSE_VEG
+# The maximum LAI used in the 0dim mode. The values should be found
+#  in the restart file. The new values of LAI will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SECHIBA_LAI__01 = 0.
+SECHIBA_LAI__02 = 8.
+SECHIBA_LAI__03 = 8.
+SECHIBA_LAI__04 = 4.
+SECHIBA_LAI__05 = 4.5
+SECHIBA_LAI__06 = 4.5
+SECHIBA_LAI__07 = 4.
+SECHIBA_LAI__08 = 4.5
+SECHIBA_LAI__09 = 4.
+SECHIBA_LAI__10 = 2.
+SECHIBA_LAI__11 = 2.
+SECHIBA_LAI__12 = 2.
+SECHIBA_LAI__13 = 2.
+# default = 0., 8., 8., 4., 4.5, 4.5, 4., 4.5, 4., 2., 2., 2., 2.
+
+# Height for all vegetation types (m)
+# If IMPOSE_VEG
+# The height used in the 0dim mode. The values should be found
+#  in the restart file. The new values of height will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SLOWPROC_HEIGHT__01 = 0.
+SLOWPROC_HEIGHT__02 = 50.
+SLOWPROC_HEIGHT__03 = 50.
+SLOWPROC_HEIGHT__04 = 30.
+SLOWPROC_HEIGHT__05 = 30.
+SLOWPROC_HEIGHT__06 = 30.
+SLOWPROC_HEIGHT__07 = 20.
+SLOWPROC_HEIGHT__08 = 20.
+SLOWPROC_HEIGHT__09 = 20.
+SLOWPROC_HEIGHT__10 = .2
+SLOWPROC_HEIGHT__11 = .2
+SLOWPROC_HEIGHT__12 = .4
+SLOWPROC_HEIGHT__13 = .4
+# default = 0., 30., 30., 20., 20., 20., 15., 15., 15., .5, .6, 1.0, 1.0
+
+
+# Fraction of the 3 soil types (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction for the 3 soil types
+#  in the mesh in the following order : sand loam and clay.
+SOIL_FRACTIONS__01 = 0.28
+SOIL_FRACTIONS__02 = 0.52
+SOIL_FRACTIONS__03 = 0.20
+# default = 0.28, 0.52, 0.20
+
+# Temperature used for the initial guess of LAI
+# If there is no LAI in the restart file, we may need
+#  a temperature that is used to guess the initial LAI.
+SLOWPROC_LAI_TEMPDIAG = 280.
+# default = 280.
+
+# Soil level (m) used for canopy development 
+# If STOMATE is not activated.
+# The temperature at this soil depth is used to determine the LAI when
+#   STOMATE is not activated.
+SECHIBA_ZCANOP = 0.5
+# default = 0.5
+
+# Fraction of other surface types within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of ice, lakes, etc. is read from the restart file. If
+#  it is not found there we will use the values provided here.
+#  For the moment, there is only ice.
+SECHIBA_FRAC_NOBIO = 0.0
+# default = 0.0
+
+# Fraction of the clay fraction (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction of clay in the grid box.
+CLAY_FRACTION = 0.2
+# default = 0.2
+
+# Should the surface parameters be prescribed
+# This flag allows the user to impose the surface parameters
+#  (Albedo Roughness and Emissivity). It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_AZE = n
+# default = n
+
+# Emissivity of the surface for LW radiation
+# If IMPOSE_AZE
+# The surface emissivity used for compution the LE emission
+#  of the surface in a 0-dim version. Values range between 
+#  0.97 and 1.. The GCM uses 0.98.
+CONDVEG_EMIS = 1.0
+# default = 1.0
+
+# SW visible albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in visible wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBVIS = 0.25
+# default = 0.25
+
+# SW near infrared albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in near infrared wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBNIR = 0.25
+# default = 0.25
+
+# Average method for z0
+# If this flag is set to true (y) then the neutral Cdrag
+#  is averaged instead of the log(z0). This should be
+#  the prefered option. We still wish to keep the other
+#  option so we can come back if needed. If this is
+#  desired then one should set Z0CDRAG_AVE = n
+Z0CDRAG_AVE = y
+# default = y
+
+# Surface roughness (m)
+# If IMPOSE_AZE
+# Surface rougness to be used on the point if a 0-dim version
+#  of SECHIBA is used. Look at the description of the forcing  
+#  data for the correct value.
+CONDVEG_Z0 = 0.15
+# default = 0.15_stnd
+
+# Height to be added to the height of the first level (m)
+# If IMPOSE_AZE
+# ORCHIDEE assumes that the atmospheric level height is counted
+#  from the zero wind level. Thus to take into account the roughness
+#  of tall vegetation we need to correct this by a certain fraction
+#  of the vegetation height. This is called the roughness height in
+#  ORCHIDEE talk.
+ROUGHHEIGHT = 0.0
+# default = 0.0
+
+# The snow albedo used by SECHIBA
+# This option allows the user to impose a snow albedo.
+#  Default behaviour is to use the model of snow albedo
+#  developed by Chalita (1993).
+CONDVEG_SNOWA = default
+# default = use the model of snow albedo developed by Chalita
+
+# Switch bare soil albedo dependent (if TRUE) on soil wetness
+# If TRUE, the model for bare soil albedo is the old formulation.
+#  Then it depend on the soil dry or wetness. If FALSE, it is the 
+#  new computation that is taken, it is only function of soil color.
+ALB_BARE_MODEL = FALSE
+# default = FALSE
+
+# Initial snow mass if not found in restart
+# The initial value of snow mass if its value is not found
+#   in the restart file. This should only be used if the model is 
+#   started without a restart file.
+HYDROL_SNOW = 0.0
+# default = 0.0
+
+
+# Initial snow age if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOWAGE = 0.0
+# default = 0.0
+
+# Initial snow amount on ice, lakes, etc. if not found in restart
+# The initial value of snow if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO = 0.0
+# default = 0.0
+
+# Initial snow age on ice, lakes, etc. if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO_AGE = 0.0
+# default = 0.0
+
+# Initial dry soil height if not found in restart for ORCHIDEE_1.3 to 1.5 Tags only.
+# The initial value of dry soil height if its value is not found
+# in the restart file. This should only be used if the model is 
+# started without a restart file.
+HYDROL_HDRY = 0.0
+# default = 0.0
+
+# Initial soil moisture stress if not found in restart
+# The initial value of soil moisture stress if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_HUMR = 1.0
+# default = 1.0
+
+# Total depth of soil reservoir
+HYDROL_SOIL_DEPTH = 2.
+# default = 2.
+
+# Root profile
+# Default values were defined for 2 meters soil depth.
+# For 4 meters soil depth, you may use those ones :
+# 5., .4, .4, 1., .8, .8, 1., 1., .8, 4., 1., 4., 1.
+HYDROL_HUMCSTE = 5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+# default =  5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+
+# Initial restart deep soil moisture if not found in restart
+# The initial value of deep soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. Default behaviour is a saturated soil.
+HYDROL_BQSB = default
+# default = Maximum quantity of water (Kg/M3) * Total depth of soil reservoir = 150. * 2
+
+# Initial upper soil moisture if not found in restart
+# The initial value of upper soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_GQSB = 0.0
+# default = 0.0
+
+# Initial upper reservoir depth if not found in restart
+# The initial value of upper reservoir depth if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_DSG = 0.0
+# default = 0.0
+
+# Initial dry soil above upper reservoir if not found in restart
+# The initial value of dry soil above upper reservoir if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. The default behaviour
+#  is to compute it from the variables above. Should be OK most of 
+#  the time.
+HYDROL_DSP = default
+# default = Total depth of soil reservoir - HYDROL_BQSB / Maximum quantity of water (Kg/M3) = 0.0
+
+# Initial water on canopy if not found in restart
+# The initial value of moisture on canopy if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_QSV = 0.0
+# default = 0.0
+
+# Soil moisture on each soil tile and levels
+# The initial value of mc if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_MOISTURE_CONTENT = 0.3
+# default = 0.3
+
+# US_NVM_NSTM_NSLM
+# The initial value of us (relative moisture) if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+US_INIT = 0.0
+# default = 0.0
+
+# Coefficient for free drainage at bottom
+# The initial value of free drainage if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+FREE_DRAIN_COEF = 1.0, 1.0, 1.0
+# default = 1.0, 1.0, 1.0
+
+# Bare soil evap on each soil if not found in restart
+# The initial value of bare soils evap if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+EVAPNU_SOIL = 0.0
+# default = 0.0
+
+# Initial temperature if not found in restart
+# The initial value of surface temperature if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+ENERBIL_TSURF = 280.
+# default = 280.
+
+# Initial Soil Potential Evaporation
+# The initial value of soil potential evaporation if its value 
+#  is not found in the restart file. This should only be used if
+#  the model is started without a restart file. 
+ENERBIL_EVAPOT = 0.0
+# default = 0.0
+
+# Initial soil temperature profile if not found in restart
+# The initial value of the temperature profile in the soil if 
+#   its value is not found in the restart file. This should only 
+#   be used if the model is started without a restart file. Here
+#   we only require one value as we will assume a constant 
+#   throughout the column.
+THERMOSOIL_TPRO = 280.
+# default = 280.
+
+# Initial leaf CO2 level if not found in restart
+# The initial value of leaf_ci if its value is not found
+#  in the restart file. This should only be used if the model is
+#  started without a restart file.
+DIFFUCO_LEAFCI = 233.
+# default = 233.
+
+
+# Keep cdrag coefficient from gcm.
+# Set to .TRUE. if you want q_cdrag coming from GCM.
+#  Keep cdrag coefficient from gcm for latent and sensible heat fluxes.
+#  TRUE if q_cdrag on initialization is non zero (FALSE for off-line runs).
+CDRAG_FROM_GCM = n
+# default =  IF q_cdrag == 0 ldq_cdrag_from_gcm = .FALSE. ELSE .TRUE.
+
+
+# Artificial parameter to increase or decrease canopy resistance
+# Add from Nathalie - the 28 of March 2006 - advice from Fred Hourdin
+# By PFT.
+RVEG_PFT = 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.
+# default = 1.
+
+
+# Interception reservoir coefficient.
+# Transforms leaf area index into size of interception reservoir
+#  for slowproc_derivvar or stomate.
+SECHIBA_QSINT = 0.1
+# default = 0.1
+
+#**************************************************************************
+# LAI
+#**************************************************************************
+
+# Read the LAI map
+# It is possible to read a 12 month LAI map which will
+#  then be interpolated to daily values as needed.
+#  If n => type_of_lai (constant_veg.f90)
+#     - mean    : lai(ji,jv) = undemi * (llaimax(jv) + llaimin(jv))
+#     - inter   : llaimin(jv) + tempfunc(stempdiag(ji,lcanop)) * (llaimax(jv) - llaimin(jv))
+LAI_MAP = n
+# default = n
+
+# Name of file from which the vegetation map is to be read
+# If LAI_MAP
+# The name of the file to be opened to read the LAI
+#  map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#  map which is derived from a Nicolas VIOVY one. 
+LAI_FILE = lai2D.nc
+# default = ../surfmap/lai2D.nc
+
+# Flag to use old "interpolation" of LAI
+# If LAI_MAP
+# If you want to recover the old (ie orchidee_1_2 branch) 
+# "interpolation" of LAI map.
+SLOWPROC_LAI_OLD_INTERPOL = n
+# default = n
+
+#**************************************************************************
+# LAND_USE
+#**************************************************************************
+
+# Read a land_use vegetation map
+# pft values are needed, max time axis is 293
+LAND_USE = y
+# default = n
+
+# Year of the land_use vegetation map readed
+# year off the pft map.
+# default is 133 for year 1982  (as 1982 - 1850 + 1 = 133)
+# If LAND_USE
+VEGET_YEAR = 1
+# default = 133
+
+# booleen to indicate that a new LAND USE file will be used (since 1.9.5 version).
+# The parameter is used to bypass veget_year count 
+# and reinitialize it with VEGET_YEAR parameter.
+# Then it is possible to change LAND USE file.
+# If LAND_USE
+VEGET_REINIT = y
+# default = n
+
+# Update vegetation frequency (since 2.0 version)
+# The veget datas will be update each this time step.
+# If LAND_USE
+VEGET_UPDATE = 0Y
+# default = 1Y
+
+# treat land use modifications
+# With this variable, you can use a Land Use map
+# to simulate anthropic modifications such as   
+# deforestation.                                
+# If LAND_USE
+LAND_COVER_CHANGE = n
+# default = y
+
+#**************************************************************************
+
+# agriculture allowed?
+# With this variable, you can determine
+#  whether agriculture is allowed
+AGRICULTURE = y
+# default = y
+
+#**************************************************************************
+
+# Time within the day simulated
+# This is the time spent simulating the current day. This variable is
+#  prognostic as it will trigger all the computations which are
+#  only done once a day.
+SECHIBA_DAY = 0.0
+# default = 0.0
+
+# Time step of STOMATE and other slow processes
+# Time step (s) of regular update of vegetation
+#  cover, LAI etc. This is also the time step
+#  of STOMATE.
+DT_SLOW = 86400.
+# default = un_jour = 86400.
+
+#**************************************************************************
+
+# Allows to switch on the multilayer hydrology of CWRR
+# This flag allows the user to decide if the vertical
+#  hydrology should be treated using the multi-layer 
+#  diffusion scheme adapted from CWRR by Patricia de Rosnay.
+#  by default the Choisnel hydrology is used.
+HYDROL_CWRR = n
+# default = n
+
+# do horizontal diffusion?
+# If TRUE, then water can diffuse horizontally between
+#  the PFTs' water reservoirs.
+HYDROL_OK_HDIFF = n
+# default = n
+ 
+
+# time scale (s) for horizontal diffusion of water
+# If HYDROL_OK_HDIFF
+# Defines how fast diffusion occurs horizontally between
+#  the individual PFTs' water reservoirs. If infinite, no
+#  diffusion.
+HYDROL_TAU_HDIFF = 86400.
+# default = 86400.
+
+# Percent of precip that is not intercepted by the canopy (only for TAG 1.6).
+# During one rainfall event, PERCENT_THROUGHFALL% of the incident rainfall
+#  will get directly to the ground without being intercepted.
+PERCENT_THROUGHFALL = 30.
+# default = 30.
+
+# Percent by PFT of precip that is not intercepted by the canopy (since TAG 1.8).
+# During one rainfall event, PERCENT_THROUGHFALL_PFT% of the incident rainfall
+#  will get directly to the ground without being intercepted, for each PFT..
+PERCENT_THROUGHFALL_PFT = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+# default = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+
+# Decides if we route the water or not
+# This flag allows the user to decide if the runoff
+#  and drainage should be routed to the ocean
+#  and to downstream grid boxes.
+RIVER_ROUTING = n
+# default = n
+
+# Name of file which contains the routing information
+# The file provided here should allow the routing module to
+#  read the high resolution grid of basins and the flow direction 
+#  from one mesh to the other.
+ROUTING_FILE = routing.nc
+# default = routing.nc
+
+# Time step of the routing scheme
+# If RIVER_ROUTING
+# This values gives the time step in seconds of the routing scheme. 
+#   It should be multiple of the main time step of ORCHIDEE. One day
+#   is a good value.
+ROUTING_TIMESTEP = 86400
+# default = 86400
+
+# Number of rivers 
+# If RIVER_ROUTING
+# This parameter chooses the number of largest river basins
+#  which should be treated as independently as rivers and not
+#  flow into the oceans as diffusion coastal flow.
+ROUTING_RIVERS = 50
+# default = 50
+
+# Should we compute an irrigation flux 
+# This parameters allows the user to ask the model
+#  to compute an irigation flux. This performed for the
+#  on very simple hypothesis. The idea is to have a good
+#  map of irrigated areas and a simple function which estimates
+#  the need to irrigate.
+DO_IRRIGATION = n
+# default = n
+
+# Name of file which contains the map of irrigated areas
+# If IRRIGATE
+# The name of the file to be opened to read the field
+#  with the area in m^2 of the area irrigated within each
+#  0.5 0.5 deg grid box. The map currently used is the one
+#  developed by the Center for Environmental Systems Research 
+#  in Kassel (1995).
+IRRIGATION_FILE = irrigated.nc
+# default = irrigated.nc
+
+# Should we include floodplains 
+# This parameters allows the user to ask the model
+#  to take into account the flood plains and return 
+#  the water into the soil moisture. It then can go 
+#  back to the atmopshere. This tried to simulate 
+#  internal deltas of rivers.
+DO_FLOODPLAINS = n
+# default = n
+
+#**************************************************************************
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/stomate.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/stomate.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/PARAM/stomate.def	(revision 405)
@@ -0,0 +1,206 @@
+#
+#**************************************************************************
+#                    Namelist for STOMATE
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of STOMATE
+#**************************************************************************
+
+# Model chatting level
+# level of online diagnostics in STOMATE (0-4)
+# With this variable, you can determine how much online information STOMATE
+#  gives during the run. 0 means virtually no info.
+BAVARD = 1
+# default = 1
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+
+# Name of file from which the reference
+# The name of the file to be opened to read
+#  temperature is read
+#  the reference surface temperature.
+#  The data from this file is then interpolated
+#  to the grid of the model.
+#  The aim is to get a reference temperature either
+#  to initialize the corresponding prognostic model
+#  variable correctly (ok_dgvm = TRUE) or to impose it
+#  as boundary condition (ok_dgvm = FALSE)
+REFTEMP_FILE = reftemp.nc
+# default = reftemp.nc
+# Input and output restart file for STOMATE :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions of STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened of STOMATE
+#   to extract the initial values of all prognostic values of STOMATE.
+STOMATE_RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened
+#        to write the final values of all prognostic values
+#        of STOMATE.
+STOMATE_RESTART_FILEOUT = stomate_rest_out.nc
+# default = stomate_restart.nc
+
+# Forcing files for TESTSTOMATE and FORCESOIL
+#---------------------------------------------------------------------
+
+# Name of STOMATE's forcing file
+# Name that will be given to STOMATE's offline forcing file
+STOMATE_FORCING_NAME = stomate_forcing.nc
+#default = NONE
+
+# Size of STOMATE forcing data in memory (MB)
+# This variable determines how many
+#  forcing states will be kept in memory.
+#  Must be a compromise between memory
+#  use and frequeny of disk access.
+STOMATE_FORCING_MEMSIZE = 50
+# default = 50
+
+# Name of STOMATE's carbon forcing file
+# Name that will be given to STOMATE's carbon offline forcing file
+STOMATE_CFORCING_NAME = stomate_Cforcing.nc
+# default = NONE
+
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+# STOMATE does minimum service
+# set to TRUE if you want STOMATE to read
+#  and write its start files and keep track
+#  of longer-term biometeorological variables.
+#  This is useful if OK_STOMATE is not set,
+#  but if you intend to activate STOMATE later.
+#  In that case, this run can serve as a 
+#  spinup for longer-term biometeorological
+#  variables.
+STOMATE_WATCHOUT = n
+# default = n
+
+
+# Output file name :
+#---------------------------------------------------------------------
+
+# Name of file in which STOMATE's output is going to be written
+# This file is going to be created by the model
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+STOMATE_OUTPUT_FILE = stomate_history.nc
+# default = stomate_history.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# STOMATE history output level (0..10)
+#  0: nothing is written; 10: everything is written
+STOMATE_HISTLEVEL = 10
+# default = 10
+
+# STOMATE_IPCC_OUTPUT_FILE
+# This file is going to be created by the model
+#    and will contain the output from the model.
+#    This file is a truly COADS compliant netCDF file.
+#    It will be generated by the hist software from
+#    the IOIPSL package.
+# Name of file in which STOMATE's output is going
+# to be written
+STOMATE_IPCC_OUTPUT_FILE = stomate_ipcc_history.nc
+# default = stomate_ipcc_history.nc
+
+# STOMATE_IPCC_HIST_DT
+# Time step of the STOMATE IPCC history file
+# STOMATE IPCC history time step (d)
+STOMATE_IPCC_HIST_DT = 0.
+# default = 0.
+
+# Write frequency for output files (STOMATE in days) :
+#---------------------------------------------------------------------
+
+# STOMATE history time step (d)
+# Time step of the STOMATE history file
+# Care : this variable must be higher than DT_SLOW
+STOMATE_HIST_DT = 10.
+# default = 10.
+
+
+#---------------------------------------------------------------------
+# FORCESOIL CARBON spin up parametrization
+#---------------------------------------------------------------------
+
+# Number of time steps per year for carbon spinup.
+FORCESOIL_STEP_PER_YEAR = 12
+# default = 12
+
+# Number of years saved for carbon spinup.
+FORCESOIL_NB_YEAR = 1
+# default = 1
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate STOMATE?
+# set to TRUE if STOMATE is to be activated
+STOMATE_OK_STOMATE = n
+# default = n
+
+# Activate DGVM?
+# set to TRUE if Dynamic Vegetation DGVM is to be activated
+STOMATE_OK_DGVM = n
+# default = n
+
+# Index of grid point for online diagnostics
+# This is the index of the grid point which will be used for online diagnostics.
+STOMATE_DIAGPT = 1
+# default = 1
+
+# constant tree mortality
+# If yes, then a constant mortality is applied to trees. 
+#  Otherwise, mortality is a function of the trees' 
+#  vigour (as in LPJ).
+LPJ_GAP_CONST_MORT = y
+# default = y
+
+# no fire allowed
+# With this variable, you can allow or not
+#  the estimation of CO2 lost by fire
+FIRE_DISABLE = n
+# default = n
+
+#**************************************************************************
+
+# Harvert model for agricol PFTs.
+# Compute harvest above ground biomass for agriculture.
+# Change daily turnover.
+HARVEST_AGRI = y
+# default = y
+
+# herbivores allowed?
+# With this variable, you can activate herbivores 
+HERBIVORES = n
+# default = n
+
+# treat expansion of PFTs across a grid cell?
+# With this variable, you can determine
+#  whether we treat expansion of PFTs across a
+#  grid cell.
+TREAT_EXPANSION = n
+# default = n
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_sechiba.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_sechiba.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_sechiba.cfg	(revision 405)
@@ -0,0 +1,68 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann@cea.fr
+# $Date$
+# $Name$
+# $Revision$
+# History:
+# Modification:
+#**************************************************************
+
+##################################################################################################################
+#-----------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#-----------------------------------------------------------------------------------------------------------------
+#
+#   field = name of the field to monitore 
+#   files patterns = pattern of the files used to monitore the field (must be discriminant) 
+#   files additionnal = additionnal files accessible by $FER_DATA
+#   operations = operations to calculate the field 
+#   title = variable title
+#   units = variable units
+#   calcul of area = expression to use for the weight average
+#
+# Notes:
+#   - Comment lines begin by # character.
+#   - Separator between fields is | character.
+#   - Operations must use the ferret syntax, if several files are used precise with the syntax d=x to refer to the x dataset.
+#     They must be enclosed by parenthesis if more than one variable is used.
+#   - files patterns,files additionnal,operations,title,units must be enclosed with character ". 
+#     Use "" if empty.
+#   - Fields will be presented through an html page with thumbnails global, north, south, land, ocean.
+#     Use a field name with one of these pattern to display it under the corresponding thumbnail.
+#
+##################################################################################################################
+
+color=E7FFAB
+smooth=12
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+evap_lands     | "evap"            |  ""               | "evap[d=1]"                      | "Evaporation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+temp_sol_lands | "temp_sol"        |  ""               | "temp_sol[d=1]"                  | "TSOL (LANDS)"                 | "K/d"    | "Areas[d=1]*Contfrac[d=1]"
+humidity_lands | "bqsb gqsb"       |  ""               | "(bqsb[d=1]+gqsb[d=2])"            | "Total Soil Moisture  (LANDS)" | "1"      | "Areas[d=1]*Contfrac[d=1]"
+fluxsens_lands | "fluxsens"        |  ""               | "fluxsens[d=1]"                  | "Sensible Flux (LANDS)"        | "W/m^2"  | "Areas[d=1]*Contfrac[d=1]"
+albedo_lands   | "alb_vis alb_nir" |  ""               | "((alb_vis[d=1]+alb_nir[d=2])*0.5)"| "Mean Albedo (LANDS)"          | "1"      | "Areas[d=1]*Contfrac[d=1]"
+subli_lands    | "subli"           |  ""               | "subli[d=1]"                     | "Sublimation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+snow_lands     | "snow"            |  ""               | "snow[d=1]"                      | "Snow Mass (LANDS)"            | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snownobio_lands | "snownobio"      |  ""               | "snownobio[d=1]"                 | "Snow Other Surfaces (LANDS)"  | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snowf_lands    | "snowf"           |  ""               | "snowf[d=1]"                     | "Snowfall (LANDS)"             | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+vegetn_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=2:9]"           | "veget natural (LANDS)"        | "1"      | "2"
+vegetg_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=10:11]"         | "veget natural grass (LANDS)"  | "1"      | "2"
+vegeta_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=12:13]"         | "veget agriculture (LANDS)"    | "1"      | "2"
+maxveget_lands | "maxvegetfrac"   |  ""              | "((maxvegetfrac[d=1,K=12]+maxvegetfrac[d=1,K=13])*Areas[d=1]*Contfrac[d=1]/1e12)" | "maxveget surface[pft=12+13] "  | "Mkm^2"  | "2"
+nee_lands      | "nee maxvegetfrac" |  ""              | "(nee[d=1]*365*86400*maxvegetfrac[d=2]*Areas[d=1]*Contfrac[d=1]/1e15)"  | "Net Ecosystem Exchange"    | "PgC/yr" | "2"
+lai_lands      | "lai"              |  ""              | "(lai[d=1,K=2:13])"                      | "lai (LANDS)"      | "1"      | "2"
+# lai2_lands     | "lai"              |  ""              | "(lai[d=1,K=2])" | "lai (LANDS)"      | "1"      | "2"
+# lai3_lands     | "lai"              |  ""              | "(lai[d=1,K=3])" | "lai (LANDS)"      | "1"      | "2"
+# lai4_lands     | "lai"              |  ""              | "(lai[d=1,K=4])" | "lai (LANDS)"      | "1"      | "2"
+# lai5_lands     | "lai"              |  ""              | "(lai[d=1,K=5])" | "lai (LANDS)"      | "1"      | "2"
+# lai6_lands     | "lai"              |  ""              | "(lai[d=1,K=6])" | "lai (LANDS)"      | "1"      | "2"
+# lai7_lands     | "lai"              |  ""              | "(lai[d=1,K=7])" | "lai (LANDS)"      | "1"      | "2"
+# lai8_lands     | "lai"              |  ""              | "(lai[d=1,K=8])" | "lai (LANDS)"      | "1"      | "2"
+# lai9_lands     | "lai"              |  ""              | "(lai[d=1,K=9])" | "lai (LANDS)"      | "1"      | "2"
+# lai10_lands    | "lai"              |  ""              | "(lai[d=1,K=10])" | "lai (LANDS)"     | "1"      | "2"
+# lai11_lands    | "lai"              |  ""              | "(lai[d=1,K=11])" | "lai (LANDS)"     | "1"      | "2"
+# lai12_lands    | "lai"              |  ""              | "(lai[d=1,K=12])" | "lai (LANDS)"     | "1"      | "2"
+# lai13_lands    | "lai"              |  ""              | "(lai[d=1,K=13])" | "lai (LANDS)"     | "1"      | "2"
+#------------------------------------------------------------------------------------------------------------------------------------------------------
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_sechiba_LAND_USE_and_LAI_PFTs.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_sechiba_LAND_USE_and_LAI_PFTs.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_sechiba_LAND_USE_and_LAI_PFTs.cfg	(revision 405)
@@ -0,0 +1,69 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann@cea.fr
+# $Date$
+# $Name$
+# $Revision$
+# History:
+# Modification:
+#**************************************************************
+
+##################################################################################################################
+#-----------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#-----------------------------------------------------------------------------------------------------------------
+#
+#   field = name of the field to monitore 
+#   files patterns = pattern of the files used to monitore the field (must be discriminant) 
+#   files additionnal = additionnal files accessible by $FER_DATA
+#   operations = operations to calculate the field 
+#   title = variable title
+#   units = variable units
+#   calcul of area = expression to use for the weight average
+#
+# Notes:
+#   - Comment lines begin by # character.
+#   - Separator between fields is | character.
+#   - Operations must use the ferret syntax, if several files are used precise with the syntax d=x to refer to the x dataset.
+#     They must be enclosed by parenthesis if more than one variable is used.
+#   - files patterns,files additionnal,operations,title,units must be enclosed with character ". 
+#     Use "" if empty.
+#   - Fields will be presented through an html page with thumbnails global, north, south, land, ocean.
+#     Use a field name with one of these pattern to display it under the corresponding thumbnail.
+#
+##################################################################################################################
+
+color=E7FFAB
+smooth=12
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+evap_lands     | "evap"            |  ""               | "evap[d=1]"                      | "Evaporation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+temp_sol_lands | "temp_sol"        |  ""               | "temp_sol[d=1]"                  | "TSOL (LANDS)"                 | "K/d"    | "Areas[d=1]*Contfrac[d=1]"
+humidity_lands | "bqsb gqsb"       |  ""               | "(bqsb[d=1]+gqsb[d=2])"            | "Total Soil Moisture  (LANDS)" | "1"      | "Areas[d=1]*Contfrac[d=1]"
+fluxsens_lands | "fluxsens"        |  ""               | "fluxsens[d=1]"                  | "Sensible Flux (LANDS)"        | "W/m^2"  | "Areas[d=1]*Contfrac[d=1]"
+albedo_lands   | "alb_vis alb_nir" |  ""               | "((alb_vis[d=1]+alb_nir[d=2])*0.5)"| "Mean Albedo (LANDS)"          | "1"      | "Areas[d=1]*Contfrac[d=1]"
+subli_lands    | "subli"           |  ""               | "subli[d=1]"                     | "Sublimation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+snow_lands     | "snow"            |  ""               | "snow[d=1]"                      | "Snow Mass (LANDS)"            | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snownobio_lands | "snownobio"      |  ""               | "snownobio[d=1]"                 | "Snow Other Surfaces (LANDS)"  | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snowf_lands    | "snowf"           |  ""               | "snowf[d=1]"                     | "Snowfall (LANDS)"             | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+vegetn_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=2:9]"           | "veget natural (LANDS)"        | "1"      | "2"
+vegetg_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=10:11]"         | "veget natural grass (LANDS)"  | "1"      | "2"
+vegeta_lands   | "vegetfrac"       |  ""               | "vegetfrac[d=1,K=12:13]"         | "veget agriculture (LANDS)"    | "1"      | "2"
+maxveget_lands | "maxvegetfrac"    |  ""               | "maxvegetfrac[d=1,K=12:13]"      | "vegetmax[pft=12,13] (LANDS)"      | "1"      | "2"
+maxveget_forcing | "maxvegetfrac"   |  ""              | "((maxvegetfrac[d=1,K=12]+maxvegetfrac[d=1,K=13])*Areas[d=1]*Contfrac[d=1]/1e12)" | "maxveget surface[pft=12,13] "  | "Mkm^2"  | "2"
+lai_lands      | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=2:13]*maxvegetfrac[d=2,K=2:13])"  | "lai (LANDS)"      | "1"      | "2"
+nee_lands      | "nee maxvegetfrac" |  ""              | "(nee[d=1]*365*86400*maxvegetfrac[d=2]*Areas[d=1]*Contfrac[d=1]/1e15)"  | "Net Ecosystem Exchange"    | "PgC/yr" | "2"
+lai02_lands    | "lai"              |  ""              | "(lai[d=1,K=2])" | "lai (LANDS)"      | "1"      | "2"
+lai03_lands    | "lai"              |  ""              | "(lai[d=1,K=3])" | "lai (LANDS)"      | "1"      | "2"
+lai04_lands    | "lai"              |  ""              | "(lai[d=1,K=4])" | "lai (LANDS)"      | "1"      | "2"
+lai05_lands    | "lai"              |  ""              | "(lai[d=1,K=5])" | "lai (LANDS)"      | "1"      | "2"
+lai06_lands    | "lai"              |  ""              | "(lai[d=1,K=6])" | "lai (LANDS)"      | "1"      | "2"
+lai07_lands    | "lai"              |  ""              | "(lai[d=1,K=7])" | "lai (LANDS)"      | "1"      | "2"
+lai08_lands    | "lai"              |  ""              | "(lai[d=1,K=8])" | "lai (LANDS)"      | "1"      | "2"
+lai09_lands    | "lai"              |  ""              | "(lai[d=1,K=9])" | "lai (LANDS)"      | "1"      | "2"
+lai10_lands    | "lai"              |  ""              | "(lai[d=1,K=10])" | "lai (LANDS)"     | "1"      | "2"
+lai11_lands    | "lai"              |  ""              | "(lai[d=1,K=11])" | "lai (LANDS)"     | "1"      | "2"
+lai12_lands    | "lai"              |  ""              | "(lai[d=1,K=12])" | "lai (LANDS)"     | "1"      | "2"
+lai13_lands    | "lai"              |  ""              | "(lai[d=1,K=13])" | "lai (LANDS)"     | "1"      | "2"
+#------------------------------------------------------------------------------------------------------------------------------------------------------
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_stomate.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_stomate.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_stomate.cfg	(revision 405)
@@ -0,0 +1,91 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann@cea.fr
+# $Date$
+# $Name$
+# $Revision$
+# History:
+# Modification:
+#**************************************************************
+
+##################################################################################################################
+#-----------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#-----------------------------------------------------------------------------------------------------------------
+#
+#   field = name of the field to monitore 
+#   files patterns = pattern of the files used to monitore the field (must be discriminant) 
+#   files additionnal = additionnal files accessible by $FER_DATA
+#   operations = operations to calculate the field 
+#   title = variable title
+#   units = variable units
+#   calcul of area = expression to use for the weight average
+#
+# Notes:
+#   - Comment lines begin by # character.
+#   - Separator between fields is | character.
+#   - Operations must use the ferret syntax, if several files are used precise with the syntax d=x to refer to the x dataset.
+#     They must be enclosed by parenthesis if more than one variable is used.
+#   - files patterns,files additionnal,operations,title,units must be enclosed with character ". 
+#     Use "" if empty.
+#   - Fields will be presented through an html page with thumbnails global, north, south, land, ocean.
+#     Use a field name with one of these pattern to display it under the corresponding thumbnail.
+#
+##################################################################################################################
+
+color=EEE8AA
+smooth=12
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+CONVFLUX_lands      | "CONVFLUX CONTFRAC"                  | "" | "(CONVFLUX[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                           | "Annual release right after deforestation (LANDS)"            | "PgC/yr" | "2"
+CFLUX_PROD10_lands  | "CFLUX_PROD10 CONTFRAC"              | "" | "(CFLUX_PROD10[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                       | "Annual release from all 10 year wood product pools (LANDS)"  | "PgC/yr" | "2"
+CFLUX_PROD100_lands | "CFLUX_PROD100 CONTFRAC"             | "" | "(CFLUX_PROD100[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                      | "Annual release from all 100 year wood product pools (LANDS)" | "PgC/yr" | "2"
+HARVEST_ABOVE_lands | "HARVEST_ABOVE CONTFRAC"             | "" | "(HARVEST_ABOVE[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                      | "Annual release product after harvest (LANDS)"                | "PgC/yr" | "2"
+SOIL_CARB_lands     | "TOTAL_SOIL_CARB VEGET_MAX CONTFRAC" | "" | "(TOTAL_SOIL_CARB[d=1]*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"     | "Total Soil Carbon (LANDS)"                                   | "PgC"    | "2"
+BIOMASS_lands       | "TOTAL_M VEGET_MAX CONTFRAC"         | "" | "(TOTAL_M[d=1]*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"             | "Total Biomass (LANDS)"                                       | "PgC"    | "2"
+LITTER_lands        | "TOTAL_BM_LITTER VEGET_MAX CONTFRAC" | "" | "(TOTAL_BM_LITTER[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)" | "Total Litter (LANDS)"                                        | "PgC/yr" | "2"
+CO2FLUX_lands       | "CO2FLUX VEGET_MAX CONTFRAC"         | "" | "(CO2FLUX[d=1]*12*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"          | "NEE (LANDS)"                                                 | "PgC/yr" | "2"
+CO2FLUX_MONTHLY_SUM_lands | "CO2FLUX_MONTHLY_SUM VEGET_MAX CONTFRAC" | "" | "(CO2FLUX_MONTHLY_SUM[d=1]*12)"                                 | "NEE Sum (LANDS)"                                             | "PgC/yr" | "Areas[d=1]"
+NPP_lands           | "NPP VEGET_MAX CONTFRAC"             | "" | "(NPP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"             | "Net Primary Produc (LANDS)"                                  | "PgC/yr" | "2"
+GPP_lands           | "GPP VEGET_MAX CONTFRAC"             | "" | "(GPP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"             | "Gross Primary Produc (LANDS)"                                | "PgC/yr" | "2"
+HET_RESP_lands      | "HET_RESP VEGET_MAX CONTFRAC"        | "" | "(HET_RESP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"        | "Heterotr. Resp. (LANDS)"                                     | "PgC/yr" | "2"
+MAINT_RESP_lands    | "MAINT_RESP VEGET_MAX CONTFRAC"      | "" | "(MAINT_RESP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"      | "Maintenance Resp. (LANDS)"                                   | "PgC/yr" | "2"
+GROWTH_RESP_lands   | "GROWTH_RESP VEGET_MAX CONTFRAC"     | "" | "(GROWTH_RESP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"     | "Growth Resp. (LANDS)"                                        | "PgC/yr" | "2"
+cVeg_lands             | "cVeg"             | "" | "(cVeg[d=1])"            | "Carbon in Vegetation"			    | "kg C m-2" | "Areas[d=1]"
+cLitter_lands          | "cLitter"          | "" | "(cLitter[d=1])" 	    | "Carbon in Litter Pool" 			    | "kg C m-2" | "Areas[d=1]"
+cSoil_lands            | "cSoil"            | "" | "(cSoil[d=1])" 	    | "Carbon in Soil Pool" 			    | "kg C m-2" | "Areas[d=1]"
+cProduct_lands         | "cProduct"         | "" | "(cProduct[d=1])" 	    | "Carbon in Products of Land Use Change" 	    | "kg C m-2" | "Areas[d=1]"
+lai_lands              | "lai"              | "" | "(lai[d=1])" 	    | "Leaf Area Fraction"   	     		    | "1"   	 | "Areas[d=1]"
+gpp_lands              | "gpp"              | "" | "(gpp[d=1])" 	    | "Gross Primary Production" 		    | "kg C m-2 s-1" | "Areas[d=1]"
+ra_lands               | "ra"               | "" | "(ra[d=1])" 		    | "Autotrophic Respiration"			    | "kg C m-2 s-1" | "Areas[d=1]"
+npp_lands              | "npp"              | "" | "(npp[d=1])" 	    | "Net Primary Production" 			    | "kg C m-2 s-1" | "Areas[d=1]"
+rh_lands               | "rh"               | "" | "(rh[d=1])" 		    | "Heterotrophic Respiration" 		    | "kg C m-2 s-1" | "Areas[d=1]"
+fFire_lands            | "fFire"            | "" | "(fFire[d=1])" 	    | "CO2 Emission from Fire" 			    | "kg C m-2 s-1" | "Areas[d=1]"
+fHarvest_lands         | "fHarvest"         | "" | "(fHarvest[d=1])" 	    | "CO2 Flux to Atmosphere from Crop Harvesting" | "kg C m-2 s-1" | "Areas[d=1]"
+fLuc_lands             | "fLuc"             | "" | "(fLuc[d=1])" 	    | "CO2 Flux to Atmosphere from Land Use Change" | "kg C m-2 s-1" | "Areas[d=1]"
+nbp_lands              | "nbp"              | "" | "(nbp[d=1])" 	    | "Net Biospheric Production"      	   	    | "kg C m-2 s-1" | "Areas[d=1]"
+fVegLitter_lands       | "fVegLitter"       | "" | "(fVegLitter[d=1])" 	    | "Total Carbon Flux from Vegetation to Litter" | "kg C m-2 s-1" | "Areas[d=1]"
+fLitterSoil_lands      | "fLitterSoil"      | "" | "(fLitterSoil[d=1])"     | "Total Carbon Flux from Litter to Soil" 	    | "kg C m-2 s-1" | "Areas[d=1]"
+cLeaf_lands            | "cLeaf"            | "" | "(cLeaf[d=1])" 	    | "Carbon in Leaves"      	       		    | "kg C m-2" | "Areas[d=1]"
+cWood_lands            | "cWood"            | "" | "(cWood[d=1])" 	    | "Carbon in Wood" 				    | "kg C m-2" | "Areas[d=1]"
+cRoot_lands            | "cRoot"            | "" | "(cRoot[d=1])" 	    | "Carbon in Roots" 			    | "kg C m-2" | "Areas[d=1]"
+cMisc_lands            | "cMisc"            | "" | "(cMisc[d=1])" 	    | "Carbon in Other Living Compartments" 	    | "kg C m-2" | "Areas[d=1]"
+cLitterAbove_lands     | "cLitterAbove"     | "" | "(cLitterAbove[d=1])"    | "Carbon in Above-Ground Litter" 		    | "kg C m-2" | "Areas[d=1]"
+cLitterBelow_lands     | "cLitterBelow"     | "" | "(cLitterBelow[d=1])"    | "Carbon in Below-Ground Litter" 		    | "kg C m-2" | "Areas[d=1]"
+cSoilFast_lands        | "cSoilFast"        | "" | "(cSoilFast[d=1])" 	    | "Carbon in Fast Soil Pool" 		    | "kg C m-2" | "Areas[d=1]"
+cSoilMedium_lands      | "cSoilMedium"      | "" | "(cSoilMedium[d=1])"     | "Carbon in Medium Soil Pool" 		    | "kg C m-2" | "Areas[d=1]"
+cSoilSlow_lands        | "cSoilSlow"        | "" | "(cSoilSlow[d=1])" 	    | "Carbon in Slow Soil Pool" 		    | "kg C m-2" | "Areas[d=1]"
+treeFracPrimDec_lands  | "treeFracPrimDec"  | "" | "(treeFracPrimDec[d=1])" | "Total Primary Deciduous Tree Cover Fraction" | "%"   	| "Areas[d=1]"
+treeFracPrimEver_lands | "treeFracPrimEver" | "" | "(treeFracPrimEver[d=1])"| "Total Primary Evergreen Tree Cover Fraction" | "%" 	| "Areas[d=1]"
+c3PftFrac_lands        | "c3PftFrac" 	    | "" | "(c3PftFrac[d=1])" 	    | "Total C3 PFT Cover Fraction" 	 	    | "%" 	| "Areas[d=1]"
+c4PftFrac_lands        | "c4PftFrac" 	    | "" | "(c4PftFrac[d=1])" 	    | "Total C4 PFT Cover Fraction" 		    | "%" 	| "Areas[d=1]"
+rGrowth_lands          | "rGrowth" 	    | "" | "(rGrowth[d=1])" 	    | "Growth Autotrophic Respiration" 		    | "kg C m-2 s-1" | "Areas[d=1]"
+rMaint_lands           | "rMaint" 	    | "" | "(rMaint[d=1])" 	    | "Maintenance Autotrophic Respiration" 	    | "kg C m-2 s-1" | "Areas[d=1]"
+nppLeaf_lands          | "nppLeaf" 	    | "" | "(nppLeaf[d=1])" 	    | "CO2 Flux from Atmosphere due to NPP Allocation to Leaf" | "kg C m-2 s-1" | "Areas[d=1]"
+nppWood_lands          | "nppWood" 	    | "" | "(nppWood[d=1])" 	    | "CO2 Flux from Atmosphere due to NPP Allocation to Wood" | "kg C m-2 s-1" | "Areas[d=1]"
+nppRoot_lands          | "nppRoot" 	    | "" | "(nppRoot[d=1])" 	    | "CO2 Flux from Atmosphere due to NPP Allocation to Root" | "kg C m-2 s-1" | "Areas[d=1]"
+nep_lands              | "nep" 		    | "" | "(nep[d=1])" 	    | "Net Carbon Mass Flux out of Atmophere due to Net Ecosystem Productivity." | "kg C m-2 s-1" | "Areas[d=1]"
+cMassVariation_lands     | "cMassVariation"     | "" | "(cMassVariation[d=1])"    | "Carbon Mass Variation"			    | "kg C m-2 s-1" | "Areas[d=1]"
+cBal_lands             | "cMassVariation nbp" | "" | "(cMassVariation[d=1,L=2:1000]-nbp[d=2,L=2:1000])" | "Total Carbon Balance"		    | "kg C m-2 s-1" | "Areas[d=1]"
+#------------------------------------------------------------------------------------------------------------------------------------------------------
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_stomate_DGVM.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_stomate_DGVM.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/POST/monitoring01_stomate_DGVM.cfg	(revision 405)
@@ -0,0 +1,117 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann@cea.fr
+# $Date: 2011-07-08 12:35:05 +0200 (ven. 08 juil. 2011) $
+# $Name$
+# $Revision: 310 $
+# History:
+# Modification:
+#**************************************************************
+
+##################################################################################################################
+#-----------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#-----------------------------------------------------------------------------------------------------------------
+#
+#   field = name of the field to monitore 
+#   files patterns = pattern of the files used to monitore the field (must be discriminant) 
+#   files additionnal = additionnal files accessible by $FER_DATA
+#   operations = operations to calculate the field 
+#   title = variable title
+#   units = variable units
+#   calcul of area = expression to use for the weight average
+#
+# Notes:
+#   - Comment lines begin by # character.
+#   - Separator between fields is | character.
+#   - Operations must use the ferret syntax, if several files are used precise with the syntax d=x to refer to the x dataset.
+#     They must be enclosed by parenthesis if more than one variable is used.
+#   - files patterns,files additionnal,operations,title,units must be enclosed with character ". 
+#     Use "" if empty.
+#   - Fields will be presented through an html page with thumbnails global, north, south, land, ocean.
+#     Use a field name with one of these pattern to display it under the corresponding thumbnail.
+#
+##################################################################################################################
+
+color=EEE8AA
+smooth=12
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+CONVFLUX_lands      | "CONVFLUX CONTFRAC"                  | "" | "(CONVFLUX[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                           | "Annual release right after deforestation (LANDS)"            | "PgC/yr" | "2"
+CFLUX_PROD10_lands  | "CFLUX_PROD10 CONTFRAC"              | "" | "(CFLUX_PROD10[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                       | "Annual release from all 10 year wood product pools (LANDS)"  | "PgC/yr" | "2"
+CFLUX_PROD100_lands | "CFLUX_PROD100 CONTFRAC"             | "" | "(CFLUX_PROD100[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                      | "Annual release from all 100 year wood product pools (LANDS)" | "PgC/yr" | "2"
+HARVEST_ABOVE_lands | "HARVEST_ABOVE CONTFRAC"             | "" | "(HARVEST_ABOVE[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                      | "Annual release product after harvest (LANDS)"                | "PgC/yr" | "2"
+SOIL_CARB_lands     | "TOTAL_SOIL_CARB VEGET_MAX CONTFRAC" | "" | "(TOTAL_SOIL_CARB[d=1]*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"     | "Total Soil Carbon (LANDS)"                                   | "PgC"    | "2"
+BIOMASS_lands       | "TOTAL_M VEGET_MAX CONTFRAC"         | "" | "(TOTAL_M[d=1]*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"             | "Total Biomass (LANDS)"                                       | "PgC"    | "2"
+LITTER_lands        | "TOTAL_BM_LITTER VEGET_MAX CONTFRAC" | "" | "(TOTAL_BM_LITTER[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)" | "Total Litter (LANDS)"                                        | "PgC/yr" | "2"
+CO2FLUX_lands       | "CO2FLUX VEGET_MAX CONTFRAC"         | "" | "(CO2FLUX[d=1]*12*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"          | "NEE (LANDS)"                                                 | "PgC/yr" | "2"
+CO2FLUX_MONTHLY_SUM_lands | "CO2FLUX_MONTHLY_SUM VEGET_MAX CONTFRAC" | "" | "(CO2FLUX_MONTHLY_SUM[d=1]*12)"                                 | "NEE Sum (LANDS)"                                             | "PgC/yr" | "Areas[d=1]"
+NPP_lands           | "NPP VEGET_MAX CONTFRAC"             | "" | "(NPP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"             | "Net Primary Produc (LANDS)"                                  | "PgC/yr" | "2"
+GPP_lands           | "GPP VEGET_MAX CONTFRAC"             | "" | "(GPP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"             | "Gross Primary Produc (LANDS)"                                | "PgC/yr" | "2"
+HET_RESP_lands      | "HET_RESP VEGET_MAX CONTFRAC"        | "" | "(HET_RESP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"        | "Heterotr. Resp. (LANDS)"                                     | "PgC/yr" | "2"
+MAINT_RESP_lands    | "MAINT_RESP VEGET_MAX CONTFRAC"      | "" | "(MAINT_RESP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"      | "Maintenance Resp. (LANDS)"                                   | "PgC/yr" | "2"
+GROWTH_RESP_lands   | "GROWTH_RESP VEGET_MAX CONTFRAC"     | "" | "(GROWTH_RESP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"     | "Growth Resp. (LANDS)"                                        | "PgC/yr" | "2"
+cVeg_lands             | "cVeg"             | "" | "(cVeg[d=1])"            | "Carbon in Vegetation"			    | "kg C m-2" | "Areas[d=1]"
+cLitter_lands          | "cLitter"          | "" | "(cLitter[d=1])" 	    | "Carbon in Litter Pool" 			    | "kg C m-2" | "Areas[d=1]"
+cSoil_lands            | "cSoil"            | "" | "(cSoil[d=1])" 	    | "Carbon in Soil Pool" 			    | "kg C m-2" | "Areas[d=1]"
+cProduct_lands         | "cProduct"         | "" | "(cProduct[d=1])" 	    | "Carbon in Products of Land Use Change" 	    | "kg C m-2" | "Areas[d=1]"
+lai_lands              | "lai"              | "" | "(lai[d=1])" 	    | "Leaf Area Fraction"   	     		    | "1"   	 | "Areas[d=1]"
+gpp_lands              | "gpp"              | "" | "(gpp[d=1])" 	    | "Gross Primary Production" 		    | "kg C m-2 s-1" | "Areas[d=1]"
+ra_lands               | "ra"               | "" | "(ra[d=1])" 		    | "Autotrophic Respiration"			    | "kg C m-2 s-1" | "Areas[d=1]"
+npp_lands              | "npp"              | "" | "(npp[d=1])" 	    | "Net Primary Production" 			    | "kg C m-2 s-1" | "Areas[d=1]"
+rh_lands               | "rh"               | "" | "(rh[d=1])" 		    | "Heterotrophic Respiration" 		    | "kg C m-2 s-1" | "Areas[d=1]"
+fFire_lands            | "fFire"            | "" | "(fFire[d=1])" 	    | "CO2 Emission from Fire" 			    | "kg C m-2 s-1" | "Areas[d=1]"
+fHarvest_lands         | "fHarvest"         | "" | "(fHarvest[d=1])" 	    | "CO2 Flux to Atmosphere from Crop Harvesting" | "kg C m-2 s-1" | "Areas[d=1]"
+fLuc_lands             | "fLuc"             | "" | "(fLuc[d=1])" 	    | "CO2 Flux to Atmosphere from Land Use Change" | "kg C m-2 s-1" | "Areas[d=1]"
+nbp_lands              | "nbp"              | "" | "(nbp[d=1])" 	    | "Net Biospheric Production"      	   	    | "kg C m-2 s-1" | "Areas[d=1]"
+fVegLitter_lands       | "fVegLitter"       | "" | "(fVegLitter[d=1])" 	    | "Total Carbon Flux from Vegetation to Litter" | "kg C m-2 s-1" | "Areas[d=1]"
+fLitterSoil_lands      | "fLitterSoil"      | "" | "(fLitterSoil[d=1])"     | "Total Carbon Flux from Litter to Soil" 	    | "kg C m-2 s-1" | "Areas[d=1]"
+cLeaf_lands            | "cLeaf"            | "" | "(cLeaf[d=1])" 	    | "Carbon in Leaves"      	       		    | "kg C m-2" | "Areas[d=1]"
+cWood_lands            | "cWood"            | "" | "(cWood[d=1])" 	    | "Carbon in Wood" 				    | "kg C m-2" | "Areas[d=1]"
+cRoot_lands            | "cRoot"            | "" | "(cRoot[d=1])" 	    | "Carbon in Roots" 			    | "kg C m-2" | "Areas[d=1]"
+cMisc_lands            | "cMisc"            | "" | "(cMisc[d=1])" 	    | "Carbon in Other Living Compartments" 	    | "kg C m-2" | "Areas[d=1]"
+cLitterAbove_lands     | "cLitterAbove"     | "" | "(cLitterAbove[d=1])"    | "Carbon in Above-Ground Litter" 		    | "kg C m-2" | "Areas[d=1]"
+cLitterBelow_lands     | "cLitterBelow"     | "" | "(cLitterBelow[d=1])"    | "Carbon in Below-Ground Litter" 		    | "kg C m-2" | "Areas[d=1]"
+cSoilFast_lands        | "cSoilFast"        | "" | "(cSoilFast[d=1])" 	    | "Carbon in Fast Soil Pool" 		    | "kg C m-2" | "Areas[d=1]"
+cSoilMedium_lands      | "cSoilMedium"      | "" | "(cSoilMedium[d=1])"     | "Carbon in Medium Soil Pool" 		    | "kg C m-2" | "Areas[d=1]"
+cSoilSlow_lands        | "cSoilSlow"        | "" | "(cSoilSlow[d=1])" 	    | "Carbon in Slow Soil Pool" 		    | "kg C m-2" | "Areas[d=1]"
+treeFracPrimDec_lands  | "treeFracPrimDec"  | "" | "(treeFracPrimDec[d=1])" | "Total Primary Deciduous Tree Cover Fraction" | "%"   	| "Areas[d=1]"
+treeFracPrimEver_lands | "treeFracPrimEver" | "" | "(treeFracPrimEver[d=1])"| "Total Primary Evergreen Tree Cover Fraction" | "%" 	| "Areas[d=1]"
+c3PftFrac_lands        | "c3PftFrac" 	    | "" | "(c3PftFrac[d=1])" 	    | "Total C3 PFT Cover Fraction" 	 	    | "%" 	| "Areas[d=1]"
+c4PftFrac_lands        | "c4PftFrac" 	    | "" | "(c4PftFrac[d=1])" 	    | "Total C4 PFT Cover Fraction" 		    | "%" 	| "Areas[d=1]"
+rGrowth_lands          | "rGrowth" 	    | "" | "(rGrowth[d=1])" 	    | "Growth Autotrophic Respiration" 		    | "kg C m-2 s-1" | "Areas[d=1]"
+rMaint_lands           | "rMaint" 	    | "" | "(rMaint[d=1])" 	    | "Maintenance Autotrophic Respiration" 	    | "kg C m-2 s-1" | "Areas[d=1]"
+nppLeaf_lands          | "nppLeaf" 	    | "" | "(nppLeaf[d=1])" 	    | "CO2 Flux from Atmosphere due to NPP Allocation to Leaf" | "kg C m-2 s-1" | "Areas[d=1]"
+nppWood_lands          | "nppWood" 	    | "" | "(nppWood[d=1])" 	    | "CO2 Flux from Atmosphere due to NPP Allocation to Wood" | "kg C m-2 s-1" | "Areas[d=1]"
+nppRoot_lands          | "nppRoot" 	    | "" | "(nppRoot[d=1])" 	    | "CO2 Flux from Atmosphere due to NPP Allocation to Root" | "kg C m-2 s-1" | "Areas[d=1]"
+nep_lands              | "nep" 		    | "" | "(nep[d=1])" 	    | "Net Carbon Mass Flux out of Atmophere due to Net Ecosystem Productivity." | "kg C m-2 s-1" | "Areas[d=1]"
+cMassVariation_lands     | "cMassVariation"     | "" | "(cMassVariation[d=1])"    | "Carbon Mass Variation"			    | "kg C m-2 s-1" | "Areas[d=1]"
+cBal_lands             | "cMassVariation nbp" | "" | "(cMassVariation[d=1,L=2:1000]-nbp[d=2,L=2:1000])" | "Total Carbon Balance"		    | "kg C m-2 s-1" | "Areas[d=1]"
+ADAPTATION01_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=1])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION02_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=2])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION03_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=3])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION04_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=4])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION05_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=5])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION06_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=6])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION07_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=7])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION08_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=8])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION09_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=9])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION10_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=10])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION11_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=11])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION12_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=12])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+ADAPTATION13_lands       | "ADAPTATION"       | "" | "(ADAPTATION[d=1,k=13])"      | "Adaptation to climate (DGVM)"                | "-" | "2"
+REGENERATION01_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=1])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION02_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=2])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION03_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=3])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION04_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=4])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION05_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=5])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION06_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=6])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION07_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=7])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION08_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=8])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION09_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=9])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION10_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=10])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION11_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=11])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION12_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=12])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+REGENERATION13_lands     | "REGENERATION"     | "" | "(REGENERATION[d=1,k=13])"    | "Probability from regenerative (DGVM)"        | "-" | "2"
+#------------------------------------------------------------------------------------------------------------------------------------------------------
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/config.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/config.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/config.card	(revision 405)
@@ -0,0 +1,129 @@
+#
+# This is config.card file for restart with an NEW libIGCM simulation tree.
+#
+#====================================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+#========================================================================
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=SECHSTOM
+LongName="Please, explain here what is this simulation for"
+TagName=OL2
+#============================
+#-- leap, noleap, 360d
+CalendarType=gregorian
+#-- Start and End of Job
+#-- "YYYY-MM-DD"
+DateBegin=1982-01-01
+DateEnd=1982-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength=1M
+#============================
+#-- PBS Class (required on brodie mono/multi)
+#JobClass=mono
+JobClass=multi
+#============================
+#-- Total Number of Processors (minimum is 2 for a coupled configuration)
+#JobNumProcTot=2
+JobNumProcTot=4
+#============================
+#-- Run Options : here for oasis coupling
+JobRunOptions='"-np "${NUM_PROC}" -max_np "${NUM_PROC}'
+#JobRunOptions='"-np "${NUM_PROC}'
+#============================
+PeriodNb=12
+
+#========================================================================
+#D-- ListOfComponents -
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+SRF= (sechiba, orchidee_1_9_5_1)
+SBG= (stomate, orchidee_1_9_5_1)
+OOL= (orchidee_ol, OOL_1_9_5_1)
+
+#========================================================================
+#D-- Executable -
+[Executable]
+Name=orchidee_ol
+#D- For each component, Real name of executable, Name of executable for oasis
+SRF= ("", "")
+SBG= ("", "")
+OOL= (orchidee_ol, orchidee_ol)
+
+#========================================================================
+#D-- Restarts -
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule=n
+#D- Last day of the experience used as restart
+RestartDate=1981-12-31
+#D- Define restart simulation name (=> JOB_OS)
+RestartJobName=CD1
+#D- Path Server Group Login (=> PSGL)
+RestartPath=${ARCHIVE}/IGCM_OUT/OL2
+# Attention login depend de la machine
+
+#========================================================================
+#D-- Post -
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=5Y
+#D- Optimization of rebuid
+RebuildFromArchive=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency=10Y
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency=10Y
+#D- Offset for seasonal average first start dates ; same unit as SeasonalFrequency
+#D- Usefull if you do not want to consider the first X simulation's years
+SeasonalFrequencyOffset= 0
+
+#========================================================================
+#D-- SRF - SECHIBA
+[SRF]
+WriteFrequency="1M HF"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=HISTO2_
+RestartPath=${ARCHIVE}/IGCM_OUT/OL2
+#-- Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
+#D-- SRF - STOMATE
+[SBG]
+WriteFrequency="1M"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=HISTO2_
+RestartPath=${ARCHIVE}/IGCM_OUT/OL2
+#-- Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
+#D-- OOL -
+[OOL]
+WriteFrequency="1M"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=2L18
+RestartPath=${ARCHIVE}/${LOGIN}/SORTIES_CPL_IPSL
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/config.card.OldName
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/config.card.OldName	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/OOL_SEC_STO/config.card.OldName	(revision 405)
@@ -0,0 +1,126 @@
+#
+# This is config.card file for restart with an NEW libIGCM simulation tree.
+#
+#====================================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+#========================================================================
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=SECHSTOM
+LongName=ORCHIDEE_OL_HEAD
+TagName=OL2
+#============================
+#-- leap, noleap, 360d
+CalendarType=gregorian
+#-- Start and End of Job
+#-- "YYYY-MM-DD"
+DateBegin=1982-01-01
+DateEnd=1982-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength=1M
+#============================
+#-- PBS Class (required on brodie mono/multi)
+#JobClass=mono
+JobClass=multi
+#============================
+#-- Total Number of Processors (minimum is 2 for a coupled configuration)
+#JobNumProcTot=2
+JobNumProcTot=4
+#============================
+#-- Run Options : here for oasis coupling
+JobRunOptions='"-np "${NUM_PROC}" -max_np "${NUM_PROC}'
+#JobRunOptions='"-np "${NUM_PROC}'
+#============================
+PeriodNb=12
+
+#========================================================================
+#D-- ListOfComponents -
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+SRF= (orchidee, orchidee_1_9_4)
+SBG= (stomate, orchidee_1_9_4)
+OOL= (orchidee_ol, OOL_1_9_4)
+
+#========================================================================
+#D-- Executable -
+[Executable]
+Name=orchidee_ol
+#D- For each component, Real name of executable, Name of executable for oasis
+SRF= ("", "")
+SBG= ("", "")
+OOL= (orchidee_ol, orchidee_ol)
+
+#========================================================================
+#D-- Restarts -
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule=n
+#D- Last day of the experience used as restart
+RestartDate=1981-12-31
+#D- Define restart simulation name (=> JOB_OS)
+RestartJobName=2L18           
+#D- Path Server Group Login (=> PSGL)
+RestartPath=${ARCHIVE}/${LOGIN}/SORTIES_CPL_IPSL
+# Attention login depend de la machine
+
+#========================================================================
+#D-- Post -
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=NONE
+#D- Optimization of rebuid
+RebuildFromArchive=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency=10Y
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency=10Y
+
+#========================================================================
+#D-- SRF - SECHIBA
+[SRF]
+WriteFrequency="1M"
+Restart=y
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=2L18
+RestartPath=${ARCHIVE}/${LOGIN}/SORTIES_CPL_IPSL
+#-- Old component name for restart (if empty, use new name)
+OldName="Srf"
+
+#========================================================================
+#D-- SRF - STOMATE
+[SBG]
+WriteFrequency="1M"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=HISTO2_
+RestartPath=${ARCHIVE}/IGCM_OUT/OL2
+#-- Old component name for restart (if empty, use new name)
+OldName=""
+
+#========================================================================
+#D-- OOL -
+[OOL]
+WriteFrequency="1M"
+Restart=y
+#-- Last day of the experience used as restart
+RestartDate=1982-01-01
+# Define restart simulation name
+RestartJobName=2L18
+RestartPath=${ARCHIVE}/${LOGIN}/SORTIES_CPL_IPSL
+# Old component name for restart (if empty, use new name)
+OldName="driver"
+
+#========================================================================
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/COMP/spinup.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/COMP/spinup.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/COMP/spinup.card	(revision 405)
@@ -0,0 +1,142 @@
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+#
+## DEBUG mode for SPINUP 
+#
+# This mode keep all SPINUP directory in ARCHIVE
+# If disable, all ARCHIVE is automaticly cleaned.
+# 
+DEBUG_SPIN=n
+# If you don't want to keep old spinup steps, but last one
+CONSERVE=y
+
+# If you want to use the same forcing file
+DRIVER_NORESTART=n
+# If you want use config.card PeriodLength for TIME_LENGTH
+DRIVER_TIMELENGTH=y
+
+#
+###-- STOMATE flag
+#
+ok_stomate=n
+
+#
+###-- CO2 flag
+#
+ok_co2=n
+
+#
+###-- LAI flag
+#
+lai_map=n
+
+#
+###-- fix vÃ©gÃ©tation flag
+#
+impose_veg=n
+
+#
+###-- historical vegetation maps
+#
+land_use=n
+
+#
+###-- ROUTING flag
+#
+ok_routing=n
+
+#
+###-- NEW HYDROL CWRR flag
+#
+ok_newhydrol=n
+
+#
+##-- Output Levels
+#
+sechiba_LEVEL=6
+stomate_LEVEL=7
+
+    # SPINUP configuration : 
+    # ----------------------
+# Initialisation for spin-up :
+# sechiba alone (!!! only if ok_stomate == n !!!)
+duree_nostomate=1
+# sechiba and stomate
+duree_inistomate=0
+# teststomate (only if duree_nostomate or duree_inistomate > 0)
+duree_offlineini=0
+
+# Loop configuration for spin-up :
+# The whole job is restarted n_iter times
+n_iter=10
+# orchidee with sechiba (and stomate if ok_stomate=y below)
+duree_sechiba=1
+# teststomate
+duree_stomate=1
+# forcesoil
+duree_carbonsol=1
+
+# Finalization for spin-up :
+# all orchidee
+duree_final=1
+# This last parameter must be non-zero.
+
+RESOL=360x180
+
+# For FLUXNET style jobs : we should erase LAND USE file ?
+# This flag will suppress all files in option ListNonDel of section BoundaryFiles in orchidee.card of Subjobs.
+BoundaryFilesListNonDel=n
+
+# Path for all skeleton SubJob scripts to SPINUP directory
+SubJobPath=${MODIPSL}/config/ORCHIDEE_OL
+
+[SubJobForcingFile]
+# Boundary Files for ORCHIDEE subjobs :
+List= (${R_BC}/OOL/${config_UserChoices_TagName}/NCC/ncc_for_${year}.nc, forcing_file.nc)
+#List= (${R_BC}/OOL/${config_UserChoices_TagName}/CRU/force${year}.nc, .)
+ListNonDel= ()
+
+[SubJobParams]
+# You can specify here any parameters to be modified in sechiba.def, stomate.def or driver.def for SpinUp Subjobs.
+# NEW : due to split of orchidee.def in component specific parameter files,
+#       you must add here a prefix for the specific parameter file.
+driver_DEBUG_INFO=n
+sechiba_LONGPRINT=n
+
+[SubJobPost]
+#
+##-- TimeSeries
+#
+sechiba_TimeSeriesVars2D=(nobiofrac, alb_nir, alb_vis, bqsb, evap, fluxlat, fluxsens, gqsb, netrad, qair, rain, runoff, snow, snownobio, snowf, subli, tair, temp_sol, tsol_max, tsol_min, drainage,mrsos, mrso, mrros, mrro, prveg, evspsblveg, evspsblsoi, tran, treeFrac, grassFrac, cropFrac, baresoilFrac, residualFrac)
+sechiba_TimeSeriesVars3D=(lai, maxvegetfrac, vegetfrac, CO2FLUX, ptn, nee)
+# ALMAOUTPUT
+#sechiba_TimeSeriesVars2D = (vegetfrac, maxvegetfrac, nobiofrac, SWnet, LWnet, Qh, Qle, Qg, Qf, DelSurfHeat, DelColdCont, Snowf, Rainf, Evap, \
+#                          Qs, Qsb, Qsm, DelSoilMoist, DelSWE, DelIntercept, AvgSurfT, RadT, Albedo, SWE, SoilMoist, SoilWet, SoilTemp, PotEvap, \
+#                          ECanop, TVeg, ESoil, RootMoist, SubSnow, ACond, SnowFrac, SAlbedo, SnowDepth, dis, GPP)
+stomate_TimeSeriesVars2D=(T2M_MONTH, CONTFRAC, RESOLUTION_X, RESOLUTION_Y, CONVFLUX, CFLUX_PROD10, CFLUX_PROD100,CO2FLUX_MONTHLY_SUM,HARVEST_ABOVE)
+stomate_TimeSeriesVars3D=(CO2FLUX,LAI,VEGET,VEGET_MAX,NPP,GPP,HET_RESP,MAINT_RESP,GROWTH_RESP,AGE,HEIGHT,TOTAL_M,TOTAL_BM_LITTER,TOTAL_SOIL_CARB,ADAPTATION,REGENERATION)
+
+# !!! DO NOT MODIFY spinup.card AFTER THIS LINE !!! 
+
+[InitialStateFiles]
+List=	
+
+[BoundaryFiles]
+List=	()
+ListNonDel= ()
+
+[ParametersFiles]
+List=	()
+
+[RestartFiles]
+# For SPINUP, we don't need a restart ! the we save the output.card 
+List=	(output_out.card,  output.card,  output_in.card) 
+
+[OutputText]
+List=   ()
+
+[OutputFiles]
+List=	
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/COMP/spinup.driver
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/COMP/spinup.driver	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/COMP/spinup.driver	(revision 405)
@@ -0,0 +1,1059 @@
+#!/bin/ksh
+
+#D- Driver du script pour SPINUP (off-line)
+
+function SECHIBA_sed
+{
+    IGCM_debug_PushStack "SECHIBA_sed"
+    
+    if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	    ${New_SUBMIT_DIR}/PARAM/sechiba.def > ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp
+    RET=$?
+	echo "SECHIBA_sed : ${1} ${2}"
+	\mv ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp ${New_SUBMIT_DIR}/PARAM/sechiba.def
+    fi
+
+    IGCM_debug_PopStack "SECHIBA_sed"
+    return $RET
+}
+
+function STOMATE_sed
+{
+    IGCM_debug_PushStack "STOMATE_sed"
+    
+    if [ -f ${New_SUBMIT_DIR}/PARAM/stomate.def ] ; then
+	sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	    ${New_SUBMIT_DIR}/PARAM/stomate.def > ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp
+	RET=$?
+	echo "STOMATE_sed : ${1} ${2}"
+	\mv ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp ${New_SUBMIT_DIR}/PARAM/stomate.def
+    fi
+
+    IGCM_debug_PopStack "STOMATE_sed"
+    return $RET
+}
+
+function DRIVER_sed
+{
+    IGCM_debug_PushStack "DRIVER_sed"
+    
+    if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then
+	sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	    ${New_SUBMIT_DIR}/PARAM/driver.def > ${New_SUBMIT_DIR}/PARAM/driver.def.tmp
+	RET=$?
+	echo "DRIVER_sed : ${1} ${2}"
+	\mv ${New_SUBMIT_DIR}/PARAM/driver.def.tmp ${New_SUBMIT_DIR}/PARAM/driver.def
+    fi
+
+    IGCM_debug_PopStack "DRIVER_sed"
+    return $RET
+}
+
+#-----------------------------------------------------------------
+function SPIN_Initialize
+{
+    IGCM_debug_PushStack "SPIN_Initialize"
+
+    # No parallelization for spinup job !
+    BATCH_NUM_PROC_TOT=""
+
+    RESOL=${spinup_UserChoices_RESOL}
+
+    # Copy initial output card for spinup job :
+    if [ ! -f ${SUBMIT_DIR}/output.card ] ; then
+	IGCM_sys_Cp ${SUBMIT_DIR}/output.card_init ${SUBMIT_DIR}/output.card
+	iter=0
+    else
+	IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/output.card Global
+	iter=${output_Global_Iteration}
+	IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/output.card PreviousStage
+	LastStageName=${output_Stage_LastStageName}
+	IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/output.card Stage
+	StageName=${output_Stage_StageName}
+    fi
+    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Path "${SUBMIT_DIR}"
+
+    # Compute DateEnd for ALL SPINUP
+    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+	ok_stom=1
+    else
+	ok_stom=0
+    fi
+
+# Compute Spinup dates
+    case ${config_UserChoices_PeriodLength} in
+    *Y|*y)
+	PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' "{print ${config_UserChoices_PeriodLength}}" )
+	;;
+    *) 
+	PeriodLengthInYears=1
+    esac
+
+# We must count only one PeriodLength (=${PeriodLengthInYears}) for each teststomate or forcesoil step.
+    This_SpinUp_Length_In_Years=$(( \
+	   ( ${spinup_UserChoices_duree_nostomate} * ( 1 - ${ok_stom} ) ) \
+ 	+ ( ${spinup_UserChoices_duree_inistomate} + ${PeriodLengthInYears} ) * ${ok_stom} \
+ 	+ ${spinup_UserChoices_n_iter} * ${spinup_UserChoices_duree_sechiba} \
+ 	+ ${spinup_UserChoices_n_iter} * ${ok_stom} * ( ${PeriodLengthInYears} + ${PeriodLengthInYears} ) \
+ 	+ ${spinup_UserChoices_duree_final} ))
+
+    IGCM_date_GetYearMonth ${DateBegin} year month   
+    if [ X"${config_UserChoices_CalendarType}" = X"360d" ] ; then
+    	This_SpinUp_DateEnd=$(( year + This_SpinUp_Length_In_Years - 1 ))1230
+    	This_SpinUp_HumanDateEnd=$(( year + This_SpinUp_Length_In_Years - 1 ))-12-30
+    else
+    	This_SpinUp_DateEnd=$(( year + This_SpinUp_Length_In_Years - 1 ))1231
+    	This_SpinUp_HumanDateEnd=$(( year + This_SpinUp_Length_In_Years - 1 ))-12-31
+    fi
+    IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices DateEnd ${This_SpinUp_HumanDateEnd}
+    echo "SPINUP NEW Job DateEnd : " ${This_SpinUp_HumanDateEnd}
+    (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${This_SpinUp_DateEnd} ${DateBegin} )  + 1 ))
+    
+    # Subjobs configuration : 
+    # -----------------------
+
+    # 1) SRF section of config.card
+# This section gives first restart file path and WriteFrequency.
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SRF
+    set +A config_SRF -- ${config_SRF[*]} > /dev/null 2>&1
+    typeset option
+    for option in ${config_SRF[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF ${option}
+    done
+
+    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+	IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SBG
+	set +A config_SBG -- ${config_SBG[*]} > /dev/null 2>&1
+	typeset option
+	for option in ${config_SBG[*]} ; do
+	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG ${option}
+	done
+    fi
+
+
+    # 2) Subjob parametrization : SubJobParams in spinup.card
+# This section give flags to put in sechiba.def, stomate.def or driver.def of Subjobs.
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/COMP/spinup.card SubJobParams
+    set +A spinup_SubJobParams -- ${spinup_SubJobParams[*]} > /dev/null 2>&1
+
+    eval first_option=${spinup_SubJobParams[0]} > /dev/null 2>&1
+    if [ X${first_option} != X"Error:" ] ; then
+	typeset option
+	for option in ${spinup_SubJobParams[*]} ; do
+	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobParams ${option}
+	done
+    fi
+
+    # 3) Post-treatment
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SubJobPost
+    typeset option
+    for option in ${config_SubJobPost[*]} ; do
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SubJobPost ${option}
+    done
+
+    # 4) Get the forcing file name (structure with variables inside) for this Spinup
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobForcingFile List
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobForcingFile ListNonDel
+
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobPost sechiba_TimeSeriesVars2D
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobPost sechiba_TimeSeriesVars3D
+    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+	IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobPost stomate_TimeSeriesVars2D
+	IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobPost stomate_TimeSeriesVars3D
+    fi
+    IGCM_debug_PopStack "SPIN_Initialize"
+}
+
+#-----------------------------------------------------------------
+function SPIN_Cp_Job
+{
+    IGCM_debug_PushStack "SPIN_Cp_Job"
+
+    typeset Path_Job_Ini New_Name
+
+    # Where to find the standard cards/drivers for this job
+    Path_Job_Ini=$1
+
+    # New Name for the Job :
+    New_Name=$2
+    # New Path for the job
+    New_SUBMIT_DIR=${SUBMIT_DIR}/${New_Name}
+
+    # Copy the standard sub-job in the ${SUBMIT_DIR} with the New_Name
+    IGCM_sys_Cp -Rp ${Path_Job_Ini} ${New_SUBMIT_DIR}
+
+    # Install this directory
+    # modifications on config.card
+    MyJobName=${config_UserChoices_JobName}
+    IGCM_card_DefineVariableFromOption ${New_SUBMIT_DIR}/config.card UserChoices JobName
+    OldJobName=${config_UserChoices_JobName}
+
+    SubJobName=${MyJobName}${New_Name}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobName ${SubJobName}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices TagName ${config_UserChoices_TagName}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobClass ${config_UserChoices_JobClass}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot}
+    sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card
+    IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card 
+
+    # keep the spinup JobName
+    config_UserChoices_JobName=${MyJobName}
+
+    # modifications on Job 
+    \rm ${New_SUBMIT_DIR}/Job_${OldJobName} 
+
+    sed -e "s/ ${MyJobName} / ${New_Name} /" \
+        -e "s/Script_Output_${MyJobName}.000001 /Script_Output_${New_Name}.000001 /" \
+	${SUBMIT_DIR}/Job_${MyJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}
+    chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName}
+
+    IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/sechiba.def ${New_SUBMIT_DIR}/PARAM/sechiba.def
+    IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/stomate.def ${New_SUBMIT_DIR}/PARAM/stomate.def
+    IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/driver.def ${New_SUBMIT_DIR}/PARAM/driver.def
+
+    eval first_option=${spinup_SubJobParams[0]} > /dev/null 2>&1
+    if [ X${first_option} != X"Error:" ] ; then
+	typeset option PARAM_FILE
+	for option in ${spinup_SubJobParams[*]} ; do
+	    PARAM_FILE=$( echo ${option} | awk -F_ '{print $1}' )
+	    echo "For parameter file ${PARAM_FILE}.def"
+	    option_=$( echo ${option} | sed -e "s/${PARAM_FILE}_//" )
+	    eval echo "${option_}="\${spinup_SubJobParams_${option}}
+	    case ${PARAM_FILE} in
+		sechiba)
+		    eval SECHIBA_sed ${option_} \${spinup_SubJobParams_${option}}
+		    ;;
+		stomate)
+		    eval STOMATE_sed ${option_} \${spinup_SubJobParams_${option}}
+		    ;;
+		driver)
+		    eval DRIVER_sed ${option_} \${spinup_SubJobParams_${option}}
+		    ;;
+	    esac
+	done
+    fi
+
+    if ( [ X${config_UserChoices_JobNumProcTot} != X ] && [ "${config_UserChoices_JobNumProcTot}" -gt 1 ] ) ; then
+	gawk -- "{if (! match(\$0,/^# .Date.*/) ) { print \$0 } else { printf(\"BATCH_NUM_PROC_TOT=%d \\n\\n\",${config_UserChoices_JobNumProcTot}) ; print \$0 } }" \
+ 	    ${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_
+	IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName}
+	chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName}
+    fi
+
+    IGCM_debug_PopStack "SPIN_Cp_Job"
+}
+
+function SPIN_prepare
+{
+    IGCM_debug_PushStack "SPIN_prepare"
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Restarts OverRule n
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card OOL Restart n
+
+    typeset option
+    for option in ${config_SubJobPost[*]} ; do
+	eval value=\${config_SubJobPost_${option}}
+	eval echo ${option} ${value}
+	if [ X${value} != X ] ; then
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post ${option} \${config_SubJobPost_${option}}
+	fi
+    done
+
+    # For Subjob special flags
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices ROUTING ${spinup_UserChoices_ok_routing}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices NEWHYDROL ${spinup_UserChoices_ok_newhydrol}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices LAIMAP ${spinup_UserChoices_lai_map}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices IMPOSE_VEG ${spinup_UserChoices_impose_veg}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices LAND_USE ${spinup_UserChoices_land_use}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices OKCO2 ${spinup_UserChoices_ok_co2}
+
+    if [ X${spinup_UserChoices_BoundaryFilesListNonDel} = Xy ] ; then 
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card BoundaryFiles ListNonDel "()"
+    fi
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card UserChoices NORESTART ${spinup_UserChoices_DRIVER_NORESTART}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card UserChoices TIMELENGTH ${spinup_UserChoices_DRIVER_TIMELENGTH}
+
+    spinup_SubJobForcingFile_List0=${spinup_SubJobForcingFile_List[0]} > /dev/null 2>&1
+    if [ X${spinup_SubJobForcingFile_List0} != X${NULL_STR} ] ; then
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card BoundaryFiles List "("$( echo ${spinup_SubJobForcingFile_List[@]} | sed -e "s/ /,/g" )")"
+    else
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card BoundaryFiles List "()"
+    fi
+
+    spinup_SubJobForcingFile_ListNonDel0=${spinup_SubJobForcingFile_ListNonDel[0]} > /dev/null 2>&1
+    if [ X${spinup_SubJobForcingFile_ListNonDel0} != X${NULL_STR} ] ; then
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card BoundaryFiles ListNonDel "("$( echo ${spinup_SubJobForcingFile_ListNonDel[@]} | sed -e "s/ /,/g" )")"
+    else
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card BoundaryFiles ListNonDel "()"
+    fi
+
+    IGCM_debug_PopStack "SPIN_prepare"
+}
+
+#-----------------------------------------------------------------
+function SPIN_OptionsSechiba
+{
+    IGCM_debug_PushStack "SPIN_OptionsSechiba"
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices sechiba_LEVEL ${spinup_UserChoices_sechiba_LEVEL}
+    spinup_SubJobPost_sechiba_TimeSeriesVars0=${spinup_SubJobPost_sechiba_TimeSeriesVars2D[0]}
+    if [ X${spinup_SubJobPost_sechiba_TimeSeriesVars0} != X${NULL_STR} ] ; then
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars2D "("$( echo ${spinup_SubJobPost_sechiba_TimeSeriesVars2D[@]} | sed -e "s/ /,/g" )")"
+    else
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars2D "()"
+    fi
+    spinup_SubJobPost_sechiba_TimeSeriesVars0=${spinup_SubJobPost_sechiba_TimeSeriesVars3D[0]}
+    if [ X${spinup_SubJobPost_sechiba_TimeSeriesVars0} != X${NULL_STR} ] ; then
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars3D "("$( echo ${spinup_SubJobPost_sechiba_TimeSeriesVars3D[@]} | sed -e "s/ /,/g" )")"
+    else
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars3D "()"
+    fi
+
+    IGCM_debug_PopStack "SPIN_OptionsSechiba"
+}
+
+#-----------------------------------------------------------------
+function SPIN_OptionsStomate
+{
+    IGCM_debug_PushStack "SPIN_OptionsStomate"
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card UserChoices stomate_LEVEL ${spinup_UserChoices_stomate_LEVEL}
+    spinup_SubJobPost_stomate_TimeSeriesVars0=${spinup_SubJobPost_stomate_TimeSeriesVars2D[0]} > /dev/null 2>&1
+    if [ X${spinup_SubJobPost_stomate_TimeSeriesVars0} != X${NULL_STR} ] ; then
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card Post_1M_stomate_history TimeSeriesVars2D "("$( echo ${spinup_SubJobPost_stomate_TimeSeriesVars2D[@]} | sed -e "s/ /,/g" )")"
+    else
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card Post_1M_stomate_history TimeSeriesVars3D "()"
+    fi
+    spinup_SubJobPost_stomate_TimeSeriesVars0=${spinup_SubJobPost_stomate_TimeSeriesVars3D[0]} > /dev/null 2>&1
+    if [ X${spinup_SubJobPost_stomate_TimeSeriesVars0} != X${NULL_STR} ] ; then
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card Post_1M_stomate_history TimeSeriesVars3D "("$( echo ${spinup_SubJobPost_stomate_TimeSeriesVars3D[@]} | sed -e "s/ /,/g" )")"
+    else
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card Post_1M_stomate_history TimeSeriesVars3D "()"
+    fi
+
+    # Nb years for forcing FORCESOIL
+    STOMATE_sed FORCESOIL_NB_YEAR ${PeriodLengthInYears}
+    STOMATE_sed FORCESOIL_STEP_PER_YEAR 365
+    # Force creation of stomate_forcing.nc and stomate_Cforcing files
+    STOMATE_sed STOMATE_FORCING_NAME stomate_forcing.nc
+    STOMATE_sed STOMATE_CFORCING_NAME stomate_Cforcing.nc
+    
+    IGCM_debug_PopStack "SPIN_OptionsStomate"
+}
+
+#-----------------------------------------------------------------
+function SPIN_PeriodStart
+{
+    IGCM_debug_PushStack "SPIN_PeriodStart"
+    echo "" > stack
+    IGCM_debug_PopStack "SPIN_PeriodStart"
+}
+
+#-----------------------------------------------------------------
+Update_SPIN_iter=false
+function SPIN_Update
+{
+    IGCM_debug_PushStack "SPIN_Update"
+
+    Update_SPIN_iter=false
+
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/output.card Global
+    SpinUpPath=${output_Global_Path}
+
+    # StageName is the internal name for the interation for spinup
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card Stage StageName
+    StageName=${output_Stage_StageName}
+
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastStageName 
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastExtName
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastRestartDate
+
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card Global Iteration
+    iter=${output_Global_Iteration}
+
+    config_SubJob_PeriodLength="${config_UserChoices_PeriodLength}"
+
+    # ExtName is the short JobName of this stage
+
+    if ( [ X${StageName} = X"start" ] ) ; then 
+	# We are in first step.
+	if ( ${FirstInitialize} ) ; then
+	    # What is the first step ?
+
+	    # First phase : Is there restarts (we would initialize ORCHIDEE) or not ?
+	    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card PreviousStage LastStageName "start"
+	    output_PreviousStage_LastStageName="start"
+	    if ( [ X"${config_SRF_Restart}" = "Xn" ] && [ X"${config_SBG_Restart}" = "Xn" ] ) ; then
+		if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		    if [ ${spinup_UserChoices_duree_inistomate} -gt 0 ] ; then
+		        # Perhaps we want to by-pass first SECHIBA-ONLY Stage and do a SECSTO Job first ?
+			StageName=SECSTOINI
+			ExtName=STOI
+		    else
+			echo "SPINUP no restart : !!!! Error !!!! "
+			echo         "ok_stomate = " ${spinup_UserChoices_ok_stomate}
+			echo         "duree_inistomate = " ${spinup_UserChoices_duree_inistomate}
+			echo "NO SPINUP possible !!"
+			exit 1
+		    fi
+		elif [ ${spinup_UserChoices_duree_nostomate} -gt 0 ] ; then
+			StageName=SECINI
+			ExtName=SECI
+		else
+		    echo "SPINUP : NO RESTART and NO INITIALIZATION !"
+		    echo "     We will launch the iteration loop directly."
+		    if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then
+			StageName=SECSTO
+			iter=1
+			ExtName=ORC_${iter}
+			Update_SPIN_iter=true
+		    else
+			echo "SPINUP : !!!! Error !!!! "
+			echo         "duree_sechiba = " ${spinup_UserChoices_duree_sechiba}
+			echo "NO SPINUP possible !!"
+			exit 1
+		    fi
+		fi
+	    else
+		echo "SPINUP : "
+		echo "     We will to launch the iteration loop WITH RESTARTS."
+		echo "     Global Restart path = " ${config_Restarts_RestartPath}
+		if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then
+		    StageName=SECSTO
+		    iter=1
+		    ExtName=ORC_${iter}
+		    Update_SPIN_iter=true
+		else
+		    echo "SPINUP : !!!! Error !!!! "
+		    echo "        duree_sechiba = " ${spinup_UserChoices_duree_sechiba}
+		    echo "NO SPINUP possible !!"
+		    exit 1
+		fi
+	    fi
+	    echo "(" start "," ${ExtName} ") \\" >> ${SUBMIT_DIR}/output.card
+
+	else
+	    echo "SPINUP : !!!! Error with output !!!! "
+	    echo "        duree_sechiba = " ${spinup_UserChoices_duree_sechiba}
+	    echo "NO SPINUP possible !!"
+	    exit 1
+	fi
+
+    else
+	# We are not in first step.
+
+	# WHAT IS THE NEXT STEP ?
+	case ${output_PreviousStage_LastStageName} in
+	    "SECINI")
+		echo "     We begin the iteration loop !!"
+		if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then
+		    StageName=SECSTO
+		    iter=1
+		    ExtName=ORC_${iter}
+		    Update_SPIN_iter=true
+		else
+		    echo "SPINUP : !!!! Error !!!! "
+		    echo         "duree_sechiba = " ${spinup_UserChoices_duree_sechiba}
+		    echo "NO SPINUP possible !!"
+		    exit 1
+		fi
+		;;
+	    "SECSTOINI")
+		if [ ${spinup_UserChoices_duree_offlineini} -gt 0 ] ; then
+		    StageName=TSTOINI
+		    ExtName=TSTOI
+		else
+		    echo "     We begin the iteration loop !!"
+		    if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then
+			StageName=SECSTO
+			iter=1
+			ExtName=ORC_${iter}
+			Update_SPIN_iter=true
+		    else
+			echo "SPINUP : !!!! Error !!!! "
+			echo         "duree_sechiba = " ${spinup_UserChoices_duree_sechiba}
+			echo "NO SPINUP possible !!"
+			exit 1
+		    fi
+		fi
+		;;
+	    "TSTOINI")
+		echo "     We begin the iteration loop !!"
+		if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then
+		    echo "     We begin the iteration loop !!"
+		    StageName=SECSTO
+		    iter=1
+		    ExtName=ORC_${iter}
+		    Update_SPIN_iter=true
+		else
+		    echo "SPINUP : !!!! Error !!!! "
+		    echo         "duree_sechiba = " ${spinup_UserChoices_duree_sechiba}
+		    echo "NO SPINUP possible !!"
+		    exit 1
+		fi
+		;;
+	    "SECSTO")
+ 		
+		if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		    if [ ${spinup_UserChoices_duree_stomate} -gt 0 ] ; then
+			StageName=TSTO
+			ExtName=TST_${iter}
+		    elif [ ${spinup_UserChoices_duree_carbonsol} -gt 0 ] ; then
+			StageName=FORC
+			ExtName=FOR_${iter}
+		    elif [ ${iter} -eq ${spinup_UserChoices_n_iter} ] ; then
+			echo "Ending loop Job"
+			StageName=SECSTOF 
+			ExtName=FIN
+			IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration END
+		    else
+			StageName=SECSTO
+			(( iter=iter+1 ))
+			ExtName=ORC_${iter}
+			Update_SPIN_iter=true
+		    fi
+		elif [ ${iter} -eq ${spinup_UserChoices_n_iter} ] ; then
+		    echo "Ending loop Job"
+		    StageName=SECSTOF 
+		    ExtName=FIN
+		    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration END
+		else
+		    StageName=SECSTO
+		    (( iter=iter+1 ))
+		    ExtName=ORC_${iter}
+		    Update_SPIN_iter=true
+		fi
+		;;
+	    "TSTO") 
+		if [ ${spinup_UserChoices_duree_carbonsol} -gt 0 ] ; then
+		    StageName=FORC
+		    ExtName=FOR_${iter}
+		elif [ ${iter} -eq ${spinup_UserChoices_n_iter} ] ; then
+		    echo "Ending loop Job"
+		    StageName=SECSTOF 
+		    ExtName=FIN
+		    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration END
+		else
+		    StageName=SECSTO
+		    (( iter=iter+1 ))
+		    ExtName=ORC_${iter}
+		    Update_SPIN_iter=true
+		fi
+		;;
+	    "FORC") 
+		if [ ${iter} -eq ${spinup_UserChoices_n_iter} ] || [ X${iter} = XEND ] ; then
+		    echo "Ending loop Job"
+		    StageName=SECSTOF 
+		    ExtName=FIN
+		    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration END
+		else
+		    StageName=SECSTO
+		    (( iter=iter+1 ))
+		    ExtName=ORC_${iter}
+		    Update_SPIN_iter=true
+		fi
+		;;
+	    "SECSTOF") 
+		echo "Begin Historical Job"
+		StageName=HISTO 
+		ExtName=HIST
+		IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration HIST
+		;;
+
+	    "HISTO")
+		echo "SPINUP : We have done the SPINUP !! "
+		echo "The job will be closed."
+		;;
+	esac
+    fi
+
+    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Stage StageName ${StageName}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Stage ExtName ${ExtName}
+
+    # BEGIN THE NEW STEP : 
+    LastJobName=${config_UserChoices_JobName}${output_PreviousStage_LastExtName}
+
+    # Copy and modifications of the standard card set
+    case $StageName in
+	"SECINI")
+
+	    # SECHIBA only initialisation step
+	    This_Job_Length_In_Years=${spinup_UserChoices_duree_nostomate}
+
+	    # Copy the standard card set 
+	    # !!! must not have been modified !!!
+	    SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC ${ExtName}
+
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart n
+    
+            SPIN_prepare
+
+	    SPIN_OptionsSechiba
+
+	    ;;
+	"SECSTOINI")
+
+	    # SECHIBA+STOMATE initialisation step
+	    This_Job_Length_In_Years=${spinup_UserChoices_duree_inistomate}
+
+	    # Copy the standard card set 
+	    # !!! must not have been modified !!!
+	    SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC_STO ${ExtName}
+
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart n
+	    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+    		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart n
+	    fi
+    
+	    SPIN_prepare
+
+	    SPIN_OptionsSechiba
+	    SPIN_OptionsStomate
+
+	    ;;
+
+	"TSTOINI")
+
+	    # TESTSTOMATE initialisation step
+	    This_Job_Length_In_Years=${spinup_UserChoices_duree_offlineini}
+	    
+	    # TESTSTOMATE will run in one execution only
+	    config_SubJob_PeriodLength="${This_Job_Length_In_Years}Y"
+
+	    # Copy the standard card set 
+	    # !!! must not have been modified !!!
+	    SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/TESTSTOMATE ${ExtName}
+
+	    # Always restart for teststomate
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Restarts OverRule n
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${output_PreviousStage_LastRestartDate}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${output_PreviousStage_LastRestartDate}
+
+            # Define restart simulation name
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName}
+	    config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath}
+	    
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName}
+	    config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath}
+	    
+	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastRestartDate
+
+	    # We Get the forcing file from the previous run of ORCHIDEE
+	    sed -e "s&(\${config_SBG_RestartPath}/\${config_SBG_RestartJobName}/SBG/Restart/\${config_SBG_RestartJobName}_\${Date_Restarts}_stomate_forcing.nc, stomate_forcing.nc)&(${config_SBG_RestartPath}/${LastJobName}/SBG/Restart/${LastJobName}_${output_PreviousStage_LastRestartDate}_stomate_forcing.nc, stomate_forcing.nc)&" ${New_SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+	    IGCM_sys_Mv sechiba.card.tmp ${New_SUBMIT_DIR}/COMP/sechiba.card
+
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices IMPOSE_VEG ${spinup_UserChoices_impose_veg}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices LAND_USE ${spinup_UserChoices_land_use}
+
+	    typeset option
+	    for option in ${config_SubJobPost[*]} ; do
+		eval value=\${config_SubJobPost_${option}}
+		eval echo ${option} ${value}
+		if [ X${value} != X ] ; then
+		    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post ${option} \${config_SubJobPost_${option}}
+		fi
+	    done
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post RebuildFrequency ${config_SubJob_PeriodLength}
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post TimeSeriesFrequency ${config_SubJob_PeriodLength}
+
+	    SPIN_OptionsStomate
+
+	    ;;
+	"SECSTO")
+
+	    # loop step
+
+	    This_Job_Length_In_Years=${spinup_UserChoices_duree_sechiba}
+
+	    # Copy the standard card set 
+	    # !!! must not have been modified !!!
+	    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC_STO ${ExtName}
+	    else
+		SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC ${ExtName}
+	    fi
+
+	    SPIN_prepare
+
+	    if [ X${output_PreviousStage_LastStageName} != X"start" ] ; then
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${output_PreviousStage_LastRestartDate}
+                # Define restart simulation name
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName}
+		config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath}
+
+		if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y
+		    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${output_PreviousStage_LastRestartDate}
+                    # Define restart simulation name
+		    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName}
+		    config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+		    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath}
+		fi
+	    else
+		# If we begin directly with the loop.
+		IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF Restart
+		IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF RestartDate
+		IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF RestartJobName
+		IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF RestartPath
+		IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF OldName
+		echo "Run in iteration loop with restarts : "
+		echo ${config_SRF_Restart}, ${config_SRF_RestartDate}, ${config_SRF_RestartJobName}, ${config_SRF_RestartPath}, ${config_SRF_OldName}
+
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart ${config_SRF_Restart}
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${config_SRF_RestartDate}
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${config_SRF_RestartJobName}
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath}
+		if [ X${config_SRF_OldName} != X"" ] ; then
+			IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF OldName ${config_SRF_OldName}
+		fi
+		if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+			IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG Restart
+			IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG RestartDate
+			IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG RestartJobName
+			IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG RestartPath
+			IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG OldName
+			echo "Run in iteration loop with STOMATE restarts : "
+			echo ${config_SBG_Restart}, ${config_SBG_RestartDate}, ${config_SBG_RestartJobName}, ${config_SBG_RestartPath}, ${config_SBG_OldName}
+
+			IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart ${config_SBG_Restart}
+			IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${config_SBG_RestartDate}
+			IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${config_SBG_RestartJobName}
+			IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath}
+			if [ X${config_SBG_OldName} != X"" ] ; then
+			    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG OldName ${config_SBG_OldName}
+			fi
+		fi
+	    fi
+
+	    SPIN_OptionsSechiba
+	    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		SPIN_OptionsStomate
+	    fi
+
+	    ;;
+	"TSTO") 
+
+	    # TESTSTOMATE loop step
+	    This_Job_Length_In_Years=${spinup_UserChoices_duree_stomate}
+	    
+	    # One execution only
+	    config_SubJob_PeriodLength="${This_Job_Length_In_Years}Y"
+
+	    # Copy the standard card set 
+	    # !!! must not have been modified !!!
+	    SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/TESTSTOMATE ${ExtName}
+
+	    # Always restart for teststomate
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Restarts OverRule n
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${output_PreviousStage_LastRestartDate}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${output_PreviousStage_LastRestartDate}
+
+            # Define restart simulation name
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName}
+	    config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath}
+
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName}
+	    config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath}
+
+	    # We Get the forcing file from the previous run of ORCHIDEE
+	    sed -e "s&(\${config_SBG_RestartPath}/\${config_SBG_RestartJobName}/SBG/Restart/\${config_SBG_RestartJobName}_\${Date_Restarts}_stomate_forcing.nc, stomate_forcing.nc)&(${config_SBG_RestartPath}/${LastJobName}/SBG/Restart/${LastJobName}_${output_PreviousStage_LastRestartDate}_stomate_forcing.nc, stomate_forcing.nc)&" ${New_SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+	    IGCM_sys_Mv sechiba.card.tmp ${New_SUBMIT_DIR}/COMP/sechiba.card
+
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices IMPOSE_VEG ${spinup_UserChoices_impose_veg}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices LAND_USE ${spinup_UserChoices_land_use}
+
+	    typeset option
+	    for option in ${config_SubJobPost[*]} ; do
+		eval value=\${config_SubJobPost_${option}}
+		eval echo ${option} ${value}
+		if [ X${value} != X ] ; then
+		    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post ${option} \${config_SubJobPost_${option}}
+		fi
+	    done
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post RebuildFrequency ${config_SubJob_PeriodLength}
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post TimeSeriesFrequency ${config_SubJob_PeriodLength}
+
+	    SPIN_OptionsStomate
+
+	    ;;
+	"FORC") 
+	    # FORCESOIL loop step
+	    This_Job_Length_In_Years=${spinup_UserChoices_duree_carbonsol}
+	    
+	    # One execution only
+	    config_SubJob_PeriodLength="${This_Job_Length_In_Years}Y"
+
+	    # Copy the standard card set 
+	    # !!! must not have been modified !!!
+	    SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/FORCESOIL ${ExtName}
+
+	    # Always restart for forcesoil
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Restarts OverRule n
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${output_PreviousStage_LastRestartDate}
+
+            # Define restart simulation name
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName}
+	    config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+	    config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath}
+
+	    # We Get the forcing file from the previous run of ORCHIDEE
+	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastRestartDate
+
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card BoundaryFiles ListNonDel \
+                    "(${config_SBG_RestartPath}/${LastJobName}/SBG/Restart/${LastJobName}_${output_PreviousStage_LastRestartDate}_stomate_Cforcing.nc, stomate_Cforcing.nc), \\"
+
+	    # Nb years for forcing FORCESOIL
+	    STOMATE_sed FORCESOIL_NB_YEAR ${PeriodLengthInYears}
+	    STOMATE_sed FORCESOIL_STEP_PER_YEAR 365
+
+	    ;;
+	"SECSTOF") 
+
+	    # END step
+
+	    This_Job_Length_In_Years=${spinup_UserChoices_duree_final}
+
+	    # Copy the standard card set 
+	    # !!! must not have been modified !!!
+	    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC_STO ${ExtName}
+	    else
+		SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC ${ExtName}
+	    fi
+
+	    SPIN_prepare
+
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${output_PreviousStage_LastRestartDate}
+            # Define restart simulation name
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName}
+	    config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath}
+	    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${output_PreviousStage_LastRestartDate}
+                # Define restart simulation name
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName}
+		config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath}
+	    fi
+
+	    SPIN_OptionsSechiba
+	    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		SPIN_OptionsStomate
+	    fi
+
+	    ;;
+
+	"HISTO") 
+
+	    # Historical step
+
+	    case ${config_SubJob_PeriodLength} in
+		*Y|*y)
+    		    This_Job_Length_In_Years=$( echo ${1} | awk -F '[yY]' "{print ${config_SubJob_PeriodLength}}" )
+    		    ;;
+		*M|*m)
+    		    This_Job_Length_In_Years=1
+    		    ;;
+		*)
+    		    echo "SPINUP : Impossible"
+    		    echo "     We have a PeriodLength less than 1M : " ${config_SubJob_PeriodLength}
+    		    echo "     We can't do the spinup with such a frequency !"
+    		    exit 1
+    		    ;;
+	    esac
+
+	    # Copy the standard card set 
+	    # !!! must not have been modified !!!
+	    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC_STO ${ExtName}
+	    else
+		SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC ${ExtName}
+	    fi
+
+	    SPIN_prepare
+
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${output_PreviousStage_LastRestartDate}
+            # Define restart simulation name
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName}
+	    config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath}
+	    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${output_PreviousStage_LastRestartDate}
+                # Define restart simulation name
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName}
+		config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName}
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath}
+	    fi
+
+	    SPIN_OptionsSechiba
+	    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+		SPIN_OptionsStomate
+	    fi
+
+	    ;;
+	*)
+	    echo "Erreur !! StageName not found."
+	    exit 1
+    esac
+
+
+    # For all Subjobs  
+    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Stage StageName ${StageName}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Stage ExtName ${ExtName}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices CalendarType ${config_UserChoices_CalendarType}
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateBegin ${config_UserChoices_DateBegin}
+
+    # Compute DateEnd for SECHIBA initialisation step
+    IGCM_date_GetYearMonth ${DateBegin} year month
+    if [ X"${config_UserChoices_CalendarType}" = X"360d" ] ; then
+    	This_Job_DateEnd=$( IGCM_date_YearDigit $(( year + This_Job_Length_In_Years - 1 )) )1230
+    	This_Job_HumanDateEnd=$( IGCM_date_YearDigit $(( year + This_Job_Length_In_Years - 1 )) )-12-30
+    else
+    	This_Job_DateEnd=$( IGCM_date_YearDigit $(( year + This_Job_Length_In_Years - 1 )) )1231
+    	This_Job_HumanDateEnd=$( IGCM_date_YearDigit $(( year + This_Job_Length_In_Years - 1 )) )-12-31
+    fi
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateEnd ${This_Job_HumanDateEnd}
+
+
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodLength ${config_SubJob_PeriodLength}
+    # Compute Subjob number of Periods
+    case ${config_SubJob_PeriodLength} in
+    *Y|*y)
+    	PeriodNbSubJob=$(( This_Job_Length_In_Years / $( echo ${1} | awk -F '[yY]' "{print ${config_SubJob_PeriodLength}}" ) ))
+    	;;
+    *M|*m)
+    	PeriodNbSubJob=$(( 12 * This_Job_Length_In_Years / $( echo ${1} | awk -F '[mM]' "{print ${config_SubJob_PeriodLength}}" ) ))
+    	;;
+    *)
+    	echo "SPINUP : Impossible"
+    	echo "     We have a PeriodLength less than 1M : " ${config_SubJob_PeriodLength}
+    	echo "     We can't do the spinup with such a frequency !"
+    	exit 1
+    	;;
+    esac
+    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodNb ${PeriodNbSubJob}
+
+    echo "SECHIBA WriteFrequency : " ${config_SRF_WriteFrequency}
+    if ( [ X${StageName} != X"TSTOINI" ] && [ X${StageName} != X"TSTO" ] && [ X${StageName} != X"FORC" ] ) ; then
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF WriteFrequency "${config_SRF_WriteFrequency}"
+    fi
+    if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
+	echo "STOMATE WriteFrequency : " ${config_SBG_WriteFrequency}
+	case $StageName in
+	    "TSTOINI"|"TSTO")
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG WriteFrequency "1Y"
+		;;
+	    *)
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG WriteFrequency "${config_SBG_WriteFrequency}"
+	esac
+    fi
+
+    echo "#!/bin/ksh" > ${RUN_DIR}/SubJob$$.ksh
+    echo "cd ${New_SUBMIT_DIR}" >> ${RUN_DIR}/SubJob$$.ksh
+    echo "export SUBMIT_DIR=${New_SUBMIT_DIR}" >> ${RUN_DIR}/SubJob$$.ksh
+    echo "./Job_${SubJobName} > ${New_SUBMIT_DIR}/Script_Output_${SubJobName}.000001 </dev/null 2>&1" >> ${RUN_DIR}/SubJob$$.ksh
+    echo "echo 'End of Subjob : ' \$( date )" >> ${RUN_DIR}/SubJob$$.ksh
+    echo "echo 'finish.'" >> ${RUN_DIR}/SubJob$$.ksh
+
+    chmod u+x ${RUN_DIR}/SubJob$$.ksh
+
+    # force run with nohup
+    BATCH_NUM_PROC_TOT=1
+    MPIRUN_COMMAND="time nohup"
+    config_Executable_Name=SubJob$$.ksh
+
+    IGCM_debug_PopStack "SPIN_Update"
+}
+
+#-----------------------------------------------------------------
+function SPIN_Finalize
+{
+    IGCM_debug_PushStack "SPIN_Finalize"
+
+    \rm ${RUN_DIR}/SubJob$$.ksh
+
+    echo "Return to Master SPINUP job : " $( date )
+
+    # Does the SubJob began ?
+    if [ -f ${New_SUBMIT_DIR}/run.card ] ; then
+	IGCM_card_DefineVariableFromOption ${New_SUBMIT_DIR}/run.card Configuration PeriodState
+    else
+	run_Configuration_PeriodState="Fatal"
+    fi
+
+# ATTENTION : avec ce test "!= Completed", on impose que chaque sous-job est contenu dans une seule itération PBS
+# On pourrait améliorer ce point pour tenir compte d'un sous-job long... 
+# Mais il faudrait faire ce test au début de la fonction update 
+# pour déterminer si on doit reprendre un job non terminer ou démarrer le suivant.
+    # Did it finish ?
+    if [ X${run_Configuration_PeriodState} != X"Completed" ] ; then
+	IGCM_debug_Exit "SPIN_update Error Run SubJob : " ${SubJobName} ${run_Configuration_PeriodState}
+    fi
+    IGCM_debug_Verif_Exit
+    
+    # Save the Stage in output.card
+    if ( ${Update_SPIN_iter} ) ; then
+	IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration ${iter}
+    fi
+
+    echo "(" ${StageName} "," ${ExtName} ") \\" >> ${SUBMIT_DIR}/output.card
+    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card PreviousStage LastStageName ${StageName}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card PreviousStage LastExtName ${ExtName}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/output.card PreviousStage LastRestartDate ${This_Job_DateEnd}
+
+
+    # For forcesoil, we have to copy the sechiba restart of last Stage
+    if [ X${StageName} = X"FORC" ] ; then
+        # This must be done on the ARCHIVE HOST.
+	IGCM_sys_MkdirArchive ${config_SBG_RestartPath}/${SubJobName}/SRF/Restart
+	IGCM_sys_RshArchive \
+	    "cp -fp ${config_SBG_RestartPath}/${LastJobName}/SRF/Restart/${LastJobName}_${output_PreviousStage_LastRestartDate}_sechiba_rest.nc"\
+                  " ${config_SBG_RestartPath}/${SubJobName}/SRF/Restart/${SubJobName}_${This_Job_DateEnd}_sechiba_rest.nc"
+    fi
+
+    # For SPINUP, we don't need a restart ! Then we save the output.card 
+    IGCM_sys_Cp ${SUBMIT_DIR}/output.card output_out.card
+    FileToBeDeleted[${#FileToBeDeleted[@]}]=output_out.card
+
+
+# If NOT DEBUG mode : 
+# we can move Previous Job in SPINUP save DIR.
+    if ( [ X${spinup_UserChoices_DEBUG_SPIN} = Xn ] && [ X${output_PreviousStage_LastStageName} != Xstart ] ) ; then
+	if ( [ X${spinup_UserChoices_CONSERVE} = Xn ] \
+	  && [ X${output_PreviousStage_LastStageName} != XSECINI ] \
+          && [ X${output_PreviousStage_LastStageName} != XSECSTOINI ] ) ; then
+	    IGCM_sys_RshArchive "rm -Rf ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}${output_PreviousStage_LastExtName}/*/Analyse/*"
+	    IGCM_sys_RshArchive "rm -Rf ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}${output_PreviousStage_LastExtName}/*/Output/*"
+	fi
+
+	IGCM_sys_RshArchive "mv -f ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}${output_PreviousStage_LastExtName}"\
+                                 " ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/SPIN/Output/"
+    fi
+
+#   Test the end of the SPINUP !
+    if [ X${StageName} = X"HISTO" ] ; then
+	DateEnd=${PeriodDateEnd}
+	(( SimulationLengthInDays=ExperienceLengthInDays + 1 ))
+	echo "SPINUP : END Job !!!"
+    fi
+
+    IGCM_debug_PopStack "SPIN_Finalize"
+}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/PARAM/driver.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/PARAM/driver.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/PARAM/driver.def	(revision 405)
@@ -0,0 +1,298 @@
+#
+#**************************************************************************
+#                    Namelist for ORCHIDEE_OL
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of DRIVER
+#**************************************************************************
+
+# Flag for debug information
+# This option allows to switch on the output of debug
+#         information without recompiling the code.
+DEBUG_INFO = n
+#default = n
+
+
+#---------------------------------------------------------------------
+# Forcing file name
+# Name of file containing the forcing data
+# This is the name of the file which should be opened
+# for reading the forcing data of the dim0 model.
+# The format of the file has to be netCDF and COADS
+# compliant. Cabauw.nc, islscp_for.nc, WG_cru.nc
+FORCING_FILE = forcing_file.nc
+# default = islscp_for.nc
+
+# split time step :
+#---------------------------------------------------------------------
+
+# Splits the timestep imposed by the forcing
+# With this value the time step of the forcing
+#  will be devided. In principle this can be run
+#  in explicit mode but it is strongly suggested
+#  to use the implicit method so that the
+#  atmospheric forcing has a smooth evolution.
+SPLIT_DT = 12
+# default = 12
+
+#  Time in the forcing file at which the model is started.
+#  This time give the point in time at which the model
+#  should be started. 
+#  If exists, the date of the restart file is use.
+#  The FORMAT of this date can be either of the following :
+#  n   : time step n within the forcing file
+#  nS  : n seconds after the first time-step in the file
+#  nD  : n days after the first time-step
+#  nM  : n month after the first time-step (year of 365 days)
+#  nY  : n years after the first time-step (year of 365 days)
+#      Or combinations :
+#  nYmM: n years and m month
+TIME_SKIP = 0
+# default = 0
+
+# Spread the precipitation.
+# Spread the precipitaiton over n steps of the splited forcing time step. 
+#  This is ONLY applied if the forcing time step has been splited (SPLIT_DT).
+#  If the value indicated is greater than SPLIT_DT, SPLIT_DT is used for it.
+SPRED_PREC = 1
+# default = 1
+
+
+
+
+
+# Input and output restart file for the driver
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by the driver
+# This variable give the  name for
+#  the restart file. The restart software within
+#  IOIPSL will add .nc if needed
+RESTART_FILEOUT = driver_rest_out.nc
+# default = driver_rest_out.nc
+
+
+#**************************************************************************
+#                             Area location
+#**************************************************************************
+#  The model will use the smalest regions from
+#  region specified here and the one of the forcing file.
+
+# Western limit of region
+# Western limit of the region we are 
+#  interested in. Between -180 and +180 degrees
+LIMIT_WEST = -180.
+# default = -180.
+
+# Eastern limit of region
+# Eastern limit of the region we are
+#  interested in. Between -180 and +180 degrees
+LIMIT_EAST = 180.
+# default = 180.
+
+# Northern limit of region
+# Northern limit of the region we are
+#  interested in. Between +90 and -90 degrees
+LIMIT_NORTH = 90.
+# default = 90.
+
+# Southern limit of region
+# Southern limit of the region we are
+#  interested in. Between 90 and -90 degrees
+LIMIT_SOUTH = -90.
+# default = -90.
+
+##**************************************************************************
+#                       Simulation parameters
+#**************************************************************************
+
+# method of forcing
+# A method is proposed by which the first atmospheric
+#   level is not directly forced by observations but
+#   relaxed with a time constant towards observations.
+#   For the moment the methods tends to smooth too much
+#   the diurnal cycle and introduces a time shift.
+#   A more sophisticated method is needed.
+RELAXATION = n
+# default = n
+
+# Time constant of the relaxation layer RELAXATION
+# The time constant associated to the atmospheric
+#  conditions which are going to be computed
+#  in the relaxed layer. To avoid too much
+#  damping the value should be larger than 1000.
+RELAX_A = 1000.
+# default = 1000.0
+
+# Height at which T and Q are given
+# The atmospheric variables (temperature and specific
+#  humidity) are measured at a specific level.
+#  The height of this level is needed to compute
+#  correctly the turbulent transfer coefficients.
+#  Look at the description of the forcing
+#  DATA for the correct value.
+HEIGHT_LEV1 = 2.0
+# default  = 2.0
+
+# Height at which the wind is given
+# The height at which wind is needed to compute
+#  correctly the turbulent transfer coefficients.
+HEIGHT_LEVW = 10.0
+# default  = 10.0
+
+#---------------------------------------------------------------------
+# Weather generator or not :
+#---------------------------------------------------------------------
+
+# Allow weather generator to create data.
+# This flag allows the forcing-reader to generate
+#  synthetic data if the data in the file is too sparse
+#  and the temporal resolution would not be enough to
+#  run the model.
+ALLOW_WEATHERGEN = n
+# default = n
+
+# North-South Resolution
+# If ALLOW_WEATHERGEN
+# North-South Resolution of the region we are
+#  interested in. In degrees
+MERID_RES = 2.
+# default = 2.
+
+# East-West Resolution
+# If ALLOW_WEATHERGEN
+# East-West Resolution of the region we are
+#  interested in. In degrees
+ZONAL_RES = 2.
+# default = 2.
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+# If this is set to 1, the weather generator
+#   uses the monthly mean values for daily means.
+#   If it is set to 0, the weather generator
+#   uses statistical relationships to derive daily
+#   values from monthly means.
+IPPREC = 0
+# default = 0
+
+# Interpolation  or not IF split is larger than 1
+# Choose IF you wish to interpolate linearly or not.
+NO_INTER = y
+INTER_LIN = n
+# default :
+#  NO_INTER = y
+#  INTER_LIN = n
+
+# Exact monthly precipitation
+# If ALLOW_WEATHERGEN
+# If this is set to y, the weather generator
+#   will generate pseudo-random precipitations
+#   whose monthly mean is exactly the prescribed one.
+#   In this case, the daily precipitation (for rainy
+#   days) is constant (that is, some days have 0 precip,
+#   the other days have precip = Precip_month/n_precip,
+#   where n_precip is the prescribed number of rainy days
+#   per month).
+WEATHGEN_PRECIP_EXACT = n
+# default = n
+
+# Calling frequency of weather generator (s)
+# Determines how often the weather generator
+#  is called (time step in s). Should be equal
+#  to or larger than Sechiba's time step (say,
+#  up to 6 times Sechiba's time step or so).
+DT_WEATHGEN = 1800.
+# default = 1800.
+
+# Conserve net radiation in the forcing
+# When the interpolation is used the net radiation
+#  provided by the forcing is not conserved anymore.
+#  This should be avoided and thus this option should
+#  be TRUE (y).
+#  This option is not used for short-wave if the
+#  time-step of the forcing is longer than an hour.
+#  It does not make sense to try and reconstruct
+#  a diurnal cycle and at the same time conserve the 
+#  incoming solar radiation.
+NETRAD_CONS = y
+# default = y
+
+# Write weather from generator into a forcing file
+# This flag makes the weather generator dump its
+#  generated weather into a forcing file which can
+#  then be used to get the same forcing on different
+#  machines. This only works correctly if there is
+#  a restart file (otherwise the forcing at the first
+#  time step is slightly wrong).
+DUMP_WEATHER = n
+# default = n
+
+# Name of the file that contains
+#  the weather from generator
+# If DUMP_WEATHER
+DUMP_WEATHER_FILE = weather_dump.nc
+# default = 'weather_dump.nc'
+
+# Dump weather data on gathered grid
+# If 'y', the weather data are gathered
+#  for all land points.
+# If DUMP_WEATHER
+DUMP_WEATHER_GATHERED = y
+# default = y
+
+
+# Read Orbital Parameters
+
+# Eccentricity Effect
+# Use prescribed values
+# IF ALLOW_WEATHERGEN
+ECCENTRICITY = 0.016724
+# default = 0.016724
+
+# Longitude of perihelie
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+PERIHELIE = 102.04
+# default = 102.04
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+OBLIQUITY = 23.446
+# default = 23.446
+
+#**************************************************************************
+# length of simulation :
+#---------------------------------------------------------------------
+# Length of the integration in time.
+# Length of integration. By default the entire length
+#        of the forcing is used. The FORMAT of this date can
+#        be either of the following :
+# n   : time step n within the forcing file
+# nS  : n seconds after the first time-step in the file
+# nD  : n days after the first time-step
+# nM  : n month after the first time-step (year of 365 days)
+# nY  : n years after the first time-step (year of 365 days)
+#        Or combinations :
+# nYmM: n years and m month
+TIME_LENGTH = default
+# default = depend on the time length and the number of time step in forcing file
+#         = itau_len = itau_fin-itau_dep
+
+
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/PARAM/sechiba.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/PARAM/sechiba.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/PARAM/sechiba.def	(revision 405)
@@ -0,0 +1,817 @@
+#
+#**************************************************************************
+#                    Namelist for SECHIBA
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of SECHIBA
+#**************************************************************************
+
+# ORCHIDEE will print more messages
+# This flag permits to print more debug messages in the run.
+LONGPRINT = n
+#default = n
+
+#---------------------------------------------------------------------
+
+# Should the output follow the ALMA convention
+# If this logical flag is set to true the model
+#  will output all its data according to the ALMA 
+#  convention. It is the recommended way to write
+#  data out of ORCHIDEE.
+ALMA_OUTPUT = n
+# default = n
+
+# To reset the time coming from SECHIBA restart file
+# This option allows the model to override the time
+#  found in the restart file of SECHIBA with the time
+#  of the first call. That is the restart time of the GCM.
+SECHIBA_reset_time = n
+# default = n
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+# Name of file from which the vegetation map is to be read
+# If !IMPOSE_VEG
+# If LAND_USE 
+#   default = pft_new.nc
+#   The name of the file to be opened to read a vegetation
+#   map (in pft) is to be given here. 
+# If !LAND_USE
+#   default = ../surfmap/carteveg5km.nc
+#   The name of the file to be opened to read the vegetation
+#   map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#   map which is derived from the IGBP one. We assume that we have
+#   a classification in 87 types. This is Olson modified by Viovy.
+VEGETATION_FILE = PFTmap.nc
+
+
+# Name of file from which the bare soil albedo
+# If !IMPOSE_AZE
+# The name of the file to be opened to read the soil types from 
+#  which we derive then the bare soil albedos. This file is 1x1 
+#  deg and based on the soil colors defined by Wilson and Henderson-Seller.
+SOILALB_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Name of file from which soil types are read
+# If !IMPOSE_VEG
+# The name of the file to be opened to read the soil types. 
+#  The data from this file is then interpolated to the grid of
+#  of the model. The aim is to get fractions for sand loam and
+#  clay in each grid box. This information is used for soil hydrology
+#  and respiration.
+SOILTYPE_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Input and output restart file for SECHIBA :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+SECHIBA_restart_in = NONE
+# default = NONE
+
+# Name of restart files to be created by SECHIBA
+# This variable give the name for the restart files. 
+#  The restart software within IOIPSL will add .nc if needed.
+SECHIBA_rest_out = sechiba_rest_out.nc
+# default = sechiba_rest_out.nc
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+
+# ORCHIDEE will write out its forcing to a file
+# This flag allows to write to a file all the variables
+#  which are used to force the land-surface. The file 
+#  has exactly the same format than a normal off-line forcing
+#  and thus this forcing can be used for forcing ORCHIDEE.
+ORCHIDEE_WATCHOUT = n
+# default = n
+
+# Filenane for the ORCHIDEE forcing file
+# If ORCHIDEE_WATCHOUT
+# This is the name of the file in which the
+#  forcing used here will be written for later use. 
+WATCHOUT_FILE = orchidee_watchout.nc
+# default = orchidee_watchout.nc
+
+# ORCHIDEE will write out with this frequency
+# If ORCHIDEE_WATCHOUT
+# This flag indicates the frequency of the write of the variables. 
+DT_WATCHOUT = 1800
+# default = dt
+
+# Output file name :
+#---------------------------------------------------------------------
+# Name of file in which the output is going
+# This file is going to be created by the model
+#  to be written
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+OUTPUT_FILE = sechiba_history.nc
+# default = cabauw_out.nc
+
+# Flag to switch on histfile 2 for SECHIBA (hi-frequency ?)
+# This Flag switch on the second SECHIBA writing for hi (or low) 
+#  frequency writing. This second output is optional and not written
+#  by default.
+SECHIBA_HISTFILE2 = FALSE
+# default  = FALSE
+
+# Name of file in which the output number 2 is going
+#   to be written
+# If SECHIBA_HISTFILE2
+# This file is going to be created by the model
+#   and will contain the output 2 from the model.
+SECHIBA_OUTPUT_FILE2 = sechiba_out_2.nc
+# default  = sechiba_out_2.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# SECHIBA history output level (0..10)
+# Chooses the list of variables in the history file. 
+#  Values between 0: nothing is written; 10: everything is 
+#  written are available More details can be found on the web under documentation.
+#  web under documentation.
+SECHIBA_HISTLEVEL = 5
+# default = 5
+
+# SECHIBA history 2 output level (0..10)
+# If SECHIBA_HISTFILE2
+# Chooses the list of variables in the history file. 
+#   Values between 0: nothing is written; 10: everything is 
+#   written are available More details can be found on the web under documentation.
+#   web under documentation.
+# First level contains all ORCHIDEE outputs.
+SECHIBA_HISTLEVEL2 = 1
+# default = 1
+
+# Write frequency for output files (SECHIBA in seconds) :
+#---------------------------------------------------------------------
+# Frequency in seconds at which to WRITE output
+# This variables gives the frequency the output of
+#  the model should be written into the netCDF file.
+#  It does not affect the frequency at which the
+#  operations such as averaging are done.
+WRITE_STEP = 86400.0
+# default = 86400.0
+
+# Frequency in seconds at which to WRITE output
+# If SECHIBA_HISTFILE2
+# This variables gives the frequency the output 2 of
+#   the model should be written into the netCDF file.
+#   It does not affect the frequency at which the
+#   operations such as averaging are done.
+#   That is IF the coding of the calls to histdef
+#   are correct !
+WRITE_STEP2 = 1800.0
+# default = 1800.0
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate CO2?
+# set to TRUE if photosynthesis is to be activated
+STOMATE_OK_CO2 = n
+# default = n
+
+# Flag to force the value of atmospheric CO2 for vegetation.
+# If this flag is set to true, the ATM_CO2 parameter is used
+#  to prescribe the atmospheric CO2.
+# This Flag is only use in couple mode.
+FORCE_CO2_VEG = FALSE
+# default = FALSE
+
+# Value for atm CO2.
+# If FORCE_CO2_VEG (in not forced mode)
+# Value to prescribe the atm CO2.
+#  For pre-industrial simulations, the value is 286.2 .
+#  348. for 1990 year.
+ATM_CO2 = 350.
+# default = 350.
+
+
+#
+#**************************************************************************
+#          NEW OPTIONS FOR RESTARTS in versions up to 1.9.3
+#**************************************************************************
+#
+## sechiba
+soilcap=n
+soilflx=n
+shumdiag=n
+runoff=n
+drainage=n
+
+## diffuco
+raero=n
+qsatt=n
+cdrag=n
+
+## enerbil
+evapot_corr=n
+temp_sol_new=n
+
+## hydrolc
+dss=n
+hdry=n
+
+## thermosoil
+cgrnd=n
+dgrnd=n
+z1=n
+pcapa=n
+pcapa_en=n
+pkappa=n
+zdz1=n
+zdz2=n
+temp_sol_beg=n
+
+# parameters describing the surface (vegetation + soil) :
+#---------------------------------------------------------------------
+#
+# Should the vegetation be prescribed
+# This flag allows the user to impose a vegetation distribution
+#  and its characterisitcs. It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_VEG = n
+# default = n
+
+# Flag to use old "interpolation" of vegetation map.
+# IF NOT IMPOSE_VEG and NOT LAND_USE
+#  If you want to recover the old (ie orchidee_1_2 branch) 
+#   "interpolation" of vegetation map.
+SLOWPROC_VEGET_OLD_INTERPOL = n
+# default = n
+
+# Vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEG__01 = 0.2
+SECHIBA_VEG__02 = 0.0
+SECHIBA_VEG__03 = 0.0
+SECHIBA_VEG__04 = 0.0
+SECHIBA_VEG__05 = 0.0
+SECHIBA_VEG__06 = 0.0
+SECHIBA_VEG__07 = 0.0
+SECHIBA_VEG__08 = 0.0
+SECHIBA_VEG__09 = 0.0
+SECHIBA_VEG__10 = 0.8
+SECHIBA_VEG__11 = 0.0
+SECHIBA_VEG__12 = 0.0
+SECHIBA_VEG__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# Maximum vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEGMAX__01 = 0.2
+SECHIBA_VEGMAX__02 = 0.0
+SECHIBA_VEGMAX__03 = 0.0
+SECHIBA_VEGMAX__04 = 0.0
+SECHIBA_VEGMAX__05 = 0.0
+SECHIBA_VEGMAX__06 = 0.0
+SECHIBA_VEGMAX__07 = 0.0
+SECHIBA_VEGMAX__08 = 0.0
+SECHIBA_VEGMAX__09 = 0.0
+SECHIBA_VEGMAX__10 = 0.8
+SECHIBA_VEGMAX__11 = 0.0
+SECHIBA_VEGMAX__12 = 0.0
+SECHIBA_VEGMAX__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# LAI for all vegetation types (0-dim mode)
+# If IMPOSE_VEG
+# The maximum LAI used in the 0dim mode. The values should be found
+#  in the restart file. The new values of LAI will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SECHIBA_LAI__01 = 0.
+SECHIBA_LAI__02 = 8.
+SECHIBA_LAI__03 = 8.
+SECHIBA_LAI__04 = 4.
+SECHIBA_LAI__05 = 4.5
+SECHIBA_LAI__06 = 4.5
+SECHIBA_LAI__07 = 4.
+SECHIBA_LAI__08 = 4.5
+SECHIBA_LAI__09 = 4.
+SECHIBA_LAI__10 = 2.
+SECHIBA_LAI__11 = 2.
+SECHIBA_LAI__12 = 2.
+SECHIBA_LAI__13 = 2.
+# default = 0., 8., 8., 4., 4.5, 4.5, 4., 4.5, 4., 2., 2., 2., 2.
+
+# Height for all vegetation types (m)
+# If IMPOSE_VEG
+# The height used in the 0dim mode. The values should be found
+#  in the restart file. The new values of height will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SLOWPROC_HEIGHT__01 = 0.
+SLOWPROC_HEIGHT__02 = 50.
+SLOWPROC_HEIGHT__03 = 50.
+SLOWPROC_HEIGHT__04 = 30.
+SLOWPROC_HEIGHT__05 = 30.
+SLOWPROC_HEIGHT__06 = 30.
+SLOWPROC_HEIGHT__07 = 20.
+SLOWPROC_HEIGHT__08 = 20.
+SLOWPROC_HEIGHT__09 = 20.
+SLOWPROC_HEIGHT__10 = .2
+SLOWPROC_HEIGHT__11 = .2
+SLOWPROC_HEIGHT__12 = .4
+SLOWPROC_HEIGHT__13 = .4
+# default = 0., 30., 30., 20., 20., 20., 15., 15., 15., .5, .6, 1.0, 1.0
+
+
+# Fraction of the 3 soil types (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction for the 3 soil types
+#  in the mesh in the following order : sand loam and clay.
+SOIL_FRACTIONS__01 = 0.28
+SOIL_FRACTIONS__02 = 0.52
+SOIL_FRACTIONS__03 = 0.20
+# default = 0.28, 0.52, 0.20
+
+# Temperature used for the initial guess of LAI
+# If there is no LAI in the restart file, we may need
+#  a temperature that is used to guess the initial LAI.
+SLOWPROC_LAI_TEMPDIAG = 280.
+# default = 280.
+
+# Soil level (m) used for canopy development 
+# If STOMATE is not activated.
+# The temperature at this soil depth is used to determine the LAI when
+#   STOMATE is not activated.
+SECHIBA_ZCANOP = 0.5
+# default = 0.5
+
+# Fraction of other surface types within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of ice, lakes, etc. is read from the restart file. If
+#  it is not found there we will use the values provided here.
+#  For the moment, there is only ice.
+SECHIBA_FRAC_NOBIO = 0.0
+# default = 0.0
+
+# Fraction of the clay fraction (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction of clay in the grid box.
+CLAY_FRACTION = 0.2
+# default = 0.2
+
+# Should the surface parameters be prescribed
+# This flag allows the user to impose the surface parameters
+#  (Albedo Roughness and Emissivity). It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_AZE = n
+# default = n
+
+# Emissivity of the surface for LW radiation
+# If IMPOSE_AZE
+# The surface emissivity used for compution the LE emission
+#  of the surface in a 0-dim version. Values range between 
+#  0.97 and 1.. The GCM uses 0.98.
+CONDVEG_EMIS = 1.0
+# default = 1.0
+
+# SW visible albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in visible wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBVIS = 0.25
+# default = 0.25
+
+# SW near infrared albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in near infrared wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBNIR = 0.25
+# default = 0.25
+
+# Average method for z0
+# If this flag is set to true (y) then the neutral Cdrag
+#  is averaged instead of the log(z0). This should be
+#  the prefered option. We still wish to keep the other
+#  option so we can come back if needed. If this is
+#  desired then one should set Z0CDRAG_AVE = n
+Z0CDRAG_AVE = y
+# default = y
+
+# Surface roughness (m)
+# If IMPOSE_AZE
+# Surface rougness to be used on the point if a 0-dim version
+#  of SECHIBA is used. Look at the description of the forcing  
+#  data for the correct value.
+CONDVEG_Z0 = 0.15
+# default = 0.15_stnd
+
+# Height to be added to the height of the first level (m)
+# If IMPOSE_AZE
+# ORCHIDEE assumes that the atmospheric level height is counted
+#  from the zero wind level. Thus to take into account the roughness
+#  of tall vegetation we need to correct this by a certain fraction
+#  of the vegetation height. This is called the roughness height in
+#  ORCHIDEE talk.
+ROUGHHEIGHT = 0.0
+# default = 0.0
+
+# The snow albedo used by SECHIBA
+# This option allows the user to impose a snow albedo.
+#  Default behaviour is to use the model of snow albedo
+#  developed by Chalita (1993).
+CONDVEG_SNOWA = default
+# default = use the model of snow albedo developed by Chalita
+
+# Switch bare soil albedo dependent (if TRUE) on soil wetness
+# If TRUE, the model for bare soil albedo is the old formulation.
+#  Then it depend on the soil dry or wetness. If FALSE, it is the 
+#  new computation that is taken, it is only function of soil color.
+ALB_BARE_MODEL = FALSE
+# default = FALSE
+
+# Initial snow mass if not found in restart
+# The initial value of snow mass if its value is not found
+#   in the restart file. This should only be used if the model is 
+#   started without a restart file.
+HYDROL_SNOW = 0.0
+# default = 0.0
+
+
+# Initial snow age if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOWAGE = 0.0
+# default = 0.0
+
+# Initial snow amount on ice, lakes, etc. if not found in restart
+# The initial value of snow if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO = 0.0
+# default = 0.0
+
+# Initial snow age on ice, lakes, etc. if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO_AGE = 0.0
+# default = 0.0
+
+# Initial dry soil height if not found in restart for ORCHIDEE_1.3 to 1.5 Tags only.
+# The initial value of dry soil height if its value is not found
+# in the restart file. This should only be used if the model is 
+# started without a restart file.
+HYDROL_HDRY = 0.0
+# default = 0.0
+
+# Initial soil moisture stress if not found in restart
+# The initial value of soil moisture stress if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_HUMR = 1.0
+# default = 1.0
+
+# Total depth of soil reservoir
+HYDROL_SOIL_DEPTH = 2.
+# default = 2.
+
+# Root profile
+# Default values were defined for 2 meters soil depth.
+# For 4 meters soil depth, you may use those ones :
+# 5., .4, .4, 1., .8, .8, 1., 1., .8, 4., 1., 4., 1.
+HYDROL_HUMCSTE = 5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+# default =  5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+
+# Initial restart deep soil moisture if not found in restart
+# The initial value of deep soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. Default behaviour is a saturated soil.
+HYDROL_BQSB = default
+# default = Maximum quantity of water (Kg/M3) * Total depth of soil reservoir = 150. * 2
+
+# Initial upper soil moisture if not found in restart
+# The initial value of upper soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_GQSB = 0.0
+# default = 0.0
+
+# Initial upper reservoir depth if not found in restart
+# The initial value of upper reservoir depth if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_DSG = 0.0
+# default = 0.0
+
+# Initial dry soil above upper reservoir if not found in restart
+# The initial value of dry soil above upper reservoir if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. The default behaviour
+#  is to compute it from the variables above. Should be OK most of 
+#  the time.
+HYDROL_DSP = default
+# default = Total depth of soil reservoir - HYDROL_BQSB / Maximum quantity of water (Kg/M3) = 0.0
+
+# Initial water on canopy if not found in restart
+# The initial value of moisture on canopy if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_QSV = 0.0
+# default = 0.0
+
+# Soil moisture on each soil tile and levels
+# The initial value of mc if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_MOISTURE_CONTENT = 0.3
+# default = 0.3
+
+# US_NVM_NSTM_NSLM
+# The initial value of us (relative moisture) if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+US_INIT = 0.0
+# default = 0.0
+
+# Coefficient for free drainage at bottom
+# The initial value of free drainage if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+FREE_DRAIN_COEF = 1.0, 1.0, 1.0
+# default = 1.0, 1.0, 1.0
+
+# Bare soil evap on each soil if not found in restart
+# The initial value of bare soils evap if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+EVAPNU_SOIL = 0.0
+# default = 0.0
+
+# Initial temperature if not found in restart
+# The initial value of surface temperature if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+ENERBIL_TSURF = 280.
+# default = 280.
+
+# Initial Soil Potential Evaporation
+# The initial value of soil potential evaporation if its value 
+#  is not found in the restart file. This should only be used if
+#  the model is started without a restart file. 
+ENERBIL_EVAPOT = 0.0
+# default = 0.0
+
+# Initial soil temperature profile if not found in restart
+# The initial value of the temperature profile in the soil if 
+#   its value is not found in the restart file. This should only 
+#   be used if the model is started without a restart file. Here
+#   we only require one value as we will assume a constant 
+#   throughout the column.
+THERMOSOIL_TPRO = 280.
+# default = 280.
+
+# Initial leaf CO2 level if not found in restart
+# The initial value of leaf_ci if its value is not found
+#  in the restart file. This should only be used if the model is
+#  started without a restart file.
+DIFFUCO_LEAFCI = 233.
+# default = 233.
+
+
+# Keep cdrag coefficient from gcm.
+# Set to .TRUE. if you want q_cdrag coming from GCM.
+#  Keep cdrag coefficient from gcm for latent and sensible heat fluxes.
+#  TRUE if q_cdrag on initialization is non zero (FALSE for off-line runs).
+CDRAG_FROM_GCM = n
+# default =  IF q_cdrag == 0 ldq_cdrag_from_gcm = .FALSE. ELSE .TRUE.
+
+
+# Artificial parameter to increase or decrease canopy resistance
+# Add from Nathalie - the 28 of March 2006 - advice from Fred Hourdin
+# By PFT.
+RVEG_PFT = 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.
+# default = 1.
+
+
+# Interception reservoir coefficient.
+# Transforms leaf area index into size of interception reservoir
+#  for slowproc_derivvar or stomate.
+SECHIBA_QSINT = 0.1
+# default = 0.1
+
+#**************************************************************************
+# LAI
+#**************************************************************************
+
+# Read the LAI map
+# It is possible to read a 12 month LAI map which will
+#  then be interpolated to daily values as needed.
+#  If n => type_of_lai (constant_veg.f90)
+#     - mean    : lai(ji,jv) = undemi * (llaimax(jv) + llaimin(jv))
+#     - inter   : llaimin(jv) + tempfunc(stempdiag(ji,lcanop)) * (llaimax(jv) - llaimin(jv))
+LAI_MAP = n
+# default = n
+
+# Name of file from which the vegetation map is to be read
+# If LAI_MAP
+# The name of the file to be opened to read the LAI
+#  map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#  map which is derived from a Nicolas VIOVY one. 
+LAI_FILE = lai2D.nc
+# default = ../surfmap/lai2D.nc
+
+# Flag to use old "interpolation" of LAI
+# If LAI_MAP
+# If you want to recover the old (ie orchidee_1_2 branch) 
+# "interpolation" of LAI map.
+SLOWPROC_LAI_OLD_INTERPOL = n
+# default = n
+
+#**************************************************************************
+# LAND_USE
+#**************************************************************************
+
+# Read a land_use vegetation map
+# pft values are needed, max time axis is 293
+LAND_USE = y
+# default = n
+
+# Year of the land_use vegetation map readed
+# year off the pft map.
+# default is 133 for year 1982  (as 1982 - 1850 + 1 = 133)
+# If LAND_USE
+VEGET_YEAR = 1
+# default = 133
+
+# booleen to indicate that a new LAND USE file will be used (since 1.9.5 version).
+# The parameter is used to bypass veget_year count 
+# and reinitialize it with VEGET_YEAR parameter.
+# Then it is possible to change LAND USE file.
+# If LAND_USE
+VEGET_REINIT = y
+# default = n
+
+# Update vegetation frequency (since 2.0 version)
+# The veget datas will be update each this time step.
+# If LAND_USE
+VEGET_UPDATE = 0Y
+# default = 1Y
+
+# treat land use modifications
+# With this variable, you can use a Land Use map
+# to simulate anthropic modifications such as   
+# deforestation.                                
+# If LAND_USE
+LAND_COVER_CHANGE = n
+# default = y
+
+#**************************************************************************
+
+# agriculture allowed?
+# With this variable, you can determine
+#  whether agriculture is allowed
+AGRICULTURE = y
+# default = y
+
+#**************************************************************************
+
+# Time within the day simulated
+# This is the time spent simulating the current day. This variable is
+#  prognostic as it will trigger all the computations which are
+#  only done once a day.
+SECHIBA_DAY = 0.0
+# default = 0.0
+
+# Time step of STOMATE and other slow processes
+# Time step (s) of regular update of vegetation
+#  cover, LAI etc. This is also the time step
+#  of STOMATE.
+DT_SLOW = 86400.
+# default = un_jour = 86400.
+
+#**************************************************************************
+
+# Allows to switch on the multilayer hydrology of CWRR
+# This flag allows the user to decide if the vertical
+#  hydrology should be treated using the multi-layer 
+#  diffusion scheme adapted from CWRR by Patricia de Rosnay.
+#  by default the Choisnel hydrology is used.
+HYDROL_CWRR = n
+# default = n
+
+# do horizontal diffusion?
+# If TRUE, then water can diffuse horizontally between
+#  the PFTs' water reservoirs.
+HYDROL_OK_HDIFF = n
+# default = n
+ 
+
+# time scale (s) for horizontal diffusion of water
+# If HYDROL_OK_HDIFF
+# Defines how fast diffusion occurs horizontally between
+#  the individual PFTs' water reservoirs. If infinite, no
+#  diffusion.
+HYDROL_TAU_HDIFF = 86400.
+# default = 86400.
+
+# Percent of precip that is not intercepted by the canopy (only for TAG 1.6).
+# During one rainfall event, PERCENT_THROUGHFALL% of the incident rainfall
+#  will get directly to the ground without being intercepted.
+PERCENT_THROUGHFALL = 30.
+# default = 30.
+
+# Percent by PFT of precip that is not intercepted by the canopy (since TAG 1.8).
+# During one rainfall event, PERCENT_THROUGHFALL_PFT% of the incident rainfall
+#  will get directly to the ground without being intercepted, for each PFT..
+PERCENT_THROUGHFALL_PFT = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+# default = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+
+# Decides if we route the water or not
+# This flag allows the user to decide if the runoff
+#  and drainage should be routed to the ocean
+#  and to downstream grid boxes.
+RIVER_ROUTING = n
+# default = n
+
+# Name of file which contains the routing information
+# The file provided here should allow the routing module to
+#  read the high resolution grid of basins and the flow direction 
+#  from one mesh to the other.
+ROUTING_FILE = routing.nc
+# default = routing.nc
+
+# Time step of the routing scheme
+# If RIVER_ROUTING
+# This values gives the time step in seconds of the routing scheme. 
+#   It should be multiple of the main time step of ORCHIDEE. One day
+#   is a good value.
+ROUTING_TIMESTEP = 86400
+# default = 86400
+
+# Number of rivers 
+# If RIVER_ROUTING
+# This parameter chooses the number of largest river basins
+#  which should be treated as independently as rivers and not
+#  flow into the oceans as diffusion coastal flow.
+ROUTING_RIVERS = 50
+# default = 50
+
+# Should we compute an irrigation flux 
+# This parameters allows the user to ask the model
+#  to compute an irigation flux. This performed for the
+#  on very simple hypothesis. The idea is to have a good
+#  map of irrigated areas and a simple function which estimates
+#  the need to irrigate.
+DO_IRRIGATION = n
+# default = n
+
+# Name of file which contains the map of irrigated areas
+# If IRRIGATE
+# The name of the file to be opened to read the field
+#  with the area in m^2 of the area irrigated within each
+#  0.5 0.5 deg grid box. The map currently used is the one
+#  developed by the Center for Environmental Systems Research 
+#  in Kassel (1995).
+IRRIGATION_FILE = irrigated.nc
+# default = irrigated.nc
+
+# Should we include floodplains 
+# This parameters allows the user to ask the model
+#  to take into account the flood plains and return 
+#  the water into the soil moisture. It then can go 
+#  back to the atmopshere. This tried to simulate 
+#  internal deltas of rivers.
+DO_FLOODPLAINS = n
+# default = n
+
+#**************************************************************************
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/PARAM/stomate.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/PARAM/stomate.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/PARAM/stomate.def	(revision 405)
@@ -0,0 +1,206 @@
+#
+#**************************************************************************
+#                    Namelist for STOMATE
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of STOMATE
+#**************************************************************************
+
+# Model chatting level
+# level of online diagnostics in STOMATE (0-4)
+# With this variable, you can determine how much online information STOMATE
+#  gives during the run. 0 means virtually no info.
+BAVARD = 1
+# default = 1
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+
+# Name of file from which the reference
+# The name of the file to be opened to read
+#  temperature is read
+#  the reference surface temperature.
+#  The data from this file is then interpolated
+#  to the grid of the model.
+#  The aim is to get a reference temperature either
+#  to initialize the corresponding prognostic model
+#  variable correctly (ok_dgvm = TRUE) or to impose it
+#  as boundary condition (ok_dgvm = FALSE)
+REFTEMP_FILE = reftemp.nc
+# default = reftemp.nc
+# Input and output restart file for STOMATE :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions of STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened of STOMATE
+#   to extract the initial values of all prognostic values of STOMATE.
+STOMATE_RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened
+#        to write the final values of all prognostic values
+#        of STOMATE.
+STOMATE_RESTART_FILEOUT = stomate_rest_out.nc
+# default = stomate_restart.nc
+
+# Forcing files for TESTSTOMATE and FORCESOIL
+#---------------------------------------------------------------------
+
+# Name of STOMATE's forcing file
+# Name that will be given to STOMATE's offline forcing file
+STOMATE_FORCING_NAME = stomate_forcing.nc
+#default = NONE
+
+# Size of STOMATE forcing data in memory (MB)
+# This variable determines how many
+#  forcing states will be kept in memory.
+#  Must be a compromise between memory
+#  use and frequeny of disk access.
+STOMATE_FORCING_MEMSIZE = 50
+# default = 50
+
+# Name of STOMATE's carbon forcing file
+# Name that will be given to STOMATE's carbon offline forcing file
+STOMATE_CFORCING_NAME = stomate_Cforcing.nc
+# default = NONE
+
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+# STOMATE does minimum service
+# set to TRUE if you want STOMATE to read
+#  and write its start files and keep track
+#  of longer-term biometeorological variables.
+#  This is useful if OK_STOMATE is not set,
+#  but if you intend to activate STOMATE later.
+#  In that case, this run can serve as a 
+#  spinup for longer-term biometeorological
+#  variables.
+STOMATE_WATCHOUT = n
+# default = n
+
+
+# Output file name :
+#---------------------------------------------------------------------
+
+# Name of file in which STOMATE's output is going to be written
+# This file is going to be created by the model
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+STOMATE_OUTPUT_FILE = stomate_history.nc
+# default = stomate_history.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# STOMATE history output level (0..10)
+#  0: nothing is written; 10: everything is written
+STOMATE_HISTLEVEL = 10
+# default = 10
+
+# STOMATE_IPCC_OUTPUT_FILE
+# This file is going to be created by the model
+#    and will contain the output from the model.
+#    This file is a truly COADS compliant netCDF file.
+#    It will be generated by the hist software from
+#    the IOIPSL package.
+# Name of file in which STOMATE's output is going
+# to be written
+STOMATE_IPCC_OUTPUT_FILE = stomate_ipcc_history.nc
+# default = stomate_ipcc_history.nc
+
+# STOMATE_IPCC_HIST_DT
+# Time step of the STOMATE IPCC history file
+# STOMATE IPCC history time step (d)
+STOMATE_IPCC_HIST_DT = 0.
+# default = 0.
+
+# Write frequency for output files (STOMATE in days) :
+#---------------------------------------------------------------------
+
+# STOMATE history time step (d)
+# Time step of the STOMATE history file
+# Care : this variable must be higher than DT_SLOW
+STOMATE_HIST_DT = 10.
+# default = 10.
+
+
+#---------------------------------------------------------------------
+# FORCESOIL CARBON spin up parametrization
+#---------------------------------------------------------------------
+
+# Number of time steps per year for carbon spinup.
+FORCESOIL_STEP_PER_YEAR = 12
+# default = 12
+
+# Number of years saved for carbon spinup.
+FORCESOIL_NB_YEAR = 1
+# default = 1
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate STOMATE?
+# set to TRUE if STOMATE is to be activated
+STOMATE_OK_STOMATE = n
+# default = n
+
+# Activate DGVM?
+# set to TRUE if Dynamic Vegetation DGVM is to be activated
+STOMATE_OK_DGVM = n
+# default = n
+
+# Index of grid point for online diagnostics
+# This is the index of the grid point which will be used for online diagnostics.
+STOMATE_DIAGPT = 1
+# default = 1
+
+# constant tree mortality
+# If yes, then a constant mortality is applied to trees. 
+#  Otherwise, mortality is a function of the trees' 
+#  vigour (as in LPJ).
+LPJ_GAP_CONST_MORT = y
+# default = y
+
+# no fire allowed
+# With this variable, you can allow or not
+#  the estimation of CO2 lost by fire
+FIRE_DISABLE = n
+# default = n
+
+#**************************************************************************
+
+# Harvert model for agricol PFTs.
+# Compute harvest above ground biomass for agriculture.
+# Change daily turnover.
+HARVEST_AGRI = y
+# default = y
+
+# herbivores allowed?
+# With this variable, you can activate herbivores 
+HERBIVORES = n
+# default = n
+
+# treat expansion of PFTs across a grid cell?
+# With this variable, you can determine
+#  whether we treat expansion of PFTs across a
+#  grid cell.
+TREAT_EXPANSION = n
+# default = n
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/config.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/config.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/config.card	(revision 405)
@@ -0,0 +1,145 @@
+#
+# This is config.card file for restart with an NEW libIGCM simulation tree.
+#
+#====================================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+#========================================================================
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=SpinUp
+LongName="Spin Up for ORCHIDEE. See spinup.card for options."
+TagName=OL2
+#============================
+#-- leap, noleap, 360d
+CalendarType= gregorian
+#-- Start and End of Job
+#-- "YYYY-MM-DD"
+DateBegin=1950-01-01
+DateEnd=1950-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength= 1Y
+PeriodNb= 1
+#============================
+#-- PBS Class (required on brodie mono/multi)
+#JobClass=mono
+JobClass=multi
+#============================
+#-- Total Number of Processors (minimum is 2 for a coupled configuration)
+JobNumProcTot=2
+#============================
+#-- Run Options : here for oasis coupling
+JobRunOptions='"-np "${NUM_PROC}" -max_np "${NUM_PROC}'
+#JobRunOptions='"-np "${NUM_PROC}'
+
+#========================================================================
+#========================================================================
+#D-- SRF options passed to SuRFace (SECHIBA) subjobs
+[SRF]
+WriteFrequency="1M"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1997-12-31
+# Define restart simulation name
+RestartJobName=SPINUP
+RestartPath=${ARCHIVE}/${LOGIN}/IGCM_OUT/${config_UserChoices_TagName}
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#D-- Surface BioGeochemistry ( STOMATE ) subjobs
+[SBG]
+WriteFrequency= 1M
+Restart= n
+#-- Last day of the experience used as restart
+RestartDate= 1900-12-31
+# Define restart simulation name
+RestartJobName= RESTART_SHILONG
+RestartPath= /dmnfs11/cont003/p86manci/SHILONG_FORCAGES
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#D-- Post-treatment options passed to SubJobs
+[SubJobPost]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=NONE
+#D- Do we rebuild parallel output from archive (use NONE to use SCRATCHDIR as buffer)
+RebuildFromArchive=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency= NONE
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency= NONE
+#D- Offset for seasonal average first start dates ; same unit as SeasonalFrequency
+#D- Usefull if you do not want to consider the first X simulation's years
+SeasonalFrequencyOffset=0
+
+#========================================================================
+#========================================================================
+
+#========================================================================
+#D-- ListOfComponents - Don't modify this !
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+SPIN= (spinup, HEAD)
+
+#========================================================================
+#D-- Executable - Don't modify this !
+[Executable]
+# No name for this job
+Name=SubJob$$.ksh
+#D- For each component, Real name of executable, Name of executable for oasis
+SPIN= ("", "")
+
+
+#========================================================================
+#D-- Post - Don't modify this !
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=NONE
+#D- Do we rebuild parallel output from archive (use NONE to use SCRATCHDIR as buffer)
+RebuildFromArchive=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency= NONE
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency= NONE
+#D- Offset for seasonal average first start dates ; same unit as SeasonalFrequency
+#D- Usefull if you do not want to consider the first X simulation's years
+SeasonalFrequencyOffset=0
+
+#========================================================================
+#D-- Restarts - Don't modify this !
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule= n
+#D- Last day of the experience used as restart
+RestartDate=1979-12-31
+#D- Define restart simulation name (=> JOB_OS)
+RestartJobName=TESTFORCE
+#D- Path Server Group Login (=> PSGL)
+RestartPath=${ARCHIVE}/${LOGIN}/IGCM_OUT
+# Attention login depend de la machine
+
+#========================================================================
+#D-- SPIN options : Don't modify this !
+[SPIN]
+WriteFrequency="1Y"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=
+# Define restart simulation name
+RestartJobName=
+RestartPath=
+# Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/output.card_init
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/output.card_init	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/SPINUP/output.card_init	(revision 405)
@@ -0,0 +1,21 @@
+#  Output card for spinup
+
+[Global]
+Iteration=0
+Path=
+
+[Stage]
+# This Stage
+# StageName is the internal name for the interation for spinup
+StageName=start
+# ExtName is the short JobName of this stage
+ExtName=
+
+[PreviousStage]
+# Previous Stage
+LastStageName=
+LastExtName=
+LastRestartDate=
+
+[Actions]
+List = \
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/sechiba.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/sechiba.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/sechiba.card	(revision 405)
@@ -0,0 +1,45 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+LAIMAP=n
+IMPOSE_VEG=n
+# if IMPOSE_VEG = n
+LAND_USE=n
+# if LAND_USE=y
+VEGET_UPDATE=1Y
+# if LAND_USE=n and we want to use carteveg5km.nc for maxvegetfrac map.
+# (instead of default PFTmap_1850to2005_AR5_LUHa.rc2 below)
+OLD_VEGET=n
+
+[InitialStateFiles]
+List=	(${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2/PFTmap_IPCC_${year}.nc, PFTmap.nc)
+	
+[BoundaryFiles]
+#List=	(${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2/PFTmap_IPCC_${year_p1}.nc, .)
+List=	()
+ListNonDel= (${config_SBG_RestartPath}/${config_SBG_RestartJobName}/SBG/Restart/${config_SBG_RestartJobName}_${Date_Restarts}_stomate_forcing.nc, stomate_forcing.nc)
+#If you want to come back to old BIG LAND USE file (to run on multipple years, just one time with LAND USE activated), you must 
+# 1) empty BC list and INIT first PFTmap lines
+# 2) and suppress previous ListNonDel line and ucomment next one :
+#ListNonDel= (${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2.nc, PFTmap.nc) \
+#            (${config_SBG_RestartPath}/${config_SBG_RestartJobName}/SBG/Restart/${config_SBG_RestartJobName}_${Date_Restarts}_stomate_forcing.nc, stomate_forcing.nc)
+# See also same comment in sechiba.driver.
+
+[SmoothFiles]
+List=()
+
+[ParametersFiles]
+List=	(${SUBMIT_DIR}/PARAM/sechiba.def, .) \
+	(${SUBMIT_DIR}/PARAM/driver.def, .) \
+	(${SUBMIT_DIR}/PARAM/run.def, .)
+
+[RestartFiles]
+# List restart that have to be saved/restored each loop (file out, saved, and in) :
+List=	(sechiba_rest_out.nc, sechiba_rest.nc, sechiba_rest_in.nc)
+
+[OutputText]
+List=   (used_sechiba.def, used_driver.def, out_teststomate, out_orchidee)
+
+[OutputFiles]
+List=	()
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/sechiba.driver
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/sechiba.driver	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/sechiba.driver	(revision 405)
@@ -0,0 +1,192 @@
+#!/bin/ksh
+
+#D- Driver du script pour SECHIBA
+
+function SECHIBA_sed
+{
+    IGCM_debug_PushStack "SECHIBA_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	sechiba.def > sechiba.def.tmp
+    RET=$?
+    echo "SECHIBA_sed : ${1} ${2}"
+    \mv sechiba.def.tmp sechiba.def
+    
+    IGCM_debug_PopStack "SECHIBA_sed"
+    return $RET
+}
+
+function DRIVER_sed
+{
+    IGCM_debug_PushStack "DRIVER_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	driver.def > driver.def.tmp
+    RET=$?
+    echo "DRIVER_sed : ${1} ${2}"
+    \mv driver.def.tmp driver.def
+    
+    IGCM_debug_PopStack "DRIVER_sed"
+    return $RET
+}
+
+#-----------------------------------------------------------------
+function SRF_Initialize
+{
+    IGCM_debug_PushStack "SRF_Initialize"
+
+    echo "ORCHIDEE Tag : " ${config_UserChoices_TagName}
+
+    NUM_PROC=1
+#D- Number of processors used for lmdz and oasis coupler computed from PBS variable
+    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
+	NUM_PROC=${BATCH_NUM_PROC_TOT}
+    fi
+    echo BATCH_NUM_PROC_TOT=${BATCH_NUM_PROC_TOT}
+    echo NUM_PROC=${NUM_PROC}
+
+    if ( [ X${BATCH_NUM_PROC_TOT} != X ] && [ "${BATCH_NUM_PROC_TOT}" -gt 1 ] ) ; then
+	MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND}
+    fi
+
+    RESOL_SRF=ALL
+    
+    typeset frequency
+    for frequency in ${config_SRF_WriteFrequency} ; do
+        case ${frequency} in
+            HF|hf) SRF_ok_hf=y ;;
+        esac
+    done
+
+    if [ X${sechiba_UserChoices_LAND_USE} = Xy ] ; then
+      sed -e 's&#List=\(.*\)PFTmap\(.*\)year_p1\(.*\)&List=\1PFTmap\2year_p1\3&' ${SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+      IGCM_sys_Mv sechiba.card.tmp ${SUBMIT_DIR}/COMP/sechiba.card
+    fi
+
+    if [ X${sechiba_UserChoices_IMPOSE_VEG} = Xy ] ; then
+      sed -e 's&\(List.*=\)*\([[:space:]]*(*\).*PFTmap.*\${year}.*.nc,.*)&\1\2)&' ${SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+      IGCM_sys_Mv sechiba.card.tmp ${SUBMIT_DIR}/COMP/sechiba.card
+    fi
+
+    IGCM_debug_PopStack "SRF_Initialize"
+}
+
+#-----------------------------------------------------------------
+# Optionnal function executed at the beginning of the main loop, 
+# after IGCM_config_PeriodStart see libIGCM/AA_job. 
+# It may be used to set special variables used in forward lists
+function SRF_PeriodStart
+{
+    IGCM_debug_PushStack "SRF_PeriodStart"
+    IGCM_debug_PopStack "SRF_PeriodStart"
+}
+
+#-----------------------------------------------------------------
+function SRF_Update
+{
+    IGCM_debug_PushStack "SRF_Update"
+
+    typeset SECHIBA_WRITE_STEP
+
+    # Get WriteFrenquecies from config.card for SECHIBA
+    SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) 
+    case ${SRF_WriteFrequency} in
+	*Y|*y) 
+	    WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' )
+	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+	    (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) ;;
+	1M)
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		SECHIBA_WRITE_STEP=-1.
+		;;
+	    *M|*m)
+		SECHIBA_WRITE_STEP=-1.
+		;;
+	    *)
+		(( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
+		;;
+	    esac
+	    ;;
+	*M|*m) 
+	    WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' )
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+		(( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12 ))
+		;;
+	    *M|*m)
+		PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
+		(( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths  * 86400 / PeriodLengthInMonths  ))
+		;;
+	    *)
+		(( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
+		;;
+	    esac
+	    ;;
+	5D|5d) 
+	    (( SECHIBA_WRITE_STEP = 5 * 86400 )) ;;
+	1D|1d) 
+	    (( SECHIBA_WRITE_STEP = 86400 )) ;;
+	*s)
+	    WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' )
+	    (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;;
+	*) 
+	    IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
+	    IGCM_debug_Verif_Exit ;;
+    esac
+    SECHIBA_sed WRITE_STEP ${SECHIBA_WRITE_STEP}
+
+    if [ X${sechiba_UserChoices_IMPOSE_VEG} = Xn ] ; then
+	if [ X${sechiba_UserChoices_LAND_USE} = Xy ] ; then
+	    SECHIBA_sed VEGET_UPDATE ${sechiba_UserChoices_VEGET_UPDATE}
+
+            ##MM : cutting PFTmaps of ORCHIDEE : for first year without restart, we must use this year map
+            ##     WARNING : the next year map must be avaible and the december month, then this device will
+            ##               only work with PeriodLength scrictly less than 1Y.
+            # If you want to come back to old BIG LAND USE file
+            # (to run on multipple years, just one time with LAND USE activated), 
+            # you must 
+            # comment all next 8 lines and check correct parameters in sechiba.def file
+            # for your LAND USE specific file.
+	    SECHIBA_sed VEGET_REINIT y
+	    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SRF_Restart}" = "n" ] ) ; then
+		SECHIBA_sed VEGET_YEAR 1
+	    else
+		SECHIBA_sed VEGET_YEAR 0
+		IGCM_sys_Mv -f PFTmap_IPCC_${year_p1}.nc PFTmap.nc
+	    fi
+	elif [ X${sechiba_UserChoices_OLD_VEGET} = Xy ] ; then
+	    SECHIBA_sed LAND_USE n
+	fi
+    else
+	SECHIBA_sed IMPOSE_VEG y
+    fi
+
+    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SRF_Restart}" = "n" ] ) ; then
+	echo "Error in teststomate !"
+	echo "You must use some old restarts with this job." 
+	echo "We will stop here."
+	IGCM_debug_Exit "YOU MUST USE SOME OLD RESTARTS WITH THE JOB TESTSTOMATE." 
+	IGCM_debug_Verif_Exit
+    else
+	SECHIBA_sed SECHIBA_restart_in sechiba_rest_in.nc
+    fi
+    FileToBeDeleted[${#FileToBeDeleted[@]}]=sechiba.def
+
+    DRIVER_sed TIME_LENGTH ${PeriodLengthInDays}D
+#    DRIVER_sed TIME_SKIP ${OldSimulationLengthInDays}D
+    FileToBeDeleted[${#FileToBeDeleted[@]}]=driver.def
+
+    IGCM_debug_PopStack "SRF_Update"
+}
+
+#-----------------------------------------------------------------
+function SRF_Finalize
+{
+    IGCM_debug_PushStack "SRF_Finalize"
+
+    echo FINALIZE SRF !!!
+
+    IGCM_debug_PopStack "SRF_Finalize"
+}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/stomate.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/stomate.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/stomate.card	(revision 405)
@@ -0,0 +1,51 @@
+[Compatibility]
+libIGCM=1.0
+
+[UserChoices]
+stomate_LEVEL=10
+
+[InitialStateFiles]
+List=   ()
+
+[BoundaryFiles]
+List=	()
+ListNonDel= (${R_BC}/SRF/${config_UserChoices_TagName}/reftemp.nc, .)
+
+[SmoothFiles]
+List=	()
+
+[ParametersFiles]
+List=   (${SUBMIT_DIR}/PARAM/stomate.def, .)
+
+[RestartFiles]
+# List restart that have to be saved/restored each loop (file out, saved, and in) :
+List=	(stomate_rest_out.nc, stomate_rest.nc, stomate_rest_in.nc)
+# \
+#	(stomate_forcing.nc, stomate_forcing.nc, stomate_forcing.nc) \
+#	(stomate_Cforcing.nc, stomate_Cforcing.nc, stomate_Cforcing.nc)
+
+
+[OutputText]
+List=   (used_stomate.def)
+
+[OutputFiles]
+List=	(stomate_history.nc, ${R_OUT_SBG_O_M}/${PREFIX}_1M_stomate_history.nc, Post_1M_stomate_history) \
+    (stomate_ipcc_history.nc, ${R_OUT_SBG_O_M}/${PREFIX}_1M_stomate_ipcc_history.nc, Post_1M_stomate_ipcc_history)
+
+[Post_1M_stomate_history]
+Patches= ()
+GatherWithInternal= (lon, lat, PFT, time_counter, Areas)
+TimeSeriesVars2D= (T2M_MONTH,CONTFRAC,RESOLUTION_X,RESOLUTION_Y,CONVFLUX,CFLUX_PROD10,CFLUX_PROD100,CO2FLUX_MONTHLY_SUM,HARVEST_ABOVE)
+ChunckJob2D = NONE
+TimeSeriesVars3D= (CO2FLUX,LAI,VEGET,VEGET_MAX,NPP,GPP,HET_RESP,MAINT_RESP,GROWTH_RESP,AGE,HEIGHT,TOTAL_M,TOTAL_BM_LITTER,TOTAL_SOIL_CARB,ADAPTATION,REGENERATION)
+ChunckJob3D = NONE
+Seasonal=ON
+
+[Post_1M_stomate_ipcc_history]
+Patches= ()
+GatherWithInternal= (lon, lat, PFT, time_counter, Areas)
+TimeSeriesVars2D=(cVeg, cLitter, cSoil, cProduct, cMassVariation, lai, gpp, ra, npp, rh, fFire, fHarvest, fLuc, nbp, fVegLitter, fLitterSoil, cLeaf, cWood, cRoot, cMisc, cLitterAbove, cLitterBelow, cSoilFast, cSoilMedium, cSoilSlow, landCoverFrac, treeFracPrimDec, treeFracPrimEver, c3PftFrac, c4PftFrac, rGrowth, rMaint, nppLeaf, nppWood, nppRoot, nep)
+ChunckJob2D = NONE
+TimeSeriesVars3D=()
+ChunckJob3D = NONE
+Seasonal=ON
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/stomate.driver
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/stomate.driver	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/COMP/stomate.driver	(revision 405)
@@ -0,0 +1,130 @@
+#!/bin/ksh
+
+#D- Driver du script pour STOMATE
+
+function STOMATE_sed
+{
+    IGCM_debug_PushStack "STOMATE_sed"
+    
+    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
+	stomate.def > stomate.def.tmp
+    RET=$?
+    echo "STOMATE_sed : ${1} ${2}"
+    \mv stomate.def.tmp stomate.def
+    
+    IGCM_debug_PopStack "STOMATE_sed"
+    return $RET
+}
+
+#-----------------------------------------------------------------
+function SBG_Initialize
+{
+    IGCM_debug_PushStack "SBG_Initialize"
+
+    RESOL_SBG=ALL
+    
+    typeset frequency
+    for frequency in ${config_SBG_WriteFrequency} ; do
+        case ${frequency} in
+            HF|hf) SBG_ok_hf=y ;;
+        esac
+    done
+    
+    IGCM_debug_PopStack "SBG_Initialize"
+}
+
+#-----------------------------------------------------------------
+function SBG_PeriodStart
+{
+    IGCM_debug_PushStack "SBG_PeriodStart"
+
+    IGCM_debug_PopStack "SBG_PeriodStart"
+}
+
+#-----------------------------------------------------------------
+function SBG_Update
+{
+    IGCM_debug_PushStack "SBG_Update"
+
+    typeset STOMATE_WRITE_STEP
+
+    case ${config_SBG_WriteFrequency} in
+	*Y|*y) 
+	    WriteInYears=$( echo ${config_SBG_WriteFrequency} | awk -F '[yY]' '{print $1}' )
+	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+	    (( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears )) ;;
+	1M|1m) 
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		STOMATE_WRITE_STEP=-1.
+		;;
+	    *M|*m)
+		STOMATE_WRITE_STEP=-1.
+		;;
+	    *)
+		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
+	    esac
+	    ;;
+	*M|*m) 
+	    WriteInMonths=$( echo ${config_SBG_WriteFrequency} | awk -F '[mM]' '{print $1}' )
+	    case ${config_UserChoices_PeriodLength} in
+	    *Y|*y)
+		PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
+		(( STOMATE_WRITE_STEP = 30 )) ;;
+	    *M|*m)
+		PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
+		(( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInMonths / PeriodLengthInMonths )) ;;
+	    *)
+		(( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
+	    esac
+	    ;;
+	5D|5d) 
+	    (( STOMATE_WRITE_STEP = 5 )) ;;
+	1D|1d) 
+	    (( STOMATE_WRITE_STEP = 1 )) ;;
+	*s)
+	    WriteInSeconds=$( echo ${config_SBG_WriteFrequency} | awk -F '[s]' '{print $1}' )
+	    (( STOMATE_WRITE_STEP = 1 )) ;;
+	*) 
+	    IGCM_debug_Exit "SBG_Update " ${config_SBG_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
+	    IGCM_debug_Verif_Exit ;;
+    esac
+
+    STOMATE_sed STOMATE_OK_STOMATE y
+
+    STOMATE_sed STOMATE_HIST_DT ${STOMATE_WRITE_STEP}
+    STOMATE_sed STOMATE_HISTLEVEL ${stomate_UserChoices_stomate_LEVEL}
+    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SBG_Restart}" = "n" ] ) ; then
+	echo "STOMATE : without restart"
+    else
+	STOMATE_sed STOMATE_RESTART_FILEIN stomate_rest_in.nc
+    fi
+
+    if [ X${SBG_ok_hf} = Xy ] ; then 
+	STOMATE_sed STOMATE_IPCC_HIST_DT 1D
+    else
+	STOMATE_sed STOMATE_IPCC_HIST_DT ${STOMATE_WRITE_STEP}
+    fi
+
+    IGCM_debug_PopStack "SBG_Update"
+}
+
+#-----------------------------------------------------------------
+function SBG_Finalize
+{
+    IGCM_debug_PushStack "SBG_Finalize"
+
+    typeset NbDaysDone NbYearsDone
+
+#     NbDaysDone=$( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} )
+#     NbYearsDone=$(( NbDaysDone / 360 ))
+    
+#     echo $NbDaysDone, $NbYearsDone, $(( NbYearsDone % 10 ))
+#    if [ $(( NbYearsDone % 10 )) = 0 ] ; then
+    if [ $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateEnd} ) -ge 0 ] ; then
+	IGCM_sys_Put_Out stomate_Cforcing.nc ${R_OUT_SBG_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_stomate_Cforcing.nc
+	rm -f stomate_Cforcing.nc
+    fi
+
+    IGCM_debug_PopStack "SBG_Finalize"
+}
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/driver.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/driver.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/driver.def	(revision 405)
@@ -0,0 +1,29 @@
+#
+#**************************************************************************
+#                    Namelist for TESTSTOMATE
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#**************************************************************************
+# length of simulation :
+#---------------------------------------------------------------------
+# Length of the integration in time.
+# Length of integration. By default the entire length
+#        of the forcing is used. The FORMAT of this date can
+#        be either of the following :
+# n   : time step n within the forcing file
+# nS  : n seconds after the first time-step in the file
+# nD  : n days after the first time-step
+# nM  : n month after the first time-step (year of 365 days)
+# nY  : n years after the first time-step (year of 365 days)
+#        Or combinations :
+# nYmM: n years and m month
+TIME_LENGTH = default
+# default = depend on the time length and the number of time step in forcing file
+#         = itau_len = itau_fin-itau_dep
+
+
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/run.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/run.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/run.def	(revision 405)
@@ -0,0 +1,5 @@
+# $Id: run.def,v 1.1 2010/10/11 14:36:12 ssipsl Exp $
+#
+INCLUDEDEF=driver.def
+INCLUDEDEF=sechiba.def
+INCLUDEDEF=stomate.def
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/sechiba.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/sechiba.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/sechiba.def	(revision 405)
@@ -0,0 +1,1261 @@
+#
+#**************************************************************************
+#                    Namelist for ORCHIDEE
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of ORCHIDEE
+#**************************************************************************
+
+# Model chatting level
+# level of online diagnostics in STOMATE (0-4)
+# With this variable, you can determine how much online information STOMATE
+#  gives during the run. 0 means virtually no info.
+BAVARD = 1
+# default = 1
+
+# Flag for debug information
+# This option allows to switch on the output of debug
+#         information without recompiling the code.
+DEBUG_INFO = n
+#default = n
+
+# ORCHIDEE will print more messages
+# This flag permits to print more debug messages in the run.
+LONGPRINT = n
+#default = n
+
+#---------------------------------------------------------------------
+
+# Should the output follow the ALMA convention
+# If this logical flag is set to true the model
+#  will output all its data according to the ALMA 
+#  convention. It is the recommended way to write
+#  data out of ORCHIDEE.
+ALMA_OUTPUT = n
+# default = n
+
+# To reset the time coming from SECHIBA restart file
+# This option allows the model to override the time
+#  found in the restart file of SECHIBA with the time
+#  of the first call. That is the restart time of the GCM.
+SECHIBA_reset_time = n
+# default = n
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+# Name of file from which the vegetation map is to be read
+# If !IMPOSE_VEG
+# If LAND_USE 
+#   default = pft_new.nc
+#   The name of the file to be opened to read a vegetation
+#   map (in pft) is to be given here. 
+# If !LAND_USE
+#   default = ../surfmap/carteveg5km.nc
+#   The name of the file to be opened to read the vegetation
+#   map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#   map which is derived from the IGBP one. We assume that we have
+#   a classification in 87 types. This is Olson modified by Viovy.
+VEGETATION_FILE = PFTmap.nc
+
+
+# Name of file from which the bare soil albedo
+# If !IMPOSE_AZE
+# The name of the file to be opened to read the soil types from 
+#  which we derive then the bare soil albedos. This file is 1x1 
+#  deg and based on the soil colors defined by Wilson and Henderson-Seller.
+SOILALB_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Name of file from which soil types are read
+# If !IMPOSE_VEG
+# The name of the file to be opened to read the soil types. 
+#  The data from this file is then interpolated to the grid of
+#  of the model. The aim is to get fractions for sand loam and
+#  clay in each grid box. This information is used for soil hydrology
+#  and respiration.
+SOILTYPE_FILE = soils_param.nc
+# default = ../surfmap/soils_param.nc
+
+# Name of file from which the reference
+# The name of the file to be opened to read
+#  temperature is read
+#  the reference surface temperature.
+#  The data from this file is then interpolated
+#  to the grid of the model.
+#  The aim is to get a reference temperature either
+#  to initialize the corresponding prognostic model
+#  variable correctly (ok_dgvm = TRUE) or to impose it
+#  as boundary condition (ok_dgvm = FALSE)
+REFTEMP_FILE = reftemp.nc
+# default = reftemp.nc
+
+# Forcing file name
+# Name of file containing the forcing data
+# This is the name of the file which should be opened
+# for reading the forcing data of the dim0 model.
+# The format of the file has to be netCDF and COADS
+# compliant. Cabauw.nc, islscp_for.nc, WG_cru.nc
+FORCING_FILE = forcing_file.nc
+# default = islscp_for.nc
+
+# Input and output restart file for the driver
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by the driver
+# This variable give the  name for
+#  the restart file. The restart software within
+#  IOIPSL will add .nc if needed
+RESTART_FILEOUT = driver_rest_out.nc
+# default = driver_rest_out.nc
+
+
+# Input and output restart file for SECHIBA :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions
+# This is the name of the file which will be opened
+#  to extract the initial values of all prognostic
+#  values of the model. This has to be a netCDF file.
+#  Not truly COADS compliant. NONE will mean that
+#  no restart file is to be expected.
+SECHIBA_restart_in = NONE
+# default = NONE
+
+# Name of restart files to be created by SECHIBA
+# This variable give the name for the restart files. 
+#  The restart software within IOIPSL will add .nc if needed.
+SECHIBA_rest_out = sechiba_rest_out.nc
+# default = sechiba_rest_out.nc
+
+# Input and output restart file for STOMATE :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions of STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened of STOMATE
+#   to extract the initial values of all prognostic values of STOMATE.
+STOMATE_RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened
+#        to write the final values of all prognostic values
+#        of STOMATE.
+STOMATE_RESTART_FILEOUT = stomate_rest_out.nc
+# default = stomate_restart.nc
+
+# Forcing files for TESTSTOMATE and FORCESOIL
+#---------------------------------------------------------------------
+
+# Name of STOMATE's forcing file
+# Name that will be given to STOMATE's offline forcing file
+STOMATE_FORCING_NAME = stomate_forcing.nc
+#default = NONE
+
+# Size of STOMATE forcing data in memory (MB)
+# This variable determines how many
+#  forcing states will be kept in memory.
+#  Must be a compromise between memory
+#  use and frequeny of disk access.
+STOMATE_FORCING_MEMSIZE = 50
+# default = 50
+
+# Name of STOMATE's carbon forcing file
+# Name that will be given to STOMATE's carbon offline forcing file
+STOMATE_CFORCING_NAME = stomate_Cforcing.nc
+# default = NONE
+
+
+# Produced forcing file name (SECHIBA puis STOMATE) :
+#---------------------------------------------------------------------
+
+# ORCHIDEE will write out its forcing to a file
+# This flag allows to write to a file all the variables
+#  which are used to force the land-surface. The file 
+#  has exactly the same format than a normal off-line forcing
+#  and thus this forcing can be used for forcing ORCHIDEE.
+ORCHIDEE_WATCHOUT = n
+# default = n
+
+# Filenane for the ORCHIDEE forcing file
+# If ORCHIDEE_WATCHOUT
+# This is the name of the file in which the
+#  forcing used here will be written for later use. 
+WATCHOUT_FILE = orchidee_watchout.nc
+# default = orchidee_watchout.nc
+
+# ORCHIDEE will write out with this frequency
+# If ORCHIDEE_WATCHOUT
+# This flag indicates the frequency of the write of the variables. 
+DT_WATCHOUT = 1800
+# default = dt
+
+# STOMATE does minimum service
+# set to TRUE if you want STOMATE to read
+#  and write its start files and keep track
+#  of longer-term biometeorological variables.
+#  This is useful if OK_STOMATE is not set,
+#  but if you intend to activate STOMATE later.
+#  In that case, this run can serve as a 
+#  spinup for longer-term biometeorological
+#  variables.
+STOMATE_WATCHOUT = n
+# default = n
+
+# Output file name (SECHIBA and STOMATE) :
+#---------------------------------------------------------------------
+# Name of file in which the output is going
+# This file is going to be created by the model
+#  to be written
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+OUTPUT_FILE = sechiba_history.nc
+# default = cabauw_out.nc
+
+# Flag to switch on histfile 2 for SECHIBA (hi-frequency ?)
+# This Flag switch on the second SECHIBA writing for hi (or low) 
+#  frequency writing. This second output is optional and not written
+#  by default.
+SECHIBA_HISTFILE2 = FALSE
+# default  = FALSE
+
+# Name of file in which the output number 2 is going
+#   to be written
+# If SECHIBA_HISTFILE2
+# This file is going to be created by the model
+#   and will contain the output 2 from the model.
+SECHIBA_OUTPUT_FILE2 = sechiba_out_2.nc
+# default  = sechiba_out_2.nc
+
+# Name of file in which STOMATE's output is going to be written
+# This file is going to be created by the model
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+STOMATE_OUTPUT_FILE = stomate_history.nc
+# default = stomate_history.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# SECHIBA history output level (0..10)
+# Chooses the list of variables in the history file. 
+#  Values between 0: nothing is written; 10: everything is 
+#  written are available More details can be found on the web under documentation.
+#  web under documentation.
+SECHIBA_HISTLEVEL = 5
+# default = 5
+
+# SECHIBA history 2 output level (0..10)
+# If SECHIBA_HISTFILE2
+# Chooses the list of variables in the history file. 
+#   Values between 0: nothing is written; 10: everything is 
+#   written are available More details can be found on the web under documentation.
+#   web under documentation.
+# First level contains all ORCHIDEE outputs.
+SECHIBA_HISTLEVEL2 = 1
+# default = 1
+
+# STOMATE history output level (0..10)
+#  0: nothing is written; 10: everything is written
+STOMATE_HISTLEVEL = 10
+# default = 10
+
+#--------------------------------------------------------------------
+# STOMATE_IPCC_OUTPUT_FILE
+# This file is going to be created by the model
+#    and will contain the output from the model.
+#    This file is a truly COADS compliant netCDF file.
+#    It will be generated by the hist software from
+#    the IOIPSL package.
+# Name of file in which STOMATE's output is going
+# to be written
+STOMATE_IPCC_OUTPUT_FILE = stomate_ipcc_history.nc
+# default = stomate_ipcc_history.nc
+
+# STOMATE_IPCC_HIST_DT
+# Time step of the STOMATE IPCC history file
+# STOMATE IPCC history time step (d)
+STOMATE_IPCC_HIST_DT = 0.
+# default = 0.
+
+# Write frequency for output files (SECHIBA in seconds et
+# STOMATE in days) :
+#---------------------------------------------------------------------
+# Frequency in seconds at which to WRITE output
+# This variables gives the frequency the output of
+#  the model should be written into the netCDF file.
+#  It does not affect the frequency at which the
+#  operations such as averaging are done.
+WRITE_STEP = 86400.0
+# default = 86400.0
+
+# Frequency in seconds at which to WRITE output
+# If SECHIBA_HISTFILE2
+# This variables gives the frequency the output 2 of
+#   the model should be written into the netCDF file.
+#   It does not affect the frequency at which the
+#   operations such as averaging are done.
+#   That is IF the coding of the calls to histdef
+#   are correct !
+WRITE_STEP2 = 1800.0
+# default = 1800.0
+
+# STOMATE history time step (d)
+# Time step of the STOMATE history file
+# Care : this variable must be higher than DT_SLOW
+STOMATE_HIST_DT = 10.
+# default = 10.
+
+#**************************************************************************
+#                             Area location
+#**************************************************************************
+#  The model will use the smalest regions from
+#  region specified here and the one of the forcing file.
+
+# Western limit of region
+# Western limit of the region we are 
+#  interested in. Between -180 and +180 degrees
+LIMIT_WEST = -180.
+# default = -180.
+
+# Eastern limit of region
+# Eastern limit of the region we are
+#  interested in. Between -180 and +180 degrees
+LIMIT_EAST = 180.
+# default = 180.
+
+# Northern limit of region
+# Northern limit of the region we are
+#  interested in. Between +90 and -90 degrees
+LIMIT_NORTH = 90.
+# default = 90.
+
+# Southern limit of region
+# Southern limit of the region we are
+#  interested in. Between 90 and -90 degrees
+LIMIT_SOUTH = -90.
+# default = -90.
+
+##**************************************************************************
+#                       Simulation parameters
+#**************************************************************************
+
+# method of forcing
+# A method is proposed by which the first atmospheric
+#   level is not directly forced by observations but
+#   relaxed with a time constant towards observations.
+#   For the moment the methods tends to smooth too much
+#   the diurnal cycle and introduces a time shift.
+#   A more sophisticated method is needed.
+RELAXATION = n
+# default = n
+
+# Time constant of the relaxation layer RELAXATION
+# The time constant associated to the atmospheric
+#  conditions which are going to be computed
+#  in the relaxed layer. To avoid too much
+#  damping the value should be larger than 1000.
+RELAX_A = 1000.
+# default = 1000.0
+
+# Height at which T and Q are given
+# The atmospheric variables (temperature and specific
+#  humidity) are measured at a specific level.
+#  The height of this level is needed to compute
+#  correctly the turbulent transfer coefficients.
+#  Look at the description of the forcing
+#  DATA for the correct value.
+HEIGHT_LEV1 = 2.0
+# default  = 2.0
+
+# Height at which the wind is given
+# The height at which wind is needed to compute
+#  correctly the turbulent transfer coefficients.
+HEIGHT_LEVW = 10.0
+# default  = 10.0
+
+#---------------------------------------------------------------------
+# Weather generator or not :
+#---------------------------------------------------------------------
+
+# Allow weather generator to create data.
+# This flag allows the forcing-reader to generate
+#  synthetic data if the data in the file is too sparse
+#  and the temporal resolution would not be enough to
+#  run the model.
+ALLOW_WEATHERGEN = n
+# default = n
+
+# North-South Resolution
+# If ALLOW_WEATHERGEN
+# North-South Resolution of the region we are
+#  interested in. In degrees
+MERID_RES = 2.
+# default = 2.
+
+# East-West Resolution
+# If ALLOW_WEATHERGEN
+# East-West Resolution of the region we are
+#  interested in. In degrees
+ZONAL_RES = 2.
+# default = 2.
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+# If this is set to 1, the weather generator
+#   uses the monthly mean values for daily means.
+#   If it is set to 0, the weather generator
+#   uses statistical relationships to derive daily
+#   values from monthly means.
+IPPREC = 0
+# default = 0
+
+# Interpolation  or not IF split is larger than 1
+# Choose IF you wish to interpolate linearly or not.
+NO_INTER = y
+INTER_LIN = n
+# default :
+#  NO_INTER = y
+#  INTER_LIN = n
+
+# Exact monthly precipitation
+# If ALLOW_WEATHERGEN
+# If this is set to y, the weather generator
+#   will generate pseudo-random precipitations
+#   whose monthly mean is exactly the prescribed one.
+#   In this case, the daily precipitation (for rainy
+#   days) is constant (that is, some days have 0 precip,
+#   the other days have precip = Precip_month/n_precip,
+#   where n_precip is the prescribed number of rainy days
+#   per month).
+WEATHGEN_PRECIP_EXACT = n
+# default = n
+
+# Calling frequency of weather generator (s)
+# Determines how often the weather generator
+#  is called (time step in s). Should be equal
+#  to or larger than Sechiba's time step (say,
+#  up to 6 times Sechiba's time step or so).
+DT_WEATHGEN = 1800.
+# default = 1800.
+
+# Conserve net radiation in the forcing
+# When the interpolation is used the net radiation
+#  provided by the forcing is not conserved anymore.
+#  This should be avoided and thus this option should
+#  be TRUE (y).
+#  This option is not used for short-wave if the
+#  time-step of the forcing is longer than an hour.
+#  It does not make sense to try and reconstruct
+#  a diurnal cycle and at the same time conserve the 
+#  incoming solar radiation.
+NETRAD_CONS = y
+# default = y
+
+# Write weather from generator into a forcing file
+# This flag makes the weather generator dump its
+#  generated weather into a forcing file which can
+#  then be used to get the same forcing on different
+#  machines. This only works correctly if there is
+#  a restart file (otherwise the forcing at the first
+#  time step is slightly wrong).
+DUMP_WEATHER = n
+# default = n
+
+# Name of the file that contains
+#  the weather from generator
+# If DUMP_WEATHER
+DUMP_WEATHER_FILE = weather_dump.nc
+# default = 'weather_dump.nc'
+
+# Dump weather data on gathered grid
+# If 'y', the weather data are gathered
+#  for all land points.
+# If DUMP_WEATHER
+DUMP_WEATHER_GATHERED = y
+# default = y
+
+
+# Read Orbital Parameters
+
+# Eccentricity Effect
+# Use prescribed values
+# IF ALLOW_WEATHERGEN
+ECCENTRICITY = 0.016724
+# default = 0.016724
+
+# Longitude of perihelie
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+PERIHELIE = 102.04
+# default = 102.04
+
+# Use prescribed values
+# If ALLOW_WEATHERGEN
+OBLIQUITY = 23.446
+# default = 23.446
+
+#**************************************************************************
+# length of simulation :
+#---------------------------------------------------------------------
+# Length of the integration in time.
+# Length of integration. By default the entire length
+#        of the forcing is used. The FORMAT of this date can
+#        be either of the following :
+# n   : time step n within the forcing file
+# nS  : n seconds after the first time-step in the file
+# nD  : n days after the first time-step
+# nM  : n month after the first time-step (year of 365 days)
+# nY  : n years after the first time-step (year of 365 days)
+#        Or combinations :
+# nYmM: n years and m month
+TIME_LENGTH = default
+# default = depend on the time length and the number of time step in forcing file
+#         = itau_len = itau_fin-itau_dep
+
+
+# split time step :
+#---------------------------------------------------------------------
+
+# Splits the timestep imposed by the forcing
+# With this value the time step of the forcing
+#  will be devided. In principle this can be run
+#  in explicit mode but it is strongly suggested
+#  to use the implicit method so that the
+#  atmospheric forcing has a smooth evolution.
+SPLIT_DT = 12
+# default = 12
+
+#  Time in the forcing file at which the model is started.
+#  This time give the point in time at which the model
+#  should be started. 
+#  If exists, the date of the restart file is use.
+#  The FORMAT of this date can be either of the following :
+#  n   : time step n within the forcing file
+#  nS  : n seconds after the first time-step in the file
+#  nD  : n days after the first time-step
+#  nM  : n month after the first time-step (year of 365 days)
+#  nY  : n years after the first time-step (year of 365 days)
+#      Or combinations :
+#  nYmM: n years and m month
+TIME_SKIP = 0
+# default = 0
+
+# Number of time steps per year for carbon spinup.
+FORCESOIL_STEP_PER_YEAR = 12
+# default = 12
+
+# Number of years saved for carbon spinup.
+FORCESOIL_NB_YEAR = 1
+# default = 1
+
+# Spread the precipitation.
+# Spread the precipitaiton over n steps of the splited forcing time step. 
+#  This is ONLY applied if the forcing time step has been splited (SPLIT_DT).
+#  If the value indicated is greater than SPLIT_DT, SPLIT_DT is used for it.
+SPRED_PREC = 1
+# default = 1
+
+
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate STOMATE?
+# set to TRUE if STOMATE is to be activated
+STOMATE_OK_STOMATE = n
+# default = n
+
+# Activate DGVM?
+# set to TRUE if Dynamic Vegetation DGVM is to be activated
+STOMATE_OK_DGVM = n
+# default = n
+
+# Activate CO2?
+# set to TRUE if photosynthesis is to be activated
+STOMATE_OK_CO2 = n
+# default = n
+
+# Flag to force the value of atmospheric CO2 for vegetation.
+# If this flag is set to true, the ATM_CO2 parameter is used
+#  to prescribe the atmospheric CO2.
+# This Flag is only use in couple mode.
+FORCE_CO2_VEG = FALSE
+# default = FALSE
+
+# Value for atm CO2.
+# If FORCE_CO2_VEG (in not forced mode)
+# Value to prescribe the atm CO2.
+#  For pre-industrial simulations, the value is 286.2 .
+#  348. for 1990 year.
+ATM_CO2 = 350.
+# default = 350.
+
+
+# Index of grid point for online diagnostics
+# This is the index of the grid point which will be used for online diagnostics.
+STOMATE_DIAGPT = 1
+# default = 1
+
+# constant tree mortality
+# If yes, then a constant mortality is applied to trees. 
+#  Otherwise, mortality is a function of the trees' 
+#  vigour (as in LPJ).
+LPJ_GAP_CONST_MORT = y
+# default = y
+
+# no fire allowed
+# With this variable, you can allow or not
+#  the estimation of CO2 lost by fire
+FIRE_DISABLE = n
+# default = n
+
+#
+#**************************************************************************
+#          NEW OPTIONS FOR RESTARTS in versions up to 1.9.3
+#**************************************************************************
+#
+## sechiba
+soilcap=n
+soilflx=n
+shumdiag=n
+runoff=n
+drainage=n
+
+## diffuco
+raero=n
+qsatt=n
+cdrag=n
+
+## enerbil
+evapot_corr=n
+temp_sol_new=n
+
+## hydrolc
+dss=n
+hdry=n
+
+## thermosoil
+cgrnd=n
+dgrnd=n
+z1=n
+pcapa=n
+pcapa_en=n
+pkappa=n
+zdz1=n
+zdz2=n
+temp_sol_beg=n
+
+# parameters describing the surface (vegetation + soil) :
+#---------------------------------------------------------------------
+#
+# Should the vegetation be prescribed
+# This flag allows the user to impose a vegetation distribution
+#  and its characterisitcs. It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_VEG = n
+# default = n
+
+# Flag to use old "interpolation" of vegetation map.
+# IF NOT IMPOSE_VEG and NOT LAND_USE
+#  If you want to recover the old (ie orchidee_1_2 branch) 
+#   "interpolation" of vegetation map.
+SLOWPROC_VEGET_OLD_INTERPOL = n
+# default = n
+
+# Vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEG__01 = 0.2
+SECHIBA_VEG__02 = 0.0
+SECHIBA_VEG__03 = 0.0
+SECHIBA_VEG__04 = 0.0
+SECHIBA_VEG__05 = 0.0
+SECHIBA_VEG__06 = 0.0
+SECHIBA_VEG__07 = 0.0
+SECHIBA_VEG__08 = 0.0
+SECHIBA_VEG__09 = 0.0
+SECHIBA_VEG__10 = 0.8
+SECHIBA_VEG__11 = 0.0
+SECHIBA_VEG__12 = 0.0
+SECHIBA_VEG__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# Maximum vegetation distribution within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of vegetation is read from the restart file. If
+#  it is not found there we will use the values provided here.
+SECHIBA_VEGMAX__01 = 0.2
+SECHIBA_VEGMAX__02 = 0.0
+SECHIBA_VEGMAX__03 = 0.0
+SECHIBA_VEGMAX__04 = 0.0
+SECHIBA_VEGMAX__05 = 0.0
+SECHIBA_VEGMAX__06 = 0.0
+SECHIBA_VEGMAX__07 = 0.0
+SECHIBA_VEGMAX__08 = 0.0
+SECHIBA_VEGMAX__09 = 0.0
+SECHIBA_VEGMAX__10 = 0.8
+SECHIBA_VEGMAX__11 = 0.0
+SECHIBA_VEGMAX__12 = 0.0
+SECHIBA_VEGMAX__13 = 0.0
+# default = 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0
+
+# LAI for all vegetation types (0-dim mode)
+# If IMPOSE_VEG
+# The maximum LAI used in the 0dim mode. The values should be found
+#  in the restart file. The new values of LAI will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SECHIBA_LAI__01 = 0.
+SECHIBA_LAI__02 = 8.
+SECHIBA_LAI__03 = 8.
+SECHIBA_LAI__04 = 4.
+SECHIBA_LAI__05 = 4.5
+SECHIBA_LAI__06 = 4.5
+SECHIBA_LAI__07 = 4.
+SECHIBA_LAI__08 = 4.5
+SECHIBA_LAI__09 = 4.
+SECHIBA_LAI__10 = 2.
+SECHIBA_LAI__11 = 2.
+SECHIBA_LAI__12 = 2.
+SECHIBA_LAI__13 = 2.
+# default = 0., 8., 8., 4., 4.5, 4.5, 4., 4.5, 4., 2., 2., 2., 2.
+
+# Height for all vegetation types (m)
+# If IMPOSE_VEG
+# The height used in the 0dim mode. The values should be found
+#  in the restart file. The new values of height will be computed anyway
+#  at the end of the current day. The need for this variable is caused
+#  by the fact that the model may stop during a day and thus we have not
+#  yet been through the routines which compute the new surface conditions.
+SLOWPROC_HEIGHT__01 = 0.
+SLOWPROC_HEIGHT__02 = 50.
+SLOWPROC_HEIGHT__03 = 50.
+SLOWPROC_HEIGHT__04 = 30.
+SLOWPROC_HEIGHT__05 = 30.
+SLOWPROC_HEIGHT__06 = 30.
+SLOWPROC_HEIGHT__07 = 20.
+SLOWPROC_HEIGHT__08 = 20.
+SLOWPROC_HEIGHT__09 = 20.
+SLOWPROC_HEIGHT__10 = .2
+SLOWPROC_HEIGHT__11 = .2
+SLOWPROC_HEIGHT__12 = .4
+SLOWPROC_HEIGHT__13 = .4
+# default = 0., 30., 30., 20., 20., 20., 15., 15., 15., .5, .6, 1.0, 1.0
+
+
+# Fraction of the 3 soil types (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction for the 3 soil types
+#  in the mesh in the following order : sand loam and clay.
+SOIL_FRACTIONS__01 = 0.28
+SOIL_FRACTIONS__02 = 0.52
+SOIL_FRACTIONS__03 = 0.20
+# default = 0.28, 0.52, 0.20
+
+# Temperature used for the initial guess of LAI
+# If there is no LAI in the restart file, we may need
+#  a temperature that is used to guess the initial LAI.
+SLOWPROC_LAI_TEMPDIAG = 280.
+# default = 280.
+
+# Soil level (m) used for canopy development 
+# If STOMATE is not activated.
+# The temperature at this soil depth is used to determine the LAI when
+#   STOMATE is not activated.
+SECHIBA_ZCANOP = 0.5
+# default = 0.5
+
+# Fraction of other surface types within the mesh (0-dim mode)
+# If IMPOSE_VEG
+# The fraction of ice, lakes, etc. is read from the restart file. If
+#  it is not found there we will use the values provided here.
+#  For the moment, there is only ice.
+SECHIBA_FRAC_NOBIO = 0.0
+# default = 0.0
+
+# Fraction of the clay fraction (0-dim mode)
+# If IMPOSE_VEG
+# Determines the fraction of clay in the grid box.
+CLAY_FRACTION = 0.2
+# default = 0.2
+
+# Should the surface parameters be prescribed
+# This flag allows the user to impose the surface parameters
+#  (Albedo Roughness and Emissivity). It is espacially interesting for 0D
+#  simulations. On the globe it does not make too much sense as
+#  it imposes the same vegetation everywhere
+IMPOSE_AZE = n
+# default = n
+
+# Emissivity of the surface for LW radiation
+# If IMPOSE_AZE
+# The surface emissivity used for compution the LE emission
+#  of the surface in a 0-dim version. Values range between 
+#  0.97 and 1.. The GCM uses 0.98.
+CONDVEG_EMIS = 1.0
+# default = 1.0
+
+# SW visible albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in visible wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBVIS = 0.25
+# default = 0.25
+
+# SW near infrared albedo for the surface
+# If IMPOSE_AZE
+# Surface albedo in near infrared wavelengths to be used 
+#  on the point if a 0-dim version of SECHIBA is used. 
+#  Look at the description of the forcing data for 
+#  the correct value.
+CONDVEG_ALBNIR = 0.25
+# default = 0.25
+
+# Average method for z0
+# If this flag is set to true (y) then the neutral Cdrag
+#  is averaged instead of the log(z0). This should be
+#  the prefered option. We still wish to keep the other
+#  option so we can come back if needed. If this is
+#  desired then one should set Z0CDRAG_AVE = n
+Z0CDRAG_AVE = y
+# default = y
+
+# Surface roughness (m)
+# If IMPOSE_AZE
+# Surface rougness to be used on the point if a 0-dim version
+#  of SECHIBA is used. Look at the description of the forcing  
+#  data for the correct value.
+CONDVEG_Z0 = 0.15
+# default = 0.15_stnd
+
+# Height to be added to the height of the first level (m)
+# If IMPOSE_AZE
+# ORCHIDEE assumes that the atmospheric level height is counted
+#  from the zero wind level. Thus to take into account the roughness
+#  of tall vegetation we need to correct this by a certain fraction
+#  of the vegetation height. This is called the roughness height in
+#  ORCHIDEE talk.
+ROUGHHEIGHT = 0.0
+# default = 0.0
+
+# The snow albedo used by SECHIBA
+# This option allows the user to impose a snow albedo.
+#  Default behaviour is to use the model of snow albedo
+#  developed by Chalita (1993).
+CONDVEG_SNOWA = default
+# default = use the model of snow albedo developed by Chalita
+
+# Switch bare soil albedo dependent (if TRUE) on soil wetness
+# If TRUE, the model for bare soil albedo is the old formulation.
+#  Then it depend on the soil dry or wetness. If FALSE, it is the 
+#  new computation that is taken, it is only function of soil color.
+ALB_BARE_MODEL = FALSE
+# default = FALSE
+
+# Initial snow mass if not found in restart
+# The initial value of snow mass if its value is not found
+#   in the restart file. This should only be used if the model is 
+#   started without a restart file.
+HYDROL_SNOW = 0.0
+# default = 0.0
+
+
+# Initial snow age if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOWAGE = 0.0
+# default = 0.0
+
+# Initial snow amount on ice, lakes, etc. if not found in restart
+# The initial value of snow if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO = 0.0
+# default = 0.0
+
+# Initial snow age on ice, lakes, etc. if not found in restart
+# The initial value of snow age if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_SNOW_NOBIO_AGE = 0.0
+# default = 0.0
+
+# Initial dry soil height if not found in restart for ORCHIDEE_1.3 to 1.5 Tags only.
+# The initial value of dry soil height if its value is not found
+# in the restart file. This should only be used if the model is 
+# started without a restart file.
+HYDROL_HDRY = 0.0
+# default = 0.0
+
+# Initial soil moisture stress if not found in restart
+# The initial value of soil moisture stress if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_HUMR = 1.0
+# default = 1.0
+
+# Total depth of soil reservoir
+HYDROL_SOIL_DEPTH = 2.
+# default = 2.
+
+# Root profile
+# Default values were defined for 2 meters soil depth.
+# For 4 meters soil depth, you may use those ones :
+# 5., .4, .4, 1., .8, .8, 1., 1., .8, 4., 1., 4., 1.
+HYDROL_HUMCSTE = 5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+# default =  5., .8, .8, 1., .8, .8, 1., 1., .8, 4., 4., 4., 4.
+
+# Initial restart deep soil moisture if not found in restart
+# The initial value of deep soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. Default behaviour is a saturated soil.
+HYDROL_BQSB = default
+# default = Maximum quantity of water (Kg/M3) * Total depth of soil reservoir = 150. * 2
+
+# Initial upper soil moisture if not found in restart
+# The initial value of upper soil moisture if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_GQSB = 0.0
+# default = 0.0
+
+# Initial upper reservoir depth if not found in restart
+# The initial value of upper reservoir depth if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_DSG = 0.0
+# default = 0.0
+
+# Initial dry soil above upper reservoir if not found in restart
+# The initial value of dry soil above upper reservoir if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file. The default behaviour
+#  is to compute it from the variables above. Should be OK most of 
+#  the time.
+HYDROL_DSP = default
+# default = Total depth of soil reservoir - HYDROL_BQSB / Maximum quantity of water (Kg/M3) = 0.0
+
+# Initial water on canopy if not found in restart
+# The initial value of moisture on canopy if its value 
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_QSV = 0.0
+# default = 0.0
+
+# Soil moisture on each soil tile and levels
+# The initial value of mc if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+HYDROL_MOISTURE_CONTENT = 0.3
+# default = 0.3
+
+# US_NVM_NSTM_NSLM
+# The initial value of us (relative moisture) if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+US_INIT = 0.0
+# default = 0.0
+
+# Coefficient for free drainage at bottom
+# The initial value of free drainage if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+FREE_DRAIN_COEF = 1.0, 1.0, 1.0
+# default = 1.0, 1.0, 1.0
+
+# Bare soil evap on each soil if not found in restart
+# The initial value of bare soils evap if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+EVAPNU_SOIL = 0.0
+# default = 0.0
+
+# Initial temperature if not found in restart
+# The initial value of surface temperature if its value is not found
+#  in the restart file. This should only be used if the model is 
+#  started without a restart file.
+ENERBIL_TSURF = 280.
+# default = 280.
+
+# Initial Soil Potential Evaporation
+# The initial value of soil potential evaporation if its value 
+#  is not found in the restart file. This should only be used if
+#  the model is started without a restart file. 
+ENERBIL_EVAPOT = 0.0
+# default = 0.0
+
+# Initial soil temperature profile if not found in restart
+# The initial value of the temperature profile in the soil if 
+#   its value is not found in the restart file. This should only 
+#   be used if the model is started without a restart file. Here
+#   we only require one value as we will assume a constant 
+#   throughout the column.
+THERMOSOIL_TPRO = 280.
+# default = 280.
+
+# Initial leaf CO2 level if not found in restart
+# The initial value of leaf_ci if its value is not found
+#  in the restart file. This should only be used if the model is
+#  started without a restart file.
+DIFFUCO_LEAFCI = 233.
+# default = 233.
+
+
+# Keep cdrag coefficient from gcm.
+# Set to .TRUE. if you want q_cdrag coming from GCM.
+#  Keep cdrag coefficient from gcm for latent and sensible heat fluxes.
+#  TRUE if q_cdrag on initialization is non zero (FALSE for off-line runs).
+CDRAG_FROM_GCM = n
+# default =  IF q_cdrag == 0 ldq_cdrag_from_gcm = .FALSE. ELSE .TRUE.
+
+
+# Artificial parameter to increase or decrease canopy resistance
+# Add from Nathalie - the 28 of March 2006 - advice from Fred Hourdin
+# By PFT.
+RVEG_PFT = 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.
+# default = 1.
+
+
+# Interception reservoir coefficient.
+# Transforms leaf area index into size of interception reservoir
+#  for slowproc_derivvar or stomate.
+SECHIBA_QSINT = 0.1
+# default = 0.1
+
+#**************************************************************************
+# LAI
+#**************************************************************************
+
+# Read the LAI map
+# It is possible to read a 12 month LAI map which will
+#  then be interpolated to daily values as needed.
+#  If n => type_of_lai (constant_veg.f90)
+#     - mean    : lai(ji,jv) = undemi * (llaimax(jv) + llaimin(jv))
+#     - inter   : llaimin(jv) + tempfunc(stempdiag(ji,lcanop)) * (llaimax(jv) - llaimin(jv))
+LAI_MAP = n
+# default = n
+
+# Name of file from which the vegetation map is to be read
+# If LAI_MAP
+# The name of the file to be opened to read the LAI
+#  map is to be given here. Usualy SECHIBA runs with a 5kmx5km
+#  map which is derived from a Nicolas VIOVY one. 
+LAI_FILE = lai2D.nc
+# default = ../surfmap/lai2D.nc
+
+# Flag to use old "interpolation" of LAI
+# If LAI_MAP
+# If you want to recover the old (ie orchidee_1_2 branch) 
+# "interpolation" of LAI map.
+SLOWPROC_LAI_OLD_INTERPOL = n
+# default = n
+
+#**************************************************************************
+# LAND_USE
+#**************************************************************************
+
+# Read a land_use vegetation map
+# pft values are needed, max time axis is 293
+LAND_USE = y
+# default = n
+
+# Year of the land_use vegetation map readed
+# year off the pft map.
+# default is 133 for year 1982  (as 1982 - 1850 + 1 = 133)
+# If LAND_USE
+VEGET_YEAR = 133
+# default = 133
+
+# booleen to indicate that a new LAND USE file will be used (since 1.9.5 version).
+# The parameter is used to bypass veget_year count 
+# and reinitialize it with VEGET_YEAR parameter.
+# Then it is possible to change LAND USE file.
+# If LAND_USE
+VEGET_REINIT = n
+# default = n
+
+# Update vegetation frequency (since 2.0 version)
+# The veget datas will be update each this time step.
+# If LAND_USE
+VEGET_UPDATE = 0Y
+# default = 1Y
+
+# treat land use modifications
+# With this variable, you can use a Land Use map
+# to simulate anthropic modifications such as   
+# deforestation.                                
+# If LAND_USE
+LAND_COVER_CHANGE = y
+# default = y
+
+#**************************************************************************
+
+# agriculture allowed?
+# With this variable, you can determine
+#  whether agriculture is allowed
+AGRICULTURE = y
+# default = y
+
+# Harvert model for agricol PFTs.
+# Compute harvest above ground biomass for agriculture.
+# Change daily turnover.
+HARVEST_AGRI = y
+# default = y
+
+# herbivores allowed?
+# With this variable, you can activate herbivores 
+HERBIVORES = n
+# default = n
+
+# treat expansion of PFTs across a grid cell?
+# With this variable, you can determine
+#  whether we treat expansion of PFTs across a
+#  grid cell.
+TREAT_EXPANSION = n
+# default = n
+
+#**************************************************************************
+
+# Time within the day simulated
+# This is the time spent simulating the current day. This variable is
+#  prognostic as it will trigger all the computations which are
+#  only done once a day.
+SECHIBA_DAY = 0.0
+# default = 0.0
+
+# Time step of STOMATE and other slow processes
+# Time step (s) of regular update of vegetation
+#  cover, LAI etc. This is also the time step
+#  of STOMATE.
+DT_SLOW = 86400.
+# default = un_jour = 86400.
+
+#**************************************************************************
+
+# Allows to switch on the multilayer hydrology of CWRR
+# This flag allows the user to decide if the vertical
+#  hydrology should be treated using the multi-layer 
+#  diffusion scheme adapted from CWRR by Patricia de Rosnay.
+#  by default the Choisnel hydrology is used.
+HYDROL_CWRR = n
+# default = n
+
+# do horizontal diffusion?
+# If TRUE, then water can diffuse horizontally between
+#  the PFTs' water reservoirs.
+HYDROL_OK_HDIFF = n
+# default = n
+ 
+
+# time scale (s) for horizontal diffusion of water
+# If HYDROL_OK_HDIFF
+# Defines how fast diffusion occurs horizontally between
+#  the individual PFTs' water reservoirs. If infinite, no
+#  diffusion.
+HYDROL_TAU_HDIFF = 86400.
+# default = 86400.
+
+# Percent of precip that is not intercepted by the canopy (only for TAG 1.6).
+# During one rainfall event, PERCENT_THROUGHFALL% of the incident rainfall
+#  will get directly to the ground without being intercepted.
+PERCENT_THROUGHFALL = 30.
+# default = 30.
+
+# Percent by PFT of precip that is not intercepted by the canopy (since TAG 1.8).
+# During one rainfall event, PERCENT_THROUGHFALL_PFT% of the incident rainfall
+#  will get directly to the ground without being intercepted, for each PFT..
+PERCENT_THROUGHFALL_PFT = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+# default = 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30.
+
+# Decides if we route the water or not
+# This flag allows the user to decide if the runoff
+#  and drainage should be routed to the ocean
+#  and to downstream grid boxes.
+RIVER_ROUTING = n
+# default = n
+
+# Name of file which contains the routing information
+# The file provided here should allow the routing module to
+#  read the high resolution grid of basins and the flow direction 
+#  from one mesh to the other.
+ROUTING_FILE = routing.nc
+# default = routing.nc
+
+# Time step of the routing scheme
+# If RIVER_ROUTING
+# This values gives the time step in seconds of the routing scheme. 
+#   It should be multiple of the main time step of ORCHIDEE. One day
+#   is a good value.
+ROUTING_TIMESTEP = 86400
+# default = 86400
+
+# Number of rivers 
+# If RIVER_ROUTING
+# This parameter chooses the number of largest river basins
+#  which should be treated as independently as rivers and not
+#  flow into the oceans as diffusion coastal flow.
+ROUTING_RIVERS = 50
+# default = 50
+
+# Should we compute an irrigation flux 
+# This parameters allows the user to ask the model
+#  to compute an irigation flux. This performed for the
+#  on very simple hypothesis. The idea is to have a good
+#  map of irrigated areas and a simple function which estimates
+#  the need to irrigate.
+DO_IRRIGATION = n
+# default = n
+
+# Name of file which contains the map of irrigated areas
+# If IRRIGATE
+# The name of the file to be opened to read the field
+#  with the area in m^2 of the area irrigated within each
+#  0.5 0.5 deg grid box. The map currently used is the one
+#  developed by the Center for Environmental Systems Research 
+#  in Kassel (1995).
+IRRIGATION_FILE = irrigated.nc
+# default = irrigated.nc
+
+# Should we include floodplains 
+# This parameters allows the user to ask the model
+#  to take into account the flood plains and return 
+#  the water into the soil moisture. It then can go 
+#  back to the atmopshere. This tried to simulate 
+#  internal deltas of rivers.
+DO_FLOODPLAINS = n
+# default = n
+
+#**************************************************************************
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/stomate.def
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/stomate.def	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/PARAM/stomate.def	(revision 405)
@@ -0,0 +1,206 @@
+#
+#**************************************************************************
+#                    Namelist for STOMATE
+#**************************************************************************
+#
+#**************************************************************************
+#          OPTIONS NOT SET
+#**************************************************************************
+#
+#
+#**************************************************************************
+#          Management of display in the run of STOMATE
+#**************************************************************************
+
+# Model chatting level
+# level of online diagnostics in STOMATE (0-4)
+# With this variable, you can determine how much online information STOMATE
+#  gives during the run. 0 means virtually no info.
+BAVARD = 1
+# default = 1
+
+#**************************************************************************
+#          Files : incoming / forcing / restart /output
+#**************************************************************************
+# Ancillary files :
+#---------------------------------------------------------------------
+
+
+# Name of file from which the reference
+# The name of the file to be opened to read
+#  temperature is read
+#  the reference surface temperature.
+#  The data from this file is then interpolated
+#  to the grid of the model.
+#  The aim is to get a reference temperature either
+#  to initialize the corresponding prognostic model
+#  variable correctly (ok_dgvm = TRUE) or to impose it
+#  as boundary condition (ok_dgvm = FALSE)
+REFTEMP_FILE = reftemp.nc
+# default = reftemp.nc
+# Input and output restart file for STOMATE :
+#---------------------------------------------------------------------
+
+# Name of restart to READ for initial conditions of STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened of STOMATE
+#   to extract the initial values of all prognostic values of STOMATE.
+STOMATE_RESTART_FILEIN = NONE
+# default = NONE
+
+# Name of restart files to be created by STOMATE
+# If STOMATE_OK_STOMATE || STOMATE_WATCHOUT
+# This is the name of the file which will be opened
+#        to write the final values of all prognostic values
+#        of STOMATE.
+STOMATE_RESTART_FILEOUT = stomate_rest_out.nc
+# default = stomate_restart.nc
+
+# Forcing files for TESTSTOMATE and FORCESOIL
+#---------------------------------------------------------------------
+
+# Name of STOMATE's forcing file
+# Name that will be given to STOMATE's offline forcing file
+STOMATE_FORCING_NAME = stomate_forcing.nc
+#default = NONE
+
+# Size of STOMATE forcing data in memory (MB)
+# This variable determines how many
+#  forcing states will be kept in memory.
+#  Must be a compromise between memory
+#  use and frequeny of disk access.
+STOMATE_FORCING_MEMSIZE = 50
+# default = 50
+
+# Name of STOMATE's carbon forcing file
+# Name that will be given to STOMATE's carbon offline forcing file
+STOMATE_CFORCING_NAME = stomate_Cforcing.nc
+# default = NONE
+
+
+# Produced forcing file name :
+#---------------------------------------------------------------------
+# STOMATE does minimum service
+# set to TRUE if you want STOMATE to read
+#  and write its start files and keep track
+#  of longer-term biometeorological variables.
+#  This is useful if OK_STOMATE is not set,
+#  but if you intend to activate STOMATE later.
+#  In that case, this run can serve as a 
+#  spinup for longer-term biometeorological
+#  variables.
+STOMATE_WATCHOUT = n
+# default = n
+
+
+# Output file name :
+#---------------------------------------------------------------------
+
+# Name of file in which STOMATE's output is going to be written
+# This file is going to be created by the model
+#  and will contain the output from the model.
+#  This file is a truly COADS compliant netCDF file.
+#  It will be generated by the hist software from
+#  the IOIPSL package.
+STOMATE_OUTPUT_FILE = stomate_history.nc
+# default = stomate_history.nc
+
+# Write levels for outputs files (number of variables) :
+#---------------------------------------------------------------------
+
+# STOMATE history output level (0..10)
+#  0: nothing is written; 10: everything is written
+STOMATE_HISTLEVEL = 10
+# default = 10
+
+# STOMATE_IPCC_OUTPUT_FILE
+# This file is going to be created by the model
+#    and will contain the output from the model.
+#    This file is a truly COADS compliant netCDF file.
+#    It will be generated by the hist software from
+#    the IOIPSL package.
+# Name of file in which STOMATE's output is going
+# to be written
+STOMATE_IPCC_OUTPUT_FILE = stomate_ipcc_history.nc
+# default = stomate_ipcc_history.nc
+
+# STOMATE_IPCC_HIST_DT
+# Time step of the STOMATE IPCC history file
+# STOMATE IPCC history time step (d)
+STOMATE_IPCC_HIST_DT = 0.
+# default = 0.
+
+# Write frequency for output files (STOMATE in days) :
+#---------------------------------------------------------------------
+
+# STOMATE history time step (d)
+# Time step of the STOMATE history file
+# Care : this variable must be higher than DT_SLOW
+STOMATE_HIST_DT = 10.
+# default = 10.
+
+
+#---------------------------------------------------------------------
+# FORCESOIL CARBON spin up parametrization
+#---------------------------------------------------------------------
+
+# Number of time steps per year for carbon spinup.
+FORCESOIL_STEP_PER_YEAR = 12
+# default = 12
+
+# Number of years saved for carbon spinup.
+FORCESOIL_NB_YEAR = 1
+# default = 1
+
+#---------------------------------------------------------------------
+# Parametrization :
+#---------------------------------------------------------------------
+
+# Activate STOMATE?
+# set to TRUE if STOMATE is to be activated
+STOMATE_OK_STOMATE = n
+# default = n
+
+# Activate DGVM?
+# set to TRUE if Dynamic Vegetation DGVM is to be activated
+STOMATE_OK_DGVM = n
+# default = n
+
+# Index of grid point for online diagnostics
+# This is the index of the grid point which will be used for online diagnostics.
+STOMATE_DIAGPT = 1
+# default = 1
+
+# constant tree mortality
+# If yes, then a constant mortality is applied to trees. 
+#  Otherwise, mortality is a function of the trees' 
+#  vigour (as in LPJ).
+LPJ_GAP_CONST_MORT = y
+# default = y
+
+# no fire allowed
+# With this variable, you can allow or not
+#  the estimation of CO2 lost by fire
+FIRE_DISABLE = n
+# default = n
+
+#**************************************************************************
+
+# Harvert model for agricol PFTs.
+# Compute harvest above ground biomass for agriculture.
+# Change daily turnover.
+HARVEST_AGRI = y
+# default = y
+
+# herbivores allowed?
+# With this variable, you can activate herbivores 
+HERBIVORES = n
+# default = n
+
+# treat expansion of PFTs across a grid cell?
+# With this variable, you can determine
+#  whether we treat expansion of PFTs across a
+#  grid cell.
+TREAT_EXPANSION = n
+# default = n
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/POST/monitoring01_sechiba.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/POST/monitoring01_sechiba.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/POST/monitoring01_sechiba.cfg	(revision 405)
@@ -0,0 +1,67 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann@cea.fr
+# $Date$
+# $Name$
+# $Revision$
+# History:
+# Modification:
+#**************************************************************
+
+##################################################################################################################
+#-----------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#-----------------------------------------------------------------------------------------------------------------
+#
+#   field = name of the field to monitore 
+#   files patterns = pattern of the files used to monitore the field (must be discriminant) 
+#   files additionnal = additionnal files accessible by $FER_DATA
+#   operations = operations to calculate the field 
+#   title = variable title
+#   units = variable units
+#   calcul of area = expression to use for the weight average
+#
+# Notes:
+#   - Comment lines begin by # character.
+#   - Separator between fields is | character.
+#   - Operations must use the ferret syntax, if several files are used precise with the syntax d=x to refer to the x dataset.
+#     They must be enclosed by parenthesis if more than one variable is used.
+#   - files patterns,files additionnal,operations,title,units must be enclosed with character ". 
+#     Use "" if empty.
+#   - Fields will be presented through an html page with thumbnails global, north, south, land, ocean.
+#     Use a field name with one of these pattern to display it under the corresponding thumbnail.
+#
+##################################################################################################################
+
+color=E7FFAB
+smooth=12
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+evap_lands     | "evap"            |  ""               | "evap[d=1]"                      | "Evaporation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+temp_sol_lands | "temp_sol"        |  ""               | "temp_sol[d=1]"                  | "TSOL (LANDS)"                 | "K/d"    | "Areas[d=1]*Contfrac[d=1]"
+humidity_lands | "bqsb gqsb"       |  ""               | "(bqsb[d=1]+gqsb[d=2])"            | "Total Soil Moisture  (LANDS)" | "1"      | "Areas[d=1]*Contfrac[d=1]"
+fluxsens_lands | "fluxsens"        |  ""               | "fluxsens[d=1]"                  | "Sensible Flux (LANDS)"        | "W/m^2"  | "Areas[d=1]*Contfrac[d=1]"
+albedo_lands   | "alb_vis alb_nir" |  ""               | "((alb_vis[d=1]+alb_nir[d=2])*0.5)"| "Mean Albedo (LANDS)"          | "1"      | "Areas[d=1]*Contfrac[d=1]"
+subli_lands    | "subli"           |  ""               | "subli[d=1]"                     | "Sublimation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+snow_lands     | "snow"            |  ""               | "snow[d=1]"                      | "Snow Mass (LANDS)"            | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snownobio_lands | "snownobio"      |  ""               | "snownobio[d=1]"                 | "Snow Other Surfaces (LANDS)"  | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snowf_lands    | "snowf"           |  ""               | "snowf[d=1]"                     | "Snowfall (LANDS)"             | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+vegetn_lands   | "_vegetfrac"      |  ""               | "vegetfrac[d=1,K=2:9]"           | "veget natural (LANDS)"        | "1"      | "2"
+vegetg_lands   | "_vegetfrac"      |  ""               | "vegetfrac[d=1,K=10:11]"         | "veget natural grass (LANDS)"  | "1"      | "2"
+vegeta_lands   | "_vegetfrac"      |  ""               | "vegetfrac[d=1,K=12:13]"         | "veget agriculture (LANDS)"    | "1"      | "2"
+maxveget_lands | "maxvegetfrac"    |  ""               | "maxvegetfrac[d=1,K=12:13]"      | "vegetmax[pft=12,13] (LANDS)"      | "1"      | "2"
+lai_lands      | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=2:13]*maxvegetfrac[d=2,K=2:13])"  | "lai (LANDS)"      | "1"      | "2"
+# lai2_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=2]*maxvegetfrac[d=2,K=2])" | "lai (LANDS)"      | "1"      | "2"
+# lai3_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=3]*maxvegetfrac[d=2,K=3])" | "lai (LANDS)"      | "1"      | "2"
+# lai4_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=4]*maxvegetfrac[d=2,K=4])" | "lai (LANDS)"      | "1"      | "2"
+# lai5_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=5]*maxvegetfrac[d=2,K=5])" | "lai (LANDS)"      | "1"      | "2"
+# lai6_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=6]*maxvegetfrac[d=2,K=6])" | "lai (LANDS)"      | "1"      | "2"
+# lai7_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=7]*maxvegetfrac[d=2,K=7])" | "lai (LANDS)"      | "1"      | "2"
+# lai8_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=8]*maxvegetfrac[d=2,K=8])" | "lai (LANDS)"      | "1"      | "2"
+# lai9_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=9]*maxvegetfrac[d=2,K=9])" | "lai (LANDS)"      | "1"      | "2"
+# lai10_lands    | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=10]*maxvegetfrac[d=2,K=10])" | "lai (LANDS)"      | "1"      | "2"
+# lai11_lands    | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=11]*maxvegetfrac[d=2,K=11])" | "lai (LANDS)"      | "1"      | "2"
+# lai12_lands    | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=12]*maxvegetfrac[d=2,K=12])" | "lai (LANDS)"      | "1"      | "2"
+# lai13_lands    | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=13]*maxvegetfrac[d=2,K=13])" | "lai (LANDS)"      | "1"      | "2"
+#------------------------------------------------------------------------------------------------------------------------------------------------------
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/POST/monitoring01_sechiba_LAND_USE_and_LAI_PFTs.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/POST/monitoring01_sechiba_LAND_USE_and_LAI_PFTs.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/POST/monitoring01_sechiba_LAND_USE_and_LAI_PFTs.cfg	(revision 405)
@@ -0,0 +1,79 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann@cea.fr
+# $Date$
+# $Name$
+# $Revision$
+# History:
+# Modification:
+#**************************************************************
+
+##################################################################################################################
+#-----------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#-----------------------------------------------------------------------------------------------------------------
+#
+#   field = name of the field to monitore 
+#   files patterns = pattern of the files used to monitore the field (must be discriminant) 
+#   files additionnal = additionnal files accessible by $FER_DATA
+#   operations = operations to calculate the field 
+#   title = variable title
+#   units = variable units
+#   calcul of area = expression to use for the weight average
+#
+# Notes:
+#   - Comment lines begin by # character.
+#   - Separator between fields is | character.
+#   - Operations must use the ferret syntax, if several files are used precise with the syntax d=x to refer to the x dataset.
+#     They must be enclosed by parenthesis if more than one variable is used.
+#   - files patterns,files additionnal,operations,title,units must be enclosed with character ". 
+#     Use "" if empty.
+#   - Fields will be presented through an html page with thumbnails global, north, south, land, ocean.
+#     Use a field name with one of these pattern to display it under the corresponding thumbnail.
+#
+##################################################################################################################
+
+color=E7FFAB
+smooth=12
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+evap_lands     | "evap"            |  ""               | "evap[d=1]"                      | "Evaporation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+temp_sol_lands | "temp_sol"        |  ""               | "temp_sol[d=1]"                  | "TSOL (LANDS)"                 | "K/d"    | "Areas[d=1]*Contfrac[d=1]"
+humidity_lands | "bqsb gqsb"       |  ""               | "(bqsb[d=1]+gqsb[d=2])"            | "Total Soil Moisture  (LANDS)" | "1"      | "Areas[d=1]*Contfrac[d=1]"
+fluxsens_lands | "fluxsens"        |  ""               | "fluxsens[d=1]"                  | "Sensible Flux (LANDS)"        | "W/m^2"  | "Areas[d=1]*Contfrac[d=1]"
+albedo_lands   | "alb_vis alb_nir" |  ""               | "((alb_vis[d=1]+alb_nir[d=2])*0.5)"| "Mean Albedo (LANDS)"          | "1"      | "Areas[d=1]*Contfrac[d=1]"
+subli_lands    | "subli"           |  ""               | "subli[d=1]"                     | "Sublimation (LANDS)"          | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+snow_lands     | "snow"            |  ""               | "snow[d=1]"                      | "Snow Mass (LANDS)"            | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snownobio_lands | "snownobio"      |  ""               | "snownobio[d=1]"                 | "Snow Other Surfaces (LANDS)"  | "kg/m^2" | "Areas[d=1]*Contfrac[d=1]"
+snowf_lands    | "snowf"           |  ""               | "snowf[d=1]"                     | "Snowfall (LANDS)"             | "mm/d"   | "Areas[d=1]*Contfrac[d=1]"
+vegetn_lands   | "_vegetfrac"      |  ""               | "vegetfrac[d=1,K=2:9]"           | "veget natural (LANDS)"        | "1"      | "2"
+vegetg_lands   | "_vegetfrac"      |  ""               | "vegetfrac[d=1,K=10:11]"         | "veget natural grass (LANDS)"  | "1"      | "2"
+vegeta_lands   | "_vegetfrac"      |  ""               | "vegetfrac[d=1,K=12:13]"         | "veget agriculture (LANDS)"    | "1"      | "2"
+maxveget_lands | "maxvegetfrac"    |  ""               | "maxvegetfrac[d=1,K=12:13]"      | "vegetmax[pft=12,13] (LANDS)"      | "1"      | "2"
+lai_lands      | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=2:13]*maxvegetfrac[d=2,K=2:13])"  | "lai (LANDS)"      | "1"      | "2"
+lai2_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=2]*maxvegetfrac[d=2,K=2])" | "lai (LANDS)"      | "1"      | "2"
+lai3_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=3]*maxvegetfrac[d=2,K=3])" | "lai (LANDS)"      | "1"      | "2"
+lai4_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=4]*maxvegetfrac[d=2,K=4])" | "lai (LANDS)"      | "1"      | "2"
+lai5_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=5]*maxvegetfrac[d=2,K=5])" | "lai (LANDS)"      | "1"      | "2"
+lai6_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=6]*maxvegetfrac[d=2,K=6])" | "lai (LANDS)"      | "1"      | "2"
+lai7_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=7]*maxvegetfrac[d=2,K=7])" | "lai (LANDS)"      | "1"      | "2"
+lai8_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=8]*maxvegetfrac[d=2,K=8])" | "lai (LANDS)"      | "1"      | "2"
+lai9_lands     | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=9]*maxvegetfrac[d=2,K=9])" | "lai (LANDS)"      | "1"      | "2"
+lai10_lands    | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=10]*maxvegetfrac[d=2,K=10])" | "lai (LANDS)"      | "1"      | "2"
+lai11_lands    | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=11]*maxvegetfrac[d=2,K=11])" | "lai (LANDS)"      | "1"      | "2"
+lai12_lands    | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=12]*maxvegetfrac[d=2,K=12])" | "lai (LANDS)"      | "1"      | "2"
+lai13_lands    | "lai maxvegetfrac"|  ""               | "(lai[d=1,K=13]*maxvegetfrac[d=2,K=13])" | "lai (LANDS)"      | "1"      | "2"
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+# lai2_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=2]*maxvegetfrac[d=2,K=2]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai3_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=3]*maxvegetfrac[d=2,K=3]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai4_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=4]*maxvegetfrac[d=2,K=4]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai5_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=5]*maxvegetfrac[d=2,K=5]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai6_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=6]*maxvegetfrac[d=2,K=6]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai7_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=7]*maxvegetfrac[d=2,K=7]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai8_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=8]*maxvegetfrac[d=2,K=8]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai9_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=9]*maxvegetfrac[d=2,K=9]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai10_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=10]*maxvegetfrac[d=2,K=10]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai11_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=11]*maxvegetfrac[d=2,K=11]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai12_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=12]*maxvegetfrac[d=2,K=12]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
+# lai13_lands      | "lai maxvegetfrac"             |  ""               | "lai[d=1,K=13]*maxvegetfrac[d=2,K=13]*Areas[d=1]*Contfrac[d=1]"          | "lai (LANDS)"      | "1"      | "2"
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/POST/monitoring01_stomate.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/POST/monitoring01_stomate.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/POST/monitoring01_stomate.cfg	(revision 405)
@@ -0,0 +1,91 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann@cea.fr
+# $Date$
+# $Name$
+# $Revision$
+# History:
+# Modification:
+#**************************************************************
+
+##################################################################################################################
+#-----------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#-----------------------------------------------------------------------------------------------------------------
+#
+#   field = name of the field to monitore 
+#   files patterns = pattern of the files used to monitore the field (must be discriminant) 
+#   files additionnal = additionnal files accessible by $FER_DATA
+#   operations = operations to calculate the field 
+#   title = variable title
+#   units = variable units
+#   calcul of area = expression to use for the weight average
+#
+# Notes:
+#   - Comment lines begin by # character.
+#   - Separator between fields is | character.
+#   - Operations must use the ferret syntax, if several files are used precise with the syntax d=x to refer to the x dataset.
+#     They must be enclosed by parenthesis if more than one variable is used.
+#   - files patterns,files additionnal,operations,title,units must be enclosed with character ". 
+#     Use "" if empty.
+#   - Fields will be presented through an html page with thumbnails global, north, south, land, ocean.
+#     Use a field name with one of these pattern to display it under the corresponding thumbnail.
+#
+##################################################################################################################
+
+color=EEE8AA
+smooth=12
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+#  field | files patterns | files additionnal | operations | title | units | calcul of area
+#------------------------------------------------------------------------------------------------------------------------------------------------------
+CONVFLUX_lands      | "CONVFLUX CONTFRAC"                  | "" | "(CONVFLUX[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                           | "Annual release right after deforestation (LANDS)"            | "PgC/yr" | "2"
+CFLUX_PROD10_lands  | "CFLUX_PROD10 CONTFRAC"              | "" | "(CFLUX_PROD10[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                       | "Annual release from all 10 year wood product pools (LANDS)"  | "PgC/yr" | "2"
+CFLUX_PROD100_lands | "CFLUX_PROD100 CONTFRAC"             | "" | "(CFLUX_PROD100[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                      | "Annual release from all 100 year wood product pools (LANDS)" | "PgC/yr" | "2"
+HARVEST_ABOVE_lands | "HARVEST_ABOVE CONTFRAC"             | "" | "(HARVEST_ABOVE[d=1]*AREAS[d=1]*CONTFRAC[d=2]/1e15)"                      | "Annual release product after harvest (LANDS)"                | "PgC/yr" | "2"
+SOIL_CARB_lands     | "TOTAL_SOIL_CARB VEGET_MAX CONTFRAC" | "" | "(TOTAL_SOIL_CARB[d=1]*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"     | "Total Soil Carbon (LANDS)"                                   | "PgC"    | "2"
+BIOMASS_lands       | "TOTAL_M VEGET_MAX CONTFRAC"         | "" | "(TOTAL_M[d=1]*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"             | "Total Biomass (LANDS)"                                       | "PgC"    | "2"
+LITTER_lands        | "TOTAL_BM_LITTER VEGET_MAX CONTFRAC" | "" | "(TOTAL_BM_LITTER[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)" | "Total Litter (LANDS)"                                        | "PgC/yr" | "2"
+CO2FLUX_lands       | "CO2FLUX VEGET_MAX CONTFRAC"         | "" | "(CO2FLUX[d=1]*12*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"          | "NEE (LANDS)"                                                 | "PgC/yr" | "2"
+CO2FLUX_MONTHLY_SUM_lands | "CO2FLUX_MONTHLY_SUM VEGET_MAX CONTFRAC" | "" | "(CO2FLUX_MONTHLY_SUM[d=1]*12)"                                 | "NEE Sum (LANDS)"                                             | "PgC/yr" | "Areas[d=1]"
+NPP_lands           | "NPP VEGET_MAX CONTFRAC"             | "" | "(NPP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"             | "Net Primary Produc (LANDS)"                                  | "PgC/yr" | "2"
+GPP_lands           | "GPP VEGET_MAX CONTFRAC"             | "" | "(GPP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"             | "Gross Primary Produc (LANDS)"                                | "PgC/yr" | "2"
+HET_RESP_lands      | "HET_RESP VEGET_MAX CONTFRAC"        | "" | "(HET_RESP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"        | "Heterotr. Resp. (LANDS)"                                     | "PgC/yr" | "2"
+MAINT_RESP_lands    | "MAINT_RESP VEGET_MAX CONTFRAC"      | "" | "(MAINT_RESP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"      | "Maintenance Resp. (LANDS)"                                   | "PgC/yr" | "2"
+GROWTH_RESP_lands   | "GROWTH_RESP VEGET_MAX CONTFRAC"     | "" | "(GROWTH_RESP[d=1]*365*VEGET_MAX[d=2]*AREAS[d=1]*CONTFRAC[d=3]/1e15)"     | "Growth Resp. (LANDS)"                                        | "PgC/yr" | "2"
+cVeg_lands             | "cVeg"             | "" | "(cVeg[d=1])"            | "Carbon in Vegetation"			    | "kg C m-2" | "Areas[d=1]"
+cLitter_lands          | "cLitter"          | "" | "(cLitter[d=1])" 	    | "Carbon in Litter Pool" 			    | "kg C m-2" | "Areas[d=1]"
+cSoil_lands            | "cSoil"            | "" | "(cSoil[d=1])" 	    | "Carbon in Soil Pool" 			    | "kg C m-2" | "Areas[d=1]"
+cProduct_lands         | "cProduct"         | "" | "(cProduct[d=1])" 	    | "Carbon in Products of Land Use Change" 	    | "kg C m-2" | "Areas[d=1]"
+lai_lands              | "lai"              | "" | "(lai[d=1])" 	    | "Leaf Area Fraction"   	     		    | "1"   	 | "Areas[d=1]"
+gpp_lands              | "gpp"              | "" | "(gpp[d=1])" 	    | "Gross Primary Production" 		    | "kg C m-2 s-1" | "Areas[d=1]"
+ra_lands               | "ra"               | "" | "(ra[d=1])" 		    | "Autotrophic Respiration"			    | "kg C m-2 s-1" | "Areas[d=1]"
+npp_lands              | "npp"              | "" | "(npp[d=1])" 	    | "Net Primary Production" 			    | "kg C m-2 s-1" | "Areas[d=1]"
+rh_lands               | "rh"               | "" | "(rh[d=1])" 		    | "Heterotrophic Respiration" 		    | "kg C m-2 s-1" | "Areas[d=1]"
+fFire_lands            | "fFire"            | "" | "(fFire[d=1])" 	    | "CO2 Emission from Fire" 			    | "kg C m-2 s-1" | "Areas[d=1]"
+fHarvest_lands         | "fHarvest"         | "" | "(fHarvest[d=1])" 	    | "CO2 Flux to Atmosphere from Crop Harvesting" | "kg C m-2 s-1" | "Areas[d=1]"
+fLuc_lands             | "fLuc"             | "" | "(fLuc[d=1])" 	    | "CO2 Flux to Atmosphere from Land Use Change" | "kg C m-2 s-1" | "Areas[d=1]"
+nbp_lands              | "nbp"              | "" | "(nbp[d=1])" 	    | "Net Biospheric Production"      	   	    | "kg C m-2 s-1" | "Areas[d=1]"
+fVegLitter_lands       | "fVegLitter"       | "" | "(fVegLitter[d=1])" 	    | "Total Carbon Flux from Vegetation to Litter" | "kg C m-2 s-1" | "Areas[d=1]"
+fLitterSoil_lands      | "fLitterSoil"      | "" | "(fLitterSoil[d=1])"     | "Total Carbon Flux from Litter to Soil" 	    | "kg C m-2 s-1" | "Areas[d=1]"
+cLeaf_lands            | "cLeaf"            | "" | "(cLeaf[d=1])" 	    | "Carbon in Leaves"      	       		    | "kg C m-2" | "Areas[d=1]"
+cWood_lands            | "cWood"            | "" | "(cWood[d=1])" 	    | "Carbon in Wood" 				    | "kg C m-2" | "Areas[d=1]"
+cRoot_lands            | "cRoot"            | "" | "(cRoot[d=1])" 	    | "Carbon in Roots" 			    | "kg C m-2" | "Areas[d=1]"
+cMisc_lands            | "cMisc"            | "" | "(cMisc[d=1])" 	    | "Carbon in Other Living Compartments" 	    | "kg C m-2" | "Areas[d=1]"
+cLitterAbove_lands     | "cLitterAbove"     | "" | "(cLitterAbove[d=1])"    | "Carbon in Above-Ground Litter" 		    | "kg C m-2" | "Areas[d=1]"
+cLitterBelow_lands     | "cLitterBelow"     | "" | "(cLitterBelow[d=1])"    | "Carbon in Below-Ground Litter" 		    | "kg C m-2" | "Areas[d=1]"
+cSoilFast_lands        | "cSoilFast"        | "" | "(cSoilFast[d=1])" 	    | "Carbon in Fast Soil Pool" 		    | "kg C m-2" | "Areas[d=1]"
+cSoilMedium_lands      | "cSoilMedium"      | "" | "(cSoilMedium[d=1])"     | "Carbon in Medium Soil Pool" 		    | "kg C m-2" | "Areas[d=1]"
+cSoilSlow_lands        | "cSoilSlow"        | "" | "(cSoilSlow[d=1])" 	    | "Carbon in Slow Soil Pool" 		    | "kg C m-2" | "Areas[d=1]"
+treeFracPrimDec_lands  | "treeFracPrimDec"  | "" | "(treeFracPrimDec[d=1])" | "Total Primary Deciduous Tree Cover Fraction" | "%"   	| "Areas[d=1]"
+treeFracPrimEver_lands | "treeFracPrimEver" | "" | "(treeFracPrimEver[d=1])"| "Total Primary Evergreen Tree Cover Fraction" | "%" 	| "Areas[d=1]"
+c3PftFrac_lands        | "c3PftFrac" 	    | "" | "(c3PftFrac[d=1])" 	    | "Total C3 PFT Cover Fraction" 	 	    | "%" 	| "Areas[d=1]"
+c4PftFrac_lands        | "c4PftFrac" 	    | "" | "(c4PftFrac[d=1])" 	    | "Total C4 PFT Cover Fraction" 		    | "%" 	| "Areas[d=1]"
+rGrowth_lands          | "rGrowth" 	    | "" | "(rGrowth[d=1])" 	    | "Growth Autotrophic Respiration" 		    | "kg C m-2 s-1" | "Areas[d=1]"
+rMaint_lands           | "rMaint" 	    | "" | "(rMaint[d=1])" 	    | "Maintenance Autotrophic Respiration" 	    | "kg C m-2 s-1" | "Areas[d=1]"
+nppLeaf_lands          | "nppLeaf" 	    | "" | "(nppLeaf[d=1])" 	    | "CO2 Flux from Atmosphere due to NPP Allocation to Leaf" | "kg C m-2 s-1" | "Areas[d=1]"
+nppWood_lands          | "nppWood" 	    | "" | "(nppWood[d=1])" 	    | "CO2 Flux from Atmosphere due to NPP Allocation to Wood" | "kg C m-2 s-1" | "Areas[d=1]"
+nppRoot_lands          | "nppRoot" 	    | "" | "(nppRoot[d=1])" 	    | "CO2 Flux from Atmosphere due to NPP Allocation to Root" | "kg C m-2 s-1" | "Areas[d=1]"
+nep_lands              | "nep" 		    | "" | "(nep[d=1])" 	    | "Net Carbon Mass Flux out of Atmophere due to Net Ecosystem Productivity." | "kg C m-2 s-1" | "Areas[d=1]"
+cMassVariation_lands     | "cMassVariation"     | "" | "(cMassVariation[d=1])"    | "Carbon Mass Variation"			    | "kg C m-2 s-1" | "Areas[d=1]"
+cBal_lands             | "cMassVariation nbp" | "" | "(cMassVariation[d=1,L=2:1000]-nbp[d=2,L=2:1000])" | "Total Carbon Balance"		    | "kg C m-2 s-1" | "Areas[d=1]"
+#------------------------------------------------------------------------------------------------------------------------------------------------------
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/config.card
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/config.card	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/TESTSTOMATE/config.card	(revision 405)
@@ -0,0 +1,114 @@
+#
+# This is config.card file for restart with an NEW libIGCM simulation tree.
+#
+#====================================================================================
+#D-- Compatibility -
+[Compatibility]
+libIGCM=1.0
+
+#========================================================================
+#D-- UserChoices -
+[UserChoices]
+#============================
+#-- (<8 chars MAX for JobName)
+JobName=TestSTO
+LongName="Please, explain here what is this simulation for"
+TagName=OL2
+#============================
+#-- leap, noleap, 360d
+CalendarType=gregorian
+#-- Start and End of Job
+#-- "YYYY-MM-DD"
+DateBegin=1980-01-01
+DateEnd=1980-12-31
+#============================
+#-- 1Y, 1M, 5D, 1D
+PeriodLength=1Y
+#============================
+#-- PBS Class (required on brodie mono/multi)
+#JobClass=mono
+JobClass= mono
+#============================
+#-- Total Number of Processors (minimum is 2 for a coupled configuration)
+#JobNumProcTot=2
+JobNumProcTot= 1
+#============================
+#-- Run Options : here for oasis coupling
+#JobRunOptions='"-np "${NUM_PROC}" -max_np "${NUM_PROC}'
+JobRunOptions='"-np "${NUM_PROC}'
+#============================
+PeriodNb=10
+
+#========================================================================
+#D-- ListOfComponents -
+[ListOfComponents]
+#D- For each component, Name of component, Tag of component
+SRF= (sechiba, orchidee_1_9_5_1)
+SBG= (stomate, orchidee_1_9_5_1)
+
+#========================================================================
+#D-- Executable -
+[Executable]
+Name=teststomate
+#D- For each component, Real name of executable, Name of executable for oasis
+SBG= ("", "")
+SRF= (teststomate, teststomate)
+
+#========================================================================
+#D-- Restarts -
+[Restarts]
+#D- If you want a GENERAL RULE FOR RESTARTS, put this flag to 'y'
+OverRule=n
+#D- Last day of the experience used as restart
+RestartDate=1979-12-31
+#D- Define restart simulation name (=> JOB_OS)
+RestartJobName=TESTFORCE
+#D- Path Server Group Login (=> PSGL)
+RestartPath=${ARCHIVE}/IGCM_OUT/OL2
+# Attention login depend de la machine
+
+#========================================================================
+#D-- Post -
+[Post]
+#D- Do we rebuild parallel output, this flag determines
+#D- frequency of rebuild submission
+RebuildFrequency=NONE
+#D- Optimization of rebuid
+RebuildFromArchive=NONE
+#D- If you want to produce time series, this flag determines
+#D- frequency of post-processing submission
+TimeSeriesFrequency=NONE
+#D- If you want to produce seasonal average, this flag determines
+#D- the period of this average
+SeasonalFrequency=NONE
+#D- Offset for seasonal average first start dates ; same unit as SeasonalFrequency
+#D- Usefull if you do not want to consider the first X simulation's years
+SeasonalFrequencyOffset= 0
+
+#========================================================================
+#D-- SRF - SLOWPROC
+[SRF]
+WriteFrequency="1M"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1979-12-31
+# Define restart simulation name
+RestartJobName=TESTFORCE
+RestartPath=${ARCHIVE}/IGCM_OUT/OL2
+#-- Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
+#D-- SRF - STOMATE
+[SBG]
+WriteFrequency="1M"
+Restart=n
+#-- Last day of the experience used as restart
+RestartDate=1979-12-31
+# Define restart simulation name
+RestartJobName=TESTFORCE
+RestartPath=${ARCHIVE}/IGCM_OUT/OL2
+#-- Old component name for restart (if empty, use new name)
+OldName=
+
+#========================================================================
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/AA_atlas
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/AA_atlas	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/AA_atlas	(revision 405)
@@ -0,0 +1,141 @@
+#-Q- sxnec ##################
+#-Q- sxnec ## RHODES   IDRIS##
+#-Q- sxnec ##################
+#-Q- sxnec #QSUB -r ATLAS
+#-Q- sxnec #QSUB -eo
+#-Q- sxnec #QSUB -l mpp_p=2
+#-Q- sxnec #QSUB -s /bin/ksh
+#-Q- fjvpp ##################
+#-Q- fjvpp ## IXIA         ##
+#-Q- fjvpp ##################
+#-Q- fjvpp #QSUB -r ATLAS
+#-Q- fjvpp #QSUB -eo
+#-Q- fjvpp #QSUB -n 1
+#-Q- fjvpp #QSUB -s /bin/ksh
+#-Q- sx6nec ##################
+#-Q- sx6nec ## SX6NEC   CEA ##
+#-Q- sx6nec ##################
+#-Q- sx6nec #PBS -N ATLAS        # nom de la requete
+#-Q- sx6nec #PBS -j o                    # regroupement des stdout et stderr
+#-Q- sx6nec #PBS -o sortie_ATLAS.1     # nom du fichier de sortie
+#-Q- sx6nec #PBS -S /usr/bin/ksh         # shell de soumission
+#-Q- sx6nec #PBS -l memsz_job=3gb        # Limite memoire a 3 Go
+#-Q- sx6nec #PBS -l cputim_job=1:00:00   # Limite temps a 1 heures
+#-Q- sx6nec #PBS -q scalaire
+
+# --------------------------------------------
+set -x
+
+# --------------------------------------------
+#-Q- sxnec . /home/rech/psl/rpsl655/.atlas_env_rhodes_ksh
+#-Q- sx6nec . /home/p86broc/.atlas_env_mercure_ksh 
+#-Q- fjvpp . /home/p86broc/.atlas_env_ixia_ksh
+#---------------------------------------------
+date_start=`date`
+
+# --------------------------------------------
+cd $TMPDIR
+
+# --------------------------------------------
+export DISPLAY=:1
+# --------------------------------------------
+# Insert your commands between III...III lines and 
+# precise produced directories to save
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+#-Q- sxnec R_FIC=${HOMEGAYA}
+#-Q- sx6nec R_FIC=${DMFDIR}
+#-Q- fjvpp R_FIC=${DMFDIR}
+#-Q- sxnec observation_file=/u/rech/ces/rces803/FORCAGE_OL/${F_FILE}.nc
+#-Q- sx6nec observation_file=/dmnfs/p86bensh/FORCAGE_OL/${F_FILE}.nc
+#-Q- fjvpp observation_file=/dmnfs/p86bensh/FORCAGE_OL/${F_FILE}.nc
+reference_file=http://dods.ipsl.jussieu.fr/cgi-bin/nph-dods/orchidee/VALID_OL/${FLAG}/${F_FILE}_sechiba_hist.nc
+#-Q- sxnec reference_file=/u/rech/ces/rces803/VALID_OL/${FLAG}/${F_FILE}_sechiba_hist.nc
+#-Q- sx6nec reference_file=/dmnfs/p86bensh/VALID_OL/${FLAG}/${F_FILE}_sechiba_hist.nc
+#-Q- fjvpp reference_file=/dmnfs/p86bensh/VALID_OL/${FLAG}/${F_FILE}_sechiba_hist.nc
+
+export F_FILE=${F_FILE}
+export CEXPER=${CEXPER}
+export FLAG=${FLAG}
+
+if  [ "${OK_SITE}" = "y" ]
+then
+let DUREE=${AN_FINAL_EXP}-${AN_DEBUT_EXP}
+export DUREE=${DUREE}
+
+sed -e "s,RRRRRRR,$reference_file,g" -e "s,VVVVVVV,$observation_file,g" ${R_FIC}/${R_FIC_MORE_U}/Cabauw.cfg > ${R_FIC}/${R_FIC_MORE_U}/${F_FILE}_${FLAG}_diag.cfg ;
+\rm ${R_FIC}/${R_FIC_MORE_U}/Cabauw.cfg
+
+atlas -o atlas_${F_FILE}_${FLAG} ${R_FIC}/${R_FIC_MORE_U}/${F_FILE}_${FLAG}_diag.cfg  ${R_FIC}"/"${R_FIC_ORCHIDEE_OL}"/"Output"/"${FLAG}/${CEXPER}_${DATES}${NITER_MAX}_sechiba_history.nc
+
+directories_produced="atlas_${F_FILE}_${FLAG}"
+
+else
+
+if [ -z $FLAG ] 
+then
+atlas -o atlas_${CEXPER}${FLAG} ${FER_ATLAS}/atlas_p_ORCHIDEE_diag2_a.cfg ${R_FIC}"/"${R_FIC_ORCHIDEE_OL}/Output/${CEXPER}_${DATES}${NITER_MAX}_sechiba_history.nc
+else
+atlas -o atlas_${CEXPER}${FLAG} ${FER_ATLAS}/atlas_p_ORCHIDEE_diag2_a.cfg ${R_FIC}"/"${R_FIC_ORCHIDEE_OL}/Output/${FLAG}/${CEXPER}_${DATES}${NITER_MAX}_sechiba_history.nc
+fi
+
+directories_produced="atlas_${CEXPER}${FLAG}"
+
+fi 
+
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+# --------------------------------------------
+for directory in $directories_produced ; do
+    rm -rf ${R_FIC}/${R_FIC_ORCHIDEE_OL}/$directory
+    cp -pR $directory ${R_FIC}/${R_FIC_ORCHIDEE_OL}
+done
+#-Q- sxnec cd $HOMEGAYA/${R_FIC_ORCHIDEE_OL}
+#-Q- sxnec for directory in $directories_produced ; do
+#-Q- sxnec    dods_rm pub/$USER/$directory
+#-Q- sxnec    dods_cp $directory pub/$USER
+#-Q- sxnec done
+
+#---------------------------------------------
+# mail
+cat << END_MAIL > job_atlas.mail
+
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+Dear $USER,
+#-Q- fjvpp Your atlas job is finished on supercomputer IXIA
+#-Q- fjvpp at CENG/CEA center.
+#-Q- fjvpp The output files are available on ixia.ceng.cea.fr at:
+#-Q- fjvpp $DMFDIR/${R_FIC_ORCHIDEE_OL}/$directories_produced
+#-Q- sxnec Your atlas job is finished on supercomputer RHODES
+#-Q- sxnec at IDRIS/CNRS center.
+#-Q- sxnec The output files are available on rhodes.idris.fr at:
+#-Q- sxnec $HOMEGAYA/${R_FIC_ORCHIDEE_OL}/$directories_produced
+#-Q- sxnec A DODS access is also avalaible at:
+#-Q- sxnec http://dods.idris.fr/cgi-bin/nph-dods/$USER/
+#-Q- sxnec Note that you can link or unlink all files of a directory
+#-Q- sxnec with dods_cp and dods_rm commands (-h option to get usage).
+#-Q- sxnec To link all files of a directory called dir1:
+#-Q- sxnec               dods_cp dir1 pub/\$USER
+#-Q- sxnec To remove all links made previously:
+#-Q- sxnec               dods_rm pub/\$USER/dir1
+#-Q- sxnec Note that you must be on the same filesystem than DODS 
+#-Q- sxnec directories which are located on the storage machine GAYA.
+#-Q- sxnec Also you should move first to \$HOMEGAYA.
+#-Q- sx6nec Your atlas job is finished on supercomputer Mercure
+#-Q- sx6nec at CCRT/CEA center.
+#-Q- sx6nec The output files are available on mercure.ccc.cea.fr at:
+#-Q- sx6nec $DMFDIR/${R_FIC_ORCHIDEE_OL}/$directories_produced
+
+Job started: $date_start
+Job ended  : `date`
+
+Thank you for reporting any problem to
+mailto:rachid.benshila@ipsl.jussieu.fr
+
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+
+END_MAIL
+
+#-Q- sxnec mailx -s "RHODES: atlas job" $USER < job_atlas.mail
+#-Q- fjvpp mailx -s "IXIA: atlas job" $USER < job_atlas.mail
+#-Q- sx6nec mail -s "Mercure: atlas job" $USER < job_atlas.mail
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Cabauw.cfg
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Cabauw.cfg	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Cabauw.cfg	(revision 405)
@@ -0,0 +1,88 @@
+
+#!/bin/ksh
+
+#**************************************************************
+# Author: Rachid Benshila
+# Contact: rbipsl@ipsl.jussieu.fr
+# $Date:
+# $Name$
+# $Revision$
+# History:
+# Modification:
+#
+#**************************************************************
+
+input=$@
+paper=-p
+#frequency=1:12:6
+echo $input
+#reference_file=RRRRRRR
+#validation directory=VVVVVVV
+
+#----------------------
+echo $input | ferretloop - -p -i "chaleur sensible : moyenne saisonniere" -o  fluxsens_sbx ORCHIDEE_3sbxdif.jnl 'VVVVVVV RRRRRRR inputfile Qh Qh'
+
+echo $input | ferretloop - -p -i "chaleur latente : moyenne saisonniere" -o  fluxlat_sbx ORCHIDEE_3sbxdif.jnl 'VVVVVVV RRRRRRR inputfile Qle Qle'
+
+if [ "${F_FILE}" = "Cabauw" ]; then
+
+echo $input | ferretloop - -p -i "lwnet : moyenne saisonniere" -o  lwnet_sbx ORCHIDEE_3sbxdif.jnl 'VVVVVVV RRRRRRR inputfile LWnet LWnet '
+
+echo $input | ferretloop - -p -i "swnet : moyenne saisonniere" -o  swnet_sbx ORCHIDEE_3sbxdif.jnl 'VVVVVVV RRRRRRR inputfile SWnet SWnet'
+
+else
+
+echo $input | ferretloop - -p -i "netrad : moyenne saisonniere" -o  netrad_sbx ORCHIDEE_3sbxdif.jnl 'VVVVVVV RRRRRRR inputfile netrad LWnet+SWnet '
+
+fi
+
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" != "SECHIBA" ]; then
+
+echo $input | ferretloop - -p -i "gpp : moyenne saisonniere" -o  gpp_sbx ORCHIDEE_3sbxdif.jnl 'VVVVVVV RRRRRRR inputfile gpp gpp*vegetfrac' 
+
+fi
+
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" = "OK_STOMATE" ]; then
+
+echo $input | ferretloop - -p -i "nee : moyenne saisonniere" -o  nee_sbx ORCHIDEE_3sbxdif.jnl 'VVVVVVV RRRRRRR inputfile nee nee*vegetfrac*1800' 
+
+fi
+
+
+let ANNEE=0
+while [ $ANNEE -le $DUREE ]
+do
+let ANNEE2=$ANNEE+1
+echo $input | ferretloop - -s ${ANNEE}:${ANNEE}:1 -p -i "chaleur sensible : climatologie_${ANNEE2}" -o  fluxsens_day ORCHIDEE_12day.jnl 'VVVVVVV RRRRRRR inputfile Qh Qh sloop'
+
+echo $input | ferretloop - -s ${ANNEE}:${ANNEE}:1 -p -i "chaleur latente : climatologie_${ANNEE2}" -o  fluxlat_day ORCHIDEE_12day.jnl 'VVVVVVV RRRRRRR inputfile Qle Qle sloop'
+
+if [ "${F_FILE}" = "Cabauw" ]; then
+
+echo $input | ferretloop - -s ${ANNEE}:${ANNEE}:1 -p -i "lwnet : climatologie_${ANNEE2}" -o  lwnet_day ORCHIDEE_12day.jnl 'VVVVVVV RRRRRRR inputfile LWnet lwnet  sloop'
+
+echo $input | ferretloop - -s ${ANNEE}:${ANNEE}:1 -p -i "swnet : climatologie_${ANNEE2}" -o  swnet_day ORCHIDEE_12day.jnl 'VVVVVVV RRRRRRR inputfile SWnet swnet sloop'
+
+else
+
+echo $input | ferretloop - -s ${ANNEE}:${ANNEE}:1 -p -i "netrad : climatologie_${ANNEE2}" -o  netrad_day ORCHIDEE_12day.jnl 'VVVVVVV RRRRRRR inputfile netrad SWnet+lwnet sloop'
+
+fi
+ 
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" != "SECHIBA" ]; then
+
+echo $input | ferretloop - -s ${ANNEE}:${ANNEE}:1 -p -i "gpp : climatologie_${ANNEE2}" -o  gpp_day ORCHIDEE_12day.jnl 'VVVVVVV RRRRRRR inputfile GPP GPP*vegetfrac sloop' 
+
+fi
+if [ "${F_FILE}" != "Cabauw" ] && [ "${FLAG}" = "OK_STOMATE" ]; then
+
+echo $input | ferretloop - -s ${ANNEE}:${ANNEE}:1 -p -i "nee : climatologie_${ANNEE2}" -o  nee_day ORCHIDEE_12day.jnl 'VVVVVVV RRRRRRR inputfile NEE nee*vegetfrac*1800 sloop' 
+
+fi
+
+let ANNEE=$ANNEE+1
+done
+
+
+
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/CF_restart.py
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/CF_restart.py	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/CF_restart.py	(revision 405)
@@ -0,0 +1,147 @@
+#!/usr/bin/env cdat
+# -*- coding: iso-8859-15 -*-
+
+import os, sys, getopt, time
+import cdms, cdutil, MV
+from cdms.axis import TransientAxis
+from cdms.coord import TransientVirtualAxis
+
+from dataproc.utils import cdat
+
+import string
+
+from Numeric import ones
+
+import fonctions_orchidee
+
+import vcs
+
+def usage():
+    """convert a restart file in CF convention."""
+    
+    man = """
+Usage : creation of a CF_'restart_file'.nc
+    prompt> CF_restart.py restart_file.nc
+    
+    exemples : CF_restart.py sechiba_rest_out.nc
+    """
+    print man
+
+options = [
+    "help",
+    "version" ]
+
+check_test = 0
+
+
+# Extract arguments from the command line
+try:
+    myopts, myargs = getopt.getopt(sys.argv[1:], 'Vh', longopts = options)
+except getopt.GetoptError:
+    print 'getopt error'
+    usage()
+    sys.exit(1)
+
+if (len(myargs) < 1):
+    print 'I need at least 1 file.'
+    usage()
+    sys.exit(1)
+else:
+    fich = myargs[0]
+    if (os.path.exists(fich)==False):
+        print 'file ',fich,' doesn''t exist !' 
+        sys.exit(1)
+
+# Affichage des variables : fixe la limite max
+MV.set_print_limit(320)
+
+# travail sur le fichier d'entrée
+f=cdms.open(fich)
+listev = f.listvariables()
+print "Liste des variables de "+fich,listev
+
+
+# Write result file
+file_out = "CF_"+fich
+print '\nWriting to file : ', file_out
+fout = cdms.open(file_out, 'w')
+
+# recuperation des axes :
+# lon et lat
+VarLon=f('nav_lon')
+VarLat=f('nav_lat')
+axisLon = VarLon.getAxis(0)
+axisLat = VarLon.getAxis(1)
+
+# tailles des axes 
+jjm = len(axisLon)
+iim = len(axisLat)
+print "Tailles (iim,jjm) = ",iim,jjm
+
+lon=VarLon[0,:]
+lat=VarLat[:,0]
+
+att_lon = cdat.getAttributes(VarLon)
+att_lon['name']='lon'
+ax_lon = TransientAxis(lon, bounds=None, id='lon', attributes=att_lon, copy=1)
+
+att_lat = cdat.getAttributes(VarLat)
+att_lat['name']='lat'
+ax_lat = TransientAxis(lat, bounds=None, id='lat', attributes=att_lat, copy=1)
+if (check_test): print "Axes lon, lat : \n", ax_lon,"\n", ax_lat
+
+level=f('nav_lev')
+att_lev = cdat.getAttributes(level)
+ax_lev = TransientAxis(level, bounds=None, id='lev', attributes=att_lev, copy=1)
+
+# Boucle sur les variables 
+for var in listev:
+    print "*=*==*=*=*=*=*=*=*=*=*=*=*=*=*=**==*"
+    print "Variable : ",var
+    var0=f(var)
+    
+    copyattributes = cdat.getAttributes(var0)
+    if (check_test): print var,' ; attributs : ',copyattributes
+    v0shape = var0.shape
+    if (check_test): print "Tailles de "+var+" : ",v0shape
+    if (check_test): print "(min / max) de ",var," = ", cdms.MV.minimum(var0),cdms.MV.maximum(var0)
+
+
+    axes = var0.getAxisList()
+    nl = len(axes)
+
+        
+    if (check_test): print "Liste des axes de la variable "+var+" : "
+    if (check_test): print axes
+
+    listeaxes=[]
+    for ax in axes:
+        if (check_test): print ax
+        if (check_test): print "Attributes de ax : ",ax.attributes
+        if  (ax.id == 'x'):
+            listeaxes.append(ax_lon)
+        elif (ax.id == 'y'):
+            listeaxes.append(ax_lat)
+        elif (ax.id == 'z' or ax.id == 'lev' or ax.id == 'level'):
+            listeaxes.append(ax_lev)
+        else:
+            listeaxes.append(ax)
+
+    if (check_test): print "liste des axes : ",listeaxes
+            
+    wvar = cdms.createVariable(var0,
+                               axes = listeaxes)
+    fout.write(wvar)
+    fout.sync()
+    print '..... fin du traitement de ',var
+
+
+# #     div=MV.where(var0_mask<1e-15,1,var0_mask)
+        
+f.close()
+fout.close()
+print '...............finished writing.'
+# Plus à faire !
+# fonctions_orchidee.filtre_dump(file_out)
+print '...............finished rewriting.'
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/ajoute_bords.py
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/ajoute_bords.py	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/ajoute_bords.py	(revision 405)
@@ -0,0 +1,153 @@
+#!/bin/env cdat
+# -*- coding: iso-8859-15 -*-
+
+# python system
+import os, sys, gc, getopt, time
+#import string
+import re
+import Numeric
+
+
+# CDAT/CDMS
+import cdms, MV
+#, cdutil
+from cdms.axis import TransientAxis
+from cdms.coord import TransientVirtualAxis
+from dataproc.utils import cdat
+
+def usage():
+    """Display usage information."""
+    
+    man = """
+    This script with corrected the mask of a restart.
+    It will get file_to_modify datas and the mask of file_to_add file
+    and make a new file_out. The missing datas in file_to_modify will be simply
+    replaced by the same points in file_to_add file.
+    
+Usage : 
+    prompt> cdat ajoute_bords.py file_to_add file_to_modify file_out [variable]
+    Add some points defines in file_to_add for all variables (or just one) of file_to_modify to file_out.
+    
+    examples :
+    > ajoute_bords.py CM1414A_20001231_sechiba_rest.nc regrid_CF_CM5PIRC11_29901231_sechiba_rest.nc grille_regrid_CF_CM5PIRC11_29901231_sechiba_rest.nc
+    > ajoute_bords.py CM1414A_20001231_stomate_rest.nc regrid_CF_CM5PIRC11_29901231_stomate_rest.nc grille_regrid_CF_CM5PIRC11_29901231_stomate_rest.nc
+    > ajoute_bords.py CM5PIRC8_26601231_stomate_rest.nc regrid_CF_OOL-CTRLPI-1_9_5_SPIN_v2ORC_43_01001231_stomate_rest.nc grille_regrid_CF_OOL-CTRLPI-1_9_5_SPIN_v2ORC_43_01001231_stomate_rest.nc
+
+"""
+    print man
+
+
+options = [
+    "help",
+    "version" ]
+
+
+
+# Extract arguments from the command line
+try:
+    myopts, myargs = getopt.getopt(sys.argv[1:], 'Vh', longopts = options)
+except getopt.GetoptError:
+    print 'getopt error'
+    usage()
+    sys.exit(1)
+
+if (len(myargs) < 3):
+    print 'I need at least three files.'
+    usage()
+    sys.exit(1)
+else:
+    FileIn = myargs[0]
+    print "file_to_add : ",FileIn
+    if (os.path.exists(FileIn)==False):
+        print 'file ',FileIn,' doesn''t exist !' 
+        sys.exit(1)
+    else:
+        fin=cdms.open(FileIn, 'r')
+
+    FileOut = myargs[1]
+    print "file_to_modify : ",FileOut
+    if (os.path.exists(FileOut)==False):
+        print 'file ',FileOut,' doesn''t exist !' 
+        sys.exit(1)
+    else:
+        fout=cdms.open(FileOut, 'r')
+
+    FileNew = myargs[2]
+    print "file_out : ",FileNew
+    fnew=cdms.open(FileNew, 'w')
+
+    if (len(myargs) > 3):
+        varlist = [myargs[3]]
+        print 'Only one variable :',varlist
+    else:
+        varlist = fin.listvariables()
+        #varlist = [varlist[0]]
+        print "Liste des variables de "+FileIn,varlist
+        
+# Affichage des variables : fixe la limite max
+MV.set_print_limit(1700)
+
+var0=fin(varlist[0])
+missing = var0.missing_value
+missing_ = var0.missing_value - 1.
+print missing, missing_
+
+for var in varlist:
+    print "-----"
+    print "Variable : ",var,"------"
+
+    if (var in ["nav_lon","nav_lat","nav_lev","time_steps","time",
+                "lat","lon","lev","day_counter",
+                "dt_days", "routingcounter", "veget_year", "date" ]):
+        var1=fin(var)
+        fnew.write(var1,attributes=cdat.getAttributes(var1), axes=var1.getAxisList(), id=var1.id)
+        print "remplace."
+        continue
+    if (var in ["bounds_lat","bounds_lon","routingcounter","routingarea","routetogrid","routetobasin",
+                "basinid","topoindex","fastres","slowres","streamres","lakeres","previous_outflow",
+                "lakeinflow","returnflow","riverflow","coastalflow","hydrographs","runoff_route",
+                "drainage_route","evapot_route","precip_route","humrel_route","totnobio_route","vegtot_route"]):
+        print "supprime."
+        continue
+
+    var0 = fin(var)
+    var0m = MV.getmaskarray(var0)
+
+    #var0_notmissing=(var0 < missing_)
+    var0_notmissing=(var0m == 0)
+
+    var1 = fout(var)
+
+    var1m = MV.getmaskarray(var1)
+    #var1_missing=(var1 > missing_)
+    var1_missing=(var1m == 1)
+#    var1or = MV.logical_or(var1,var1m)
+
+    #test = MV.logical_and(var0_notmissing,var1or)
+    test = MV.logical_and(var0_notmissing,var1_missing)
+#     if ( var in ["temp_sol"] ):
+#         fnew.write(var0m,attributes=cdat.getAttributes(var1), axes=var1.getAxisList(), id="var0m")
+#         fnew.write(var0_notmissing,attributes=cdat.getAttributes(var1), axes=var1.getAxisList(), id="var0_notmissing")
+#         fnew.write(var1_missing,attributes=cdat.getAttributes(var1), axes=var1.getAxisList(), id="var1_missing")
+#         fnew.write(var1m,attributes=cdat.getAttributes(var1), axes=var1.getAxisList(), id="var1m")
+#         fnew.write(var1or,attributes=cdat.getAttributes(var1), axes=var1.getAxisList(), id="var1or")
+#         fnew.write(test,attributes=cdat.getAttributes(var1), axes=var1.getAxisList(), id="test")
+
+    var1b = MV.where( test , var0, var1)
+    
+#     var1w = cdms.createVariable(var1b,
+#                                fill_value = missing,
+#                                attributes = cdat.getAttributes(var1),
+#                                id = var,
+#                                axes = var1.getAxisList())
+#     print var1w
+
+#     var1w = cdms.createVariable(var1b,
+#                                 attributes = cdat.getAttributes(var1),
+#                                 id = var,
+#                                 axes = [var1.getAxis(0), var1.getAxis(1), var1.getAxis(2)])
+#     print var1w,cdat.getAttributes(var1w),
+
+    fnew.write(var1b,attributes=cdat.getAttributes(var1), axes=var1.getAxisList(), id=var1.id)
+
+fnew.close()
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/fonctions_orchidee.py
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/fonctions_orchidee.py	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/fonctions_orchidee.py	(revision 405)
@@ -0,0 +1,307 @@
+# -*- coding: iso-8859-15 -*-
+import os
+import Numeric
+
+import cdms
+import MV
+import vcs
+
+# filtre un flichier créé par cdms avec un ncdump, puis un ncgen.
+def filtre_dump (fichier):
+    os.spawnlp(os.P_WAIT,"filtre_dump","filtre_dump",fichier,fichier)
+
+
+# calcul le tableau d'index d'un axe de points de terre
+# (ie kindex2D[i,j] = land[kij]),
+# ainsi que les indices inversés
+# (ie ( iland[ kindex2D[i,j]],jland[kindex2D[i,j]] ) = ( i,j )).
+# l'algorithme est celui utilisé dans ORCHIDEE.
+def calcul_kindex(kindex2D,iland,jland,axisLand,iim,jjm):
+    kij=0
+    for ki in axisLand:
+        j = int((ki-1)/iim)
+        i = int(((ki-1) - j*iim))
+        kindex2D[i,j] = int(kij)
+        iland[kij] = i
+        jland[kij] = j
+        #kindex2Dt[jjm-1-j,i] = kij
+        kij = kij+1
+    return
+
+# calcul le vecteur des points de terre à partir du tableau des index
+# (ie land[kij] = kindex2D[i,j])
+# l'algorithme est celui utilisé dans ORCHIDEE.
+def calcul_axisLand(kindex2D,iim,jjm,missing_value):
+    axisLand = []
+    kij=0
+    for j in range(jjm):
+        for i in range(iim):
+            if (kindex2D[i,j] < missing_value):
+                ki = int(j*iim + i + 1)
+                axisLand.append(ki)
+                # vérification : 
+                if (j != (ki-1)/iim or i != ((ki-1) - j*iim)):
+                    print "Erreur calcul_axisLand au ",kij,"-ième point de terre pour (i,j) = ",i,j,"  et land_i = ",ki
+		kij = kij+1
+    return(MV.array(axisLand))
+
+
+# Converti une variable d'axes [t,z,land] (avec land les points de terre)
+# en une variable 2D (lat,lon)
+def conversion2D(VarIn, kindex, nbindex, iim, jjm, missing_value):
+    VarOut = missing_value*MV.ones((jjm,iim))
+    for j in range(jjm):
+	for i in range(iim):
+            if (kindex[i,j] < missing_value):
+                #print i,j,kindex[j,i],(jjm-1)-j
+                VarOut[j,i] = VarIn[kindex[i,j]]
+    return(VarOut)
+
+# Converti une variable 2D (lat,lon) en
+# une variable d'axe land (les points de terre).
+def conversion2Dinv(VarIn, kindex, nbindex, iim, jjm, missing_value):
+    VarOut = missing_value*MV.ones(nbindex)
+    ii=0
+    for j in range(jjm):
+	for i in range(iim):
+		if (kindex[i,j] < missing_value):
+                    VarOut[ii] = VarIn[j,i]
+                    ii=ii+1
+    return(VarOut)
+
+# Pour les graphiques : même fonction, avec la latitude inversée.
+def conversion2DGr(VarIn, kindex, nbindex, iim, jjm, missing_value):
+    VarOutGr = missing_value*Numeric.ones((jjm,iim))
+    for j in range(jjm):
+	for i in range(iim):
+		if (kindex[i,j] < missing_value):
+                        #print i,j,kindex[j,i],(jjm-1)-j
+			VarOutGr[(jjm-1)-j,i] = VarIn[kindex[i,j]]
+    return(VarOutGr)
+
+# Pour les graphiques : inverse la latitude d'une variable 2D
+def inverse2DGr(VarIn, kindex, nbindex, iim, jjm, missing_value):
+    VarOutGr = missing_value*Numeric.ones((jjm,iim))
+    for j in range(jjm):
+	for i in range(iim):
+		if (kindex[i,j] < missing_value):
+                    VarOutGr[(jjm-1)-j,i] = VarIn[j,i]
+    return(VarOutGr)
+
+# Calcul l'échelle iso d'une variable Var, dans un graphique grd, avec une valeur missing_value.
+# On décale les grandeurs min/max de decal % 
+def errlevGr(Var, grd, decal, missing_value):    
+    minv = cdms.MV.minimum(Var)
+    maxv = cdms.MV.maximum(Var)
+    if (minv > 0):
+        minv = minv*(1-decal/100.)
+    else:
+        minv = minv*(1+decal/100.)
+    if (maxv > 0):
+        maxv = maxv*(1+decal/100.)
+    else:
+        maxv = maxv*(1-decal/100.)
+    diffv = (maxv - minv)/10. 
+    errlevs = vcs.mkevenlevels(minv,maxv,12)
+    errlevs.append(missing_value)
+    errlevs.insert(0,missing_value)
+    cols = vcs.getcolors(errlevs)
+
+    return(errlevs, cols)
+
+
+
+# The input VarIn is a land variable.
+# The output variable is 2D ( [jjm,iim] or [jmin:(jmax+1),imin:(imax+1)] )
+#            and if calcland==1, it returns too :
+#                zoomkindex, zoomiim, zoomjjm, nlandz,
+#                invindex, ifenetre =(imin,imax,jmin,jmax)
+def zoom_land(VarIn, kindex, nbindex, lat, lon, iim, jjm, limits, missing_value, calcland=1):
+# where limits is in the order : [limit_W, limit_E, limit_N, limit_S]
+    VarOut = missing_value*Numeric.ones((jjm,iim))
+    # inverse of kindex
+    invindex = Numeric.zeros((nbindex,2))
+    imin = iim+1
+    imax = -1
+    jmin = jjm+1
+    jmax = -1
+    for j in range(jjm):
+	for i in range(iim):
+		if (kindex[i,j] < missing_value):
+			if ( limits[0] <= lon[j,i] and lon[j,i] <= limits[1]
+			     and limits[3] <= lat[j,i] and lat[j,i] <= limits[2] ):
+				imin = min(imin, i)
+				imax = max(imax, i)
+				jmin = min(jmin, j)
+				jmax = max(jmax, j)
+                                invindex[kindex[i,j],0]=j
+                                invindex[kindex[i,j],1]=i
+				VarOut[j,i] = VarIn[kindex[i,j]]
+    zoomiim = imax - imin +1
+    zoomjjm = jmax - jmin +1
+    #print imin, imax, jmin, jmax
+    #print zoomiim, zoomjjm
+    # pourquoi le +1 ???? (python ??) => nécessaire en tout cas.
+    # à cause des lat/lon qui doivent anglober la zone zoomée
+    VarOutZoom = VarOut[jmin:(jmax+1),imin:(imax+1)]
+    if (calcland==1):
+        zoomkindex = Numeric.ones((zoomiim,zoomjjm))*int(missing_value)
+        nlandz=0
+        for j in range(jjm):
+            for i in range(iim):
+		if (kindex[i,j] < missing_value):
+                    if ( limits[0] <= lon[j,i] and lon[j,i] <= limits[1]
+                         and limits[3] <= lat[j,i] and lat[j,i] <= limits[2] ):
+                        zoomkindex[i-imin, j-jmin] = kindex[i,j]
+                        nlandz=nlandz+1
+        print "zoom : dimension", zoomiim, zoomjjm, nlandz
+        # print "zoom : nouvel index ",zoomkindex
+        return(VarOutZoom, zoomkindex, zoomiim, zoomjjm, nlandz,
+               invindex, (imin, imax, jmin, jmax))
+    else:
+        return(VarOutZoom)
+
+
+# The input VarIn is a land variable.
+# The output variable is 2D ( [jjm,iim] or [jmin:(jmax+1),imin:(imax+1)] )
+# Simplified version of precedent one.
+def zoom_land_simpl(VarIn, kindex, nbindex, zoomiim, zoomjjm, ifenetre, missing_value):
+# where limits is in the order : [limit_W, limit_E, limit_N, limit_S]
+    (imin, imax, jmin, jmax) = ifenetre
+    VarOutZoom = missing_value*Numeric.ones((zoomjjm,zoomiim))
+    for i in range(zoomiim):
+        for j in range(zoomjjm):
+            ki=kindex[imin+i,jmin+j]
+            if (ki < missing_value):
+                VarOutZoom[j,i] = VarIn[ki]
+    return(VarOutZoom)
+
+
+# The input VarIn is a 2D variable.
+# the output variable is 2D ( [jjm,iim] or [jmin:(jmax+1),imin:(imax+1)] )
+#            and if calcland==1, it returns too :
+#                zoomkindex, zoomiim, zoomjjm, nlandz,
+#                invindex, ifenetre =(imin,imax,jmin,jmax)
+def zoom(VarIn, kindex, nbindex, lat, lon, iim, jjm, limits, missing_value, calcland=1):
+# where limits is in the order : [limit_W, limit_E, limit_N, limit_S]
+    imin = iim+1
+    imax = -1
+    jmin = jjm+1
+    jmax = -1
+    for j in range(jjm):
+	for i in range(iim):
+		if (kindex[i,j] < missing_value):
+			if ( limits[0] <= lon[j,i] and lon[j,i] <= limits[1]
+			     and limits[3] <= lat[j,i] and lat[j,i] <= limits[2] ):
+				imin = min(imin, i)
+				imax = max(imax, i)
+				jmin = min(jmin, j)
+				jmax = max(jmax, j)
+                                invindex[kindex[i,j],0]=j
+                                invindex[kindex[i,j],1]=i
+    zoomiim = imax - imin +1
+    zoomjjm = jmax - jmin +1
+    # pourquoi le +1 ???? (python ??) => nécessaire en tout cas.
+    # à cause des lat/lon qui doivent anglober la zone zoomée
+    VarOutZoom = VarIn[jmin:(jmax+1),imin:(imax+1)]
+    if (calcland == 1):
+        zoomkindex = Numeric.ones((zoomiim,zoomjjm))*int(missing_value)
+        nlandz=0
+        for j in range(jjm):
+            for i in range(iim):
+		if (kindex[i,j] < missing_value):
+                    if ( limits[0] <= lon[j,i] and lon[j,i] <= limits[1]
+                         and limits[3] <= lat[j,i] and lat[j,i] <= limits[2] ):
+                        zoomkindex[i-imin, j-jmin] = kindex[i,j]
+                        nlandz=nlandz+1
+        print "zoom : dimension",zoomiim, zoomjjm, nlandz
+        # print "zoom : nouvel index ",zoomkindex
+        return(VarOutZoom, zoomkindex, zoomiim, zoomjjm, nlandz,
+               invindex, (imin, imax, jmin, jmax))
+    else:
+        return(VarOutZoom)
+
+# The input VarIn is a 2D variable.
+# the output variable is 2D [jmin:(jmax+1),imin:(imax+1)]
+def zoom2D(VarIn, lat, lon, iim, jjm, limits, missing_value):
+# where limits is in the order : [limit_W, limit_E, limit_N, limit_S]
+    imin = iim+1
+    imax = -1
+    jmin = jjm+1
+    jmax = -1
+    for j in range(jjm):
+	for i in range(iim):
+            if ( limits[0] <= lon[j,i] and lon[j,i] <= limits[1]
+                 and limits[3] <= lat[j,i] and lat[j,i] <= limits[2] ):
+                imin = min(imin, i)
+                imax = max(imax, i)
+                jmin = min(jmin, j)
+                jmax = max(jmax, j)
+    zoomiim = imax - imin +1
+    zoomjjm = jmax - jmin +1
+    VarOutZoom = VarIn[jmin:(jmax+1),imin:(imax+1)]
+    return(VarOutZoom)
+
+# The input VarIn is a 2D variable.
+# the output variable is 2D ( [jjm,iim] or [jmin:(jmax+1),imin:(imax+1)] )
+# Simplified version of precedent one.
+def zoom_simpl(VarIn, zoomiim, zoomjjm, ifenetre, missing_value):
+# where limits is in the order : [limit_W, limit_E, limit_N, limit_S]
+    (imin, imax, jmin, jmax) = ifenetre
+    VarOutZoom = missing_value*Numeric.ones((zoomjjm,zoomiim))
+    VarOutZoom = VarIn[jmin:(jmax+1),imin:(imax+1)]
+    return(VarOutZoom)
+
+
+tab_mois=[31,28,31,30,31,30,31,31,30,31,30,31]
+
+# Conversion Month/Day => Num of Day in year
+def monthday_to_numday(month,day):
+#Tableau definissant la duree des mois dans un calendrier de 365 jours
+    numday=sum(tab_mois[0:(month-1)])+day
+    return(numday)
+    
+# Rajoute dans le fichier "fichier" les tableaux bounds_lat et bounds_lon
+# pour le rendre compatible avec la convention CF.
+
+# def rajoutBounds(fichier,lat,lon,nland,land,kindex,nbindex,missing_value)
+#     bounds_lon = Numeric.zeros((nland,,4))
+#     bounds_lat = Numeric.zeros((nland,,4))
+#     for j in range(jjm):
+# 	for i in range(iim):
+# 		if (kindex[i,j] < missing_vlaue):
+#                         #print i,j,kindex[i,j],(jjm-1)-j
+# 			VarOut[i,j] = VarIn[kindex[i,j]]
+#     return(VarOut)
+
+
+# Construction des tableaux de coordonnées 2D nav_lat et nav_lon
+def Construit_nav_l(ax_lat, ax_lon, missing_v):
+    Mones=Numeric.ones((len(ax_lat),1))
+    Slon=Numeric.array([ax_lon])
+    nvlon=MV.dot(Mones,Slon)
+    nav_lon=cdms.createVariable(nvlon, 
+                                typecode = cdms.MV.Float16,
+                                fill_value = missing_v,
+                                attributes={'name': 'nav_lon',
+                                            'valid_min': -180.,
+                                            'valid_max': 180.,
+                                            'long_name': 'Longitude',
+                                            'units': 'degrees_east' },
+                                axes = [ ax_lat, ax_lon ],
+                                id = 'nav_lon')
+
+    Mones=Numeric.swapaxes(Numeric.ones((len(ax_lon),1)),0,1)
+    tmplat=Numeric.swapaxes(Numeric.array([ax_lat]),0,1)
+    nvlat=MV.dot(tmplat, Mones)
+    nav_lat=cdms.createVariable(nvlat, 
+                                typecode = cdms.MV.Float16,
+                                fill_value = missing_v,
+                                attributes={'name': 'nav_lat',
+                                            'valid_min': -90.,
+                                            'valid_max': 90.,
+                                            'long_name': 'Latitude',
+                                            'units': 'degrees_north' },
+                                axes = [ ax_lat, ax_lon ],
+                                id = 'nav_lat')
+    return (nav_lat, nav_lon)
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/restart_interpol.py
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/restart_interpol.py	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/restart_interpol.py	(revision 405)
@@ -0,0 +1,216 @@
+#!/usr/bin/env cdat
+# -*- coding: iso-8859-15 -*-
+
+import cdms, cdutil, genutil, os, sys, getopt
+from cdms import MV
+from dataproc.utils import cdat
+from regrid import Regridder
+
+from Numeric import ones
+
+def usage():
+    """Display usage information."""
+    
+    man = """
+    This script will get 2 SECHIBA or STOMATE restarts for ORCHIDEE code and will
+    produce a regridded restart with the grid of the first restart (and other non gridded variables)
+    and the values of the second one.
+    
+Usage : 
+    prompt> restart_interpol.py restart_outgrid.nc restart_invalues.nc'
+        This script regrids values in file 2 (namely restart_invlaues.nc) with
+        grid in restart_outgrid.nc.
+
+Examples :
+    > restart_interpol.py CF_CM1414A_20001231_sechiba_rest.nc CF_CM5PIRC11_29901231_sechiba_rest.nc
+    > restart_interpol.py CF_CM1414A_20001231_stomate_rest.nc CF_CM5PIRC11_29901231_stomate_rest.nc
+    > restart_interpol.py CF_CM5PIRC8_26601231_sechiba_rest.nc CF_OOL-CTRLPI-1_9_5_SPIN_v2ORC_43_01001231_sechiba_rest.nc
+    """
+    print man
+
+options = [
+    "help",
+    "version" ]
+
+# Extract arguments from the command line
+try:
+    myopts, myargs = getopt.getopt(sys.argv[1:], 'Vh', longopts = options)
+except getopt.GetoptError:
+    print 'getopt error'
+    usage()
+    sys.exit(1)
+
+variable=""
+if (len(myargs) < 2):
+    print 'I need at least 2 files.'
+    usage()
+    sys.exit(1)
+else:
+    file = myargs[:]
+    lf = len(file)
+    for i in range(2):
+    	if (os.path.exists(file[i])==False):
+            print 'file number ',i+1,' : ',file[i],\
+                  ' doesn''t exist !' 
+            sys.exit(1)
+
+f1=cdms.open( file[0],'r')
+f2=cdms.open( file[1],'r')
+listv=f1.listvariables()
+listv2=f2.listvariables()
+#listv.sort()
+#listv2.sort()
+print listv
+print listv2
+
+
+f3=cdms.open( "regrid_"+file[1],'w')
+
+onet=None
+
+missing_value = 1e+20
+
+for var in listv:
+    print var
+    if (var in ["nav_lon","nav_lat","nav_lev","time_steps","time",
+                "lat","bounds_lat","lon","bounds_lon","lev","day_counter",
+                "dt_days", "routingcounter", "veget_year", "date" ]):
+        var1=f1(var)
+        f3.write(var1)
+
+        print "remplacé."
+        continue
+        
+    var1=f1(var)
+    try:
+        var2=f2(var)
+    except:
+        f3.write(var1)
+        print "remplacé."
+        continue
+
+#    var2.info()
+    if (len(var1.shape) > 3):
+       var_1=f1(var, squeeze=1)
+       tmp=cdms.createVariable(var1)
+       var_2=f2(var, squeeze=1)
+#       print var1.id,var
+
+#        if (var1.id == 'day_counter'):
+#            var1[0,0,0,0]=var_2
+#            continue
+       
+#       print tmp.shape,var_2,type(var_2)
+#       axlist2=var_2.getAxisList()
+#       print tmp.shape,var_2,len(axlist2)
+#       if (len(axlist2) > 0 ):
+
+       if (len(var_2)!=1) :
+           if (len(var_2.shape) > 2):
+#               print tmp.shape, var_2.shape,var2.shape
+               if ( len(tmp.getAxis(0)) == 1 ):
+#                   print tmp.getAxis(0),var2.getAxis(0)
+
+                   if ( len(var_2.getAxis(0)) > 0 ):
+#                       print var_2.getAxis(0)[:]
+                       shift=( var_2.getAxis(0)[0] > 0 )
+                       outgrid=var_1[0,:,:].getGrid()
+                       ingrid=var_2[0,:,:].getGrid()
+                       regridfunc = Regridder(ingrid, outgrid)
+                       sumpft=var_1[0,:,:]*0.
+                       for fpft in var_2.getAxis(0):
+                           if ( shift ):
+                               pft=int(fpft) - int(var_2.getAxis(0)[0])
+                           else:
+                               pft=int(fpft)
+                               
+#                           print pft
+                           tmp_ = tmp[0,pft,:,:]
+                           v2 = var_2[pft,:,:]
+                           v1 = var_1[pft,:,:]
+ #                           mask_undef = MV.where(v2 > missing_value, 1, 0)
+#                            v2_mask=MV.masked_array(v2, mask_undef)
+#                            varmax2=max(max(abs(v2_mask)))
+#                            v2=v2_mask/varmax2
+                           tmp__ = regridfunc(v2)
+#                            tmp[0,pft,:,:]=tmp__*varmax2                           
+                           tmp[0,pft,:,:]=tmp__
+                           if (var in ["veget_max","veget"]):
+                               sumpft[:,:]=sumpft[:,:]+tmp__
+
+                       if (var in ["veget_max"]):
+                           # On veut :
+                           #somm(tmp[0,pft,:,:])+frac_nobio=1
+                           vegnorm=1-frac_nobio
+                           veget_max=tmp[0,:,:,:]
+                           for fpft in var_2.getAxis(0):
+                               if ( shift ):
+                                   pft=int(fpft) - int(var_2.getAxis(0)[0])
+                               else:
+                                   pft=int(fpft)
+                               veget_max[pft,:,:]=MV.where(sumpft[:,:] == 0., 0., veget_max[pft,:,:] * vegnorm / sumpft[:,:])
+                               tmp[0,pft,:,:]= veget_max[pft,:,:]
+                               
+                       if (var in ["veget"]):
+                           for fpft in var_2.getAxis(0):
+                               if ( shift ):
+                                   pft=int(fpft) - int(var_2.getAxis(0)[0])
+                               else:
+                                   pft=int(fpft)
+                                   
+                               tmp[0,pft,:,:]= MV.where(tmp[0,pft,:,:] > veget_max[pft,:,:], veget_max[pft,:,:], tmp[0,pft,:,:])
+
+                   else:
+                       tmp[0,0,:,:]=var_2.regrid( var_1.getGrid() )
+               else:
+                   print "Erreur ! "
+                   print tmp.getAxis(0),var2.getAxis(0)
+#                   print var1.getAxisList()
+                   
+                   if ( len(var_2.getAxis(0)) > 0 ):
+#                       print var_2.getAxis(0)[:]
+                       shift=( var_2.getAxis(0)[0] > 0 )
+                       for fpft in var_2.getAxis(0):
+                           if ( shift ):
+                               pft=int(fpft) - int(var_2.getAxis(0)[0])
+                           else:
+                               pft=int(fpft)
+                               
+#                           print pft
+                           tmp_ = tmp[0,pft,:,:]
+                           v2 = var_2[pft,:,:]
+                           v1 = var_1[0,pft,:,:]
+#                           mask_undef = MV.where(v2 > missing_value, 1, 0)
+#                           v2_mask=MV.masked_array(v2, mask_undef)
+#                           varmax2=max(abs(v2_mask))
+#                           v2=v2_mask/varmax2
+                           tmp__ = v2.regrid( v1.getGrid() )
+#                           tmp[0,pft,:,:]=tmp__*varmax2
+                           tmp[0,pft,:,:]=tmp__
+                           
+           else:
+               tmp[0,0,:,:]=var_2.regrid( var_1.getGrid() )
+               if (var in ["frac_nobio"]):
+                   frac_nobio=tmp[0,0,:,:]
+       else:
+           tmp[0,0,0,0]=var_2
+
+       var1=tmp
+
+       #       var1.info()
+       t=var1.getTime()
+       print 'len of t:',t
+       if t is not None:
+           if len(t)!=1:
+               raise 'Error too much time'
+       if onet is None:
+           onet=t.clone()
+       else:
+           if t[0]!=onet[0]:
+               raise 'different time'
+
+       f3.write(var1)
+    else:
+        print "impossible ?"
+#        var2=f2(var)
+#        f3.write(var2)
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/script_regrid
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/script_regrid	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/Regrid_restart/script_regrid	(revision 405)
@@ -0,0 +1,69 @@
+#!/bin/ksh
+
+set -vx
+
+###########################################################################################
+# ajoute_bord.py
+###########################################################################################
+# usage : 
+# prompt> script_regrid restart_file_to_keep_the_grid.nc restart_file_to_get_the_values.nc
+
+# example in ksh shell : 
+# > script_regrid CM1414A_20001231_sechiba_rest.nc CM5PIRC11_29901231_sechiba_rest.nc > shell_test_script_regrid_SECHIBA 2>&1
+###########################################################################################
+
+
+PATH_FILE_IN_TO_GRID=$1
+FILE_IN_TO_GRID=$( basename $1 )
+DIR_IN_TO_GRID=$( dirname $1 )
+
+PATH_FILE_IN_VALUES=$2
+FILE_IN_VALUES=$( basename $2 )
+DIR_IN_VALUES=$( dirname $2 )
+
+if [ X${DIR_IN_TO_GRID} != X. ] ; then
+    cp ${1} .
+fi
+if [ X${DIR_IN_VALUES} != X. ] ; then
+    cp ${2} .
+fi
+
+# Add true CF convention compatible with CDAT cdms library 
+# --------------------------------------------------------
+CF_restart.py ${FILE_IN_TO_GRID}
+CF_FILE_IN_TO_GRID=CF_${FILE_IN_TO_GRID}
+
+CF_restart.py ${FILE_IN_VALUES}
+CF_FILE_IN_VALUES=CF_${FILE_IN_VALUES}
+
+
+
+# Interpol the CF restart
+# -----------------------
+# For SECHIBA restart files, we delete routing variables :
+# 1) with restget calls order in the code :
+# routingcounter,routingarea,routetogrid,routetobasin,basinid,topoindex,fastres,slowres,streamres,lakeres,
+# previous_outflow,lakeinflow,returnflow,riverflow,coastalflow,hydrographs,
+# runoff_route,drainage_route,evapot_route,precip_route,humrel_route,totnobio_route,vegtot_route 
+# 2) with alphabetic order :
+# basinid, coastalflow,
+# drainage_route, evapot_route, fastres, humrel_route, hydrographs, lakeinflow, lakeres,
+# precip_route, previous_outflow, returnflow, riverflow, routetobasin, routetogrid, routingarea,
+# runoff_route, slowres, streamres, topoindex, totnobio_route, vegtot_route
+
+restart_interpol.py ${CF_FILE_IN_TO_GRID} ${CF_FILE_IN_VALUES}
+regrid_FILE_OUT=regrid_${CF_FILE_IN_VALUES}
+
+# Change CF convention to restcom axes
+# ------------------------------------
+ncrename -d lat,y -d lon,x -d lev,z ${regrid_FILE_OUT}
+ncks -O -a -x -v lat,lon,lev,bounds_lat,bounds_lon ${regrid_FILE_OUT} ${regrid_FILE_OUT}
+
+# Name of the output file
+# -----------------------
+FILE_OUT=grille_${regrid_FILE_OUT}
+
+# Correct mask of the output file
+# -------------------------------
+ajoute_bords.py ${FILE_IN_TO_GRID} ${regrid_FILE_OUT} ${FILE_OUT}
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/calend365.py
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/calend365.py	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/calend365.py	(revision 405)
@@ -0,0 +1,48 @@
+##################################################################
+#PIEDLOUP Sebastien
+#sebastien.piedloup@ipsl.jussieu.fr
+#juillet 2003
+##################################################################
+
+##################################################################
+#Module qui definit un calendrier de 365 jours et qui renvoie une date valide
+##################################################################
+
+
+
+#!/usr/bin/env python
+
+#Tableau definissant la duree des mois dans un calendrier de 365 jours
+tab=[31,28,31,30,31,30,31,31,30,31,30,31]
+
+##################################################################
+#Fonction qui se charge des mois et jours negatifs ou nul
+##################################################################
+def pre(y,m,d):
+   #print "1",y,m,d
+   if m==0:
+       return pre(y-1,12,d)
+   if m<=0:
+       return pre(y-abs((m-1)/12),abs((m-1)%12+1),d)
+   if d==0:
+       return pre(y,m-1,tab[(m-2)%12])
+   if d<0:
+       return pre(y-abs((d-1)/365),m,abs((d-1)%365+1))
+   return date_365d(y,m,d)
+                  
+##################################################################
+#Fonction qi renvoit une date valide sur un calendrier de 365 jours
+##################################################################
+def date_365d(y,m,d):
+   #print "2",y,m,d
+   mm=m-1
+   if mm/12:
+       return date_365d(y+(mm/12),mm%12+1,d)
+   if (d-1)/tab[mm]:
+       return date_365d(y,m+1,d-tab[mm])
+   return y,m,d
+
+
+
+#print pre(1987,1,365)
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/recup_date.py
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/recup_date.py	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/recup_date.py	(revision 405)
@@ -0,0 +1,42 @@
+#######################################################################
+#PIEDLOUP Sebastien
+#sebastien.piedloup@ipsl.jussieu.fr
+#juillet 2003
+#######################################################################
+
+
+#######################################################################
+#Module qui recupere les information de date dans un fichier de forcage NETCDF
+#######################################################################
+
+
+#!/usr/bin/env python
+#. /home/p86cadul/CDAT/cdat.login_ksh
+
+#importation du module cdms de CDAT
+import cdms,cdtime,sys,os
+
+def recup():
+    
+    try:
+        for X in sys.argv[1:]:
+            if os.path.isfile(X) and X[-3:]=='.nc':
+                f=cdms.open(sys.argv[1])
+                a,m,j=f('time').units.split()[2].split('-')
+                p=int(f('timestp').tstep_sec[0])
+                n=len(f('time'))   
+            else:
+                print "usage: ",sys.argv[0],"nom_de_fichier"
+    except IndexError: 
+        print "usage: ",sys.argv[0],"nom_de_fichier"
+
+    return a,m,j,p,n        
+
+#a,m,j,p,n=recup()
+#d=n*p/86400
+#print a,m,j,p,n,d
+
+
+
+
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/sortie_date.py
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/sortie_date.py	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/Utilitaire/sortie_date.py	(revision 405)
@@ -0,0 +1,25 @@
+##!/usr/bin/env python
+####################################################################
+#PIEDLOUP Sebastien
+#sebastien.piedloup@ipsl.jussieu.fr
+#juillet 2003
+####################################################################
+
+####################################################################
+#Module principal qui appelle les module de date et de calendrier, il affiche les informations de date
+#################################################################### 
+
+
+import recup_date,calend365,sys,os
+
+#################################################################### 
+#Fonction qui incremente une date a partir du calendrier de 365 jours
+#################################################################### 
+def date_fin(a,m,j,i):
+    return calend365.pre(a,m,j+i)
+
+####################################################################
+ad,md,jd,p,n=map(int,recup_date.recup())
+d=n*p/86400
+af,mf,jf=date_fin(ad,md,jd-1,d)
+print ad,md,jd,p,n,d,af,mf,jf
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/bench_ORCHIDEE
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/bench_ORCHIDEE	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/bench_ORCHIDEE	(revision 405)
@@ -0,0 +1,308 @@
+#!/bin/ksh
+#
+#
+#
+#
+# The model to be tested
+#
+model='../modipsl/bin/orchidee_ol'
+#
+# File with the forcing data
+#
+forcing='../ISLSCP/islscp_Euro_87.nc'
+#
+# Files of the various maps needed by the model
+#
+vegmap='../surfmap/carteveg5km.nc'
+irrigmap='../surfmap/irrigated.nc'
+routmap='../surfmap/routing.nc'
+soilmap='../surfmap/soils_param.nc'
+reftemp='../surfmap/reftemp.nc'
+#
+# Some tools we will need to process the data
+#
+ncks=$(which ncks)
+ncrcat=$(which ncrcat)
+ncdump=$(which ncdump)
+#
+rm="/bin/rm"
+mv="/bin/mv"
+diff="/usr/bin/diff"
+#
+#
+#  DO NOT CHANGE BELOW THIS LINE
+#------------------------------------------------------
+#------------------------------------------------------
+#
+######################################################
+#
+# Verifications
+#
+######################################################
+#
+if [ ! -x ${model} ]; then
+   echo "The model executable does not exist"
+   echo "Retry the compilation of ORCHIDEE in the modipsl strcture"
+   exit
+fi 
+#
+if [ ! -x ${ncks} ]; then
+   echo "The ncks tool of nco does not exist"
+   echo "Check it out at http://www.cgd.ucar.edu/cms/nco/nco.html"
+   exit
+fi
+#
+#
+if [ ! -x ${rm} ]; then
+   echo "How do I delete a file ?"
+   exit
+fi
+#
+if [ ! -f ${forcing} ]; then
+   echo "I could not find the forcing file"
+   exit
+fi
+#
+if [ ! -f ${vegmap} ]; then
+   echo "I could not find the file with the vegetation map"
+   exit
+fi
+#
+if [ ! -f ${irrigmap} ]; then
+   echo "I could not find the file with the irrigation map"
+   exit
+fi
+#
+if [ ! -f ${routmap} ]; then
+   echo "I could not find the file with the basin map for the routing"
+   exit
+fi
+#
+if [ ! -f ${soilmap} ]; then
+   echo "I could not find the file with the map with the soil types"
+   exit
+fi
+#
+if [ ! -f ${reftemp} ]; then
+   echo "I could not find the file with the map of reference temperatures"
+   exit
+fi
+#
+#
+######################################################
+#
+# generate the default run.def
+#
+######################################################
+#
+#
+${rm} -f run_default.def
+cat > run_default.def << %
+#
+# SECHIBA_2dim
+#
+DEBUG_INFO=n
+FORCING_FILE=${forcing}
+HEIGHT_LEV1=2.0
+SPLIT_DT=12
+RESTART_FILEIN=XXDR_RINXX
+RESTART_FILEOUT=XXDR_ROUTXX
+TIME_SKIP=0
+TIME_LENGTH=XXTLXX
+# IMPLICIT is not set
+NO_INTER=y
+SPRED_PREC=1
+NETRAD_CONS=n 
+#
+LIMIT_WEST = XX_WEST_XX
+LIMIT_EAST = XX_EAST_XX
+LIMIT_NORTH = XX_NORTH_XX
+LIMIT_SOUTH = XX_SOUTH_XX
+#
+# IOIPSL
+#
+RIVER_ROUTING=y
+ROUTING_RIVERS = 2
+ROUTING_FILE=${routmap}
+IRRIGATION_FILE=${irrigmap}
+DO_IRRIGATION=y
+DO_FLOODPLAINS=y
+#
+# SECHIBA
+#
+CONDVEG_SNOWA=default
+# IMPOSE_AZE is not set
+SOILALB_FILE=${soilmap}
+SOILTYPE_FILE=${soilmap}
+DIFFUCO_LEAFCI=233.
+ENERBIL_TSURF=280.
+HYDROL_SNOW=0.0
+HYDROL_SNOWAGE=0.0
+HYDROL_SNOWICE=0.0
+HYDROL_SNOWICEAGE=0.0
+HYDROL_HDRY=0.0
+HYDROL_HUMR=1.0
+HYDROL_BQSB=default
+HYDROL_GQSB=0.0
+HYDROL_DSG=0.0
+HYDROL_DSP=default
+HYDROL_QSV=0.0
+# STOMATE_OK_CO2=y
+# STOMATE_OK_STOMATE is not set
+# STOMATE_OK_DGVM is not set
+# STOMATE_WATCHOUT is not set
+SECHIBA_restart_in=XXSE_RINXX
+SECHIBA_rest_out=XXSE_ROUTXX
+SECHIBA_reset_time=y
+STOMATE_RESTART_FILEIN=XXST_RINXX
+STOMATE_RESTART_FILEOUT=XXST_ROUTXX
+OUTPUT_FILE=XX_SEOUT_XX
+WRITE_STEP=86400
+SECHIBA_HISTLEVEL=5
+STOMATE_OUTPUT_FILE=XX_STOUT_XX
+STOMATE_HIST_DT=10.
+STOMATE_HISTLEVEL=10
+SECHIBA_DAY=0.0
+SECHIBA_ZCANOP=0.5
+DT_SLOW=86400.
+# IMPOSE_VEG is not set
+VEGETATION_FILE=${vegmap}
+THERMOSOIL_TPRO=280.
+%
+#
+######################################################
+#
+# Launch our first simulation. It will be called RLarge
+#
+######################################################
+#
+# Build the run.def file for 10 days on the large domaine.
+#
+exp_a='Rlarge'
+#
+${rm} -f wo
+cat << % > wo
+s/XXDR_RINXX/NONE/
+s/XXDR_ROUTXX/${exp_a}_drv_rest.nc/
+s/XXTLXX/10d/
+s/XX_WEST_XX/-20.0/
+s/XX_EAST_XX/10.0/
+s/XX_NORTH_XX/20.0/
+s/XX_SOUTH_XX/2.0/
+s/XXSE_RINXX/NONE/
+s/XXSE_ROUTXX/${exp_a}_sec_rest.nc/
+s/XXST_RINXX/NONE/
+s/XXST_ROUTXX/${exp_a}_sto_rest.nc/
+s/XX_SEOUT_XX/sec_${exp_a}.nc/
+s/XX_STOUT_XX/sto_${exp_a}.nc/
+%
+${rm} -f run.def
+sed -f wo run_default.def > run.def
+#
+# Run the model
+#
+#
+${rm} -f ${exp_a}.log ${exp_a}_*_rest.nc
+time ${model} > ${exp_a}.log
+${mv} used_run.def used_run_${exp_a}.def
+${rm} -f ${exp_a}_drv_rest.nc
+#
+#
+######################################################
+#
+# Launch our second simulation. It will test the restart of the model
+#
+######################################################
+#
+# Build the run.def file for the first 5 days on the large domaine.
+#
+exp_b='RlargeA'
+#
+${rm} -f wo
+cat << % > wo
+s/XXDR_RINXX/NONE/
+s/XXDR_ROUTXX/${exp_b}_drv_rest.nc/
+s/XXTLXX/5d/
+s/XX_WEST_XX/-20.0/
+s/XX_EAST_XX/10.0/
+s/XX_NORTH_XX/20.0/
+s/XX_SOUTH_XX/2.0/
+s/XXSE_RINXX/NONE/
+s/XXSE_ROUTXX/${exp_b}_sec_rest.nc/
+s/XXST_RINXX/NONE/
+s/XXST_ROUTXX/${exp_b}_sto_rest.nc/
+s/XX_SEOUT_XX/sec_${exp_b}.nc/
+s/XX_STOUT_XX/sto_${exp_b}.nc/
+%
+${rm} -f run.def
+sed -f wo run_default.def > run.def
+#
+# Run the model for the first 5 days
+#
+${rm} -f ${exp_b}.log ${exp_b}_*_rest.nc
+${model} > ${exp_b}.log
+${mv} used_run.def used_run_${exp_b}.def
+#
+# Build the run.def file for the second set of 5 days.
+#
+exp_c='RlargeB'
+#
+${rm} -f wo
+cat << % > wo
+s/XXDR_RINXX/${exp_b}_drv_rest.nc/
+s/XXDR_ROUTXX/${exp_c}_drv_rest.nc/
+s/XXTLXX/5d/
+s/XX_WEST_XX/-20.0/
+s/XX_EAST_XX/10.0/
+s/XX_NORTH_XX/20.0/
+s/XX_SOUTH_XX/2.0/
+s/XXSE_RINXX/${exp_b}_sec_rest.nc/
+s/XXSE_ROUTXX/${exp_c}_sec_rest.nc/
+s/XXST_RINXX/${exp_b}_sto_rest.nc/
+s/XXST_ROUTXX/${exp_c}_sto_rest.nc/
+s/XX_SEOUT_XX/sec_${exp_c}.nc/
+s/XX_STOUT_XX/sto_${exp_c}.nc/
+%
+${rm} -f run.def
+sed -f wo run_default.def > run.def
+#
+# Run the model for the first 5 days
+#
+${rm} -f ${exp_c}.log ${exp_c}_*_rest.nc
+${model} > ${exp_c}.log
+${mv} used_run.def used_run_${exp_c}.def
+${rm} -f ${exp_b}_drv_rest.nc ${exp_c}_drv_rest.nc
+#
+#################################################################
+#
+# Do the diagnostics
+#
+#################################################################
+#
+${rm} -f sec_${exp_a}_pt.nc sec_${exp_b}_pt.nc sec_${exp_c}_pt.nc sec_${exp_a}_combi_pt.nc
+${ncks} -d lon,5.25,5.75 -d lat,10.25,10.75 sec_${exp_a}.nc sec_${exp_a}_pt.nc
+${ncks} -d lon,5.25,5.75 -d lat,10.25,10.75 sec_${exp_b}.nc sec_${exp_b}_pt.nc
+${ncks} -d lon,5.25,5.75 -d lat,10.25,10.75 sec_${exp_c}.nc sec_${exp_c}_pt.nc
+#
+${ncrcat} sec_${exp_b}_pt.nc sec_${exp_c}_pt.nc sec_${exp_a}_combi_pt.nc
+#
+vars='evap gqsb bqsb temp_sol'
+for v in $vars ; do
+  ${rm} -f full combi
+  ${ncdump} -v $v -p 9,17 -f f sec_${exp_a}_pt.nc | tail -12 > full
+  ${ncdump} -v $v -p 9,17 -f f sec_${exp_a}_combi_pt.nc | tail -12 > combi
+  ${diff} full combi > /dev/null
+  if [ $? -eq 1 ]; then
+    echo 'The restart did not work and we have differences for variable ' $v
+    paste full combi
+  else
+    echo 'The restart worked for variable ' $v
+  fi
+done
+${rm} full combi sec_${exp_b}.nc sec_${exp_c}.nc
+#
+# Clean up !
+#
+#
+${rm} -f wo run.def run_default.def
+
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/dim2_driver.f90
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/dim2_driver.f90	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/dim2_driver.f90	(revision 405)
@@ -0,0 +1,1743 @@
+PROGRAM driver
+!< $HeadURL$ 
+!< $Date$
+!< $Author$
+!< $Revision$
+!- IPSL (2006)
+!-  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
+!---------------------------------------------------------------------
+!- This PROGRAM is the driver of the dim2 version of SECHIBA. It's
+!- main use is for PILPS type experiments. To run it you need to have
+!- the following software :
+!- - SECHIBA
+!- - ioipsl
+!- - netcdf
+!- - F90 compiler
+!- - tk (optional but very useful for configuring the model)
+!- Obviously also the associated Makefiles.
+!-
+!- The forcing data needs to be in netCDF format and should
+!- contain the following variables :
+!- - Incoming SW radiation
+!- - Incoming LW radiation
+!- - Precipitation
+!- - Air temperature at a reference level
+!- - Air humidity at the same level
+!- - wind at the same level
+!- - surface pressure
+!-
+!- Once you have all this and compiled the model you can configure it.
+!- Type make config and set all the values presented in the menu.
+!- This tool will create a run.def which will be used by the model.
+!- The run.def can also be edited by hand but it is more tedious.
+!- Once this run.def is created the model is ready to run.
+!---------------------------------------------------------------------
+  USE netcdf
+  USE ioipsl
+  USE grid
+  USE intersurf,  ONLY : intersurf_main
+  USE constantes
+  USE constantes_veg
+  USE readdim2
+  USE parallel
+  USE timer
+!-
+  IMPLICIT NONE
+!-
+  INTEGER :: iim, jjm, llm
+  INTEGER :: im, jm, lm, tm, is, force_id, itest, jtest
+  REAL :: dt, dt_force, dt_rest, date0, date0_rest
+  REAL :: zlflu
+  REAL :: alpha
+!-
+  REAL, ALLOCATABLE, DIMENSION(:,:) :: &
+ & swdown, precip_rain, precip_snow, tair_obs, u, v, &
+ & qair_obs, pb, lwdown, &
+ & eair_obs, zlev_vec, zlevuv_vec, relax
+!- Variables which are forcings for SECHIBA
+  REAL, ALLOCATABLE, DIMENSION(:,:) :: &
+ & petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, &
+ & for_u, for_v, for_swnet, for_swdown, for_lwdown, &
+ & for_psurf, for_qair, for_tair, for_eair, &
+ & for_ccanopy, for_rau
+!!$, tmp_eair, tmp_tair, &
+!!$ & tmp_qair, tmp_pb
+!-
+  REAL, ALLOCATABLE, DIMENSION(:,:) :: &
+ & for_contfrac, old_zlev, old_qair, old_eair, tsol_rad, vevapp, &
+ & temp_sol_NEW, temp_sol_old, qsurf, dtdt, coastalflow, riverflow, &
+ & fluxsens, fluxlat, emis, z0
+!!$, epot_sol
+!-
+  INTEGER, ALLOCATABLE, DIMENSION(:,:,:) :: for_neighbours
+!-
+  REAL, ALLOCATABLE, DIMENSION(:,:,:) :: for_resolution
+!-
+  REAL, ALLOCATABLE, DIMENSION(:,:,:) :: albedo
+  REAL, ALLOCATABLE, DIMENSION(:,:) :: albedo_vis
+  REAL, ALLOCATABLE, DIMENSION(:,:) :: albedo_nir
+!-
+  INTEGER, ALLOCATABLE, DIMENSION(:) :: kindex
+  REAL, ALLOCATABLE, DIMENSION(:,:) :: lon, lat
+!-
+  REAL :: old_tair
+  REAL :: atmco2
+  INTEGER :: nbindex
+  REAL,DIMENSION(:), ALLOCATABLE :: lev, levuv
+  REAL :: julian, ss
+  INTEGER :: yy, mm, dd
+!-
+  LOGICAL :: relaxation, lower_wind
+!-
+  CHARACTER(LEN=80) :: filename, restname_in, restname_out
+  CHARACTER(LEN=30) :: time_str, var_name
+!-
+  INTEGER :: it, istp, istp_old, rest_id, it_force
+!-
+  INTEGER :: split, split_start, nb_spread, for_offset
+  INTEGER :: itau_dep, itau_dep_rest, itau_fin, itau_skip, itau_len
+
+  INTEGER,DIMENSION(2) :: ml
+!-
+  LOGICAL :: last_CALL, first_CALL, debug
+  LOGICAL :: no_inter, inter_lin, netrad_cons
+!-
+  ! to check variables passed to intersurf
+  INTEGER :: ik
+  INTEGER :: i,j
+  LOGICAL, PARAMETER :: longprint = .FALSE.
+  INTEGER :: ierr
+
+  REAL, ALLOCATABLE, DIMENSION(:,:) :: &
+  & fluxsens_g,vevapp_g,old_zlev_g,old_qair_g,old_eair_g,for_rau_g, &
+  & petAcoef_g, petBcoef_g,peqAcoef_g,peqBcoef_g,albedo_g,z0_g
+  LOGICAL :: Flag
+
+  REAL :: fill_init
+
+  fill_init=REAL(nf90_fill_real,r_std)
+  CALL ioconf_expval(val_exp)
+!-
+! Init parallelism
+
+  CALL init_para(.FALSE.)
+  CALL init_timer
+  
+! driver only for process root
+  
+!---------------------------------------------------------------------
+!-
+! set debug to have more information
+!-
+  !Config  Key  = DEBUG_INFO
+  !Config  Desc = Flag for debug information
+  !Config  Def  = n
+  !Config  Help = This option allows to switch on the output of debug
+  !Config         information without recompiling the code.
+!-
+  debug = .FALSE.
+  CALL getin_p('DEBUG_INFO',debug)
+!=====================================================================
+!- 1.0 This section defines the general set-up of the experiment :
+!-   - Forcing data to be used with its time step
+!-   - Restart file to be used
+!-   - The time step that will be used
+!-   - The starting date of the simulation
+!-   - Length of integration
+!-   - Basic flags for SSIPSL
+!=====================================================================
+!- 1.1 Initialize the driving variables. It essentialy gets the mode
+!-     used and the size of the driving variables.
+!=====================================================================
+  IF (debug) WRITE(numout,*) 'Reading name of the forcing file'
+!- 
+ !Config  Key  = FORCING_FILE
+ !Config  Desc = Name of file containing the forcing data
+ !Config  Def  = islscp_for.nc
+ !Config  Help = This is the name of the file which should be opened
+ !Config         for reading the forcing data of the dim0 model.
+ !Config         The format of the file has to be netCDF and COADS
+ !Config         compliant.
+!- 
+  filename='islscp_for.nc'
+  CALL getin_p('FORCING_FILE',filename)
+!-
+  IF (debug) WRITE(numout,*) 'Opening forcing file'
+!-
+! We call flininfo to obtain the dimensions
+! of iim, jjm and others.
+! This information will allow us to allocate all the space needed.
+!-
+  CALL forcing_info &
+ &  (filename, iim, jjm, llm, tm, date0, dt_force, force_id) 
+!-
+  WRITE(numout,*) 'Out of flininfo : date0 ', date0, &
+       'iim, jjm, llm, tm',iim,jjm,llm,tm,' dt_force ',dt_force
+!-
+  IF (debug) THEN
+    WRITE(numout,*) 'Allocate memory for the driver :', iim, jjm, llm
+  ENDIF
+!-
+  ALLOCATE(lev(llm),levuv(llm))
+  ALLOCATE &
+ & (swdown(iim,jjm), precip_rain(iim,jjm), precip_snow(iim,jjm), &
+ &  tair_obs(iim,jjm), u(iim,jjm), v(iim,jjm), qair_obs(iim,jjm), &
+ &  pb(iim,jjm), lwdown(iim,jjm), &
+ &  eair_obs(iim,jjm), zlev_vec(iim,jjm), zlevuv_vec(iim,jjm), relax(iim,jjm))
+!- 
+  ALLOCATE &
+ & (petAcoef(iim,jjm), peqAcoef(iim,jjm), &
+ &  petBcoef(iim,jjm), peqBcoef(iim,jjm), &
+ &  cdrag(iim,jjm), for_u(iim,jjm), for_v(iim,jjm), &
+ &  for_swnet(iim,jjm), for_swdown(iim,jjm), for_lwdown(iim,jjm), &
+ &  for_psurf(iim,jjm), for_qair(iim,jjm), for_tair(iim,jjm), &
+ &  for_eair(iim,jjm), for_ccanopy(iim,jjm), for_rau(iim,jjm))
+!!$, &
+!!$ &  tmp_eair(iim,jjm), tmp_tair(iim,jjm), &
+!!$ &  tmp_qair(iim,jjm), tmp_pb(iim,jjm))
+!-
+  ALLOCATE &
+ & (for_contfrac(iim,jjm), for_neighbours(iim,jjm,8), for_resolution(iim,jjm,2), &
+ &  old_zlev(iim,jjm), old_qair(iim,jjm), old_eair(iim,jjm), &
+ &  tsol_rad(iim,jjm), vevapp(iim,jjm), &
+ &  temp_sol_NEW(iim,jjm), temp_sol_old(iim,jjm), &
+ &  dtdt(iim,jjm), coastalflow(iim,jjm), riverflow(iim,jjm), &
+ &  fluxsens(iim,jjm), fluxlat(iim,jjm), emis(iim,jjm), &
+ &  z0(iim,jjm), qsurf(iim,jjm))
+!!$, epot_sol(iim,jjm)
+!-
+  ALLOCATE(albedo(iim,jjm,2))
+  ALLOCATE(albedo_vis(iim,jjm),albedo_nir(iim,jjm))
+!-
+  ALLOCATE(kindex(iim*jjm))
+  ALLOCATE(lon(iim,jjm), lat(iim,jjm))
+!-- 
+  lev(:) = 0.0
+  levuv(:) = 0.0
+  swdown(:,:) = fill_init
+  precip_rain(:,:) = 0.0
+  precip_snow(:,:) = 0.0
+  tair_obs(:,:) = 0.0
+  u(:,:) = fill_init
+  v(:,:) = fill_init
+  qair_obs(:,:) = fill_init
+  pb(:,:) = fill_init
+  lwdown(:,:) = fill_init
+  eair_obs(:,:) = fill_init
+  zlev_vec(:,:) = 0.0
+  zlevuv_vec(:,:) = 0.0
+  relax(:,:) = 0.0
+  petAcoef(:,:) = 0.0
+  peqAcoef(:,:) = 0.0
+  petBcoef(:,:) = 0.0
+  peqBcoef(:,:) = 0.0
+  cdrag(:,:) = 0.0
+  for_u(:,:) = fill_init
+  for_v(:,:) = fill_init
+  for_swnet(:,:) = fill_init
+  for_swdown(:,:) = fill_init
+  for_lwdown(:,:) = fill_init
+  for_psurf(:,:) = fill_init
+  for_qair(:,:) = fill_init
+  for_tair(:,:) = fill_init
+  for_eair(:,:) = fill_init
+  for_ccanopy(:,:) = 0.0
+  for_rau(:,:) = fill_init
+  for_contfrac(:,:) = 0.0
+  for_neighbours(:,:,:) = 0
+  for_resolution(:,:,:) = 0.0
+  old_zlev(:,:) = 0.0
+  old_qair(:,:) = 0.0
+  old_eair(:,:) = 0.0
+  tsol_rad(:,:) = 0.0
+  vevapp(:,:) = 0.0
+  temp_sol_NEW(:,:) = fill_init
+  temp_sol_old(:,:) = fill_init
+  dtdt(:,:) = 0.0
+  coastalflow(:,:) = 0.0
+  riverflow(:,:) = 0.0
+  fluxsens(:,:) = 0.0
+  fluxlat(:,:) = 0.0
+  emis(:,:) = 0.0
+  z0(:,:) = fill_init
+  qsurf(:,:) = 0.0
+  albedo(:,:,:) = fill_init
+  albedo_vis(:,:) = fill_init
+  albedo_nir(:,:) = fill_init
+  kindex(:) = 0
+  lon(:,:) = 0.0
+  lat(:,:) = 0.0
+!-
+! We need to know the grid.
+! Then we can initialize the restart files, and then we
+! can give read the restart files in the forcing subroutine.
+!-
+  CALL forcing_grid (iim,jjm,llm,lon,lat,lev,levuv,init_f=.FALSE.)
+!=====================================================================
+!- 1.2 Time step to be used.
+!-     This is relative to the time step of the  forcing data
+!=====================================================================
+  IF ( .NOT. weathergen ) THEN
+     !Config  Key  = SPLIT_DT
+     !Config  Desc = splits the timestep imposed by the forcing
+     !Config  If NOT WEATHERGEN
+     !Config  Def  = 12
+     !Config  Help = With this value the time step of the forcing
+     !Config         will be devided. In principle this can be run
+     !Config         in explicit mode but it is strongly suggested
+     !Config         to use the implicit method so that the
+     !Config         atmospheric forcing has a smooth evolution.
+!-
+     split = 12
+     CALL getin_p('SPLIT_DT', split)
+  ELSE
+     split = 1
+  ENDIF
+!-
+! The time step which is going to be used is computed
+! from the forcing time step and the user input.
+!-
+  IF (split > 0) THEN
+     dt = dt_force/split
+  ELSE
+     split = 1
+     dt = dt_force
+  ENDIF
+!=====================================================================
+!- 1.3 Initialize the restart file for the driver
+!=====================================================================
+  !Config  Key  = RESTART_FILEIN
+  !Config  Desc = Name of restart to READ for initial conditions
+  !Config  Def  = NONE
+  !Config  Help = This is the name of the file which will be opened
+  !Config         to extract the initial values of all prognostic
+  !Config         values of the model. This has to be a netCDF file.
+  !Config         Not truly COADS compliant. NONE will mean that
+  !Config         no restart file is to be expected.
+!-
+  restname_in = 'NONE'
+  CALL getin_p('RESTART_FILEIN',restname_in)
+  if (debug) WRITE(numout,*) 'INPUT RESTART_FILE : ',TRIM(restname_in)
+!-
+  !Config Key  = RESTART_FILEOUT
+  !Config Desc = Name of restart files to be created by the driver
+  !Config Def  = driver_rest_out.nc
+  !Config Help = This variable give the  name for
+  !Config        the restart files. The restart software within
+  !Config        IOIPSL will add .nc if needed
+!-
+  restname_out = 'driver_rest_out.nc'
+  CALL getin_p('RESTART_FILEOUT', restname_out)
+  if (debug) WRITE(numout,*) 'OUTPUT RESTART_FILE : ',TRIM(restname_out)
+!-
+! We choose some default values for the chronology
+! of the restart file.
+!-
+  dt_rest = dt
+  date0_rest = date0
+!-
+! Set default values for the start and end of the simulation
+! in the forcing chronology.
+!-
+  itau_dep = 0
+  itau_dep_rest = 0
+  itau_fin = tm
+!-
+  CALL gather2D(lon,lon_g)
+  CALL gather2D(lat,lat_g)
+!-
+  if (debug) WRITE(numout,*) &
+ &   'Before Restart file initialization : itau_dep, itau_fin, date0, dt', &
+ &   itau_dep, itau_fin, date0, dt
+  
+  IF (is_root_prc) THEN
+     CALL restini &
+ &       (restname_in, iim_g, jjm_g, lon_g, lat_g, llm, lev, &
+ &        restname_out, itau_dep_rest, date0_rest, dt_rest, rest_id)
+!-
+     IF (debug) WRITE(numout,*) &
+ &       'For Restart file initialization : itau_dep_rest, date0_rest, dt_rest', &
+ &       itau_dep_rest, date0_rest, dt_rest
+!-
+!    MM When itau_dep_rest is not equal to itau_dep
+     IF (itau_dep /= itau_dep_rest) THEN
+        itau_dep = itau_dep_rest
+        itau_fin = itau_dep+tm
+     ENDIF
+  ENDIF
+  CALL bcast (itau_dep_rest)
+  CALL bcast (itau_dep)
+  CALL bcast (itau_fin)
+  CALL bcast (date0_rest)
+  CALL bcast (dt_rest)
+!-
+  WRITE(numout,*) &
+ & 'Restart file initialized : itau_dep, itau_fin, date0_rest, dt_rest', &
+ & itau_dep, itau_fin, date0_rest, dt_rest
+!=====================================================================
+!- 1.4 Here we do the first real reading of the driving. It only
+!-     gets a few variables.
+!=====================================================================
+!-
+  zlev_vec(:,:) = lev(1)
+!-
+!- In most forcing datas obtained from observations, the wind will be available
+!- another height than temperature and humidity. We will thus need to lower the
+!- wind to take this effect into account.
+!-
+  lower_wind=.FALSE.
+  IF ( ABS(lev(1) - levuv(1)) > EPSILON(lev) ) THEN
+     lower_wind=.TRUE.
+     zlevuv_vec(:,:) = levuv(1)
+  ELSE
+     lower_wind=.FALSE.
+     zlevuv_vec(:,:) = lev(1)
+  ENDIF
+!-
+! prepares kindex table from the information obtained
+! from the forcing data and reads some initial values for
+! temperature, etc.
+!- 
+  kindex(1) = 1
+!-
+  CALL forcing_READ &
+ &  (filename, rest_id, .TRUE., .FALSE., &
+ &   0, itau_dep, 0, split, nb_spread, netrad_cons, &
+ &   date0, dt_force, iim, jjm, lon, lat, zlev_vec, zlevuv_vec, tm, &
+ &   swdown, precip_rain, precip_snow, tair_obs, &
+ &   u, v, qair_obs, pb, lwdown, for_contfrac, for_neighbours, for_resolution, &
+ &   for_swnet, eair_obs, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, for_ccanopy, &
+ &   kindex, nbindex, force_id)
+!-
+  WRITE (numout,*) ">> Number of land points =",nbindex
+  IF (nbindex == 0) THEN
+     WRITE(numout,*) "Limits : (W,E / N,S)", limit_west, limit_east, &
+          &                             limit_north, limit_south
+     CALL ipslerr ( 3, 'dim2_driver','number of land points error.', &
+          &         ' is zero !','stop driver')
+  ENDIF
+
+  jlandindex = (((kindex(1:nbindex)-1)/iim) + 1)
+  ilandindex = (kindex(1:nbindex) - (jlandindex(1:nbindex)-1)*iim)
+  IF (longprint) THEN
+     WRITE(numout,*) "kindex of land points : ", kindex(1:nbindex)
+     WRITE(numout,*) "index i of land points : ", ilandindex
+     WRITE(numout,*) "index j of land points : ", jlandindex 
+  ENDIF
+
+  IF (is_watchout) THEN
+     lower_wind = .FALSE.
+  ENDIF
+  IF (debug) WRITE(numout,*) "lower wind : ",lower_wind
+
+!-
+  im = iim; jm = jjm; lm = llm;
+  IF ( (iim > 1).AND.(jjm > 1) ) THEN
+    jtest = INT((kindex(INT(nbindex/2))-1)/iim)+1
+    itest = MAX( 1, kindex(INT(nbindex/2))-(jtest-1)*iim )
+  ELSE
+    jtest = 1
+    itest = 1
+  ENDIF
+  IF (debug) WRITE(numout,*) "test point in dim2_driver : ",itest,jtest
+!-
+  IF ((im /= iim) .AND. (jm /= jjm) .AND. (lm /= llm))  THEN
+    WRITE(numout,*) ' dimensions are not good. Verify FILE :'
+    WRITE(numout,*) ' filename = ',filename
+    WRITE(numout,*) ' im, jm, lm lus         = ', im, jm, lm
+    WRITE(numout,*) ' iim, jjm, llm demandes = ', iim, jjm, llm
+    STOP 'dim2_driver'
+  ENDIF  
+!=====================================================================
+!- 1.5  Configures the time-steps and other parameters 
+!-      of the run.
+!=====================================================================
+!-
+! If the time steping of the restart is different from the one
+! of the forcing we need to convert the itau_dep into the
+! chronology of the forcing. This ensures that the forcing will
+! start at the date of the restart file. Obviously the itau_fin
+! needs to be shifted as well !
+!-
+  IF ( (dt_rest /= dt_force).AND.(itau_dep > 1) ) THEN
+    itau_dep = NINT((itau_dep*dt_rest )/dt_force)
+    itau_fin = itau_dep+tm
+    if (debug) WRITE(numout,*) &
+ & 'The time steping of the restart is different from the one ',&
+ & 'of the forcing we need to convert the itau_dep into the ',&
+ & 'chronology of the forcing. This ensures that the forcing will ',&
+ & 'start at the date of the restart file. Obviously the itau_fin ',&
+ & 'needs to be shifted as well : itau_dep, itau_fin ', &
+ & itau_dep, itau_fin
+  ENDIF
+!-
+! Same things if the starting dates are not the same.
+! Everything should look as if we had only one forcing file !
+!-
+  IF (date0 /= date0_rest) THEN
+    WRITE(numout,*) 'date0_rest , date0 : ',date0_rest , date0
+    for_offset = NINT((date0_rest-date0)*one_day/dt_force)
+    date0 = date0_rest
+  ELSE
+    for_offset = 0
+  ENDIF
+  WRITE(numout,*) 'OFFSET FOR THE data read :', for_offset
+
+  CALL ioconf_startdate(date0)
+!-
+  !Config  Key  = TIME_SKIP
+  !Config  Desc = Time in the forcing file at which the model
+  !Config         is started.
+  !Config  Def  = 0
+  !Config  Help = This time give the point in time at which the model
+  !Config         should be started. If exists, the date of the restart file is use.
+  !Config  The FORMAT of this date can be either of the following :
+  !Config  n   : time step n within the forcing file
+  !Config  nS  : n seconds after the first time-step in the file
+  !Config  nD  : n days after the first time-step
+  !Config  nM  : n month after the first time-step (year of 365 days)
+  !Config  nY  : n years after the first time-step (year of 365 days)
+  !Config         Or combinations :
+  !Config  nYmM: n years and m month
+!-
+  itau_skip = 0
+  WRITE(time_str,'(I10)') itau_skip
+  CALL getin_p('TIME_SKIP', time_str)
+!-
+! Transform into itau
+!-
+  CALL tlen2itau (time_str, dt_force, date0, itau_skip)
+!-
+  itau_dep = itau_dep+itau_skip
+!-
+! We need to select the right position of the splited time steps.
+!-
+  istp = itau_dep*split+1
+  IF (MOD(istp-1,split) /= 0) THEN
+    split_start = MOD(istp-1,split)+1
+  ELSE
+    split_start = 1
+  ENDIF
+  istp_old = itau_dep_rest
+!!$  it_force = MAX(MOD(itau_dep,INT(one_day*one_year/dt_force)),1)+itau_skip
+!!$  WRITE(numout,*) 'itau_dep, it_force :', itau_dep, it_force
+!-
+  itau_len = itau_fin-itau_dep
+!-
+  !Config  Key  = TIME_LENGTH
+  !Config  Desc = Length of the integration in time.
+  !Config  Def  = DEF
+  !Config  Help = Length of integration. By default the entire length
+  !Config         of the forcing is used. The FORMAT of this date can
+  !Config         be either of the following :
+  !Config  n   : time step n within the forcing file
+  !Config  nS  : n seconds after the first time-step in the file
+  !Config  nD  : n days after the first time-step
+  !Config  nM  : n month after the first time-step (year of 365 days)
+  !Config  nY  : n years after the first time-step (year of 365 days)
+  !Config         Or combinations :
+  !Config  nYmM: n years and m month
+!-
+  WRITE(time_str,'(I10)') itau_len
+  CALL getin_p('TIME_LENGTH', time_str)
+!-
+! Transform into itau
+!-
+  CALL tlen2itau (time_str, dt_force, date0, itau_len)
+!-
+  itau_fin = itau_dep+itau_len
+!-
+  WRITE(numout,*) '>> Time origine in the forcing file :', date0
+  WRITE(numout,*) '>> Time origine in the restart file :', date0_rest
+  WRITE(numout,*) '>> Simulate starts at forcing time-step : ', itau_dep
+  WRITE(numout,*) '>> The splited time-steps start at (Sets the '
+  WRITE(numout,*) '>>  chronology for the history and restart files):',istp
+  WRITE(numout,*) '>> The time spliting starts at :', split_start
+  WRITE(numout,*) '>> Simulation ends at forcing time-step: ', itau_fin
+  WRITE(numout,*) '>> Length of the simulation is thus :', itau_len
+  WRITE(numout,*) '>> Length of the forcing data is in time-steps : ', tm
+  IF (tm < itau_len) THEN
+     CALL ipslerr ( 2, 'dim2_driver','Length of the simulation is greater than.', &
+ &         ' Length of the forcing data is in time-steps','verify TIME_LENGTH parameter.')
+  ENDIF
+  WRITE(numout,*) '>> Time steps : true, forcing and restart : ', dt,dt_force,dt_rest
+
+!=====================================================================
+!- 2.0 This section is going to define the details by which
+!-     the input data is going to be used to force the
+!-     land-surface scheme. The tasks are the following :
+!-   - Is the coupling going to be explicit or implicit
+!-   - Type of interpolation to be used.
+!-   - At which height are the atmospheric forcings going to be used ?
+!-   - Is a relaxation method going to be used on the forcing
+!-   - Does net radiation in the interpolated data need to be conserved
+!-   - How do we distribute precipitation.
+!=====================================================================
+  !Config  Key  = RELAXATION
+  !Config  Desc = method of forcing
+  !Config  Def  = n
+  !Config  Help = A method is proposed by which the first atmospheric
+  !Config         level is not directly forced by observations but
+  !Config         relaxed with a time constant towards observations.
+  !Config         For the moment the methods tends to smooth too much
+  !Config         the diurnal cycle and introduces a time shift.
+  !Config         A more sophisticated method is needed.
+!-
+  relaxation = .FALSE.
+  CALL getin_p('RELAXATION', relaxation)  
+  IF ( relaxation ) THEN
+     WRITE(numout,*) 'dim2_driver : The relaxation option is temporarily disabled as it does not'
+     WRITE(numout,*) '              produce energy conservation in ORCHIDEE. If you intend to use it'
+     WRITE(numout,*) '              you should validate it.'
+     STOP 'dim2_driver'
+!- 
+     !Config  Key  = RELAX_A
+     !Config  Desc = Time constant of the relaxation layer
+     !Config  If   = RELAXATION
+     !Config  Def  = 1.0
+     !Config  Help = The time constant associated to the atmospheric
+     !Config         conditions which are going to be computed
+     !Config         in the relaxed layer. To avoid too much
+     !Config         damping the value should be larger than 1000.
+!-
+     alpha = 1000.0
+     CALL getin_p('RELAX_A', alpha)
+  ENDIF
+!-
+  !Config  Key  = NO_INTER||INTER_LIN
+  !Config  Desc = Interpolation or not IF split is larger than 1
+  !Config  Def  = NO_INTER
+  !Config  Help = Choose IF you wish to interpolate linearly or not.
+!-
+  no_inter = .TRUE.
+  inter_lin = .FALSE.
+  CALL getin_p('NO_INTER', no_inter)
+  CALL getin_p('INTER_LIN', inter_lin)
+!-
+  IF (inter_lin) THEN
+     no_inter = .FALSE.
+  ELSE
+     no_inter = .TRUE.
+  ENDIF
+!-
+  IF (split == 1) THEN
+    no_inter = .TRUE.
+    inter_lin = .FALSE.
+  ENDIF
+!-
+  !Config  Key  = SPRED_PREC
+  !Config  Desc = Spread the precipitation.
+  !Config  Def  = 1
+  !Config  Help = Spread the precipitation over n steps of the splited forcing 
+  !Config         time step. This ONLY applied if the forcing time step has been splited.
+  !Config         If the value indicated is greater than SPLIT_DT, SPLIT_DT is used for it.
+!-
+  nb_spread = 1
+  CALL getin_p('SPRED_PREC', nb_spread)  
+  IF (nb_spread > split) THEN
+    WRITE(numout,*) 'WARNING : nb_spread is too large it will be '
+    WRITE(numout,*) '          set to the value of split'
+    nb_spread = split
+  ELSE IF (split == 1) THEN
+    nb_spread = 1
+  ENDIF
+!-
+  IF (inter_lin) THEN
+     !Config  Key  = NETRAD_CONS
+     !Config  Desc = Conserve net radiation in the forcing
+     !Config  Def  = y
+     !Config  If  = INTER_LIN
+     !Config  Help = When the interpolation is used the net radiation
+     !Config         provided by the forcing is not conserved anymore.
+     !Config         This should be avoided and thus this option should
+     !Config         be TRUE (y).
+     !Config         This option is not used for short-wave if the
+     !Config         time-step of the forcing is longer than an hour.
+     !Config         It does not make sense to try and reconstruct
+     !Config         a diurnal cycle and at the same time conserve the 
+     !Config         incoming solar radiation.
+     !-
+     netrad_cons = .TRUE.
+     CALL getin_p('NETRAD_CONS', netrad_cons)
+  ELSE
+     netrad_cons = .FALSE.
+  ENDIF
+!=====================================================================
+!- 3.0 Finaly we can prepare all the variables before launching
+!-     the simulation !
+!=====================================================================
+! Initialize LOGICAL and the length of the integration
+!-
+  last_CALL = .FALSE.
+  first_CALL = .TRUE.
+!-
+  temp_sol_NEW(:,:) = tp_00
+!-  
+  !Config  Key  = ATM_CO2
+  !Config  Desc = Value for atm CO2 
+  !Config  Def  = 350.
+  !Config  Help = Value to prescribe the atm CO2.
+  !Config         For pre-industrial simulations, the value is 286.2 .
+  !Config         348. for 1990 year.
+!-
+  atmco2=350.
+  CALL getin_p('ATM_CO2',atmco2)
+  for_ccanopy(:,:)=atmco2
+!-
+! Preparing for the implicit scheme.
+! This means loading the prognostic variables from the restart file.
+!-
+  Flag=.FALSE.
+  IF (is_root_prc) THEN
+     ALLOCATE(fluxsens_g(iim_g,jjm_g))
+     var_name= 'fluxsens'
+     CALL restget &
+ &        (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., fluxsens_g)
+     IF (ALL(fluxsens_g(:,:) == val_exp)) THEN
+        Flag=.TRUE.
+     ELSE
+        Flag=.FALSE.
+     ENDIF
+  ELSE
+     ALLOCATE(fluxsens_g(0,1))
+  ENDIF
+  CALL bcast(Flag)
+  IF (.NOT. Flag) THEN
+     CALL scatter2D(fluxsens_g,fluxsens)
+  ELSE
+     fluxsens(:,:) = zero
+  ENDIF
+  DEALLOCATE(fluxsens_g)
+!-
+  IF (is_root_prc) THEN
+     ALLOCATE(vevapp_g(iim_g,jjm_g))
+     var_name= 'vevapp'
+     CALL restget &
+ &        (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., vevapp_g)
+     IF (ALL(vevapp_g(:,:) == val_exp)) THEN
+        Flag=.TRUE.
+     ELSE
+        Flag=.FALSE.
+     ENDIF
+  ELSE
+     ALLOCATE(vevapp_g(0,1))
+  ENDIF
+  CALL bcast(Flag)
+  IF (.NOT. Flag) THEN
+     CALL scatter2D(vevapp_g,vevapp)
+  ELSE
+     vevapp(:,:) = zero
+  ENDIF
+  DEALLOCATE(vevapp_g)
+!-
+  IF (is_root_prc) THEN
+     ALLOCATE(old_zlev_g(iim_g,jjm_g))
+     var_name= 'zlev_old'
+     CALL restget &
+ &        (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., old_zlev_g)
+     IF (ALL(old_zlev_g(:,:) == val_exp)) THEN
+        Flag=.TRUE.
+     ELSE
+        Flag=.FALSE.
+     ENDIF
+  ELSE
+     ALLOCATE(old_zlev_g(0,1))
+  ENDIF
+  CALL bcast(Flag)
+  IF ( .NOT. Flag ) THEN
+     CALL scatter2D(old_zlev_g,old_zlev)
+  ELSE
+     old_zlev(:,:)=zlev_vec(:,:)
+  ENDIF
+  DEALLOCATE(old_zlev_g)
+!-
+  IF (is_root_prc) THEN
+     ALLOCATE(old_qair_g(iim_g,jjm_g))
+     var_name= 'qair_old'
+     CALL restget &
+ &       (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., old_qair_g)
+    IF (ALL(old_qair_g(:,:) == val_exp)) THEN
+      Flag=.TRUE.
+    ELSE
+      Flag=.FALSE.
+    ENDIF
+  ELSE
+     ALLOCATE(old_qair_g(0,1))
+  ENDIF
+  CALL bcast(Flag)
+  IF ( .NOT. Flag ) THEN
+     CALL scatter2D(old_qair_g,old_qair)
+  ELSE
+     old_qair(:,:) = qair_obs(:,:)
+  ENDIF
+  DEALLOCATE(old_qair_g)
+!-
+  IF (is_root_prc) THEN
+     ALLOCATE(old_eair_g(iim_g,jjm_g))
+     var_name= 'eair_old'
+     CALL restget &
+ &        (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., old_eair_g)
+    IF (ALL(old_eair_g(:,:) == val_exp)) THEN
+      Flag=.TRUE.
+    ELSE
+      Flag=.FALSE.
+    ENDIF
+  ELSE
+     ALLOCATE(old_eair_g(0,1))
+  ENDIF
+  CALL bcast(Flag)
+  IF ( .NOT. Flag ) THEN
+     CALL scatter2D(old_eair_g,old_eair)
+  ELSE
+     DO ik=1,nbindex
+        i=ilandindex(ik)
+        j=jlandindex(ik)
+        old_eair(i,j) = cp_air * tair_obs(i,j) + cte_grav*zlev_vec(i,j)
+     ENDDO
+  ENDIF
+  DEALLOCATE(old_eair_g)
+!-
+! old density is also needed because we do not yet have the right pb
+!-
+!=> obsolète ??!! (tjrs calculé après forcing_read) 
+  IF (is_root_prc) THEN
+     ALLOCATE(for_rau_g(iim_g,jjm_g))
+     var_name= 'rau_old'
+     CALL restget &
+ &        (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., for_rau_g)
+    IF (ALL(for_rau_g(:,:) == val_exp)) THEN
+      Flag=.TRUE.
+    ELSE
+      Flag=.FALSE.
+    ENDIF
+  ELSE
+     ALLOCATE(for_rau_g(0,1))
+  ENDIF
+  CALL bcast(Flag)
+  IF ( .NOT. Flag ) THEN
+     CALL scatter2D(for_rau_g,for_rau)
+  ELSE
+     DO ik=1,nbindex
+        i=ilandindex(ik)
+        j=jlandindex(ik)
+        for_rau(i,j) = pb(i,j)/(cte_molr*(tair_obs(i,j)))
+     ENDDO
+  ENDIF
+  DEALLOCATE(for_rau_g)
+!-
+! For this variable the restart is extracted by SECHIBA
+!-
+  temp_sol_NEW(:,:) = tair_obs(:,:)
+!- 
+  if (.NOT. is_watchout) THEN
+!-
+!   This does not yield a correct restart in the case of relaxation
+!-
+     IF (is_root_prc) THEN
+        ALLOCATE(petAcoef_g(iim_g,jjm_g))
+        var_name= 'petAcoef'
+        CALL restget &
+ &           (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., petAcoef_g)
+        IF (ALL(petAcoef_g(:,:) == val_exp)) THEN
+           Flag=.TRUE.
+        ELSE
+           Flag=.FALSE.
+        ENDIF
+     ELSE
+        ALLOCATE(petAcoef_g(0,1))
+     ENDIF
+     CALL bcast(Flag)
+     IF ( .NOT. Flag ) THEN
+        CALL scatter2D(petAcoef_g,petAcoef)
+     ELSE
+        petAcoef(:,:) = zero
+     ENDIF
+     DEALLOCATE(petAcoef_g)
+!--
+     IF (is_root_prc) THEN
+        ALLOCATE(petBcoef_g(iim_g,jjm_g))
+        var_name= 'petBcoef'
+        CALL restget &
+ &           (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., petBcoef_g)
+        IF (ALL(petBcoef_g(:,:) == val_exp)) THEN
+           Flag=.TRUE.
+        ELSE
+           Flag=.FALSE.
+        ENDIF
+     ELSE
+        ALLOCATE(petBcoef_g(0,1))
+     ENDIF
+     CALL bcast(Flag)
+     IF ( .NOT. Flag ) THEN
+        CALL scatter2D(petBcoef_g,petBcoef)
+     ELSE
+        petBcoef(:,:) = old_eair(:,:)
+     ENDIF
+     DEALLOCATE(petBcoef_g)
+!--
+     IF (is_root_prc) THEN
+        ALLOCATE(peqAcoef_g(iim_g,jjm_g))
+        var_name= 'peqAcoef'
+        CALL restget &
+ &           (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., peqAcoef_g)
+        IF (ALL(peqAcoef_g(:,:) == val_exp)) THEN
+           Flag=.TRUE.
+        ELSE
+           Flag=.FALSE.
+        ENDIF
+     ELSE
+        ALLOCATE(peqAcoef_g(0,1))
+     ENDIF
+     CALL bcast(Flag)
+     IF ( .NOT. Flag ) THEN
+        CALL scatter2D(peqAcoef_g,peqAcoef)
+     ELSE
+        peqAcoef(:,:) = zero
+     ENDIF
+     DEALLOCATE(peqAcoef_g)
+!--
+     IF (is_root_prc) THEN
+        ALLOCATE(peqBcoef_g(iim_g,jjm_g))
+        var_name= 'peqBcoef'
+        CALL restget &
+ &           (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., peqBcoef_g)
+        IF (ALL(peqBcoef_g(:,:) == val_exp)) THEN
+           Flag=.TRUE.
+        ELSE
+           Flag=.FALSE.
+        ENDIF
+     ELSE
+        ALLOCATE(peqBcoef_g(0,1))
+     ENDIF
+     CALL bcast(Flag)
+     IF ( .NOT. Flag ) THEN
+        CALL scatter2D(peqBcoef_g,peqBcoef)
+     ELSE
+        peqBcoef(:,:) = old_qair(:,:)
+     ENDIF
+     DEALLOCATE(peqBcoef_g)
+  ENDIF
+!-
+! And other variables which need initial variables. These variables
+! will get properly initialized by ORCHIDEE when it is called for 
+! the first time.
+!-
+  albedo(:,:,:) = 0.13
+  emis(:,:) = 1.0
+  z0(:,:) = 0.1
+!--
+!=====================================================================
+!- 4.0 START THE TIME LOOP
+!=====================================================================
+
+  CALL init_timer   
+
+  it = itau_dep+1
+  DO WHILE ( it <= itau_fin )
+!----
+    it_force = it+for_offset
+    IF (it_force < 0) THEN
+      WRITE(numout,*) 'The day is not in the forcing file :', &
+ &               it_force, it, for_offset
+      STOP 'dim2_driver'
+    ENDIF
+!!$    IF (it_force > itau_dep+tm) THEN
+!!$       WRITE(numout,*) 'ERROR : more time-steps than data'
+!!$       WRITE(numout,*) 'it_force : ', it_force, ' itau_dep+tm : ', itau_dep+tm
+!!$      STOP 'dim2_driver'
+!!$    ENDIF 
+!---
+    is=split_start
+    DO WHILE ( is <= split )
+!-----
+      julian = itau2date(istp, date0, dt)
+      CALL ju2ymds(julian, yy, mm, dd, ss)
+      IF (debug) THEN
+         WRITE(numout,*) "=============================================================="
+         WRITE(numout,"('New iteration at date : ',I4,'-',I2.2,'-',I2.2,':',F8.4)") &
+              &               yy,mm,dd,ss/3600.
+#ifdef CPP_PARA
+         IF (is_root_prc) THEN
+            WRITE(*,*) "=============================================================="
+            WRITE(*,"('New iteration at date : ',I4,'-',I2.2,'-',I2.2,':',F8.4)") &
+              &               yy,mm,dd,ss/3600.
+         ENDIF
+#endif
+      ENDIF
+!----- 
+      IF ( (it == itau_fin).AND.(is == split) ) THEN
+        last_CALL = .TRUE.
+      ENDIF
+!-----
+      IF (debug) WRITE(numout,*) 'Into forcing_read'
+!-----
+      CALL forcing_READ &
+ &      (filename, rest_id, .FALSE., last_call, &
+ &       it_force, istp, is, split, nb_spread, netrad_cons, &
+ &       date0, dt_force, iim, jjm, lon, lat, zlev_vec, zlevuv_vec, tm, &
+ &       swdown, precip_rain, precip_snow, tair_obs, &
+ &       u, v, qair_obs, pb, for_lwdown, for_contfrac, for_neighbours, for_resolution, &
+ &       for_swnet, eair_obs, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, for_ccanopy, &
+ &       kindex, nbindex, force_id)
+
+!-----
+!---- SECHIBA expects surface pressure in hPa
+!-----
+      for_psurf(:,:)  = pb(:,:)/100.
+
+      IF (longprint) THEN
+         WRITE(numout,*) "dim2_driver 0 ",it_force 
+         WRITE(numout,*) ">> Index of land points =",kindex(1:nbindex)
+         WRITE(numout,*) "Lowest level wind speed North = ", &
+              & (/ ( u(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Lowest level wind speed East = ", &
+              & (/ ( v(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "z0            ; Surface roughness = ", &
+              & (/ ( z0(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Height of first layer = ", &
+              & (/ ( zlev_vec(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Lowest level specific humidity = ", &
+              & (/ ( qair_obs(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Rain precipitation = ", &
+              & (/ ( precip_rain(ilandindex(ik), jlandindex(ik))*dt,ik=1,nbindex ) /)
+         WRITE(numout,*) "Snow precipitation = ", &
+              & (/ ( precip_snow(ilandindex(ik), jlandindex(ik))*dt,ik=1,nbindex ) /)
+         WRITE(numout,*) "Down-welling long-wave flux = ", &
+              & (/ ( for_lwdown(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Net surface short-wave flux = ", &
+              & (/ ( for_swnet(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Downwelling surface short-wave flux = ", &
+              & (/ ( swdown(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Air temperature in Kelvin = ", &
+              & (/ ( tair_obs(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Air potential energy = ", &
+              & (/ ( eair_obs(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "CO2 concentration in the canopy = ", &
+              & (/ ( for_ccanopy(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Coeficients A from the PBL resolution = ", &
+              & (/ ( petAcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "One for T and another for q = ", &
+              & (/ ( peqAcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Coeficients B from the PBL resolution = ", &
+              & (/ ( petBcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "One for T and another for q = ", &
+              & (/ ( peqBcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Cdrag = ", &
+              & (/ ( cdrag(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /) 
+         WRITE(numout,*) "CO2 concentration in the canopy = ", &
+              & (/ ( for_ccanopy(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /) 
+         WRITE(numout,*) "Lowest level pressure = ", &
+              & (/ ( for_psurf(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Geographical coordinates lon = ", &
+              & (/ (  lon(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Geographical coordinates lat = ", &
+              & (/ (  lat(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Fraction of continent in the grid = ", &
+              & (/ ( for_contfrac(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+      ENDIF
+!-----
+!---- Prepare : tmp_qair, tmp_eair, tmp_tair, tmp_pb
+!---- and     : for_u, for_v, for_lwdown, for_swnet, for_swdown
+!---- All the work is done in forcing_read
+!---- We do not need the no_inter options as we will
+!---- allways interpolate
+!----- 
+      IF (debug) WRITE(numout,*) 'Prepare the atmospheric forcing'
+!----- 
+      IF (.NOT. is_watchout) THEN
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            eair_obs(i,j) = cp_air*tair_obs(i,j)+cte_grav*zlev_vec(i,j)
+            for_swnet(i,j) = (1.-(albedo(i,j,1)+albedo(i,j,2))/2.)*swdown(i,j)
+         ENDDO
+      ENDIF
+      DO ik=1,nbindex
+         i=ilandindex(ik)
+         j=jlandindex(ik)
+         for_swdown(i,j) = swdown(i,j)
+      ENDDO
+!----- 
+!---- Computing the buffer zone !
+!----- 
+      IF (relaxation) THEN
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            for_qair(i,j) = peqAcoef(i,j)*(-1.) * vevapp(i,j)*dt+peqBcoef(i,j)
+!-------
+            for_eair(i,j) = petAcoef(i,j)*(-1.) * fluxsens(i,j)+petBcoef(i,j)
+!-------
+         ENDDO
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            for_tair(i,j) = (for_eair(i,j) - cte_grav*zlev_vec(i,j))/cp_air
+!-------
+!!$        if (.NOT. is_watchout) &
+!!$             epot_sol(:,:) = cp_air*temp_sol_NEW(:,:)
+!-------
+         ENDDO
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            for_rau(i,j) = pb(i,j) / (cte_molr*for_tair(i,j))
+!-------
+            relax(i,j) = for_rau(i,j)*alpha 
+         ENDDO
+         zlflu = lev(1)/2.0*dt
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            peqAcoef(i,j) = 1.0/(zlflu+relax(i,j))
+            peqBcoef(i,j) = (relax(i,j) * qair_obs(i,j)/(zlflu+relax(i,j))) + & 
+                 & for_qair(i,j)/(1.0+relax(i,j)/zlflu)
+         ENDDO
+!-------
+!        relax(:,:) = for_rau(:,:)*alpha 
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            petAcoef(i,j) = 1.0/(zlflu+relax(i,j))
+            petBcoef(i,j) = ( relax(i,j) * eair_obs(i,j) / (zlflu+relax(i,j)) ) &
+                 & + for_eair(i,j)/(1.0+relax(i,j)/zlflu)
+         ENDDO
+      ELSE
+         for_qair(:,:) = fill_init
+         for_eair(:,:) = fill_init
+         for_tair(:,:) = fill_init
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            for_qair(i,j) = qair_obs(i,j)
+            for_eair(i,j) = eair_obs(i,j)
+            for_tair(i,j) = tair_obs(i,j)
+         ENDDO
+!-------
+!!$        if (.NOT. is_watchout) &
+!!$             epot_sol(:,:) =  cp_air*temp_sol_NEW(:,:)
+!-------
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            for_rau(i,j) = pb(i,j) / (cte_molr*for_tair(i,j))
+         ENDDO
+!-------
+         IF (.NOT. is_watchout) THEN
+           petAcoef(:,:) = 0.0
+           peqAcoef(:,:) = 0.0
+           DO ik=1,nbindex
+              i=ilandindex(ik)
+              j=jlandindex(ik)
+              petBcoef(i,j) = eair_obs(i,j)
+              peqBcoef(i,j) = qair_obs(i,j)
+           ENDDO
+        ENDIF
+      ENDIF
+!-----
+      IF (.NOT. is_watchout) &
+           cdrag(:,:)  = 0.0
+      for_ccanopy(:,:)=atmco2
+!-----
+!---- SECHIBA expects wind, temperature and humidity at the same height.
+!---- If this is not the case then we need to correct for that.
+!-----
+      IF ( lower_wind .AND. .NOT. is_watchout ) THEN
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            for_u(i,j) = u(i,j)*LOG(zlev_vec(i,j)/z0(i,j)) / &
+                 &              LOG(zlevuv_vec(i,j)/z0(i,j))
+            for_v(i,j) = v(i,j)*LOG(zlev_vec(i,j)/z0(i,j)) / &
+                 &              LOG(zlevuv_vec(i,j)/z0(i,j))
+         ENDDO
+      ELSE
+         DO ik=1,nbindex
+            i=ilandindex(ik)
+            j=jlandindex(ik)
+            for_u(i,j) = u(i,j)
+            for_v(i,j) = v(i,j)
+         ENDDO
+      ENDIF
+!-----
+!---- Prepare the other variables WITH the special CASE
+!---- of splited time steps
+!----
+!---- PRINT input value for debug
+!-----
+      IF (debug) THEN
+        WRITE(numout,*) ' >>>>>> time step it_force = ',it_force
+        WRITE(numout,*) &
+ &       ' tair, qair, eair = ', &
+ &       for_tair(itest,jtest),for_qair(itest,jtest), &
+ &       for_eair(itest,jtest)
+        WRITE(numout,*) &
+ &       ' OBS : tair, qair, eair = ', &
+ &       tair_obs(itest,jtest),qair_obs(itest,jtest), &
+ &       eair_obs(itest,jtest)
+        WRITE(numout,*) ' u et v = ',for_u(itest,jtest),for_v(itest,jtest)
+        WRITE(numout,*) ' precip rain et snow = ', &
+        & precip_rain(itest,jtest),precip_snow(itest,jtest)
+        WRITE(numout,*) ' lwdown et swnet = ', &
+        & for_lwdown(itest,jtest),for_swnet(itest,jtest)
+        WRITE(numout,*) ' petAcoef et peqAcoef = ', &
+        & petAcoef(itest,jtest), peqAcoef(itest,jtest)
+        WRITE(numout,*) ' petBcoef et peqAcoef = ', &
+        & petBcoef(itest,jtest),peqBcoef(itest,jtest)
+        WRITE(numout,*) ' zlev = ',zlev_vec(itest,jtest)
+      ENDIF
+!-----
+      IF (first_CALL) THEN
+
+        DO ik=1,nbindex
+           i=ilandindex(ik)
+           j=jlandindex(ik)
+           for_swdown(i,j) = swdown(i,j)
+        ENDDO
+        IF (longprint) THEN
+           WRITE(numout,*) "dim2_driver first_CALL ",it_force 
+           WRITE(numout,*) ">> Index of land points =",kindex(1:nbindex)
+           WRITE(numout,*) "Lowest level wind speed North = ", &
+             &     (/ ( for_u(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Lowest level wind speed East = ", &
+             &     (/ ( for_v(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "z0            ; Surface roughness = ", &
+             &     (/ ( z0(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Height of first layer = ", &
+             &     (/ ( zlev_vec(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Lowest level specific humidity = ", &
+             &     (/ ( for_qair(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Rain precipitation = ", &
+             &     (/ ( precip_rain(ilandindex(ik), jlandindex(ik))*dt,ik=1,nbindex ) /)
+           WRITE(numout,*) "Snow precipitation = ", &
+             &     (/ ( precip_snow(ilandindex(ik), jlandindex(ik))*dt,ik=1,nbindex ) /)
+           WRITE(numout,*) "Down-welling long-wave flux = ", &
+             &     (/ ( for_lwdown(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Net surface short-wave flux = ", &
+             &     (/ ( for_swnet(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Downwelling surface short-wave flux = ", &
+             &     (/ ( for_swdown(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Air temperature in Kelvin = ", &
+             &     (/ ( for_tair(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Air potential energy = ", &
+             &     (/ ( for_eair(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "CO2 concentration in the canopy = ", &
+             &     (/ ( for_ccanopy(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Coeficients A from the PBL resolution = ", &
+             &     (/ ( petAcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "One for T and another for q = ", &
+             &     (/ ( peqAcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Coeficients B from the PBL resolution = ", &
+             &     (/ ( petBcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "One for T and another for q = ", &
+             &     (/ ( peqBcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Cdrag = ", &
+             &     (/ ( cdrag(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Lowest level pressure = ", &
+             &     (/ ( for_psurf(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Geographical coordinates lon = ", &
+             &     (/ (  lon(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Geographical coordinates lat = ", &
+             &     (/ (  lat(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Fraction of continent in the grid = ", &
+             &     (/ ( for_contfrac(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+        ENDIF
+!-------
+!------ CALL sechiba to initialize fields
+!------ and have some initial results: emis, albedo, z0
+!-------
+        CALL intersurf_main &
+ &        (istp_old, iim, jjm, nbindex, kindex, dt, &
+ &         first_CALL, .FALSE., lon, lat, for_contfrac, for_neighbours, for_resolution, date0, &
+!       first level conditions
+ &         zlev_vec, for_u, for_v, &
+ &         for_qair, for_tair, for_eair, for_ccanopy, &
+!       Variables for the implicit coupling
+ &         cdrag, petAcoef, peqAcoef, petBcoef, peqBcoef, &
+!       Rain, snow, radiation and surface pressure
+ &         precip_rain, precip_snow, &
+ &         for_lwdown, for_swnet, for_swdown, for_psurf, &
+!       Output : Fluxes
+ &         vevapp, fluxsens, fluxlat, coastalflow, riverflow,  &
+!       Surface temperatures and surface properties
+ &         tsol_rad, temp_sol_NEW, qsurf, albedo, emis, z0)
+
+        !
+        first_CALL = .FALSE.
+        !
+        ! Get Restart values for albedo and z0, 
+        ! as they modify forcing variables swnet and wind.
+!-------
+        ! albedo 
+        IF (is_root_prc) THEN
+           ALLOCATE(albedo_g(iim_g,jjm_g))
+        ELSE
+           ALLOCATE(albedo_g(0,1))
+        ENDIF
+        !
+        IF (is_root_prc) THEN
+           var_name= 'albedo_vis'
+           CALL restget &
+                &        (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., albedo_g)
+           IF (ALL(albedo_g(:,:) == val_exp)) THEN
+              Flag=.TRUE.
+           ELSE
+              Flag=.FALSE.
+           ENDIF
+        ENDIF
+        CALL bcast(Flag)
+        IF ( .NOT. Flag ) THEN
+           CALL scatter2D(albedo_g,albedo_vis)
+           albedo(:,:,1)=albedo_vis(:,:)
+        ELSE
+           albedo_vis(:,:)=albedo(:,:,1)
+        ENDIF
+        !
+        IF (is_root_prc) THEN
+           var_name= 'albedo_nir'
+           CALL restget &
+                &        (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., albedo_g)
+           IF (ALL(albedo_g(:,:) == val_exp)) THEN
+              Flag=.TRUE.
+           ELSE
+              Flag=.FALSE.
+           ENDIF
+        ENDIF
+        CALL bcast(Flag)
+        IF ( .NOT. Flag ) THEN
+           CALL scatter2D(albedo_g,albedo_nir)
+           albedo(:,:,2)=albedo_nir(:,:)
+        ELSE
+           albedo_nir(:,:)=albedo(:,:,2)
+        ENDIF
+        !
+        DEALLOCATE(albedo_g)
+        !--
+        ! z0 
+        IF (is_root_prc) THEN
+           ALLOCATE(z0_g(iim_g,jjm_g))
+           var_name= 'z0'
+           CALL restget &
+                &        (rest_id, var_name, iim_g, jjm_g, 1, istp_old, .TRUE., z0_g)
+           IF (ALL(z0_g(:,:) == val_exp)) THEN
+              Flag=.TRUE.
+           ELSE
+              Flag=.FALSE.
+           ENDIF
+        ELSE
+           ALLOCATE(z0_g(0,1))
+        ENDIF
+        CALL bcast(Flag)
+        IF (.NOT. Flag) &
+             CALL scatter2D(z0_g,z0)
+        DEALLOCATE(z0_g)
+!-------
+        DO ik=1,nbindex
+           i=ilandindex(ik)
+           j=jlandindex(ik)
+           temp_sol_old(i,j) = temp_sol_NEW(i,j)
+           for_swnet(i,j) = (1.- (albedo(i,j,1)+albedo(i,j,2))/2.)*swdown(i,j)
+           for_swdown(i,j) = swdown(i,j)
+        ENDDO
+!
+!     MM : z0 have been modified then we must lower the wind again
+!-----
+!---- SECHIBA expects wind, temperature and humidity at the same height.
+!---- If this is not the case then we need to correct for that.
+!-----
+        IF ( lower_wind .AND. .NOT. is_watchout ) THEN
+           DO ik=1,nbindex
+              i=ilandindex(ik)
+              j=jlandindex(ik)
+              for_u(i,j) = u(i,j) * LOG(zlev_vec(i,j)/z0(i,j)) / &
+                   &                LOG(zlevuv_vec(i,j)/z0(i,j))
+              for_v(i,j) = v(i,j) * LOG(zlev_vec(i,j)/z0(i,j)) / &
+                   &                LOG(zlevuv_vec(i,j)/z0(i,j))
+           ENDDO
+        ELSE
+           DO ik=1,nbindex
+              i=ilandindex(ik)
+              j=jlandindex(ik)
+              for_u(i,j) = u(i,j)
+              for_v(i,j) = v(i,j)
+           ENDDO
+        ENDIF
+!-----
+!---- PRINT input value after first_CALL for debug
+!-----
+        IF (debug) THEN
+           WRITE(numout,*) ' >>>>>> after first_CALL = ',first_CALL
+           WRITE(numout,*) ' u et v = ',for_u(itest,jtest),for_v(itest,jtest)
+           WRITE(numout,*) ' swnet = ', for_swnet(itest,jtest)
+        ENDIF
+!-------
+        IF (longprint) THEN
+           WRITE(numout,*) "dim2_driver first_CALL outputs"
+           !       Output : Fluxes
+           WRITE(numout,*) "vevapp        ; Total of evaporation = ", &
+             &     (/ ( vevapp(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Sensible heat flux = ", &
+             &     (/ ( fluxsens(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "Latent heat flux = ", &
+             &     (/ ( fluxlat(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "coastalflow   ; Diffuse flow of water into the ocean (m^3/dt) = ", &
+             &     (/ ( coastalflow(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "riverflow     ; Largest rivers flowing into the ocean (m^3/dt) = ", &
+             &     (/ ( riverflow(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           !       Surface temperatures and surface properties
+           WRITE(numout,*) "tsol_rad      ; Radiative surface temperature = ", &
+             &     (/ ( tsol_rad(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "temp_sol_new  ; New soil temperature = ", &
+             &     (/ ( temp_sol_NEW(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "qsurf         ; Surface specific humidity = ", &
+             &     (/ ( qsurf(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "albedoVIS = ", &
+             &     (/ ( albedo(ilandindex(ik), jlandindex(ik), 1),ik=1,nbindex ) /)
+           WRITE(numout,*) "albedoNIR = ", &
+             &     (/ ( albedo(ilandindex(ik), jlandindex(ik), 2),ik=1,nbindex ) /)
+           WRITE(numout,*) "emis          ; Emissivity = ", &
+             &     (/ ( emis(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+           WRITE(numout,*) "z0            ; Surface roughness = ", &
+             &     (/ ( z0(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+        ENDIF
+!-------
+        IF (debug) THEN
+          WRITE(numout,*) &
+ &         ' OUT rest : z0, albedoVIS, albedoNIR, emis = ', &
+ &         z0(itest,jtest),albedo(itest,jtest,1), &
+ &                         albedo(itest,jtest,2),emis(itest,jtest)
+          WRITE(numout,*) ' OUT rest : coastal and river flow = ', &
+ &         coastalflow(itest,jtest), riverflow(itest,jtest)
+          WRITE(numout,*) ' OUT rest : tsol_rad, vevapp = ', &
+ &         tsol_rad(itest,jtest), vevapp(itest,jtest)
+          WRITE(numout,*) ' OUT rest : temp_sol_new =', &
+ &         temp_sol_NEW(itest,jtest)
+        ENDIF
+    
+        CALL barrier_para
+        CALL start_timer(timer_global)
+        CALL start_timer(timer_mpi)
+   
+      ENDIF
+!-----
+!---- Calling SECHIBA and doing the number crunching.
+!---- Note that for the first time step SECHIBA is called twice.
+!----
+!---- All H_2O fluxes are now in Kg/m^2s
+!-----
+      IF (longprint) THEN
+         WRITE(numout,*) "dim2_driver ",it_force 
+         WRITE(numout,*) ">> Index of land points =",kindex(1:nbindex)
+         WRITE(numout,*) "Lowest level wind speed North = ", &
+           &     (/ ( for_u(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Lowest level wind speed East = ", &
+           &     (/ ( for_v(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "z0            ; Surface roughness = ", &
+           &     (/ ( z0(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Height of first layer = ", &
+           &     (/ ( zlev_vec(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Lowest level specific humidity = ", &
+           &     (/ ( for_qair(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Rain precipitation = ", &
+           &     (/ ( precip_rain(ilandindex(ik), jlandindex(ik))*dt,ik=1,nbindex ) /)
+         WRITE(numout,*) "Snow precipitation = ", &
+           &     (/ ( precip_snow(ilandindex(ik), jlandindex(ik))*dt,ik=1,nbindex ) /)
+         WRITE(numout,*) "Down-welling long-wave flux = ", &
+           &     (/ ( for_lwdown(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Net surface short-wave flux = ", &
+           &     (/ ( for_swnet(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Downwelling surface short-wave flux = ", &
+           &     (/ ( for_swdown(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Air temperature in Kelvin = ", &
+           &     (/ ( for_tair(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Air potential energy = ", &
+           &     (/ ( for_eair(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "CO2 concentration in the canopy = ", &
+           &     (/ ( for_ccanopy(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Coeficients A from the PBL resolution = ", &
+           &     (/ ( petAcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "One for T and another for q = ", &
+           &     (/ ( peqAcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Coeficients B from the PBL resolution = ", &
+           &     (/ ( petBcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "One for T and another for q = ", &
+           &     (/ ( peqBcoef(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Cdrag = ", &
+           &     (/ ( cdrag(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Lowest level pressure = ", &
+           &     (/ ( for_psurf(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Geographical coordinates lon = ", &
+           &     (/ (  lon(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Geographical coordinates lat = ", &
+           &     (/ (  lat(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Fraction of continent in the grid = ", &
+           &     (/ ( for_contfrac(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+      ENDIF
+      
+      CALL intersurf_main &
+ &      (istp, iim, jjm, nbindex, kindex, dt, &
+ &       first_CALL, last_CALL, lon, lat, for_contfrac, for_neighbours, for_resolution, date0, &
+!     first level conditions
+ &       zlev_vec, for_u, for_v, &
+ &       for_qair, for_tair, for_eair, for_ccanopy, &
+!     Variables for the implicit coupling
+ &       cdrag, petAcoef, peqAcoef, petBcoef, peqBcoef, &
+!     Rain, snow, radiation and surface pressure
+ &       precip_rain, precip_snow, &
+ &       for_lwdown, for_swnet, for_swdown, for_psurf, &
+!     Output : Fluxes
+ &       vevapp, fluxsens, fluxlat, coastalflow, riverflow,  &
+!     Surface temperatures and surface properties
+ &       tsol_rad, temp_sol_NEW, qsurf, albedo, emis, z0)
+!-------
+      IF (longprint) THEN
+         WRITE(numout,*) "dim2_driver outputs"
+         !       Output : Fluxes
+         WRITE(numout,*) "vevapp        ; Total of evaporation = ", &
+           &     (/ ( vevapp(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Sensible heat flux = ", &
+           &     (/ ( fluxsens(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "Latent heat flux = ", &
+           &     (/ ( fluxlat(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "coastalflow   ; Diffuse flow of water into the ocean (m^3/dt) = ", &
+           &     (/ ( coastalflow(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "riverflow     ; Largest rivers flowing into the ocean (m^3/dt) = ", &
+           &     (/ ( riverflow(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         !       Surface temperatures and surface properties
+         WRITE(numout,*) "tsol_rad      ; Radiative surface temperature = ", &
+           &     (/ ( tsol_rad(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "temp_sol_new  ; New soil temperature = ", &
+           &     (/ ( temp_sol_NEW(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "qsurf         ; Surface specific humidity = ", &
+           &     (/ ( qsurf(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "albedoVIS = ", &
+           &     (/ ( albedo(ilandindex(ik), jlandindex(ik), 1),ik=1,nbindex ) /)
+         WRITE(numout,*) "albedoNIR = ", &
+           &     (/ ( albedo(ilandindex(ik), jlandindex(ik), 2),ik=1,nbindex ) /)
+         WRITE(numout,*) "emis          ; Emissivity = ", &
+           &     (/ ( emis(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+         WRITE(numout,*) "z0            ; Surface roughness = ", &
+           &     (/ ( z0(ilandindex(ik), jlandindex(ik)),ik=1,nbindex ) /)
+      ENDIF
+!-----
+      dtdt(:,:) = zero
+      DO ik=1,nbindex
+         i=ilandindex(ik)
+         j=jlandindex(ik)
+         dtdt(i,j) = ABS(temp_sol_NEW(i,j)-temp_sol_old(i,j))/dt
+      ENDDO
+!-----
+!---- Test if the point with the largest change has more than 5K per dt
+!-----
+      IF (MAXVAL(dtdt(:,:)) > 5./dt) THEN
+        ml = MAXLOC(dtdt)
+        CALL ju2ymds(julian, yy, mm, dd, ss)
+        WRITE(numout,"('ATT :',I5,' big temperature jumps on ', &
+ &       I4,'-',I2.2,'-',I2.2,':',F8.4)") &
+ &       COUNT(dtdt(:,:) > 5./dt),yy,mm,dd,ss/3600.
+        WRITE(numout,*) &
+ &       'Maximum change of surface temperature located at :', &
+ &       lon(ml(1),ml(2)),lat(ml(1),ml(2))
+        WRITE(numout,*) 'Coordinates in grid space: ',ml(1),ml(2)
+        WRITE(numout,*) 'Change from ',temp_sol_old(ml(1),ml(2)), &
+ &       ' to ',temp_sol_new(ml(1),ml(2)),&
+ &       'with sw_in = ',for_swnet(ml(1),ml(2))
+        old_tair = &
+ &        (old_eair(ml(1),ml(2))-cte_grav*old_zlev(ml(1),ml(2)))/cp_air
+        WRITE(numout,*) 'Air temperature change from ',old_tair, &
+ &       ' to ',for_tair(ml(1),ml(2))
+        WRITE(numout,*) 'Max of dtdt : ',dtdt(ml(1),ml(2)),' with dt = ',dt
+      ENDIF
+!-----
+      temp_sol_old(:,:) = temp_sol_NEW(:,:)
+!-----
+!---- PRINT output value for debug
+!-----
+      IF (debug) THEN
+        WRITE(numout,*) ' OUT : z0, albedoVIS, albedoNIR, emis = ', &
+ &       z0(itest,jtest),albedo(itest,jtest,1), &
+ &                       albedo(itest,jtest,2),emis(itest,jtest)
+        WRITE(numout,*) ' OUT : coastal and river flow = ',&
+ &       coastalflow(itest,jtest), riverflow(itest,jtest)
+        WRITE(numout,*) ' OUT : tsol_rad, vevapp = ', &
+ &       tsol_rad(itest,jtest), vevapp(itest,jtest)
+        WRITE(numout,*) ' OUT : temp_sol_new =', temp_sol_NEW(itest,jtest)
+      ENDIF
+!-----
+!---- Give some variables to the output package
+!---- for saving on the history tape
+!-----
+      IF (debug) WRITE(numout,*) 'history written for ', istp
+!-----
+      istp_old = istp
+      istp = istp+1
+!-----
+      old_zlev(:,:) = zlev_vec(:,:)
+      old_qair(:,:) = for_qair(:,:)
+      old_eair(:,:) = for_eair(:,:)
+!-----
+      is = is + 1
+    ENDDO
+    split_start = 1
+!!$    it_force =it_force+1
+    IF (it==itau_fin-1) THEN
+     CALL stop_timer(timer_global)
+     CALL stop_timer(timer_mpi)
+    ENDIF
+    it = it + 1
+!!! CALL histsync
+  ENDDO
+!-
+! Archive in restart file the prognostic variables
+!-
+  IF (debug) WRITE(numout,*) 'Write the restart for the driver', istp_old
+!-
+  var_name = 'fluxsens'
+  IF (is_root_prc) THEN
+     ALLOCATE(fluxsens_g(iim_g,jjm_g))
+  ELSE
+     ALLOCATE(fluxsens_g(0,1))
+  ENDIF
+  CALL gather2D(fluxsens , fluxsens_g)
+  IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, fluxsens_g)
+  DEALLOCATE(fluxsens_g)
+  
+  var_name = 'vevapp'
+  IF (is_root_prc) THEN
+     ALLOCATE(vevapp_g(iim_g,jjm_g))
+  ELSE
+     ALLOCATE(vevapp_g(0,1))
+  ENDIF
+  CALL gather2D( vevapp, vevapp_g)
+  IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, vevapp_g)
+  DEALLOCATE(vevapp_g)
+  
+  var_name = 'zlev_old'
+  IF (is_root_prc) THEN
+     ALLOCATE(old_zlev_g(iim_g,jjm_g))
+  ELSE
+     ALLOCATE(old_zlev_g(0,1))
+  ENDIF
+  CALL gather2D( old_zlev, old_zlev_g)
+  IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, old_zlev_g)
+  DEALLOCATE(old_zlev_g)
+  
+  var_name = 'qair_old'
+  IF (is_root_prc) THEN
+     ALLOCATE(old_qair_g(iim_g,jjm_g))
+  ELSE
+     ALLOCATE(old_qair_g(0,1))
+  ENDIF
+  CALL gather2D( old_qair, old_qair_g)
+  IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, old_qair_g)
+  DEALLOCATE(old_qair_g)
+  
+  var_name = 'eair_old'
+  IF (is_root_prc) THEN
+     ALLOCATE(old_eair_g(iim_g,jjm_g))
+  ELSE
+     ALLOCATE(old_eair_g(0,1))
+  ENDIF
+  CALL gather2D( old_eair, old_eair_g)
+  IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, old_eair_g)
+  DEALLOCATE(old_eair_g)
+  
+  var_name = 'rau_old'
+  IF (is_root_prc) THEN
+     ALLOCATE(for_rau_g(iim_g,jjm_g))
+  ELSE
+     ALLOCATE(for_rau_g(0,1))
+  ENDIF
+  CALL gather2D( for_rau, for_rau_g)
+  IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, for_rau_g)
+  DEALLOCATE(for_rau_g)
+  
+  IF (is_root_prc) THEN
+     ALLOCATE(albedo_g(iim_g,jjm_g))
+  ELSE
+     ALLOCATE(albedo_g(0,1))
+  ENDIF
+  var_name= 'albedo_vis'
+  albedo_vis(:,:)=albedo(:,:,1)
+  CALL gather2D(albedo_vis,albedo_g)
+  IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, albedo_g)  
+  !
+  var_name= 'albedo_nir'
+  albedo_nir(:,:)=albedo(:,:,2)
+  CALL gather2D(albedo_nir,albedo_g)
+  IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, albedo_g)  
+  DEALLOCATE(albedo_g)
+
+  IF (is_root_prc) THEN
+     ALLOCATE(z0_g(iim_g,jjm_g))
+  ELSE
+     ALLOCATE(z0_g(0,1))
+  ENDIF
+  var_name= 'z0'
+  CALL gather2D(z0,z0_g)
+  IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, z0_g)  
+  DEALLOCATE(z0_g)
+
+  if (.NOT. is_watchout) THEN
+     var_name = 'petAcoef'
+     IF (is_root_prc) THEN
+        ALLOCATE(petAcoef_g(iim_g,jjm_g))
+     ELSE
+        ALLOCATE(petAcoef_g(0,1))
+     ENDIF
+     CALL gather2D( petAcoef, petAcoef_g)
+     IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, petAcoef_g)
+     DEALLOCATE(petAcoef_g)
+  
+     var_name = 'petBcoef'
+     IF (is_root_prc) THEN
+        ALLOCATE(petBcoef_g(iim_g,jjm_g))
+     ELSE
+        ALLOCATE(petBcoef_g(0,1))
+     ENDIF
+     CALL gather2D( petBcoef, petBcoef_g)
+     IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, petBcoef_g)
+     DEALLOCATE(petBcoef_g)
+  
+     var_name = 'peqAcoef'
+     IF (is_root_prc) THEN
+        ALLOCATE(peqAcoef_g(iim_g,jjm_g))
+     ELSE
+        ALLOCATE(peqAcoef_g(0,1))
+     ENDIF
+     CALL gather2D( peqAcoef, peqAcoef_g)
+     IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, peqAcoef_g)
+     DEALLOCATE(peqAcoef_g)
+  
+     var_name = 'peqBcoef'
+     IF (is_root_prc) THEN
+        ALLOCATE(peqBcoef_g(iim_g,jjm_g))
+     ELSE
+        ALLOCATE(peqBcoef_g(0,1))
+     ENDIF
+     CALL gather2D( peqBcoef, peqBcoef_g)
+     IF(is_root_prc) CALL restput (rest_id, var_name, iim_g, jjm_g, 1, istp_old, peqBcoef_g)
+     DEALLOCATE(peqBcoef_g)
+  ENDIF
+!-
+  IF (debug) WRITE(numout,*) 'Restart for the driver written'
+!=====================================================================
+!- 5.0 Closing all files
+!=====================================================================
+  CALL flinclo(force_id)
+  IF ( debug )  WRITE(numout,*) 'FLIN CLOSED'
+  CALL histclo
+  IF ( debug )   WRITE(numout,*) 'HIST CLOSED'      
+    
+  IF(is_root_prc) THEN
+     CALL restclo
+     IF ( debug )  WRITE(numout,*) 'REST CLOSED'
+     CALL getin_dump
+     IF ( debug )  WRITE(numout,*) 'GETIN CLOSED'
+  ENDIF
+!---------------
+  CALL finalize_para(timer_global,timer_mpi)
+!-
+  STOP 'END of dim2_driver'
+!---------------
+END PROGRAM driver
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/forcesoil.f90
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/forcesoil.f90	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/forcesoil.f90	(revision 405)
@@ -0,0 +1,368 @@
+PROGRAM forcesoil
+  !---------------------------------------------------------------------
+  ! This program reads a forcing file for STOMATE's soil carbon routine
+  ! which was created with STOMATE.
+  ! It then integrates STOMATE's soil carbon parameterizations
+  ! for a given number of years using this forcing.
+  !---------------------------------------------------------------------
+  !- IPSL (2006)
+  !-  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
+  USE netcdf
+  !-
+  USE defprec
+  USE constantes
+  USE constantes_veg
+  USE constantes_co2
+  USE stomate_constants
+  USE ioipsl
+  USE stomate_soilcarbon
+  USE parallel
+  !-
+  IMPLICIT NONE
+  !-
+  CHARACTER(LEN=80) :: sto_restname_in,sto_restname_out
+  INTEGER(i_std)                             :: iim,jjm
+
+  INTEGER(i_std),PARAMETER                   :: llm = 1
+  INTEGER(i_std)                             :: kjpindex
+
+  INTEGER(i_std)                             :: itau_dep,itau_len
+  CHARACTER(LEN=30)                         :: time_str
+  REAL(r_std)                                :: dt_files
+  REAL(r_std)                                :: date0
+  INTEGER(i_std)                             :: rest_id_sto
+  CHARACTER(LEN=20), SAVE                    :: thecalendar = 'noleap'
+  !-
+  CHARACTER(LEN=100) :: Cforcing_name
+  INTEGER            :: Cforcing_id
+  INTEGER            :: v_id
+  REAL(r_std)                                :: dt_forcesoil
+  INTEGER                                   :: nparan
+
+  INTEGER(i_std),DIMENSION(:),ALLOCATABLE    :: indices
+  INTEGER(i_std),DIMENSION(:),ALLOCATABLE    :: indices_g
+  REAL(r_std),DIMENSION(:),ALLOCATABLE       :: x_indices_g
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE     :: lon, lat
+  REAL(r_std),DIMENSION(llm)                 :: lev
+
+
+  INTEGER                                   :: i,m,iatt,iv,iyear
+
+  CHARACTER(LEN=80)                         :: var_name
+  CHARACTER(LEN=400)                        :: taboo_vars
+  REAL(r_std),DIMENSION(1)                   :: xtmp
+  INTEGER(i_std),PARAMETER                   :: nbvarmax=300
+  INTEGER(i_std)                             :: nbvar
+  CHARACTER(LEN=50),DIMENSION(nbvarmax)     :: varnames
+  INTEGER(i_std)                             :: varnbdim
+  INTEGER(i_std),PARAMETER                   :: varnbdim_max=20
+  INTEGER,DIMENSION(varnbdim_max)           :: vardims
+  LOGICAL                                   :: l1d
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE     :: var_3d
+  REAL(r_std)                                :: x_tmp
+  ! string suffix indicating an index
+  CHARACTER(LEN=10)  :: part_str
+  !
+  ! clay fraction
+  REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:)  :: clay_g
+  REAL(r_std),DIMENSION(:,:,:,:),ALLOCATABLE :: soilcarbon_input_g
+  REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE   :: control_temp_g
+  REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE   :: control_moist_g
+  REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE   :: carbon_g
+
+  REAL(r_std),ALLOCATABLE :: clay(:)
+  REAL(r_std),ALLOCATABLE :: soilcarbon_input(:,:,:,:)
+  REAL(r_std),ALLOCATABLE :: control_temp(:,:,:)
+  REAL(r_std),ALLOCATABLE :: control_moist(:,:,:)
+  REAL(r_std),ALLOCATABLE :: carbon(:,:,:)
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE     :: resp_hetero_soil
+
+  INTEGER(i_std)                             :: ier,iret
+
+  LOGICAL :: debug
+
+  CALL Init_para(.FALSE.) 
+  CALL init_timer
+
+!---------------------------------------------------------------------
+!-
+! set debug to have more information
+!-
+  !Config  Key  = DEBUG_INFO
+  !Config  Desc = Flag for debug information
+  !Config  Def  = n
+  !Config  Help = This option allows to switch on the output of debug
+  !Config         information without recompiling the code.
+!-
+  debug = .FALSE.
+  CALL getin_p('DEBUG_INFO',debug)
+  !-
+  ! Stomate's restart files
+  !-
+  IF (is_root_prc) THEN
+     sto_restname_in = 'stomate_start.nc'
+     CALL getin ('STOMATE_RESTART_FILEIN',sto_restname_in)
+     WRITE(numout,*) 'STOMATE INPUT RESTART_FILE: ',TRIM(sto_restname_in)
+     sto_restname_out = 'stomate_rest_out.nc'
+     CALL getin ('STOMATE_RESTART_FILEOUT',sto_restname_out)
+     WRITE(numout,*) 'STOMATE OUTPUT RESTART_FILE: ',TRIM(sto_restname_out)
+     !-
+     ! We need to know iim_g, jjm.
+     ! Get them from the restart files themselves.
+     !-
+     iret = NF90_OPEN (sto_restname_in, NF90_NOWRITE, rest_id_sto)
+     iret = NF90_INQUIRE_DIMENSION (rest_id_sto,1,len=iim_g)
+     iret = NF90_INQUIRE_DIMENSION (rest_id_sto,2,len=jjm_g)
+     iret = NF90_INQ_VARID (rest_id_sto, "time", iv)
+     iret = NF90_GET_ATT (rest_id_sto, iv, 'calendar',thecalendar)
+     iret = NF90_CLOSE (rest_id_sto)
+     i=INDEX(thecalendar,ACHAR(0))
+     IF ( i > 0 ) THEN
+        thecalendar(i:20)=' '
+     ENDIF
+     !-
+     ! Allocate longitudes and latitudes
+     !-
+     ALLOCATE (lon(iim_g,jjm_g))
+     ALLOCATE (lat(iim_g,jjm_g))
+     lon(:,:) = 0.0
+     lat(:,:) = 0.0
+     lev(1)   = 0.0
+     !-
+     CALL restini &
+          & (sto_restname_in, iim_g, jjm_g, lon, lat, llm, lev, &
+          &  sto_restname_out, itau_dep, date0, dt_files, rest_id_sto)
+  ENDIF
+  CALL bcast(date0)
+  CALL bcast(thecalendar)
+  WRITE(numout,*) "calendar = ",thecalendar
+  !-
+  ! calendar
+  !-
+  CALL ioconf_calendar (thecalendar)
+  CALL ioget_calendar  (one_year,one_day)
+  CALL ioconf_startdate(date0)
+  !
+  IF (is_root_prc) THEN
+     !-
+     ! open FORCESOIL's forcing file to read some basic info
+     !-
+     Cforcing_name = 'NONE'
+     CALL getin ('STOMATE_CFORCING_NAME',Cforcing_name)
+     !-
+     iret = NF90_OPEN (TRIM(Cforcing_name),NF90_NOWRITE,Cforcing_id)
+     IF (iret /= NF90_NOERR) THEN
+        CALL ipslerr (3,'forcesoil', &
+             &        'Could not open file : ', &
+             &          Cforcing_name,'(Do you have forget it ?)')
+     ENDIF
+     !-
+     ier = NF90_GET_ATT (Cforcing_id,NF90_GLOBAL,'kjpindex',x_tmp)
+     nbp_glo = NINT(x_tmp)
+     ier = NF90_GET_ATT (Cforcing_id,NF90_GLOBAL,'nparan',x_tmp)
+     nparan = NINT(x_tmp)
+     !-
+     ALLOCATE (indices_g(nbp_glo))
+     ALLOCATE (clay_g(nbp_glo))
+     !-
+     ALLOCATE (x_indices_g(nbp_glo),stat=ier)
+     ier = NF90_INQ_VARID (Cforcing_id,'index',v_id)
+     ier = NF90_GET_VAR   (Cforcing_id,v_id,x_indices_g)
+     indices_g(:) = NINT(x_indices_g(:))
+     WRITE(numout,*) mpi_rank,"indices globaux : ",indices_g
+     DEALLOCATE (x_indices_g)
+     !-
+     ier = NF90_INQ_VARID (Cforcing_id,'clay',v_id)
+     ier = NF90_GET_VAR   (Cforcing_id,v_id,clay_g)
+     !-
+     ! time step of forcesoil
+     !-
+     dt_forcesoil = one_year / FLOAT(nparan)
+     WRITE(numout,*) 'time step (d): ',dt_forcesoil
+     !-
+     ! read (and partially write) the restart file
+     !-
+     ! read and write the variables we do not need
+     !-
+     taboo_vars = '$lon$ $lat$ $lev$ $nav_lon$ $nav_lat$ $nav_lev$ $time$ $time_steps$ '// &
+          &             '$day_counter$ $dt_days$ $date$ '// &
+          &             '$carbon_01$ $carbon_02$ $carbon_03$ $carbon_04$ $carbon_05$'// &
+          &             '$carbon_06$ $carbon_07$ $carbon_08$ $carbon_09$ $carbon_10$'// &
+          &             '$carbon_11$ $carbon_12$ $carbon_13$'
+     !-
+     CALL ioget_vname(rest_id_sto, nbvar, varnames)
+     !-
+     ! read and write some special variables (1D or variables that we need)
+     !-
+     var_name = 'day_counter'
+     CALL restget (rest_id_sto, var_name, 1, 1, 1, itau_dep, .TRUE., xtmp)
+     CALL restput (rest_id_sto, var_name, 1, 1, 1, itau_dep, xtmp)
+     !-
+     var_name = 'dt_days'
+     CALL restget (rest_id_sto, var_name, 1, 1, 1, itau_dep, .TRUE., xtmp)
+     CALL restput (rest_id_sto, var_name, 1, 1, 1, itau_dep, xtmp)
+     !-
+     var_name = 'date'
+     CALL restget (rest_id_sto, var_name, 1, 1, 1, itau_dep, .TRUE., xtmp)
+     CALL restput (rest_id_sto, var_name, 1, 1, 1, itau_dep, xtmp)
+     !-
+     DO iv=1,nbvar
+        !-- check if the variable is to be written here
+        IF (INDEX(taboo_vars,'$'//TRIM(varnames(iv))//'$') == 0 ) THEN
+           !---- get variable dimensions, especially 3rd dimension
+           CALL ioget_vdim &
+                &      (rest_id_sto, varnames(iv), varnbdim_max, varnbdim, vardims)
+           l1d = ALL(vardims(1:varnbdim) == 1)
+           !---- read it
+           IF (l1d) THEN
+              CALL restget &
+                   &        (rest_id_sto, TRIM(varnames(iv)), 1, vardims(3), &
+                   &         1, itau_dep, .TRUE., xtmp)
+           ELSE
+              ALLOCATE( var_3d(nbp_glo,vardims(3)), stat=ier)
+              IF (ier /= 0) STOP 'ALLOCATION PROBLEM'
+              !----
+              CALL restget &
+                   &        (rest_id_sto, TRIM(varnames(iv)), nbp_glo, vardims(3), &
+                   &         1, itau_dep, .TRUE., var_3d, "gather", nbp_glo, indices_g)
+           ENDIF
+           !---- write it
+           IF (l1d) THEN
+              CALL restput &
+                   &        (rest_id_sto, TRIM(varnames(iv)), 1, vardims(3), &
+                   &         1, itau_dep, xtmp)
+           ELSE
+              CALL restput &
+                   &        (rest_id_sto, TRIM(varnames(iv)), nbp_glo, vardims(3), &
+                   &         1, itau_dep, var_3d, 'scatter',  nbp_glo, indices_g)
+              !----
+              DEALLOCATE(var_3d)
+           ENDIF
+        ENDIF
+     ENDDO
+     !-
+     ! read soil carbon
+     !-
+     ALLOCATE(carbon_g(nbp_glo,ncarb,nvm))
+     carbon_g(:,:,:) = val_exp
+     DO m = 1, nvm
+        WRITE (part_str, '(I2)') m
+        IF (m<10) part_str(1:1)='0'
+        var_name = 'carbon_'//part_str(1:LEN_TRIM(part_str))
+        CALL restget &
+             &    (rest_id_sto, var_name, nbp_glo, ncarb , 1, itau_dep, &
+             &     .TRUE., carbon_g(:,:,m), 'gather', nbp_glo, indices_g)
+        IF (ALL(carbon_g(:,:,m) == val_exp)) carbon_g(:,:,m) = zero
+        !-- do not write this variable: it will be modified.
+     ENDDO
+     WRITE(numout,*) "date0 : ",date0, itau_dep
+     !-
+     ! Length of run
+     !-
+     WRITE(time_str,'(a)') '10000Y'
+     CALL getin('TIME_LENGTH', time_str)
+     write(numout,*) 'Number of years for carbon spinup : ',time_str
+     ! transform into itau
+     CALL tlen2itau(time_str, dt_forcesoil*one_day, date0, itau_len)
+     write(numout,*) 'Number of time steps to do: ',itau_len
+     !-
+     ! read the rest of the forcing file and store forcing in an array.
+     ! We read an average year.
+     !-
+     ALLOCATE(soilcarbon_input_g(nbp_glo,ncarb,nvm,nparan))
+     ALLOCATE(control_temp_g(nbp_glo,nlevs,nparan))
+     ALLOCATE(control_moist_g(nbp_glo,nlevs,nparan))
+     !-
+     ier = NF90_INQ_VARID (Cforcing_id,'soilcarbon_input',v_id)
+     ier = NF90_GET_VAR   (Cforcing_id,v_id,soilcarbon_input_g)
+     ier = NF90_INQ_VARID (Cforcing_id,   'control_moist',v_id)
+     ier = NF90_GET_VAR   (Cforcing_id,v_id,control_moist_g)
+     ier = NF90_INQ_VARID (Cforcing_id,    'control_temp',v_id)
+     ier = NF90_GET_VAR   (Cforcing_id,v_id,control_temp_g)
+     !-
+     ier = NF90_CLOSE (Cforcing_id)
+     !-
+  ENDIF
+  CALL bcast(nparan)
+  CALL bcast(dt_forcesoil)
+  CALL bcast(iim_g)
+  CALL bcast(jjm_g)
+  call bcast(nbp_glo)
+  CALL bcast(itau_dep)
+  CALL bcast(itau_len)
+  !
+  ! We must initialize data_para :
+     !
+     !
+  CALL init_data_para(iim_g,jjm_g,nbp_glo,indices_g)
+
+  kjpindex=nbp_loc
+  jjm=jj_nb
+  iim=iim_g
+  IF (debug) WRITE(numout,*) "Local grid : ",kjpindex,iim,jjm
+
+  !---
+  !--- Create the index table
+  !---
+  !--- This job return a LOCAL kindex
+  !---
+  ALLOCATE (indices(kjpindex),stat=ier)
+  CALL scatter(indices_g,indices)
+  indices(1:kjpindex)=indices(1:kjpindex)-(jj_begin-1)*iim_g
+  IF (debug) WRITE(numout,*) mpi_rank,"indices locaux = ",indices(1:kjpindex)
+  !-
+  !-
+  ! there we go: time loop
+  !-
+  ALLOCATE(clay(kjpindex))
+  ALLOCATE(soilcarbon_input(kjpindex,ncarb,nvm,nparan))
+  ALLOCATE(control_temp(kjpindex,nlevs,nparan))
+  ALLOCATE(control_moist(kjpindex,nlevs,nparan))
+  ALLOCATE(carbon(kjpindex,ncarb,nvm))
+  ALLOCATE(resp_hetero_soil(kjpindex,nvm))
+  iatt = 0
+
+  CALL Scatter(clay_g,clay)
+  CALL Scatter(soilcarbon_input_g,soilcarbon_input)
+  CALL Scatter(control_temp_g,control_temp)
+  CALL Scatter(control_moist_g,control_moist)
+  CALL Scatter(carbon_g,carbon)
+
+  iyear=1
+  DO i=1,itau_len
+     iatt = iatt+1
+     IF (iatt > nparan) THEN
+        IF (debug) WRITE(numout,*) iyear
+        iatt = 1
+        iyear=iyear+1
+     ENDIF
+     CALL soilcarbon &
+          &    (kjpindex, dt_forcesoil, clay, &
+          &     soilcarbon_input(:,:,:,iatt), &
+          &     control_temp(:,:,iatt), control_moist(:,:,iatt), &
+          &     carbon, resp_hetero_soil)
+  ENDDO
+  WRITE(numout,*) "End of soilcarbon LOOP."
+  CALL Gather(carbon,carbon_g)
+  !-
+  ! write new carbon into restart file
+  !-
+  IF (is_root_prc) THEN
+     DO m=1,nvm
+        WRITE (part_str, '(I2)') m
+        IF (m<10) part_str(1:1)='0'
+        var_name = 'carbon_'//part_str(1:LEN_TRIM(part_str))
+        CALL restput &
+             &    (rest_id_sto, var_name, nbp_glo, ncarb , 1, itau_dep, &
+             &     carbon_g(:,:,m), 'scatter', nbp_glo, indices_g)
+     ENDDO
+     !-
+     CALL getin_dump
+     CALL restclo
+  ENDIF
+#ifdef CPP_PARA
+  CALL MPI_FINALIZE(ier)
+#endif
+  WRITE(numout,*) "End of forcesoil."
+  !--------------------
+END PROGRAM forcesoil
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/getprec.f90
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/getprec.f90	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/getprec.f90	(revision 405)
@@ -0,0 +1,57 @@
+!< $HeadURL$ 
+!< $Date$
+!< $Author$
+!< $Revision$
+!-
+PROGRAM getprec
+!---------------------------------------------------------------------
+!- This program verifies that that the number representation
+!- between the different components of the model are compatible
+!---------------------------------------------------------------------
+  USE defprec
+!-
+  IMPLICIT NONE
+!-
+  INTEGER :: i
+  REAL    :: r
+!-
+  INTEGER :: range_int,range_real,precision_real
+!---------------------------------------------------------------------
+  range_int  = RANGE(i)
+  range_real = RANGE(r)
+  precision_real = PRECISION(r)
+!-
+  WRITE(*,*) 'The following ranges and precisions are standard'
+  WRITE(*,*) 'on this computer with your compiler options :'
+  WRITE(*,*) ' INTEGER range     :',range_int
+  WRITE(*,*) ' REAL    range     :',range_real
+  WRITE(*,*) ' REAL    precision :',precision_real
+!-
+  WRITE(*,*) 'The corresponding kinds are :'
+  WRITE(*,*) ' KIND for integer  :', &
+ & SELECTED_INT_KIND(range_int)
+  WRITE(*,*) ' KIND for real     :', &
+ & SELECTED_REAL_KIND(precision_real,range_real)
+!-
+  WRITE(*,*) 'We test if this corresponds to what is used'
+  WRITE(*,*) 'in various parts of the code :'
+!-
+! Real :
+!-
+  IF (SELECTED_REAL_KIND(precision_real,range_real) /= r_std) THEN
+    WRITE(*,*) ' REAL : ERROR, the wrong kind is specified.'
+    WRITE(*,*) ' Use the value above.'
+  ELSE
+    WRITE(*,*) ' REAL    : OK'
+  ENDIF
+!-
+! Integer :
+!-
+  IF (SELECTED_INT_KIND(range_int) /= i_std) THEN
+    WRITE(*,*) ' INTEGER : ERROR, the wrong kind is specified.'
+    WRITE(*,*) ' Use the value above.'
+  ELSE
+    WRITE(*,*) ' INTEGER : OK'
+  ENDIF
+!------------------
+END PROGRAM getprec
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/readdim2.f90
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/readdim2.f90	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/readdim2.f90	(revision 405)
@@ -0,0 +1,1650 @@
+!
+MODULE readdim2
+!---------------------------------------------------------------------
+!< $HeadURL$ 
+!< $Date$
+!< $Author$
+!< $Revision$
+!- IPSL (2006)
+!-  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
+!-
+   USE ioipsl
+   USE weather
+   USE TIMER
+   USE constantes
+   USE constantes_veg
+   USE solar
+   USE grid
+!-
+   IMPLICIT NONE
+!-
+   PRIVATE
+   PUBLIC  :: forcing_read, forcing_info, forcing_grid
+!-
+   INTEGER, SAVE                            :: iim_full, jjm_full, llm_full, ttm_full
+   INTEGER, SAVE                            :: iim_zoom, jjm_zoom
+   INTEGER, SAVE                            :: iim_g_begin,jjm_g_begin,iim_g_end,jjm_g_end
+   REAL, SAVE, ALLOCATABLE, DIMENSION(:,:)  :: data_full, lon_full, lat_full
+   REAL, SAVE, ALLOCATABLE, DIMENSION(:)    :: lev_full
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: itau, i_index, j_index,j_index_g
+   INTEGER, SAVE                            :: i_test, j_test
+   LOGICAL, SAVE                            :: allow_weathergen, interpol
+   LOGICAL, SAVE, PUBLIC                    :: weathergen, is_watchout
+   REAL, SAVE                               :: merid_res, zonal_res
+   LOGICAL, SAVE                            :: have_zaxis=.FALSE.
+!-
+CONTAINS
+!-
+!=====================================================================
+!-
+  SUBROUTINE forcing_info(filename, iim, jjm, llm, tm, date0, dt_force,&
+       & force_id)
+
+    !---------------------------------------------------------------------
+    !
+    !- This subroutine will get all the info from the forcing file and
+    !- prepare for the zoom if needed.
+    !- It returns to the caller the sizes of the data it will receive at
+    !- the forcing_read call. This is important so that the caller can
+    !- allocate the right space.
+    !-
+    !- filename   : name of the file to be opened
+    !- iim        : size in x of the forcing data
+    !- jjm        : size in y of the forcing data
+    !- llm        : number of levels in the forcing data (not yet used)
+    !- tm         : Time dimension of the forcing
+    !- date0      : The date at which the forcing file starts (julian days)
+    !- dt_force   : time-step of the forcing file in seconds
+    !- force_id   : ID of the forcing file
+    !-
+    !- ARGUMENTS
+    !-
+    USE parallel
+    IMPLICIT NONE
+    !-
+    CHARACTER(LEN=*) :: filename
+    INTEGER          :: iim, jjm, llm, tm
+    REAL             :: date0, dt_force
+    INTEGER, INTENT(OUT) :: force_id
+    !- LOCAL
+    CHARACTER(LEN=20) :: calendar_str
+    REAL :: juld_1, juld_2
+    LOGICAL :: debug = .FALSE.
+    REAL, ALLOCATABLE, DIMENSION(:,:) :: fcontfrac
+    REAL, ALLOCATABLE, DIMENSION(:,:) :: tair
+    LOGICAL :: contfrac_exists=.FALSE.
+    INTEGER :: NbPoint
+    INTEGER :: i_test,j_test
+    INTEGER :: i,j,ind
+    INTEGER, ALLOCATABLE, DIMENSION(:)  :: index_l
+    REAL, ALLOCATABLE, DIMENSION(:,:)  :: lon, lat
+    REAL, ALLOCATABLE, DIMENSION(:)    :: lev, levuv
+
+    !-
+    CALL flininfo(filename,  iim_full, jjm_full, llm_full, ttm_full, force_id)
+    CALL flinclo(force_id)
+    !-
+    IF ( debug ) WRITE(numout,*) 'forcing_info : Details from forcing file :', &
+         iim_full, jjm_full, llm_full, ttm_full
+    !-
+    IF ( llm_full < 1 ) THEN
+       have_zaxis = .FALSE.
+    ELSE
+       have_zaxis = .TRUE.
+    ENDIF
+    WRITE(numout,*) 'have_zaxis : ', llm_full, have_zaxis
+    !-
+    ALLOCATE(itau(ttm_full))
+    ALLOCATE(data_full(iim_full, jjm_full),lon_full(iim_full, jjm_full),&
+         & lat_full(iim_full, jjm_full))
+    ALLOCATE(lev_full(llm_full))
+    ALLOCATE(fcontfrac(iim_full,jjm_full))
+    !-
+    lev_full(:) = zero
+    !-
+    dt_force=zero
+    CALL flinopen &
+         &  (filename, .FALSE., iim_full, jjm_full, llm_full, lon_full, lat_full, &
+         &   lev_full, ttm_full, itau, date0, dt_force, force_id)
+    IF ( dt_force == zero ) THEN
+       dt_force = itau(2) - itau(1) 
+       itau(:) = itau(:) / dt_force
+    ENDIF
+    !  WRITE(numout,*) "forcing_info : Forcing time step out of flinopen : ",dt_force
+    !-
+    !- What are the alowed options for the temportal interpolation
+    !-
+    !Config  Key  = ALLOW_WEATHERGEN
+    !Config  Desc = Allow weather generator to create data
+    !Config  Def  = n
+    !Config  Help = This flag allows the forcing-reader to generate
+    !Config         synthetic data if the data in the file is too sparse
+    !Config         and the temporal resolution would not be enough to
+    !Config         run the model.
+    !-
+    allow_weathergen = .FALSE.
+    CALL getin_p('ALLOW_WEATHERGEN',allow_weathergen)
+    !-
+    !- The calendar was set by the forcing file. If no "calendar" attribute was
+    !- found then it is assumed to be gregorian, 
+    !MM => FALSE !! it is NOT assumed anything !
+    !- else it is what ever is written in this attribute.
+    !-
+    CALL ioget_calendar(calendar_str)
+    i=INDEX(calendar_str,ACHAR(0))
+    IF ( i > 0 ) THEN
+       calendar_str(i:20)=' '
+    ENDIF
+    !  WRITE(numout,*) "forcing_info : Calendar used : ",calendar_str
+    IF ( calendar_str == 'XXXX' ) THEN
+       WRITE(numout,*) "forcing_info : The calendar was not found in the forcing file."
+       IF (allow_weathergen) THEN
+          ! Then change the calendar
+          CALL ioconf_calendar("noleap") 
+       ELSE
+          WRITE(numout,*) "forcing_info : We will force it to gregorian by default."
+          CALL ioconf_calendar("gregorian") !! = 365.2425 ; "noleap" = 365.0; "360d"; "julian"=365.25
+       ENDIF
+    ENDIF
+    WRITE(numout,*) "readdim2 : Calendar used by the model : ",calendar_str
+    IF (ttm_full .GE. 2) THEN
+       juld_1 = itau2date(itau(1), date0, dt_force)
+       juld_2 = itau2date(itau(2), date0, dt_force)
+    ELSE
+       juld_1 = 0
+       juld_2 = 0
+       CALL ipslerr ( 3, 'forcing_info','What is that only one time step in the forcing file ?', &
+            &         ' That can not be right.','verify forcing file.')
+       STOP
+    ENDIF
+    !-
+    !- Initialize one_year / one_day
+    CALL ioget_calendar (one_year, one_day)
+    !-
+    !- What is the distance between the two first states. From this we will deduce what is
+    !- to be done.
+    weathergen = .FALSE.
+    interpol = .FALSE.
+    is_watchout = .FALSE.
+    !-
+    IF ( ABS(ABS(juld_2-juld_1)-30.) .LE. 2.) THEN
+       IF ( allow_weathergen ) THEN
+          weathergen = .TRUE.
+          WRITE(numout,*) 'Using weather generator.' 
+       ELSE
+          CALL ipslerr ( 3, 'forcing_info', &
+               &         'This seems to be a monthly file.', &
+               &         'We should use a weather generator with this file.', &
+               &         'This should be allowed in the run.def')
+       ENDIF
+    ELSEIF ( ABS(juld_1-juld_2) .LE. 1./4.) THEN
+       interpol = .TRUE.
+       WRITE(numout,*) 'We will interpolate between the forcing data time steps.' 
+    ELSE
+       ! Using the weather generator with data other than monthly ones probably
+       ! needs some thinking.
+       WRITE(numout,*) 'The time step is not suitable:',ABS(juld_1-juld_2),' days.'
+       CALL ipslerr ( 3, 'forcing_info','The time step is not suitable.', &
+            &         '','We cannot do anything with these forcing data.')
+    ENDIF
+    !-
+    !- redefine the forcing time step if the weather generator is activated
+    !-
+    IF ( weathergen ) THEN
+       !Config  Key  = DT_WEATHGEN
+       !Config  Desc = Calling frequency of weather generator (s)
+       !Config  If = ALLOW_WEATHERGEN
+       !Config  Def  = 1800.
+       !Config  Help = Determines how often the weather generator
+       !Config         is called (time step in s). Should be equal
+       !Config         to or larger than Sechiba's time step (say,
+       !Config         up to 6 times Sechiba's time step or so).
+       dt_force = 1800.
+       CALL getin_p('DT_WEATHGEN',dt_force)
+    ENDIF
+    !-
+    !- Define the zoom
+    !-
+    !Config  Key  = LIMIT_WEST
+    !Config  Desc = Western limit of region
+    !Config  Def  = -180.
+    !Config  Help = Western limit of the region we are 
+    !Config         interested in. Between -180 and +180 degrees
+    !Config         The model will use the smalest regions from
+    !Config         region specified here and the one of the forcing file.
+    !- 
+    limit_west = -180.
+    CALL getin_p('LIMIT_WEST',limit_west)
+    !-
+    !Config  Key  = LIMIT_EAST
+    !Config  Desc = Eastern limit of region
+    !Config  Def  = 180.
+    !Config  Help = Eastern limit of the region we are
+    !Config         interested in. Between -180 and +180 degrees
+    !Config         The model will use the smalest regions from
+    !Config         region specified here and the one of the forcing file.
+    !-
+    limit_east = 180.
+    CALL getin_p('LIMIT_EAST',limit_east)
+    !-
+    !Config  Key  = LIMIT_NORTH
+    !Config  Desc = Northern limit of region
+    !Config  Def  = 90.
+    !Config  Help = Northern limit of the region we are
+    !Config         interested in. Between +90 and -90 degrees
+    !Config         The model will use the smalest regions from
+    !Config         region specified here and the one of the forcing file.
+    !-
+    limit_north = 90.
+    CALL getin_p('LIMIT_NORTH',limit_north)
+    !-
+    !Config  Key  = LIMIT_SOUTH
+    !Config  Desc = Southern limit of region
+    !Config  Def  = -90.
+    !Config  Help = Southern limit of the region we are
+    !Config         interested in. Between 90 and -90 degrees
+    !Config         The model will use the smalest regions from
+    !Config         region specified here and the one of the forcing file.
+    !-
+    limit_south = -90.
+    CALL getin_p('LIMIT_SOUTH',limit_south)
+    !- 
+    !- Calculate domain size
+    !-
+    IF ( interpol ) THEN
+       !-
+       !- If we use temporal interpolation, then we cannot change the resolution (yet?)
+       !-
+       ALLOCATE(i_index(iim_full), j_index(jjm_full),j_index_g(jjm_full))
+       IF (is_root_prc) THEN
+
+          CALL domain_size (limit_west, limit_east, limit_north, limit_south,&
+               &         iim_full, jjm_full, lon_full, lat_full, iim_zoom, jjm_zoom,&
+               &         i_index, j_index_g)
+
+          j_index(:)=j_index_g(:)
+
+          ALLOCATE(tair(iim_full,jjm_full))
+          CALL flinget (force_id,'Tair',iim_full, jjm_full, 1, ttm_full,  1, 1, data_full)
+          CALL forcing_zoom(data_full, tair)
+
+          CALL flinquery_var(force_id, 'contfrac', contfrac_exists)
+          IF ( contfrac_exists ) THEN
+             WRITE(numout,*) "contfrac exist in the forcing file."
+             CALL flinget (force_id,'contfrac',iim_full, jjm_full, 1, ttm_full,  1, 1, data_full)
+             CALL forcing_zoom(data_full, fcontfrac)
+             WRITE(numout,*) "fcontfrac min/max :",MINVAL(fcontfrac(1:iim_zoom,1:jjm_zoom)),MAXVAL(fcontfrac(1:iim_zoom,1:jjm_zoom))
+          ELSE
+             fcontfrac(:,:)=1.
+          ENDIF
+
+
+          DO i=1,iim_zoom
+             DO j=1,jjm_zoom
+                IF ( fcontfrac(i,j) <= EPSILON(1.) ) THEN
+                   tair(i,j) = 999999.
+                ENDIF
+             ENDDO
+          ENDDO
+
+          ALLOCATE(index_l(iim_zoom*jjm_zoom))
+          !- In this point is returning the global NbPoint with the global index
+          CALL forcing_landind(iim_zoom,jjm_zoom,tair,.TRUE.,NbPoint,index_l,i_test,j_test)
+       ELSE
+          ALLOCATE(index_l(1))
+       ENDIF
+
+       CALL init_data_para(iim_zoom,jjm_zoom,NbPoint,index_l)
+
+       !
+       !- global index index_g is the index_l of root proc 
+       IF (is_root_prc) index_g(:)=index_l(1:NbPoint)
+
+       DEALLOCATE(index_l)
+
+       CALL bcast(jjm_zoom)
+       CALL bcast(i_index)
+       CALL bcast(j_index_g)
+
+       ind=0
+       DO j=1,jjm_zoom
+          IF ( (j >= jj_begin) .AND. (j <= jj_end) ) THEN
+             ind=ind+1
+             j_index(ind)=j_index_g(j)
+          ENDIF
+       ENDDO
+
+       jjm_zoom=jj_nb
+       iim_zoom=iim_g
+
+       !-
+       !- If we use the weather generator, then we read zonal and meridional resolutions
+       !- This should be unified one day...
+       !-
+    ELSEIF ( weathergen ) THEN
+       !-
+       !Config  Key  = MERID_RES
+       !Config  Desc = North-South Resolution
+       !Config  Def  = 2.
+       !Config  If = ALLOW_WEATHERGEN
+       !Config  Help = North-South Resolution of the region we are
+       !Config         interested in. In degrees
+       !-
+       merid_res = 2.
+       CALL getin_p('MERID_RES',merid_res)
+       !-
+       !Config  Key  = ZONAL_RES
+       !Config  Desc = East-West Resolution
+       !Config  Def  = 2.
+       !Config  If = ALLOW_WEATHERGEN
+       !Config  Help = East-West Resolution of the region we are
+       !Config         interested in. In degrees
+       !-
+       zonal_res = 2.
+       CALL getin_p('ZONAL_RES',zonal_res)
+       !-
+       !- Number of time steps is meaningless in this case
+       !-
+       !    ttm_full = HUGE( ttm_full )
+       !MM Number (realistic) of time steps for half hour dt
+       ttm_full = NINT(one_year * 86400. / dt_force)
+       !-
+       IF (is_root_prc) THEN
+
+          !- In this point is returning the global NbPoint with the global index
+          CALL weathgen_domain_size (limit_west,limit_east,limit_north,limit_south, &
+               zonal_res,merid_res,iim_zoom,jjm_zoom)
+          ALLOCATE(index_l(iim_zoom*jjm_zoom))
+       ENDIF
+       CALL bcast(iim_zoom)
+       CALL bcast(jjm_zoom)
+
+       ALLOCATE(lon(iim_zoom,jjm_zoom))
+       ALLOCATE(lat(iim_zoom,jjm_zoom))
+       ALLOCATE(lev(llm_full),levuv(llm_full))
+       
+       ! We need lon and lat now for weathgen_init
+       CALL forcing_grid (iim_zoom,jjm_zoom,llm_full,lon,lat,lev,levuv,init_f=.TRUE.)
+
+       IF (is_root_prc) THEN
+          CALL weathgen_init &
+               &        (filename,dt_force,force_id,iim_zoom,jjm_zoom, &
+               &         zonal_res,merid_res,lon,lat,index_l,NbPoint)
+!!$,&
+!!$               &         i_index,j_index_g)
+       ELSE
+          ALLOCATE(index_l(1))
+          index_l(1)=1
+       ENDIF
+
+       CALL init_data_para(iim_zoom,jjm_zoom,NbPoint,index_l)
+
+       !
+       !- global index index_g is the index_l of root proc 
+       IF (is_root_prc) index_g(:)=index_l(1:NbPoint)
+
+       DEALLOCATE(index_l)
+
+!!$       CALL bcast(i_index)
+!!$       CALL bcast(j_index_g)
+
+!!$       ind=0
+!!$       DO j=1,jjm_zoom
+!!$          IF ( (j >= jj_begin) .AND. (j <= jj_end) ) THEN
+!!$             ind=ind+1
+!!$             j_index(ind)=j_index_g(j)
+!!$          ENDIF
+!!$       ENDDO
+
+       jjm_zoom=jj_nb
+       iim_zoom=iim_g
+       !
+       CALL weathgen_read_file(force_id,iim_zoom,jjm_zoom)
+
+       !-
+    ELSE
+       !-
+       STOP 'ERROR: Neither interpolation nor weather generator is specified.'
+       !-
+    ENDIF
+    !-
+    !- Transfer the right information to the caller
+    !-
+    iim = iim_zoom
+    jjm = jjm_zoom
+    llm = 1
+    tm = ttm_full
+    !-
+    IF ( debug ) WRITE(numout,*) 'forcing_info : end : ', iim,jjm, llm,tm
+    !-
+  END SUBROUTINE forcing_info
+!-
+!-
+!=====================================================================
+SUBROUTINE forcing_read &
+  & (filename, rest_id, lrstread, lrstwrite, &
+  &  itauin, istp, itau_split, split, nb_spread, netrad_cons, date0,   &
+  &  dt_force, iim, jjm, lon, lat, zlev, zlevuv, ttm, &
+  &  swdown, precip, snowf, tair, u, v, qair, pb, lwdown, &
+  &  fcontfrac, fneighbours, fresolution, &
+  &  SWnet, Eair, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, ccanopy, &
+  &  kindex, nbindex, force_id)
+!---------------------------------------------------------------------
+!- filename   : name of the file to be opened
+!- rest_id    : ID of restart file
+!- lrstread   : read restart file?
+!- lrstwrite  : write restart file?
+!- itauin     : time step for which we need the data
+!- istp       : time step for restart file
+!- itau_split : Where are we within the splitting
+!-              of the time-steps of the forcing files
+!-              (it decides IF we READ or not)
+!- split      : The number of time steps we do
+!-              between two time-steps of the forcing
+!- nb_spread  : Over how many time steps do we spread the precipitation
+!- netrad_cons: flag that decides if net radiation should be conserved.
+!- date0      : The date at which the forcing file starts (julian days)
+!- dt_force   : time-step of the forcing file in seconds
+!- iim        : Size of the grid in x
+!- jjm        : size of the grid in y
+!- lon        : Longitudes
+!- lat        : Latitudes
+!- zlev       : First Levels if it exists (ie if watchout file)
+!- zlevuv     : First Levels of the wind (equal precedent, if it exists)
+!- ttm        : number of time steps in all in the forcing file
+!- swdown     : Downward solar radiation (W/m^2)
+!- precip     : Precipitation (Rainfall) (kg/m^2s)
+!- snowf      : Snowfall (kg/m^2s)
+!- tair       : 1st level (2m ? in off-line) air temperature (K)
+!- u and v    : 1st level (2m/10m ? in off-line) (in theory !) wind speed (m/s)
+!- qair       : 1st level (2m ? in off-line) humidity (kg/kg)
+!- pb         : Surface pressure (Pa)
+!- lwdown     : Downward long wave radiation (W/m^2)
+!- fcontfrac  : Continental fraction (no unit)
+!- fneighbours: land neighbours
+!- fresolution: resolution in x and y dimensions for each points
+!-
+!- From a WATCHOUT file :
+!- SWnet      : Net surface short-wave flux
+!- Eair       : Air potential energy
+!- petAcoef   : Coeficients A from the PBL resolution for T
+!- peqAcoef   : Coeficients A from the PBL resolution for q
+!- petBcoef   : Coeficients B from the PBL resolution for T
+!- peqBcoef   : Coeficients B from the PBL resolution for q
+!- cdrag      : Surface drag
+!- ccanopy    : CO2 concentration in the canopy
+!-
+!- kindex     : Index of all land-points in the data
+!-              (used for the gathering)
+!- nbindex    : Number of land points
+!- force_id   : FLINCOM file id.
+!-              It is used to close the file at the end of the run.
+!-
+!---------------------------------------------------------------------
+   IMPLICIT NONE
+!-
+   CHARACTER(LEN=*) :: filename
+   INTEGER, INTENT(IN) :: force_id
+   INTEGER, INTENT(INOUT) :: nbindex
+   INTEGER :: rest_id
+   LOGICAL :: lrstread, lrstwrite
+   INTEGER :: itauin, istp, itau_split, split, nb_spread
+   LOGICAL :: netrad_cons
+   REAL    :: date0, dt_force
+   INTEGER :: iim, jjm, ttm
+   REAL,DIMENSION(iim,jjm) :: lon, lat, zlev, zlevuv, &
+  & swdown, precip, snowf, tair, u, v, qair, pb, lwdown, &
+  & fcontfrac
+   REAL,DIMENSION(iim,jjm,2) :: fresolution
+   INTEGER,DIMENSION(iim,jjm,8) :: fneighbours
+   ! for watchout files
+   REAL,DIMENSION(iim,jjm) :: &
+  &  SWnet, Eair, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, ccanopy
+   INTEGER,DIMENSION(iim*jjm), INTENT(INOUT) :: kindex
+!-
+   INTEGER :: ik,i,j
+!
+   IF ( interpol ) THEN
+!-
+     CALL forcing_read_interpol &
+         (filename, itauin, itau_split, split, nb_spread, netrad_cons, date0,   &
+          dt_force, iim, jjm, lon, lat, zlev, zlevuv, ttm, &
+          swdown, precip, snowf, tair, u, v, qair, pb, lwdown, &
+          fcontfrac, fneighbours, fresolution, &
+          SWnet, Eair, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, ccanopy, &
+          kindex, nbindex, force_id)
+!-
+   ELSEIF ( weathergen ) THEN
+!-
+      IF (lrstread) THEN
+         fcontfrac(:,:) = 1.0
+         WRITE(numout,*) 'contfrac : ', MINVAL(fcontfrac), MAXVAL(fcontfrac)
+      ENDIF
+
+      IF ( (itauin == 0).AND.(itau_split == 0) ) THEN
+         CALL weathgen_main (istp, istp, filename, force_id, iim, jjm, 1, &
+              rest_id, lrstread, lrstwrite, &
+              limit_west, limit_east, limit_north, limit_south, &
+              zonal_res, merid_res, lon, lat, date0, dt_force, &
+              kindex, nbindex, &
+              swdown, precip, snowf, tair, u, v, qair, pb, lwdown)
+      ELSE
+         CALL weathgen_main (itauin, istp, filename, force_id, iim, jjm, 1, &
+              rest_id, lrstread, lrstwrite, &
+              limit_west, limit_east, limit_north, limit_south, &
+              zonal_res, merid_res, lon, lat, date0, dt_force, &
+              kindex, nbindex, &
+              swdown, precip, snowf, tair, u, v, qair, pb, lwdown)
+      ENDIF
+!-
+      IF ( (itauin == 0).AND.(itau_split == 0) ) THEN
+         !---
+         !--- Allocate grid stuff
+         !---
+         CALL init_grid ( nbindex )
+         !---
+         !--- Compute
+         !---
+         CALL grid_stuff(nbp_glo, iim_g, jjm_g, lon_g, lat_g, kindex)
+         !CALL grid_stuff (nbindex, iim, jjm, lon, lat, kindex)
+         DO ik=1,nbindex
+         
+            j = ((kindex(ik)-1)/iim) + 1
+            i = (kindex(ik) - (j-1)*iim)
+            !-
+            !- Store variable to help describe the grid
+            !- once the points are gathered.
+            !-
+            fneighbours(i,j,:) = neighbours(ik,:)
+            !
+            fresolution(i,j,:) = resolution(ik,:)
+         ENDDO
+      ENDIF
+   ELSE
+!-
+     STOP 'ERROR: Neither interpolation nor weather generator is specified.'
+!-
+   ENDIF
+!-
+   IF (.NOT. is_watchout) THEN
+      ! We have to compute Potential air energy
+      WHERE(tair(:,:) < val_exp) 
+         eair(:,:) = cp_air*tair(:,:)+cte_grav*zlev(:,:)
+      ENDWHERE
+   ENDIF
+!-
+!
+!-------------------------
+END SUBROUTINE forcing_read
+!=====================================================================
+!-
+!-
+!=====================================================================
+SUBROUTINE forcing_read_interpol &
+  & (filename, itauin, itau_split, split, nb_spread, netrad_cons, date0,   &
+  &  dt_force, iim, jjm, lon, lat, zlev, zlevuv, ttm, swdown, rainf, snowf, tair, &
+  &  u, v, qair, pb, lwdown, &
+  &  fcontfrac, fneighbours, fresolution, &
+  &  SWnet, Eair, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, ccanopy, &
+  &  kindex, nbindex, force_id)
+!---------------------------------------------------------------------
+!- filename   : name of the file to be opened
+!- itauin     : time step for which we need the data
+!- itau_split : Where are we within the splitting
+!-              of the time-steps of the forcing files
+!-              (it decides IF we READ or not)
+!- split      : The number of time steps we do
+!-              between two time-steps of the forcing
+!- nb_spread  : Over how many time steps do we spread the precipitation
+!- netrad_cons: flag that decides if net radiation should be conserved.
+!- date0      : The date at which the forcing file starts (julian days)
+!- dt_force   : time-step of the forcing file in seconds
+!- iim        : Size of the grid in x
+!- jjm        : size of the grid in y
+!- lon        : Longitudes
+!- lat        : Latitudes
+!- zlev       : First Levels if it exists (ie if watchout file)
+!- zlevuv     : First Levels of the wind (equal precedent, if it exists)
+!- ttm        : number of time steps in all in the forcing file
+!- swdown     : Downward solar radiation (W/m^2)
+!- rainf      : Rainfall (kg/m^2s)
+!- snowf      : Snowfall (kg/m^2s)
+!- tair       : 2m air temperature (K)
+!- u and v    : 2m (in theory !) wind speed (m/s)
+!- qair       : 2m humidity (kg/kg)
+!- pb         : Surface pressure (Pa)
+!- lwdown     : Downward long wave radiation (W/m^2)
+!- fcontfrac  : Continental fraction (no unit)
+!- fneighbours: land neighbours
+!- fresolution: resolution in x and y dimensions for each points
+!-
+!- From a WATCHOUT file :
+!- SWnet      : Net surface short-wave flux
+!- Eair       : Air potential energy
+!- petAcoef   : Coeficients A from the PBL resolution for T
+!- peqAcoef   : Coeficients A from the PBL resolution for q
+!- petBcoef   : Coeficients B from the PBL resolution for T
+!- peqBcoef   : Coeficients B from the PBL resolution for q
+!- cdrag      : Surface drag
+!- ccanopy    : CO2 concentration in the canopy
+!- 
+!- kindex     : Index of all land-points in the data
+!-              (used for the gathering)
+!- nbindex    : Number of land points
+!- force_id   : FLINCOM file id.
+!-              It is used to close the file at the end of the run.
+!---------------------------------------------------------------------
+   USE parallel
+   IMPLICIT NONE
+!-
+   INTEGER,PARAMETER :: lm=1
+!-
+!- Input variables
+!-
+   CHARACTER(LEN=*) :: filename
+   INTEGER :: itauin, itau_split, split, nb_spread
+   LOGICAL :: netrad_cons
+   REAL    :: date0, dt_force
+   INTEGER :: iim, jjm, ttm
+   REAL,DIMENSION(:,:),INTENT(IN) :: lon, lat   !- LOCAL data array (size=iim,jjm)
+   INTEGER, INTENT(IN) :: force_id
+!-
+!- Output variables
+!-
+   REAL,DIMENSION(:,:),INTENT(OUT) :: zlev, zlevuv, &  !- LOCAL data array (size=iim,jjm)
+  &  swdown, rainf, snowf, tair, u, v, qair, pb, lwdown, &
+  &  fcontfrac
+   REAL,DIMENSION(:,:,:),INTENT(OUT) :: fresolution    !- LOCAL data array (size=iim,jjm,2)
+   INTEGER,DIMENSION(:,:,:),INTENT(OUT) :: fneighbours !- LOCAL data array (size=iim,jjm,8)
+   ! for watchout files
+   REAL,DIMENSION(:,:),INTENT(OUT) :: &
+  &  SWnet, Eair, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, ccanopy
+   INTEGER,DIMENSION(:),INTENT(INOUT) :: kindex    !- LOCAL index of the map
+   INTEGER, INTENT(INOUT) :: nbindex
+!-
+!- Local variables
+!-
+   INTEGER, SAVE :: last_read=0
+   INTEGER, SAVE :: itau_read, itau_read_nm1=0, itau_read_n=0
+   REAL,SAVE,ALLOCATABLE,DIMENSION(:,:) :: &
+  &  zlev_nm1, swdown_nm1, rainf_nm1, snowf_nm1, tair_nm1, u_nm1, v_nm1, qair_nm1, pb_nm1, lwdown_nm1, &
+  &  zlev_n, swdown_n, rainf_n, snowf_n, tair_n, u_n, v_n, qair_n,     &
+  &  pb_n, lwdown_n, mean_sinang, sinang 
+!  just for grid stuff if the forcing file is a watchout file
+   REAL, ALLOCATABLE, DIMENSION(:,:) :: tmpdata
+   ! variables to be read in watchout files
+   REAL,SAVE,ALLOCATABLE,DIMENSION(:,:) :: &
+  &  SWnet_nm1, Eair_nm1, petAcoef_nm1, peqAcoef_nm1, petBcoef_nm1, peqBcoef_nm1, cdrag_nm1, ccanopy_nm1, &
+  &  SWnet_n, Eair_n, petAcoef_n, peqAcoef_n, petBcoef_n, peqBcoef_n, cdrag_n, ccanopy_n
+   REAL, SAVE :: julian_for ! Date of the forcing to be read
+   REAL :: julian, ss, rw
+!jur, 
+   REAL, SAVE :: julian0    ! First day of this year
+   INTEGER :: yy, mm, dd, is, i, j, ik
+!  if Wind_N and Wind_E are in the file (and not just Wind)
+   LOGICAL, SAVE :: wind_N_exists=.FALSE.
+   LOGICAL       :: wind_E_exists=.FALSE.
+   LOGICAL, SAVE :: contfrac_exists=.FALSE.
+   LOGICAL, SAVE :: neighbours_exists=.FALSE.
+   LOGICAL, SAVE :: initialized = .FALSE.
+   LOGICAL :: check=.FALSE.
+!  to bypass FPE problem on integer convertion with missing_value heigher than precision
+   INTEGER, PARAMETER                         :: undef_int = 999999999
+!---------------------------------------------------------------------
+   IF (check) THEN
+     WRITE(numout,*) &
+    &  " FORCING READ : itau_read, itau_split : ",itauin,itau_split
+   ENDIF
+!-
+!!$   itau_read = itauin
+   itau_read = MOD((itauin-1),ttm)+1
+!-
+!- This part initializes the reading of the forcing. As you can see
+!- we only go through here if both time steps are zero.
+!- 
+   IF ( (itau_read == 0).AND.(itau_split == 0) ) THEN
+!-
+!- Tests on forcing file type
+     CALL flinquery_var(force_id, 'Wind_N', wind_N_exists)
+     IF ( wind_N_exists ) THEN
+        CALL flinquery_var(force_id, 'Wind_E', wind_E_exists)
+        IF ( .NOT. wind_E_exists ) THEN
+           CALL ipslerr(3,'forcing_read_interpol', &
+   &             'Variable Wind_E does not exist in forcing file', &
+   &             'But variable Wind_N exists.','Please, rename Wind_N to Wind;') 
+        ENDIF
+     ENDIF
+     CALL flinquery_var(force_id, 'levels', is_watchout)
+     IF ( is_watchout ) THEN
+        WRITE(numout,*) "Read a Watchout File."
+     ENDIF
+     CALL flinquery_var(force_id, 'contfrac', contfrac_exists)
+!-
+     IF (check) WRITE(numout,*) 'ALLOCATE all the memory needed'
+!-
+     ALLOCATE &
+    &  (swdown_nm1(iim,jjm), rainf_nm1(iim,jjm), snowf_nm1(iim,jjm), &
+    &   tair_nm1(iim,jjm), u_nm1(iim,jjm), v_nm1(iim,jjm), qair_nm1(iim,jjm), &
+    &   pb_nm1(iim,jjm), lwdown_nm1(iim,jjm))
+     ALLOCATE &
+    &  (swdown_n(iim,jjm), rainf_n(iim,jjm), snowf_n(iim,jjm), &
+    &   tair_n(iim,jjm), u_n(iim,jjm), v_n(iim,jjm), qair_n(iim,jjm), &
+    &   pb_n(iim,jjm), lwdown_n(iim,jjm))
+     ! to read of watchout files
+     IF (is_watchout) THEN
+        ALLOCATE &
+    &  (zlev_nm1(iim,jjm), zlev_n(iim,jjm), &
+    &   SWnet_nm1(iim,jjm), Eair_nm1(iim,jjm), cdrag_nm1(iim,jjm), ccanopy_nm1(iim,jjm), &
+    &   petAcoef_nm1(iim,jjm), peqAcoef_nm1(iim,jjm), petBcoef_nm1(iim,jjm), peqBcoef_nm1(iim,jjm), &
+    &   SWnet_n(iim,jjm), Eair_n(iim,jjm), cdrag_n(iim,jjm), ccanopy_n(iim,jjm), &
+    &   petAcoef_n(iim,jjm), peqAcoef_n(iim,jjm), petBcoef_n(iim,jjm), peqBcoef_n(iim,jjm))
+     ENDIF
+     ALLOCATE &
+    &  (mean_sinang(iim,jjm), sinang(iim,jjm))
+!-
+     IF (check) WRITE(numout,*) 'Memory ALLOCATED'
+!-
+!- We need for the driver surface air temperature and humidity before the
+!- the loop starts. Thus we read it here.
+!-     
+     CALL forcing_just_read (iim, jjm, zlev, ttm, 1, 1, &
+          &  swdown, rainf, snowf, tair, &
+          &  u, v, qair, pb, lwdown, &
+          &  SWnet, Eair, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, ccanopy, &
+          &  force_id, wind_N_exists, check)
+!----
+     IF (is_watchout) THEN
+        zlevuv(:,:) = zlev(:,:)
+     ENDIF
+!-- First in case it's not a watchout file
+     IF ( .NOT. is_watchout ) THEN
+        IF ( contfrac_exists ) THEN
+           WRITE(numout,*) "contfrac exist in the forcing file."
+           CALL flinget (force_id,'contfrac',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+           CALL forcing_zoom(data_full, fcontfrac)
+           WRITE(numout,*) "fcontfrac min/max :",MINVAL(fcontfrac(1:iim_zoom,jjm_zoom)),MAXVAL(fcontfrac(1:iim_zoom,jjm_zoom))
+           !
+           ! We need to make sure that when we gather the points we pick all
+           ! the points where contfrac is above 0. Thus we prepare tair for
+           ! subroutine forcing_landind
+           !
+           DO i=1,iim
+              DO j=1,jjm
+                 IF ( j==1 .AND. i<ii_begin) fcontfrac(i,j)=0.     ! bande de recouvrement du scatter2D 
+                 IF ( j==jjm .AND. i>ii_end) fcontfrac(i,j)=0.     ! => on mets les données qu'on veut pas du noeud à missing_value
+                 IF ( fcontfrac(i,j) <= EPSILON(1.) ) THEN
+                    tair(i,j) = 999999.
+                 ENDIF
+              ENDDO
+           ENDDO
+        ELSE
+           fcontfrac(:,:) = 1.0
+        ENDIF
+        !---
+        !--- Create the index table
+        !---
+        !--- This job return a LOCAL kindex
+        CALL forcing_landind(iim, jjm, tair, check, nbindex, kindex, i_test, j_test)
+#ifdef CPP_PARA
+        ! We keep previous function forcing_landind, only to get a valid (i_test,j_test) 
+        ! Force nbindex points for parallel computation
+        nbindex=nbp_loc
+        CALL scatter(index_g,kindex)
+        kindex(1:nbindex)=kindex(1:nbindex)-(jj_begin-1)*iim_g
+#endif
+        ik=MAX(nbindex/2,1)
+        j_test = (((kindex(ik)-1)/iim) + 1)
+        i_test = (kindex(ik) - (j_test-1)*iim)
+        IF (check) THEN
+           WRITE(numout,*) 'New test point is : ', i_test, j_test
+        ENDIF
+        !---
+        !--- Allocate grid stuff
+        !---
+        CALL init_grid ( nbindex )
+        !---
+        !--- All grid variables
+        !---
+        CALL grid_stuff(nbp_glo, iim_g, jjm_g, lon_g, lat_g, kindex)
+        DO ik=1,nbindex
+           !
+           j = ((kindex(ik)-1)/iim) + 1
+           i = (kindex(ik) - (j-1)*iim)
+           !-
+           !- Store variable to help describe the grid
+           !- once the points are gathered.
+              !-
+           fneighbours(i,j,:) = neighbours(ik,:)
+           !
+           fresolution(i,j,:) = resolution(ik,:)
+        ENDDO
+     ELSE
+!-- Second, in case it is a watchout file
+        ALLOCATE (tmpdata(iim,jjm))
+        tmpdata(:,:) = 0.0
+!--
+        IF ( .NOT. contfrac_exists ) THEN
+           CALL ipslerr (3,'forcing_read_interpol', &
+ &          'Could get contfrac variable in a watchout file :',TRIM(filename), &
+ &          '(Problem with file ?)')
+        ENDIF
+        CALL flinget (force_id,'contfrac',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, fcontfrac)
+        !
+        ! We need to make sure that when we gather the points we pick all
+        ! the points where contfrac is above 0. Thus we prepare tair for
+        ! subroutine forcing_landind
+        !
+        DO i=1,iim
+           DO j=1,jjm
+	      IF ( j==1 .AND. i<ii_begin) fcontfrac(i,j)=0.
+	      IF ( j==jjm .AND. i>ii_end) fcontfrac(i,j)=0.
+              IF ( fcontfrac(i,j) <= EPSILON(1.) ) THEN
+                 tair(i,j) = 999999.
+              ENDIF
+           ENDDO
+        ENDDO
+        !---
+        !--- Create the index table
+        !---
+        !--- This job return a LOCAL kindex
+        CALL forcing_landind(iim, jjm, tair, check, nbindex, kindex, i_test, j_test)
+#ifdef CPP_PARA
+        ! We keep previous function forcing_landind, only to get a valid (i_test,j_test) 
+        ! Force nbindex points for parallel computation
+        nbindex=nbp_loc
+        CALL scatter(index_g,kindex)
+        kindex(:)=kindex(:)-(jj_begin-1)*iim_g
+#endif
+        ik=MAX(nbindex/2,1)
+        j_test = (((kindex(ik)-1)/iim) + 1)
+        i_test = (kindex(ik) - (j_test-1)*iim)
+        IF (check) THEN
+           WRITE(numout,*) 'New test point is : ', i_test, j_test
+        ENDIF
+        !---
+        !--- Allocate grid stuff
+        !---
+        CALL init_grid ( nbindex )
+        neighbours(:,:) = -1
+        resolution(:,:) = 0.
+        min_resol(:) = 1.e6
+        max_resol(:) = -1.
+        !---
+        !--- All grid variables
+        !---
+        !-
+        !- Get variables to help describe the grid
+        CALL flinquery_var(force_id, 'neighboursNN', neighbours_exists)
+        IF ( .NOT. neighbours_exists ) THEN
+           CALL ipslerr (3,'forcing_read_interpol', &
+ &          'Could get neighbours in a watchout file :',TRIM(filename), &
+ &          '(Problem with file ?)')
+        ELSE
+           WRITE(numout,*) "Watchout file contains neighbours and resolutions."
+        ENDIF
+        !
+        fneighbours(:,:,:) = undef_int
+        !
+        !- once the points are gathered.
+        CALL flinget (force_id,'neighboursNN',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        WHERE(tmpdata(:,:) < undef_int)
+           fneighbours(:,:,1) = NINT(tmpdata(:,:))
+        ENDWHERE
+        !
+        CALL flinget (force_id,'neighboursNE',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        WHERE(tmpdata(:,:) < undef_int)
+           fneighbours(:,:,2) = NINT(tmpdata(:,:))
+        ENDWHERE
+        !
+        CALL flinget (force_id,'neighboursEE',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        WHERE(tmpdata(:,:) < undef_int)
+           fneighbours(:,:,3) = NINT(tmpdata(:,:))
+        ENDWHERE
+        !
+        CALL flinget (force_id,'neighboursSE',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        WHERE(tmpdata(:,:) < undef_int)
+           fneighbours(:,:,4) = NINT(tmpdata(:,:))
+        ENDWHERE
+        !
+        CALL flinget (force_id,'neighboursSS',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        WHERE(tmpdata(:,:) < undef_int)
+           fneighbours(:,:,5) = NINT(tmpdata(:,:))
+        ENDWHERE
+        !
+        CALL flinget (force_id,'neighboursSW',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        WHERE(tmpdata(:,:) < undef_int)
+           fneighbours(:,:,6) = NINT(tmpdata(:,:))
+        ENDWHERE
+        !
+        CALL flinget (force_id,'neighboursWW',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        WHERE(tmpdata(:,:) < undef_int)
+           fneighbours(:,:,7) = NINT(tmpdata(:,:))
+        ENDWHERE
+        !
+        CALL flinget (force_id,'neighboursNW',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        WHERE(tmpdata(:,:) < undef_int)
+           fneighbours(:,:,8) = NINT(tmpdata(:,:))
+        ENDWHERE
+        !
+        ! now, resolution of the grid
+        CALL flinget (force_id,'resolutionX',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        fresolution(:,:,1) = tmpdata(:,:)
+        !
+        CALL flinget (force_id,'resolutionY',iim_full, jjm_full, llm_full, ttm,  1, 1, data_full)
+        CALL forcing_zoom(data_full, tmpdata)
+        fresolution(:,:,2) = tmpdata(:,:)
+        !
+        DO ik=1,nbindex
+           !
+           j = ((kindex(ik)-1)/iim) + 1
+           i = (kindex(ik) - (j-1)*iim)
+           !-
+           !- Store variable to help describe the grid
+           !- once the points are gathered.
+           !-
+           neighbours(ik,:) = fneighbours(i,j,:)  
+           !
+           resolution(ik,:) = fresolution(i,j,:)
+           !
+        
+        ENDDO
+        CALL gather(neighbours,neighbours_g)
+        CALL gather(resolution,resolution_g)
+        min_resol(1) = MINVAL(resolution(:,1))
+        min_resol(2) = MAXVAL(resolution(:,2))
+        max_resol(1) = MAXVAL(resolution(:,1))
+        max_resol(2) = MAXVAL(resolution(:,2))
+        !
+        area(:) = resolution(:,1)*resolution(:,2)
+        CALL gather(area,area_g)
+!--
+        DEALLOCATE (tmpdata)
+     ENDIF
+     WRITE(numout,*) 'contfrac : ', MINVAL(fcontfrac), MAXVAL(fcontfrac)
+!---
+   ENDIF
+!---
+   IF (check) THEN
+      WRITE(numout,*) &
+           & 'The dates : ',itau_read,itau_split,itau_read_nm1,itau_read_n
+   ENDIF
+!---
+!--- Here we do the work in case only interpolation is needed.
+!---
+   IF ( initialized .AND. interpol ) THEN
+!---
+      IF (itau_read /= last_read) THEN
+!---
+!-----   Start or Restart
+         IF (itau_read_n == 0) THEN
+            ! Case of a restart or a shift in the forcing file.
+            IF (itau_read > 1) THEN
+               itau_read_nm1=itau_read-1
+               CALL forcing_just_read (iim, jjm, zlev_nm1, ttm, itau_read_nm1, itau_read_nm1, &
+                    &  swdown_nm1, rainf_nm1, snowf_nm1, tair_nm1, &
+                    &  u_nm1, v_nm1, qair_nm1, pb_nm1, lwdown_nm1, &
+                    &  SWnet_nm1, Eair_nm1, petAcoef_nm1, peqAcoef_nm1, petBcoef_nm1, peqBcoef_nm1, cdrag_nm1, ccanopy_nm1, &
+                    &  force_id, wind_N_exists, check)
+            ! Case of a simple start.
+            ELSE IF (dt_force*ttm > one_day-1. ) THEN
+               ! if the forcing file contains at least 24 hours, 
+               ! we will use the last forcing step of the first day
+               ! as initiale condition to prevent first shift off reading.
+               itau_read_nm1 = NINT (one_day/dt_force)
+               WRITE(numout,*) "the forcing file contains 24 hours :",dt_force*ttm,one_day-1.
+               WRITE(numout,*) "we will use the last forcing step of the first day : itau_read_nm1 ",itau_read_nm1
+               CALL forcing_just_read (iim, jjm, zlev_nm1, ttm, itau_read_nm1, itau_read_nm1, &
+                    &  swdown_nm1, rainf_nm1, snowf_nm1, tair_nm1, &
+                    &  u_nm1, v_nm1, qair_nm1, pb_nm1, lwdown_nm1, &
+                    &  SWnet_nm1, Eair_nm1, petAcoef_nm1, peqAcoef_nm1, petBcoef_nm1, peqBcoef_nm1, cdrag_nm1, ccanopy_nm1, &
+                    &  force_id, wind_N_exists, check)
+            ELSE
+               ! if the forcing file contains less than 24 hours, 
+               ! just say error !
+               CALL ipslerr(3,'forcing_read_interpol', &
+   &             'The forcing file contains less than 24 hours !', &
+   &             'We can''t intialize interpolation with such a file.','') 
+            ENDIF
+         ELSE
+!-----   Normal mode : copy old step
+            swdown_nm1(:,:) = swdown_n(:,:)
+            rainf_nm1(:,:) = rainf_n(:,:)
+            snowf_nm1(:,:)  = snowf_n(:,:) 
+            tair_nm1(:,:)   = tair_n(:,:)
+            u_nm1(:,:)      = u_n(:,:)
+            v_nm1(:,:)      = v_n(:,:)
+            qair_nm1(:,:)   = qair_n(:,:)
+            pb_nm1(:,:)     = pb_n(:,:)
+            lwdown_nm1(:,:) = lwdown_n(:,:)
+            IF (is_watchout) THEN
+               zlev_nm1(:,:)   = zlev_n(:,:)
+               ! Net surface short-wave flux
+               SWnet_nm1(:,:) = SWnet_n(:,:)
+               ! Air potential energy
+               Eair_nm1(:,:)   = Eair_n(:,:)
+               ! Coeficients A from the PBL resolution for T
+               petAcoef_nm1(:,:) = petAcoef_n(:,:)
+               ! Coeficients A from the PBL resolution for q
+               peqAcoef_nm1(:,:) = peqAcoef_n(:,:)
+               ! Coeficients B from the PBL resolution for T
+               petBcoef_nm1(:,:) = petBcoef_n(:,:)
+               ! Coeficients B from the PBL resolution for q
+               peqBcoef_nm1(:,:) = peqBcoef_n(:,:)
+               ! Surface drag
+               cdrag_nm1(:,:) = cdrag_n(:,:)
+               ! CO2 concentration in the canopy
+               ccanopy_nm1(:,:) = ccanopy_n(:,:)
+            ENDIF
+            itau_read_nm1 = itau_read_n
+         ENDIF
+!-----
+         itau_read_n = itau_read
+         IF (itau_read_n > ttm) THEN
+            WRITE(numout,*) 'WARNING --WARNING --WARNING --WARNING '
+            WRITE(numout,*) &
+                 &  'WARNING : We are going back to the start of the file'
+            itau_read_n =1
+         ENDIF
+         IF (check) THEN
+            WRITE(numout,*) &
+                 & 'The dates 2 : ',itau_read,itau_split,itau_read_nm1,itau_read_n
+         ENDIF
+!-----
+!----- Get a reduced julian day !
+!----- This is needed because we lack the precision on 32 bit machines.
+!-----
+         IF ( dt_force .GT. 3600. ) THEN
+            julian_for = itau2date(itau_read-1, date0, dt_force)
+            CALL ju2ymds (julian_for, yy, mm, dd, ss)
+
+            ! first day of this year
+            CALL ymds2ju (yy,1,1,0.0, julian0)
+!-----
+            IF (check) THEN
+               WRITE(numout,*) 'Forcing for Julian day ',julian_for,'is read'
+               WRITE(numout,*) 'Date for this day ',yy,' / ',mm,' / ',dd,"  ",ss
+            ENDIF
+         ENDIF
+!-----
+         CALL forcing_just_read (iim, jjm, zlev_n, ttm, itau_read_n, itau_read_n, &
+              &  swdown_n, rainf_n, snowf_n, tair_n, &
+              &  u_n, v_n, qair_n, pb_n, lwdown_n, &
+              &  SWnet_n, Eair_n, petAcoef_n, peqAcoef_n, petBcoef_n, peqBcoef_n, cdrag_n, ccanopy_n, &
+              &  force_id, wind_N_exists, check)
+!---
+         last_read = itau_read_n
+!-----
+!----- Compute mean solar angle for the comming period
+!-----
+         IF (check) WRITE(numout,*) 'Going into  solarang', split, one_day
+!-----
+         IF ( dt_force .GT. 3600. ) THEN
+            mean_sinang(:,:) = 0.0
+            DO is=1,split
+               !MM we compute mean SWdown between t and t+Dt then I take t+Dt/2. 
+               julian = julian_for+((is-0.5)/split)*dt_force/one_day
+!!$               julian = julian_for+(FLOAT(is)/split)*dt_force/one_day
+               CALL solarang (julian, julian0, iim, jjm, lon, lat, sinang)
+               mean_sinang(:,:) = mean_sinang(:,:)+sinang(:,:)
+            ENDDO
+            mean_sinang(:,:) = mean_sinang(:,:)/split
+!            WRITE(*,*) "mean_sinang =",MAXVAL(mean_sinang)
+         ENDIF
+!-----
+      ENDIF
+!---
+!--- Do the interpolation
+      IF (check) WRITE(numout,*) 'Doing the interpolation between time steps'
+!---
+      IF (split > 1) THEN
+         rw = REAL(itau_split)/split
+      ELSE
+         rw = 1.
+      ENDIF
+      IF (check) WRITE(numout,*) 'Coeff of interpollation : ',rw
+!---
+      qair(:,:) = (qair_n(:,:)-qair_nm1(:,:))*rw + qair_nm1(:,:)
+      tair(:,:) = (tair_n(:,:)-tair_nm1(:,:))*rw + tair_nm1(:,:)
+      pb(:,:) = (pb_n(:,:)-pb_nm1(:,:))*rw + pb_nm1(:,:)
+      u(:,:)  = (u_n(:,:)-u_nm1(:,:))*rw + u_nm1(:,:)
+      v(:,:)  = (v_n(:,:)-v_nm1(:,:))*rw + v_nm1(:,:)
+      IF (is_watchout) THEN
+         zlev(:,:) = (zlev_n(:,:)-zlev_nm1(:,:))*rw + zlev_nm1(:,:)
+         zlevuv(:,:) = zlev(:,:)
+         SWnet(:,:) = (SWnet_n(:,:)-SWnet_nm1(:,:))*rw + SWnet_nm1(:,:)
+         Eair(:,:) = (Eair_n(:,:)-Eair_nm1(:,:))*rw + Eair_nm1(:,:)
+         petAcoef(:,:) = (petAcoef_n(:,:)-petAcoef_nm1(:,:))*rw + petAcoef_nm1(:,:)
+         peqAcoef(:,:) = (peqAcoef_n(:,:)-peqAcoef_nm1(:,:))*rw + peqAcoef_nm1(:,:)
+         petBcoef(:,:) = (petBcoef_n(:,:)-petBcoef_nm1(:,:))*rw + petBcoef_nm1(:,:)
+         peqBcoef(:,:) = (peqBcoef_n(:,:)-peqBcoef_nm1(:,:))*rw + peqBcoef_nm1(:,:)
+         cdrag(:,:) = (cdrag_n(:,:)-cdrag_nm1(:,:))*rw + cdrag_nm1(:,:)
+         ccanopy(:,:) = (ccanopy_n(:,:)-ccanopy_nm1(:,:))*rw + ccanopy_nm1(:,:)
+      ENDIF
+!---
+!--- Here we need to allow for an option
+!--- where radiative energy is conserved
+!---
+      IF ( netrad_cons ) THEN
+         lwdown(:,:) = lwdown_n(:,:)
+      ELSE
+         lwdown(:,:) = (lwdown_n(:,:)-lwdown_nm1(:,:))*rw + lwdown_nm1(:,:)
+      ENDIF
+!---
+!--- For the solar radiation we decompose the mean value
+!--- using the zenith angle of the sun if the time step in the forcing data is 
+!---- more than an hour. Else we use the standard linera interpolation
+!----
+      IF (check) WRITE(numout,*) 'Ready to deal with the solar radiation'
+!----
+      IF ( dt_force .GT. 3600. ) THEN
+!---
+         IF ( netrad_cons ) THEN
+            WRITE(numout,*) 'Solar radiation can not be conserved with a timestep of ', dt_force
+         ENDIF
+!---
+         !MM we compute mean SWdown between t and t+Dt then I take t+Dt/2. 
+         julian = julian_for + (itau_split-0.5)/split*dt_force/one_day
+!!$         julian = julian_for + rw*dt_force/one_day
+         IF (check) THEN
+            WRITE(numout,'(a,f20.10,2I3)') &
+                 &  'JULIAN BEFORE SOLARANG : ',julian,itau_split,split
+         ENDIF
+!---
+         CALL solarang(julian, julian0, iim, jjm, lon, lat, sinang)
+!---
+         WHERE (mean_sinang(:,:) > 0.)
+            swdown(:,:) = swdown_n(:,:) *sinang(:,:)/mean_sinang(:,:)
+         ELSEWHERE
+            swdown(:,:) = 0.0
+         END WHERE
+!---
+         WHERE (swdown(:,:) > 2000. )
+            swdown(:,:) = 2000.
+         END WHERE
+!---
+      ELSE
+!!$      IF ( .NOT. is_watchout ) THEN
+!---
+         IF ( netrad_cons ) THEN
+            swdown(:,:) = swdown_n(:,:)
+         ELSE
+            swdown(:,:) = (swdown_n(:,:)-swdown_nm1(:,:))*rw + swdown_nm1(:,:)
+         ENDIF
+!---
+      ENDIF
+!---
+      IF (check) THEN
+         WRITE(numout,*) '__ Forcing read at ',itau_split,' :',i_test, j_test
+         WRITE(numout,*) 'SWdown  : ',swdown_nm1(i_test, j_test), &
+              &           ' < ', swdown(i_test, j_test), ' < ', swdown_n(i_test, j_test)
+         IF (is_watchout) THEN
+            WRITE(numout,*) 'SWnet  : ',swnet_nm1(i_test, j_test), &
+                 &           ' < ', swnet(i_test, j_test), ' < ', swnet_n(i_test, j_test)
+            WRITE(numout,*) 'levels  :',zlev_nm1(i_test, j_test), &
+                 &           ' < ', zlev(i_test, j_test), ' < ', zlev_n(i_test, j_test)
+            WRITE(numout,*) 'EAIR  :',Eair_nm1(i_test, j_test), &
+                 &           ' < ', eair(i_test, j_test), ' < ', Eair_n(i_test, j_test)
+         ENDIF
+         WRITE(numout,*) 'TAIR  :',tair_nm1(i_test, j_test), &
+              &           ' < ', tair(i_test, j_test), ' < ', tair_n(i_test, j_test)
+         WRITE(numout,*) 'QAIR  :',qair_nm1(i_test, j_test), &
+              &           ' < ', qair(i_test, j_test), ' < ', qair_n(i_test, j_test)
+         WRITE(numout,*) 'U  :',u_nm1(i_test, j_test), &
+              &           ' < ', u(i_test, j_test), ' < ', u_n(i_test, j_test)
+         WRITE(numout,*) 'V  :',v_nm1(i_test, j_test), &
+              &           ' < ', v(i_test, j_test), ' < ', v_n(i_test, j_test)
+      ENDIF
+!---
+!--- For precip we suppose that the rain
+!--- is the sum over the next 6 hours
+!---
+      IF (itau_split <= nb_spread) THEN
+         rainf(:,:) = rainf_n(:,:)*(split/nb_spread)
+         snowf(:,:) = snowf_n(:,:)*(split/nb_spread)
+      ELSE
+         rainf(:,:) = 0.0
+         snowf(:,:) = 0.0
+      ENDIF
+      IF (check) THEN
+         WRITE(numout,*) '__ Forcing read at ',itau_split,' :'
+         WRITE(numout,*) 'Rainf  : ',rainf_nm1(i_test, j_test), &
+              &           ' < ', rainf(i_test, j_test), ' < ', rainf_n(i_test, j_test)
+         WRITE(numout,*) 'Snowf  : ',snowf_nm1(i_test, j_test), &
+              &           ' < ', snowf(i_test, j_test), ' < ', snowf_n(i_test, j_test)
+      ENDIF
+!---
+   ENDIF
+!---
+!--- Here we might put the call to the weather generator ... one day.
+!--- Pour le moment, le branchement entre interpolation et generateur de temps 
+!--- est fait au-dessus.
+!---
+!-   IF ( initialized .AND. weathergen ) THEN
+!-      ....
+!-   ENDIF
+!---
+!--- At this point the code should be initialized. If not we have a problem !
+!---
+   IF ( (itau_read == 0).AND.(itau_split == 0) ) THEN
+!---
+      initialized = .TRUE.
+!---
+   ELSE
+      IF ( .NOT. initialized ) THEN
+         WRITE(numout,*) 'Why is the code forcing_read not initialized ?'
+         WRITE(numout,*) 'Have you called it with both time-steps set to zero ?'
+         STOP
+      ENDIF
+   ENDIF
+!
+!-------------------------
+END SUBROUTINE forcing_read_interpol
+!=====================================================================
+!-
+!=====================================================================
+SUBROUTINE forcing_just_read &
+  & (iim, jjm, zlev, ttm, itb, ite, &
+  &  swdown, rainf, snowf, tair, &
+  &  u, v, qair, pb, lwdown, &
+  &  SWnet, Eair, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, ccanopy, &
+  &  force_id, wind_N_exists, check)
+!---------------------------------------------------------------------
+!- iim        : Size of the grid in x
+!- jjm        : size of the grid in y
+!- zlev       : First Levels if it exists (ie if watchout file)
+!- ttm        : number of time steps in all in the forcing file
+!- itb, ite   : index of respectively begin and end of read for each variable
+!- swdown     : Downward solar radiation (W/m^2)
+!- rainf      : Rainfall (kg/m^2s)
+!- snowf      : Snowfall (kg/m^2s)
+!- tair       : 2m air temperature (K)
+!- u and v    : 2m (in theory !) wind speed (m/s)
+!- qair       : 2m humidity (kg/kg)
+!- pb         : Surface pressure (Pa)
+!- lwdown     : Downward long wave radiation (W/m^2)
+!-
+!- From a WATCHOUT file :
+!- SWnet      : Net surface short-wave flux
+!- Eair       : Air potential energy
+!- petAcoef   : Coeficients A from the PBL resolution for T
+!- peqAcoef   : Coeficients A from the PBL resolution for q
+!- petBcoef   : Coeficients B from the PBL resolution for T
+!- peqBcoef   : Coeficients B from the PBL resolution for q
+!- cdrag      : Surface drag
+!- ccanopy    : CO2 concentration in the canopy
+!- force_id   : FLINCOM file id.
+!-              It is used to close the file at the end of the run.
+!- wind_N_exists : if Wind_N and Wind_E are in the file (and not just Wind)
+!- check      : Prompt for reading
+!---------------------------------------------------------------------
+   IMPLICIT NONE
+!-
+   INTEGER, INTENT(in) :: iim, jjm, ttm
+   INTEGER, INTENT(in) :: itb, ite
+   REAL, DIMENSION(iim,jjm), INTENT(out) ::  zlev, &
+  &  swdown, rainf, snowf, tair, u, v, qair, pb, lwdown
+   ! for watchout files
+   REAL, DIMENSION(iim,jjm), INTENT(out) :: &
+  &  SWnet, Eair, petAcoef, peqAcoef, petBcoef, peqBcoef, cdrag, ccanopy
+   INTEGER, INTENT(in) :: force_id
+!  if Wind_N and Wind_E are in the file (and not just Wind)
+   LOGICAL, INTENT(in) :: wind_N_exists
+   LOGICAL :: check
+!-
+!---------------------------------------------------------------------
+   CALL flinget (force_id,'Tair'  , iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+   CALL forcing_zoom(data_full, tair)
+   CALL flinget (force_id,'SWdown', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+   CALL forcing_zoom(data_full, swdown)
+   CALL flinget (force_id,'LWdown', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+   CALL forcing_zoom(data_full, lwdown)
+   CALL flinget (force_id,'Snowf' , iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+   CALL forcing_zoom(data_full, snowf)
+   CALL flinget (force_id,'Rainf' , iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+   CALL forcing_zoom(data_full, rainf)
+!SZ FLUXNET input file correction
+!  rainf=rainf/1800.
+!MM Rainf and not Snowf ?
+   CALL flinget (force_id,'PSurf' , iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+   CALL forcing_zoom(data_full, pb)
+   CALL flinget (force_id,'Qair'  , iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+   CALL forcing_zoom(data_full, qair)
+!---
+   IF ( wind_N_exists ) THEN
+      CALL flinget (force_id,'Wind_N', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, u)
+      CALL flinget (force_id,'Wind_E', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, v)
+   ELSE
+      CALL flinget (force_id,'Wind',   iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, u)
+      v=0.0
+   ENDIF
+!----
+   IF ( is_watchout ) THEN
+      CALL flinget (force_id,'levels', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, zlev)
+      ! Net surface short-wave flux
+      CALL flinget (force_id,'SWnet', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, SWnet)
+      ! Air potential energy
+      CALL flinget (force_id,'Eair', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, Eair)
+      ! Coeficients A from the PBL resolution for T
+      CALL flinget (force_id,'petAcoef', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, petAcoef)
+      ! Coeficients A from the PBL resolution for q
+      CALL flinget (force_id,'peqAcoef', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, peqAcoef)
+      ! Coeficients B from the PBL resolution for T
+      CALL flinget (force_id,'petBcoef', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, petBcoef)
+      ! Coeficients B from the PBL resolution for q
+      CALL flinget (force_id,'peqBcoef', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, peqBcoef)
+      ! Surface drag
+      CALL flinget (force_id,'cdrag', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, cdrag)
+      ! CO2 concentration in the canopy
+      CALL flinget (force_id,'ccanopy', iim_full, jjm_full, llm_full, ttm, itb, ite, data_full)
+      CALL forcing_zoom(data_full, ccanopy)
+   ENDIF
+!
+!----
+     IF (check) WRITE(numout,*) 'Variables have been extracted between ',itb,' and ',ite,' iterations of the forcing file.'
+!-------------------------
+END SUBROUTINE forcing_just_read
+!=====================================================================
+!-
+SUBROUTINE forcing_landind(iim, jjm, tair, check, nbindex, kindex, i_test, j_test)
+!---
+!--- This subroutine finds the indices of the land points over which the land
+!--- surface scheme is going to run.
+!---
+  IMPLICIT NONE
+!-
+!- ARGUMENTS
+!-
+  INTEGER, INTENT(IN) :: iim, jjm
+  REAL, INTENT(IN)    :: tair(iim,jjm)
+  INTEGER, INTENT(OUT) :: i_test, j_test, nbindex
+  INTEGER, INTENT(OUT) :: kindex(iim*jjm)
+  LOGICAL :: check
+!-
+!- LOCAL
+  INTEGER :: i, j, ig
+!-
+!-
+  ig = 0
+  i_test = 0
+  j_test = 0
+!---
+  IF (MINVAL(tair(:,:)) < 100.) THEN
+!----- In this case the 2m temperature is in Celsius
+     DO j=1,jjm
+        DO i=1,iim
+           IF (tair(i,j) < 100.) THEN
+              ig = ig+1
+              kindex(ig) = (j-1)*iim+i
+              !
+              !  Here we find at random a land-point on which we can do
+              !  some printouts for test.
+              !
+              IF (ig .GT. (iim*jjm)/2 .AND. i_test .LT. 1) THEN
+                 i_test = i
+                 j_test = j
+                 IF (check) THEN
+                    WRITE(numout,*) 'The test point chosen for output is : ', i_test, j_test
+                 ENDIF
+              ENDIF
+           ENDIF
+        ENDDO
+     ENDDO
+  ELSE 
+!----- 2m temperature is in Kelvin
+     DO j=1,jjm
+        DO i=1,iim
+           IF (tair(i,j) < 500.) THEN
+              ig = ig+1
+              kindex(ig) = (j-1)*iim+i
+              !
+              !  Here we find at random a land-point on which we can do
+              !  some printouts for test.
+              !
+              IF (ig .GT. (iim*jjm)/2 .AND. i_test .LT. 1) THEN
+                 i_test = i
+                 j_test = j
+                 IF (check) THEN
+                    WRITE(numout,*) 'The test point chosen for output is : ', i_test, j_test
+                 ENDIF
+              ENDIF
+           ENDIF
+        ENDDO
+     ENDDO
+  ENDIF
+!---
+  nbindex = ig
+!---
+END SUBROUTINE forcing_landind
+!-
+!=====================================================================
+!-
+SUBROUTINE forcing_grid(iim,jjm,llm,lon,lat,lev,levuv,init_f)
+!-
+!- This subroutine calculates the longitudes and latitudes of the model grid.
+!-   
+  USE parallel
+  IMPLICIT NONE
+!-
+  INTEGER, INTENT(in)                   :: iim, jjm, llm
+  LOGICAL, INTENT(in)                   :: init_f
+  REAL, DIMENSION(iim,jjm), INTENT(out) :: lon, lat
+  REAL, DIMENSION(llm), INTENT(out)     :: lev, levuv
+!-
+  INTEGER :: i,j
+  REAL :: zlev, wlev
+!-
+  LOGICAL :: debug = .FALSE.
+!-
+!- Should be unified one day
+!-
+  IF ( debug ) WRITE(numout,*) 'forcing_grid : options : ', weathergen, interpol
+!-
+!Config  Key  = HEIGHT_LEV1
+!Config  Desc = Height at which T and Q are given
+!Config  Def  = 2.0
+!Config  Help = The atmospheric variables (temperature and specific
+!Config         humidity) are measured at a specific level.
+!Config         The height of this level is needed to compute
+!Config         correctly the turbulent transfer coefficients.
+!Config         Look at the description of the forcing
+!Config         DATA for the correct value.
+!-
+   zlev = 2.0
+   CALL getin_p('HEIGHT_LEV1', zlev)
+!-
+!Config  Key  = HEIGHT_LEVW
+!Config  Desc = Height at which the wind is given
+!Config  Def  = 10.0
+!Config  Help = The height at which wind is needed to compute
+!Config         correctly the turbulent transfer coefficients.
+!-
+   wlev = 10.0
+   CALL getin_p('HEIGHT_LEVW', wlev)
+!-
+  IF ( weathergen ) THEN
+     IF (init_f) THEN
+        DO i = 1, iim
+           lon(i,:) = limit_west + merid_res/2. + &
+                FLOAT(i-1)*(limit_east-limit_west)/FLOAT(iim)
+        ENDDO
+        !-
+        DO j = 1, jjm
+           lat(:,j) = limit_north - zonal_res/2. - &
+                FLOAT(j-1)*(limit_north-limit_south)/FLOAT(jjm)
+        ENDDO
+     ELSE
+        IF (is_root_prc) THEN
+           DO i = 1, iim_g
+              lon_g(i,:) = limit_west + merid_res/2. + &
+                   FLOAT(i-1)*(limit_east-limit_west)/FLOAT(iim_g)
+           ENDDO
+           !-
+           DO j = 1, jjm_g
+              lat_g(:,j) = limit_north - zonal_res/2. - &
+                   FLOAT(j-1)*(limit_north-limit_south)/FLOAT(jjm_g)
+           ENDDO
+        ELSE
+           ALLOCATE(lon_g(iim_g, jjm_g), lat_g(iim_g, jjm_g))
+        ENDIF
+        CALL bcast(lon_g)
+        CALL bcast(lat_g)
+        lon=lon_g(:,jj_para_begin(mpi_rank):jj_para_end(mpi_rank))
+        lat=lat_g(:,jj_para_begin(mpi_rank):jj_para_end(mpi_rank))
+     ENDIF
+!-
+     lev(:) = zlev
+     levuv(:) = wlev
+!-
+  ELSEIF ( interpol ) THEN
+!-
+    CALL forcing_zoom(lon_full, lon)
+    IF ( debug ) WRITE(numout,*) 'forcing_grid : out of zoom on lon'
+    CALL forcing_zoom(lat_full, lat)
+    IF ( debug ) WRITE(numout,*) 'forcing_grid : out of zoom on lat'
+!
+    IF ( have_zaxis ) THEN
+       lev(:) = lev_full(:)
+       levuv(:) = lev_full(:)
+    ELSE
+       lev(:) = zlev
+       levuv(:) = wlev
+    ENDIF
+    IF ( debug ) WRITE(numout,*) 'forcing_grid : levels : ', lev(:), levuv(:)
+!-
+  ELSE
+!-
+    STOP 'Neither weather generator nor temporal interpolation is specified.'
+!-
+  ENDIF
+!-
+  IF ( debug ) WRITE(numout,*) 'forcing_grid : ended'
+!-
+END SUBROUTINE forcing_grid
+!-
+!=====================================================================
+!-
+SUBROUTINE forcing_zoom(x_f, x_z)
+!-
+!- This subroutine takes the slab of data over which we wish to run the model.
+!-   
+  IMPLICIT NONE
+!-
+  REAL, INTENT(IN) :: x_f(iim_full, jjm_full)
+  REAL, INTENT(OUT) :: x_z(iim_zoom, jjm_zoom)
+!-
+  INTEGER :: i,j
+!-
+  DO i=1,iim_zoom
+     DO j=1,jjm_zoom
+        x_z(i,j) = x_f(i_index(i),j_index(j))
+     ENDDO
+  ENDDO
+!-
+END SUBROUTINE forcing_zoom
+!
+! ---------------------------------------------------------------------
+!
+
+SUBROUTINE domain_size (limit_west, limit_east, limit_north, limit_south, &
+     &  iim_f, jjm_f, lon, lat, iim, jjm, iind, jind)
+  
+  IMPLICIT NONE
+  !
+  ! ARGUMENTS
+  !
+  REAL, INTENT(inout)  :: limit_west,limit_east,limit_north,limit_south
+  INTEGER, INTENT(in)  :: iim_f, jjm_f
+  REAL, INTENT(in)     :: lon(iim_f, jjm_f), lat(iim_f, jjm_f)
+  INTEGER, INTENT(out) :: iim,jjm
+  INTEGER, INTENT(out) :: iind(iim_f), jind(jjm_f)
+  !
+  ! LOCAL
+  !
+  INTEGER :: i, j
+  REAL :: lolo
+  LOGICAL :: over_dateline = .FALSE.
+  !
+  !
+  IF ( ( ABS(limit_east) .GT. 180. ) .OR. &
+       ( ABS(limit_west) .GT. 180. ) ) THEN
+     WRITE(numout,*) 'Limites Ouest, Est: ',limit_west,limit_east
+     CALL ipslerr (3,'domain_size', &
+ &        'Longitudes problem.','In run.def file :', &
+ &        'limit_east > 180. or limit_west > 180.')
+  ENDIF
+  !
+  IF ( limit_west .GT. limit_east ) over_dateline = .TRUE.
+  !
+  IF ( ( limit_south .LT. -90. ) .OR. &
+       ( limit_north .GT. 90. ) .OR. &
+       ( limit_south .GE. limit_north ) ) THEN
+     WRITE(numout,*) 'Limites Nord, Sud: ',limit_north,limit_south
+     CALL ipslerr (3,'domain_size', &
+ &        'Latitudes problem.','In run.def file :', &
+ &        'limit_south < -90. or limit_north > 90. or limit_south >= limit_north')
+  ENDIF
+  !
+  ! Here we assume that the grid of the forcing data is regular. Else we would have
+  ! to do more work to find the index table.
+  !
+  iim = 0
+  DO i=1,iim_f
+     !
+     lolo =  lon(i,1)
+     IF ( lon(i,1) .GT. 180. ) lolo =  lon(i,1) - 360.
+     IF ( lon(i,1) .LT. -180. ) lolo =  lon(i,1) + 360.
+     !
+     IF (lon(i,1) < limit_west) iim_g_begin = i+1
+     IF (lon(i,1) < limit_east) iim_g_end = i
+     !
+     IF ( over_dateline ) THEN
+        IF ( lolo .LE. limit_west .OR. lolo .GE. limit_east ) THEN
+           iim = iim + 1
+           iind(iim) = i
+        ENDIF
+     ELSE
+        IF ( lolo .GE. limit_west .AND. lolo .LE. limit_east ) THEN
+           iim = iim + 1
+           iind(iim) = i
+        ENDIF
+     ENDIF
+     !
+  ENDDO
+  !
+  jjm = 0
+  DO j=1,jjm_f
+     IF (lat(1,j) > limit_north) jjm_g_begin = j+1
+     IF (lat(1,j) > limit_south) jjm_g_end = j
+     !
+     IF ( lat(1,j) .GE. limit_south .AND. lat(1,j) .LE. limit_north) THEN
+        jjm = jjm + 1
+        jind(jjm) = j
+     ENDIF
+  ENDDO
+  !
+  WRITE(numout,*) 'Domain zoom size: iim, jjm = ', iim, jjm
+  END SUBROUTINE domain_size
+
+!------------------
+END MODULE readdim2
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/teststomate.f90
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/teststomate.f90	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/teststomate.f90	(revision 405)
@@ -0,0 +1,941 @@
+PROGRAM teststomate
+!---------------------------------------------------------------------
+! This program reads a forcing file for STOMATE
+! which was created with STOMATE coupled to SECHIBA.
+! It then integrates STOMATE for a
+! given number of years using this forcing.
+! The GPP is scaled to the new calculated LAI...
+! Nothing is done for soil moisture which should
+! actually evolve with the vegetation.
+!---------------------------------------------------------------------
+!- IPSL (2006)
+!-  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
+  USE netcdf
+!-
+  USE defprec
+  USE constantes
+  USE constantes_soil
+  USE constantes_veg
+  USE constantes_co2
+  USE stomate_constants
+  USE ioipsl
+  USE grid
+  USE slowproc
+  USE stomate
+  USE intersurf, ONLY: stom_define_history, stom_ipcc_define_history, intsurf_time, l_first_intersurf, check_time
+  USE parallel
+!-
+  IMPLICIT NONE
+!-
+! Declarations
+!-
+  INTEGER(i_std)                            :: kjpij,kjpindex
+  REAL(r_std)                               :: dtradia,dt_force
+
+  INTEGER(i_std),DIMENSION(:),ALLOCATABLE   :: indices
+  INTEGER(i_std),DIMENSION(:),ALLOCATABLE   :: indexveg
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: soiltype, veget_x
+  REAL(r_std),DIMENSION(:),ALLOCATABLE      :: totfrac_nobio
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: frac_nobio
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: veget_max_x
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: lai_x
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: veget_force_x
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: veget_max_force_x
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: lai_force_x
+  REAL(r_std),DIMENSION(:),ALLOCATABLE      :: t2m,t2m_min,temp_sol
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: soiltemp,soilhum
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: humrel_x
+  REAL(r_std),DIMENSION(:),ALLOCATABLE      :: litterhum
+  REAL(r_std),DIMENSION(:),ALLOCATABLE      :: precip_rain,precip_snow
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: gpp_x
+  REAL(r_std),DIMENSION(:),ALLOCATABLE      :: deadleaf_cover
+  REAL(r_std),DIMENSION(:,:,:),ALLOCATABLE  :: assim_param_x
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: height_x
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: qsintmax_x
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE    :: co2_flux
+  REAL(r_std),DIMENSION(:),ALLOCATABLE      :: fco2_lu
+
+  INTEGER(i_std),DIMENSION(:),ALLOCATABLE   :: indices_g
+  REAL(r_std),DIMENSION(:),ALLOCATABLE   :: x_indices_g
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE :: x_neighbours_g
+
+  INTEGER    :: ier,iret
+  INTEGER    :: ncfid
+  CHARACTER(LEN=20),SAVE                      :: thecalendar='noleap'
+
+  LOGICAL    :: a_er
+  CHARACTER(LEN=80) :: &
+ &  dri_restname_in,dri_restname_out, &
+ &  sec_restname_in,sec_restname_out, &
+ &  sto_restname_in,sto_restname_out, &
+ &  stom_histname, stom_ipcc_histname
+  INTEGER(i_std)                    :: iim,jjm,llm
+  REAL, ALLOCATABLE, DIMENSION(:,:)  :: lon, lat
+  REAL, ALLOCATABLE, DIMENSION(:)    :: lev
+  LOGICAL                            :: rectilinear
+  REAL, ALLOCATABLE, DIMENSION(:)    :: lon_rect, lat_rect
+  REAL(r_std)                       :: dt
+  INTEGER(i_std)                    :: itau_dep,itau_fin,itau,itau_len,itau_step
+  REAL(r_std)                       :: date0
+  INTEGER(i_std)                    :: rest_id_sec,rest_id_sto
+  INTEGER(i_std)                    :: hist_id_sec,hist_id_sec2,hist_id_stom,hist_id_stom_IPCC
+  CHARACTER(LEN=30)                :: time_str
+  REAL(r_std)                       :: dt_slow_
+  REAL                             :: hist_days_stom,hist_days_stom_ipcc,hist_dt_stom,hist_dt_stom_ipcc
+  REAL,DIMENSION(nvm)              :: hist_PFTaxis
+  REAL(r_std),DIMENSION(10)         :: hist_pool_10axis     
+  REAL(r_std),DIMENSION(100)        :: hist_pool_100axis     
+  REAL(r_std),DIMENSION(11)         :: hist_pool_11axis     
+  REAL(r_std),DIMENSION(101)        :: hist_pool_101axis     
+  INTEGER                          :: hist_PFTaxis_id,hist_IPCC_PFTaxis_id,hori_id
+  INTEGER                          :: hist_pool_10axis_id
+  INTEGER                          :: hist_pool_100axis_id
+  INTEGER                          :: hist_pool_11axis_id
+  INTEGER                          :: hist_pool_101axis_id
+  INTEGER(i_std)                    :: i,j,iv
+  LOGICAL                          :: ldrestart_read,ldrestart_write
+  LOGICAL                          :: l1d
+  INTEGER(i_std),PARAMETER          :: nbvarmax=200
+  INTEGER(i_std)                    :: nbvar
+  CHARACTER*50,DIMENSION(nbvarmax) :: varnames
+  INTEGER(i_std)                    :: varnbdim
+  INTEGER(i_std),PARAMETER          :: varnbdim_max=20
+  INTEGER,DIMENSION(varnbdim_max)  :: vardims
+  CHARACTER*200                    :: taboo_vars
+  REAL(r_std),DIMENSION(1)         :: xtmp
+  INTEGER                          :: nsfm,nsft
+  INTEGER                          :: iisf,iiisf
+  INTEGER(i_std)                    :: max_totsize,totsize_1step,totsize_tmp
+
+  INTEGER                          :: vid
+  CHARACTER(LEN=100)               :: forcing_name
+  REAL                             :: x
+
+  REAL(r_std),DIMENSION(:,:),ALLOCATABLE :: var_3d
+  REAL(r_std) :: var_1d(1)
+
+!-
+  REAL(r_std)                             :: time_sec,time_step_sec
+  REAL(r_std)                             :: time_dri,time_step_dri
+  REAL(r_std),DIMENSION(1)                :: r1d
+  REAL(r_std)                             :: julian,djulian
+
+  INTEGER(i_std)                                :: ji,jv,l
+
+  LOGICAL :: debug
+
+!---------------------------------------------------------------------
+
+  CALL init_para(.FALSE.)
+  CALL init_timer
+
+  IF (is_root_prc) THEN
+     !-
+     ! open STOMATE's forcing file to read some basic info
+     !-
+     forcing_name = 'stomate_forcing.nc'
+     CALL getin ('STOMATE_FORCING_NAME',forcing_name)
+     iret = NF90_OPEN (TRIM(forcing_name),NF90_NOWRITE,forcing_id)
+     IF (iret /= NF90_NOERR) THEN
+        CALL ipslerr (3,'teststomate', &
+             &        'Could not open file : ', &
+             &          forcing_name,'(Do you have forget it ?)')
+     ENDIF
+     ier = NF90_GET_ATT (forcing_id,NF90_GLOBAL,'dtradia',dtradia)
+     ier = NF90_GET_ATT (forcing_id,NF90_GLOBAL,'dt_slow',dt_force)
+     ier = NF90_GET_ATT (forcing_id,NF90_GLOBAL,'nsft',x)
+     nsft = NINT(x)
+     ier = NF90_GET_ATT (forcing_id,NF90_GLOBAL,'kjpij',x)
+     kjpij = NINT(x)
+     ier = NF90_GET_ATT (forcing_id,NF90_GLOBAL,'kjpindex',x)
+     nbp_glo = NINT(x)
+  ENDIF
+  CALL bcast(dtradia)
+  CALL bcast(dt_force)
+  CALL bcast(nsft)
+  CALL bcast(nbp_glo)
+  !-
+  write(numout,*) 'ATTENTION',dtradia,dt_force
+  !-
+  ! read info about land points
+  !-
+  IF (is_root_prc) THEN
+     a_er=.FALSE.
+     ALLOCATE (indices_g(nbp_glo),stat=ier)
+     a_er = a_er .OR. (ier.NE.0)
+     IF (a_er) THEN
+        CALL ipslerr (3,'teststomate', &
+             &        'PROBLEM WITH ALLOCATION', &
+             &        'for local variables 1','')
+     ENDIF
+     !
+     ALLOCATE (x_indices_g(nbp_glo),stat=ier)
+     a_er = a_er .OR. (ier.NE.0)
+     IF (a_er) THEN
+        CALL ipslerr (3,'teststomate', &
+             &        'PROBLEM WITH ALLOCATION', &
+             &        'for global variables 1','')
+     ENDIF
+     ier = NF90_INQ_VARID (forcing_id,'index',vid)
+     IF (ier .NE. 0) THEN
+        CALL ipslerr (3,'teststomate', &
+             &        'PROBLEM WITH ALLOCATION', &
+             &        'for global variables 1','')
+     ENDIF
+     ier = NF90_GET_VAR   (forcing_id,vid,x_indices_g)
+     IF (iret /= NF90_NOERR) THEN
+        CALL ipslerr (3,'teststomate', &
+             &        'PROBLEM WITH variable "index" in file ', &
+             &        forcing_name,'(check this file)')
+     ENDIF
+     indices_g(:) = NINT(x_indices_g(:))
+     DEALLOCATE (x_indices_g)
+  ELSE
+     ALLOCATE (indices_g(0))
+  ENDIF
+!---------------------------------------------------------------------
+!-
+! set debug to have more information
+!-
+  !Config  Key  = DEBUG_INFO
+  !Config  Desc = Flag for debug information
+  !Config  Def  = n
+  !Config  Help = This option allows to switch on the output of debug
+  !Config         information without recompiling the code.
+!-
+  debug = .FALSE.
+  CALL getin_p('DEBUG_INFO',debug)
+  !
+  !Config Key  = LONGPRINT
+  !Config Desc = ORCHIDEE will print more messages
+  !Config Def  = n
+  !Config Help = This flag permits to print more debug messages in the run.
+  !
+  long_print = .FALSE.
+  CALL getin_p('LONGPRINT',long_print)
+  !-
+  ! activate CO2, STOMATE, but not sechiba
+  !-
+  control%river_routing = .FALSE.
+  control%hydrol_cwrr = .FALSE.
+  control%ok_sechiba = .FALSE.
+  !
+  control%stomate_watchout = .TRUE.
+  control%ok_co2 = .TRUE.
+  control%ok_stomate = .TRUE.
+  !-
+  ! is DGVM activated?
+  !-
+  control%ok_dgvm = .FALSE.
+  CALL getin_p('STOMATE_OK_DGVM',control%ok_dgvm)
+  WRITE(numout,*) 'LPJ is activated: ',control%ok_dgvm
+
+  !-
+  ! restart files
+  !-
+  IF (is_root_prc) THEN
+     ! Sechiba's restart files
+     sec_restname_in = 'sechiba_start.nc'
+     CALL getin('SECHIBA_restart_in',sec_restname_in)
+     WRITE(numout,*) 'SECHIBA INPUT RESTART_FILE: ',TRIM(sec_restname_in)
+     IF ( TRIM(sec_restname_in) .EQ. 'NONE' ) THEN
+        STOP 'Need a restart file for Sechiba'
+     ENDIF
+     sec_restname_out = 'sechiba_rest_out.nc'
+     CALL getin('SECHIBA_rest_out',sec_restname_out)
+     WRITE(numout,*) 'SECHIBA OUTPUT RESTART_FILE: ',TRIM(sec_restname_out)
+     ! Stomate's restart files
+     sto_restname_in = 'stomate_start.nc'
+     CALL getin('STOMATE_RESTART_FILEIN',sto_restname_in)
+     WRITE(numout,*) 'STOMATE INPUT RESTART_FILE: ',TRIM(sto_restname_in)
+     sto_restname_out = 'stomate_rest_out.nc'
+     CALL getin('STOMATE_RESTART_FILEOUT',sto_restname_out)
+     WRITE(numout,*) 'STOMATE OUTPUT RESTART_FILE: ',TRIM(sto_restname_out)
+
+     !-
+     ! We need to know iim, jjm.
+     ! Get them from the restart files themselves.
+     !-
+     iret = NF90_OPEN (sec_restname_in,NF90_NOWRITE,ncfid)
+     IF (iret /= NF90_NOERR) THEN
+        CALL ipslerr (3,'teststomate', &
+             &        'Could not open file : ', &
+             &          sec_restname_in,'(Do you have forget it ?)')
+     ENDIF
+     iret = NF90_INQUIRE_DIMENSION (ncfid,1,len=iim_g)
+     iret = NF90_INQUIRE_DIMENSION (ncfid,2,len=jjm_g)
+     iret = NF90_INQ_VARID (ncfid, "time", iv)
+     iret = NF90_GET_ATT (ncfid, iv, 'calendar',thecalendar)
+     iret = NF90_CLOSE (ncfid)
+     i=INDEX(thecalendar,ACHAR(0))
+     IF ( i > 0 ) THEN
+        thecalendar(i:20)=' '
+     ENDIF
+  ENDIF
+  CALL bcast(iim_g)
+  CALL bcast(jjm_g)
+  CALL bcast(thecalendar)
+  !-
+  ! calendar
+  !-
+  CALL ioconf_calendar (thecalendar)
+  CALL ioget_calendar  (one_year,one_day)
+  !
+  ! Parallelization :
+  !
+  CALL init_data_para(iim_g,jjm_g,nbp_glo,indices_g)
+  kjpindex=nbp_loc
+  jjm=jj_nb
+  iim=iim_g
+  kjpij=iim*jjm
+  IF (debug) WRITE(numout,*) "Local grid : ",kjpindex,iim,jjm
+  !-
+  !-
+  ! read info about grids
+  !-
+  !-
+  llm=1
+  ALLOCATE(lev(llm))
+  IF (is_root_prc) THEN
+     !-
+     ier = NF90_INQ_VARID (forcing_id,'lalo',vid)
+     ier = NF90_GET_VAR   (forcing_id,vid,lalo_g)
+     !-
+     ALLOCATE (x_neighbours_g(nbp_glo,8),stat=ier)
+     ier = NF90_INQ_VARID (forcing_id,'neighbours',vid)
+     ier = NF90_GET_VAR   (forcing_id,vid,x_neighbours_g)
+     neighbours_g(:,:) = NINT(x_neighbours_g(:,:))
+     DEALLOCATE (x_neighbours_g)
+     !-
+     ier = NF90_INQ_VARID (forcing_id,'resolution',vid)
+     ier = NF90_GET_VAR   (forcing_id,vid,resolution_g)
+     !-
+     ier = NF90_INQ_VARID (forcing_id,'contfrac',vid)
+     ier = NF90_GET_VAR   (forcing_id,vid,contfrac_g)
+
+     lon_g(:,:) = 0.0
+     lat_g(:,:) = 0.0
+     lev(1)   = 0.0
+     !-
+     CALL restini &
+          & (sec_restname_in, iim_g, jjm_g, lon_g, lat_g, llm, lev, &
+          &  sec_restname_out, itau_dep, date0, dt, rest_id_sec)
+     !-
+     IF ( dt .NE. dtradia ) THEN
+        WRITE(numout,*) 'dt',dt
+        WRITE(numout,*) 'dtradia',dtradia
+        CALL ipslerr (3,'teststomate', &
+             &        'PROBLEM with time steps.', &
+             &          sec_restname_in,'(dt .NE. dtradia)')
+     ENDIF
+     !-
+     CALL restini &
+          & (sto_restname_in, iim_g, jjm_g, lon_g, lat_g, llm, lev, &
+          &  sto_restname_out, itau_dep, date0, dt, rest_id_sto)
+     !-
+     IF ( dt .NE. dtradia ) THEN
+        WRITE(numout,*) 'dt',dt
+        WRITE(numout,*) 'dtradia',dtradia
+        CALL ipslerr (3,'teststomate', &
+             &        'PROBLEM with time steps.', &
+             &          sto_restname_in,'(dt .NE. dtradia)')
+     ENDIF
+  ENDIF
+  CALL bcast(rest_id_sec)
+  CALL bcast(rest_id_sto)
+  CALL bcast(itau_dep)
+  CALL bcast(date0)
+  CALL bcast(dt)
+  CALL bcast(lev)
+  !---
+  !--- Create the index table
+  !---
+  !--- This job return a LOCAL kindex
+  !---
+  ALLOCATE (indices(kjpindex),stat=ier)
+  IF (debug .AND. is_root_prc) WRITE(numout,*) "indices_g = ",indices_g(1:nbp_glo)
+  CALL scatter(indices_g,indices)
+  indices(1:kjpindex)=indices(1:kjpindex)-(jj_begin-1)*iim_g
+  IF (debug) WRITE(numout,*) "indices = ",indices(1:kjpindex)
+
+  !---
+  !--- initialize global grid
+  !---
+  CALL init_grid( kjpindex ) 
+  CALL grid_stuff (nbp_glo, iim_g, jjm_g, lon_g, lat_g, indices_g)
+
+  !---
+  !--- initialize local grid
+  !---
+  jlandindex = (((indices(1:kjpindex)-1)/iim) + 1)
+  if (debug) WRITE(numout,*) "jlandindex = ",jlandindex(1:kjpindex)
+  ilandindex = (indices(1:kjpindex) - (jlandindex(1:kjpindex)-1)*iim)
+  IF (debug) WRITE(numout,*) "ilandindex = ",ilandindex(1:kjpindex)
+  ALLOCATE(lon(iim,jjm))
+  ALLOCATE(lat(iim,jjm))
+  lon=zero
+  lat=zero
+  CALL scatter2D(lon_g,lon)
+  CALL scatter2D(lat_g,lat)
+
+  DO ji=1,kjpindex
+
+     j = jlandindex(ji)
+     i = ilandindex(ji)
+
+     !- Create the internal coordinate table
+!-
+     lalo(ji,1) = lat(i,j)
+     lalo(ji,2) = lon(i,j)
+  ENDDO
+  CALL scatter(neighbours_g,neighbours)
+  CALL scatter(resolution_g,resolution)
+  CALL scatter(contfrac_g,contfrac)
+  CALL scatter(area_g,area)
+  !-
+  !- Check if we have by any change a rectilinear grid. This would allow us to 
+  !- simplify the output files.
+  !
+  rectilinear = .FALSE.
+  IF (is_root_prc) THEN
+     IF ( ALL(lon_g(:,:) == SPREAD(lon_g(:,1), 2, SIZE(lon_g,2))) .AND. &
+       & ALL(lat_g(:,:) == SPREAD(lat_g(1,:), 1, SIZE(lat_g,1))) ) THEN
+        rectilinear = .TRUE.
+     ENDIF
+  ENDIF
+  CALL bcast(rectilinear)
+  IF (rectilinear) THEN
+     ALLOCATE(lon_rect(iim),stat=ier)
+     IF (ier .NE. 0) THEN
+        WRITE (numout,*) ' error in lon_rect allocation. We stop. We need iim words = ',iim
+        STOP 'intersurf_history'
+     ENDIF
+     ALLOCATE(lat_rect(jjm),stat=ier)
+     IF (ier .NE. 0) THEN
+        WRITE (numout,*) ' error in lat_rect allocation. We stop. We need jjm words = ',jjm
+        STOP 'intersurf_history'
+     ENDIF
+     lon_rect(:) = lon(:,1)
+     lat_rect(:) = lat(1,:)
+  ENDIF
+  !-
+  ! allocate arrays
+  !-
+  !
+  a_er = .FALSE.
+  ALLOCATE (indexveg(kjpindex*nvm), stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (soiltype(kjpindex,nstm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (veget_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (totfrac_nobio(kjpindex),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (frac_nobio(kjpindex,nnobio),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (veget_max_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (lai_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (veget_force_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (veget_max_force_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (lai_force_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (t2m(kjpindex),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (t2m_min(kjpindex),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (temp_sol(kjpindex),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (soiltemp(kjpindex,nbdl),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (soilhum(kjpindex,nbdl),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (humrel_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (litterhum(kjpindex),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (precip_rain(kjpindex),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (precip_snow(kjpindex),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (gpp_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (deadleaf_cover(kjpindex),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (assim_param_x(kjpindex,nvm,npco2),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (height_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (qsintmax_x(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (co2_flux(kjpindex,nvm),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  ALLOCATE (fco2_lu(kjpindex),stat=ier)
+  a_er = a_er .OR. (ier.NE.0)
+  IF (a_er) THEN
+     CALL ipslerr (3,'teststomate', &
+          &        'PROBLEM WITH ALLOCATION', &
+          &        'for local variables 1','')
+  ENDIF
+  !
+  ! prepare forcing
+  !
+  max_totsize = 50
+  CALL getin_p ('STOMATE_FORCING_MEMSIZE',max_totsize)
+  max_totsize = max_totsize * 1000000
+
+  totsize_1step = SIZE(soiltype(:,3))*KIND(soiltype(:,3)) + &
+       SIZE(humrel_x)*KIND(humrel_x) + &
+       SIZE(litterhum)*KIND(litterhum) + &
+       SIZE(t2m)*KIND(t2m) + &
+       SIZE(t2m_min)*KIND(t2m_min) + &
+       SIZE(temp_sol)*KIND(temp_sol) + &
+       SIZE(soiltemp)*KIND(soiltemp) + &
+       SIZE(soilhum)*KIND(soilhum) + &
+       SIZE(precip_rain)*KIND(precip_rain) + &
+       SIZE(precip_snow)*KIND(precip_snow) + &
+       SIZE(gpp_x)*KIND(gpp_x) + &
+       SIZE(veget_force_x)*KIND(veget_force_x) + &
+       SIZE(veget_max_force_x)*KIND(veget_max_force_x) + &
+       SIZE(lai_force_x)*KIND(lai_force_x)
+  CALL reduce_sum(totsize_1step,totsize_tmp)
+  CALL bcast(totsize_tmp)
+  totsize_1step=totsize_tmp 
+
+! total number of forcing steps
+  IF ( nsft .NE. INT(one_year/(dt_force/one_day)) ) THEN
+     CALL ipslerr (3,'teststomate', &
+          &        'stomate: error with total number of forcing steps', &
+          &        'nsft','teststomate computation different with forcing file value.')
+  ENDIF
+! number of forcing steps in memory
+  nsfm = MIN(nsft, &
+       &       MAX(1,NINT( REAL(max_totsize,r_std) &
+       &                  /REAL(totsize_1step,r_std))))
+!-
+  WRITE(numout,*) 'Offline forcing of Stomate:'
+  WRITE(numout,*) '  Total number of forcing steps:',nsft
+  WRITE(numout,*) '  Number of forcing steps in memory:',nsfm
+!-
+  CALL init_forcing(kjpindex,nsfm,nsft)
+  !-
+! ensure that we read all new forcing states
+  iisf = nsfm
+! initialize that table that contains the indices
+! of the forcing states that will be in memory
+  isf(:) = (/ (i,i=1,nsfm) /)
+
+  nf_written(:) = .FALSE.
+  nf_written(isf(:)) = .TRUE.
+
+!-
+! a time step for STOMATE corresponds to itau_step timesteps in SECHIBA
+!-
+  itau_step = NINT(dt_force/dtradia)
+  IF (debug) WRITE(numout,*) "dtradia, dt_rest, dt_force, itau_step",dtradia, dt, dt_force, itau_step
+  !
+  CALL ioconf_startdate(date0)
+  CALL intsurf_time( itau_dep, date0, dtradia )
+!-
+! Length of integration
+!-
+  WRITE(time_str,'(a)') '1Y'
+  CALL getin_p ('TIME_LENGTH', time_str)
+! transform into itau
+  CALL tlen2itau(time_str, dt, date0, itau_len)
+! itau_len*dtradia must be a multiple of dt_force
+  itau_len = NINT( MAX(1.,FLOAT(NINT(itau_len*dtradia/dt_force))) &
+       &                *dt_force/dtradia)
+  !-
+  itau_fin = itau_dep+itau_len
+  !-
+  ! set up STOMATE history file
+  !-
+  !Config  Key  = STOMATE_OUTPUT_FILE
+  !Config  Desc = Name of file in which STOMATE's output is going
+  !Config         to be written
+  !Config  Def  = stomate_history.nc
+  !Config  Help = This file is going to be created by the model
+  !Config         and will contain the output from the model.
+  !Config         This file is a truly COADS compliant netCDF file.
+  !Config         It will be generated by the hist software from
+  !Config         the IOIPSL package.
+  !-
+  stom_histname='stomate_history.nc'
+  CALL getin_p ('STOMATE_OUTPUT_FILE', stom_histname)
+  WRITE(numout,*) 'STOMATE_OUTPUT_FILE', TRIM(stom_histname)
+  !-
+  !Config  Key  = STOMATE_HIST_DT
+  !Config  Desc = STOMATE history time step (d)
+  !Config  Def  = 10.
+  !Config  Help = Time step of the STOMATE history file
+  !-
+  hist_days_stom = 10.
+  CALL getin_p ('STOMATE_HIST_DT', hist_days_stom)
+  IF ( hist_days_stom == -1. ) THEN
+     hist_dt_stom = -1.
+     WRITE(numout,*) 'output frequency for STOMATE history file (d): one month.'
+  ELSE
+     hist_dt_stom = NINT( hist_days_stom ) * one_day
+     WRITE(numout,*) 'output frequency for STOMATE history file (d): ', &
+             hist_dt_stom/one_day
+  ENDIF
+!-
+  !-
+  !- initialize
+  WRITE(numout,*) "before histbeg : ",date0,dt
+  IF ( rectilinear ) THEN
+#ifdef CPP_PARA
+     CALL histbeg(stom_histname, iim, lon_rect, jjm, lat_rect,  1, iim, 1, jjm, &
+          &     itau_dep, date0, dt, hori_id, hist_id_stom, domain_id=orch_domain_id)
+#else
+     CALL histbeg(stom_histname, iim, lon_rect, jjm, lat_rect,  1, iim, 1, jjm, &
+          &     itau_dep, date0, dt, hori_id, hist_id_stom)
+#endif
+  ELSE
+#ifdef CPP_PARA
+     CALL histbeg(stom_histname, iim, lon, jjm, lat,  1, iim, 1, jjm, &
+          &     itau_dep, date0, dt, hori_id, hist_id_stom, domain_id=orch_domain_id)
+#else
+     CALL histbeg(stom_histname, iim, lon, jjm, lat,  1, iim, 1, jjm, &
+          &     itau_dep, date0, dt, hori_id, hist_id_stom)
+#endif
+  ENDIF
+  !- define PFT axis
+  hist_PFTaxis = (/ ( REAL(i,r_std), i=1,nvm ) /)
+  !- declare this axis
+  CALL histvert (hist_id_stom, 'PFT', 'Plant functional type', &
+       & '1', nvm, hist_PFTaxis, hist_PFTaxis_id)
+!- define Pool_10 axis
+   hist_pool_10axis = (/ ( REAL(i,r_std), i=1,10 ) /)
+!- declare this axis
+  CALL histvert (hist_id_stom, 'P10', 'Pool 10 years', &
+       & '1', 10, hist_pool_10axis, hist_pool_10axis_id)
+
+!- define Pool_100 axis
+   hist_pool_100axis = (/ ( REAL(i,r_std), i=1,100 ) /)
+!- declare this axis
+  CALL histvert (hist_id_stom, 'P100', 'Pool 100 years', &
+       & '1', 100, hist_pool_100axis, hist_pool_100axis_id)
+
+!- define Pool_11 axis
+   hist_pool_11axis = (/ ( REAL(i,r_std), i=1,11 ) /)
+!- declare this axis
+  CALL histvert (hist_id_stom, 'P11', 'Pool 10 years + 1', &
+       & '1', 11, hist_pool_11axis, hist_pool_11axis_id)
+!- define Pool_101 axis
+   hist_pool_101axis = (/ ( REAL(i,r_std), i=1,101 ) /)
+!- declare this axis
+  CALL histvert (hist_id_stom, 'P101', 'Pool 100 years + 1', &
+       & '1', 101, hist_pool_101axis, hist_pool_101axis_id)
+
+  !- define STOMATE history file
+  CALL stom_define_history (hist_id_stom, nvm, iim, jjm, &
+       & dt, hist_dt_stom, hori_id, hist_PFTaxis_id, &
+ & hist_pool_10axis_id, hist_pool_100axis_id, &
+ & hist_pool_11axis_id, hist_pool_101axis_id)
+
+  !- end definition
+  CALL histend(hist_id_stom)
+  !-
+  !-
+  ! STOMATE IPCC OUTPUTS IS ACTIVATED
+  !-
+  !Config  Key  = STOMATE_IPCC_OUTPUT_FILE
+  !Config  Desc = Name of file in which STOMATE's output is going
+  !Config         to be written
+  !Config  Def  = stomate_ipcc_history.nc
+  !Config  Help = This file is going to be created by the model
+  !Config         and will contain the output from the model.
+  !Config         This file is a truly COADS compliant netCDF file.
+  !Config         It will be generated by the hist software from
+  !Config         the IOIPSL package.
+  !-
+  stom_ipcc_histname='stomate_ipcc_history.nc'
+  CALL getin_p('STOMATE_IPCC_OUTPUT_FILE', stom_ipcc_histname)       
+  WRITE(numout,*) 'STOMATE_IPCC_OUTPUT_FILE', TRIM(stom_ipcc_histname)
+  !-
+  !Config  Key  = STOMATE_IPCC_HIST_DT
+  !Config  Desc = STOMATE IPCC history time step (d)
+  !Config  Def  = 0.
+  !Config  Help = Time step of the STOMATE IPCC history file
+  !-
+  hist_days_stom_ipcc = zero
+  CALL getin_p('STOMATE_IPCC_HIST_DT', hist_days_stom_ipcc)       
+  IF ( hist_days_stom_ipcc == moins_un ) THEN
+     hist_dt_stom_ipcc = moins_un
+     WRITE(numout,*) 'output frequency for STOMATE IPCC history file (d): one month.'
+  ELSE
+     hist_dt_stom_ipcc = NINT( hist_days_stom_ipcc ) * one_day
+     WRITE(numout,*) 'output frequency for STOMATE IPCC history file (d): ', &
+          hist_dt_stom_ipcc/one_day
+  ENDIF
+
+  ! test consistency between STOMATE_IPCC_HIST_DT and DT_SLOW parameters
+  dt_slow_ = one_day
+  CALL getin_p('DT_SLOW', dt_slow_)
+  IF ( hist_days_stom_ipcc > zero ) THEN
+     IF (dt_slow_ > hist_dt_stom_ipcc) THEN
+        WRITE(numout,*) "DT_SLOW = ",dt_slow_,"  , STOMATE_IPCC_HIST_DT = ",hist_dt_stom_ipcc
+        CALL ipslerr (3,'intsurf_history', &
+             &          'Problem with DT_SLOW > STOMATE_IPCC_HIST_DT','', &
+             &          '(must be less or equal)')
+     ENDIF
+  ENDIF
+
+  IF ( hist_dt_stom_ipcc == 0 ) THEN
+     hist_id_stom_ipcc = -1
+  ELSE
+     !-
+     !- initialize
+     IF ( rectilinear ) THEN
+#ifdef CPP_PARA
+        CALL histbeg(stom_ipcc_histname, iim, lon_rect, jjm, lat_rect,  1, iim, 1, jjm, &
+             &     itau_dep, date0, dt, hori_id, hist_id_stom_ipcc,domain_id=orch_domain_id)
+#else
+        CALL histbeg(stom_ipcc_histname, iim, lon_rect, jjm, lat_rect,  1, iim, 1, jjm, &
+             &     itau_dep, date0, dt, hori_id, hist_id_stom_ipcc)
+#endif
+     ELSE
+#ifdef CPP_PARA
+        CALL histbeg(stom_ipcc_histname, iim, lon, jjm, lat,  1, iim, 1, jjm, &
+             &     itau_dep, date0, dt, hori_id, hist_id_stom_ipcc,domain_id=orch_domain_id)
+#else
+        CALL histbeg(stom_ipcc_histname, iim, lon, jjm, lat,  1, iim, 1, jjm, &
+             &     itau_dep, date0, dt, hori_id, hist_id_stom_ipcc)
+#endif
+     ENDIF
+     !- declare this axis
+     CALL histvert (hist_id_stom_IPCC, 'PFT', 'Plant functional type', &
+          & '1', nvm, hist_PFTaxis, hist_IPCC_PFTaxis_id)
+
+     !- define STOMATE history file
+     CALL stom_IPCC_define_history (hist_id_stom_IPCC, nvm, iim, jjm, &
+          & dt, hist_dt_stom_ipcc, hori_id, hist_IPCC_PFTaxis_id)
+
+     !- end definition
+     CALL histend(hist_id_stom_IPCC)
+
+  ENDIF
+  !
+  CALL histwrite(hist_id_stom, 'Areas',  itau_dep+itau_step, area, kjpindex, indices)
+  IF ( hist_id_stom_IPCC > 0 ) THEN
+     CALL histwrite(hist_id_stom_IPCC, 'Areas',  itau_dep+itau_step, area, kjpindex, indices)
+  ENDIF
+  !
+  hist_id_sec = -1
+  hist_id_sec2 = -1
+!-
+! first call of slowproc to initialize variables
+!-
+  itau = itau_dep
+  !  
+  DO ji=1,kjpindex
+     DO jv=1,nvm
+        indexveg((jv-1)*kjpindex + ji) = indices(ji) + (jv-1)*kjpij
+     ENDDO
+  ENDDO
+  !-
+  !MM Problem here with dpu which depends on soil type           
+  DO l = 1, nbdl-1
+     ! first 2.0 is dpu 
+     ! second 2.0 is average
+     diaglev(l) = dpu_cste/(2**(nbdl-1) -1) * ( ( 2**(l-1) -1) + ( 2**(l) -1) ) / 2.0
+  ENDDO
+  diaglev(nbdl) = dpu_cste
+  !
+  CALL ioget_expval(val_exp)
+  ldrestart_read = .TRUE.
+  ldrestart_write = .FALSE.
+  !-
+  ! read some variables we need from SECHIBA's restart file
+  !-
+  CALL slowproc_main &
+ &  (itau, kjpij, kjpindex, dt_force, date0, &
+ &   ldrestart_read, ldrestart_write, .FALSE., .TRUE., &
+ &   indices, indexveg, lalo, neighbours, resolution, contfrac, soiltype, &
+ &   t2m, t2m_min, temp_sol, soiltemp, &
+ &   humrel_x, soilhum, litterhum, precip_rain, precip_snow, gpp_x, &
+ &   deadleaf_cover, assim_param_x, lai_x, height_x, veget_x, &
+ &   frac_nobio, veget_max_x, totfrac_nobio, qsintmax_x, &
+ &   rest_id_sec, hist_id_sec, hist_id_sec2, rest_id_sto, hist_id_stom, hist_id_stom_IPCC, co2_flux, fco2_lu)
+  ! correct date
+  day_counter = one_day - dt_force
+  date=1
+!-
+! time loop
+!-
+  IF (debug) check_time=.TRUE.
+  CALL intsurf_time( itau_dep+itau_step, date0, dtradia )
+  l_first_intersurf=.FALSE.
+  !
+  DO itau = itau_dep+itau_step,itau_fin,itau_step
+    !
+    CALL intsurf_time( itau, date0, dtradia )
+     !
+!-- next forcing state
+    iisf = iisf+1
+    IF (debug) WRITE(numout,*) "itau,iisf : ",itau,iisf
+!---
+    IF (iisf .GT. nsfm) THEN
+!-----
+!---- we have to read new forcing states from the file
+!-----
+!---- determine blocks of forcing states that are contiguous in memory
+!-----
+        CALL forcing_read(forcing_id,nsfm)
+
+!--------------------------
+
+!-----
+!---- determine which forcing states must be read next time
+!-----
+      isf(1) = isf(nsfm)+1
+      IF ( isf(1) .GT. nsft ) isf(1) = 1
+        DO iiisf = 2, nsfm
+           isf(iiisf) = isf(iiisf-1)+1
+           IF ( isf(iiisf) .GT. nsft ) isf(iiisf) = 1
+        ENDDO
+        nf_written(isf(:)) = .TRUE.
+!---- start again at first forcing state
+        iisf = 1
+     ENDIF
+     ! Bug here ! soiltype(:,3) != clay
+!     soiltype(:,3) = clay_fm(:,iisf)
+     humrel_x(:,:) = humrel_daily_fm(:,:,iisf)
+     litterhum(:) = litterhum_daily_fm(:,iisf)
+     t2m(:) = t2m_daily_fm(:,iisf)
+     t2m_min(:) = t2m_min_daily_fm(:,iisf)
+     temp_sol(:) = tsurf_daily_fm(:,iisf)
+     soiltemp(:,:) = tsoil_daily_fm(:,:,iisf)
+     soilhum(:,:) = soilhum_daily_fm(:,:,iisf)
+     precip_rain(:) = precip_fm(:,iisf)
+     gpp_x(:,:) = gpp_daily_fm(:,:,iisf)
+     veget_force_x(:,:) = veget_fm(:,:,iisf)
+     veget_max_force_x(:,:) = veget_max_fm(:,:,iisf)
+     lai_force_x(:,:) = lai_fm(:,:,iisf)
+     WHERE ( t2m(:) .LT. ZeroCelsius )
+        precip_snow(:) = precip_rain(:)
+        precip_rain(:) = 0.
+     ELSEWHERE
+        precip_snow(:) = 0.
+     ENDWHERE
+!---
+!-- scale GPP to new lai and veget_max
+!---
+     WHERE ( lai_x(:,:) .EQ. 0.0 ) gpp_x(:,:) = 0.0
+!-- scale GPP to new LAI
+     WHERE (lai_force_x(:,:) .GT. 0.0 )
+        gpp_x(:,:) = gpp_x(:,:)*ATAN(2.*lai_x(:,:)) &
+ &                           /ATAN( 2.*MAX(lai_force_x(:,:),0.01))
+     ENDWHERE
+!-- scale GPP to new veget_max
+     WHERE (veget_max_force_x(:,:) .GT. 0.0 )
+        gpp_x(:,:) = gpp_x(:,:)*veget_max_x(:,:)/veget_max_force_x(:,:)
+     ENDWHERE
+!---
+!-- number crunching
+!---
+     ldrestart_read = .FALSE.
+     ldrestart_write = .FALSE.
+     CALL slowproc_main &
+ &    (itau, kjpij, kjpindex, dt_force, date0, &
+ &     ldrestart_read, ldrestart_write, .FALSE., .TRUE., &
+ &     indices, indexveg, lalo, neighbours, resolution, contfrac, soiltype, &
+ &     t2m, t2m_min, temp_sol, soiltemp, &
+ &     humrel_x, soilhum, litterhum, precip_rain, precip_snow, gpp_x, &
+ &     deadleaf_cover, assim_param_x, lai_x, height_x, veget_x, &
+ &     frac_nobio, veget_max_x, totfrac_nobio, qsintmax_x, &
+ &     rest_id_sec, hist_id_sec, hist_id_sec2, rest_id_sto, hist_id_stom, hist_id_stom_IPCC, co2_flux, fco2_lu)
+     day_counter = one_day - dt_force
+  ENDDO ! end of the time loop
+!-
+! write restart files
+!-
+  IF (is_root_prc) THEN
+! first, read and write variables that are not managed otherwise
+     taboo_vars = &
+          &  '$lat$ $lon$ $lev$ $veget_year$ '// &
+          &  '$height$ $day_counter$ $veget$ $veget_max$ $frac_nobio$ '// &
+          &  '$lai$ $soiltype_frac$ $clay_frac$ '// &
+          &  '$nav_lon$ $nav_lat$ $nav_lev$ $time$ $time_steps$'
+!-
+     CALL ioget_vname(rest_id_sec, nbvar, varnames)
+!-
+     DO iv = 1, nbvar
+!-- check if the variable is to be written here
+        IF (INDEX( taboo_vars,'$'//TRIM(varnames(iv))//'$') .EQ. 0 ) THEN
+           IF (debug) WRITE(numout,*) "restart var : ",TRIM(varnames(iv)),itau_dep,itau_fin
+
+!---- get variable dimensions, especially 3rd dimension
+           CALL ioget_vdim &
+                &      (rest_id_sec, varnames(iv), varnbdim_max, varnbdim, vardims)
+           l1d = ALL(vardims(1:varnbdim) .EQ. 1)
+!---- read it
+           IF (l1d) THEN
+              CALL restget (rest_id_sec,TRIM(varnames(iv)), &
+                   1,1,1,itau_dep,.TRUE.,var_1d)
+           ELSE
+              ALLOCATE(var_3d(nbp_glo,vardims(3)),stat=ier)
+              IF (ier .NE. 0) STOP 'ALLOCATION PROBLEM'
+              CALL restget (rest_id_sec,TRIM(varnames(iv)), &
+                   nbp_glo,vardims(3),1,itau_dep,.TRUE.,var_3d, &
+                   "gather",nbp_glo,indices_g)
+           ENDIF
+!---- write it
+           IF (l1d) THEN
+              CALL restput (rest_id_sec,TRIM(varnames(iv)), &
+                   1,1,1,itau_fin,var_1d)
+           ELSE
+              CALL restput (rest_id_sec,TRIM(varnames(iv)), &
+                   nbp_glo,vardims(3),1,itau_fin,var_3d, &
+                   'scatter',nbp_glo,indices_g)
+              DEALLOCATE (var_3d)
+           ENDIF
+        ENDIF
+     ENDDO
+  ENDIF
+  CALL barrier_para()
+
+! call slowproc to write restart files
+  ldrestart_read = .FALSE.
+  ldrestart_write = .TRUE.
+!-
+  IF (debug) WRITE(numout,*) "Call slowproc for restart."
+  CALL slowproc_main &
+ &  (itau_fin, kjpij, kjpindex, dt_force, date0, &
+ &   ldrestart_read, ldrestart_write, .FALSE., .TRUE., &
+ &   indices, indexveg, lalo, neighbours, resolution, contfrac, soiltype, &
+ &   t2m, t2m_min, temp_sol, soiltemp, &
+ &   humrel_x, soilhum, litterhum, precip_rain, precip_snow, gpp_x, &
+ &   deadleaf_cover, assim_param_x, lai_x, height_x, veget_x, &
+ &   frac_nobio, veget_max_x, totfrac_nobio, qsintmax_x, &
+ &   rest_id_sec, hist_id_sec, hist_id_sec2, rest_id_sto, hist_id_stom, hist_id_stom_IPCC, co2_flux, fco2_lu)
+!-
+! close files
+!-
+  IF (is_root_prc) THEN
+     CALL restclo
+     IF ( debug )  WRITE(numout,*) 'REST CLOSED'
+  ENDIF
+  CALL histclo
+
+  IF (is_root_prc) &
+       ier = NF90_CLOSE (forcing_id)
+
+  IF (is_root_prc) THEN
+     CALL getin_dump()
+  ENDIF
+#ifdef CPP_PARA
+  CALL MPI_FINALIZE(ier)
+#endif
+  WRITE(numout,*) "End of teststomate."
+
+!---------------
+END PROGRAM teststomate
+!
+!===
+!
Index: /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/weather.f90
===================================================================
--- /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/weather.f90	(revision 405)
+++ /tags/ORCHIDEE_1_9_5_2/ORCHIDEE_OL/weather.f90	(revision 405)
@@ -0,0 +1,3649 @@
+MODULE weather
+!- IPSL (2006)
+!-  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
+!---------------------------------------------------------------------
+  USE netcdf
+!-
+  USE defprec
+  USE ioipsl
+  USE constantes
+  USE parallel
+  USE grid, ONLY : year,month,day,sec
+!-
+  IMPLICIT NONE
+!-
+  PRIVATE
+  PUBLIC weathgen_main, weathgen_domain_size, weathgen_init, weathgen_read_file
+!
+! Only for root proc
+  INTEGER, SAVE                              :: iim_file, jjm_file, llm_file, ttm_file
+  INTEGER,DIMENSION(:,:),SAVE,ALLOCATABLE    :: ncorr
+  INTEGER,DIMENSION(:,:,:),SAVE,ALLOCATABLE  :: icorr,jcorr
+  INTEGER,SAVE                               :: i_cut, n_agg
+
+! climatological wet days + anomaly (days/month)
+  REAL,DIMENSION(:,:),SAVE,ALLOCATABLE :: xinwet
+! climatological precipition + anomaly (mm/day)
+  REAL,DIMENSION(:,:),SAVE,ALLOCATABLE :: xinprec
+! climatological temp + anomaly (C)
+  REAL,DIMENSION(:,:),SAVE,ALLOCATABLE :: xint
+! climatological relative humidity + anomaly (%)
+  REAL,DIMENSION(:,:),SAVE,ALLOCATABLE :: xinq
+! climatological wind speed + anomaly (m s-1)
+  REAL,DIMENSION(:,:),SAVE,ALLOCATABLE :: xinwind
+! climatological cloudiness + anomaly(%)
+  REAL,DIMENSION(:,:),SAVE,ALLOCATABLE :: xincld
+! climatological temp range + anomaly(C)
+  REAL,DIMENSION(:,:),SAVE,ALLOCATABLE :: xintrng
+! topography (m)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: xintopo
+! latitudes of land points
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: lat_land
+!-
+! daily values
+!-
+  REAL,SAVE :: julian_last
+! flag for wet day / dry day
+  INTEGER,DIMENSION(:),SAVE,ALLOCATABLE :: iwet
+!-
+! today's values (m0 means "minus 0")
+!-
+! surface pressure (Pa)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: psurfm0
+! cloud fraction
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: cloudm0
+! maximum daily temperature (K)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: tmaxm0
+! minimum daily temperature (K)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: tminm0
+! daily average specific humidity (kg_h2o/kg_air)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: qdm0
+! daily average wind speed (m/sec)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: udm0
+! daily precitation (mm/day)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: precipm0
+!-
+! yesterday's values (m1 means "minus 1")
+!-
+! surface pressure (Pa)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: psurfm1
+! cloud fraction
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: cloudm1
+! maximum daily temperature (K)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: tmaxm1
+! minimum daily temperature (K)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: tminm1
+! daily average specific humidity (kg_h2o/kg_air)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: qdm1
+! daily average wind speed (m/sec)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: udm1
+! daily precitation (mm/day)
+  REAL,DIMENSION(:),SAVE,ALLOCATABLE   :: precipm1
+!-
+! other
+!-
+  REAL,PARAMETER   :: undef=1.e+20
+! statistical (0) or prescribed (1) daily values
+  INTEGER,SAVE     :: ipprec
+! respect monthly precipitation
+  LOGICAL,SAVE                  :: precip_exact
+  INTEGER,DIMENSION(31,12),SAVE :: jour_precip
+! max size of random seed
+  INTEGER,PARAMETER      :: seedsize_max = 300
+  LOGICAL,SAVE           :: dump_weather
+  CHARACTER(LEN=20),SAVE :: dump_weather_file
+  LOGICAL,SAVE           :: gathered
+  INTEGER,SAVE           :: dump_id
+!
+! Absolute zero
+  REAL,PARAMETER         :: zero_t=273.16
+!-
+! Parametres orbitaux:
+!-
+! Eccentricity
+  REAL,SAVE :: ecc
+! Longitude of perihelie
+  REAL,SAVE :: perh
+! obliquity
+  REAL,SAVE :: xob
+!-
+  INTEGER,PARAMETER :: nmon = 12
+!
+  CHARACTER(LEN=3),DIMENSION(12) :: cal = &
+ &  (/ 'JAN','FEB','MAR','APR','MAY','JUN', &
+ &     'JUL','AUG','SEP','OCT','NOV','DEC' /)
+  INTEGER,DIMENSION(12),SAVE :: ndaypm = &
+ &  (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /)
+  INTEGER,SAVE :: soldownid, rainfid, snowfid, lwradid, &
+ &                tairid, qairid,  psolid, uid, vid, &
+ &                time_id, timestp_id
+!-
+! Parameters for NETCDF :
+!-
+  INTEGER,SAVE :: n_rtp = nf90_real4
+!- 
+! Flag for dynamic allocations :
+  INTEGER  :: ALLOC_ERR
+!-
+! Calendar type
+  CHARACTER(LEN=20),SAVE :: calendar_str
+!-
+! Land points index
+  INTEGER, DIMENSION(:), ALLOCATABLE, SAVE :: kindex_w
+  INTEGER, SAVE                            :: nbindex_w
+!-
+! Plot of projection file => grid, number of column on terminal
+  INTEGER, PARAMETER :: termcol = 100
+!80
+  CONTAINS
+!-
+!===
+!-
+SUBROUTINE daily &
+ &  (npoi, imonth, iday, cloud, tmax, tmin, precip, qd, ud, psurf)
+!---------------------------------------------------------------------
+! overview
+!
+! this routine generates daily weather conditions from monthly-mean
+! climatic parameters
+!
+! specifically, this routine generates daily values of
+!
+!  - daily total precipitation
+!  - daily maximum temperature
+!  - daily minimum temperature
+!  - daily average cloud cover
+!  - daily average relative humidity
+!  - daily average wind speed
+!
+! in order to generate daily weather conditions, the model uses
+! a series of 'weather generator' approaches,
+! which generate random combinations of weather conditions
+! based upon the climatological conditions in general,
+! this weather generator is based upon the so-called Richardson
+! weather generator
+!
+! appropriate references include:
+!
+! Geng, S., F.W.T. Penning de Vries, and L. Supit, 1985:  A simple
+! method for generating rainfall data, Agricultural and Forest
+! Meteorology, 36, 363-376.
+!
+! Richardson, C. W. and Wright, D. A., 1984: WGEN: A model for
+! generating daily weather variables: U. S. Department of
+! Agriculture, Agricultural Research Service.
+!
+! Richardson, C., 1981: Stochastic simulation of daily
+! precipitation, temperature, and solar radiation. Water Resources
+! Research 17, 182-190.
+!---------------------------------------------------------------------
+!-
+! in & out: global variables
+!-
+! wet day / dry day flag
+! INTEGER,INTENT(INOUT):: iwet(npoi)
+!-
+! input
+!-
+! total number of land points
+  INTEGER,INTENT(IN) :: npoi
+  INTEGER,INTENT(IN) :: imonth, iday
+!-
+! output
+!-
+! surface pressure (Pa)
+  REAL,INTENT(OUT) :: psurf(npoi)
+! cloud fraction
+  REAL,INTENT(OUT) :: cloud(npoi)
+! maximum daily temperature (K)
+  REAL,INTENT(OUT) :: tmax(npoi)
+! maximum daily temperature (K)
+  REAL,INTENT(OUT) :: tmin(npoi)
+! daily average specific humidity (kg_h2o/kg_air)
+  REAL,INTENT(OUT) :: qd(npoi)
+! daily average wind speed (m/sec)
+  REAL,INTENT(OUT) :: ud(npoi)
+! daily precitation (mm/day)
+  REAL,INTENT(OUT) :: precip(npoi)
+!-
+! local
+!-
+! daily average temperature (K)
+  REAL :: td(npoi)
+  REAL,PARAMETER ::  rair = 287.
+  REAL,PARAMETER :: grav = 9.81
+  REAL,PARAMETER ::  pi = 3.1415927
+!-
+! weather generator 'memory' matrix
+!-
+  REAL,allocatable,save,dimension(:,:) ::  xstore
+!-
+  REAL :: ee(3), r(3), rr(npoi,3)
+  REAL :: alpha(npoi), rndnum, pwd, pww
+  REAL :: beta(npoi)
+  REAL :: pwet(npoi)
+  REAL :: rwork
+  REAL :: omcloud, omqd, omtmax
+  REAL :: cloudm, cloudw, cloudd
+  REAL :: cloude(npoi), clouds(npoi)
+  REAL :: tmaxd, tmaxw, tmaxm
+  REAL :: tminm
+  REAL :: tmins(npoi), tmaxs(npoi)
+  REAL :: tmine(npoi), tmaxe(npoi)
+  REAL :: qdm(npoi),qdd(npoi),qde(npoi),qdw(npoi),qdup(npoi),qdlow(npoi)
+  INTEGER :: i,j,k
+  REAL :: amn,b1,b2,b3,eud,rn,rn1,rn2,rn3,rn4,s1,s2,s12,x1,y, z(npoi)
+  REAL :: aa(npoi),ab(npoi),tr1(npoi), tr2(npoi)
+  REAL :: tdm,trngm,tdum
+  REAL :: qsattd(npoi)
+  INTEGER :: it1w, it2w
+  REAL :: dt
+  REAL :: rainpwd(npoi)
+  INTEGER :: not_ok(npoi)
+  INTEGER :: count_not_ok,count_not_ok_g
+  LOGICAL,SAVE :: firstcall = .TRUE.
+  INTEGER,save :: npoi0
+  REAL :: xx,e
+!-
+! define autocorrelation matrices for Richardson generator
+!
+! note that this matrix should be based upon a statistical
+! analysis of regional weather patterns
+!
+! for global simulations, we use 'nominal' values
+!-
+  REAL, DIMENSION(3,3) :: a,b
+! Warnings
+  LOGICAL :: Warning_aa_ab(npoi), Warning_iwet(npoi)
+
+!---------------------------------------------------------------------
+!-
+! initial setup for daily climate calculations
+!-
+  a(1,:) = (/ 0.600,  0.500,  0.005 /)
+  a(2,:) = (/ 0.010,  0.250,  0.005 /)
+  a(3,:) = (/ 0.020,  0.125,  0.250 /)
+!-
+  b(1,:) = (/ 0.500,  0.250, -0.250 /)
+  b(2,:) = (/ 0.000,  0.500,  0.250 /)
+  b(3,:) = (/ 0.000,  0.000,  0.500 /)
+!-
+  e = EXP(1.)
+! GK240100
+  IF (firstcall) THEN
+    firstcall = .FALSE.
+    ALLOC_ERR=-1
+    ALLOCATE(xstore(npoi,3), STAT=ALLOC_ERR)
+    IF (ALLOC_ERR/=0) THEN
+      WRITE(numout,*) "ERROR IN ALLOCATION of xstore : ",ALLOC_ERR
+      STOP 
+    ENDIF
+    xstore(:,:) = 0.
+    npoi0 = npoi
+  ELSE IF (npoi /= npoi0) THEN
+    WRITE(numout,*) 'Domain size old, new: ',npoi0,npoi
+    STOP 'WG Daily: Problem: Domain has changed since last call'
+  ENDIF
+!-
+! define working variables
+!-
+  rwork = (grav/rair/0.0065)
+!-
+! 'omega' parameters used to calculate differences in expected
+! climatic parameters on wet and dry days
+!
+! following logic of weather generator used in the EPIC crop model
+!
+! omcloud -- cloud cover
+! omqd    -- humidity
+! omtmax  -- maximum temperature
+!-
+  omcloud = 0.90    ! originally 0.90
+  omqd    = 0.50    ! originally 0.50
+  omtmax  = 0.75    ! originally 0.75
+!-
+! calculate weighting factors used in interpolating climatological
+! monthly-mean input values to daily-mean values
+!-
+! this is a simple linear interpolation technique that takes into
+! account the length of each month
+!-
+  IF (ipprec == 0) THEN
+    IF (REAL(iday) < REAL(ndaypm(imonth)+1)/2.0) then
+      it1w = imonth-1
+      it2w = imonth
+      dt   = (REAL(iday)-0.5)/ndaypm(imonth)+0.5
+    ELSE
+      it1w = imonth
+      it2w = imonth+1
+      dt   = (REAL(iday)-0.5)/ndaypm(imonth)-0.5
+    ENDIF
+    if (it1w <  1)  it1w = 12
+    if (it2w > 12)  it2w = 1
+  ELSE
+     dt = -1.
+     it1w = -1
+     it2w = -1
+  ENDIF
+!-
+  IF (ipprec == 0) THEN
+!---
+!-- use weather generator to create daily statistics
+!---
+! (1) determine if today will rain or not
+!---
+!-- calculate monthly-average probability of rainy day
+!---
+    DO i=1,npoi
+      pwet(i) = xinwet(i,imonth)/ndaypm(imonth)
+    ENDDO
+!---
+    IF (.NOT.precip_exact) THEN
+!-----
+!---- (1.1) following Geng et al.
+!-----
+      IF (is_root_prc) THEN
+         CALL random_number (rndnum)
+      ENDIF
+      CALL bcast(rndnum)
+!-----
+      DO i=1,npoi
+        IF (xinprec(i,imonth) > 1.e-6) THEN
+!---------
+!-------- implement simple first-order Markov-chain precipitation
+!-------- generator logic based on Geng et al. (1986),
+!-------- Richardson and Wright (1984), and Richardson (1981)
+!---------
+!-------- basically, this allows for the probability of today being
+!-------- a wet day (a day with measureable precipitation)
+!-------- to be a function of what yesterday was (wet or dry)
+!---------
+!-------- the logic here is that it is more likely that a wet day
+!-------- will follow another wet day -- allowing
+!-------- for 'storm events' to persist
+!---------
+!-------- estimate the probability of a wet day after a dry day
+!---------
+          pwd = 0.75*pwet(i)
+!---------
+!-------- estimate the probability of a wet day after a wet day
+!---------
+          pww = 0.25+pwd
+!---------
+!-------- decide if today is a wet day or a dry day
+!-------- using a random number
+!---------
+!-------- call random_number(rndnum) ! done before
+!---------
+          IF (iwet(i) == 0) then
+            IF (rndnum <= pwd) iwet(i) = 1
+          ELSE
+            IF (rndnum > pww) iwet(i) = 0
+          ENDIF
+        ELSE
+          iwet(i) = 0
+        ENDIF
+      ENDDO
+    ELSE
+!-----
+!---- (1.2) preserving the monthly number of precip days
+!----       and monthly precip
+!-----
+      DO i=1,npoi
+        IF (ABS(xinwet(i,imonth)) < 32.) THEN
+          IF (xinprec(i,imonth) > 1.e-6) THEN
+            IF (   jour_precip(iday,imonth) &
+ &              <= NINT(MAX(1.,xinwet(i,imonth))) ) THEN
+              iwet(i) = 1
+            ELSE
+              iwet(i) = 0
+            ENDIF
+          ELSE
+           iwet(i) = 0
+          ENDIF
+        ENDIF
+      ENDDO
+    ENDIF
+!---
+!-- (2) determine today's precipitation amount
+!---
+    IF (.not.precip_exact) THEN
+       Warning_aa_ab(:)=.FALSE.
+       Warning_iwet(:)=.FALSE.
+!-----
+!---- (2.1) following Geng et al.
+!-----
+      aa(:) = zero
+      ab(:) = zero
+      tr2(:)= zero
+      tr1(:)= zero
+      beta(:) = un
+      DO i=1,npoi
+!-------
+!------ initialize daily precipitation to zero
+!-------
+        precip(i) = 0.0
+!-------
+        IF (xinprec(i,imonth) > 1.e-6) THEN
+!---------
+!-------- if it is going to rain today
+!---------
+          IF (iwet(i) == 1) THEN
+!-----------
+!---------- calculate average rainfall per wet day
+!-----------
+            rainpwd(i) = xinprec(i,imonth) &
+ &                      *ndaypm(imonth)/MAX(0.1,xinwet(i,imonth))
+!-----------
+!---------- randomly select a daily rainfall amount
+!---------- from a probability density function of rainfall
+!----------
+!---------- method i --
+!-----------
+!---------- use the following technique from Geng et al. and Richardson
+!---------- to distribute rainfall probabilities
+!-----------
+!---------- pick a random rainfall amount
+!---------- from a two-parameter gamma function distribution function
+!-----------
+!---------- estimate two parameters for gamma function
+!---------- (following Geng et al.)
+!-----------
+            beta(i) = MAX(1.0,-2.16+1.83*rainpwd(i))
+            alpha(i) = rainpwd(i)/beta(i)
+!-----------
+!---------- determine daily precipitation amount
+!---------- from gamma distribution function
+!---------- (following WGEN code of Richardson and Wright (1984))
+!-----------
+            IF (ABS(1.-alpha(i)) < 1.e-6) THEN
+              alpha(i) = 1.e-6*(alpha(i)/ABS(alpha(i)))
+            ENDIF
+            aa(i) = 1.0/alpha(i)
+            ab(i) = 1.0/(1.0-alpha(i))
+!-----------
+            IF ( (ABS(aa(i)) < 1.e-6) .OR. (ABS(ab(i)) < 1.e-6) ) THEN
+               Warning_aa_ab(:)=.TRUE.
+            ENDIF
+            tr1(i) = exp(-18.42/aa(i))
+            tr2(i) = exp(-18.42/ab(i))
+          ENDIF
+        ELSE
+          IF (iwet(i) == 1) THEN
+            Warning_iwet(i)=.TRUE.
+          ENDIF
+        ENDIF
+      ENDDO
+
+      DO i=1,npoi
+         IF ( Warning_aa_ab(i) ) THEN
+            WRITE(numout,*) ' ATTENTION, aa ou ab:'
+            WRITE(numout,*) ' aa, ab = ',aa(i),ab(i)
+            WRITE(numout,*) '   alpha, rainpwd, beta =', &
+ &                       alpha(i),rainpwd(i),beta(i)
+         ENDIF
+         IF ( Warning_iwet(i) ) THEN
+            WRITE(numout,*) ' ATTENTION, iwet = 1 alors que xinprec = 0)'
+            WRITE(numout,*) '   xinprec, iwet = ',xinprec(i,imonth),iwet(i)
+          ENDIF
+      ENDDO
+!-----
+      where ( iwet(:) == 1 )
+        not_ok(:) = 1
+      elsewhere
+        not_ok(:) = 0
+      endwhere
+!-----
+      count_not_ok_g=0
+      count_not_ok=SUM(not_ok(:))
+      CALL reduce_sum(count_not_ok,count_not_ok_g)
+      CALL bcast(count_not_ok_g)
+!-
+      z(:)=0.0
+      DO WHILE (count_not_ok_g > 0)
+        IF (is_root_prc) THEN
+        CALL random_number (rn1)
+        CALL random_number (rn2)
+        ENDIF
+        CALL bcast(rn1)
+        CALL bcast(rn2)
+
+        DO i=1,npoi
+          IF ((iwet(i) == 1).AND.(not_ok(i) == 1)) then
+            IF ( (rn1-tr1(i)) <= 0. ) THEN
+              s1 = 0.0
+            ELSE
+              s1 = rn1**aa(i)
+            ENDIF
+!-----------
+            IF ((rn2-tr2(i)) <= 0.) THEN
+              s2 = 0.0
+            ELSE
+              s2 = rn2**ab(i)
+            ENDIF
+!-----------
+            s12 = s1+s2
+            IF ((s12-1.0) <= 0.) THEN
+              z(i) = s1/s12
+              not_ok(i) = 0
+            ENDIF
+          ENDIF
+        ENDDO
+
+        count_not_ok_g=0
+        count_not_ok=SUM(not_ok(:))
+        CALL reduce_sum(count_not_ok,count_not_ok_g)
+        CALL bcast(count_not_ok_g)
+      ENDDO
+!-----
+      IF (is_root_prc) THEN
+         CALL random_number (rn3)
+      ENDIF
+      CALL bcast(rn3)
+!      WRITE(*,*) mpi_rank,"rn3=",rn3
+!-----
+      DO i=1,npoi
+        IF (iwet(i) == 1) then
+          precip(i) = -z(i)*log(rn3)*beta(i)
+        ENDIF
+      ENDDO
+!-----
+!---- method ii --
+!-----
+!---- here we use a one-parameter Weibull distribution function
+!---- following the analysis of Selker and Haith (1990)
+!-----
+!---- Selker, J.S. and D.A. Haith, 1990: Development and testing
+!---- of single- parameter precipitation distributions,
+!---- Water Resources Research, 11, 2733-2740.
+!-----
+!---- this technique seems to have a significant advantage over other
+!---- means of generating rainfall distribution functions
+!-----
+!---- by calibrating the Weibull function to U.S. precipitation records,
+!---- Selker and Haith were able to establish the following relationship
+!-----
+!---- the cumulative probability of rainfall intensity x is given as:
+!-----
+!---- f(x) = 1.0-exp(-(1.191 x / rainpwd)**0.75)
+!-----
+!---- where x       : rainfall intensity
+!----       rainpwd : rainfall per wet day
+!-----
+!---- using transformation method, take uniform deviate and convert
+!---- it to a random number weighted by the following Weibull function
+!-----
+!----    call random_number(rndnum)
+!-----
+!----    precip(i) = rainpwd / 1.191*(-log(1.0-rndnum))**1.333333
+!-----
+!---- bound daily precipitation to "REAListic" range
+!-----
+      DO i=1,npoi
+        IF (iwet(i) == 1) THEN
+!---------
+!-------- lower end is determined by definition of a 'wet day'
+!-------- (at least 0.25 mm of total precipitation)
+!---------
+!-------- upper end is to prevent ibis from blowing up
+!---------
+          precip(i) = MAX(precip(i),  0.25) ! min =   0.25 mm/day
+          precip(i) = MIN(precip(i),150.00) ! max = 150.00 mm/day
+        ENDIF
+      ENDDO
+    ELSE
+!-----
+!---- (2.2) preserving the monthly number of precip days
+!----       and monthly precip
+!-----
+      DO i=1,npoi
+!-------
+!------ Correction Nathalie. C'est abs(xinwet) < 32 qu'il faut tester
+!------ et non pas abs(xinprec(i,imonth)) < 32.
+!-------
+!------ IF ( (iwet(i) == 1).and.(abs(xinprec(i,imonth)) < 32.) ) THEN
+        IF ( (iwet(i) == 1).and.(abs(xinwet(i,imonth)) < 32.) ) THEN
+          precip(i) = xinprec(i,imonth)*REAL(ndaypm(imonth)) &
+ &                   /REAL(NINT(MAX(1.,xinwet(i,imonth))))
+        ELSE
+          precip(i) = 0.
+        ENDIF
+      ENDDO
+    ENDIF
+!---
+!-- (3) estimate expected minimum and maximum temperatures
+!---
+    DO i=1,npoi
+!-----
+!---- first determine the expected maximum and minimum temperatures
+!---- (from climatological means) for this day of the year
+!-----
+!---- mean daily mean temperature (K)
+      tdm = xint(i,it1w)+dt*(xint(i,it2w)-xint(i,it1w))+zero_t
+!---- mean daily temperature range (K)
+      trngm = xintrng(i,it1w)+dt*(xintrng(i,it2w)-xintrng(i,it1w))
+!---- mean minimum and maximum temperatures
+      tmaxm = tdm+0.56*trngm
+      tminm = tdm-0.44*trngm
+!-----
+!---- modify maximum temperatures for wet and dry days
+!-----
+      IF (pwet(i) /= 0.0) THEN
+        tmaxd = tmaxm+pwet(i)*omtmax*trngm
+        tmaxw = tmaxd-        omtmax*trngm
+      ELSE
+        tmaxd = tmaxm
+        tmaxw = tmaxm
+      ENDIF
+!-----
+!---- set the 'expected' maximum and minimum temperatures for today
+!-----
+!---- note that the expected minimum temperatures are the same for
+!---- both wet and dry days
+!-----
+      if (iwet(i) == 0)  tmaxe(i) = tmaxd
+      if (iwet(i) == 1)  tmaxe(i) = tmaxw
+!-----
+      tmine(i) = tminm
+!-----
+!---- estimate variability in minimum and maximum temperatures
+!-----
+!---- tmaxs : standard deviation in maximum temperature (K)
+!---- tmins : standard deviation in minimum temperature (K)
+!-----
+!---- Regression is based on analysis of 2-m air temperature data
+!---- from the NCEP/NCAR reanalysis (1958-1997) for 294 land points
+!---- over central North America
+!---- (24N-52N, 130W-60W, 0.5-degree resolution):
+!---- Daily max and min temperatures were calculated for each
+!---- land point from daily mean temperature and temperature range.
+!---- Anomalies were calculated
+!---- by subtracting similar max and min temperatures calculated from
+!---- monthly mean temperature and range (interpolated to daily).
+!---- The 40 years of anomalies were then binned by month
+!---- and the standard deviation calculated for each month.
+!---- The 294 x 12 standard deviations were then regressed
+!---- against the 3528 long-term monthly mean temperatures.
+!-----
+!---- note: the values are bound to be greater than 1.0 K
+!----       (at the very least they must be bound
+!----        so they don't go below zero)
+!-----
+      tmaxs(i) = MAX(1.0,-0.0713*(tdm-zero_t)+4.89)
+      tmins(i) = MAX(1.0,-0.1280*(tdm-zero_t)+5.73)
+    ENDDO
+!---
+!-- (4) estimate expected cloud cover
+!---
+!---
+!-- the formulation of dry and wet cloud cover has been
+!-- derived from the weather generator used in the epic crop model
+!---
+    DO i=1,npoi
+!-----
+!---- cloudm : mean cloud cover for today
+!---- cloudd : dry day cloud cover
+!---- cloudw : dry day cloud cover
+!---- cloude : expected cloud cover today
+!-----
+!---- mean cloud cover (%)
+!-----
+      cloudm = xincld(i,it1w)+dt*(xincld(i,it2w)-xincld(i,it1w))
+!-----
+!---- convert from percent to fraction
+!-----
+      cloudm = cloudm/100.0
+!-----
+!---- adjust cloud cover depending on dry day / rainy day
+!---- following logic of the EPIC weather generator code
+!-----
+      IF (pwet(i) /= 0.0) THEN
+        cloudd = (cloudm-pwet(i)*omcloud)/(1.0-pwet(i)*omcloud)
+        cloudd = MIN(1.0,MAX(0.0,cloudd))
+        cloudw = (cloudm-(1.0-pwet(i))*cloudd)/pwet(i)
+      ELSE
+        cloudd = cloudm
+        cloudw = cloudm
+      ENDIF
+      IF (iwet(i) == 0)  cloude(i) = cloudd
+      IF (iwet(i) == 1)  cloude(i) = cloudw
+!-----
+!---- estimate variability in cloud cover for wet and dry days
+!---- following numbers proposed by Richardson
+!-----
+!---- clouds : standard deviation of cloud fraction
+!-----
+      IF (iwet(i) == 0)  clouds(i) = 0.24*cloude(i)
+      IF (iwet(i) == 1)  clouds(i) = 0.48*cloude(i)
+    ENDDO
+!---
+! (5) determine today's temperatures and cloud cover using
+!     first-order serial autoregressive technique
+!---
+!-- use the Richardson (1981) weather generator approach to simulate the
+!-- daily values of minimum / maximum temperature and cloud cover
+!---
+!-- following the implementation of the Richardson WGEN weather
+!-- generator used in the EPIC crop model
+!---
+!-- this approach uses a multivariate generator, which assumes that the
+!-- perturbation of minimum / maximum temperature and cloud cover are
+!-- normally distributed and that the serial correlation of each
+!-- variable may be described by a first-order autoregressive model
+!---
+!-- generate standard deviates for weather generator
+!---
+    DO j=1,3
+      ee(j) = 9999.
+      DO WHILE (ee(j) > 2.5)
+        IF (is_root_prc) THEN
+           CALL random_number (rn1)
+           CALL random_number (rn2)
+        ENDIF
+        CALL bcast(rn1)
+        CALL bcast(rn2)
+        ee(j) = SQRT(-2.0*LOG(rn1))*COS(6.283185*rn2)
+      ENDDO
+    ENDDO
+!---
+!-- zero out vectors
+!---
+    r(1:3)  = 0.0
+    rr(1:npoi,1:3) = 0.0
+!---
+!-- update working vectors
+!---
+    do j=1,3
+      do k=1,3
+        r(j) = r(j)+b(j,k)*ee(j)
+      enddo
+    enddo
+!---
+    do j=1,3
+      do k=1,3
+        do i=1,npoi
+          rr(i,j) = rr(i,j)+a(j,k)*xstore(i,k)
+        enddo
+      enddo
+    enddo
+!---
+!-- solve for x() perturbation vector and save current vector
+!-- into the xim1() storage vector (saved for each point)
+!---
+    do j=1,3
+      do i=1,npoi
+        xstore(i,j) = r(j)+rr(i,j)
+      enddo
+    enddo
+!---
+!-- determine today's minimum and maximum temperature
+!--
+    do i=1,npoi
+      tmax(i) = tmaxe(i)+tmaxs(i)*xstore(i,1)
+      tmin(i) = tmine(i)+tmins(i)*xstore(i,2)
+!-----
+!---- if tmin > tmax, then switch the two around
+!-----
+      if (tmin(i) > tmax(i)) then
+        tdum    = tmax(i)
+        tmax(i) = tmin(i)
+        tmin(i) = tdum
+      ENDIF
+!---- daily average temperature
+      td(i) = 0.44*tmax(i)+0.56*tmin(i)
+!---- determine today's cloud cover
+      cloud(i) = cloude(i)+clouds(i)*xstore(i,3)
+!---- constrain cloud cover to be between 0 and 100%
+      cloud(i) = MAX(0.0,MIN(1.0,cloud(i)))
+    enddo
+!---
+!-- (6) estimate today's surface atmospheric pressure
+!---
+    do i=1,npoi
+!-----
+!---- simply a function of the daily average temperature
+!---- and topographic height -- nothing fancy here
+!-----
+      psurf(i) = 101325.0*(td(i)/(td(i)+0.0065*xintopo(i)))**rwork
+    enddo
+!---
+!-- (7) estimate today's relative humidity
+!---
+    IF (is_root_prc) THEN
+       CALL random_number (rn)
+    ENDIF
+    CALL bcast(rn)
+!---
+    CALL weathgen_qsat (npoi,td,psurf,qsattd)
+!---
+    do i=1,npoi
+!-----
+!---- the formulation of dry and wet relative humidities has been
+!---- derived from the weather generator used in the epic crop model
+!-----
+!---- qdm : mean relative humidity
+!---- qdd : dry day relative humidity
+!---- qdw : rainy day relative humidity
+!---- qde : expected relative humidity (based on wet/dry decision)
+!-----
+!---- mean relative humidity (%)
+      qdm(i) = xinq(i,it1w)+dt*(xinq(i,it2w)-xinq(i,it1w))
+!---- convert from percent to fraction
+      qdm(i) = qdm(i)/100.0
+!-----
+!---- adjust humidity depending on dry day / rainy day
+!---- following logic of the EPIC weather generator code
+!-----
+      if (pwet(i) /= 0.0) then
+        qdd(i) = (qdm(i)-pwet(i)*omqd)/(1.0-pwet(i)*omqd)
+        if (qdd(i) < 0.2) then
+          qdd(i) = 0.2
+          if (qdd(i) > qdm(i)) qdm(i) = qdd(i)
+        ENDIF
+        qdd(i) = MIN(1.0,qdd(i))
+        qdw(i) = (qdm(i)-(1.0-pwet(i))*qdd(i))/pwet(i)
+      ELSE
+        qdd(i) = qdm(i)
+        qdw(i) = qdm(i)
+      ENDIF
+!-----
+      if (iwet(i) == 0)  qde(i) = qdd(i)
+      if (iwet(i) == 1)  qde(i) = qdw(i)
+!-----
+!---- estimate lower and upper bounds of humidity distribution function
+!---- following logic of the EPIC weather generator code
+!-----
+      xx = exp(qde(i))
+      qdup(i)  = qde(i)+(1.0-qde(i))*xx/e
+      qdlow(i) = qde(i)*(1.0-1./xx)
+!-----
+!---- randomlly select humidity from triangular distribution function
+!---- following logic of the EPIC weather generator code
+!-----
+!---- call random_number(rn) ! GK done before
+!-----
+      y  = 2.0/(qdup(i)-qdlow(i))
+!-----
+      b3 = qde(i)-qdlow(i)
+      b2 = qdup(i)-qde(i)
+      b1 = rn/y
+!-----
+      x1 = y*b3/2.0
+!-----
+      if (rn > x1) then
+        qd(i) = qdup(i)-sqrt (b2*b2-2.0*b2*(b1-0.5*b3))
+      ELSE
+        qd(i) = qdlow(i)+sqrt (2.0*b1*b3)
+      ENDIF
+!-----
+!---- adjust daily humidity to conserve monthly mean values
+!-----
+!---- note that this adjustment sometimes gives rise to humidity
+!---- values greater than 1.0 -- which is corrected below
+!-----
+      amn = (qdup(i)+qde(i)+qdlow(i))/3.0
+      qd(i) = qd(i)*qde(i)/amn
+!-----
+!---- constrain daily average relative humidity
+!-----
+      qd(i) = MAX(0.30,MIN(qd(i),0.99))
+!-----
+!---- convert from relative humidity to specific humidity at
+!---- daily mean temperature
+!-----
+      qd(i) = qd(i)*qsattd(i)
+    enddo
+!---
+!-- (8) estimate today's daily average wind speed
+!---
+    IF (is_root_prc) THEN
+        CALL random_number (rn4)
+    ENDIF
+    CALL bcast(rn4)
+
+    do i=1,npoi
+!-----
+!---- first estimate the expected daily average wind speed (from monthly
+!---- means)
+!-----
+      eud = xinwind(i,it1w)+dt*(xinwind(i,it2w)-xinwind(i,it1w))
+!-----
+!---- following logic of the EPIC weather generator
+!---- select random wind speed following this equation
+!-----
+!---- call random_number(rn4)
+!-----
+      ud(i) = 1.13989*eud*(-log(rn4))**0.30
+!---- constrain daily wind speeds to be between 2.5 and 10.0 m/sec
+      ud(i) = MAX(2.5,MIN(ud(i),10.0))
+    ENDDO
+  ELSE
+!---
+!-- use REAL daily climate data
+!---
+    DO i=1,npoi
+!-----
+!---- use basic daily climate data, converting units
+!-----
+!---- daily total precipitation
+      precip(i) = xinprec(i,imonth)
+!---- daily average temperatures
+      td(i) = xint(i,imonth)+zero_t
+      trngm = MIN(44.0,xintrng(i,imonth))
+!-----
+      tmax(i) = td(i)+0.56*trngm
+      tmin(i) = td(i)-0.44*trngm
+!---- daily average cloud cover
+      cloud(i) = xincld(i,imonth)*0.01
+!---- daily average specific humidity
+      qd(i) = xinq(i,imonth)
+!---- daily average wind speed
+      ud(i) = xinwind(i,imonth)
+!-----
+!---- compute surface atmospheric pressure
+!-----
+      psurf(i) = 101325.0*(td(i)/(td(i)+0.0065*xintopo(i)))**rwork
+    ENDDO
+  ENDIF
+!-------------------
+END SUBROUTINE daily
+!-
+!===
+!-
+SUBROUTINE diurnal &
+& (npoi, nband, time, jday, plens, startp, endp, latitude, &
+&  cloud, tmax, tmin, precip, qd, ud, psurf, &
+&  fira, solad, solai, ua, ta, qa, raina, snowa, rh)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+! input
+!-
+! number of grid points
+  INTEGER,INTENT(IN) :: npoi
+! number of visible bands
+  INTEGER,INTENT(IN) :: nband
+  REAL,INTENT(IN) :: time
+  INTEGER, INTENT(IN) :: jday
+  REAL,INTENT(IN) :: plens,startp,endp
+! latitude in degrees
+  REAL,INTENT(IN) :: latitude(npoi)
+! cloud fraction [0,1]
+  REAL,INTENT(IN) :: cloud(npoi)
+! maximum daily temperature (K)
+  REAL,INTENT(IN) :: tmax(npoi)
+! maximum daily temperature (K)
+  REAL,INTENT(IN) :: tmin(npoi)
+! daily precitation (mm/day)
+  REAL,INTENT(IN) :: precip(npoi)
+! daily average specific humidity (kg_h2o/kg_air)
+  REAL,INTENT(IN) :: qd(npoi)
+! daily average wind speed (m/sec)
+  REAL,INTENT(IN) :: ud(npoi)
+! surface pressure (Pa)
+  REAL,INTENT(IN) :: psurf(npoi)
+!-
+! output
+!-
+! incoming ir flux (W m-2)
+  REAL,INTENT(OUT) :: fira(npoi)
+! direct downward solar flux (W m-2)
+  REAL,INTENT(OUT) :: solad(npoi,nband)
+! diffuse downward solar flux (W m-2)
+  REAL,INTENT(OUT) :: solai(npoi,nband)
+! wind speed (m s-1)
+  REAL,INTENT(OUT) :: ua(npoi)
+! air temperature (K)
+  REAL,INTENT(OUT) :: ta(npoi)
+! specific humidity (kg_h2o/kg_air)
+  REAL,INTENT(OUT) :: qa(npoi)
+! rainfall rate (mm/day)
+  REAL,INTENT(OUT) :: raina(npoi)
+! snowfall rate (mm/day)
+  REAL,INTENT(OUT) :: snowa(npoi)
+! relative humidity(%)
+  REAL,INTENT(OUT) :: rh(npoi)
+!-
+! local
+!-
+  REAL,PARAMETER :: stef = 5.67051E-8
+  REAL,PARAMETER :: pi = 3.1415927
+  REAL,SAVE      :: step
+  REAL,PARAMETER :: pir = pi/180.
+  REAL :: xl,so,xllp,xee,xse
+  REAL :: xlam,dlamm,anm,ranm,ranv,anv,tls,rlam
+  REAL :: sd,cd,deltar,delta,Dis_ST,ddt
+!-
+  REAL :: coszen(npoi)      ! cosine of solar zenith angle
+  REAL :: rtime
+  REAL :: orbit,angle,xdecl,xlat
+  REAL :: sw,frac,gamma,qmin,qmax,qsa,emb,ea,ec,dtair,dtcloud,rn
+  REAL :: trans(npoi), fdiffuse(npoi), qsatta(npoi), qsattmin(npoi)
+  INTEGER :: i,ib
+  INTEGER,SAVE :: npoi0
+  LOGICAL,SAVE :: firstcall = .TRUE.
+!---------------------------------------------------------------------
+! GK240100
+  IF (firstcall) THEN
+     IF ( TRIM(calendar_str) .EQ. 'gregorian' ) THEN  
+        step = 1.0
+     ELSE
+        step = one_year/365.2425
+     ENDIF
+    firstcall = .FALSE.
+    npoi0 = npoi
+  ELSE IF (npoi /= npoi0) THEN
+    WRITE(numout,*) 'Domain size old, new: ',npoi0,npoi
+    STOP 'WG Diurnal: Problem: Domain has changed since last call'
+  ENDIF
+!-
+! calendar and orbital calculations
+!-
+! calculate time in hours
+  rtime = time/3600.0
+!-
+! calculate the earth's orbital angle (around the sun) in radians
+  orbit = 2.0*pi*REAL(jday)/365.2425
+!-
+! calculate the solar hour angle in radians
+  angle = 2.0*pi*(rtime-12.0)/24.0
+!-
+! calculate the current solar declination angle
+! ref: global physical climatology, hartmann, appendix a
+!
+! xdecl = 0.006918 &
+!        -0.399912*cos(orbit) &
+!        +0.070257*sin(orbit) &
+!        -0.006758*cos(2.0*orbit) &
+!        +0.000907*sin(2.0*orbit) &
+!        -0.002697*cos(3.0*orbit) &
+!        +0.001480*sin(3.0*orbit)
+!
+! calculate the effective solar constant,
+! including effects of eccentricity
+! ref: global physical climatology, hartmann, appendix a
+!
+! sw = 1370.*( 1.000110 &
+!             +0.034221*cos(orbit) &
+!             +0.001280*sin(orbit) &
+!             +0.000719*cos(2.0*orbit) &
+!             +0.000077*sin(2.0*orbit))
+!
+! correction Marie-France Loutre
+!
+!    orbital parameters
+!
+!    ecc = 0.016724
+!    perh = 102.04
+!    xob = 23.446
+!-
+  xl = perh+180.0
+! so : sinus of obliquity
+  so = sin(xob*pir)
+!-
+  xllp = xl*pir
+  xee  = ecc*ecc
+  xse  = sqrt(1.0d0-xee)
+! xlam : true long. sun for mean long. = 0
+  xlam = (ecc/2.0+ecc*xee/8.0d0)*(1.0+xse)*sin(xllp)-xee/4.0 &
+ &      *(0.5+xse)*sin(2.0*xllp)+ecc*xee/8.0*(1.0/3.0+xse) &
+ &      *sin(3.0*xllp)
+  xlam  =2.0d0*xlam/pir
+! dlamm : mean long. sun for ma-ja
+  dlamm =xlam+(jday-79)*step
+  anm   = dlamm-xl
+  ranm  = anm*pir
+  xee   = xee*ecc
+! ranv : anomalie vraie    (radian)
+  ranv = ranm+(2.0*ecc-xee/4.0)*sin(ranm)+5.0/4.0*ecc*ecc &
+ &      *sin(2.0*ranm)+13.0/12.0*xee*sin(3.0*ranm)
+! anv  : anomalie vraie    (degrees)
+  anv  = ranv/pir
+! tls  : longitude vraie   (degrees)
+  tls  = anv+xl
+! rlam : longitude vraie   (radian)
+  rlam = tls*pir
+! sd and cd: cosinus and sinus of solar declination angle (delta)
+! sinus delta = sin (obl)*sin(lambda) with lambda = real longitude
+! (Phd. thesis of Marie-France Loutre, ASTR-UCL, Belgium, 1993)
+  sd    = so*sin(rlam)
+  cd    = sqrt(1.0d0-sd*sd)
+! delta : Solar Declination (degrees, angle sun at equator)
+  deltar = atan(sd/cd)
+  delta  = deltar/pir
+!-
+! Eccentricity Effect
+!-
+  Dis_ST  =(1.0-ecc*ecc)/(1.0+ecc*cos(ranv))
+! ddt :    1 / normalized earth's sun distance
+  ddt = 1.0/Dis_ST
+!-
+! Insolation normal to the atmosphere (W/m2)
+!-
+  sw  = ddt *ddt *1370.d0
+!-
+  xdecl = deltar
+!-
+! solar calculations
+!-
+  do i=1,npoi
+!---
+!-- calculate the latitude in radians
+!---
+    xlat = latitude(i)*pi/180.0
+!---
+!-- calculate the cosine of the solar zenith angle
+!---
+    coszen(i) = MAX(0.0, (sin(xlat)*sin(xdecl) &
+ &                      + cos(xlat)*cos(xdecl)*cos(angle)))
+!---
+!-- calculate the solar transmission through the atmosphere
+!-- using simple linear function of tranmission and cloud cover
+!---
+!-- note that the 'cloud cover' data is typically obtained from
+!-- sunshine hours -- not direct cloud observations
+!---
+!-- where, cloud cover = 1 - sunshine fraction
+!---
+!-- different authors present different values for the slope and
+!-- intercept terms of this equation
+!---
+!-- Friend, A: Parameterization of a global daily weather generator
+!-- for terrestrial ecosystem and biogeochemical modelling,
+!-- Ecological Modelling
+!---
+!-- Spitters et al., 1986: Separating the diffuse and direct component
+!-- of global radiation and its implications for modeling canopy
+!-- photosynthesis, Part I: Components of incoming radiation,
+!-- Agricultural and Forest Meteorology, 38, 217-229.
+!---
+!-- A. Friend       : trans = 0.251+0.509*(1.0-cloud(i))
+!-- Spitters et al. : trans = 0.200+0.560*(1.0-cloud(i))
+!---
+!-- we are using the values from A. Friend
+!---
+    trans(i) = 0.251+0.509*(1.0-cloud(i))
+!---
+!-- calculate the fraction of indirect (diffuse) solar radiation
+!-- based upon the cloud cover
+!---
+!-- note that these relationships typically are measured for either
+!-- monthly or daily timescales, and may not be exactly appropriate
+!-- for hourly calculations -- however, in ibis, cloud cover is fixed
+!-- through the entire day so it may not make much difference
+!---
+!-- method i --
+!---
+!-- we use a simple empirical relationships
+!-- from Nikolov and Zeller (1992)
+!---
+!-- Nikolov, N. and K.F. Zeller, 1992:  A solar radiation algorithm
+!-- for ecosystem dynamics models, Ecological Modelling, 61, 149-168.
+!---
+    fdiffuse(i) = 1.0045+trans(i)*( 0.0435+trans(i) &
+ &                                 *(-3.5227+trans(i)*2.6313))
+!---
+    IF (trans(i) > 0.75) fdiffuse(i) = 0.166
+!---
+!-- method ii --
+!---
+!-- another method was suggested by Spitters et al. (1986) based on
+!-- long-term data from the Netherlands
+!--
+!-- Spitters et al., 1986: Separating the diffuse and direct component
+!-- of global radiation and its implications for modeling canopy
+!-- photosynthesis, Part I: Components of incoming radiation,
+!-- Agricultural and Forest Meteorology, 38, 217-229.
+!---
+!--       if ((trans == 0.00).and.(trans < 0.07)) then
+!--         fdiffuse = 1.0
+!--       else if ((trans >= 0.07).and.(trans < 0.35)) then
+!--         fdiffuse = 1.0-2.3*(trans-0.07)**2
+!--       else if ((trans >= 0.35).and.(trans < 0.75)) then
+!--         fdiffuse = 1.33-1.46*trans
+!--       ELSE
+!--         fdiffuse = 0.23
+!--       endif
+!---
+  ENDDO
+!-
+! do for each waveband
+!-
+  DO ib=1,nband
+!---
+!-- calculate the fraction in each waveband
+!---
+!-- GK010200
+    IF (nband == 2) then
+      frac = 0.46+0.08*REAL(ib-1)
+    ELSE
+      frac = 1./REAL(nband)
+    ENDIF
+!---
+    DO i=1,npoi
+!-----
+!---- calculate the direct and indirect solar radiation
+!-----
+      solad(i,ib) = sw*coszen(i)*frac*trans(i)*(1.-fdiffuse(i))
+      solai(i,ib) = sw*coszen(i)*frac*trans(i)*fdiffuse(i)
+    ENDDO
+  ENDDO
+!-
+! temperature calculations
+!-
+!---
+!-- assign hourly temperatures using tmax and tmin
+!-- following Environmental Biophysics, by Campbell and Norman, p.23
+!---
+!-- this function fits a fourier series to the diurnal temperature cycle
+!-- note that the maximum temperature occurs at 2:00 pm local solar time
+!---
+!-- note that the daily mean value of gamma is 0.44,
+!-- so td = 0.44*tmax+0.56*tmin,  instead of
+!--    td = 0.50*tmax+0.50*tmin
+!---
+  gamma = 0.44-0.46*SIN(    pi/12.0*rtime+0.9) &
+              +0.11*SIN(2.0*pi/12.0*rtime+0.9)
+  DO i=1,npoi
+    ta(i) = tmax(i)*gamma+tmin(i)*(1.0-gamma)
+  ENDDO
+!-
+! humidity calculations
+!-
+  CALL weathgen_qsat (npoi,tmin,psurf,qsattmin)
+  CALL weathgen_qsat (npoi,ta,psurf,qsatta)
+!-
+  DO i=1,npoi
+!---
+!-- adjust specific humidity against daily minimum temperatures
+!---
+!-- To do this, qa is written as an approximate sine function
+!-- (same as ta) to preserve the daily mean specific humidity,
+!-- while also preventing rh from exceeding 99% at night
+!---
+!-- Note that the daily mean RH is *not* preserved, and therefore the
+!-- output RH will be slightly different from what was read in.
+!---
+!-- first adjust so that maximum RH cannot exceed 99% at night
+!---
+    qmin = MIN(qd(i),0.99*qsattmin(i))
+    qmax = (qd(i)-0.56*qmin)/0.44
+!---
+!-- if needed, adjust again to 99% at other times of the day (in which
+!-- case the daily mean *specific* humidity is also not preserved)
+!---
+    qsa  = 0.99*qsatta(i)
+!---
+!-- calculate the hourly specific humidity, using the above adjustments
+!---
+    qa(i) = MIN(qsa,qmax*gamma+qmin*(1.0-gamma))
+!---
+!-- calculate the hourly relative humidity
+!--
+    rh(i) = 100.*qa(i)/qsatta(i)
+  ENDDO
+!-
+! wind speed calculations
+!-
+  IF (is_root_prc) THEN
+     CALL random_number (rn)
+  ENDIF
+  CALL bcast(rn)
+!-
+  DO i=1,npoi
+!---
+!-- following logic of the EPIC weather generator
+!-- select random wind speed following this equation
+!---
+!-- call random_number(rn) ! done before
+!---
+    ua(i) = 1.13989*ud(i)*(-log(rn))**0.30
+!---
+!-- fix wind speeds to always be above 2.5 m/sec and below 10.0 m/sec
+!---
+    ua(i) = MAX(2.5,MIN(10.0,ua(i)))
+  ENDDO
+!-
+! ir flux calculations
+!-
+  DO i=1,npoi
+!---
+!-- clear-sky emissivity as a function of water vapor pressure
+!-- and atmospheric temperature
+!---
+!-- calculate the ir emissivity of the clear sky
+!-- using equation from idso (1981) water resources res., 17, 295-304
+!---
+    emb = 0.01*(psurf(i)*qa(i)/(0.622+qa(i)))
+    ea  = 0.70+5.95e-5*emb*EXP(1500.0/ta(i))
+!---
+!-- assign the ir emissivity of clouds
+!-- (assume they are ~black in the ir)
+!---
+    ec = 0.950
+!---
+!-- assign the temperature difference of emissions (air+cloud) from
+!-- the surface air temperature
+!---
+    dtair   = 0.0
+    dtcloud = 0.0
+!---
+!-- total downward ir is equal to the sum of:
+!---
+!-- (1) clear sky contribution to downward ir radiation flux
+!-- (2) cloud contribution to downward ir radiation flux
+!---
+    fira(i) = (1.-cloud(i))*ea*stef*(ta(i)-dtair)**4 &
+ &           +cloud(i)*ec*stef*(ta(i)-dtcloud)**4
+  ENDDO
+!-
+! snow and rain calculations
+!-
+  DO i=1,npoi
+!---
+!-- reset snow and rain to zero
+!---
+    snowa(i) = 0.0
+    raina(i) = 0.0
+!---
+!-- if precipitation event then calculate
+!---
+    IF (time >= startp .and. time < endp) then
+!-----
+!---- for rain / snow partitioning, make it all rain if
+!---- ta > 2.5 C and all snow if ta <= 2.5 C
+!-----
+!---- reference:
+!-----
+!---- Auer, A. H., 1974: The rain versus snow threshold temperatures,
+!---- Weatherwise, 27, 67.
+!-----
+      IF (ta(i)-273.15 > 2.5) then
+        raina(i) = precip(i)/plens
+      ELSE
+        snowa(i) = precip(i)/plens
+      ENDIF
+    ENDIF
+  ENDDO
+!---------------------
+END SUBROUTINE diurnal
+!-
+!===
+!-
+SUBROUTINE weathgen_main &
+& (itau, istp, filename, force_id, iim, jjm, nband, &
+&  rest_id, lrstread, lrstwrite, &
+&  limit_west, limit_east, limit_north, limit_south, &
+&  zonal_res, merid_res, lon, lat, date0, dt_force, &
+&  kindex, nbindex, &
+&  swdown, rainf, snowf, tair, u, v, qair, pb, lwdown)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(IN)                  :: itau,istp
+  CHARACTER(LEN=*),INTENT(IN)         :: filename
+  INTEGER,INTENT(IN)                  :: force_id
+  INTEGER,INTENT(IN)                  :: iim,jjm
+  INTEGER,INTENT(IN)                  :: nband
+  INTEGER,INTENT(IN)                  :: rest_id
+  LOGICAL,INTENT(IN)                  :: lrstread, lrstwrite
+  REAL,INTENT(IN)                     :: limit_west,limit_east
+  REAL,INTENT(IN)                     :: limit_north,limit_south
+  REAL,INTENT(IN)                     :: zonal_res,merid_res
+  REAL,DIMENSION(iim,jjm),INTENT(IN)  :: lon,lat
+  REAL,INTENT(IN)                     :: date0,dt_force
+!-
+  INTEGER,DIMENSION(iim*jjm),INTENT(INOUT) :: kindex
+  INTEGER,INTENT(INOUT)                    :: nbindex
+!-
+  REAL,DIMENSION(iim,jjm),INTENT(OUT) :: &
+ &  tair,pb,qair,swdown,rainf,snowf, u,v,lwdown
+  REAL, ALLOCATABLE, DIMENSION(:,:) :: &
+ &  tair_g,pb_g,qair_g,swdown_g,rainf_g,snowf_g, u_g,v_g,lwdown_g
+  REAL,DIMENSION(nbindex) :: &
+ &  tairl,pbl,qairl,swdownl,rainfl,snowfl, ul,vl,lwdownl
+  INTEGER :: i,j,ij
+!---------------------------------------------------------------------
+  IF (lrstread) THEN
+    CALL weathgen_begin ( &
+     & dt_force,itau, date0, &
+     & rest_id,iim,jjm, &
+     & lon,lat,tair,pb,qair,kindex,nbindex)
+        RETURN
+  ELSE
+    CALL weathgen_get &
+ &   (itau, date0, dt_force, nbindex, nband, lat_land, &
+ &    swdownl, rainfl, snowfl, tairl, ul, vl, qairl, pbl, lwdownl)
+
+    tair(:,:)=val_exp
+    qair(:,:)=val_exp
+    pb(:,:)=val_exp
+!!$    tair(:,:)=280.
+!!$    qair(:,:)=1.E-03
+!!$    pb(:,:)=101325
+    DO ij=1,nbindex
+       j = (((kindex(ij)-1)/iim) + 1)
+       i = (kindex(ij) - (j-1)*iim)
+       !
+       swdown(i,j)=swdownl(ij)
+       rainf(i,j)=rainfl(ij)
+       snowf(i,j)=snowfl(ij)
+       tair(i,j)=tairl(ij)
+       u(i,j)=ul(ij)
+       v(i,j)=vl(ij)
+       qair(i,j)=qairl(ij)
+       pb(i,j)=pbl(ij)
+       lwdown(i,j)=lwdownl(ij)
+    ENDDO
+!---
+    IF (dump_weather) THEN
+      ALLOCATE(tair_g(iim_g,jjm_g))
+      ALLOCATE(pb_g(iim_g,jjm_g))
+      ALLOCATE(qair_g(iim_g,jjm_g))
+      ALLOCATE(swdown_g(iim_g,jjm_g))
+      ALLOCATE(rainf_g(iim_g,jjm_g))
+      ALLOCATE(snowf_g(iim_g,jjm_g))
+      ALLOCATE(u_g(iim_g,jjm_g))
+      ALLOCATE(v_g(iim_g,jjm_g))
+      ALLOCATE(lwdown_g(iim_g,jjm_g))
+
+      CALL gather2D(tair, tair_g)
+      CALL gather2D(pb, pb_g)
+      CALL gather2D(qair, qair_g)
+      CALL gather2D(swdown, swdown_g)
+      CALL gather2D(rainf, rainf_g)
+      CALL gather2D(snowf, snowf_g)
+      CALL gather2D(u, u_g)
+      CALL gather2D(v, v_g)
+      CALL gather2D(lwdown, lwdown_g)
+      IF (is_root_prc) THEN
+         CALL weathgen_dump &
+ &           (itau, dt_force, iim_g, jjm_g, nbp_glo, index_g, lrstwrite, &
+ &            swdown_g, rainf_g, snowf_g, tair_g, u_g, v_g, qair_g, pb_g, lwdown_g)
+      ENDIF
+    ENDIF
+!---
+    IF (lrstwrite) THEN
+      CALL weathgen_restwrite (rest_id,istp,iim,jjm,nbindex,kindex)
+    ENDIF
+  ENDIF
+!---------------------------
+END SUBROUTINE weathgen_main
+!-
+!===
+!-
+SUBROUTINE weathgen_init &
+     & (filename,dt_force,force_id,iim,jjm, &
+     &  zonal_res,merid_res,lon,lat,kindex,nbindex)
+!!$,iind,jind)
+  !---------------------------------------------------------------------
+  IMPLICIT NONE
+  !-
+  CHARACTER(LEN=*),INTENT(IN)         :: filename
+  REAL,INTENT(IN)                     :: dt_force
+  INTEGER,INTENT(INOUT)               :: force_id
+  INTEGER,INTENT(IN)                  :: iim, jjm
+  REAL,INTENT(IN)                     :: zonal_res,merid_res
+  REAL,DIMENSION(iim,jjm),INTENT(IN)  :: lon,lat
+  !-
+  INTEGER,DIMENSION(iim*jjm),INTENT(OUT)  :: kindex
+  INTEGER,INTENT(OUT)                     :: nbindex
+!!$  INTEGER,DIMENSION(iim),INTENT(OUT) :: iind
+!!$  INTEGER,DIMENSION(jjm),INTENT(OUT) :: jind
+  !-
+  REAL,PARAMETER  :: fcrit = .5
+  REAL,DIMENSION(:),ALLOCATABLE         :: lon_file, lon_temp
+  REAL,DIMENSION(:,:),ALLOCATABLE       :: nav_lon, nav_lat
+  REAL,DIMENSION(:),ALLOCATABLE         :: lat_file, lat_temp
+  REAL,DIMENSION(:,:),ALLOCATABLE       :: lsm_file
+  REAL     :: xextent_file, yextent_file, xres_file, yres_file
+  INTEGER  :: i, j, plotstep
+  REAL,DIMENSION(iim,jjm)               :: mask
+  CHARACTER(LEN=1),DIMENSION(0:1)       :: maskchar
+  CHARACTER(LEN=30)                     :: var_name
+  REAL     :: x_cut
+
+  REAL,DIMENSION(iim) :: tmp_lon
+  REAL,DIMENSION(jjm) :: tmp_lat
+  !---------------------------------------------------------------------
+  !-
+  ! 0. messages, initialisations
+  !-
+  WRITE(numout,*) &
+       &  'weathgen_init: Minimum land fraction on original grid =',fcrit
+  CALL ioget_calendar(calendar_str)
+  !-
+  ! 1. on lit les longitudes et latitudes de la grille de depart
+  !    ainsi que le masque terre-ocean
+  !-
+  CALL flinclo(force_id)
+  CALL flininfo (filename,iim_file,jjm_file,llm_file,ttm_file,force_id)
+  !-
+  ALLOC_ERR=-1
+  ALLOCATE(nav_lon(iim_file,jjm_file), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+     WRITE(numout,*) "ERROR IN ALLOCATION of nav_lon : ",ALLOC_ERR
+     STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(nav_lat(iim_file,jjm_file), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+     WRITE(numout,*) "ERROR IN ALLOCATION of nav_lat : ",ALLOC_ERR
+     STOP 
+  ENDIF
+  !-
+  var_name='nav_lon'
+  CALL flinget (force_id,var_name,iim_file,jjm_file,0,0,1,1,nav_lon)
+  var_name='nav_lat'
+  CALL flinget (force_id,var_name,iim_file,jjm_file,0,0,1,1,nav_lat)
+  !-
+
+  ALLOC_ERR=-1
+  ALLOCATE(lon_file(iim_file), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+     WRITE(numout,*) "ERROR IN ALLOCATION of lon_file : ",ALLOC_ERR
+     STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(lat_file(jjm_file), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+     WRITE(numout,*) "ERROR IN ALLOCATION of lat_file : ",ALLOC_ERR
+     STOP 
+  ENDIF
+  !-
+  DO i=1,iim_file
+     lon_file(i) = nav_lon(i,1)
+  ENDDO
+  DO j=1,jjm_file
+     lat_file(j) = nav_lat(1,j)
+  ENDDO
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(lsm_file(iim_file,jjm_file), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of lsm_file : ",ALLOC_ERR
+    STOP 
+  ENDIF
+!-
+  var_name='lsmera'
+  CALL flinget (force_id,var_name,iim_file,jjm_file,0,0,1,1,lsm_file)
+!-
+! 2. La resolution du modele ne doit pas etre superieure
+!    a celle de la grille de depart
+!-
+  xextent_file = lon_file(iim_file)-lon_file(1)
+  yextent_file = lat_file(1)-lat_file(jjm_file)
+  xres_file = xextent_file/REAL(iim_file-1)
+  yres_file = yextent_file/REAL(jjm_file-1)
+!-
+  IF (xres_file > zonal_res) THEN
+    WRITE(numout,*) 'Zonal resolution of model grid too fine.'
+    WRITE(numout,*) 'Resolution of original data (deg): ', xres_file
+    STOP
+  ENDIF
+!-
+  IF (yres_file > merid_res) THEN
+    WRITE(numout,*) 'Meridional resolution of model grid too fine.'
+    WRITE(numout,*) 'Resolution of original data (deg): ', yres_file
+    STOP
+  ENDIF
+!-
+! 3. On verifie la coherence des coordonnees de depart et d'arrivee.
+!    Sinon, il faut deplacer une partie du monde (rien que ca).
+!-
+  i_cut = 0
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(lon_temp(iim_file), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of lon_temp : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(lat_temp(jjm_file), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of lat_temp : ",ALLOC_ERR
+    STOP 
+  ENDIF
+!-
+  IF (lon(iim,1) > lon_file(iim_file)) THEN
+!-- A l'Est de la region d'interet, il n'y a pas de donnees
+!-- le bout a l'Ouest de la region d'interet est deplace de 360 deg
+!-- vers l'Est
+    x_cut = lon(1,1)
+    DO i=1,iim_file
+      IF (lon_file(i) < x_cut) i_cut = i
+    ENDDO
+    IF ((i_cut < 1).OR.(i_cut >= iim_file)) THEN
+        STOP 'Cannot find longitude for domain shift'
+    ENDIF
+!---
+    lon_temp(1:iim_file-i_cut-1) = lon_file(i_cut:iim_file)
+    lon_temp(iim_file-i_cut:iim_file) = lon_file(1:i_cut+1)+360.
+    lon_file(:) = lon_temp(:)
+  ELSEIF (lon(1,1) < lon_file(1)) THEN
+!-- A l'Ouest de la region d'interet, il n'y a pas de donnees
+!-- le bout a l'Est de la region d'interet est deplace de 360 deg
+!-- vers l'Ouest
+    x_cut = lon(iim,1)
+    DO i=1,iim_file
+      IF (lon_file(i) < x_cut) i_cut = i
+    ENDDO
+    IF ( ( i_cut < 1 ) .OR. ( i_cut >= iim_file ) ) THEN
+        STOP 'Cannot find longitude for domain shift'
+    ENDIF
+!---
+    lon_temp(1:iim_file-i_cut-1) = lon_file(i_cut:iim_file) -360.
+    lon_temp(iim_file-i_cut:iim_file) = lon_file(1:i_cut+1)
+    lon_file(:) = lon_temp(:)
+  ENDIF
+!-
+  DEALLOCATE (lon_temp)
+  DEALLOCATE (lat_temp)
+!-
+  IF (    (lon(1,1) < lon_file(1)) &
+ &    .OR.(     (lon(iim,1) > lon_file(iim_file)) &
+ &         .AND.(lon(iim,1) > lon_file(1)+360.) ) ) THEN
+    WRITE(numout,*) lon(:,1)
+    WRITE(numout,*)
+    WRITE(numout,*) lon_file(:)
+    STOP 'weathgen_init: cannot find coherent x-coordinates'
+  ENDIF
+!-
+  IF (i_cut /= 0) THEN
+    CALL shift_field (iim_file,jjm_file,i_cut,lsm_file)
+  ENDIF
+!-
+! 4. Verification
+!-
+  WRITE(numout,*)
+  WRITE(numout,*) 'Input File: (Shifted) Global Land-Sea Mask'
+  WRITE(numout,*)
+  maskchar(0) = '-'
+  maskchar(1) = 'X'
+  plotstep = INT(REAL(iim_file-1)/termcol)+1
+  DO j=1,jjm_file,plotstep
+    DO i=1,iim_file,plotstep
+      WRITE(numout,'(a1,$)') maskchar(NINT(lsm_file(i,j)))
+    ENDDO
+    WRITE(numout,*)
+  ENDDO
+  WRITE(numout,*)
+!-
+! 5. Prepare interpolation from fine grid land points to model grid
+!-
+! 5.1 how many grid points of the original grid fall into one grid
+!     box of the model grid?
+!-
+  n_agg = NINT((zonal_res/xres_file*merid_res/yres_file )+1.)
+!-
+! au diable l'avarice !
+!-
+  n_agg = n_agg*2
+!-
+! 5.2 Allocate arrays where we store information about which
+!     (and how many) points on the original grid fall
+!     into which box on the model grid
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(ncorr(iim,jjm), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of ncorr : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(icorr(iim,jjm,n_agg), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of icorr : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(jcorr(iim,jjm,n_agg), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of jcorr : ",ALLOC_ERR
+    STOP 
+  ENDIF
+!-
+! 6. Land-Ocean Mask on model grid
+!-
+  tmp_lon = lon(:,1)
+  tmp_lat = lat(1,:)
+
+  CALL mask_c_o &
+ &  (iim_file, jjm_file, lon_file, lat_file, lsm_file, fcrit, &
+ &   iim, jjm, zonal_res, merid_res, n_agg, tmp_lon, tmp_lat, &
+! &   iim, jjm, zonal_res, merid_res, n_agg, lon(:,1), lat(1,:), &
+ &   mask, ncorr, icorr, jcorr)
+!-
+  WRITE(numout,*) 'Land-Sea Mask on Model Grid'
+  WRITE(numout,*)
+  plotstep = INT(REAL(iim-1)/termcol)+1
+  DO j=1,jjm,plotstep
+    DO i=1,iim,plotstep
+      WRITE(numout,'(a1,$)') maskchar(NINT(mask(i,j)))
+    ENDDO
+    WRITE(numout,*)
+  ENDDO
+  WRITE(numout,*)
+!-
+! 7. kindex table.
+!-
+  nbindex = 0
+  DO j=1,jjm
+    DO i=1,iim
+      IF (NINT(mask(i,j)) == 1) THEN
+        nbindex = nbindex+1
+        kindex(nbindex) = (j-1)*iim+i
+      ENDIF
+    ENDDO
+  ENDDO
+  nbindex_w = nbindex
+  ALLOC_ERR=-1
+  ALLOCATE(kindex_w(nbindex_w), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of kindex_w : ",ALLOC_ERR
+    STOP 
+  ENDIF
+  kindex_w(:)=kindex(1:nbindex)
+!-
+  IF ( nbindex == 0 ) THEN
+    WRITE(numout,*) 'Couillon! On est au plein milieu de l''ocean.'
+    STOP 'Ou est-ce un bug?'
+  ELSE
+    WRITE(numout,*) 'Number of continental points: ',nbindex
+  ENDIF
+
+!-
+! 10. clean up
+!-
+  DEALLOCATE (lon_file)
+  DEALLOCATE (lat_file)
+  DEALLOCATE (lsm_file)
+
+END SUBROUTINE weathgen_init
+
+SUBROUTINE weathgen_read_file &
+     & (force_id,iim,jjm)
+  !---------------------------------------------------------------------
+  IMPLICIT NONE
+  !-
+  INTEGER,INTENT(IN)                  :: force_id
+  INTEGER,INTENT(IN)                  :: iim, jjm
+  !-
+  REAL,PARAMETER  :: fcrit = .5
+
+  CHARACTER(LEN=30)                     :: var_name
+
+  INTEGER,DIMENSION(iim*jjm)  :: kindex
+  INTEGER                     :: nbindex
+
+  REAL,DIMENSION(iim*jjm)     :: xchamp
+  REAL,DIMENSION(iim*jjm,nmon)  :: xchampm
+
+  kindex(:)=0
+
+#ifdef CPP_PARA
+  nbindex=nbp_loc
+  CALL scatter(index_g,kindex)
+  kindex(1:nbindex)=kindex(1:nbindex)-(jj_begin-1)*iim_g
+#else
+  ! Copy saved land points index
+  nbindex = nbindex_w
+  kindex(1:nbindex_w) = kindex_w(:)
+#endif
+
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(lat_land(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of lat_land : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+!-
+! 8 topography
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(xintopo(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of xintopo : ",ALLOC_ERR
+    STOP 
+  ENDIF
+!-
+  var_name='altitude'
+  CALL weather_read (force_id,var_name,iim_file,jjm_file,1,i_cut, &
+                     iim,jjm,n_agg,ncorr,icorr,jcorr,xchamp)
+  xintopo(:)=xchamp(kindex(1:nbindex))
+!-
+! 9. Allocate and read the monthly fields
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(xinwet(nbindex,nmon), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of xinwet : ",ALLOC_ERR
+    STOP 
+  ENDIF
+  var_name='prs'
+  CALL weather_read (force_id,var_name,iim_file,jjm_file,nmon,i_cut, &
+                     iim,jjm,n_agg,ncorr,icorr,jcorr,xchampm)
+  xinwet(:,:)=xchampm(kindex(1:nbindex),:)
+  !-
+
+  ALLOC_ERR=-1
+  ALLOCATE(xinprec(nbindex,nmon), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of xinprec : ",ALLOC_ERR
+    STOP 
+  ENDIF
+  var_name='prm'
+  CALL weather_read (force_id,var_name,iim_file,jjm_file,nmon,i_cut, &
+                     iim,jjm,n_agg,ncorr,icorr,jcorr,xchampm)
+  xinprec(:,:)=xchampm(kindex(1:nbindex),:)
+!-
+  
+  ALLOC_ERR=-1
+  ALLOCATE(xint(nbindex,nmon), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of xint : ",ALLOC_ERR
+    STOP 
+  ENDIF
+  var_name='t2m'
+  CALL weather_read (force_id,var_name,iim_file,jjm_file,nmon,i_cut, &
+                     iim,jjm,n_agg,ncorr,icorr,jcorr,xchampm)
+  xint(:,:)=xchampm(kindex(1:nbindex),:)
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(xinq(nbindex,nmon), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of xinq : ",ALLOC_ERR
+    STOP 
+  ENDIF
+  var_name='r2m'
+  CALL weather_read (force_id,var_name,iim_file,jjm_file,nmon,i_cut, &
+                     iim,jjm,n_agg,ncorr,icorr,jcorr,xchampm)
+  xinq(:,:)=xchampm(kindex(1:nbindex),:)
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(xinwind(nbindex,nmon), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of xinwind : ",ALLOC_ERR
+    STOP 
+  ENDIF
+  var_name='uv10m'
+  CALL weather_read (force_id,var_name,iim_file,jjm_file,nmon,i_cut, &
+                     iim,jjm,n_agg,ncorr,icorr,jcorr,xchampm)
+  xinwind(:,:)=xchampm(kindex(1:nbindex),:)
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(xincld(nbindex,nmon), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of xincld : ",ALLOC_ERR
+    STOP 
+  ENDIF
+  var_name='tc'
+  CALL weather_read (force_id,var_name,iim_file,jjm_file,nmon,i_cut, &
+                       iim,jjm,n_agg,ncorr,icorr,jcorr,xchampm)
+  xincld(:,:)=xchampm(kindex(1:nbindex),:)
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(xintrng(nbindex,nmon), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of xintrng : ",ALLOC_ERR
+    STOP 
+  ENDIF
+  var_name='t2a'
+  CALL weather_read (force_id,var_name,iim_file,jjm_file,nmon,i_cut, &
+                       iim,jjm,n_agg,ncorr,icorr,jcorr,xchampm)
+  xintrng(:,:)=xchampm(kindex(1:nbindex),:)
+!-
+! 10. clean up
+!-
+  IF (is_root_prc) THEN
+     DEALLOCATE (ncorr)
+     DEALLOCATE (icorr)
+     DEALLOCATE (jcorr)
+  ENDIF
+
+!-
+! 12. Allocate space for daily mean values
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(iwet(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of iwet : ",ALLOC_ERR
+    STOP 
+  ENDIF
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(psurfm0(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of psurfm0 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(cloudm0(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of cloudm0 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(tmaxm0(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of tmaxm0 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(tminm0(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of tminm0 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(qdm0(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of qdm0 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(udm0(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of udm0 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(precipm0(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of precipm0 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(psurfm1(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of psurfm1 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(cloudm1(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of cloudm1 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(tmaxm1(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of tmaxm1 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(tminm1(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of tminm1 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(qdm1(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of qdm1 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(udm1(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of udm1 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(precipm1(nbindex), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of precipm1 : ",ALLOC_ERR
+    STOP 
+  ENDIF
+END SUBROUTINE weathgen_read_file
+
+SUBROUTINE weathgen_begin ( &
+     & dt_force,itau, date0, &
+     & rest_id,iim,jjm, &
+     & lon,lat,tair,pb,qair,kindex,nbindex)
+  !---------------------------------------------------------------------
+  IMPLICIT NONE
+
+  !-
+  REAL,INTENT(IN)                     :: dt_force, date0
+  INTEGER,INTENT(IN)                  :: itau
+  INTEGER,INTENT(IN)                  :: rest_id
+  INTEGER,INTENT(IN)                  :: iim, jjm
+  REAL,DIMENSION(iim,jjm),INTENT(IN)  :: lon,lat
+  INTEGER,DIMENSION(iim*jjm),INTENT(OUT)  :: kindex
+  INTEGER,INTENT(OUT)                     :: nbindex
+  !-
+  REAL,DIMENSION(iim,jjm),INTENT(OUT)     :: tair,pb,qair
+  INTEGER  :: i, j, ij
+  REAL     :: val_exp
+  REAL,DIMENSION(iim*jjm)               :: xchamp
+  REAL,DIMENSION(iim_g*jjm_g)           :: xchamp_g
+  CHARACTER(LEN=30)                     :: var_name
+  REAL,DIMENSION(1)                     :: jullasttab
+  REAL,DIMENSION(seedsize_max)          :: seed_in_file
+  INTEGER,DIMENSION(:), ALLOCATABLE     :: seed_in_proc
+  INTEGER  :: seedsize, iret
+  INTEGER  :: nlonid, nlatid, nlonid1, nlatid1, tdimid1, varid
+  INTEGER  :: ndim, dims(4)
+  CHARACTER(LEN=30) :: assoc
+  CHARACTER(LEN=70) :: str70
+  CHARACTER(LEN=80) :: stamp
+  INTEGER  :: yy_b, mm_b, dd_b, hh, mm
+  REAL     :: ss
+  CHARACTER(LEN=10) :: today, att
+  INTEGER  :: nlandid1, nlandid, nlevid, nlevid1
+  REAL     :: lev_max, lev_min
+  REAL     :: height_lev1
+  INTEGER  :: imois
+  REAL     :: xx, td
+
+  kindex(:)=0
+
+#ifdef CPP_PARA
+  nbindex=nbp_loc
+  CALL scatter(index_g,kindex)
+  kindex(1:nbindex)=kindex(1:nbindex)-(jj_begin-1)*iim_g
+#else
+  ! Copy saved land points index
+  nbindex = nbindex_w
+  kindex(1:nbindex_w) = kindex_w(:)
+#endif
+!-
+! 13. Prescribed or statistical values?
+!-
+  !Config  Key  = IPPREC
+  !Config  Desc = Use prescribed values
+  !Config  If = ALLOW_WEATHERGEN
+  !Config  Def  = 0
+  !Config  Help = If this is set to 1, the weather generator
+  !Config         uses the monthly mean values for daily means.
+  !Config         If it is set to 0, the weather generator
+  !Config         uses statistical relationships to derive daily
+  !Config         values from monthly means.
+  ipprec = 0
+  CALL getin_p ('IPPREC',ipprec)
+  WRITE(numout,*) 'IPPREC: ',ipprec
+!-
+! 14. Do we want exact monthly precipitations even with ipprec=0 ?
+!-
+  !Config  Key  = WEATHGEN_PRECIP_EXACT
+  !Config  Desc = Exact monthly precipitation
+  !Config  If = ALLOW_WEATHERGEN
+  !Config  Def  = n
+  !Config  Help = If this is set to y, the weather generator
+  !Config         will generate pseudo-random precipitations
+  !Config         whose monthly mean is exactly the prescribed one.
+  !Config         In this case, the daily precipitation (for rainy
+  !Config         days) is constant (that is, some days have 0 precip,
+  !Config         the other days have precip=Precip_month/n_precip,
+  !Config         where n_precip is the prescribed number of rainy days
+  !Config         per month).
+  precip_exact = .FALSE.
+  CALL getin_p ('WEATHGEN_PRECIP_EXACT',precip_exact)
+  WRITE(numout,*) 'PRECIP_EXACT: ',precip_exact
+!-
+  IF (precip_exact) THEN
+!---
+!-- preparer un tableau utilise pour determiner s'il pleut ou pas
+!-- (en fct. du nombre de jours de pluie par mois).
+!---
+     IF (is_root_prc) THEN
+        DO imois=1,12
+           CALL permute (ndaypm(imois),jour_precip(:,imois))
+        ENDDO
+     ENDIF
+     CALL bcast(jour_precip)
+  ENDIF
+!-
+! Read Orbital Parameters
+!-
+  !Config  Key  = ECCENTRICITY
+  !Config  Desc = Use prescribed values
+  !Config  If = ALLOW_WEATHERGEN
+  !Config  Def  = 0.016724
+  ecc = 0.016724
+  CALL getin_p ('ECCENTRICITY',ecc)
+  WRITE(numout,*) 'ECCENTRICITY: ',ecc
+!
+  !Config  Key  = PERIHELIE
+  !Config  Desc = Use prescribed values
+  !Config  If = ALLOW_WEATHERGEN
+  !Config  Def  = 102.04
+  perh = 102.04
+  CALL getin_p ('PERIHELIE',perh)
+  WRITE(numout,*) 'PERIHELIE: ',perh
+!
+  !Config  Key  = OBLIQUITY
+  !Config  Desc = Use prescribed values
+  !Config  If = ALLOW_WEATHERGEN
+  !Config  Def  = 23.446
+  xob = 23.446
+  CALL getin_p ('OBLIQUITY',xob)
+  WRITE(numout,*) 'OBLIQUITY: ',xob
+!-
+! 15. Read restart file
+!-
+  CALL ioget_expval (val_exp)
+!-
+  var_name= 'julian'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id,var_name,1,1,1,itau,.TRUE.,jullasttab)
+     IF (jullasttab(1) == val_exp) THEN
+        jullasttab(1) = itau2date(itau-1, date0, dt_force)
+     ENDIF
+  ENDIF
+  CALL bcast(jullasttab)
+  julian_last = jullasttab(1)
+!-
+  var_name= 'seed'
+  IF (is_root_prc) &
+       CALL restget (rest_id,var_name,seedsize_max, &
+ &              1,1,itau,.TRUE.,seed_in_file)
+  CALL bcast(seed_in_file)
+  IF (ALL(seed_in_file(:) == val_exp)) THEN
+!---
+!-- there is no need to reinitialize the random number generator as
+!-- this does not seem to be a restart
+!---
+    CONTINUE
+  ELSE
+!---
+!-- reinitialize the random number generator
+!---
+     IF (is_root_prc) &
+          CALL RANDOM_SEED( SIZE = seedsize )
+     CALL bcast(seedsize)
+    IF (seedsize > seedsize_max) THEN
+        STOP 'weathgen_begin: increase seedsize_max'
+    ENDIF
+  
+    ALLOC_ERR=-1
+    ALLOCATE(seed_in_proc(seedsize), STAT=ALLOC_ERR)
+    IF (ALLOC_ERR/=0) THEN
+      WRITE(numout,*) "ERROR IN ALLOCATION of seed_in_proc : ",ALLOC_ERR
+      STOP 
+    ENDIF
+    seed_in_proc(1:seedsize) = NINT( seed_in_file(1:seedsize) )
+    CALL RANDOM_SEED (PUT = seed_in_proc)
+    DEALLOCATE( seed_in_proc )
+  ENDIF
+!-
+  var_name= 'iwet'
+  IF (is_root_prc) THEN
+    CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+    IF (ALL(xchamp_g(:) == val_exp)) THEN
+      xchamp_g(:) = 0.
+    ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  iwet(:) = NINT(xchamp(kindex(1:nbindex)))
+!-
+  var_name= 'psurfm0'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 100000.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  psurfm0(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'cloudm0'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = .5
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  cloudm0(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'tmaxm0'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 285.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  tmaxm0(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'tminm0'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 275.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  tminm0(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'qdm0'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 1.E-03
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  qdm0(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'udm0'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 2.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  udm0(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'precipm0'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 1.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  precipm0(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'psurfm1'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 100000.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  psurfm1(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'cloudm1'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = .5
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  cloudm1(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'tmaxm1'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 285.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  tmaxm1(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'tminm1'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 275.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  tminm1(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'qdm1'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 1.E-03
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  qdm1(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'udm1'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 2.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  udm1(:) = xchamp(kindex(1:nbindex))
+!-
+  var_name= 'precipm1'
+  IF (is_root_prc) THEN
+     CALL restget (rest_id, var_name, iim_g, jjm_g, 1, itau, .TRUE., xchamp_g)
+     IF (ALL(xchamp_g(:) == val_exp)) THEN
+        xchamp_g(:) = 1.
+     ENDIF
+  ENDIF
+  CALL scatter2D(xchamp_g,xchamp)
+  precipm1(:) = xchamp(kindex(1:nbindex))
+!-
+! 16. We still need instantaneous tair, qair, and the surface pressure
+!     We take daily mean values read from the restart file
+!-
+!!$  tair(:,:)=280.
+!!$  qair(:,:)=1.E-03
+!!$  pb(:,:)=101325
+  tair(:,:)=val_exp
+  qair(:,:)=val_exp
+  pb(:,:)=val_exp
+  xx = 9.81/287./0.0065
+  DO ij=1,nbindex
+     j = ((kindex(ij)-1)/iim) + 1
+     i = kindex(ij) - (j-1)*iim
+     
+     lat_land(ij) = lat(i,j)
+     
+     td =  (tmaxm0(ij)+tminm0(ij))/2.
+     tair(i,j) = td
+     qair(i,j) = qdm1(ij)
+     pb(i,j) = 101325.*(td/(td+0.0065*xintopo(ij)))**xx
+  ENDDO
+!-
+! 17. We can write a forcing file for Orchidee
+!     from this weather Generator run.
+!-
+  !Config  Key  = DUMP_WEATHER
+  !Config  Desc = Write weather from generator into a forcing file
+  !Config  Def  = n
+  !Config  Help = This flag makes the weather generator dump its
+  !               generated weather into a forcing file which can
+  !               then be used to get the same forcing on different
+  !               machines. This only works correctly if there is
+  !               a restart file (otherwise the forcing at the first
+  !               time step is slightly wrong).
+  dump_weather = .FALSE.
+  CALL getin_p ('DUMP_WEATHER',dump_weather)
+!-
+  IF (dump_weather .AND. is_root_prc) THEN
+!---
+!-- Initialize the file
+!---
+    !Config  Key  = DUMP_WEATHER_FILE
+    !Config  Desc = Name of the file that contains
+    !               the weather from generator
+    !Config  Def  = 'weather_dump.nc'
+    !Config  If = DUMP_WEATHER
+    !Config  Help =
+    dump_weather_file = 'weather_dump.nc'
+    CALL getin ('DUMP_WEATHER_FILE',dump_weather_file)
+!---
+    !Config  Key  = DUMP_WEATHER_GATHERED
+    !Config  Desc = Dump weather data on gathered grid
+    !Config  Def  = y
+    !Config  If = DUMP_WEATHER
+    !Config  Help = If 'y', the weather data are gathered
+    !               for all land points.
+    gathered = .TRUE.
+    CALL getin ('DUMP_WEATHER_GATHERED',gathered)
+!---
+    iret = NF90_CREATE (TRIM(dump_weather_file),NF90_CLOBBER,dump_id)
+!---
+!-- Dimensions
+!---
+    iret = NF90_DEF_DIM (dump_id,'x',iim_g,nlonid1)
+    iret = NF90_DEF_DIM (dump_id,'y',jjm_g,nlatid1)
+    iret = NF90_DEF_DIM (dump_id,'z',  1,nlevid1)
+!---
+    IF (gathered) THEN
+      iret = NF90_DEF_DIM (dump_id,'land',nbp_glo,nlandid1)
+    ENDIF
+    iret = NF90_DEF_DIM (dump_id,'tstep',NF90_UNLIMITED,tdimid1)
+!---
+!-- Coordinate variables
+!---
+    dims(1:2) = (/ nlonid1, nlatid1 /)
+!---
+    iret = NF90_DEF_VAR (dump_id,'nav_lon',n_rtp,dims(1:2),nlonid)
+    iret = NF90_PUT_ATT (dump_id,nlonid,'units',"degrees_east")
+    iret = NF90_PUT_ATT (dump_id,nlonid,'valid_min',MINVAL(lon_g))
+    iret = NF90_PUT_ATT (dump_id,nlonid,'valid_max',MAXVAL(lon_g))
+    iret = NF90_PUT_ATT (dump_id,nlonid,'long_name',"Longitude")
+!---
+    iret = NF90_DEF_VAR (dump_id,'nav_lat',n_rtp,dims(1:2),nlatid)
+    iret = NF90_PUT_ATT (dump_id,nlatid,'units',"degrees_north")
+    iret = NF90_PUT_ATT (dump_id,nlatid,'valid_min',MINVAL(lat_g))
+    iret = NF90_PUT_ATT (dump_id,nlatid,'valid_max',MAXVAL(lat_g))
+    iret = NF90_PUT_ATT (dump_id,nlatid,'long_name',"Latitude")
+!---
+    height_lev1 = 10.
+    CALL getin ('HEIGHT_LEV1',height_lev1)
+    lev_min = height_lev1
+    lev_max = height_lev1
+!---
+    iret = NF90_DEF_VAR (dump_id,'level',n_rtp,(/ nlevid1 /),nlevid)
+    iret = NF90_PUT_ATT (dump_id,nlevid,'units',"m")
+    iret = NF90_PUT_ATT (dump_id,nlevid,'valid_min',lev_min)
+    iret = NF90_PUT_ATT (dump_id,nlevid,'valid_max',lev_max)
+    iret = NF90_PUT_ATT (dump_id,nlevid,'long_name',"Vertical levels")
+!---
+    IF (gathered) THEN
+      iret = NF90_DEF_VAR (dump_id,'land',NF90_INT,(/ nlandid1 /),nlandid)
+      iret = NF90_PUT_ATT (dump_id,nlandid,'compress',"y x")
+    ENDIF
+!---
+!-- Store the time axes.
+!---
+    iret = NF90_DEF_VAR (dump_id,'time',n_rtp,tdimid1,time_id)
+
+    yy_b=0
+    mm_b=1
+    dd_b=1
+    hh=00
+    mm=00
+    ss=0.
+
+    WRITE (str70,7000) yy_b, mm_b, dd_b, hh, mm, INT(ss)
+    iret = NF90_PUT_ATT (dump_id,time_id,'units',TRIM(str70))
+    iret = NF90_PUT_ATT (dump_id,time_id,'calendar',TRIM(calendar_str))
+    iret = NF90_PUT_ATT (dump_id,time_id,'title','Time')
+    iret = NF90_PUT_ATT (dump_id,time_id,'long_name','Time axis')
+    WRITE(str70,7001) yy_b, cal(mm_b), dd_b, hh, mm, INT(ss)
+    iret = NF90_PUT_ATT (dump_id,time_id,'time_origin',TRIM(str70))
+!---
+!-- Time steps
+!---
+    iret = NF90_DEF_VAR (dump_id,'timestp',NF90_INT,tdimid1,timestp_id)
+    WRITE(str70,7002) yy_b, mm_b, dd_b, hh, mm, INT(ss)
+    iret = NF90_PUT_ATT (dump_id,timestp_id,'units',TRIM(str70))
+    iret = NF90_PUT_ATT (dump_id,timestp_id,'title','Time steps')
+    iret = NF90_PUT_ATT (dump_id,timestp_id,'tstep_sec',dt_force)
+    iret = NF90_PUT_ATT &
+ &           (dump_id,timestp_id,'long_name','Time step axis')
+    WRITE(str70,7001) yy_b, cal(mm_b), dd_b, hh, mm, INT(ss)
+    iret = NF90_PUT_ATT (dump_id,timestp_id,'time_origin',TRIM(str70))
+!---
+7000 FORMAT('seconds since ',I4.4,'-',I2.2,'-',I2.2,' ',I2.2,':',I2.2,':',I2.2)
+7001 FORMAT(' ',I4.4,'-',A3,'-',I2.2,' ',I2.2,':',I2.2,':',I2.2)
+7002 FORMAT('timesteps since ', I4.4,'-',I2.2,'-',I2.2,' ',I2.2,':',I2.2,':',I2.2)
+!---
+!-- The variables in the file are declared and their attributes
+!-- written.
+!---
+    IF (gathered) THEN
+      ndim = 2
+      dims(1:2) = (/ nlandid1, tdimid1 /)
+      assoc = 'time (nav_lat nav_lon)'
+    ELSE
+      ndim = 3
+      dims(1:3) = (/ nlonid1, nlatid1, tdimid1 /)
+      assoc = 'time nav_lat nav_lon'
+    ENDIF
+!---
+    iret = NF90_DEF_VAR (dump_id,'SWdown',n_rtp,dims(1:ndim),varid)
+    iret = NF90_PUT_ATT (dump_id,varid,'axis','TYX')
+    iret = NF90_PUT_ATT (dump_id,varid,'units','W/m^2')
+    iret = NF90_PUT_ATT (dump_id,varid,'long_name', &
+ &                       'Surface incident shortwave radiation')
+    iret = NF90_PUT_ATT (dump_id,varid,'associate',TRIM(assoc))
+    iret = NF90_PUT_ATT (dump_id,varid,'missing_value',undef)
+    soldownid = varid
+!---
+    iret = NF90_DEF_VAR (dump_id,'Rainf',n_rtp,dims(1:ndim),varid)
+    iret = NF90_PUT_ATT (dump_id,varid,'axis','TYX')
+    iret = NF90_PUT_ATT (dump_id,varid,'units','kg/m^2s')
+    iret = NF90_PUT_ATT (dump_id,varid,'long_name', &
+ &                       'Rainfall rate')
+    iret = NF90_PUT_ATT (dump_id,varid,'associate',TRIM(assoc))
+    iret = NF90_PUT_ATT (dump_id,varid,'missing_value',undef)
+    rainfid = varid
+!---
+    iret = NF90_DEF_VAR (dump_id,'Snowf',n_rtp,dims(1:ndim),varid)
+    iret = NF90_PUT_ATT (dump_id,varid,'axis','TYX')
+    iret = NF90_PUT_ATT (dump_id,varid,'units','kg/m^2s')
+    iret = NF90_PUT_ATT (dump_id,varid,'long_name', &
+ &                       'Snowfall rate')
+    iret = NF90_PUT_ATT (dump_id,varid,'associate',TRIM(assoc))
+    iret = NF90_PUT_ATT (dump_id,varid,'missing_value',undef)
+    snowfid = varid
+!---
+    iret = NF90_DEF_VAR (dump_id,'LWdown',n_rtp,dims(1:ndim),varid)
+    iret = NF90_PUT_ATT (dump_id,varid,'axis','TYX')
+    iret = NF90_PUT_ATT (dump_id,varid,'units','W/m^2')
+    iret = NF90_PUT_ATT (dump_id,varid,'long_name', &
+ &                       'Surface incident longwave radiation')
+    iret = NF90_PUT_ATT (dump_id,varid,'associate',TRIM(assoc))
+    iret = NF90_PUT_ATT (dump_id,varid,'missing_value',undef)
+    lwradid = varid
+!---
+    iret = NF90_DEF_VAR (dump_id,'PSurf',n_rtp,dims(1:ndim),varid)
+    iret = NF90_PUT_ATT (dump_id,varid,'axis','TYX')
+    iret = NF90_PUT_ATT (dump_id,varid,'units','Pa')
+    iret = NF90_PUT_ATT (dump_id,varid,'long_name', &
+ &                       'Surface pressure')
+    iret = NF90_PUT_ATT (dump_id,varid,'associate',TRIM(assoc))
+    iret = NF90_PUT_ATT (dump_id,varid,'missing_value',undef)
+    psolid = varid
+!---
+!-- 3D Variables to be written
+!---
+    IF (gathered) THEN
+      ndim = 3
+      dims(1:3) = (/ nlandid1, nlevid1, tdimid1 /)
+      assoc = 'time level (nav_lat nav_lon)'
+    ELSE
+      ndim = 4
+      dims(1:4) = (/ nlonid1, nlatid1, nlevid1, tdimid1 /)
+      assoc = 'time level nav_lat nav_lon'
+    ENDIF
+!---
+    iret = NF90_DEF_VAR (dump_id,'Tair',n_rtp,dims(1:ndim),varid)
+    iret = NF90_PUT_ATT (dump_id,varid,'axis','TZYX')
+    iret = NF90_PUT_ATT (dump_id,varid,'units','K')
+    iret = NF90_PUT_ATT (dump_id,varid,'long_name', &
+ &                       'Near surface air temperature')
+    iret = NF90_PUT_ATT (dump_id,varid,'associate',TRIM(assoc))
+    iret = NF90_PUT_ATT (dump_id,varid,'missing_value',undef)
+    tairid = varid
+!---
+    iret = NF90_DEF_VAR (dump_id,'Qair',n_rtp,dims(1:ndim),varid)
+    iret = NF90_PUT_ATT (dump_id,varid,'axis','TZYX')
+    iret = NF90_PUT_ATT (dump_id,varid,'units','kg/kg')
+    iret = NF90_PUT_ATT (dump_id,varid,'long_name', &
+ &                       'Near surface specific humidity')
+    iret = NF90_PUT_ATT (dump_id,varid,'associate',TRIM(assoc))
+    iret = NF90_PUT_ATT (dump_id,varid,'missing_value',undef)
+    qairid = varid
+!---
+    iret = NF90_DEF_VAR (dump_id,'Wind_N',n_rtp,dims(1:ndim),varid)
+    iret = NF90_PUT_ATT (dump_id,varid,'axis','TZYX')
+    iret = NF90_PUT_ATT (dump_id,varid,'units','m/s')
+    iret = NF90_PUT_ATT (dump_id,varid,'long_name', &
+ &                       'Near surface northward wind component')
+    iret = NF90_PUT_ATT (dump_id,varid,'associate',TRIM(assoc))
+    iret = NF90_PUT_ATT (dump_id,varid,'missing_value',undef)
+    uid = varid
+!---
+    iret = NF90_DEF_VAR (dump_id,'Wind_E',n_rtp,dims(1:ndim),varid)
+    iret = NF90_PUT_ATT (dump_id,varid,'axis','TZYX')
+    iret = NF90_PUT_ATT (dump_id,varid,'units','m/s')
+    iret = NF90_PUT_ATT (dump_id,varid,'long_name', &
+ &                       'Near surface eastward wind component')
+    iret = NF90_PUT_ATT (dump_id,varid,'associate',TRIM(assoc))
+    iret = NF90_PUT_ATT (dump_id,varid,'missing_value',undef)
+    vid = varid
+!---
+!-- Global attributes
+!---
+    CALL DATE_AND_TIME (today, att)
+    stamp = "WG, date: "//TRIM(today)//" at "//TRIM(att)
+    iret = NF90_PUT_ATT (dump_id,NF90_GLOBAL,'Conventions',"GDT 1.2")
+    iret = NF90_PUT_ATT (dump_id,NF90_GLOBAL,'file_name', &
+ &                       TRIM(dump_weather_file))
+    iret = NF90_PUT_ATT (dump_id,NF90_GLOBAL,'production',TRIM(stamp))
+!---
+!-- Finish the definition phase
+!---
+    iret = NF90_ENDDEF (dump_id)
+!---
+!--    Write coordinates
+!---
+    iret = NF90_PUT_VAR (dump_id,nlonid,lon_g)
+    IF (iret /= NF90_NOERR) THEN
+       WRITE(numout,*) iret
+       CALL ipslerr (3,'weathgen_begin', &
+ &          'Could not put variable nav_lon in the file : ', &
+ &          TRIM(dump_weather_file),'(Solution ?)')
+    ENDIF
+    iret = NF90_PUT_VAR (dump_id,nlatid,lat_g)
+    IF (iret /= NF90_NOERR) THEN
+       WRITE(numout,*) iret
+       CALL ipslerr (3,'weathgen_begin', &
+ &          'Could not put variable nav_lat in the file : ', &
+ &          TRIM(dump_weather_file),'(Solution ?)')
+    ENDIF
+    iret = NF90_PUT_VAR (dump_id,nlevid,height_lev1)
+    IF (iret /= NF90_NOERR) THEN
+       WRITE(numout,*) iret
+       CALL ipslerr (3,'weathgen_begin', &
+ &          'Could not put variable level in the file : ', &
+ &          TRIM(dump_weather_file),'(Solution ?)')
+    ENDIF
+!---
+    IF (gathered) THEN
+       iret = NF90_PUT_VAR (dump_id,nlandid,index_g(1:nbp_glo))
+       IF (iret /= NF90_NOERR) THEN
+          WRITE(numout,*) iret
+          CALL ipslerr (3,'weathgen_begin', &
+ &          'Could not put variable land in the file : ', &
+ &          TRIM(dump_weather_file),'(Solution ?)')
+       ENDIF
+    ENDIF
+!---
+ ENDIF ! dump_weather
+!-----------------------------
+END SUBROUTINE weathgen_begin
+!-
+!===
+!-
+SUBROUTINE weathgen_get &
+& (itau, date0, dt_force, nbindex, nband, lat, &
+&  swdown, raina, snowa, tair, u, v, qair, psurf, lwdown)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+! number of time step
+  INTEGER,INTENT(IN)               :: itau
+! date when itau was 0
+  REAL,INTENT(IN)                  :: date0
+! time step (s)
+  REAL,INTENT(IN)                  :: dt_force
+! number of land points
+  INTEGER,INTENT(IN)               :: nbindex
+! number of visible bands
+  INTEGER,INTENT(IN)               :: nband
+! latitude (deg)
+  REAL,DIMENSION(nbindex),INTENT(IN)  :: lat
+!-
+  REAL,DIMENSION(nbindex,nband),INTENT(OUT) :: swdown
+  REAL,DIMENSION(nbindex),INTENT(OUT)       :: raina, snowa
+  REAL,DIMENSION(nbindex),INTENT(OUT)       :: tair
+  REAL,DIMENSION(nbindex),INTENT(OUT)       :: u,v
+  REAL,DIMENSION(nbindex),INTENT(OUT)       :: qair
+  REAL,DIMENSION(nbindex),INTENT(OUT)       :: psurf
+  REAL,DIMENSION(nbindex),INTENT(OUT)       :: lwdown
+!-
+  REAL,DIMENSION(nbindex)        :: cloud, tmax, tmin, precipd, qd, ud
+  REAL,DIMENSION(nbindex)        :: rh
+  REAL,DIMENSION(nbindex,nband)  :: solai, solad
+  REAL                        :: julian, jur
+  REAL                        :: x
+  INTEGER                     :: yy, mm, dd
+  REAL                        :: ss, plens, time
+!---------------------------------------------------------------------
+!-
+! 1. get a reduced julian day
+!-
+  julian = itau2date(itau-1, date0, dt_force)
+!SZ, test: solar noon at 12 o'clock!
+!  julian = itau2date(itau, date0, dt_force)
+  CALL ju2ymds (julian, yy, mm, dd, ss)
+  CALL ymds2ju (yy,1,1,0.0, jur)
+  julian = julian-jur
+  CALL ju2ymds (julian, yy, mm, dd, ss)
+!-
+! 2. daily values
+!-
+  IF (INT(julian_last) /= INT(julian)) THEN
+!-- today's values become yesterday's values
+    cloudm1(:) = cloudm0(:)
+    tmaxm1(:) = tmaxm0(:)
+    tminm1(:) = tminm0(:)
+    precipm1(:) = precipm0(:)
+    qdm1(:) = qdm0(:)
+    udm1(:) = udm0(:)
+    psurfm1(:) = psurfm0(:)
+!-- we have to get new daily values
+!!$    WRITE(*,*) mpi_rank, "weathgen_get : date ",yy, mm, dd, ss
+!!$    WRITE(*,*) mpi_rank, "weathgen_get : grid date ",year, month, day, sec
+    CALL daily (nbindex, mm, dd, cloudm0, tmaxm0, tminm0, &
+ &              precipm0, qdm0, udm0, psurfm0)
+  ENDIF
+!-
+! 3. interpolate daily values
+!    (otherwise we get ugly temperature jumps at midnight)
+!-
+  x = (julian-INT(julian))
+!-
+  cloud(:) = (1.-x)*cloudm1(:)+x*cloudm0(:)
+  tmax(:) = (1.-x)*tmaxm1(:)+x*tmaxm0(:)
+  tmin(:) = (1.-x)*tminm1(:)+x*tminm0(:)
+  precipd(:) = (1.-x)*precipm1(:)+x*precipm0(:)
+  qd(:) = (1.-x)*qdm1(:)+x*qdm0(:)
+  ud(:) = (1.-x)*udm1(:)+x*udm0(:)
+  psurf(:) = (1.-x)*psurfm1(:)+x*psurfm0(:)
+!-
+! 4. read instantaneous values
+!-
+  plens = one_day/dt_force
+  time = (julian-REAL(INT(julian)))*one_day
+!-
+  CALL diurnal (nbindex, nband, time, NINT(julian), plens, 0., one_day, &
+ &              lat, cloud, tmax, tmin, precipd, qd, ud, psurf, &
+ &              lwdown, solad, solai, u, tair, qair, raina, snowa, rh)
+!-
+  raina(:) = raina(:)/dt_force
+  snowa(:) = snowa(:)/dt_force
+!-
+  swdown(:,:) = solad(:,:)+solai(:,:)
+!-
+  v(:) = 0.
+!-
+! 5. Store date
+!-
+  julian_last = julian
+!--------------------------
+END SUBROUTINE weathgen_get
+!-
+!===
+!-
+SUBROUTINE weathgen_restwrite (rest_id,itau,iim,jjm,nbindex,kindex)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(IN)  :: rest_id,itau,iim,jjm,nbindex
+  INTEGER,DIMENSION(iim*jjm),INTENT(IN) :: kindex
+!-
+  CHARACTER(LEN=30)                 :: var_name
+  INTEGER                           :: i,j,ij
+  REAL,DIMENSION(1)                 :: jullasttab
+  REAL,DIMENSION(seedsize_max)      :: seed_in_file
+  INTEGER,DIMENSION(:),ALLOCATABLE  :: seed_in_proc
+  INTEGER                           :: seedsize
+  REAL                              :: rndnum
+  REAL,DIMENSION(iim*jjm)           :: xchamp
+  REAL,DIMENSION(iim_g*jjm_g)       :: xchamp_g
+!---------------------------------------------------------------------
+  var_name= 'julian'
+  jullasttab(:) = julian_last
+  IF (is_root_prc) CALL restput (rest_id, var_name, 1, 1, 1, itau, jullasttab)
+!-
+  IF (is_root_prc) THEN
+     CALL RANDOM_SEED( SIZE = seedsize )
+     IF (seedsize > seedsize_max) THEN
+        STOP 'weathgen_restwrite: increase seedsize_max'
+     ENDIF
+  ENDIF
+  CALL bcast(seedsize)
+
+  IF (is_root_prc) THEN
+     ALLOC_ERR=-1
+     ALLOCATE(seed_in_proc(seedsize), STAT=ALLOC_ERR)
+     IF (ALLOC_ERR/=0) THEN
+        WRITE(numout,*) "ERROR IN ALLOCATION of seed_in_proc : ",ALLOC_ERR
+        STOP 
+     ENDIF
+!-
+     CALL RANDOM_SEED (GET = seed_in_proc)
+!-
+     seed_in_file(1:seedsize) = REAL(seed_in_proc(1:seedsize))
+!-
+! fill in the seed up to seedsize_max
+! (useful in the case we restart on
+!  a machine with a longer seed vector:
+!  we do not want a degenerated seed)
+!-
+     DO i=seedsize+1,seedsize_max
+        CALL RANDOM_NUMBER( rndnum )
+        seed_in_file(i) = 100000.*rndnum
+     ENDDO
+  ENDIF
+  CALL bcast (seed_in_file)
+!-
+  IF (is_root_prc) THEN
+     DEALLOCATE( seed_in_proc )
+!-
+     var_name= 'seed'
+     CALL restput (rest_id,var_name,seedsize_max,1,1,itau,seed_in_file)
+  ENDIF
+!-
+
+  xchamp(:) = val_exp
+  
+!!$  DO j=1,jjm
+!!$    DO i=1,iim
+!!$      ij = (j-1)*iim+i
+!!$      xchamp(i,j) = REAL(iwet(ij))
+!!$    ENDDO
+!!$  ENDDO
+  DO ij=1,nbindex
+     xchamp(kindex(ij)) = REAL(iwet(ij))
+  ENDDO
+  var_name= 'iwet'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = psurfm0(ij)
+  ENDDO
+  var_name= 'psurfm0'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = cloudm0(ij)
+  ENDDO
+  var_name= 'cloudm0'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = tmaxm0(ij)
+  ENDDO
+  var_name= 'tmaxm0'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = tminm0(ij)
+  ENDDO
+  var_name= 'tminm0'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = qdm0(ij)
+  ENDDO
+  var_name= 'qdm0'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = udm0(ij)
+  ENDDO
+  var_name= 'udm0'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = precipm0(ij)
+  ENDDO
+  var_name= 'precipm0'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = psurfm1(ij)
+  ENDDO
+  var_name= 'psurfm1'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = cloudm1(ij)
+  ENDDO
+  var_name= 'cloudm1'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = tmaxm1(ij)
+  ENDDO
+  var_name= 'tmaxm1'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = tminm1(ij)
+  ENDDO
+  var_name= 'tminm1'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = qdm1(ij)
+  ENDDO
+  var_name= 'qdm1'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = udm1(ij)
+  ENDDO
+  var_name= 'udm1'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!-
+  DO ij=1,nbindex
+    xchamp(kindex(ij)) = precipm1(ij)
+  ENDDO
+  var_name= 'precipm1'
+  CALL gather2D(xchamp,xchamp_g)
+  IF (is_root_prc) THEN
+     CALL restput (rest_id, var_name, iim_g, jjm_g, 1, itau, xchamp_g)
+  ENDIF
+!--------------------------------
+END SUBROUTINE weathgen_restwrite
+!-
+!===
+!-
+SUBROUTINE weather_read &
+& (force_id,nomvar,iim_file,jjm_file,n3,i_cut, &
+&  iim,jjm,n_agg,ncorr,icorr,jcorr,champout)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(IN)                          :: force_id
+  CHARACTER(LEN=*),INTENT(IN)                 :: nomvar
+  INTEGER,INTENT(IN)                          :: iim_file,jjm_file
+  INTEGER,INTENT(IN)                          :: n3
+  INTEGER,INTENT(IN)                          :: i_cut
+  INTEGER,INTENT(IN)                          :: iim,jjm
+  INTEGER,INTENT(IN)                          :: n_agg
+  INTEGER,DIMENSION(:,:),INTENT(IN)       :: ncorr
+  INTEGER,DIMENSION(:,:,:),INTENT(IN) :: icorr,jcorr
+!-
+  REAL,DIMENSION(iim*jjm,n3),INTENT(OUT)      :: champout
+!-
+  REAL,DIMENSION(iim_file,jjm_file,n3)        :: champ_file
+  REAL,ALLOCATABLE,DIMENSION(:,:)             :: champout_g
+  INTEGER                                     :: i,j,ij,l,m
+!---------------------------------------------------------------------
+  WRITE(numout,*) 'Lecture ',TRIM(nomvar)
+!-
+  IF (is_root_prc) THEN
+     ALLOCATE(champout_g(iim_g*jjm_g,n3))
+     IF ( n3 == 1 ) THEN
+        CALL flinget (force_id,nomvar(1:LEN_TRIM(nomvar)), &
+             &                iim_file, jjm_file, 0, 0,  1, 1, champ_file)
+     ELSE
+        DO l=1,n3
+           CALL flinget &
+                &      (force_id,nomvar(1:LEN_TRIM(nomvar)), &
+                &       iim_file, jjm_file, 0, n3,  l, l, champ_file(:,:,l))
+        ENDDO
+     ENDIF
+     ! shift if necessary
+     IF (i_cut /= 0) THEN
+        DO l=1,n3
+           CALL shift_field (iim_file,jjm_file,i_cut,champ_file(:,:,l))
+        ENDDO
+     ENDIF
+     ! interpolate onto the model grid
+     DO l=1,n3
+        DO j=1,jjm_g
+           DO i=1,iim_g
+              ij = i+(j-1)*iim_g
+              champout_g(ij,l) = 0.
+              DO m=1,ncorr(i,j)
+                 champout_g(ij,l) = champout_g(ij,l) &
+        &                        +champ_file(icorr(i,j,m),jcorr(i,j,m),l)
+              ENDDO
+              champout_g(ij,l) = champout_g(ij,l)/REAL(ncorr(i,j))
+           ENDDO
+        ENDDO
+     ENDDO
+!!$     DO l=1,n3
+!!$        DO j=1,jjm_g
+!!$           WRITE(numout,*) j,(/ ( champout_g((j-1)*iim_g+i,l), i=1,iim_g ) /)
+!!$        ENDDO
+!!$     ENDDO
+  ELSE
+     ALLOCATE(champout_g(1,1))
+  ENDIF
+!!$  CALL scatter2D(champout_g,champout)
+#ifndef CPP_PARA
+  champout(:,:)=champout_g(:,:)
+#else
+  CALL scatter2D_rgen(champout_g,champout,n3)
+#endif
+
+!!$  DO l=1,n3
+!!$     DO j=1,jjm
+!!$        WRITE(numout,*) j,(/ ( champout((j-1)*iim_g+i,l), i=1,iim_g ) /)
+!!$     ENDDO
+!!$  ENDDO
+  !----------------------------
+END SUBROUTINE weather_read
+!-
+!===
+!-
+SUBROUTINE weathgen_dump &
+& (itau, dt_force, iim, jjm, nbindex, kindex, lrstwrite, &
+&  swdown, rainf, snowf, tair, u, v, qair, pb, lwdown )
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(IN)                     :: itau
+  REAL,INTENT(IN)                        :: dt_force
+  INTEGER,INTENT(IN)                     :: iim,jjm
+  INTEGER,INTENT(IN)                     :: nbindex
+  INTEGER,DIMENSION(iim*jjm),INTENT(IN)  :: kindex
+  LOGICAL,INTENT(IN)                     :: lrstwrite
+  REAL,DIMENSION(iim*jjm),INTENT(IN)     :: &
+ &  swdown, rainf, snowf, tair, u, v, qair, pb, lwdown
+!-
+  INTEGER                 :: iret,ndim
+  INTEGER,DIMENSION(4)    :: corner,edges
+  REAL,DIMENSION(iim*jjm) :: var_gather
+!---------------------------------------------------------------------
+!-
+! time dimension
+!-
+  iret = NF90_PUT_VAR (dump_id,timestp_id,(/ REAL(itau) /), &
+ &                     start=(/ itau /),count=(/ 1 /))
+  iret = NF90_PUT_VAR (dump_id,time_id,(/ REAL(itau)*dt_force /), &
+ &                     start=(/ itau /),count=(/ 1 /))
+!-
+! 2D variables: pas de dimension verticale
+!-
+  IF (gathered) THEN
+    ndim = 2
+    corner(1:2) = (/ 1, itau /)
+    edges(1:2) = (/ nbindex, 1 /)
+  ELSE
+    ndim = 3
+    corner(1:3) = (/ 1, 1, itau /)
+    edges(1:3) = (/ iim, jjm, 1 /)
+  ENDIF
+!-
+  CALL gather_weather (iim*jjm,nbindex,kindex,swdown, var_gather)
+  iret = NF90_PUT_VAR (dump_id,soldownid, var_gather, &
+ &         start=corner(1:ndim), count=edges(1:ndim))
+  CALL gather_weather (iim*jjm,nbindex,kindex,rainf,  var_gather)
+  iret = NF90_PUT_VAR (dump_id,rainfid,   var_gather, &
+ &         start=corner(1:ndim), count=edges(1:ndim))
+  CALL gather_weather (iim*jjm,nbindex,kindex,snowf,  var_gather)
+  iret = NF90_PUT_VAR (dump_id,snowfid,   var_gather, &
+ &         start=corner(1:ndim), count=edges(1:ndim))
+  CALL gather_weather (iim*jjm,nbindex,kindex,pb,     var_gather)
+  iret = NF90_PUT_VAR (dump_id,psolid,    var_gather, &
+ &         start=corner(1:ndim), count=edges(1:ndim))
+  CALL gather_weather (iim*jjm,nbindex,kindex,lwdown, var_gather)
+  iret = NF90_PUT_VAR (dump_id,lwradid,   var_gather, &
+ &         start=corner(1:ndim), count=edges(1:ndim))
+!-
+! 3D variables
+!-
+  IF (gathered) THEN
+    ndim = 3
+    corner(1:3) = (/ 1, 1, itau /)
+    edges(1:3) = (/ nbindex, 1, 1 /)
+  ELSE
+    ndim = 4
+    corner(1:4) = (/ 1, 1, 1, itau /)
+    edges(1:4) = (/ iim, jjm, 1, 1 /)
+  ENDIF
+!-
+  CALL gather_weather (iim*jjm,nbindex,kindex,u,    var_gather)
+  iret = NF90_PUT_VAR (dump_id,uid,    var_gather, &
+ &         start=corner(1:ndim), count=edges(1:ndim))
+  CALL gather_weather (iim*jjm,nbindex,kindex,v,    var_gather)
+  iret = NF90_PUT_VAR (dump_id,vid,    var_gather, &
+ &         start=corner(1:ndim), count=edges(1:ndim))
+  CALL gather_weather (iim*jjm,nbindex,kindex,tair, var_gather)
+  iret = NF90_PUT_VAR (dump_id,tairid, var_gather, &
+ &         start=corner(1:ndim), count=edges(1:ndim))
+  CALL gather_weather (iim*jjm,nbindex,kindex,qair, var_gather)
+  iret = NF90_PUT_VAR (dump_id,qairid, var_gather, &
+ &         start=corner(1:ndim), count=edges(1:ndim))
+!-
+  IF (lrstwrite) THEN
+    iret = NF90_CLOSE (dump_id)
+  ENDIF
+!---------------------------
+END SUBROUTINE weathgen_dump
+!-
+!===
+!-
+SUBROUTINE gather_weather (iimjjm, nbindex, kindex, var_in, var_out)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(IN)                     :: iimjjm,nbindex
+  INTEGER,DIMENSION(iimjjm),INTENT(IN)   :: kindex
+  REAL,DIMENSION(iimjjm),INTENT(IN)      :: var_in
+!-
+  REAL,DIMENSION(iimjjm),INTENT(OUT)     :: var_out
+!-
+  INTEGER                                :: i
+  LOGICAL,SAVE                           :: firstcall = .TRUE.
+  INTEGER,SAVE                           :: nb_outside
+  INTEGER,ALLOCATABLE,SAVE,DIMENSION(:)  :: outside
+!---------------------------------------------------------------------
+  IF (firstcall) THEN
+!---
+!-- determine which points are not in the computational domain and
+!-- create a mask for these points
+!---
+    firstcall = .FALSE.
+  
+    ALLOC_ERR=-1
+    ALLOCATE(outside(iimjjm), STAT=ALLOC_ERR)
+    IF (ALLOC_ERR/=0) THEN
+      WRITE(numout,*) "ERROR IN ALLOCATION of outside : ",ALLOC_ERR
+      STOP 
+    ENDIF
+    outside(:) = 0.
+    nb_outside = 0
+    DO i=1,iimjjm
+      IF ( ALL( kindex(:) /= i ) ) THEN
+        nb_outside = nb_outside+1
+        outside(nb_outside) = i
+      ENDIF
+    ENDDO
+  ENDIF
+!-
+  IF ( gathered ) THEN
+    DO i=1,nbindex
+      var_out(i) = var_in(kindex(i))
+    ENDDO
+  ELSE
+    var_out(:) = var_in(:)
+    DO i=1,nb_outside
+      var_out(outside(i)) = undef
+    ENDDO
+  ENDIF
+!--------------------
+END SUBROUTINE gather_weather
+!-
+!===
+!-
+SUBROUTINE shift_field (im,jm,i_cut,champ)
+!---------------------------------------------------------------------
+  INTEGER,INTENT(IN)                  :: im,jm,i_cut
+  REAL,DIMENSION(im,jm),INTENT(INOUT) :: champ
+!-
+  REAL,DIMENSION(im,jm)               :: champ_temp
+!---------------------------------------------------------------------
+  IF ( (i_cut >= 1).AND.(i_cut <= im) ) THEN
+    champ_temp(1:im-i_cut-1,:) = champ(i_cut:im,:)
+    champ_temp(im-i_cut:im,:)  = champ(1:i_cut+1,:)
+    champ(:,:) = champ_temp(:,:)
+  ENDIF
+!-------------------------
+END SUBROUTINE shift_field
+!-
+!===
+!-
+SUBROUTINE weathgen_domain_size &
+& (limit_west,limit_east,limit_north,limit_south, &
+&  zonal_res,merid_res,iim,jjm)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  REAL,INTENT(INOUT)  :: limit_west,limit_east,limit_north,limit_south
+  REAL,INTENT(IN)     :: zonal_res,merid_res
+  INTEGER,INTENT(OUT) :: iim,jjm
+!---------------------------------------------------------------------
+  IF (limit_west > limit_east)  limit_east = limit_east+360.
+!-
+  IF (    (limit_west >= limit_east) &
+ &    .OR.(limit_east > 360.) &
+ &    .OR.(limit_west < -180.) &
+ &    .OR.(limit_east-limit_west > 360.) ) THEN
+    WRITE(numout,*) 'PROBLEME longitudes.'
+    WRITE(numout,*) 'Limites Ouest, Est: ',limit_west,limit_east
+    STOP
+  ENDIF
+!-
+  IF (    (limit_south < -90.) &
+ &    .OR.(limit_north > 90.) &
+ &    .OR.(limit_south >= limit_north ) ) THEN
+    WRITE(numout,*) 'PROBLEME latitudes.'
+    WRITE(numout,*) 'Limites Nord, Sud: ',limit_north,limit_south
+    STOP
+  ENDIF
+!-
+  IF (    (zonal_res <= 0. ) &
+ &    .OR.(zonal_res > limit_east-limit_west) ) THEN
+    WRITE(numout,*) 'PROBLEME resolution zonale.'
+    WRITE(numout,*) 'Limites Ouest, Est, Resolution: ', &
+ &             limit_west,limit_east,zonal_res
+    STOP
+  ENDIF
+!-
+  IF (    (merid_res <= 0.) &
+ &    .OR.(merid_res > limit_north-limit_south) ) THEN
+    WRITE(numout,*) 'PROBLEME resolution meridionale.'
+    WRITE(numout,*) 'Limites Nord, Sud, Resolution: ', &
+ &             limit_north,limit_south,merid_res
+    STOP
+  ENDIF
+!-
+  iim = NINT(MAX((limit_east-limit_west)/zonal_res,1.))
+  jjm = NINT(MAX((limit_north-limit_south)/merid_res,1.))
+!-
+  WRITE(numout,*) 'Domain size: iim, jjm = ', iim, jjm
+!----------------------------------
+END SUBROUTINE weathgen_domain_size
+!-
+!===
+!-
+FUNCTION tsatl (t) RESULT (tsat)
+!---------------------------------------------------------------------
+! statement functions tsatl,tsati are used below so that lowe's
+! polyomial for liquid is used if t gt 273.16, or for ice if
+! t lt 273.16. also impose range of validity for lowe's polys.
+!---------------------------------------------------------------------
+  REAL,INTENT(IN) :: t
+  REAL            :: tsat
+!---------------------------------------------------------------------
+  tsat = MIN(100.,MAX(t-zero_t,0.))
+!-----------------
+END FUNCTION tsatl
+!-
+!===
+!-
+FUNCTION tsati (t) RESULT (tsat)
+!---------------------------------------------------------------------
+! statement functions tsatl,tsati are used below so that lowe's
+! polyomial for liquid is used if t gt 273.16, or for ice if
+! t lt 273.16. also impose range of validity for lowe's polys.
+!---------------------------------------------------------------------
+  REAL,INTENT(IN) :: t
+  REAL            :: tsat
+!---------------------------------------------------------------------
+  tsat = MAX(-60.,MIN(t-zero_t,0.))
+!-----------------
+END FUNCTION tsati
+!-
+!===
+!-
+FUNCTION esat (t) RESULT (esatout)
+!---------------------------------------------------------------------
+! statement function esat is svp in n/m**2, with t in deg k.
+! (100 * lowe's poly since 1 mb = 100 n/m**2.)
+!---------------------------------------------------------------------
+  REAL,INTENT(IN) :: t
+  REAL             :: esatout
+  REAL             :: x
+!-
+! polynomials for svp(t), d(svp)/dt over water and ice are from
+! lowe(1977),jam,16,101-103.
+!-
+  REAL,PARAMETER :: &
+ & asat0 = 6.1078000,    asat1 = 4.4365185e-1, asat2 = 1.4289458e-2, &
+ & asat3 = 2.6506485e-4, asat4 = 3.0312404e-6, asat5 = 2.0340809e-8, &
+ & asat6 = 6.1368209e-11, &
+ & bsat0 = 6.1091780,    bsat1 = 5.0346990e-1, bsat2 = 1.8860134e-2, &
+ & bsat3 = 4.1762237e-4, bsat4 = 5.8247203e-6, bsat5 = 4.8388032e-8, &
+ & bsat6 = 1.8388269e-10
+!---------------------------------------------------------------------
+  IF (t >= zero_t) THEN
+    x = asat0
+  ELSE
+    x = bsat0
+  ENDIF
+!-
+  esatout = 100.* &
+    ( x &
+     +tsatl(t)*(asat1+tsatl(t)*(asat2+tsatl(t)*(asat3 &
+     +tsatl(t)*(asat4+tsatl(t)*(asat5+tsatl(t)* asat6))))) &
+     +tsati(t)*(bsat1+tsati(t)*(bsat2+tsati(t)*(bsat3 &
+     +tsati(t)*(bsat4+tsati(t)*(bsat5+tsati(t)* bsat6)))))  )
+!----------------
+END FUNCTION esat
+!-
+!===
+!-
+FUNCTION qsat (e,p) RESULT (qsatout)
+!---------------------------------------------------------------------
+! statement function qsat is saturation specific humidity,
+! with svp e and ambient pressure p in n/m**2. impose an upper
+! limit of 1 to avoid spurious values for very high svp
+! and/or small p
+!---------------------------------------------------------------------
+  REAL, INTENT(IN) :: e,p
+  REAL             :: qsatout
+!---------------------------------------------------------------------
+  qsatout = 0.622*e/MAX(p-(1.0-0.622)*e,0.622*e)
+!----------------
+END FUNCTION qsat
+!-
+!===
+!-
+SUBROUTINE weathgen_qsat (npoi,t,p,qsat)
+!---------------------------------------------------------------------
+! vectorized version of functions esat and qsat.
+! statement function esat is svp in n/m**2, with t in deg k.
+! (100 * lowe's poly since 1 mb = 100 n/m**2.)
+!---------------------------------------------------------------------
+  INTEGER,INTENT(IN)              :: npoi
+  REAL,DIMENSION(npoi),INTENT(IN) :: t,p
+  REAL,DIMENSION(npoi),INTENT(OUT):: qsat
+!-
+  REAL,DIMENSION(npoi) :: x, tl, ti, e
+!-
+! polynomials for svp(t), d(svp)/dt over water and ice
+! are from lowe(1977),jam,16,101-103.
+!-
+  REAL,PARAMETER :: &
+ & asat0 = 6.1078000,    asat1 = 4.4365185e-1, asat2 = 1.4289458e-2, &
+ & asat3 = 2.6506485e-4, asat4 = 3.0312404e-6, asat5 = 2.0340809e-8, &
+ & asat6 = 6.1368209e-11, &
+ & bsat0 = 6.1091780,    bsat1 = 5.0346990e-1, bsat2 = 1.8860134e-2, &
+ & bsat3 = 4.1762237e-4, bsat4 = 5.8247203e-6, bsat5 = 4.8388032e-8, &
+ & bsat6 = 1.8388269e-10
+!---------------------------------------------------------------------
+  WHERE (t(:) > zero_t)
+    x(:) = asat0
+  ELSEWHERE
+    x(:) = bsat0
+  ENDWHERE
+!-
+  tl(:) = MIN(100.,MAX(t(:)-zero_t,0.))
+  ti(:) = MAX(-60.,MIN(t(:)-zero_t,0.))
+!-
+  e(:) =  100.* &
+    ( x(:) &
+     +tl(:)*(asat1+tl(:)*(asat2+tl(:)*(asat3 &
+     +tl(:)*(asat4+tl(:)*(asat5+tl(:)* asat6))))) &
+     +ti(:)*(bsat1+ti(:)*(bsat2+ti(:)*(bsat3 &
+     +ti(:)*(bsat4+ti(:)*(bsat5+ti(:)* bsat6)))))  )
+!-
+  qsat(:) = 0.622*e(:)/MAX(p(:)-(1.0-0.622)*e(:),0.622*e(:))
+!---------------------------
+END SUBROUTINE weathgen_qsat
+!-
+!===
+!-
+SUBROUTINE mask_c_o &
+& (imdep, jmdep, xdata, ydata, mask_in, fcrit, &
+&  imar, jmar, zonal_res, merid_res, n_agg, x, y, mask, &
+&  ncorr, icorr, jcorr)
+!---------------------------------------------------------------------
+! z.x.li (le 01/04/1994) :
+!    A partir du champ de masque, on fabrique
+!    un champ indicateur (masque) terre/ocean
+!    terre:1; ocean:0
+!---------------------------------------------------------------------
+  INTEGER :: imdep,jmdep
+  REAL :: xdata(imdep),ydata(jmdep)
+  REAL :: mask_in(imdep,jmdep)
+  REAL :: fcrit
+  INTEGER :: imar,jmar
+  REAL :: zonal_res,merid_res
+  INTEGER :: n_agg
+  REAL :: x(imar),y(jmar)
+  REAL, INTENT(OUT) :: mask(imar,jmar)
+  INTEGER :: ncorr(imar,jmar)
+  INTEGER,DIMENSION(imar,jmar,n_agg) :: icorr,jcorr
+!-
+  INTEGER i, j, ii, jj
+  REAL a(imar),b(imar),c(jmar),d(jmar)
+  INTEGER num_tot(imar,jmar), num_oce(imar,jmar)
+  REAL,ALLOCATABLE :: distans(:)
+  INTEGER ij_proche(1),i_proche,j_proche
+!-
+  INTEGER,DIMENSION(imar,jmar) :: ncorr_oce , ncorr_land
+  INTEGER,DIMENSION(imar,jmar,n_agg) :: &
+ &  icorr_oce, jcorr_oce , icorr_land, jcorr_land
+!-
+  INTEGER imdepp
+  REAL,ALLOCATABLE :: xdatap(:)
+  REAL,ALLOCATABLE :: mask_inp(:,:)
+  LOGICAL :: extend
+!---------------------------------------------------------------------
+  ncorr(:,:) = 0
+  icorr(:,:,:) = -1; jcorr(:,:,:) = -1
+  ncorr_land(:,:) = 0
+  icorr_land(:,:,:) = -1; jcorr_land(:,:,:) = -1
+  ncorr_oce(:,:) = 0
+  icorr_oce(:,:,:) = -1; jcorr_oce(:,:,:) = -1
+! do we have to extend the domain (-x...-x+360)?
+  IF ( xdata(1)+360.-xdata(imdep) > 0.01 ) THEN
+    extend = .TRUE.
+    imdepp = imdep+1
+  ELSE
+    extend = .FALSE.
+    imdepp = imdep
+  ENDIF
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(xdatap(imdepp), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of xdatap : ",ALLOC_ERR
+    STOP 
+  ENDIF
+
+  ALLOC_ERR=-1
+  ALLOCATE(mask_inp(imdepp,jmdep), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of mask_inp : ",ALLOC_ERR
+    STOP 
+  ENDIF
+!-
+  xdatap(1:imdep) = xdata(1:imdep)
+  mask_inp(1:imdep,:) = mask_in(1:imdep,:)
+!-
+  IF (extend) THEN
+    xdatap(imdepp) = xdatap(1)+360.
+    mask_inp(imdepp,:) = mask_inp(1,:)
+  ENDIF
+!-
+
+  ALLOC_ERR=-1
+  ALLOCATE(distans(imdepp*jmdep), STAT=ALLOC_ERR)
+  IF (ALLOC_ERR/=0) THEN
+    WRITE(numout,*) "ERROR IN ALLOCATION of distans : ",ALLOC_ERR
+    STOP 
+  ENDIF
+! Definition des limites des boites de la grille d'arrivee.
+  IF (imar > 1) THEN
+    a(1) = x(1)-(x(2)-x(1))/2.0
+    b(1) = (x(1)+x(2))/2.0
+    DO i=2,imar-1
+      a(i) = b(i-1)
+      b(i) = (x(i)+x(i+1))/2.0
+    ENDDO
+    a(imar) = b(imar-1)
+    b(imar) = x(imar)+(x(imar)-x(imar-1))/2.0
+  ELSE
+    a(1) = x(1)-zonal_res/2.
+    b(1) = x(1)+zonal_res/2.
+  ENDIF
+!-
+  IF (jmar > 1) THEN
+    c(1) = y(1)-(y(2)-y(1))/2.0
+    d(1) = (y(1)+y(2))/2.0
+    DO j=2,jmar-1
+      c(j) = d(j-1)
+      d(j) = (y(j)+y(j+1))/2.0
+    ENDDO
+    c(jmar) = d(jmar-1)
+    d(jmar) = y(jmar)+(y(jmar)-y(jmar-1))/2.0
+  ELSE
+    c(1) = y(1)-merid_res/2.
+    d(1) = y(1)+merid_res/2.
+  ENDIF
+!-
+  num_oce(1:imar,1:jmar) = 0
+  num_tot(1:imar,1:jmar) = 0
+!-
+!  .....  Modif  P. Le Van ( 23/08/95 )  ....
+!-
+  DO ii=1,imar
+    DO jj=1,jmar
+      DO i=1,imdepp
+        IF (    (     (xdatap(i)-a(ii) >= 1.e-5) &
+ &               .AND.(xdatap(i)-b(ii) <= 1.e-5) ) &
+ &          .OR.(     (xdatap(i)-a(ii) <= 1.e-5) &
+ &               .AND.(xdatap(i)-b(ii) >= 1.e-5) ) ) THEN
+          DO j=1,jmdep
+            IF (    (     (ydata(j)-c(jj) >= 1.e-5) &
+ &                   .AND.(ydata(j)-d(jj) <= 1.e-5) ) &
+ &              .OR.(     (ydata(j)-c(jj) <= 1.e-5) &
+ &                   .AND.(ydata(j)-d(jj) >= 1.e-5) ) ) THEN
+              num_tot(ii,jj) = num_tot(ii,jj)+1
+              IF (mask_inp(i,j) < 0.5) THEN
+                num_oce(ii,jj) = num_oce(ii,jj)+1
+!-------------- on a trouve un point oceanique. On le memorise.
+                ncorr_oce(ii,jj) = ncorr_oce(ii,jj)+1
+                IF ((i == imdepp).AND.extend) THEN
+                  icorr_oce(ii,jj,ncorr_oce(ii,jj)) = 1
+                ELSE
+                  icorr_oce(ii,jj,ncorr_oce(ii,jj)) = i
+                ENDIF
+                jcorr_oce(ii,jj,ncorr_oce(ii,jj)) = j
+              ELSE
+!-------------- on a trouve un point continental. On le memorise.
+                ncorr_land(ii,jj) = ncorr_land(ii,jj)+1
+                IF ((i == imdepp).AND.extend) THEN
+                  icorr_land(ii,jj,ncorr_land(ii,jj)) = 1
+                ELSE
+                  icorr_land(ii,jj,ncorr_land(ii,jj)) = i
+                ENDIF
+                jcorr_land(ii,jj,ncorr_land(ii,jj)) = j
+              ENDIF
+            ENDIF
+          ENDDO
+        ENDIF
+      ENDDO
+    ENDDO
+  ENDDO
+!-
+  DO i=1,imar
+    DO j=1,jmar
+      IF (num_tot(i,j) > 0) THEN
+        IF (    (     (num_oce(i,j) == 0) &
+ &               .AND.(num_tot(i,j) > 0) ) &
+ &          .OR.(     (num_oce(i,j) > 0) &
+ &               .AND.(   REAL(num_oce(i,j)) &
+ &                     <= REAL(num_tot(i,j))*(1.-fcrit) ) ) ) THEN
+          mask(i,j) = 1.
+          ncorr(i,j) = ncorr_land(i,j)
+          icorr(i,j,:) = icorr_land(i,j,:)
+          jcorr(i,j,:) = jcorr_land(i,j,:)
+        ELSE
+          mask(i,j) = 0.
+          ncorr(i,j) = ncorr_oce(i,j)
+          icorr(i,j,:) = icorr_oce(i,j,:)
+          jcorr(i,j,:) = jcorr_oce(i,j,:)
+        ENDIF
+      ELSE
+        CALL dist_sphe(x(i),y(j),xdatap,ydata,imdepp,jmdep,distans)
+        ij_proche(:) = MINLOC(distans)
+        j_proche = (ij_proche(1)-1)/imdepp+1
+        i_proche = ij_proche(1)-(j_proche-1)*imdepp
+        mask(i,j) = mask_inp(i_proche,j_proche)
+        IF ( (i_proche == imdepp).AND.extend)  i_proche=1
+        ncorr(i,j) = 1
+        icorr(i,j,1) = i_proche
+        jcorr(i,j,1) = j_proche
+      ENDIF
+    ENDDO
+  ENDDO
+!----------------------
+END SUBROUTINE mask_c_o
+!-
+!===
+!-
+SUBROUTINE dist_sphe (rf_lon,rf_lat,rlon,rlat,im,jm,distance)
+!---------------------------------------------------------------------
+! Auteur: Laurent Li (le 30/12/1996)
+!
+! Ce programme calcule la distance minimale (selon le grand cercle)
+! entre deux points sur la terre
+!---------------------------------------------------------------------
+!-
+! Input:
+!-
+  INTEGER im, jm ! dimensions
+  REAL rf_lon ! longitude du point de reference (degres)
+  REAL rf_lat ! latitude du point de reference (degres)
+  REAL rlon(im), rlat(jm) ! longitude et latitude des points
+!-
+! Output:
+!-
+  REAL distance(im,jm) ! distances en metre
+!-
+  REAL rlon1, rlat1
+  REAL rlon2, rlat2
+  REAL dist
+  REAL pa, pb, p, pi
+  INTEGER i,j
+!-
+  REAL radius
+  PARAMETER (radius=6371229.)
+!---------------------------------------------------------------------
+  pi = 4.0*ATAN(1.0)
+!-
+  DO j=1,jm
+    DO i=1,im
+      rlon1=rf_lon
+      rlat1=rf_lat
+      rlon2=rlon(i)
+      rlat2=rlat(j)
+      pa = pi/2.0-rlat1*pi/180.0 ! dist. entre pole n et point a
+      pb = pi/2.0-rlat2*pi/180.0 ! dist. entre pole n et point b
+!-----
+      p = (rlon1-rlon2)*pi/180.0 ! angle entre a et b (leurs meridiens)
+!-----
+      dist = ACOS( COS(pa)*COS(pb)+SIN(pa)*SIN(pb)*COS(p))
+      dist = radius*dist
+      distance(i,j) = dist
+    ENDDO
+  ENDDO
+!-----------------------
+END SUBROUTINE dist_sphe
+!-
+!===
+!-
+SUBROUTINE permute (n,ordre)
+!---------------------------------------------------------------------
+  INTEGER,INTENT(IN) :: n
+  INTEGER,DIMENSION(n),INTENT(OUT) :: ordre
+!-
+  INTEGER,DIMENSION(n) :: restant
+  INTEGER :: ipique, i, n_rest
+  REAL    :: rndnum
+!---------------------------------------------------------------------
+  n_rest = n
+  restant(:) = (/ (i, i=1,n) /)
+!-
+  DO i=1,n
+    CALL random_number (rndnum)
+    ipique = INT(rndnum*n_rest)+1
+    ordre(i) = restant(ipique)
+    restant(ipique:n_rest-1) = restant(ipique+1:n_rest)
+    n_rest = n_rest-1
+  ENDDO
+!---------------------
+END SUBROUTINE permute
+!-
+!===
+!-----------------
+END MODULE weather
