Index: /branches/libIGCM_MPI_OpenMP/libIGCM_config/libIGCM_config.ksh
===================================================================
--- /branches/libIGCM_MPI_OpenMP/libIGCM_config/libIGCM_config.ksh	(revision 555)
+++ /branches/libIGCM_MPI_OpenMP/libIGCM_config/libIGCM_config.ksh	(revision 556)
@@ -538,14 +538,17 @@
     fi
 
-    typeset ExeNameIn
+    typeset ExeNameIn ExeNameFirst CompNameFirst
     typeset comp i
-    typeset tempvar tempvarMPI tempvarNOD NbElts j
+    typeset tempvar tempvarMPI tempvarNOD NbElts j NbExec
 
     (( PROCESSUS_NUMBER = 0 ))
     (( i=0 ))
+    (( NbExec=0 ))
 
     OK_PARA_MPI=false
     OK_PARA_OMP=false
     OK_PARA_NOD=false
+    OK_PARA_MPMD=false
+
     for comp in ${config_ListOfComponents[*]} ; do
 
@@ -568,10 +571,21 @@
 	# Only if we really have an executable for the component :
 	if [ X${ExeNameIn} != X\"\" ] ; then
+
+	    # Keep the first executable found and the first CompName
+	    ExeNameFirst=${ExeNameIn}
+	    CompNameFirst=${comp}
+
+	    # Are we a second executable?
+	    (( NbExec = NbExec + 1 ))
+
+	    # set 1 MPI task, 1 OpenMP thread and 1 node as default
+	    eval ${comp}_PROC_MPI=1
+	    eval ${comp}_PROC_OMP=1
+	    eval ${comp}_PROC_NOD=1
+
 	    eval NbElts=\${#config_Executable_${comp}[@]}
+
 	    if [ ${NbElts} -ge 2 ] ; then
 		(( j = 2 ))
-		eval ${comp}_PROC_MPI=1
-		eval ${comp}_PROC_OMP=1
-		eval ${comp}_PROC_NOD=1
 
 		while [ $j -lt ${NbElts} ] ; do 
@@ -591,13 +605,13 @@
 
 		    case ${tempvar} in
-			*MPI)
+			*[mM][pP][iI]*)
                             # Read MPI parameter for composante
 			    eval ${comp}_PROC_MPI=$( echo ${tempvar} | sed -e "s/MPI//" )
 			    OK_PARA_MPI=true;;
-			*OMP)
+			*[oO][mM][pP]*)
                             # Read OMP parameter for composante
 			    eval ${comp}_PROC_OMP=$( echo ${tempvar} | sed -e "s/OMP//" )
 			    OK_PARA_OMP=true;;
-			*NOD)
+			*[nN][oO][dD]*)
                             # Read NOD (NumBer of Nodes) parameter for composante
 			    eval ${comp}_PROC_NOD=$( echo ${tempvar} | sed -e "s/NOD//" )
@@ -609,9 +623,12 @@
 		done
 
-		eval tempvarMPI=\${${comp}_PROC_MPI}
-		eval tempvarNOD=\${${comp}_PROC_NOD}
-		eval tempvarOMP=\${${comp}_PROC_OMP}
-		(( PROCESSUS_NUMBER = PROCESSUS_NUMBER + tempvarMPI * tempvarNOD * tempvarOMP ))
  	    fi
+
+	    eval tempvarMPI=\${${comp}_PROC_MPI}
+	    eval tempvarNOD=\${${comp}_PROC_NOD}
+	    eval tempvarOMP=\${${comp}_PROC_OMP}
+
+	    (( PROCESSUS_NUMBER = PROCESSUS_NUMBER + tempvarMPI * tempvarNOD * tempvarOMP ))
+
 	fi
 
@@ -619,43 +636,61 @@
     done
 
-    # sequential case !
-    if [ ${PROCESSUS_NUMBER} -eq 0 ] ; then
-	(( PROCESSUS_NUMBER = 1 ))
-	echo "PROCESSUS_NUMBER is all 0 (sequential use of old definition in config->Executable->list)."
-	echo "We set it to 1."
-    fi
-
-    IGCM_debug_Print 1 "MPI/OMP treatment PROCESSUS_NUMBER = ${PROCESSUS_NUMBER}"
-
-    # Verification with PBS parameter
+    # set MPMD mode if more than 2 executable names.
+    [ ${NbExec} -ge 2 ] && OK_PARA_MPMD=true
+
+    # Verification of BATCH_NUM_PROC_TOT total number of processors set in job header.
     if [ X${BATCH_NUM_PROC_TOT} != X ] ; then
-	if [ ${BATCH_NUM_PROC_TOT} -ne ${PROCESSUS_NUMBER} ] ; then
-	    echo "Warning with parallelization parameters !"
-	    echo "PBS variable BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} "
-	    echo " is the total number of _processors_ reserved."
-	    echo "It is not equal to the sum of _processus_ in config.card = ${PROCESSUS_NUMBER}."
-	fi
+	# BATCH_NUM_PROC_TOT is set
 	if ( ! ${OK_PARA_MPI} ) ; then
+	    # with previous method.
 	    if [ ${BATCH_NUM_PROC_TOT} -gt 1 ] ; then
-		echo "You have given a reservation of ${BATCH_NUM_PROC_TOT} processors,"
-		echo "but you havn't filled the parallel parameter in config->Executable->list."
-		echo "This is the old method and it is no more supported."
-		echo "Please read documentation or config specific comments."
-		echo "We stop now."
-		exit 1
+		# with more than 1 proc
+		if ( ${OK_PARA_MPMD} ) ; then
+		     # with MPMD ie CPL/oasis method
+		     echo "We will use default number of MPI tasks : 5 for OCE, 1 for CPL and 26 for ATM for coupled configuration"
+		     OK_PARA_MPI=true
+		     CPL_PROC_MPI=1
+		     OCE_PROC_MPI=5
+		     ATM_PROC_MPI=26
+		     PROCESSUS_NUMBER=32
+		else
+		     # with have only one executable
+		     echo "We will use ${BATCH_NUM_PROC_TOT} MPI tasks for ${CompNameFirst} : ${config_Executable_Name} "
+		     OK_PARA_MPI=true
+		     eval ${CompNameFirst}_PROC_MPI=${BATCH_NUM_PROC_TOT}
+		     PROCESSUS_NUMBER=${BATCH_NUM_PROC_TOT}
+		fi
 	    else 
 		PROCESSUS_NUMBER=1
 	    fi
 	fi
-    else
+	# Verification with PBS parameter
+        if [ ${BATCH_NUM_PROC_TOT} -ne ${PROCESSUS_NUMBER} ] ; then
+            echo "Warning with parallelization parameters !"
+            echo "Job header variable BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} "
+            echo "is the total number of _processors_ reserved."
+            echo "It is not equal to the sum of _processus_  = ${PROCESSUS_NUMBER}."
+	    echo "We stop now."
+	    exit 1
+        fi
+
+    else # BATCH_NUM_PROC_TOT=""
 	if ( ${OK_PARA_MPI} ) ; then
 	    echo "You have not given a value of ${BATCH_NUM_PROC_TOT} processors,"
 	    echo "but you have filled the parallel parameter in config->Executable->list."
-	    echo "This is the old method and it is no more supported."
-	    echo "Please read documentation or config specific comments."
+	    echo "Please add BATCH_NUM_PROC_TOT variable in job header."
 	    echo "We stop now."
 	    exit 1
-	fi
-    fi
+	else
+    	# sequential case !
+	    if [ ${PROCESSUS_NUMBER} -eq 0 ] ; then
+               (( PROCESSUS_NUMBER = 1 ))
+               echo "PROCESSUS_NUMBER is all 0 (sequential use of old definition in config->Executable->list)."
+               echo "We set it to 1."
+    	    fi
+	fi
+    fi
+
+    IGCM_debug_Print 1 "MPI/OMP treatment PROCESSUS_NUMBER = ${PROCESSUS_NUMBER}"
 
 #     if ( ${OK_PARA_MPI} || ${OK_PARA_OMP} || ${OK_PARA_NOD} ) ; then
Index: /branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_vargas.ksh
===================================================================
--- /branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_vargas.ksh	(revision 555)
+++ /branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_vargas.ksh	(revision 556)
@@ -1138,22 +1138,15 @@
     typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count
     
-    # Verification with PBS parameter
-    if [ X${BATCH_NUM_PROC_TOT} != X ] ; then
-
-	if ( ${OK_PARA_MPI} ) ; then
-	    EXECUTION=${HOST_MPIRUN_COMMAND}
-	else
-	    if [ ${BATCH_NUM_PROC_TOT} -eq 1 ] ; then
-		EXECUTION=${MPIRUN_COMMAND:="time "}
-	    fi
-	fi
-    else
-	if ( ! ${OK_PARA_MPI} ) ; then
-            EXECUTION=${MPIRUN_COMMAND:="time "}
-	fi
-    fi
-
-    if [ ${PROCESSUS_NUMBER} -gt 1 ] ; then
-   
+    if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
+        IGCM_debug_Exit "IGCM_sys_vargas build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
+    fi
+
+    if [ -f run_file ] ; then
+        IGCM_sys_Rm -f run_file
+    fi
+    touch run_file
+
+    if ( ${OK_PARA_MPMD} ) ; then
+
 	if ( ${OK_PARA_OMP} ) ; then
 # NEW : 2 Noeuds
@@ -1191,11 +1184,6 @@
 	    fi		  
 	fi
-	if [ -f runfile ] ; then
-	    IGCM_sys_Rm -f runfile
-	    touch runfile
-	fi
-    fi
-
-# runfile construction
+
+# run_file construction
 
 # Then first loop on the components for the coupler ie oasis
@@ -1218,7 +1206,7 @@
 		until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
 		    if ( ${OK_PARA_OMP} ) ; then 
-			echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> runfile
+			echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
 		    else
-			echo "./${ExeNameOut}" >> runfile 
+			echo "./${ExeNameOut}" >> run_file 
 		    fi
 		    (( mpi_count = mpi_count + 1 ))
@@ -1226,7 +1214,7 @@
 	    else
 		if ( ${OK_PARA_OMP} ) ; then 
-		    echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> runfile
+		    echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
 		else
-		    echo "./${ExeNameOut} " >> runfile 
+		    echo "./${ExeNameOut} " >> run_file 
 		fi
 	    fi
@@ -1252,7 +1240,7 @@
 		until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
 		    if ( ${OK_PARA_OMP} ) ; then 
-			echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> runfile
+			echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
 		    else
-			echo "./${ExeNameOut}" >> runfile 
+			echo "./${ExeNameOut}" >> run_file 
 		    fi
 		    (( mpi_count = mpi_count + 1 ))
@@ -1260,7 +1248,8 @@
 	    else
 		if ( ${OK_PARA_OMP} ) ; then 
-		    echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> runfile
+		    echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
 		else
-		    echo "./${ExeNameOut} " >> runfile 
+		    # to be tested : no MPI only OpenMP into MPMD mode
+		    echo "./${ExeNameOut} " >> run_file 
 		fi
 	    fi
@@ -1268,10 +1257,25 @@
     done
 
-# update execution command for sequential and parallel cases
-
-    if [ ${PROCESSUS_NUMBER} -gt 1 ] ; then
-       EXECUTION="${EXECUTION} -pgmmodel mpmd -cmdfile ./runfile"
-    else
-       EXECUTION="${EXECUTION} " $( cat ./runfile ) 
+    EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file"
+
+else # Only one executable. launch it.
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+        eval ExeNameIn=\${config_Executable_${comp}[0]}
+        eval ExeNameOut=\${config_Executable_${comp}[1]}
+        # to suppress "" coming from config.card
+        eval ExeNameToLaunch=${ExeNameOut}
+
+	[ "X${ExeNameToLaunch}" != X ] &&  EXECUTION="time ./${ExeNameToLaunch}"
+
+    done
+
+fi
+
+    IGCM_sys_Chmod u+x run_file
+    if ( $DEBUG_sys ) ; then
+      echo "run_file contains : "
+      cat run_file
     fi
 
@@ -1279,13 +1283,11 @@
     IGCM_debug_Print 1 "$EXECUTION"
 
-    IGCM_sys_Chmod u+x runfile 
-
-    if ( $DEBUG_sys ) ; then
-        echo "runfile contains : "
-        cat runfile
-    fi
-
     IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
 }
 
-
+function IGCM_sys_build_run_file {
+
+IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
+
+}
+
