Index: trunk/LMDZ.COMMON/libf/evolution/changelog.txt
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/changelog.txt	(revision 3389)
+++ trunk/LMDZ.COMMON/libf/evolution/changelog.txt	(revision 3391)
@@ -392,2 +392,5 @@
 == 25/06/2024 == JBC
 Correction to r3387 for the time limit stopping criterion.
+
+== 02/07/2024 == JBC
+Addition of the possiblity to launch the 1D model in the launching script + correction of small errors.
Index: trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job	(revision 3391)
+++ trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job	(revision 3391)
@@ -0,0 +1,67 @@
+#!/bin/bash
+#SBATCH --job-name=jobPCM0
+#SBATCH --account=cin0391
+### GENOA nodes accommodate 96 cores
+#SBATCH --constraint=GENOA
+### Number of Nodes to use
+#SBATCH --nodes=1
+#SBATCH --ntasks-per-node=24
+#SBATCH --cpus-per-task=4
+#SBATCH --threads-per-core=1 # --hint=nomultithread
+###SBATCH --exclusive
+#SBATCH --output=jobPCM_%A.out
+#SBATCH --time=12:00:00
+
+# A few parameters that might need to be changed depending on your setup
+# Path to the arch.env to source:
+source ../trunk/LMDZ.COMMON/arch.env
+
+# Number of threads to use (must be the same as '#MSUB -c' above)
+export OMP_NUM_THREADS=4
+export OMP_STACKSIZE=400M
+
+# Name of executable for the PCM:
+exePCM="gcm_64x48x32_phymars_para.e"
+########################################################################
+
+# Running the PCM
+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
+srun --cpu-bind=threads --label -c${OMP_NUM_THREADS:=1} $exePCM > out_runPCM${iPCM} 2>&1
+if [ ! -f "restartfi.nc" ] || ! (tail -n 1 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\"."
+    exit 1
+fi
+
+# Copy data files and prepare the next run
+mv out_runPCM${iPCM} out_PCM/run${iPCM}
+if [ -f "diagfi.nc" ]; then
+    mv diagfi.nc diags/diagfi${iPCM}.nc
+fi
+if [ -f "diagsoil.nc" ]; then
+    mv diagsoil.nc diags/diagsoil${iPCM}.nc
+fi
+if [ -f "stats.nc" ]; then
+    mv stats.nc diags/stats${iPCM}.nc
+fi
+k=0
+if [ $(echo "$k < 1" | bc -l) -eq 1 ]; then # Only the last 2 years are taken for the PEM
+    mv Xdiurnalave.nc diags/data2reshape${iPCM}.nc
+else
+    cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
+    mv Xdiurnalave.nc data2reshape_Y${k}.nc
+fi
+cp restartfi.nc starts/restartfi${iPCM}.nc
+mv restartfi.nc startfi.nc
+if [ -f "restart.nc" ]; then
+    cp restart.nc starts/restart${iPCM}.nc
+    mv restart.nc start.nc
+elif [ -f "restart1D.txt" ]; then
+    cp restart1D.txt starts/restart1D${iPCM}.txt
+    mv restart1D.txt start1D.txt
+fi
+((iPCM++))
+((i_myear++))
+sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
Index: trunk/LMDZ.COMMON/libf/evolution/deftank/PEMrun.job
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/PEMrun.job	(revision 3391)
+++ trunk/LMDZ.COMMON/libf/evolution/deftank/PEMrun.job	(revision 3391)
@@ -0,0 +1,71 @@
+#!/bin/bash
+#SBATCH --job-name=jobPEM1
+#SBATCH --account=cin0391
+### GENOA nodes accommodate 96 cores
+#SBATCH --constraint=GENOA
+### Number of Nodes to use
+#SBATCH --nodes=4 # to run with enough memory
+#SBATCH --ntasks-per-node=1
+#SBATCH --cpus-per-task=1
+#SBATCH --threads-per-core=1 # --hint=nomultithread
+###SBATCH --exclusive
+#SBATCH --output=jobPEM_%A.out
+#SBATCH --time=24:00:00
+
+# A few parameters that might need to be changed depending on your setup
+# Path to the arch.env to source:
+source ../trunk/LMDZ.COMMON/arch.env
+
+# Name of executable for the PEM:
+exePEM="pem_64x48x32_phymars_seq.e"
+
+# Name of executable for reshaping PCM data with XIOS:
+exeReshape="reshape_XIOS_output_64x48x32_phymars_seq.e"
+########################################################################
+
+
+# Reshaping PCM data with XIOS
+echo "Reshaping PCM data with XIOS is starting."
+./$exeReshape
+if [ ! -f "data_PCM_Y1.nc" ] || [ ! -f "data_PCM_Y2.nc" ]; then # Check if it ended abnormally
+    echo "Error: the reshaping executable crashed!"
+    exit 1
+fi
+
+# Running the PEM
+echo "Run PEM $iPEM is starting."
+read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
+cp run_PEM.def run.def
+./$exePEM $SLURM_JOB_ID > out_runPEM${iPEM} 2>&1
+if [ ! -f "restartfi.nc" ] || ! (tail -n 1 out_runPEM${iPEM} | grep -iq "so far, so good!"); then # Check if it ended abnormally
+    echo "Error: the run PEM $iPEM crashed!"
+    exit 1
+fi
+
+# Copy data files and prepare the next run
+mv out_runPEM${iPEM} out_PEM/run${iPEM}
+if [ -f "diagpem.nc" ]; then
+    mv diagpem.nc diags/diagpem${iPEM}.nc
+fi
+if [ -f "diagsoilpem.nc" ]; then
+    mv diagsoilpem.nc diags/diagsoilpem${iPEM}.nc
+fi
+cp restartpem.nc starts/restartpem${iPEM}.nc
+mv restartpem.nc startpem.nc
+cp restartfi.nc starts/restartfi_postPEM${iPEM}.nc
+mv restartfi.nc startfi.nc
+if [ -f "restart.nc" ]; then
+    cp restart.nc starts/restart_postPEM${iPEM}.nc
+    mv restart.nc start.nc
+elif [ -f "restart1D.txt" ]; then
+    cp restart1D.txt starts/restart1D_postPEM${iPEM}.txt
+    mv restart1D.txt start1D.txt
+fi
+
+# Launch the next cycle
+#if [ "$(awk 'END{print $NF}' info_PEM.txt)" -eq 7 ]; then
+#    read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
+#    ./launchPEM.sh cont # Continue the PEM run if it stopped because of job time limit
+#else
+    ./launchPEM.sh new
+#fi
Index: trunk/LMDZ.COMMON/libf/evolution/deftank/jobPCM.slurm
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/jobPCM.slurm	(revision 3389)
+++ 	(revision )
@@ -1,67 +1,0 @@
-#!/bin/bash
-#SBATCH --job-name=jobPCM0
-#SBATCH --account=cin0391
-### GENOA nodes accommodate 96 cores
-#SBATCH --constraint=GENOA
-### Number of Nodes to use
-#SBATCH --nodes=1
-#SBATCH --ntasks-per-node=24
-#SBATCH --cpus-per-task=4
-#SBATCH --threads-per-core=1 # --hint=nomultithread
-###SBATCH --exclusive
-#SBATCH --output=jobPCM_%A.out
-#SBATCH --time=12:00:00
-
-# A few parameters that might need to be changed depending on your setup
-# Path to the arch.env to source:
-source ../trunk/LMDZ.COMMON/arch.env
-
-# Number of threads to use (must be the same as '#MSUB -c' above)
-export OMP_NUM_THREADS=4
-export OMP_STACKSIZE=400M
-
-# Name of executable for the PCM:
-exePCM="gcm_64x48x32_phymars_para.e"
-########################################################################
-
-# Running the PCM
-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
-srun --cpu-bind=threads --label -c${OMP_NUM_THREADS:=1} $exePCM > out_runPCM${iPCM} 2>&1
-if [ ! -f "restartfi.nc" ] || ! (tail -n 1 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\"."
-    exit 1
-fi
-
-# Copy data files and prepare the next run
-mv out_runPCM${iPCM} out_PCM/run${iPCM}
-if [ -f "diagfi.nc" ]; then
-    mv diagfi.nc diags/diagfi${iPCM}.nc
-fi
-if [ -f "diagsoil.nc" ]; then
-    mv diagsoil.nc diags/diagsoil${iPCM}.nc
-fi
-if [ -f "stats.nc" ]; then
-    mv stats.nc diags/stats${iPCM}.nc
-fi
-k=0
-if [ $(echo "$k < 1" | bc -l) -eq 1 ]; then # Only the last 2 years are taken for the PEM
-    mv Xdiurnalave.nc diags/data2reshape${iPCM}.nc
-else
-    cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
-    mv Xdiurnalave.nc data2reshape_Y${k}.nc
-fi
-cp restartfi.nc starts/restartfi${iPCM}.nc
-mv restartfi.nc startfi.nc
-if [ -f "restart.nc" ]; then
-    cp restart.nc starts/restart${iPCM}.nc
-    mv restart.nc start.nc
-elif [ -f "restart1D.txt" ]; then
-    cp restart1D.txt starts/restart1D${iPCM}.txt
-    mv restart1D.txt start1D.txt
-fi
-((iPCM++))
-((i_myear++))
-sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
Index: trunk/LMDZ.COMMON/libf/evolution/deftank/jobPEM.slurm
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/jobPEM.slurm	(revision 3389)
+++ 	(revision )
@@ -1,71 +1,0 @@
-#!/bin/bash
-#SBATCH --job-name=jobPEM1
-#SBATCH --account=cin0391
-### GENOA nodes accommodate 96 cores
-#SBATCH --constraint=GENOA
-### Number of Nodes to use
-#SBATCH --nodes=4 # to run with enough memory
-#SBATCH --ntasks-per-node=1
-#SBATCH --cpus-per-task=1
-#SBATCH --threads-per-core=1 # --hint=nomultithread
-###SBATCH --exclusive
-#SBATCH --output=jobPEM_%A.out
-#SBATCH --time=24:00:00
-
-# A few parameters that might need to be changed depending on your setup
-# Path to the arch.env to source:
-source ../trunk/LMDZ.COMMON/arch.env
-
-# Name of executable for the PEM:
-exePEM="pem_64x48x32_phymars_seq.e"
-
-# Name of executable for reshaping PCM data with XIOS:
-exeReshape="reshape_XIOS_output_64x48x32_phymars_seq.e"
-########################################################################
-
-
-# Reshaping PCM data with XIOS
-echo "Reshaping PCM data with XIOS is starting."
-./$exeReshape
-if [ ! -f "data_PCM_Y1.nc" ] || [ ! -f "data_PCM_Y2.nc" ]; then # Check if it ended abnormally
-    echo "Error: the reshaping executable crashed!"
-    exit 1
-fi
-
-# Running the PEM
-echo "Run PEM $iPEM is starting."
-read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
-cp run_PEM.def run.def
-./$exePEM $SLURM_JOB_ID > out_runPEM${iPEM} 2>&1
-if [ ! -f "restartfi.nc" ] || ! (tail -n 1 out_runPEM${iPEM} | grep -iq "so far, so good!"); then # Check if it ended abnormally
-    echo "Error: the run PEM $iPEM crashed!"
-    exit 1
-fi
-
-# Copy data files and prepare the next run
-mv out_runPEM${iPEM} out_PEM/run${iPEM}
-if [ -f "diagpem.nc" ]; then
-    mv diagpem.nc diags/diagpem${iPEM}.nc
-fi
-if [ -f "diagsoilpem.nc" ]; then
-    mv diagsoilpem.nc diags/diagsoilpem${iPEM}.nc
-fi
-cp restartpem.nc starts/restartpem${iPEM}.nc
-mv restartpem.nc startpem.nc
-cp restartfi.nc starts/restartfi_postPEM${iPEM}.nc
-mv restartfi.nc startfi.nc
-if [ -f "restart.nc" ]; then
-    cp restart.nc starts/restart_postPEM${iPEM}.nc
-    mv restart.nc start.nc
-elif [ -f "restart1D.txt" ]; then
-    cp restart1D.txt starts/restart1D_postPEM${iPEM}.txt
-    mv restart1D.txt start1D.txt
-fi
-
-# Launch the next cycle
-#if [ "$(awk 'END{print $NF}' info_PEM.txt)" -eq 7 ]; then
-#    read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
-#    ./launchPEM.sh cont # Continue the PEM run if it stopped because of job time limit
-#else
-    ./launchPEM.sh new
-#fi
Index: trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh	(revision 3389)
+++ trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh	(revision 3391)
@@ -22,4 +22,7 @@
 # Set the number of PCM runs between each PEM run:
 nPCM=2
+
+# Set the dimension of the model (1 = "1D"; other values = "3D"):
+dim=3
 ########################################################################
 
@@ -45,5 +48,5 @@
     checklaunch
     initlaunch
-    cyclelaunch $nPCM_ini
+    cyclelaunch $dim $nPCM_ini
 
 else
@@ -55,5 +58,5 @@
         date
         read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
-        cyclelaunch $nPCM
+        cyclelaunch $dim $nPCM
 
     # Starting a relaunch
@@ -113,7 +116,7 @@
         sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
         if [ $relaunch = "PCM" ]; then
-            relaunchPCM
+            relaunchPCM $dim
         else
-            relaunchPEM
+            relaunchPEM $dim
         fi
 
@@ -124,5 +127,5 @@
         echo "This is a continuation of the previous PEM run."
         date
-        submitPEM
+        submitPEM $dim
 
     # Default case: error
Index: trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh
===================================================================
--- trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh	(revision 3389)
+++ trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh	(revision 3391)
@@ -26,5 +26,5 @@
 # To check if SLURM is the job scheduler
 function is_slurm() {
-    if [ ! -x $(command -v squeue) ]; then
+    if ! command -v squeue &> /dev/null; then
         echo "Error: the job scheduler is not SLURM on $machine!"
         echo "You need to adapt the script to your case."
@@ -39,5 +39,7 @@
     LC_NUMERIC=en_US.UTF-8
 
-    is_slurm
+    if [ $dim -ne 1 ]; then # 3D model works only with SLURM for now (because of time limit)
+        islurm
+    fi
     if [ -v n_mars_years ] && [ ! -z "$n_mars_years" ]; then
         if [ $n_mars_years -lt 1 ]; then
@@ -62,10 +64,10 @@
         errlaunch
     fi
-    if [ ! -f "jobPCM.slurm" ]; then
-        echo "Error: file \"jobPCM.slurm\" does not exist in $dir!"
-        errlaunch
-    fi
-    if [ ! -f "jobPEM.slurm" ]; then
-        echo "Error: file \"$jobPEM.slurm\" does not exist in $dir!"
+    if [ ! -f "PCMrun.job" ]; then
+        echo "Error: file \"PCMrun.job\" does not exist in $dir!"
+        errlaunch
+    fi
+    if [ ! -f "PEMrun.job" ]; then
+        echo "Error: file \"PEMrun.job\" does not exist in $dir!"
         errlaunch
     fi
@@ -142,22 +144,28 @@
 
 # To submit the PCM runs
-# arg1: number of PCM runs to launch
-# arg2: local number of the PCM run from which to start (optional)
+# arg1: model dimension
+# arg2: number of PCM runs to launch
+# arg3: local number of the PCM run from which to start (optional)
 submitPCM() {
-    find . -type f -name "jobPCM*.slurm" ! -name "jobPCM.slurm" -delete
+    find . -type f -name "PCMrun*.job" ! -name "PCMrun.job" -delete
     ii=1
-    if [ ! -z $2 ]; then
-        ii=$2
+    if [ ! -z $3 ]; then
+        ii=$3
     fi
     if [ $i_myear -lt $n_myear ]; then
-        echo "Run PCM $iPCM: call $ii/$1..."
-        cp jobPCM.slurm jobPCM${iPCM}.slurm
-        sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPCM}/" jobPCM${iPCM}.slurm
-        sed -i "s/^k=[0-9]\+$/k=$(echo "3 - $nPCM_ini" | bc -l)/" jobPCM${iPCM}.slurm
-        jobID=$(sbatch --parsable jobPCM${iPCM}.slurm)
-        # Create a file to cancel the dependent jobs of the cycle
-        echo "#!/bin/bash" > kill_launchPEM.sh
-        chmod +x kill_launchPEM.sh
-        echo "scancel" $jobID >> kill_launchPEM.sh
+        echo "Run PCM $iPCM: call $ii/$2..."
+        if [ $1 -eq 1 ]; then # 1D model
+            sed -i "s/^k=[0-9]\+$/k=$(echo "3 - $nPCM_ini" | bc -l)/" PCMrun.job
+            ./PCMrun.job
+        else # 3D model
+            cp PCMrun.job PCMrun${iPCM}.job
+            sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPCM}/" PCMrun${iPCM}.job
+            sed -i "s/^k=[0-9]\+$/k=$(echo "3 - $nPCM_ini" | bc -l)/" PCMrun${iPCM}.job
+            jobID=$(sbatch --parsable PCMrun${iPCM}.job)
+            # Create a file to cancel the dependent jobs of the cycle
+            echo "#!/bin/bash" > kill_launchPEM.sh
+            chmod +x kill_launchPEM.sh
+            echo "scancel" $jobID >> kill_launchPEM.sh
+        fi
         ((iPCM++))
         ((i_myear++))
@@ -166,12 +174,17 @@
         endlaunch
     fi
-    for ((i = $ii; i <= $1; i++)); do
+    for ((i = $ii; i <= $2; i++)); do
         if [ $i_myear -lt $n_myear ]; then
-            echo "Run PCM $iPCM: call $i/$1..."
-            cp jobPCM.slurm jobPCM${iPCM}.slurm
-            sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPCM}/" jobPCM${iPCM}.slurm
-            sed -i "s/^k=[0-9]\+$/k=$(echo "$i + 2 - $nPCM_ini" | bc -l)/" jobPCM${iPCM}.slurm
-            jobID=$(sbatch --parsable --dependency=afterok:${jobID} jobPCM${iPCM}.slurm)
-            echo "scancel" $jobID >> kill_launchPEM.sh
+            echo "Run PCM $iPCM: call $i/$2..."
+            if [ $1 -eq 1 ]; then # 1D model
+                sed -i "s/^k=[0-9]\+$/k=$(echo "$i + 2 - $nPCM_ini" | bc -l)/" PCMrun.job
+                ./PCMrun.job
+            else # 3D model
+                cp PCMrun.job PCMrun${iPCM}.job
+                sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPCM}/" PCMrun${iPCM}.job
+                sed -i "s/^k=[0-9]\+$/k=$(echo "$i + 2 - $nPCM_ini" | bc -l)/" PCMrun${iPCM}.job
+                jobID=$(sbatch --parsable --dependency=afterok:${jobID} PCMrun${iPCM}.job)
+                echo "scancel" $jobID >> kill_launchPEM.sh
+            fi
             ((iPCM++))
             ((i_myear++))
@@ -183,13 +196,18 @@
 
 # To submit the PEM run
+# arg1: model dimension
 submitPEM() {
     if [ $i_myear -lt $n_myear ]; then
         echo "Run PEM $iPEM"
-        sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPEM}/" jobPEM.slurm
-        jobID=$(sbatch --parsable jobPEM.slurm)
-        # Create a file to cancel the dependent jobs of the cycle
-        echo "#!/bin/bash" > kill_launchPEM.sh
-        chmod +x kill_launchPEM.sh
-        echo "scancel" $jobID >> kill_launchPEM.sh
+        if [ $1 -eq 1 ]; then # 1D model
+            ./PEMrun.job
+        else # 3D model
+            sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPEM}/" PEMrun.job
+            jobID=$(sbatch --parsable PEMrun.job)
+            # Create a file to cancel the dependent jobs of the cycle
+            echo "#!/bin/bash" > kill_launchPEM.sh
+            chmod +x kill_launchPEM.sh
+            echo "scancel" $jobID >> kill_launchPEM.sh
+        fi
     else
         endlaunch
@@ -198,16 +216,21 @@
 
 # To make one cycle of PCM and PEM runs
-# arg1: number of PCM runs to launch
-# arg2: local number of the PCM run from which to start (optional)
+# arg1: model dimension
+# arg2: number of PCM runs to launch
+# arg3: local number of the PCM run from which to start (optional)
 cyclelaunch() {
     # PCM runs
-    submitPCM $1 $2
+    submitPCM $1 $2 $3
 
     # PEM run
     if [ $i_myear -lt $n_myear ]; then
         echo "Run PEM $iPEM"
-        sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPEM}/" jobPEM.slurm
-        jobID=$(sbatch --parsable --dependency=afterok:${jobID} jobPEM.slurm)
-        echo "scancel" $jobID >> kill_launchPEM.sh
+        if [ $1 -eq 1 ]; then # 1D model
+            ./PEMrun.job
+        else # 3D model
+            sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPEM}/" PEMrun.job
+            jobID=$(sbatch --parsable --dependency=afterok:${jobID} PEMrun.job)
+            echo "scancel" $jobID >> kill_launchPEM.sh
+        fi
     else
         endlaunch
@@ -241,4 +264,5 @@
 
 # To relaunch from PCM run
+# arg1: model dimension
 relaunchPCM() {
     iPCM=$(($irelaunch + 1))
@@ -269,11 +293,11 @@
         if [ $irelaunch -eq $(($nPCM_ini - 1)) ]; then
             cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc
-            cyclelaunch $nPCM_ini $irelaunch
+            cyclelaunch $1 $nPCM_ini $iPCM
         elif [ $irelaunch -eq $nPCM_ini ]; then
             cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc
             cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc
-            submitPEM # The next job is a PEM run
+            submitPEM $1 # The next job is a PEM run
         else
-            cyclelaunch $nPCM_ini $iPCM
+            cyclelaunch $1 $nPCM_ini $iPCM
         fi
     else
@@ -292,5 +316,5 @@
             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 $nPCM $il
+            cyclelaunch $1 $nPCM $il
         elif [ $il -eq 0 ]; then
             i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $nPCM))
@@ -298,9 +322,9 @@
             cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc
             cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc
-            submitPEM # The next job is a PEM run
+            submitPEM $1 # The next job is a PEM run
         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 $nPCM $il
+            cyclelaunch $1 $nPCM $il
         fi
     fi
@@ -308,4 +332,5 @@
 
 # To relaunch from PEM run
+# arg1: model dimension
 relaunchPEM() {
     iPEM=$irelaunch
@@ -332,4 +357,4 @@
         cp starts/restart1D_postPEM${irelaunch}.txt start1D.txt
     fi
-    cyclelaunch $nPCM
-}
+    cyclelaunch $1 $nPCM
+}
