Index: trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job	(revision 3538)
+++ trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job	(revision 3556)
@@ -32,11 +32,13 @@
 
 # Running the PCM
+read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
 echo "Run PCM $iPCM is starting."
-read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
 cp run_PCM.def run.def
 eval "$exe_cmd > out_runPCM${iPCM} 2>&1"
 if [ ! -f "restartfi.nc" ] || ! (tail -n 100 out_runPCM${iPCM} | grep -iq "everything is cool!"); then # Check if it ended abnormally
     echo "Error: the run PCM $iPCM crashed!"
-    echo "Be careful: there may be dependent jobs remaining in the SLURM queue with status 'DependencyNeverSatisfied'! You can cancel them by executing the script \"kill_launchPEM.sh\"."
+    if [ $mode -ne 0 ]; then
+        echo "Be careful: there may be dependent jobs remaining in the SLURM queue with status 'DependencyNeverSatisfied'! You can cancel them by executing the script \"kill_launchPEM.sh\"."
+    fi
     exit 1
 fi
@@ -70,4 +72,6 @@
 fi
 ((iPCM++))
-((i_myear++))
+if [ $counting -ne 0 ]; then
+    i_myear=$(echo "$i_myear + 1." | bc -l)
+fi
 sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
Index: trunk/LMDZ.COMMON/libf/evolution/deftank/README
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/README	(revision 3538)
+++ trunk/LMDZ.COMMON/libf/evolution/deftank/README	(revision 3556)
@@ -7,5 +7,6 @@
       (ii)  nPCM_ini -> the number of initial PCM runs (at least 2);
       (iii) nPCM -> the number of PCM runs between each PEM run (usually 2);
-      (iv)  mode -> the launching mode (0 = "processing scripts"; any other values = "submitting jobs"). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer.
+      (iv)  counting -> the counting method for the number of years to be simulated (0 = "only PEM runs count"; any other values = "PCM runs are taken into account"). The former option is the PEM default use;
+      (v)   mode -> the launching mode (0 = "processing scripts"; any other values = "submitting jobs"). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer.
   The script can take an argument:
       - If there is no argument, then the script initiates a PEM simulation from scratch.
Index: trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh	(revision 3538)
+++ trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh	(revision 3556)
@@ -23,4 +23,7 @@
 nPCM=2
 
+# Set the counting method for the number of years to be simulated (0 = "only PEM runs count"; any other values = "PCM runs are taken into account"):
+counting=0
+
 # Set the launching mode (0 = "processing scripts"; any other values = "submitting jobs"). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer:
 mode=1
@@ -38,4 +41,5 @@
 
 source lib_launchPEM.sh
+export counting mode
 
 if [ $# -eq 0 ]; then
@@ -48,5 +52,5 @@
     checklaunch
     initlaunch
-    cyclelaunch $mode $nPCM_ini
+    cyclelaunch $mode $counting $nPCM_ini
 
 else
@@ -61,5 +65,5 @@
         fi
         read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
-        cyclelaunch $mode $nPCM
+        cyclelaunch $mode $counting $nPCM
 
     # Starting a relaunch
@@ -122,7 +126,7 @@
         fi
         if [ $relaunch = "PCM" ]; then
-            relaunchPCM $mode
+            relaunchPCM $mode $counting
         else
-            relaunchPEM $mode
+            relaunchPEM $mode $counting
         fi
 
Index: trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh	(revision 3538)
+++ trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh	(revision 3556)
@@ -160,14 +160,15 @@
 # To submit the PCM runs
 # arg1: launching mode
-# arg2: number of PCM runs to launch
-# arg3: local number of the PCM run from which to start (optional)
+# arg2: counting method
+# arg3: number of PCM runs to launch
+# arg4: local number of the PCM run from which to start (optional)
 submitPCM() {
     find . -type f -name "PCMrun*.job" ! -name "PCMrun.job" -delete
     ii=1
-    if [ ! -z $3 ]; then
-        ii=$3
+    if [ ! -z $4 ]; then
+        ii=$4
     fi
     if [ $(echo "$i_myear < $n_myear" | bc -l) -eq 1 ]; then
-        echo "Run PCM $iPCM: call $ii/$2..."
+        echo "Run PCM $iPCM: call $ii/$3..."
         if [ $1 -eq 0 ]; then # Mode: processing scripts
             sed -i "s/^k=[0-9]\+$/k=$(echo "3 - $nPCM_ini" | bc)/" PCMrun.job
@@ -187,12 +188,14 @@
         fi
         ((iPCM++))
-        i_myear=$(echo "$i_myear + 1." | bc -l)
+        if [ $2 -ne 0 ]; then # Counting: PCM runs taken into account
+            i_myear=$(echo "$i_myear + 1." | bc -l)
+        fi
         ((ii++))
     else
         endlaunch
     fi
-    for ((i = $ii; i <= $2; i++)); do
+    for ((i = $ii; i <= $3; i++)); do
         if [ $(echo "$i_myear < $n_myear" | bc -l) -eq 1 ]; then
-            echo "Run PCM $iPCM: call $i/$2..."
+            echo "Run PCM $iPCM: call $i/$3..."
             if [ $1 -eq 0 ]; then # Mode: processing scripts
                 sed -i "s/^k=[0-9]\+$/k=$(echo "$i + 2 - $nPCM_ini" | bc)/" PCMrun.job
@@ -209,5 +212,7 @@
             fi
             ((iPCM++))
-            i_myear=$(echo "$i_myear + 1." | bc -l)
+            if [ $2 -ne 0 ]; then # Counting: PCM runs taken into account
+                i_myear=$(echo "$i_myear + 1." | bc -l)
+            fi
         else
             endlaunch
@@ -241,9 +246,10 @@
 # To make one cycle of PCM and PEM runs
 # arg1: launching mode
-# arg2: number of PCM runs to launch
-# arg3: local number of the PCM run from which to start (optional)
+# arg2: counting method
+# arg3: number of PCM runs to launch
+# arg4: local number of the PCM run from which to start (optional)
 cyclelaunch() {
     # PCM runs
-    submitPCM $1 $2 $3
+    submitPCM $1 $2 $3 $4
 
     # PEM run
@@ -292,4 +298,5 @@
 # To relaunch from PCM run
 # arg1: launching mode
+# arg2: counting method
 relaunchPCM() {
     iPCM=$(($irelaunch + 1))
@@ -310,4 +317,10 @@
         # PCM relaunch during the initialization cycle
         iPEM=1
+        if [ $2 -ne 0 ]; then # Counting: PCM runs taken into account
+            i_myear=$irelaunch
+        else # Counting: only PEM runs count
+            i_myear=0
+        fi
+        sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
         cleanfiles diags/diagpem .nc $(($iPEM - 1))
         cleanfiles diags/diagsoilpem .nc $(($iPEM - 1))
@@ -317,10 +330,8 @@
         cleanfiles starts/restartfi_postPEM .nc $(($iPEM - 1))
         cleanfiles starts/restartpem .nc $(($iPEM - 1))
-        i_myear=$irelaunch
-        sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
         rm -f startpem.nc
         if [ $irelaunch -eq $(($nPCM_ini - 1)) ]; then
             cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc
-            cyclelaunch $1 $nPCM_ini $iPCM
+            cyclelaunch $1 $2 $nPCM_ini $iPCM
         elif [ $irelaunch -eq $nPCM_ini ]; then
             cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc
@@ -328,5 +339,5 @@
             submitPEM $1 # The next job is a PEM run
         else
-            cyclelaunch $1 $nPCM_ini $iPCM
+            cyclelaunch $1 $2 $nPCM_ini $iPCM
         fi
     else
@@ -334,4 +345,10 @@
         iPEM=$(echo "($iPCM - $nPCM_ini)/$nPCM + 1" | bc)
         il=$(echo "($irelaunch - $nPCM_ini + 1)%$nPCM + 1" | bc)
+        if [ $2 -ne 0 ]; then # Counting: PCM runs taken into account
+            i_myear=$(($(awk "NR==$iPEM {print \$3}" "info_PEM.txt") + $il))
+        else # Counting: only PEM runs count
+            i_myear=$(awk "NR==$iPEM {print \$3}" "info_PEM.txt")
+        fi
+        sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
         cleanfiles diags/diagpem .nc $(($iPEM - 1))
         cleanfiles diags/diagsoilpem .nc $(($iPEM - 1))
@@ -343,18 +360,12 @@
         cp starts/restartpem$(($iPEM - 1)).nc startpem.nc
         if [ $il -eq $(($nPCM - 1)) ]; then # Second to last PCM run
-            i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $il))
-            sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
             cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc
-            cyclelaunch $1 $nPCM $il
+            cyclelaunch $1 $2 $nPCM $il
         elif [ $il -eq $nPCM ]; then # Last PCM run so the next job is a PEM run
-            i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $nPCM))
-            sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
             cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc
             cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc
             submitPEM $1
         else
-            i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $il))
-            sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
-            cyclelaunch $1 $nPCM $il
+            cyclelaunch $1 $2 $nPCM $il
         fi
     fi
@@ -363,8 +374,9 @@
 # To relaunch from PEM run
 # arg1: launching mode
+# arg2: counting method
 relaunchPEM() {
     iPEM=$(echo "$irelaunch + 1" | bc)
     iPCM=$(echo "$nPCM_ini + $nPCM*($irelaunch - 1) + 1" | bc)
-    i_myear=$(awk "NR==$(($iPEM + 1)) {print \$1}" "info_PEM.txt")
+    i_myear=$(awk "NR==$(($iPEM + 1)) {print \$3}" "info_PEM.txt")
     sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
     cleanfiles diags/diagfi .nc $(($iPCM - 1))
@@ -389,4 +401,4 @@
         cp starts/restart1D_postPEM${irelaunch}.txt start1D.txt
     fi
-    cyclelaunch $1 $nPCM
-}
+    cyclelaunch $1 $2 $nPCM
+}
