Index: trunk/libIGCM/libIGCM_config/libIGCM_config.ksh
===================================================================
--- trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 997)
+++ trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 1009)
@@ -786,157 +786,161 @@
   #================================================================#
   #       Prepare variables available for binary execution         #
+  #       Call function for creation of run script                 #
+  #       Only done once per job                                   #
   #================================================================#
 
-  typeset ExeNameIn ExeNameFirst CompNameFirst comp i j
-  typeset tempvar tempvarMPI tempvarNOD NbElts NbExec
-
-  PROCESSUS_NUMBER=0
-  NbExec=0
-  i=0
-
-  OK_PARA_MPI=false
-  OK_PARA_OMP=false
-  OK_PARA_NOD=false
-  OK_PARA_MPMD=false
-
-  for comp in ${config_ListOfComponents[*]} ; do
-
-    IGCM_debug_Print 1 ${comp}
-
-    eval ExeNameIn=\${config_Executable_${comp}[0]}
-
-    # NO order in config.card for parallelized values !
-    # just use suffix : MPI , OMP and NOD (for number of NODes.)
-
-    # NOD is the number of NODes allocated
-    eval ${comp}_PROC_NOD=0
-
-    # MPI is the number of MPI processus per nodes
-    eval ${comp}_PROC_MPI=0
-
-    # OMP is the number of OpenMP threads per MPI processus
-    eval ${comp}_PROC_OMP=0
-
-    # Only if we really have an executable for the component :
-    if ( [ "X${ExeNameIn}" != X\"\" ] && [ "X${ExeNameIn}" != "Xinca.dat" ] ) ; 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 ))
-        while [ $j -lt ${NbElts} ] ; do
-          eval tempvar=\${config_Executable_${comp}[${j}]}
-          IGCM_debug_Print 2 ${tempvar}
-
-          if [ X${tempvar} = X ] ; then
-            IGCM_debug_Print 2 "Error reading MPI/OMP parameters !!!"
-            IGCM_debug_Exit "Check your config.card. Exit now"
-            IGCM_debug_Verif_Exit
+  if [ ${Period} -eq 1 ]; then
+    typeset ExeNameIn ExeNameFirst CompNameFirst comp i j
+    typeset tempvar tempvarMPI tempvarNOD NbElts NbExec
+
+    PROCESSUS_NUMBER=0
+    NbExec=0
+    i=0
+
+    OK_PARA_MPI=false
+    OK_PARA_OMP=false
+    OK_PARA_NOD=false
+    OK_PARA_MPMD=false
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      IGCM_debug_Print 1 ${comp}
+
+      eval ExeNameIn=\${config_Executable_${comp}[0]}
+
+      # NO order in config.card for parallelized values !
+      # just use suffix : MPI , OMP and NOD (for number of NODes.)
+
+      # NOD is the number of NODes allocated
+      eval ${comp}_PROC_NOD=0
+
+      # MPI is the number of MPI processus per nodes
+      eval ${comp}_PROC_MPI=0
+
+      # OMP is the number of OpenMP threads per MPI processus
+      eval ${comp}_PROC_OMP=0
+
+      # Only if we really have an executable for the component :
+      if ( [ "X${ExeNameIn}" != X\"\" ] && [ "X${ExeNameIn}" != "Xinca.dat" ] ) ; 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 ))
+          while [ $j -lt ${NbElts} ] ; do
+            eval tempvar=\${config_Executable_${comp}[${j}]}
+            IGCM_debug_Print 2 ${tempvar}
+
+            if [ X${tempvar} = X ] ; then
+              IGCM_debug_Print 2 "Error reading MPI/OMP parameters !!!"
+              IGCM_debug_Exit "Check your config.card. Exit now"
+              IGCM_debug_Verif_Exit
+            fi
+
+            case ${tempvar} in
+            *[mM][pP][iI]*)
+              # Read MPI parameter for composante
+              eval ${comp}_PROC_MPI=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/MPI//" )
+              OK_PARA_MPI=true;;
+            *[oO][mM][pP]*)
+              # Read OMP parameter for composante
+              eval ${comp}_PROC_OMP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/OMP//" )
+              OK_PARA_OMP=true;;
+            *[nN][oO][dD]*)
+              # Read NOD (NumBer of Nodes) parameter for composante
+              eval ${comp}_PROC_NOD=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/NOD//" )
+              OK_PARA_NOD=true
+              OK_PARA_MPI=true;;
+            esac
+            (( j = j + 1 ))
+          done
+        fi
+        eval tempvarMPI=\${${comp}_PROC_MPI}
+        eval tempvarNOD=\${${comp}_PROC_NOD}
+        eval tempvarOMP=\${${comp}_PROC_OMP}
+
+        (( PROCESSUS_NUMBER = PROCESSUS_NUMBER + tempvarMPI * tempvarNOD * tempvarOMP ))
+      fi
+      (( i=i+1 ))
+    done
+
+    # 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
+      # BATCH_NUM_PROC_TOT is set
+      if ( ${OK_PARA_MPI} ) ; then
+        IGCM_debug_Print 1 "MPI/OMP/NOD found into config.card and BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} "
+      else
+        # with previous method.
+        if [ ${BATCH_NUM_PROC_TOT} -gt 1 ] ; then
+          # with more than 1 proc
+          if ( ${OK_PARA_MPMD} ) ; then
+            # with MPMD ie CPL/oasis method
+            IGCM_debug_Print 2 "Use default number of MPI tasks for this machine : "
+            IGCM_debug_Print 2 "${DEFAULT_NUM_PROC_OCE} for OCE"
+            IGCM_debug_Print 2 "${DEFAULT_NUM_PROC_CPL} for CPL"
+            IGCM_debug_Print 2 "${DEFAULT_NUM_PROC_ATM} for ATM"
+            OK_PARA_MPI=true
+            CPL_PROC_MPI=${DEFAULT_NUM_PROC_CPL}
+            OCE_PROC_MPI=${DEFAULT_NUM_PROC_OCE}
+            ATM_PROC_MPI=${DEFAULT_NUM_PROC_ATM}
+            PROCESSUS_NUMBER=${DEFAULT_NUM_PROC_TOTAL}
+          else
+            # with have only one executable
+            IGCM_debug_Print 2 "Use ${BATCH_NUM_PROC_TOT} MPI tasks for ${CompNameFirst} : ${ExeNameFirst} "
+            OK_PARA_MPI=true
+            eval ${CompNameFirst}_PROC_MPI=${BATCH_NUM_PROC_TOT}
+            PROCESSUS_NUMBER=${BATCH_NUM_PROC_TOT}
           fi
-
-          case ${tempvar} in
-          *[mM][pP][iI]*)
-            # Read MPI parameter for composante
-            eval ${comp}_PROC_MPI=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/MPI//" )
-            OK_PARA_MPI=true;;
-          *[oO][mM][pP]*)
-            # Read OMP parameter for composante
-            eval ${comp}_PROC_OMP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/OMP//" )
-            OK_PARA_OMP=true;;
-          *[nN][oO][dD]*)
-            # Read NOD (NumBer of Nodes) parameter for composante
-            eval ${comp}_PROC_NOD=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/NOD//" )
-            OK_PARA_NOD=true
-            OK_PARA_MPI=true;;
-          esac
-          (( j = j + 1 ))
-        done
+        else
+          PROCESSUS_NUMBER=1
+        fi
       fi
-      eval tempvarMPI=\${${comp}_PROC_MPI}
-      eval tempvarNOD=\${${comp}_PROC_NOD}
-      eval tempvarOMP=\${${comp}_PROC_OMP}
-
-      (( PROCESSUS_NUMBER = PROCESSUS_NUMBER + tempvarMPI * tempvarNOD * tempvarOMP ))
-    fi
-    (( i=i+1 ))
-  done
-
-  # 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
-    # BATCH_NUM_PROC_TOT is set
-    if ( ${OK_PARA_MPI} ) ; then
-      IGCM_debug_Print 1 "MPI/OMP/NOD found into config.card and BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} "
-    else
-      # with previous method.
-      if [ ${BATCH_NUM_PROC_TOT} -gt 1 ] ; then
-        # with more than 1 proc
-        if ( ${OK_PARA_MPMD} ) ; then
-          # with MPMD ie CPL/oasis method
-          IGCM_debug_Print 2 "Use default number of MPI tasks for this machine : "
-          IGCM_debug_Print 2 "${DEFAULT_NUM_PROC_OCE} for OCE"
-          IGCM_debug_Print 2 "${DEFAULT_NUM_PROC_CPL} for CPL"
-          IGCM_debug_Print 2 "${DEFAULT_NUM_PROC_ATM} for ATM"
-          OK_PARA_MPI=true
-          CPL_PROC_MPI=${DEFAULT_NUM_PROC_CPL}
-          OCE_PROC_MPI=${DEFAULT_NUM_PROC_OCE}
-          ATM_PROC_MPI=${DEFAULT_NUM_PROC_ATM}
-          PROCESSUS_NUMBER=${DEFAULT_NUM_PROC_TOTAL}
-        else
-          # with have only one executable
-          IGCM_debug_Print 2 "Use ${BATCH_NUM_PROC_TOT} MPI tasks for ${CompNameFirst} : ${ExeNameFirst} "
-          OK_PARA_MPI=true
-          eval ${CompNameFirst}_PROC_MPI=${BATCH_NUM_PROC_TOT}
-          PROCESSUS_NUMBER=${BATCH_NUM_PROC_TOT}
+      # Verification with PBS parameter
+      if [ ${BATCH_NUM_PROC_TOT} -ne ${PROCESSUS_NUMBER} ] ; then
+        IGCM_debug_Exit "ERROR with parallelization parameters !"
+        IGCM_debug_Print 2 "Job header variable BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} "
+        IGCM_debug_Print 2 "is the total number of _processors_ reserved."
+        IGCM_debug_Print 2 "It is not equal to the sum of _processus_  = ${PROCESSUS_NUMBER}."
+        IGCM_debug_Verif_Exit
+      fi
+      NUM_PROC_CPL=${CPL_PROC_MPI} # for backward compatibility
+      NUM_PROC_OCE=${OCE_PROC_MPI} # for backward compatibility
+      NUM_PROC_ATM=${ATM_PROC_MPI} # for backward compatibility
+    else # BATCH_NUM_PROC_TOT=""
+      if ( ${OK_PARA_MPI} ) ; then
+        IGCM_debug_Exit "ERROR : missing value for ${BATCH_NUM_PROC_TOT} processors,"
+        IGCM_debug_Print 2 "You have parallel parameters in config->Executable->list."
+        IGCM_debug_Print 2 "Please add BATCH_NUM_PROC_TOT variable in job header as well."
+        IGCM_debug_Exit "Exit now."
+        IGCM_debug_Verif_Exit
+      else
+        # sequential case !
+        if [ ${PROCESSUS_NUMBER} -eq 0 ] ; then
+          (( PROCESSUS_NUMBER = 1 ))
+          IGCM_debug_Print 2 "PROCESSUS_NUMBER is all 0 (sequential use of old definition in config->Executable->list)."
+          IGCM_debug_Print 2 "We set it to 1."
         fi
-      else
-        PROCESSUS_NUMBER=1
       fi
     fi
-    # Verification with PBS parameter
-    if [ ${BATCH_NUM_PROC_TOT} -ne ${PROCESSUS_NUMBER} ] ; then
-      IGCM_debug_Exit "ERROR with parallelization parameters !"
-      IGCM_debug_Print 2 "Job header variable BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} "
-      IGCM_debug_Print 2 "is the total number of _processors_ reserved."
-      IGCM_debug_Print 2 "It is not equal to the sum of _processus_  = ${PROCESSUS_NUMBER}."
-      IGCM_debug_Verif_Exit
-    fi
-    NUM_PROC_CPL=${CPL_PROC_MPI} # for backward compatibility
-    NUM_PROC_OCE=${OCE_PROC_MPI} # for backward compatibility
-    NUM_PROC_ATM=${ATM_PROC_MPI} # for backward compatibility
-  else # BATCH_NUM_PROC_TOT=""
-    if ( ${OK_PARA_MPI} ) ; then
-      IGCM_debug_Exit "ERROR : missing value for ${BATCH_NUM_PROC_TOT} processors,"
-      IGCM_debug_Print 2 "You have parallel parameters in config->Executable->list."
-      IGCM_debug_Print 2 "Please add BATCH_NUM_PROC_TOT variable in job header as well."
-      IGCM_debug_Exit "Exit now."
-      IGCM_debug_Verif_Exit
-    else
-      # sequential case !
-      if [ ${PROCESSUS_NUMBER} -eq 0 ] ; then
-        (( PROCESSUS_NUMBER = 1 ))
-        IGCM_debug_Print 2 "PROCESSUS_NUMBER is all 0 (sequential use of old definition in config->Executable->list)."
-        IGCM_debug_Print 2 "We set it to 1."
-      fi
-    fi
-  fi
-
-  IGCM_debug_Print 1 "MPI/OMP treatment PROCESSUS_NUMBER = ${PROCESSUS_NUMBER}"
-
-  IGCM_sys_build_execution_scripts
+
+    IGCM_debug_Print 1 "MPI/OMP treatment PROCESSUS_NUMBER = ${PROCESSUS_NUMBER}"
+
+    IGCM_sys_build_execution_scripts
+  fi
 
   ExecutionFail=false
