Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mesoipsl.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_ciclad.ksh	(revision 1541)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_mesoipsl.ksh	(revision 1558)
@@ -19,5 +19,5 @@
 
 #D-#==================================================
-#D-LibIGCM_sys for ciclad
+#D-LibIGCM_sys for IPSL ESPRI MESO cluster: spirit and spiritx
 #D-#==================================================
 #D-
@@ -72,5 +72,5 @@
 typeset PROJECT=NONE
 # jobWarningDelay in seconds
-typeset jobWarningDelay=${PBS_WALLTIME}
+#typeset jobWarningDelay=${PBS_WALLTIME}
 
 #D-
@@ -80,5 +80,5 @@
 
 # Submit command
-typeset SUBMIT=${SUBMIT:=qsub}
+typeset SUBMIT=${SUBMIT:=sbatch}
 # rsync with path
 typeset -r RSYNC=/usr/bin/rsync
@@ -91,5 +91,5 @@
 # Access to module command
 #====================================================
-. /usr/share/Modules/init/ksh
+. /etc/profile.d/modules.sh
 
 #====================================================
@@ -99,15 +99,12 @@
     IGCM_debug_Print 1 "Modules will be loaded later in IGCM_sys_activ_variables."
 else
-    if [ $CENTER == IPSL-ciclad ] ; then
-        # At ciclad
-        . /home/igcmg/MachineEnvironment/ciclad/atlas_env_ciclad 
-    else
-        # At climserv use the same files stored at ciclad but adapt the path
-	. /ciclad-home/igcmg/MachineEnvironment/climserv/atlas_env_climserv
+    if [ $CENTER == spirit ] ; then
+        # At spirit
+        . /home/igcmg/MachineEnvironment/mesoipsl/atlas_env_mesoipsl
+    elif [ $CENTER == spiritx ] ; then
+        # At spiritx
+	. /ciclad-home/igcmg/MachineEnvironment/mesoipsl/atlas_env_mesoipsl
     fi
 fi
-
-# Load python
-module load python/2.7-anaconda > /dev/null 2>&1
 
 [ ! X${TaskType} = Xchecking ] && IGCM_debug_Print 1 "List of loaded modules:"
@@ -118,8 +115,8 @@
 #====================================================
 # For rebuild
-if [ $CENTER == IPSL-ciclad ] ; then
-    export PATH=${PATH}:/home/igcmg/rebuild/src_X64_CICLAD/modipsl_v2_2_3_netcdf4.2/bin/
+if [ $CENTER == spirit ] ; then
+    export PATH=${PATH}:/home/igcmg/rebuild/spirit/modipsl/modeles/IOIPSL/bin/
 else
-    export PATH=${PATH}:/ciclad-home/igcmg/rebuild/src_X64_CICLAD/modipsl_v2_2_3_netcdf4.2/bin/
+    export PATH=${PATH}:/ciclad-home/igcmg/rebuild/spirit/modipsl/modeles/IOIPSL/bin/
 fi
 #====================================================
@@ -137,6 +134,6 @@
 #====================================================
 #- SUBMIT_DIR : submission dir
-if [ X${PBS_O_WORKDIR} != X ] ; then
-  typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${PBS_O_WORKDIR}}
+if [ X${SLURM_SUMBIT_DIR} != X ] ; then
+  typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${SLURM_SUBMIT_DIR}}
 else
   typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${PWD}}
@@ -148,18 +145,21 @@
 
 #====================================================
-#- RUN_DIR_PATH : Temporary working directory (=> TMP)
-if [ X${PBS_JOBID} != X ] ; then
-    if [ $CENTER == IPSL-ciclad ] ; then
-	typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/data/${LOGIN}/RUN_DIR/${PBS_JOBID}_${$}}
-    else
-	typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/homedata/${LOGIN}/RUN_DIR/${PBS_JOBID}_${$}}
-    fi
+#- RUN_DIR_PATH : Temporary working directory
+
+if [ $CENTER == spirit ] ; then
+    RUN_DIR_PATH=${RUN_DIR_PATH:=/scratchu/${LOGIN}/RUN_DIR}
 else
-  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/tmp/tmp$$}
+    RUN_DIR_PATH=${RUN_DIR_PATH:=/scratchx/${LOGIN}/RUN_DIR}
 fi
+if [ X${SLURM_JOBID} != X ] ; then
+    typeset -r RUN_DIR_PATH=${RUN_DIR_PATH}/${SLURM_JOBID}_${$}
+else
+    typeset -r RUN_DIR_PATH=${RUN_DIR_PATH}/${$}
+fi
 
 #====================================================
 #- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs
-typeset -r OUTCOMMAND_PATH=/tmp
+# Note that typeset -r can not be set at spirit because it sets the path as read-only
+typeset OUTCOMMAND_PATH=/tmp
 
 #====================================================
@@ -172,5 +172,5 @@
 
 #====================================================
-#- set PackDefault to false on ciclad
+#- set PackDefault to false on meso-ipsl 
 PackDefault=false
 
@@ -204,9 +204,9 @@
     #====================================================
     #- ARCHIVE (dedicated to large files)
-    if [ $CENTER == IPSL-ciclad ] ; then
-	# At ciclad
+    if [ $CENTER == spirit ] ; then
+	# At spirit
    	ARCHIVE=${ARCHIVE:=/data/${LOGIN}}
     else
-	# At climserv
+	# At spiritx
 	ARCHIVE=${ARCHIVE:=/homedata/${LOGIN}}
     fi
@@ -223,5 +223,5 @@
   fi
 
-  # ON CICLAD NO SPECIAL CASE WHEN X${config_UserChoices_SpaceName} = XTEST
+  # ON MESO-IPSL NO SPECIAL CASE WHEN X${config_UserChoices_SpaceName} = XTEST
 
   #====================================================
@@ -392,6 +392,6 @@
   fi
   typeset options status
-  options="-o ${SUBMIT_DIR}/${Script_Output}"
-  /usr/bin/qsub ${options} $1 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
+  options="-o ${SUBMIT_DIR}/${Script_Output} -e ${SUBMIT_DIR}/${Script_Output}"
+  /usr/bin/time sbatch ${options} $1 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
   status=$?
 
@@ -401,5 +401,5 @@
     IGCM_debug_Exit "IGCM_sys_Qsub"
   else
-    JobID=$( gawk {'print $1'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
+    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
   fi
   IGCM_debug_PopStack "IGCM_sys_Qsub"
@@ -417,6 +417,6 @@
   fi
   typeset options status
-  options="-o ${POST_DIR}/${Script_Post_Output}.out -v ${listVarEnv}"
-  /usr/bin/qsub ${options} ${libIGCM_POST}/$1.job > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
+  options="-o ${POST_DIR}/${Script_Post_Output}.out  -e ${POST_DIR}/${Script_Post_Output}.out"
+  sbatch ${options} ${libIGCM_POST}/$1.job > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
   status=$?
 
@@ -426,5 +426,5 @@
     IGCM_debug_Exit "IGCM_sys_QsubPost"
   else
-    JobID=$( gawk {'print $1'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
+    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
   fi
   IGCM_debug_PopStack "IGCM_sys_QsubPost"
@@ -792,10 +792,10 @@
   else
       IGCM_debug_Print 1 "IGCM_sys_active_variables : Default modules will be used"
-      if [ $CENTER == IPSL-ciclad ] ; then
-          # At ciclad
-	  EnvFile=/home/igcmg/.atlas_env_ciclad_ksh 
+      if [ $CENTER == spirit ] ; then
+          # At spirit
+	  EnvFile=/home/igcmg/MachineEnvironment/mesoipsl/atlas_env_mesoipsl
       else
-          # At climserv use the same files stored at ciclad but adapt the path
-	  EnvFile=/ciclad-home/igcmg/.atlas_env_ciclad_ksh
+          # At spirit
+	  EnvFile=/ciclad-home/igcmg/MachineEnvironment/mesoipsl/atlas_env_mesoipsl
       fi
   fi
@@ -804,6 +804,8 @@
   . ${EnvFile}
 
-  IGCM_debug_Print 1 "IGCM_sys_active_variables : Now loaded modules for ciclad/climserv. "
+
+  IGCM_debug_Print 1 "IGCM_sys_active_variables : Now loaded modules for meso-ipsl . "
   module list
+  
 
 # --------------------------------------------------------------------
@@ -868,8 +870,11 @@
   elif [ ${executionType} -eq 2 ] ; then
     # MPMD + MPI + OMP
-    sed -e "s/::openMPthreads::/${openMPthreads}/" \
-        -e "s/::JobNumProcTot::/${coreNumber}/"    \
-      ${file} > ${file}.tmp
-
+      (( nodeNumber = coreNumber / NB_CORE_PER_NODE ))
+      [ $(( ${coreNumber} % ${NB_CORE_PER_NODE} )) -ne 0 ] && (( nodeNumber = nodeNumber + 1 ))
+      sed -e "/::openMPthreads::/d"                 \
+        -e "s/::JobNumProcTot::/${mpiTasks}/"       \
+	-e "/ntasks/i\#SBATCH --nodes=${nodeNumber}"\
+        -e "/ntasks/i\#SBATCH --exclusive"          \
+         ${file} > ${file}.tmp
   elif [ ${executionType} -eq 3 ] ; then
     # SPMD + MPI/OMP
@@ -929,20 +934,22 @@
     echo "IGCM_sys_build_execution_scripts " $@
   fi
-
+  IGCM_debug_Print 1 "executionType= ${executionType}"
   EXECUTION=${HOST_MPIRUN_COMMAND}
 
-  # MPMD mode
   if ( ${OK_PARA_MPMD} ) ; then
 
-    # Only MPI (MPMD)
+    # MPMD mode
+    # 1 MPI only : executionType=1
+    # 2 MPI/OpenMP : executionType=2
+
+    if [ -f run_file ] ; then
+      IGCM_sys_Rm -f run_file
+    fi
+    touch run_file
+
+    # case 1 : Only MPI (MPMD)
     if  ( ! ${OK_PARA_OMP} ) ; then
-
-      if [ -f run_file ] ; then
-        IGCM_sys_Rm -f run_file
-      fi
-      touch run_file
-
       # Build run_file
-
+      current_core=0
       # First loop on the components for the coupler ie oasis (only if oasis3)
       # the coupler ie oasis3 must be the first one
@@ -952,25 +959,16 @@
         eval ExeNameOut=\${config_Executable_${comp}[1]}
 
-        # for CPL component only
-        if [ "X${comp}" = "XCPL" ]  && [ "X${ExeNameOut}" != X\"\" ] ; then
-          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
-          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
-          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file
-        fi
-      done
-
-      # Then second loop on the components
-      for comp in ${config_ListOfComponents[*]} ; do
-
-        eval ExeNameIn=\${config_Executable_${comp}[0]}
-        eval ExeNameOut=\${config_Executable_${comp}[1]}
-
-        # Only if we really have an executable for the component and not the coupler ie oasis:
-        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
-
+        # Only if the component has an executable
+        if ( [ "X${ExeNameOut}" != X\"\" ] ) ; then
+
+#          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+#          (( end_core = ${current_core} + ${comp_proc_mpi_loc} - 1 ))
+#          echo "${current_core}-${end_core} ./${ExeNameOut}" >> run_file
+#          (( current_core = ${end_core} + 1 ))
           eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
           eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
           echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
-        fi
+
+	fi
       done
 
@@ -982,33 +980,47 @@
         cat run_file
       fi
- 
+
+    else 
+
+    # 2 MPI/OpenMP : executionType=2
+
     # MPI-OpenMP (MPMD)
-    else
-
-      #  Hosts treatment
-      ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp
-
-      i=0
-      rm -f hosts
-      IGCM_debug_Print 1 "sys Ciclad, Hosts available :"
-      for nodes in `cat hosts.tmp` ; do
-        host[$i]=$nodes
-        echo "${host[$i]} slots=1 max_slots=1" >> hosts
-        IGCM_debug_Print 1 ${host[$i]}
-        i=$((i+1))
-      done
-      rm -f hosts.tmp
-
-      listnodes=${host[*]}
-
-      EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts"
-
-      # Initialisation
-      rank=0
-      current_core=0
-      core_per_node=8
-      init_exec=n
-
-      # Loop on the components
+    # export SLURM_HOSTFILE=./hostlist 
+    # srun --cpu-bind=none --distribution=arbitrary --multi-prog ./run_file
+    # example of  hostlist file :
+    # r3i3n33
+    # r3i3n33
+    # ...
+    # example of run_file :
+    # 0-70 ./prog_lmdz.x.sh %o %t
+    # 71-430 ./prog_opa.xx.sh %o %t
+    # 431-431 ./prog_xios.x.sh %o %t
+    # examples of prog_file :
+    # prog_lmdz.x.sh :
+    # (( init = 0 + $1 ))
+    # (( index = init * 10 ))
+    # (( slot = index % 40 ))
+    # taskset -c $slot-$((slot + 10 - 1)) ./script_lmdz.x.ksh
+    # that will become
+    # taskset -c 0-9 ./script_lmdz.x.ksh
+    # ...
+    # with script_lmdz.x.ksh
+    # export OMP_STACKSIZE=3g
+    # export OMP_PLACES=cores
+    # export OMP_NUM_THREADS=10
+    # ./lmdz.x > out_lmdz.x.out.${SLURM_PROCID} 2>out_lmdz.x.err.${SLURM_PROCID}
+
+    #  Hosts treatment
+    _bkIFS=$IFS;
+	IFS=$'\n'; set -f
+	listnodes=($(< <( scontrol show hostnames $SLURM_JOB_NODELIST )))
+	IFS=$_bkIFS; set +f
+	rm -f hostlist
+
+     # Loop on the components to build run_file and script_exec files
+	rank=0
+	current_core=0
+        current_core_mpi=0
+
       for comp in ${config_ListOfComponents[*]} ; do
 
@@ -1028,74 +1040,89 @@
           eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
           eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+          eval comp_proc_nod_loc=\${${comp}_PROC_NOD}
+     
+
+          # Build script files
 
           echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
           echo ""  >> script_${ExeNameOut}.ksh
           if [ ${comp_proc_omp_loc} -gt 1 ] ; then
-
-            # Check if the number of threads is correct
-            case ${comp_proc_omp_loc} in
-            2|4|8)
-              IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads"
-              ;;
-            *)
-              IGCM_debug_Exit "ERROR with OMP parameters !"
-              IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads"
-              IGCM_debug_Print 2 "Only 2,4,8 as number of OMP threads are possible "
-              IGCM_debug_Verif_Exit
-              ;;
-            esac
-            #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
-            #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
-            #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
-            echo "export OMP_STACKSIZE=200M" >> script_${ExeNameOut}.ksh 
-            echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
+          # Check if the number of threads is correct
+	      case ${comp_proc_omp_loc} in
+		  2|4|5|10|20)
+		      IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads"
+		      ;;
+		  *)
+		      IGCM_debug_Exit "ERROR with OMP parameters !"
+		      IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads"
+		      IGCM_debug_Print 2 "Only 2,4,5,10,20 as number of OMP threads are possible "
+		      IGCM_debug_Verif_Exit
+		      ;;
+	      esac
+            echo "export OMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
+            echo "export OMP_PLACES=cores"  >> script_${ExeNameOut}.ksh
+            echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}"  >> script_${ExeNameOut}.ksh
+
           fi
 
-          #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
-	  echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK )) " >> script_${ExeNameOut}.ksh
-	  echo "MYMPIRANK=\$(printf '%3.3d\n' \${MYMPIRANK})" >> script_${ExeNameOut}.ksh
-	  echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}" >> script_${ExeNameOut}.ksh
+          # to have out/err per process on different files
+          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${SLURM_PROCID} 2>out_${ExeNameOut}.err.\${SLURM_PROCID}" >> script_${ExeNameOut}.ksh
+
           IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
 
-          if [ ${init_exec} = y ] ; then
-            EXECUTION="${EXECUTION} : -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
+        # Build run_file
+        # Only if the component has an executable
+        if ( [ "X${ExeNameOut}" != X\"\" ] ) ; then
+
+          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+          (( end_core = ${current_core_mpi} + ${comp_proc_mpi_loc} - 1 ))
+          echo "${current_core_mpi}-${end_core} ./prog_${ExeNameOut}.sh %o %t" >> run_file
+          (( current_core_mpi = ${end_core} + 1 ))
+        fi
+
+          if [ ${comp_proc_nod_loc} -gt 1 ] ; then
+              (( offset_comp_proc_loc =  NB_CORE_PER_NODE / (comp_proc_mpi_loc / comp_proc_nod_loc) ))
           else
-            EXECUTION="${EXECUTION} -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
-            init_exec=y
+              (( offset_comp_proc_loc =  comp_proc_omp_loc ))
           fi
 
-          # Build rankfile : method used to assign cores and nodes for the MPI process
-          # Ex :
-          #rank 0=curie5296 slot=0,1,2,3
-          #rank 1=curie5296 slot=4,5,6,7
-          # Example of final command :
-          # mpirun -hostfile hosts -rankfile rankfile -np 27 ./script_lmdz.x.ksh : -np 5 ./script_opa.xx.ksh
-          # with script_lmdz.x.ksh :
-          # #!/bin/ksh
-          #export OMP_STACKSIZE=200M
-          #export OMP_NUM_THREADS=4
-          #./lmdz.x
+          # Build configuration file
+ 
+	      echo "#!/bin/sh" > prog_${ExeNameOut}.sh
+          echo "(( init = $current_core + \$1 ))" >> prog_${ExeNameOut}.sh
+          echo "(( index = init * $comp_proc_omp_loc ))" >> prog_${ExeNameOut}.sh
+          echo "(( slot = index % 40 ))" >> prog_${ExeNameOut}.sh
+	      echo "echo ${ExeNameOut} taskset -c \$slot"-"\$((slot + $comp_proc_omp_loc - 1))" >> prog_${ExeNameOut}.sh
+          echo "taskset -c \$slot"-"\$((slot + $comp_proc_omp_loc - 1)) ./script_${ExeNameOut}.ksh" >> prog_${ExeNameOut}.sh
+
+          IGCM_sys_Chmod u+x prog_${ExeNameOut}.sh
+
+        # Build hostlist file
 
           for nb_proc_mpi in `seq 0 $(($comp_proc_mpi_loc-1))`; do
-            (( index_host = current_core / core_per_node ))
-            host_value=${host[${index_host}]}
-            (( slot =  current_core % core_per_node ))
-            virg=","
-            string_final=""
-            for index in `seq $slot $(($slot+$comp_proc_omp_loc-1))`; do
-              string=$index$virg
-              string_final=$string_final$string
-            done
-            string_final=$( echo $string_final | sed "s/.$//" )
-            echo "rank $rank=$host_value slot=$string_final" >> rankfile
-            (( rank = rank + 1 ))
-            (( current_core = current_core + comp_proc_omp_loc ))
+             (( index_host = current_core / NB_CORE_PER_NODE ))
+             host_value=${listnodes[${index_host}]}
+               echo "$host_value" >> hostlist
+             (( current_core = current_core + offset_comp_proc_loc ))
           done
         fi
       done
-    fi
-
-  # Only one executable (SPMD mode).
+
+      ## variable added to stop after 60s instead of 600s by default. 
+      ## This is used when no error comes from executables and when something stopped an executable without notice. 
+      export SLURM_WAIT=60
+
+      EXECUTION="${HOST_MPIRUN_COMMAND} --cpu-bind=none --distribution=arbitrary --multi-prog ./run_file"
+
+      IGCM_sys_Chmod u+x run_file
+      if ( $DEBUG_sys ) ; then
+        echo "run_file contains : "
+        cat run_file
+      fi
+
+    fi # if ${OK_PARA_MPMD}
+
   else
+  # Only one executable (SPMD mode):  executionType=3, 4, 5 and 6
 
     for comp in ${config_ListOfComponents[*]} ; do
@@ -1105,28 +1132,37 @@
       if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
 
+        # Build script files
+
         echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
         echo ""  >> script_${ExeNameOut}.ksh
+        IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+
         if ( ${OK_PARA_OMP} ) ; then
-          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
-          echo "export OMP_STACKSIZE=200M" >> script_${ExeNameOut}.ksh
-          echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
+            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+	    # Check if the number of threads is correct
+	    case ${comp_proc_omp_loc} in
+		2|4|5|10|20)
+		    IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads"
+		    ;;
+		*)
+		    IGCM_debug_Exit "ERROR with OMP parameters !"
+		    IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads"
+		    IGCM_debug_Print 2 "Only 2,4,5,10,20 as number of OMP threads are possible "
+		    IGCM_debug_Verif_Exit
+		    ;;
+	    esac 
+            echo ""  >> script_${ExeNameOut}.ksh
+            echo "export OMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
+            echo "export OMP_PLACES=cores"  >> script_${ExeNameOut}.ksh
+            echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
         fi
-        if  ( ${OK_PARA_MPI} ) ; then
-          # Default : mpirun used if nb_proc gt 1
-          # pour sortie out/err par process
-          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}"  >> script_${ExeNameOut}.ksh
-          #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
-          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
-          EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh"
-        else
-          # Default : mpirun is NOT used if nb_proc eq 1
-          # pour sortie out/err par process
-          echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
-          #echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
-          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
-          EXECUTION="time ./script_${ExeNameOut}.ksh"
-        fi
-
-        IGCM_debug_Print 1 "sys Ciclad : script_${ExeNameOut}.ksh contains"
+
+        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+        
+        # To have out/err per process on different files
+        echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${SLURM_PROCID} 2>out_${ExeNameOut}.err.\${SLURM_PROCID}"  >> script_${ExeNameOut}.ksh
+        EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh"
+
+        IGCM_debug_Print 1 "sys Jean-Zay : script_${ExeNameOut}.ksh contains"
         cat script_${ExeNameOut}.ksh
 
@@ -1135,7 +1171,7 @@
     done
 
-  fi
-
-  IGCM_debug_Print 1 "sys Ciclad : execution command is"
+  fi # ${OK_PARA_MPMD}
+
+  IGCM_debug_Print 1 "sys meso-ipsl : execution command is "
   IGCM_debug_Print 1 "$EXECUTION"
 
