Index: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/README
===================================================================
--- dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/README	(revision 4066)
+++ dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/README	(revision 4067)
@@ -22,7 +22,6 @@
     IFLAG_PHYS   : 103 if CE0L, 1 otherwise
     READ_START	 : no if CE0L, yes otherwise
-
-For 'CE0L' XIOS is run in 'attached' mode. In server mode, xios_server.exe would hang after the dynamico_lmdz.exe MPI processes have aborted. 
-For 'START' and 'NEXT', XIOS is run in server mode for flexibility. Especially it allows to restart with a different number of processors, which is not possible in attached mode.
+    ANNEEREF	 : ANNEEREF (see below)
+For 'CE0L' XIOS is run in 'attached' mode.  For 'START' and 'NEXT', XIOS is run in server mode for flexibility. Especially it allows to restart with a different number of processors, which is not possible in attached mode.
 
 Notice that the definitions of start.def have the highest priority since start.def is the last *.def file included in run.def .
@@ -40,5 +39,5 @@
 
 2 - In order to create a run of type 'ce0l' :
-> ./prepare ce0l MYDIR0 STORE0
+> ./prepare ce0l MYDIR0 STORE0 ANNEEREF
 This will create STORE0 and MYDIR0 if necessary and populate MYDIR0 with .xml and .def files, as well as a batch job 'job.sh' to be submitted (on CURIE) as :
 ccc_msub job.sh .
@@ -46,9 +45,9 @@
 
 3 - In order to create a one-year run of type 'first'
-> ./prepare first STORE0 MYDIR1 STORE1
+> ./prepare first STORE0 MYDIR1 STORE1 ANNEEREF
 This will create STORE1 and MYDIR1 if necessary and populate MYDIR1 with .xml and .def files, as well as a batch job 'job.sh'. This batch job copies input files from STORE0. Submit MYDIR1/job.sh . After successful completion, STORE1 contains all *.nc files produced by the run, especially start.nc
 
 4 - In order to create a one-year run of type NEXT, type
-./prepare first STORE0 STOREPREV MYDIR2 STORE2
+./prepare first STORE0 STOREPREV MYDIR2 STORE2 ANNEEREF
 This will create STORE2 and MYDIR2 if necessary and populate MYDIR2 with .xml and .def files, as well as a batch job 'job.sh'. This batch job copies input files from STORE0 and STOREPREV. Submit MYDIR2/job.sh .
 
Index: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/config.def
===================================================================
--- dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/config.def	(revision 4066)
+++ dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/config.def	(revision 4067)
@@ -101,5 +101,5 @@
 version_ocean=nemo
 #avec ou sans orchidee (D:n)
-VEGET=n
+VEGET=KEY_VEGET
 #type_run=AMIP, ENSP, clim (D:AMIP)
 type_run=CLIM
@@ -166,5 +166,5 @@
 # 1: read a single ozone climatology that will be used day and night
 # 2: read two ozone climatologies, the average day and night climatology and the daylight climatology
-read_climoz=-1
+read_climoz=READ_CLIMOZ
 #
 # Parametres simulateur COSP (CFMIP Observational Simulator Package)
@@ -203,5 +203,4 @@
 ok_all_xml=y
 #qsol0=100.
-VEGET=bucket
 flag_aerosol=0
 ok_ade=.false.
Index: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/example.sh
===================================================================
--- dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/example.sh	(revision 4066)
+++ dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/example.sh	(revision 4067)
@@ -16,4 +16,11 @@
 {
     for ((i="$1";i<="$2";i++)) ; do
+	echo $i
+    done
+}
+
+function yeardirs()
+{
+    for ((i="$1";i<="$2";i++)) ; do
 	echo $(printf 'year%02d' $i)
     done
@@ -26,15 +33,17 @@
     ls -l $PWD/storedir || (echo "$PWD/storedir is missing, please create it and retry." ; exit -1) || exit
     STORE_ROOT=$( fullpath $PWD/storedir )
-    YEARS=$(years 1 $NB_YEARS)
-    for DIR in ce0l $YEARS ; do
+    YEARDIRS=$(yeardirs 1 $NB_YEARS)
+    for DIR in ce0l $YEARDIRS ; do
 	rm -rf $DIR $STORE_ROOT/$DIR
     done
     STORE0L="$STORE_ROOT/ce0l"
-    $BASEDIR/prepare.sh ce0l ce0l "$STORE0L"
-    $BASEDIR/prepare.sh first $STORE0L year01 "$STORE_ROOT/year01"
+    $BASEDIR/prepare.sh ce0l ce0l "$STORE0L" 1980
+    $BASEDIR/prepare.sh first $STORE0L year01 "$STORE_ROOT/year01" 1980
     PREV=year01
     for YEAR in $(years 2 $NB_YEARS) ; do
-	$BASEDIR/prepare.sh next  $STORE0L "$STORE_ROOT/$PREV" $YEAR "$STORE_ROOT/$YEAR"
-	PREV=$YEAR
+	YEARDIR=$(printf 'year%02d' $YEAR)
+	ANNEEREF=$((1979 + YEAR))
+	$BASEDIR/prepare.sh next  $STORE0L "$STORE_ROOT/$PREV" $YEARDIR "$STORE_ROOT/$YEARDIR" $ANNEEREF
+	PREV=$YEARDIR
     done
 }
@@ -55,17 +64,16 @@
     DEP=""
     submit_$ARCH ce0l
-    for YEAR in $(years 1 $NB_YEARS) ; do
-	submit_$ARCH $YEAR $DEP
+    for YEARDIR in $(yeardirs 1 $NB_YEARS) ; do
+	submit_$ARCH $YEARDIR $DEP
     done
 }
 
-function cmd_init()
+function init_all()
 {
-    cp -fp $BASEDIR/*.sh $BASEDIR/*.xml $BASEDIR/*.def .
-    cat > config.sh <<EOF
+    cat >> config.sh <<EOF
 ARCH=X64_CURIE
 BASEDIR=$BASEDIR
 ESM_ROOT=$ESM_ROOT
-NB_YEARS=10
+NB_YEARS=2
 NB_MPI_DYNAMICO=160
 NB_MPI_XIOS=16
@@ -73,4 +81,6 @@
 JOB_WALLTIME=7200
 EOF
+    cp -fp $BASEDIR/*.sh $BASEDIR/*.xml $BASEDIR/*.def .
+    rm gcm.def # LMDZ-only, remove to avoid confusion
     ls -lrh
     echo
@@ -81,8 +91,32 @@
 }
 
-function cmd_()
+function cmd_init_aqua()
 {
-echo
+    cat > config.sh <<EOF
+READ_CLIMOZ=-1
+VEGET=n
+SOLARLONG0=1000.
+ETAT0=held_suarez
+IFLAG_PHYS0=103
+EXPERIMENT=aqua
+EOF
+    init_all
 }
+
+function cmd_init_betaclim()
+{
+    cat > config.sh <<EOF
+READ_CLIMOZ=2
+VEGET=betaclim
+SOLARLONG0=-9999.999
+ETAT0=database
+IFLAG_PHYS0=1
+EXPERIMENT=betaclim
+EOF
+    init_all
+    echo "Decompressing FILES_LMDZ.tar.bz2"
+    tar xjf /ccc/store/cont003/gen7548/dubosth/Lluis/FILES_LMDZ.tar.bz2
+}
+
 
 BASEDIR=$(dirname ${BASH_SOURCE[0]})
@@ -92,4 +126,4 @@
 echo "Script base dir : $BASEDIR"
 echo "Run from : $(fullpath $PWD)"
-echo "Usage : $0 [init|create|submit]"
+echo "Usage : $0 [init_aqua|init_betaclim|create|submit]"
 cmd_$1
Index: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/prepare.sh
===================================================================
--- dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/prepare.sh	(revision 4066)
+++ dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/prepare.sh	(revision 4067)
@@ -11,4 +11,5 @@
     MYDIR=$(fullpath $2)
     MYSTORE=$(fullpath $3)
+    ANNEEREF=$4
     mkdir -p $MYDIR
     mkdir -p $MYSTORE
@@ -21,4 +22,5 @@
     MYDIR=$(fullpath $3)
     MYSTORE=$(fullpath $4)
+    ANNEEREF=$5
     mkdir -p $MYDIR
     mkdir -p $MYSTORE
@@ -32,4 +34,5 @@
     MYDIR=$(fullpath $4)
     MYSTORE=$(fullpath $5)
+    ANNEEREF=$6
     mkdir -p $MYDIR
     mkdir -p $MYSTORE
@@ -66,6 +69,6 @@
     def CE0L yes
     def READ_START no
-    def IFLAG_PHYS 103
-    def ETAT0 held_suarez
+    def IFLAG_PHYS $IFLAG_PHYS0
+    def ETAT0 $ETAT0
 }
 
@@ -75,5 +78,5 @@
     def READ_START yes
     def IFLAG_PHYS 1
-    def ETAT0 held_suarez
+    def ETAT0 $ETAT0
 }
 
@@ -86,4 +89,11 @@
 }
 
+function sed_all() {
+    def READ_CLIMOZ $READ_CLIMOZ
+    def KEY_VEGET $VEGET
+    def SOLARLONG0 $SOLARLONG0
+    def ANNEEREF $ANNEEREF
+}
+
 #------------ Batch jobs : machine-independent prologues and epilogues  --------------
 
@@ -92,4 +102,5 @@
 cd ${MYDIR}
 rm -rf gcm.log *.nc xios_*.err xios_*.out gcm.log logs
+ln -s ../FILES_LMDZ/*.nc .
 
 cat <<END  > killme.sh
@@ -107,5 +118,5 @@
 function prologue_first() {
 cat <<EOF 
-cp -f store0/limit.nc store0/startphy.nc .
+ln -s store0/limit.nc store0/climoz_LMDZ.nc store0/startphy.nc .
 EOF
 }
@@ -113,7 +124,7 @@
 function prologue_next() {
 cat <<EOF 
-cp -f store0/limit.nc .
-cp -f store_prev/restartphy.nc startphy.nc
-cp -f store_prev/restart.nc start.nc
+ln -s store0/limit.nc store0/climoz_LMDZ.nc .
+ln -s store_prev/restartphy.nc startphy.nc
+ln -s store_prev/restart.nc start.nc
 EOF
 }
@@ -122,5 +133,5 @@
     cat <<EOF
 # save useful files
-mv limit.nc startphy.nc store/
+mv limit.nc startphy.nc climoz_LMDZ.nc store/
 EOF
 }
@@ -128,6 +139,4 @@
 function epilogue_first(){
     cat <<EOF
-# remove input files to avoid storing them a few lines below
-rm -f limit.nc startphy.nc
 # save useful files
 mv restartphy.nc restart.nc store/
@@ -137,6 +146,4 @@
 function epilogue_next(){
     cat <<EOF
-# remove input files to avoid storing them a few lines below
-rm -f limit.nc startphy.nc start.nc
 # save useful files
 mv restartphy.nc restart.nc store/
@@ -151,5 +158,5 @@
 tar czf logs.tgz logs
 mv hist*.nc logs.tgz store/
-# cleanup
+# cleanup input files
 rm -f *.nc
 EOF
@@ -162,5 +169,5 @@
 #!/bin/bash
 ## Request name
-#MSUB -r aqua_ce0l_mpi
+#MSUB -r ${EXPERIMENT}_ce0l_mpi
 #MSUB -q standard 
 #MSUB -A gen7548
@@ -196,5 +203,5 @@
 #!/bin/bash
 ## Request name
-#MSUB -r aqua_$1_mpi
+#MSUB -r ${EXPERIMENT}_$1_mpi
 #MSUB -q standard 
 #MSUB -A gen7548
@@ -256,5 +263,6 @@
 MYSED=$(mktemp)
 sed_$TYPE > $MYSED
-cat $MYSED
+sed_all >> $MYSED
+#cat $MYSED
 for FILE in *.def *.xml ; do
     sed -f $MYSED $FILE > $MYDIR/$FILE
@@ -269,5 +277,5 @@
 #ls -l $MYDIR
 grep using_server iodef.xml
-for KEY in read_start iflag_phys etat0 run_length; do
-    grep $KEY *.def
+for KEY in create_etat0_limit read_start etat0 anneeref iflag_phys read_climoz VEGET solarlong0 ; do
+    grep "\b$KEY\b" *.def | grep -v '#' # match whole words : \b means 'word boundary'
 done
Index: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/run.def
===================================================================
--- dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/run.def	(revision 4066)
+++ dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/run.def	(revision 4067)
@@ -17,8 +17,8 @@
 dayref=1
 ##  Annee de l'etat  initial (   avec  4  chiffres   )
-anneeref=1980
+anneeref=ANNEEREF
 
 # Deactivate annual cycle
-solarlong0 = 1000.
+solarlong0 = SOLARLONG0
 
 ## Remise a zero de la date initiale
Index: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/run_icosa.def
===================================================================
--- dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/run_icosa.def	(revision 4066)
+++ dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/run_icosa.def	(revision 4067)
@@ -32,5 +32,4 @@
 
 # run length : real (default=dt*itaumax)
-#run_length=864000
 run_length=31104000
 
@@ -71,4 +70,6 @@
 niterdivgrad=2
 
+iflag_sponge = 1
+
 # -------------------------------- Physics -------------------------------------
 
