Changeset 544 for trunk


Ignore:
Timestamp:
12/22/11 16:04:47 (12 years ago)
Author:
sdipsl
Message:
  • Prepare libIGCM for TGCC migration. For now work for CCRT machines ONLY
  • SX8, SX9 and Titane are independant from DMNFS
    • 30 seconds between execution instead of at least 3 minutes ; sometimes hours
  • SX8, SX9 and Titane use their SCRATCHDIR as a BUFFER (for restart and text)
  • Titane simulations are entirely post-processed on titane mono
    • Working except create_se and atlas (missing software : ncap2, openpbm, ImageMagick?)
  • Cards are the same up to now
  • New indentation to ease readability ("svn diff -x -b" to ignore space when differencing)
  • Project (gen2211) is inherited from AA_job by post-processing jobs
    • will stop during config_check if Project is empty
  • Prepare easy switching (submitting post-processing here or there)
  • Homogenize CCRTs libIGCM_sys
  • Bugfixes
  • Cosmetics

First steps and still a long way to go.

Location:
trunk/libIGCM
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/AA_additionnal

    r504 r544  
    8282#-Q- sx9mercure ## CESIUM FOR SX9  CEA ## 
    8383#-Q- sx9mercure ######################### 
    84 #-Q- sx9mercure #MSUB -r ATL_ADD        # Nom du job                 
     84#-Q- sx9mercure #MSUB -r ATL_ADD        # Nom du job 
    8585#-Q- sx9mercure #MSUB -N 1              # Reservation du noeud 
    8686#-Q- sx9mercure #MSUB -n 2              # Reservation du processus 
     
    9393#-Q- titane ## TITANE   CEA ## 
    9494#-Q- titane ###################### 
    95 #-Q- titane #MSUB -r ATL_ADD        # Nom du job                 
    96 #-Q- titane #MSUB -N 1              # Reservation du noeud 
    97 #-Q- titane #MSUB -n 2              # Reservation du processus 
    98 #-Q- titane #MSUB -c 4              # Reservation du core 
     95#-Q- titane #MSUB -r ATL_ADD        # Nom du job 
     96#-Q- titane #MSUB -eo 
     97#-Q- titane #MSUB -n 1              # Reservation du processus 
    9998#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    100 #-Q- titane #MSUB -E "-j o" 
    101 #-Q- titane #MSUB -E "-S /bin/ksh" 
    102 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    103 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     99#-Q- titane #MSUB -q mono 
    104100#-Q- default #!/bin/ksh 
    105101#-Q- default ################## 
  • trunk/libIGCM/AA_atlas_LMDZ

    r504 r544  
    9292#-Q- titane ###################### 
    9393#-Q- titane #MSUB -r ATL_LMDZ       # Nom du job                 
    94 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     94#-Q- titane #MSUB -eo 
    9595#-Q- titane #MSUB -n 1              # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -E "-j o" 
    98 #-Q- titane #MSUB -E "-S /bin/ksh" 
    99 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    100 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     97#-Q- titane #MSUB -q mono 
    10198#-Q- default #!/bin/ksh 
    10299#-Q- default ################## 
  • trunk/libIGCM/AA_atlas_ORCA_LIM

    r518 r544  
    9292#-Q- titane ###################### 
    9393#-Q- titane #MSUB -r ATL_OPA        # Nom du job                 
    94 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     94#-Q- titane #MSUB -eo 
    9595#-Q- titane #MSUB -n 1              # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -E "-j o" 
    98 #-Q- titane #MSUB -E "-S /bin/ksh" 
    99 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    100 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     97#-Q- titane #MSUB -q mono 
    10198#-Q- default #!/bin/ksh 
    10299#-Q- default ################## 
  • trunk/libIGCM/AA_atlas_ORCHIDEE

    r504 r544  
    9292#-Q- titane ###################### 
    9393#-Q- titane #MSUB -r ATL_ORCH       # Nom du job                 
    94 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     94#-Q- titane #MSUB -eo 
    9595#-Q- titane #MSUB -n 1              # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -E "-j o" 
    98 #-Q- titane #MSUB -E "-S /bin/ksh" 
    99 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    100 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     97#-Q- titane #MSUB -q mono 
    10198#-Q- lxiv8 ###################### 
    10299#-Q- lxiv8 ## OBELIX      LSCE ## 
  • trunk/libIGCM/AA_atlas_PISCES

    r504 r544  
    9191#-Q- titane ## TITANE   CEA ## 
    9292#-Q- titane ###################### 
    93 #-Q- titane #MSUB -r ATL_PIS        # Nom du job                 
    94 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     93#-Q- titane #MSUB -r ATL_PIS        # Nom du job 
     94#-Q- titane #MSUB -eo 
    9595#-Q- titane #MSUB -n 1              # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -E "-j o" 
    98 #-Q- titane #MSUB -E "-S /bin/ksh" 
    99 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    100 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     97#-Q- titane #MSUB -q mono 
    10198#-Q- default #!/bin/ksh 
    10299#-Q- default ################## 
  • trunk/libIGCM/AA_create_multi_se

    r504 r544  
    9292#-Q- titane ###################### 
    9393#-Q- titane #MSUB -r MULTISE             # Nom du job                 
    94 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     94#-Q- titane #MSUB -eo 
    9595#-Q- titane #MSUB -n 1              # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -E "-j o" 
    98 #-Q- titane #MSUB -E "-S /bin/ksh" 
    99 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    100 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     97#-Q- titane #MSUB -q mono 
    10198#-Q- lxiv8 ###################### 
    10299#-Q- lxiv8 ## OBELIX      LSCE ## 
  • trunk/libIGCM/AA_create_se

    r504 r544  
    9292#-Q- titane ###################### 
    9393#-Q- titane #MSUB -r SE             # Nom du job                 
    94 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     94#-Q- titane #MSUB -eo 
    9595#-Q- titane #MSUB -n 1              # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -E "-j o" 
    98 #-Q- titane #MSUB -E "-S /bin/ksh" 
    99 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    100 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     97#-Q- titane #MSUB -q mono 
    10198#-Q- lxiv8 ###################### 
    10299#-Q- lxiv8 ## OBELIX      LSCE ## 
  • trunk/libIGCM/AA_create_ts

    r514 r544  
    9292#-Q- titane ###################### 
    9393#-Q- titane #MSUB -r TS             # Nom du job                 
    94 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     94#-Q- titane #MSUB -eo 
    9595#-Q- titane #MSUB -n 1              # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -E "-j o" 
    98 #-Q- titane #MSUB -E "-S /bin/ksh" 
    99 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    100 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     97#-Q- titane #MSUB -q mono 
    10198#-Q- lxiv8 ###################### 
    10299#-Q- lxiv8 ## OBELIX      LSCE ## 
  • trunk/libIGCM/AA_monitoring

    r504 r544  
    9292#-Q- titane ###################### 
    9393#-Q- titane #MSUB -r MONITORING     # Nom du job                 
    94 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     94#-Q- titane #MSUB -eo 
    9595#-Q- titane #MSUB -n 1              # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -E "-j o" 
    98 #-Q- titane #MSUB -E "-S /bin/ksh" 
    99 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    100 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     97#-Q- titane #MSUB -q mono 
    10198#-Q- lxiv8 ###################### 
    10299#-Q- lxiv8 ## OBELIX      LSCE ## 
  • trunk/libIGCM/AA_rebuild_fromArchive

    r504 r544  
    9595#-Q- titane #MSUB -n 1               # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400           # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -p gen2211 
    9897#-Q- titane #MSUB -q mono 
    9998#-Q- lxiv8 ###################### 
  • trunk/libIGCM/AA_rebuild_fromWorkdir

    r504 r544  
    9595#-Q- titane #MSUB -n 1              # Reservation du processus 
    9696#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    97 #-Q- titane #MSUB -p gen2211 
    9897#-Q- titane #MSUB -q mono 
    9998#-Q- lxiv8 ###################### 
  • trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh

    r522 r544  
    1515function IGCM_comp_Initialize 
    1616{ 
    17     IGCM_debug_PushStack "IGCM_comp_Initialize" 
     17  IGCM_debug_PushStack "IGCM_comp_Initialize" 
    1818 
    1919    # Debug Print : 
     20  echo 
     21  IGCM_debug_Print 1 "IGCM_comp_Initialize" 
     22  echo 
     23 
     24  typeset comp compname comptagname CompatibilityTag auxprint card_UserChoices first_option option i j 
     25  for comp in ${config_ListOfComponents[*]} ; do 
     26    # Debug Print 
     27    IGCM_debug_Print 1 "Initialize ${comp} : ${compname} component." 
     28 
     29    # Define component  
     30    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} 
     31    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     32    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
     33 
     34    # Read libIGCM compatibility version in ${compname}.card 
     35    card=${SUBMIT_DIR}/COMP/${compname}.card 
     36    IGCM_card_DefineVariableFromOption ${card} Compatibility libIGCM 
     37 
     38    eval CompatibilityTag=\${${compname}_Compatibility_libIGCM} > /dev/null 2>&1         
     39    if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then 
     40      IGCM_debug_Exit "${compname}.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ." 
     41    fi 
     42 
     43    # Manage component executable 
     44    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card Executable ${comp} 
     45 
     46    # Read component Write Frequency in config.card 
     47    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} WriteFrequency 
     48    # Debug Print : 
     49    eval auxprint=\${config_${comp}_WriteFrequency} 
     50    IGCM_debug_Print 1 "Write frequency for ${compname} : ${auxprint} " 
     51    #2> /dev/null 
     52 
     53    # Debug Print : 
     54    IGCM_debug_Print 2 "Initialize following component library" 
     55 
     56    # Source drivers in directory DRIVER if it exist 
     57    # else source them from directory COMP 
     58    if [ -d ${SUBMIT_DIR}/DRIVER ] ; then 
     59      IGCM_debug_Print 2 ${SUBMIT_DIR}/DRIVER/${compname}.driver 
     60      # Source component library 
     61      . ${SUBMIT_DIR}/DRIVER/${compname}.driver 
     62    else 
     63      IGCM_debug_Print 2 ${SUBMIT_DIR}/COMP/${compname}.driver 
     64      # Source component library 
     65      . ${SUBMIT_DIR}/COMP/${compname}.driver 
     66    fi 
     67    IGCM_debug_Print 3 "With tag : ${comptagname}" 
     68 
     69    # Debug Print 
     70    IGCM_debug_Print 3 "Initialize ${comp} output directory." 
     71 
     72    # Define ARCHIVED Dirs 
     73    eval R_OUT_${comp}=${R_SAVE}/${comp} 
     74    eval IGCM_sys_MkdirArchive \${R_OUT_${comp}} 
     75 
     76    eval R_OUT_${comp}_O=\${R_OUT_${comp}}/Output 
     77    eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_O} 
     78 
     79    eval R_OUT_${comp}_R=\${R_OUT_${comp}}/Restart 
     80    eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_R} 
     81 
     82    eval R_OUT_${comp}_D=\${R_OUT_${comp}}/Debug 
     83    eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_D} 
     84 
     85    eval R_OUT_${comp}_O_I=\${R_OUT_${comp}_O}/INS 
     86    eval R_OUT_${comp}_O_H=\${R_OUT_${comp}_O}/HF 
     87    eval R_OUT_${comp}_O_D=\${R_OUT_${comp}_O}/DA 
     88    eval R_OUT_${comp}_O_M=\${R_OUT_${comp}_O}/MO 
     89    eval R_OUT_${comp}_O_Y=\${R_OUT_${comp}_O}/YE 
     90 
     91    # Define BUFFERED Dirs 
     92    eval R_BUF_${comp}=${R_BUFR}/${comp} 
     93    eval IGCM_sys_Mkdir \${R_BUF_${comp}} 
     94 
     95    eval R_BUF_${comp}_O=\${R_BUF_${comp}}/Output 
     96    eval IGCM_sys_Mkdir \${R_BUF_${comp}_O} 
     97 
     98    eval R_BUF_${comp}_R=\${R_BUF_${comp}}/Restart 
     99    eval IGCM_sys_Mkdir \${R_BUF_${comp}_R} 
     100 
     101    eval R_BUF_${comp}_D=\${R_BUF_${comp}}/Debug 
     102    eval IGCM_sys_Mkdir \${R_BUF_${comp}_D} 
     103 
     104    eval R_BUF_${comp}_O_I=\${R_BUF_${comp}_O}/INS 
     105    eval R_BUF_${comp}_O_H=\${R_BUF_${comp}_O}/HF 
     106    eval R_BUF_${comp}_O_D=\${R_BUF_${comp}_O}/DA 
     107    eval R_BUF_${comp}_O_M=\${R_BUF_${comp}_O}/MO 
     108    eval R_BUF_${comp}_O_Y=\${R_BUF_${comp}_O}/YE 
     109 
     110    # Read UserChoices section of component card 
     111    IGCM_debug_Print 2 "DefineArrayFromSection : ${compname}_UserChoices ${card}" 
     112    IGCM_card_DefineArrayFromSection ${card} UserChoices 
     113    eval first_option=\${${compname}_UserChoices[0]} > /dev/null 2>&1 
     114    # If section is not empty we define corresponding variables 
     115    if [ X${first_option} != X"Error:" ] ; then 
     116      if [ X${card_UserChoices[0]} != X ] ; then 
     117        unset card_UserChoices 
     118      fi 
     119      eval set +A card_UserChoices -- \${${compname}_UserChoices[*]} > /dev/null 2>&1 
     120      IGCM_debug_Print 3 "${compname}_UserChoices_values:" 
     121      for option in ${card_UserChoices[*]} ; do 
     122        IGCM_card_DefineVariableFromOption ${card} UserChoices ${option} 
     123        eval IGCM_debug_Print 3 "${option}=\${${compname}_UserChoices_${option}}" 
     124      done 
     125    fi 
     126 
     127    # Read and Build Output File stuff 
     128    IGCM_debug_Print 2 "DefineArrayFromOption  : ${compname}_OutputFiles ${card}" 
     129    IGCM_card_DefineArrayFromOption ${card} OutputFiles List 
     130    ListFilesName=${compname}_OutputFiles_List 
     131    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
     132    # 
     133    if [ X${FileName0} != X${NULL_STR} ] ; then 
     134      # 
     135      #IGCM_debug_Print 1 "Component      : ${compname}" 
     136      # 
     137      # INITIALISATION 
     138      # 
     139      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     140      # 
     141      i=2 
     142      # 
     143      until [ $i -ge $NbFiles ]; do 
     144        # 
     145        eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     146        # 
     147        if [ X${flag_post} != XNONE ] ; then 
     148          # 
     149          # First of all 
     150          # 
     151          IGCM_card_DefineArrayFromSection ${card} ${flag_post} 
     152          # 
     153          # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default 
     154          # 
     155          # variable option allready typeset above 
     156          for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do 
     157            if [ ${option} = Seasonal ] ; then 
     158              FoundSeasonal=true 
     159              IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal 
     160            fi 
     161          done 
     162          # 
     163          if [ ! X${FoundSeasonal} = Xtrue ] ; then 
     164            eval ${compname}_${flag_post}_Seasonal=ON 
     165          fi 
     166          # 
     167          if [ $( eval echo \${${compname}_${flag_post}_Seasonal} ) = ON ] ; then 
     168            Seasonal=true 
     169          fi 
     170           
     171          # Dimension = vide si vieille card. 
     172          IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars 
     173          IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches 
     174          if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not" ] ; then 
     175            # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob. 
     176            ListDimension[0]=2D 
     177            ListDimension[1]=3D 
     178            TimeSeries=false 
     179            iLoop=${#ListDimension[*]} 
     180            j=0 
     181            until [ $j -ge ${iLoop} ]; do 
     182              Dimension=${ListDimension[${j}]} 
     183              IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars${Dimension} 
     184              IGCM_card_DefineVariableFromOption ${card} ${flag_post} ChunckJob${Dimension} 
     185              # 
     186              # Time series WITHOUT chunk 
     187              # 
     188              if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then 
     189                if [ $( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) = NONE ] ; then 
     190                  IGCM_debug_Print 3 "${Dimension} time series activated for ${flag_post}" 
     191                  eval TimeSeries${Dimension}=true 
     192                fi 
     193              fi 
     194              # 
     195              # Time series WITH chunk 
     196              # 
     197              if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then 
     198                chunck_size=$( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) 
     199                if [ ! ${chunck_size} = NONE ] &&  [ ! ${chunck_size} = OFF ] ; then 
     200                  IGCM_debug_Print 3 "${Dimension} time series activated with chunck for ${flag_post}" 
     201                  eval TimeSeriesChunck${Dimension}=true 
     202                  eval set +A CHUNCK${Dimension}_COMP \${CHUNCK${Dimension}_COMP[*]} ${comp} 
     203                  eval set +A CHUNCK${Dimension}_FLAG \${CHUNCK${Dimension}_FLAG[*]} ${i} 
     204                  eval set +A CHUNCK${Dimension}_NAME \${CHUNCK${Dimension}_NAME[*]} ${flag_post} 
     205                  eval set +A CHUNCK${Dimension}_SIZE \${CHUNCK${Dimension}_SIZE[*]} ${chunck_size} 
     206                fi 
     207              fi 
     208              (( j=j+1 )) 
     209            done 
     210          else 
     211            ListDimension[0]="" 
     212            TimeSeries=true 
     213            TimeSeries2D=false 
     214            TimeSeries3D=false 
     215            TimeSeriesChunck2D=false 
     216            TimeSeriesChunck3D=false 
     217          fi 
     218        fi 
     219        (( i=i+3 )) 
     220      done 
     221    fi 
     222    # Debug Print 
     223    IGCM_debug_Print 3 "Initialize ${compname} with driver." 
     224    # INIT component 
     225    ${comp}_Initialize 
    20226    echo 
    21     IGCM_debug_Print 1 "IGCM_comp_Initialize" 
    22     echo 
    23  
    24     typeset comp compname comptagname CompatibilityTag auxprint card_UserChoices first_option option i j 
    25     for comp in ${config_ListOfComponents[*]} ; do 
    26         # Debug Print 
    27         IGCM_debug_Print 1 ${comp} 
    28         # Define component  
    29         IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} 
    30         eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
    31         eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    32  
    33         # Read libIGCM compatibility version in ${compname}.card 
    34         card=${SUBMIT_DIR}/COMP/${compname}.card 
    35         IGCM_card_DefineVariableFromOption ${card} Compatibility libIGCM 
    36  
    37         eval CompatibilityTag=\${${compname}_Compatibility_libIGCM} > /dev/null 2>&1     
    38         if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then 
    39             IGCM_debug_Exit "${compname}.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ." 
    40         fi 
    41  
    42         # Manage component executable 
    43         IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card Executable ${comp} 
    44  
    45         # Read component Write Frequency in config.card 
    46         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} WriteFrequency 
    47         # Debug Print : 
    48         eval auxprint=\${config_${comp}_WriteFrequency} 
    49         IGCM_debug_Print 1 "Write frequency for ${compname} : ${auxprint} " 
    50         #2> /dev/null 
    51  
    52         # Debug Print : 
    53         IGCM_debug_Print 2 "Initialize following component library" 
    54  
    55         # Source drivers in directory DRIVER if it exist 
    56         # else source them from directory COMP 
    57         if [ -d ${SUBMIT_DIR}/DRIVER ] ; then 
    58             IGCM_debug_Print 2 ${SUBMIT_DIR}/DRIVER/${compname}.driver 
    59             # Source component library 
    60             . ${SUBMIT_DIR}/DRIVER/${compname}.driver 
    61         else 
    62             IGCM_debug_Print 2 ${SUBMIT_DIR}/COMP/${compname}.driver 
    63             # Source component library 
    64             . ${SUBMIT_DIR}/COMP/${compname}.driver 
    65         fi 
    66         IGCM_debug_Print 3 "With tag : ${comptagname}" 
    67          
    68  
    69         # Debug Print 
    70         IGCM_debug_Print 3 "Initialize ${comp} output directory." 
    71         # Define Dirs    
    72         eval R_OUT_${comp}=${R_SAVE}/${comp} 
    73         eval IGCM_sys_MkdirArchive \${R_OUT_${comp}} 
    74  
    75         eval R_OUT_${comp}_O=\${R_OUT_${comp}}/Output 
    76         eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_O} 
    77  
    78         eval R_OUT_${comp}_R=\${R_OUT_${comp}}/Restart 
    79         eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_R} 
    80  
    81         eval R_OUT_${comp}_D=\${R_OUT_${comp}}/Debug 
    82         eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_D} 
    83  
    84         eval R_OUT_${comp}_O_I=\${R_OUT_${comp}_O}/INS 
    85         eval R_OUT_${comp}_O_H=\${R_OUT_${comp}_O}/HF 
    86         eval R_OUT_${comp}_O_D=\${R_OUT_${comp}_O}/DA 
    87         eval R_OUT_${comp}_O_M=\${R_OUT_${comp}_O}/MO 
    88         eval R_OUT_${comp}_O_Y=\${R_OUT_${comp}_O}/YE 
    89  
    90         # Read UserChoices section of component card 
    91         IGCM_debug_Print 2 "DefineArrayFromSection : ${compname}_UserChoices ${card}" 
    92         IGCM_card_DefineArrayFromSection ${card} UserChoices 
    93         eval first_option=\${${compname}_UserChoices[0]} > /dev/null 2>&1 
    94         # If section is not empty we define corresponding variables 
    95         if [ X${first_option} != X"Error:" ] ; then 
    96             if [ X${card_UserChoices[0]} != X ] ; then 
    97                 unset card_UserChoices 
    98             fi 
    99             eval set +A card_UserChoices -- \${${compname}_UserChoices[*]} > /dev/null 2>&1 
    100             IGCM_debug_Print 3 "${compname}_UserChoices_values:" 
    101             for option in ${card_UserChoices[*]} ; do 
    102                 IGCM_card_DefineVariableFromOption ${card} UserChoices ${option} 
    103                 eval IGCM_debug_Print 3 "${option}=\${${compname}_UserChoices_${option}}" 
    104             done 
    105         fi 
    106  
    107         # Read and Build Output File stuff 
    108         IGCM_debug_Print 2 "DefineArrayFromOption  : ${compname}_OutputFiles ${card}" 
    109         IGCM_card_DefineArrayFromOption ${card} OutputFiles List 
    110         ListFilesName=${compname}_OutputFiles_List 
    111         eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    112         # 
    113         if [ X${FileName0} != X${NULL_STR} ] ; then 
    114             # 
    115             #IGCM_debug_Print 1 "Component      : ${compname}" 
    116             # 
    117             # INITIALISATION 
    118             # 
    119             eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    120             # 
    121             i=2 
    122             # 
    123             until [ $i -ge $NbFiles ]; do 
    124                 # 
    125                 eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    126                 # 
    127                 if [ X${flag_post} != XNONE ] ; then 
    128                     # 
    129                     # First of all 
    130                     # 
    131                     IGCM_card_DefineArrayFromSection ${card} ${flag_post} 
    132                     # 
    133                     # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default 
    134                     # 
    135                     # variable option allready typeset above 
    136                     for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do 
    137                         if [ ${option} = Seasonal ] ; then 
    138                             FoundSeasonal=true 
    139                             IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal 
    140                         fi 
    141                     done 
    142                     # 
    143                     if [ ! X${FoundSeasonal} = Xtrue ] ; then 
    144                         eval ${compname}_${flag_post}_Seasonal=ON 
    145                     fi 
    146                     # 
    147                     if [ $( eval echo \${${compname}_${flag_post}_Seasonal} ) = ON ] ; then 
    148                         Seasonal=true 
    149                     fi 
    150                      
    151                     # Dimension = vide si vieille card. 
    152                     IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars 
    153                     IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches 
    154                     if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not" ] ; then 
    155                         # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob. 
    156                         ListDimension[0]=2D 
    157                         ListDimension[1]=3D 
    158                         TimeSeries=false 
    159                         iLoop=${#ListDimension[*]} 
    160                         j=0 
    161                         until [ $j -ge ${iLoop} ]; do 
    162                             Dimension=${ListDimension[${j}]} 
    163                             IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars${Dimension} 
    164                             IGCM_card_DefineVariableFromOption ${card} ${flag_post} ChunckJob${Dimension} 
    165                             # 
    166                             # Time series WITHOUT chunk 
    167                             # 
    168                             if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then 
    169                                 if [ $( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) = NONE ] ; then 
    170                                     IGCM_debug_Print 3 "${Dimension} time series activated for ${flag_post}" 
    171                                     eval TimeSeries${Dimension}=true 
    172                                 fi 
    173                             fi 
    174                             # 
    175                             # Time series WITH chunk 
    176                             # 
    177                             if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then 
    178                                 chunck_size=$( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) 
    179                                 if [ ! ${chunck_size} = NONE ] &&  [ ! ${chunck_size} = OFF ] ; then 
    180                                     IGCM_debug_Print 3 "${Dimension} time series activated with chunck for ${flag_post}" 
    181                                     eval TimeSeriesChunck${Dimension}=true 
    182                                     eval set +A CHUNCK${Dimension}_COMP \${CHUNCK${Dimension}_COMP[*]} ${comp} 
    183                                     eval set +A CHUNCK${Dimension}_FLAG \${CHUNCK${Dimension}_FLAG[*]} ${i} 
    184                                     eval set +A CHUNCK${Dimension}_NAME \${CHUNCK${Dimension}_NAME[*]} ${flag_post} 
    185                                     eval set +A CHUNCK${Dimension}_SIZE \${CHUNCK${Dimension}_SIZE[*]} ${chunck_size} 
    186                                 fi 
    187                             fi 
    188                             (( j=j+1 )) 
    189                         done 
    190                     else 
    191                         ListDimension[0]="" 
    192                         TimeSeries=true 
    193                         TimeSeries2D=false 
    194                         TimeSeries3D=false 
    195                         TimeSeriesChunck2D=false 
    196                         TimeSeriesChunck3D=false 
    197                     fi 
    198                 fi 
    199                 (( i=i+3 )) 
    200             done 
    201         fi 
    202         # Debug Print 
    203         IGCM_debug_Print 3 "Initialize ${compname} with driver." 
    204         # INIT component 
    205         ${comp}_Initialize 
    206         echo 
    207     done 
    208  
    209     IGCM_debug_PopStack "IGCM_comp_Initialize" 
     227  done 
     228 
     229  IGCM_debug_PopStack "IGCM_comp_Initialize" 
    210230} 
    211231 
     
    213233function IGCM_comp_PrepareDeletedFiles 
    214234{ 
    215     IGCM_debug_PushStack "IGCM_comp_PrepareDeletedFiles" $@ 
    216      
    217     if [ X${2} != X. ] ; then 
    218         eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${2} ) > /dev/null 2>&1 
    219     else 
    220         eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${1} ) > /dev/null 2>&1 
    221     fi 
    222  
    223     IGCM_debug_PopStack "IGCM_comp_PrepareDeletedFiles" 
     235  IGCM_debug_PushStack "IGCM_comp_PrepareDeletedFiles" $@ 
     236   
     237  if [ X${2} != X. ] ; then 
     238    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${2} ) > /dev/null 2>&1 
     239  else 
     240    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${1} ) > /dev/null 2>&1 
     241  fi 
     242 
     243  IGCM_debug_PopStack "IGCM_comp_PrepareDeletedFiles" 
    224244} 
    225245 
     
    227247function IGCM_comp_GetInputInitialStateFiles 
    228248{ 
    229     IGCM_debug_PushStack "IGCM_comp_GetInputInitialStateFiles" 
    230  
    231     # Debug Print : 
    232     echo 
    233     IGCM_debug_Print 1 "IGCM_comp_GetInputInitialStateFiles" 
    234     echo 
    235  
    236     # Only the first time step need InitialStateFiles  
    237     # otherwise it's BoundaryConditions 
    238     if ( ${FirstInitialize} ) ; then 
    239       typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_  
    240       typeset file_in_ file_in file_out_ file_out do_init  
    241       for comp in ${config_ListOfComponents[*]} ; do 
    242           # Initialize 
     249  IGCM_debug_PushStack "IGCM_comp_GetInputInitialStateFiles" 
     250 
     251  # Debug Print : 
     252  echo 
     253  IGCM_debug_Print 1 "IGCM_comp_GetInputInitialStateFiles" 
     254  echo 
     255 
     256  # Only the first time step need InitialStateFiles  
     257  # otherwise it's BoundaryConditions 
     258  if ( ${FirstInitialize} ) ; then 
     259    typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_  
     260    typeset file_in_ file_in file_out_ file_out do_init  
     261    for comp in ${config_ListOfComponents[*]} ; do 
     262      # Initialize 
     263      do_init="y" 
     264      # Do we need to bring initial state file for this component 
     265      if [ "${config_Restarts_OverRule}" = "y" ] ; then 
     266        eval do_init="n" 
     267      else 
     268        # Read component Restarts parameters 
     269        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart 
     270        eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 
     271        if [ "${do_start}" = "y" ] ; then 
     272          do_init="n" 
     273        else 
    243274          do_init="y" 
    244           # Do we need to bring initial state file for this component 
    245           if [ "${config_Restarts_OverRule}" = "y" ] ; then 
    246               eval do_init="n" 
    247           else 
    248               # Read component Restarts parameters 
    249               IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart 
    250               eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 
    251               if [ "${do_start}" = "y" ] ; then 
    252                     do_init="n" 
    253               else 
    254                     do_init="y" 
    255               fi 
    256           fi 
    257  
    258           if [ "${do_init}" = "y" ] ; then 
    259               # Define component  
    260               eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
    261               eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    262  
    263               # Debug Print : 
    264               IGCM_debug_Print 3 "Initialisation files ${compname}" 
    265  
    266               card=${SUBMIT_DIR}/COMP/${compname}.card 
    267  
    268               IGCM_card_DefineArrayFromOption ${card} InitialStateFiles List 
    269               ListFilesName=${compname}_InitialStateFiles_List 
    270  
    271               eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    272               if [ X${FileName0} != X${NULL_STR} ] ; then 
    273                   eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    274                   (( i=0 )) 
    275                   until [ $i -ge $NbFiles ]; do 
    276                       eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    277                       eval file_in=${file_in_} 
    278                       (( i_ = i+1 )) 
    279                       eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    280                       eval file_out=${file_out_} 
    281                        
    282                       IGCM_sys_Get ${file_in} ${file_out} 
    283                       #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
    284  
    285                       (( i=i+2 )) 
    286                   done 
    287               fi 
    288           fi 
    289       done 
    290     fi 
    291     IGCM_debug_PopStack "IGCM_comp_GetInputInitialStateFiles" 
     275        fi 
     276      fi 
     277 
     278      if [ "${do_init}" = "y" ] ; then 
     279        # Define component  
     280        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     281        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
     282 
     283        # Debug Print : 
     284        IGCM_debug_Print 3 "Initialisation files ${compname}" 
     285 
     286        card=${SUBMIT_DIR}/COMP/${compname}.card 
     287 
     288        IGCM_card_DefineArrayFromOption ${card} InitialStateFiles List 
     289        ListFilesName=${compname}_InitialStateFiles_List 
     290 
     291        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
     292        if [ X${FileName0} != X${NULL_STR} ] ; then 
     293          eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     294          (( i=0 )) 
     295          until [ $i -ge $NbFiles ]; do 
     296            eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     297            eval file_in=${file_in_} 
     298            (( i_ = i+1 )) 
     299            eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     300            eval file_out=${file_out_} 
     301             
     302            IGCM_sys_Get ${file_in} ${file_out} 
     303            #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
     304 
     305            (( i=i+2 )) 
     306          done 
     307        fi 
     308      fi 
     309    done 
     310  fi 
     311  IGCM_debug_PopStack "IGCM_comp_GetInputInitialStateFiles" 
    292312} 
    293313 
     
    311331function IGCM_SmoothModulo 
    312332{ 
    313     IGCM_debug_PushStack "IGCM_SmoothModulo" 
    314     typeset defVector ModValue 
    315  
    316     eval set +A defVector -- $( echo "${1}" | \ 
    317         gawk -F ':' '{print ($1 == "" ? 1 : $1) " " (NF==3 ? ($2 == "" ? 1 : $2) : 1) " " (NF==3 ? ($3 == "" ? -1 : $3) : ($2 == "" ? -1 : $2))}' ) 
    318  
    319     # Save Smooth Min and Max. Needed to call IGCM_sys_Get when appropriate 
    320     arr[1]=${defVector[0]} 
    321     arr[2]=${defVector[2]} 
    322  
    323     # Test limits :  
    324     # ${defVector[0]} <= ${2} <= ${defVector[2]}  
    325     #                                      or ${defVector[2]} == -1 
    326     if ( [ ${2} -ge ${defVector[0]} ] && \ 
    327          ( [ ${2} -le ${defVector[2]} ] || \ 
    328            [ ${defVector[2]} -lt 0 ] ) ) ; then 
    329         # Test modulo 
    330         ModValue=$( expr \( ${2} - ${defVector[0]} \) % ${defVector[1]} ) 
    331         if [ ${ModValue} -eq 0 ] ;  then 
    332             arr[3]=true 
    333             echo ${arr[@]} 
    334             IGCM_debug_PopStack "IGCM_SmoothModulo" 
    335             return 1 
    336         else 
    337             arr[3]=false 
    338             echo ${arr[@]} 
    339             IGCM_debug_PopStack "IGCM_SmoothModulo" 
    340             return 0 
    341         fi 
     333  IGCM_debug_PushStack "IGCM_SmoothModulo" 
     334  typeset defVector ModValue 
     335 
     336  eval set +A defVector -- $( echo "${1}" | \ 
     337    gawk -F ':' '{print ($1 == "" ? 1 : $1) " " (NF==3 ? ($2 == "" ? 1 : $2) : 1) " " (NF==3 ? ($3 == "" ? -1 : $3) : ($2 == "" ? -1 : $2))}' ) 
     338 
     339  # Save Smooth Min and Max. Needed to call IGCM_sys_Get when appropriate 
     340  arr[1]=${defVector[0]} 
     341  arr[2]=${defVector[2]} 
     342 
     343  # Test limits :  
     344  # ${defVector[0]} <= ${2} <= ${defVector[2]}  
     345  #          or ${defVector[2]} == -1 
     346  if ( [ ${2} -ge ${defVector[0]} ] && ( [ ${2} -le ${defVector[2]} ] || [ ${defVector[2]} -lt 0 ] ) ) ; then 
     347    # Test modulo 
     348    ModValue=$( expr \( ${2} - ${defVector[0]} \) % ${defVector[1]} ) 
     349    if [ ${ModValue} -eq 0 ] ;  then 
     350      arr[3]=true 
     351      echo ${arr[@]} 
     352      IGCM_debug_PopStack "IGCM_SmoothModulo" 
     353      return 1 
    342354    else 
    343         arr[3]=false 
    344         echo ${arr[@]} 
    345         IGCM_debug_PopStack "IGCM_SmoothModulo" 
    346         return 0 
    347     fi 
     355      arr[3]=false 
     356      echo ${arr[@]} 
     357      IGCM_debug_PopStack "IGCM_SmoothModulo" 
     358      return 0 
     359    fi 
     360  else 
     361    arr[3]=false 
     362    echo ${arr[@]} 
     363    IGCM_debug_PopStack "IGCM_SmoothModulo" 
     364    return 0 
     365  fi 
    348366} 
    349367 
     
    351369function IGCM_comp_GetInputSmoothFiles 
    352370{ 
    353     IGCM_debug_PushStack "IGCM_comp_GetInputSmoothFiles" 
     371  IGCM_debug_PushStack "IGCM_comp_GetInputSmoothFiles" 
     372 
     373  # Debug Print : 
     374  echo 
     375  IGCM_debug_Print 1 "IGCM_comp_GetInputSmoothFiles" 
     376  echo 
     377 
     378  typeset comp compname comptagname card ListFilesName FileName0 NbFiles j i i_ i__ 
     379  typeset file_in_ file_in file_out_ file_out ret SmoothDef aux val 
     380 
     381  for comp in ${config_ListOfComponents[*]} ; do 
     382    # Define component 
     383    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     384    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    354385 
    355386    # Debug Print : 
    356     echo 
    357     IGCM_debug_Print 1 "IGCM_comp_GetInputSmoothFiles" 
    358     echo 
    359  
    360     typeset comp compname comptagname card ListFilesName FileName0 NbFiles j i i_ i__ 
    361     typeset file_in_ file_in file_out_ file_out ret SmoothDef aux val 
    362  
    363     for comp in ${config_ListOfComponents[*]} ; do 
    364         # Define component 
    365         eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
    366         eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    367  
    368         # Debug Print : 
    369         IGCM_debug_Print 3 "Smooth files ${compname}" 
    370  
    371         card=${SUBMIT_DIR}/COMP/${compname}.card 
    372  
    373         IGCM_card_DefineArrayFromOption ${card} SmoothFiles List 
    374         ListFilesName=${compname}_SmoothFiles_List 
    375         eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    376  
    377         if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != X"Section" ] ) ; then 
    378             eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    379  
    380             (( i=0 )) 
    381             until [ $i -ge $NbFiles ]; do 
    382                 eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    383                 eval file_in=${file_in_} 
    384                 (( i_ = i+1 )) 
    385                 eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    386                 eval file_out=${file_out_} 
    387  
    388                 # define CumulPeriod definition for this file 
    389                 (( i__ = i+2 )) 
    390                 eval SmoothDef=\${${ListFilesName}[$i__]} 
    391                 IGCM_debug_Print 3 "  ${file_in} ${SmoothDef}" 
    392                 aux=$( IGCM_SmoothModulo ${SmoothDef} ${CumulPeriod} ) 
    393                 j=1 
    394                 for val in ${aux} ; do 
    395                     [ ${j} -eq 1 ] && SmoothMin=${val} 
    396                     [ ${j} -eq 2 ] && SmoothMax=${val} 
    397                     [ ${j} -eq 3 ] && ret=${val} 
    398                     (( j=j+1 )) 
    399                 done 
    400                 [ ${SmoothMax} -eq -1 ] && SmoothMax=${CumulPeriod} 
    401                 if ( [ X${ret} = Xtrue ] || ( [ ${Period} -eq 1 ] && [ ${CumulPeriod} -ge ${SmoothMin} ] && [ ${CumulPeriod} -le ${SmoothMax} ] ) ) ; then 
    402                 #if ( [ X${ret} = Xtrue ] || [ ${Period} -eq 1 ] ) ; then 
    403                     IGCM_sys_Get ${file_in} ${file_out} 
    404                     #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
    405                 fi 
    406                 (( i=i+3 )) 
    407             done 
     387    IGCM_debug_Print 3 "Smooth files ${compname}" 
     388 
     389    card=${SUBMIT_DIR}/COMP/${compname}.card 
     390 
     391    IGCM_card_DefineArrayFromOption ${card} SmoothFiles List 
     392    ListFilesName=${compname}_SmoothFiles_List 
     393    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
     394 
     395    if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != X"Section" ] ) ; then 
     396      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     397 
     398      (( i=0 )) 
     399      until [ $i -ge $NbFiles ]; do 
     400        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     401        eval file_in=${file_in_} 
     402        (( i_ = i+1 )) 
     403        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     404        eval file_out=${file_out_} 
     405 
     406        # define CumulPeriod definition for this file 
     407        (( i__ = i+2 )) 
     408        eval SmoothDef=\${${ListFilesName}[$i__]} 
     409        IGCM_debug_Print 3 "  ${file_in} ${SmoothDef}" 
     410        aux=$( IGCM_SmoothModulo ${SmoothDef} ${CumulPeriod} ) 
     411        j=1 
     412        for val in ${aux} ; do 
     413          [ ${j} -eq 1 ] && SmoothMin=${val} 
     414          [ ${j} -eq 2 ] && SmoothMax=${val} 
     415          [ ${j} -eq 3 ] && ret=${val} 
     416          (( j=j+1 )) 
     417        done 
     418        [ ${SmoothMax} -eq -1 ] && SmoothMax=${CumulPeriod} 
     419        if ( [ X${ret} = Xtrue ] || ( [ ${Period} -eq 1 ] && [ ${CumulPeriod} -ge ${SmoothMin} ] && [ ${CumulPeriod} -le ${SmoothMax} ] ) ) ; then 
     420          #if ( [ X${ret} = Xtrue ] || [ ${Period} -eq 1 ] ) ; then 
     421          IGCM_sys_Get ${file_in} ${file_out} 
     422          #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
    408423        fi 
    409     done 
    410      
    411     IGCM_debug_PopStack "IGCM_comp_GetInputSmoothFiles" 
     424        (( i=i+3 )) 
     425      done 
     426    fi 
     427  done 
     428   
     429  IGCM_debug_PopStack "IGCM_comp_GetInputSmoothFiles" 
    412430} 
    413431 
     
    415433function IGCM_comp_GetInputBoundaryFiles 
    416434{ 
    417     IGCM_debug_PushStack "IGCM_comp_GetInputBoundaryFiles" 
     435  IGCM_debug_PushStack "IGCM_comp_GetInputBoundaryFiles" 
     436 
     437  # Debug Print : 
     438  echo 
     439  IGCM_debug_Print 1 "IGCM_comp_GetInputBoundaryFiles" 
     440  echo 
     441 
     442  typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_  
     443  typeset file_in_ file_in file_out_ file_out  
     444 
     445  if [ ${Period} = 1 ]; then 
     446    ListFixBoundary=" " 
     447  fi 
     448 
     449  for comp in ${config_ListOfComponents[*]} ; do 
     450 
     451    # Define component 
     452    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     453    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    418454 
    419455    # Debug Print : 
    420     echo 
    421     IGCM_debug_Print 1 "IGCM_comp_GetInputBoundaryFiles" 
    422     echo 
    423  
    424     typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_  
    425     typeset file_in_ file_in file_out_ file_out  
    426  
     456    IGCM_debug_Print 3 "Boundary files ${compname}" 
     457 
     458    card=${SUBMIT_DIR}/COMP/${compname}.card 
     459 
     460    IGCM_card_DefineArrayFromOption ${card} BoundaryFiles List 
     461    ListFilesName=${compname}_BoundaryFiles_List 
     462    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
     463 
     464    if [ X${FileName0} != X${NULL_STR} ] ; then 
     465      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     466 
     467      (( i=0 )) 
     468      until [ $i -ge $NbFiles ]; do 
     469        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     470        eval file_in=${file_in_} 
     471        (( i_ = i+1 )) 
     472        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     473        eval file_out=${file_out_} 
     474 
     475        IGCM_sys_Get ${file_in} ${file_out} 
     476        IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
     477 
     478        (( i=i+2 )) 
     479      done 
     480    fi 
     481 
     482    # Get non deleted files 
    427483    if [ ${Period} = 1 ]; then 
    428         ListFixBoundary=" " 
    429     fi 
    430  
    431     for comp in ${config_ListOfComponents[*]} ; do 
    432  
    433         # Define component 
    434         eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
    435         eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    436  
    437         # Debug Print : 
    438         IGCM_debug_Print 3 "Boundary files ${compname}" 
    439  
    440         card=${SUBMIT_DIR}/COMP/${compname}.card 
    441  
    442         IGCM_card_DefineArrayFromOption ${card} BoundaryFiles List 
    443         ListFilesName=${compname}_BoundaryFiles_List 
    444         eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    445  
    446         if [ X${FileName0} != X${NULL_STR} ] ; then 
    447             eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    448  
    449             (( i=0 )) 
    450             until [ $i -ge $NbFiles ]; do 
    451                 eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    452                 eval file_in=${file_in_} 
    453                 (( i_ = i+1 )) 
    454                 eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    455                 eval file_out=${file_out_} 
    456  
    457                 IGCM_sys_Get ${file_in} ${file_out} 
    458                 IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
    459  
    460                 (( i=i+2 )) 
    461             done 
    462         fi 
    463  
    464         # Get non deleted files 
    465         if [ ${Period} = 1 ]; then 
    466  
    467             IGCM_card_DefineArrayFromOption ${card} BoundaryFiles ListNonDel 
    468             ListFilesName=${compname}_BoundaryFiles_ListNonDel 
    469             eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    470              
    471             if [ X${FileName0} != X${NULL_STR} ] ; then 
    472                 eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    473                  
    474                 (( i=0 )) 
    475                 until [ $i -ge $NbFiles ]; do 
    476                     eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    477                     eval file_in=${file_in_} 
    478                     (( i_ = i+1 )) 
    479                     eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    480                     eval file_out=${file_out_} 
    481  
    482                     IGCM_sys_Get ${file_in} ${file_out} 
    483  
    484                     if [ X${file_out} != X. ] ; then 
    485                         ListFixBoundary=${ListFixBoundary}" "${file_out} 
    486                     else 
    487                         ListFixBoundary=${ListFixBoundary}" "$( basename ${file_in} ) 
    488                     fi 
    489  
    490                     (( i=i+2 )) 
    491                 done 
    492             fi 
    493         fi 
    494     done 
    495      
    496     IGCM_debug_PopStack "IGCM_comp_GetInputBoundaryFiles" 
     484 
     485      IGCM_card_DefineArrayFromOption ${card} BoundaryFiles ListNonDel 
     486      ListFilesName=${compname}_BoundaryFiles_ListNonDel 
     487      eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
     488       
     489      if [ X${FileName0} != X${NULL_STR} ] ; then 
     490        eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     491         
     492        (( i=0 )) 
     493        until [ $i -ge $NbFiles ]; do 
     494          eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     495          eval file_in=${file_in_} 
     496          (( i_ = i+1 )) 
     497          eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     498          eval file_out=${file_out_} 
     499 
     500          IGCM_sys_Get ${file_in} ${file_out} 
     501 
     502          if [ X${file_out} != X. ] ; then 
     503            ListFixBoundary=${ListFixBoundary}" "${file_out} 
     504          else 
     505            ListFixBoundary=${ListFixBoundary}" "$( basename ${file_in} ) 
     506          fi 
     507 
     508          (( i=i+2 )) 
     509        done 
     510      fi 
     511    fi 
     512  done 
     513   
     514  IGCM_debug_PopStack "IGCM_comp_GetInputBoundaryFiles" 
    497515} 
    498516 
     
    500518function IGCM_comp_DelFixeBoundaryFiles 
    501519{ 
    502     IGCM_debug_PushStack "IGCM_comp_DelFixeBoundaryFiles" 
    503  
    504     # Debug Print : 
    505     echo 
    506     IGCM_debug_Print 1 "IGCM_comp_DelFixeBoundaryFiles" 
    507     echo 
    508  
    509     ls -l ${ListFixBoundary} 
    510     rm -f ${ListFixBoundary} 
    511  
    512     IGCM_debug_PopStack "IGCM_comp_DelFixeBoundaryFiles" 
     520  IGCM_debug_PushStack "IGCM_comp_DelFixeBoundaryFiles" 
     521 
     522  # Debug Print : 
     523  echo 
     524  IGCM_debug_Print 1 "IGCM_comp_DelFixeBoundaryFiles" 
     525  echo 
     526 
     527  ls -l ${ListFixBoundary} 
     528  rm -f ${ListFixBoundary} 
     529 
     530  IGCM_debug_PopStack "IGCM_comp_DelFixeBoundaryFiles" 
    513531} 
    514532 
     
    516534function IGCM_comp_GetInputParametersFiles 
    517535{ 
    518     IGCM_debug_PushStack "IGCM_comp_GetInputParametersFiles" 
     536  IGCM_debug_PushStack "IGCM_comp_GetInputParametersFiles" 
     537 
     538  # Debug Print : 
     539  echo 
     540  IGCM_debug_Print 1 "IGCM_comp_GetInputParametersFiles" 
     541  echo 
     542 
     543  typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ file_in file_out 
     544  for comp in ${config_ListOfComponents[*]} ; do 
     545    # Define component  
     546    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     547    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    519548 
    520549    # Debug Print : 
    521     echo 
    522     IGCM_debug_Print 1 "IGCM_comp_GetInputParametersFiles" 
    523     echo 
    524  
    525     typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ file_in file_out 
    526     for comp in ${config_ListOfComponents[*]} ; do 
    527         # Define component  
    528         eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
    529         eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    530  
    531         # Debug Print : 
    532         IGCM_debug_Print 3 "Parameters ${compname}" 
    533  
    534         card=${SUBMIT_DIR}/COMP/${compname}.card         
    535  
    536         IGCM_card_DefineArrayFromOption ${card} ParametersFiles List 
    537         ListFilesName=${compname}_ParametersFiles_List 
    538         eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    539  
    540         if [ X${FileName0} != X${NULL_STR} ] ; then 
    541             eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    542  
    543             (( i=0 )) 
    544             until [ $i -ge $NbFiles ]; do 
    545                 eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    546                 eval file_in=${file_in_} 
    547                 (( i_ = i+1 )) 
    548                 eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    549                 eval file_out=${file_out_}  
    550  
    551                 IGCM_sys_Cp ${file_in} ${file_out}  
    552                 IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
    553  
    554                 (( i=i+2 )) 
    555             done 
    556         fi 
    557     done 
    558  
    559     IGCM_debug_PopStack "IGCM_comp_GetInputParametersFiles" 
     550    IGCM_debug_Print 3 "Parameters ${compname}" 
     551 
     552    card=${SUBMIT_DIR}/COMP/${compname}.card     
     553 
     554    IGCM_card_DefineArrayFromOption ${card} ParametersFiles List 
     555    ListFilesName=${compname}_ParametersFiles_List 
     556    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
     557 
     558    if [ X${FileName0} != X${NULL_STR} ] ; then 
     559      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     560 
     561      (( i=0 )) 
     562      until [ $i -ge $NbFiles ]; do 
     563        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     564        eval file_in=${file_in_} 
     565        (( i_ = i+1 )) 
     566        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     567        eval file_out=${file_out_}  
     568 
     569        IGCM_sys_Cp ${file_in} ${file_out}  
     570        IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
     571 
     572        (( i=i+2 )) 
     573      done 
     574    fi 
     575  done 
     576 
     577  IGCM_debug_PopStack "IGCM_comp_GetInputParametersFiles" 
    560578} 
    561579 
     
    563581function IGCM_comp_GetInputRestartFiles 
    564582{ 
    565     IGCM_debug_PushStack "IGCM_comp_GetInputRestartFiles" 
     583  IGCM_debug_PushStack "IGCM_comp_GetInputRestartFiles" 
     584 
     585  # Debug Print : 
     586  echo 
     587  IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles" 
     588  echo 
     589 
     590  typeset Date_tmp Date_r Path_r do_start CompOldName Path_OUT Path_BUF Buffered 
     591  typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_  
     592  typeset file_in file_out file_in_ file_out_ file_in_Name 
     593  typeset -Z4 j4 
     594 
     595  for comp in ${config_ListOfComponents[*]} ; do 
     596    # Define component  
     597    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     598    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
     599    # 
     600    card=${SUBMIT_DIR}/COMP/${compname}.card 
     601    # 
     602    IGCM_card_DefineArrayFromOption ${card} RestartFiles List 
     603    ListFilesName=${compname}_RestartFiles_List 
     604    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    566605 
    567606    # Debug Print : 
    568     echo 
    569     IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles" 
    570     echo 
    571  
    572     typeset Date_tmp Date_r Path_r do_start CompOldName Path_temp 
    573     typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_  
    574     typeset file_in file_out file_in_ file_out_ file_in_Name 
    575     typeset -Z4 j4 
    576  
    577     for comp in ${config_ListOfComponents[*]} ; do 
    578         # Define component  
    579         eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
    580         eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    581         # 
    582         card=${SUBMIT_DIR}/COMP/${compname}.card 
    583         # 
    584         IGCM_card_DefineArrayFromOption ${card} RestartFiles List 
    585         ListFilesName=${compname}_RestartFiles_List 
    586         eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    587  
    588         # Debug Print : 
    589         IGCM_debug_Print 3 "restart ${compname}" 
    590  
    591         if ( ${FirstInitialize} ) ; then 
    592  
    593             if [ "${config_Restarts_OverRule}" = "y" ] ; then 
    594                 eval config_${comp}_Restart="y" 
    595                 eval config_${comp}_RestartDate=${config_Restarts_RestartDate} 
    596                 eval config_${comp}_RestartJobName=${config_Restarts_RestartJobName} 
    597                 eval config_${comp}_RestartPath=${config_Restarts_RestartPath} 
    598                 eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 
    599                 eval CompOldName=${comp} 
     607    IGCM_debug_Print 3 "restart ${compname}" 
     608 
     609    if ( ${FirstInitialize} ) ; then 
     610 
     611      if [ "${config_Restarts_OverRule}" = "y" ] ; then 
     612        eval config_${comp}_Restart="y" 
     613        eval config_${comp}_RestartDate=${config_Restarts_RestartDate} 
     614        eval config_${comp}_RestartJobName=${config_Restarts_RestartJobName} 
     615        eval config_${comp}_RestartPath=${config_Restarts_RestartPath} 
     616        eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 
     617        eval CompOldName=${comp} 
     618      else 
     619                # Read component Restarts parameters 
     620        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart 
     621        eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 
     622 
     623        if [ "${do_start}" = "y" ] ; then 
     624          IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartDate 
     625          IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartJobName 
     626          IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartPath 
     627        else 
     628          eval config_${comp}_RestartDate=-1 
     629          eval config_${comp}_RestartJobName=${NULL_STR} 
     630          eval config_${comp}_RestartPath=${NULL_STR} 
     631        fi 
     632        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} OldName 
     633        eval CompOldName=\${config_${comp}_OldName} 
     634        if [ X${CompOldName} = X ] ; then 
     635          eval CompOldName=${comp} 
     636        fi 
     637      fi 
     638 
     639      if [ "${do_start}" = "y" ] ; then 
     640 
     641        if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then 
     642          eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     643 
     644          (( i=1 )) 
     645          until [ $i -gt $NbFiles ]; do 
     646            eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     647            eval file_in=${file_in_} 
     648 
     649            (( i_ = i+1 )) 
     650            eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     651            eval file_out=${file_out_} 
     652             
     653            eval Date_tmp=\${config_${comp}_RestartDate} 
     654            Date_r=$( IGCM_date_ConvertFormatToGregorian ${Date_tmp} ) 
     655            eval Path_r=\${config_${comp}_RestartPath}/\${config_${comp}_RestartJobName}/${CompOldName}/Restart 
     656            eval file_in_Name=\${config_${comp}_RestartJobName}_${Date_r}_${file_in} 
     657 
     658            generic_restart_file_name_in=$( basename ${file_in_Name} .nc ) 
     659            generic_restart_file_name_out=$( basename ${file_out} .nc ) 
     660             
     661            eval Path_OUT=\${Path_r}/${generic_restart_file_name_in} 
     662            nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_OUT}_????.nc) 
     663 
     664            if [ ${nb_restart_file} -gt 1 ] ; then 
     665              j=0 
     666              until [ $j -ge $nb_restart_file ]; do 
     667                j4=${j} 
     668                eval IGCM_sys_Get ${Path_r}/${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc 
     669                #IGCM_comp_PrepareDeletedFiles ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc 
     670                #eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${generic_restart_file_name_out}_${j4}.nc" > /dev/null 2>&1 
     671                (( j=j+1 )) 
     672              done 
    600673            else 
    601                 # Read component Restarts parameters 
    602                 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart 
    603                 eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 
    604  
    605                 if [ "${do_start}" = "y" ] ; then 
    606                     IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartDate 
    607                     IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartJobName 
    608                     IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartPath 
    609                 else 
    610                     eval config_${comp}_RestartDate=-1 
    611                     eval config_${comp}_RestartJobName=${NULL_STR} 
    612                     eval config_${comp}_RestartPath=${NULL_STR} 
    613                 fi 
    614                 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} OldName 
    615                 eval CompOldName=\${config_${comp}_OldName} 
    616                 if [ X${CompOldName} = X ] ; then 
    617                     eval CompOldName=${comp} 
    618                 fi 
    619             fi 
    620  
    621             if [ "${do_start}" = "y" ] ; then 
    622  
    623                 if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then 
    624                     eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    625  
    626                     (( i=1 )) 
    627                     until [ $i -gt $NbFiles ]; do 
    628                         eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    629                         eval file_in=${file_in_} 
    630  
    631                         (( i_ = i+1 )) 
    632                         eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    633                         eval file_out=${file_out_} 
    634                          
    635                         eval Date_tmp=\${config_${comp}_RestartDate} 
    636                         Date_r=$( IGCM_date_ConvertFormatToGregorian ${Date_tmp} ) 
    637                         eval Path_r=\${config_${comp}_RestartPath}/\${config_${comp}_RestartJobName}/${CompOldName}/Restart 
    638                         eval file_in_Name=\${config_${comp}_RestartJobName}_${Date_r}_${file_in} 
    639  
    640                         generic_restart_file_name_in=$( basename ${file_in_Name} .nc ) 
    641                         generic_restart_file_name_out=$( basename ${file_out} .nc ) 
    642                          
    643                         eval Path_temp=\${Path_r}/${generic_restart_file_name_in} 
    644                         nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_temp}_????.nc) 
    645  
    646                         if [ ${nb_restart_file} -gt 1 ] ; then 
    647                             j=0 
    648                             until [ $j -ge $nb_restart_file ]; do 
    649                                 j4=${j} 
    650                                 eval IGCM_sys_Get ${Path_r}/${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc 
    651                                 #IGCM_comp_PrepareDeletedFiles ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc 
    652                                 #eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${generic_restart_file_name_out}_${j4}.nc" > /dev/null 2>&1 
    653                                 (( j=j+1 )) 
    654                             done 
    655                         else 
    656                             eval IGCM_sys_Get ${Path_r}/${file_in_Name} ${file_out}   
    657                             #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
    658                         fi 
    659                  
    660                         (( i=i+3 )) 
    661                     done 
    662                 else 
    663                     if [ X${FileName0} != XNONE ] ; then 
    664                         IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}." 
    665                     else 
    666                         IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}." 
    667                     fi 
    668                 fi 
    669             fi 
    670         elif [ ${Period} -eq 1 ] ; then 
    671             # if not FirstInitialize and first loop of this job 
    672  
    673             # Restore Restarts files 
    674             #----------------------- 
    675             if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then 
    676                 eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    677  
    678                 (( i=1 )) 
    679                 until [ $i -gt $NbFiles ]; do 
    680                     eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    681                     eval file_in=${file_in_} 
    682                     (( i_ = i+1 )) 
    683                     eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    684                     eval file_out=${file_out_} 
    685                      
    686                     file_in_Name=${run_Configuration_OldPrefix}_${file_in} 
    687  
    688                     generic_restart_file_name_in=$( basename ${file_in_Name} .nc ) 
    689                     generic_restart_file_name_out=$( basename ${file_out} .nc ) 
    690  
    691                     eval Path_temp=\${R_OUT_${comp}_R}/${generic_restart_file_name_in} 
    692                     nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_temp}_????.nc) 
    693  
    694                     if [ ${nb_restart_file} -gt 1 ] ; then 
    695                         j=0 
    696                         until [ $j -ge $nb_restart_file ]; do 
    697                             j4=${j} 
    698                             eval IGCM_sys_Get \${R_OUT_${comp}_R}/${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc 
    699                             #IGCM_comp_PrepareDeletedFiles ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc 
    700                             #eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${generic_restart_file_name_out}_${j4}.nc" > /dev/null 2>&1 
    701  
    702                             (( j=j+1 )) 
    703                         done 
    704                     else 
    705                         eval IGCM_sys_Get \${R_OUT_${comp}_R}/${file_in_Name} ${file_out} 
    706                         #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
    707                     fi 
    708  
    709                     (( i=i+3 )) 
    710                 done 
     674              eval IGCM_sys_Get ${Path_r}/${file_in_Name} ${file_out}   
     675              #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
     676            fi 
     677             
     678            (( i=i+3 )) 
     679          done 
     680        else 
     681          if [ X${FileName0} != XNONE ] ; then 
     682            IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}." 
     683          else 
     684            IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}." 
     685          fi 
     686        fi 
     687      fi 
     688    elif [ ${Period} -eq 1 ] ; then 
     689      # if not FirstInitialize and first loop of this job 
     690 
     691      # Restore Restarts files 
     692      #----------------------- 
     693      if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then 
     694        eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     695 
     696        (( i=1 )) 
     697        until [ $i -gt $NbFiles ]; do 
     698          eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     699          eval file_in=${file_in_} 
     700          (( i_ = i+1 )) 
     701          eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     702          eval file_out=${file_out_} 
     703           
     704          file_in_Name=${run_Configuration_OldPrefix}_${file_in} 
     705 
     706          generic_restart_file_name_in=$( basename ${file_in_Name} .nc ) 
     707          generic_restart_file_name_out=$( basename ${file_out} .nc ) 
     708 
     709          eval Path_BUF=\${R_BUF_${comp}_R}/${generic_restart_file_name_in} 
     710          eval Path_OUT=\${R_OUT_${comp}_R}/${generic_restart_file_name_in} 
     711 
     712          if [ -f ${Path_BUF}*.nc ] ; then 
     713            Buffered=true 
     714            nb_restart_file=$(IGCM_sys_CountFileBuffer ${Path_BUF}_????.nc) 
     715          else 
     716            Buffered=false 
     717            nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_OUT}_????.nc) 
     718          fi 
     719 
     720          if [ ${nb_restart_file} -gt 1 ] ; then 
     721            j=0 
     722            until [ $j -ge $nb_restart_file ]; do 
     723              j4=${j} 
     724              if [ ${Buffered} ] ; then 
     725                IGCM_sys_GetBuffer ${Path_BUF}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc 
     726              else 
     727                IGCM_sys_Get ${Path_OUT}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc 
     728              fi 
     729              (( j=j+1 )) 
     730            done 
     731          else 
     732            if [ ${Buffered} ] ; then 
     733              eval IGCM_sys_GetBuffer \${R_BUF_${comp}_R}/${file_in_Name} ${file_out} 
    711734            else 
    712                 if [ X${FileName0} != XNONE ] ; then 
    713                     IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}." 
    714                 else 
    715                     IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}." 
    716                 fi 
    717             fi 
     735              eval IGCM_sys_Get \${R_OUT_${comp}_R}/${file_in_Name} ${file_out} 
     736            fi 
     737          fi 
     738 
     739          (( i=i+3 )) 
     740        done 
     741      else 
     742        if [ X${FileName0} != XNONE ] ; then 
     743          IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}." 
     744        else 
     745          IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}." 
    718746        fi 
    719     done 
    720  
    721     typeset NbFichs 
    722     NbFiles=$( ls * 2> /dev/null | wc -l ) 
    723     if [ ${NbFiles} -gt 0 ] ; then 
    724         IGCM_sys_Chmod u+rw * 
    725     fi 
    726  
    727     IGCM_debug_PopStack "IGCM_comp_GetInputRestartFiles" 
     747      fi 
     748    fi 
     749  done 
     750 
     751  NbFiles=$( ls * 2> /dev/null | wc -l ) 
     752  if [ ${NbFiles} -gt 0 ] ; then 
     753    IGCM_sys_Chmod u+rw * 
     754  fi 
     755 
     756  IGCM_debug_PopStack "IGCM_comp_GetInputRestartFiles" 
    728757} 
    729758 
     
    731760function IGCM_comp_PeriodStart 
    732761{ 
    733     IGCM_debug_PushStack "IGCM_comp_PeriodStart" 
    734  
    735     # Debug Print : 
    736     echo 
    737     IGCM_debug_Print 1 "IGCM_comp_PeriodStart" 
    738     echo 
    739  
    740     typeset ExeNameIn ExeNameOut  
    741     typeset comp compname comptagname 
    742     for comp in ${config_ListOfComponents[*]} ; do 
    743         # Define component  
    744         eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
    745         eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    746  
    747         # Copy executable for this component 
    748         eval ExeNameIn=\${config_Executable_${comp}[0]} 
    749         eval ExeNameOut=\${config_Executable_${comp}[1]} 
    750  
    751         # Debug Print 
    752         IGCM_debug_Print 3 "PeriodStart ${compname} Driver Function (if any)." 
    753         # UPDATE component 
    754         ${comp}_PeriodStart 2> /dev/null 
    755  
    756     done 
    757  
    758     IGCM_debug_PopStack "IGCM_comp_PeriodStart" 
     762  IGCM_debug_PushStack "IGCM_comp_PeriodStart" 
     763 
     764  # Debug Print : 
     765  echo 
     766  IGCM_debug_Print 1 "IGCM_comp_PeriodStart" 
     767  echo 
     768 
     769  typeset ExeNameIn ExeNameOut  
     770  typeset comp compname comptagname 
     771  for comp in ${config_ListOfComponents[*]} ; do 
     772    # Define component  
     773    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     774    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
     775 
     776    # Copy executable for this component 
     777    eval ExeNameIn=\${config_Executable_${comp}[0]} 
     778    eval ExeNameOut=\${config_Executable_${comp}[1]} 
     779 
     780    # Debug Print 
     781    IGCM_debug_Print 3 "PeriodStart ${compname} Driver Function (if any)." 
     782    # UPDATE component 
     783    ${comp}_PeriodStart 2> /dev/null 
     784 
     785  done 
     786 
     787  IGCM_debug_PopStack "IGCM_comp_PeriodStart" 
    759788} 
    760789 
     
    762791function IGCM_comp_Update 
    763792{ 
    764     IGCM_debug_PushStack "IGCM_comp_Update" 
     793  IGCM_debug_PushStack "IGCM_comp_Update" 
    765794 
    766795    # Debug Print : 
    767     echo 
    768     IGCM_debug_Print 1 "IGCM_comp_Update" 
    769     echo 
    770  
    771     typeset ExeNameIn ExeNameOut  
    772     typeset comp compname comptagname 
    773     for comp in ${config_ListOfComponents[*]} ; do 
    774         # Define component  
    775         eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
    776         eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    777  
    778         # Copy executable for this component 
    779         eval ExeNameIn=\${config_Executable_${comp}[0]} 
    780         eval ExeNameOut=\${config_Executable_${comp}[1]} 
    781  
    782         # If missing executable then stop! 
    783         #if [ ! X${ExeNameIn} = X ] && [ ! -f ${R_EXE}/${ExeNameIn} ] ; then 
    784         #    IGCM_debug_Exit "IGCM_comp_Update missing executable ${ExeNameIn}" 
    785         #fi  
    786  
    787         if [ ${Period} -eq 1 ] && [ -f ${R_EXE}/${ExeNameIn} ] ; then 
    788             eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut} 
    789             if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then 
    790                 eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut} 
    791             fi 
    792         elif [ -f ${R_EXE}/${ExeNameIn} ] && [ ! -f ${RUN_DIR}/${ExeNameOut} ] ; then 
    793             eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut} 
    794             if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then 
    795                 eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut} 
    796             fi 
    797         fi 
    798  
    799         # Debug Print 
    800         IGCM_debug_Print 1 "Update ${compname} Parameter Files." 
    801         # UPDATE component 
    802         ${comp}_Update 
    803  
    804     done 
    805  
    806     IGCM_debug_PopStack "IGCM_comp_Update" 
     796  echo 
     797  IGCM_debug_Print 1 "IGCM_comp_Update" 
     798  echo 
     799 
     800  typeset ExeNameIn ExeNameOut  
     801  typeset comp compname comptagname 
     802  for comp in ${config_ListOfComponents[*]} ; do 
     803    # Define component  
     804    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     805    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
     806 
     807    # Copy executable for this component 
     808    eval ExeNameIn=\${config_Executable_${comp}[0]} 
     809    eval ExeNameOut=\${config_Executable_${comp}[1]} 
     810 
     811    # If missing executable then stop! 
     812    #if [ ! X${ExeNameIn} = X ] && [ ! -f ${R_EXE}/${ExeNameIn} ] ; then 
     813    #    IGCM_debug_Exit "IGCM_comp_Update missing executable ${ExeNameIn}" 
     814    #fi  
     815 
     816    if [ ${Period} -eq 1 ] && [ -f ${R_EXE}/${ExeNameIn} ] ; then 
     817      eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut} 
     818      if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then 
     819        eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut} 
     820      fi 
     821    elif [ -f ${R_EXE}/${ExeNameIn} ] && [ ! -f ${RUN_DIR}/${ExeNameOut} ] ; then 
     822      eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut} 
     823      if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then 
     824        eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut} 
     825      fi 
     826    fi 
     827 
     828    # Debug Print 
     829    IGCM_debug_Print 1 "Update ${compname} Parameter Files." 
     830    # UPDATE component 
     831    ${comp}_Update 
     832 
     833  done 
     834 
     835  IGCM_debug_PopStack "IGCM_comp_Update" 
    807836} 
    808837 
     
    810839function IGCM_comp_Finalize 
    811840{ 
    812     IGCM_debug_PushStack "IGCM_comp_Finalize" 
    813  
    814     # Debug Print : 
     841  IGCM_debug_PushStack "IGCM_comp_Finalize" 
     842 
     843  # Debug Print : 
     844  echo 
     845  IGCM_debug_Print 1 "IGCM_comp_Finalize" 
     846  echo 
     847 
     848  typeset ListTextName TextName0 
     849  typeset comp compname comptagname card ListFilesName FileName0 NbFiles SaveOnArchive 
     850  typeset i i_ file_in file_in_ file_out file_out_ file_outin file_outin_ generic_file_name nb_rebuild_file 
     851  typeset -Z4 j4 
     852  typeset list_file nlist_file 
     853  typeset compactoutputs 
     854 
     855  compactoutputs=false 
     856  if [ X${JobType} != XRUN ] ; then 
     857    compactoutputs=true 
     858  elif [ X${config_UserChoices_CompactText} != Xn ] ; then 
     859    compactoutputs=true 
     860  fi 
     861 
     862  for comp in ${config_ListOfComponents[*]} ; do 
     863    # Define component  
     864    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     865    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
     866 
     867    # Debug Print 
     868    IGCM_debug_Print 1 "Finalize ${comp} : ${compname} component." 
     869    # FINALIZE component 
     870    ${comp}_Finalize 
     871 
     872    card=${SUBMIT_DIR}/COMP/${compname}.card     
     873 
     874    # Save Restarts files 
     875    #-------------------- 
     876    IGCM_debug_Print 2 "Save Restart files for ${comp} : ${compname} component." 
     877    IGCM_card_DefineArrayFromOption ${card} RestartFiles List 
     878    ListFilesName=${compname}_RestartFiles_List 
     879    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
     880     
     881    if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then 
     882      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     883       
     884      (( i=0 )) 
     885      until [ $i -ge $NbFiles ]; do 
     886        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     887        eval file_in=${file_in_} 
     888 
     889        (( i_ = i+1 )) 
     890        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     891        eval file_out=${file_out_} 
     892 
     893        (( i_ = i+2 )) 
     894        eval file_outin_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     895        eval file_outin=${file_outin_} 
     896 
     897        generic_restart_file_name_in=$(    basename ${file_in} .nc ) 
     898        generic_restart_file_name_out=$(   basename ${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} .nc ) 
     899        generic_restart_file_name_outin=$( basename ${file_outin} .nc ) 
     900         
     901        nb_restart_file=$( ls ${generic_restart_file_name_in}_????.nc 2>/dev/null | wc -l )  
     902        if [ ${nb_restart_file} -gt 1 ] ; then 
     903          j=0 
     904          until [ $j -ge $nb_restart_file ]; do 
     905            j4=${j} 
     906            #eval IGCM_sys_Put_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_OUT_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc 
     907            eval IGCM_sys_PutBuffer_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_BUF_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc 
     908            if [ ! ${file_in} = ${file_outin} ] ; then 
     909              if ( ${ExitFlag} ) ; then 
     910                echo "IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc not executed." 
     911              else 
     912                IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc 
     913              fi 
     914            fi 
     915            (( j=j+1 )) 
     916          done 
     917        else 
     918          #eval IGCM_sys_Put_Rest ${file_in} \${R_OUT_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} 
     919          eval IGCM_sys_PutBuffer_Rest ${file_in} \${R_BUF_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} 
     920          if [ ! ${file_in} = ${file_outin} ] ; then 
     921            if ( ${ExitFlag} ) ; then 
     922              echo "IGCM_sys_Mv ${file_in} ${file_outin} not executed." 
     923            else 
     924              IGCM_sys_Mv ${file_in} ${file_outin} 
     925            fi 
     926          fi 
     927        fi 
     928 
     929        (( i=i+3 )) 
     930      done 
     931    else 
     932      if [ X${FileName0} != XNONE ] ; then 
     933        IGCM_debug_Exit "IGCM_comp_Finalize : No file in restart list for ${compname}." 
     934      else 
     935        IGCM_debug_Print 1 "IGCM_comp_Finalize : NONE specified in Restart List ${compname}." 
     936      fi 
     937    fi 
     938 
     939    # Save Output files 
     940    #------------------ 
     941    IGCM_debug_Print 2 "Save Output files for ${comp} : ${compname} component." 
     942    IGCM_card_DefineArrayFromOption ${card} OutputFiles List 
     943    ListFilesName=${compname}_OutputFiles_List 
     944    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
     945 
     946    if [ X${FileName0} != X${NULL_STR} ] ; then 
     947      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     948 
     949      (( i=0 )) 
     950      until [ $i -ge $NbFiles ]; do 
     951        SaveOnArchive=true 
     952        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     953        eval file_in=${file_in_} 
     954        (( i_ = i+1 )) 
     955        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     956        eval file_out=${file_out_} 
     957        (( i_ = i+2 )) 
     958        eval flag_post=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     959        # 
     960        generic_file_name=$( basename ${file_in} .nc ) 
     961        nb_rebuild_file=$( ls | grep "^${generic_file_name}_[0-9]*.nc" | wc -l ) 
     962        # 
     963        if ( [ ${nb_rebuild_file} -eq 1 ] && [ -f ${generic_file_name}_0000.nc ] ) ; then 
     964          IGCM_debug_Print 2 "Parallelism with 1 process. Rebuilding ${file_in} not needed" 
     965          IGCM_sys_Mv ${generic_file_name}_0000.nc ${file_in} 
     966        elif [ ${nb_rebuild_file} -gt 1 ] ; then 
     967          IGCM_debug_Print 2 "Parallelism detected rebuilding ${file_in} is needed" 
     968          if ( [ X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
     969            IGCM_debug_Print 2 "Rebuilding ${file_in} online" 
     970            IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc 
     971          else 
     972            IGCM_debug_Print 2 "Preparing offline rebuild for ${file_in}" 
     973            [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
     974            IGCM_sys_Mv ${generic_file_name}_????.nc ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
     975 
     976            # Prepare headers for the shell dedicated to offline rebuild 
     977            if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
     978              if [ $DRYRUN -le 1 ]; then 
     979                echo "#!/bin/ksh                                        " >  ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     980                echo "function IGCM_FlushRebuild                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     981                echo "{                                                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     982                echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\"        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     983                echo "echo                                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     984                echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\"          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     985                echo "echo                                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     986                echo "export R_SAVE=${R_SAVE}                           " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     987                echo "export config_UserChoices_JobName=${config_UserChoices_JobName} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     988              fi 
     989            fi 
     990            # Prepare the shell dedicated to offline rebuild 
     991            if [ $DRYRUN -le 1 ]; then 
     992              echo "IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     993              echo "IGCM_debug_Verif_Exit_Post                           " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     994            fi 
     995            # 
     996            # Load Patch we need to apply and apply 
     997            if [ $DRYRUN -le 1 ]; then 
     998              if [ X$( eval echo \${${compname}_${flag_post}_Patches[0]} ) !=  X${NULL_STR} ]; then 
     999                for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ); do 
     1000                  echo ". ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1001                  echo "IGCM_${Patch} ${file_in}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1002                  echo "IGCM_debug_Verif_Exit_Post                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1003                done 
     1004              fi 
     1005            fi 
     1006            # 
     1007            if [ $DRYRUN -le 1 ]; then 
     1008              echo "IGCM_sys_Put_Out ${file_in} ${file_out}             " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1009              echo "IGCM_debug_Verif_Exit_Post                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1010              echo "IGCM_sys_Rm ${generic_file_name}_*.nc               " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1011            fi 
     1012            SaveOnArchive=false 
     1013          fi 
     1014        fi 
     1015        # 
     1016        if [ ${SaveOnArchive} = true ] ; then 
     1017          # 
     1018          # If we need to apply a patch we use TMP DIRECTORY before ARCHIVING if asynchronous rebuild is on 
     1019          # 
     1020          thereisapatch=$( eval echo \${${compname}_${flag_post}_Patches[0]} ) 
     1021           
     1022          if ( [ ! X${thereisapatch} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = X ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
     1023            if [ -f ${file_in} ] ; then 
     1024              [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
     1025 
     1026              IGCM_sys_Mv ${file_in} ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
     1027              eval FileToBeDeleted[${#FileToBeDeleted[@]}]=REBUILD_${PeriodDateBegin}/${file_in} > /dev/null 2>&1 
     1028              # 
     1029              if [ $DRYRUN -le 1 ]; then 
     1030                if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
     1031                  echo "#!/bin/ksh                                      " >  ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1032                  echo "function IGCM_FlushRebuild                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1033                  echo "{                                               " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1034                  echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\"      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1035                  echo "echo                                            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1036                  echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\"        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1037                  echo "echo                                            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1038                  echo "export R_SAVE=${R_SAVE}                         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1039                  echo "export config_UserChoices_JobName=${config_UserChoices_JobName} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1040                fi 
     1041                # 
     1042                for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ); do 
     1043                  echo ". ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1044                  echo "IGCM_${Patch} ${file_in}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1045                  echo "IGCM_debug_Verif_Exit_Post                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1046                done 
     1047                # 
     1048                echo "IGCM_sys_Put_Out ${file_in} ${file_out}           " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1049                echo "IGCM_debug_Verif_Exit_Post                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1050                # 
     1051              fi 
     1052            fi 
     1053          else 
     1054            [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
     1055            if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
     1056              echo "#!/bin/ksh                                          " >  ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1057              echo "function IGCM_FlushRebuild                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1058              echo "{                                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1059              echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\"          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1060              echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1061              echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\"            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1062              echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1063              echo "export R_SAVE=${R_SAVE}                             " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1064              echo "export config_UserChoices_JobName=${config_UserChoices_JobName} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     1065            fi 
     1066 
     1067            IGCM_sys_Put_Out ${file_in} ${file_out} 
     1068            eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 
     1069            if [ ${nb_rebuild_file} -gt 1 ] ; then 
     1070              for DelFile in $( ls | grep "${generic_file_name}[_0-9]*.nc" ) ; do 
     1071                eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${DelFile} > /dev/null 2>&1 
     1072              done 
     1073            fi 
     1074          fi 
     1075        fi 
     1076        (( i=i+3 )) 
     1077      done 
     1078    fi 
     1079 
     1080    # Save Output Text files of models 
     1081    #--------------------------------- 
     1082    IGCM_debug_Print 2 "Save Output Text files for ${comp} : ${compname} component." 
     1083    IGCM_card_DefineArrayFromOption ${card} OutputText List 
     1084    ListTextName=${compname}_OutputText_List 
     1085     
     1086    eval TextName0=\${${ListTextName}[0]} > /dev/null 2>&1 
     1087    if [ X${TextName0} != X${NULL_STR} ] ; then 
     1088      eval NbFiles=\${#${ListTextName}[@]} > /dev/null 2>&1 
     1089 
     1090      (( i=0 )) 
     1091      until [ $i -eq $NbFiles ]; do 
     1092        eval file_in=\${${ListTextName}[$i]} > /dev/null 2>&1 
     1093        eval file_out=${PREFIX}_${file_in} 
     1094 
     1095        (( i=i+1 )) 
     1096 
     1097        unset list_file 
     1098        #set +A list_file -- $( ls ${file_in}* | sort 2>/dev/null ) 
     1099        # result for a a1 a10 a2 with file_in=a a a1 a2 a10 
     1100        set +A list_file -- $( [ -f ${file_in} ] && ls ${file_in} ; for i in $(ls ${file_in}* 2>/dev/null | sed "s/${file_in}//" | sort -n) ; do ls ${file_in}$i ; done ) 
     1101        nlist_file=${#list_file[@]} 
     1102          if [ ${nlist_file} -gt 1 ] ; then 
     1103            if ( ${compactoutputs} ) ; then 
     1104              IGCM_debug_Print 2 "Parallelism of Text Output with ${nlist_file} files." 
     1105              IGCM_debug_Print 2 "Compact files in ${file_out} : " ${list_file[*]} 
     1106              echo ${list_file[*]} > ${file_out} 
     1107              echo " 
     1108" >> ${file_out} 
     1109               
     1110              (( i_ = 0 )) 
     1111              for file in ${list_file[@]} 
     1112              do 
     1113                echo "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ " >> ${file_out} 
     1114                echo "| " ${i_} " " ${file} >> ${file_out} 
     1115                echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " >> ${file_out} 
     1116                cat ${file} | sed "s/\(.*\)/${i_}\1/" ${file} >> ${file_out} 
     1117                echo " 
     1118" >> ${file_out} 
     1119                eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1 
     1120                    (( i_ = i_ + 1 )) 
     1121              done 
     1122              #eval IGCM_sys_Put_Out ${file_out} \${R_OUT_${comp}_D}/${file_out} 
     1123              eval IGCM_sys_PutBuffer_Out ${file_out} \${R_BUF_${comp}_D}/${file_out} 
     1124              eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_out}" > /dev/null 2>&1 
     1125 
     1126              if ( ${ExecutionFail} ) ; then 
     1127                IGCM_sys_Cp ${file_out} ${SUBMIT_DIR}/Debug 
     1128              fi 
     1129            else 
     1130              for file in ${list_file[@]} 
     1131              do 
     1132                #eval IGCM_sys_Put_Out ${file} \${R_OUT_${comp}_D}/${PREFIX}_${file} 
     1133                eval IGCM_sys_PutBuffer_Out ${file} \${R_BUF_${comp}_D}/${PREFIX}_${file} 
     1134                eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1 
     1135 
     1136                if ( ${ExecutionFail} ) ; then 
     1137                  IGCM_sys_Cp ${file} ${SUBMIT_DIR}/Debug/${PREFIX}_${file} 
     1138                fi 
     1139              done 
     1140            fi 
     1141          else 
     1142            if ( [ -f ${file_in}_0000 ] || [ -f ${file_in}0 ] ) ; then 
     1143              eval IGCM_sys_Mv ${file_in}* ${file_in} 
     1144            fi 
     1145            #eval IGCM_sys_Put_Out ${file_in} \${R_OUT_${comp}_D}/${file_out} 
     1146            eval IGCM_sys_PutBuffer_Out ${file_in} \${R_BUF_${comp}_D}/${file_out} 
     1147            eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 
     1148 
     1149            if ( ${ExecutionFail} ) ; then 
     1150              IGCM_sys_Cp ${file_in} ${SUBMIT_DIR}/Debug/${file_out} 
     1151            fi 
     1152          fi 
     1153      done 
     1154    fi 
    8151155    echo 
    816     IGCM_debug_Print 1 "IGCM_comp_Finalize" 
    817     echo 
    818  
    819     typeset ListTextName TextName0 
    820     typeset comp compname comptagname card ListFilesName FileName0 NbFiles SaveOnArchive 
    821     typeset i i_ file_in file_in_ file_out file_out_ file_outin file_outin_ generic_file_name nb_rebuild_file 
    822     typeset -Z4 j4 
    823     typeset list_file nlist_file 
    824     typeset compactoutputs 
    825  
    826     compactoutputs=false 
    827     if [ X${JobType} != XRUN ] ; then 
    828         compactoutputs=true 
    829     elif [ X${config_UserChoices_CompactText} != Xn ] ; then 
    830         compactoutputs=true 
    831     fi 
    832  
    833     for comp in ${config_ListOfComponents[*]} ; do 
    834         # Define component  
    835         eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
    836         eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
    837  
    838         # Debug Print 
    839         IGCM_debug_Print 1 "Finalize ${compname} component." 
    840         # FINALIZE component 
    841         ${comp}_Finalize 
    842  
    843         card=${SUBMIT_DIR}/COMP/${compname}.card         
    844  
    845         # Save Restarts files 
    846         #-------------------- 
    847         IGCM_card_DefineArrayFromOption ${card} RestartFiles List 
    848         ListFilesName=${compname}_RestartFiles_List 
    849         eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    850          
    851         if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then 
    852             eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    853              
    854             (( i=0 )) 
    855             until [ $i -ge $NbFiles ]; do 
    856                 eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    857                 eval file_in=${file_in_} 
    858  
    859                 (( i_ = i+1 )) 
    860                 eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    861                 eval file_out=${file_out_} 
    862  
    863                 (( i_ = i+2 )) 
    864                 eval file_outin_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    865                 eval file_outin=${file_outin_} 
    866  
    867                 generic_restart_file_name_in=$(    basename ${file_in} .nc ) 
    868                 generic_restart_file_name_out=$(   basename ${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} .nc ) 
    869                 generic_restart_file_name_outin=$( basename ${file_outin} .nc ) 
    870                          
    871                 nb_restart_file=$( ls ${generic_restart_file_name_in}_????.nc 2>/dev/null | wc -l )  
    872                 if [ ${nb_restart_file} -gt 1 ] ; then 
    873                     j=0 
    874                     until [ $j -ge $nb_restart_file ]; do 
    875                         j4=${j} 
    876                         eval IGCM_sys_Put_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_OUT_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc 
    877                         if [ ! ${file_in} = ${file_outin} ] ; then 
    878                             if ( ${ExitFlag} ) ; then 
    879                                 echo "IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc not executed." 
    880                             else 
    881                                 IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc 
    882                             fi 
    883                         fi 
    884                         #eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${generic_restart_file_name_in}_${j4}.nc" > /dev/null 2>&1 
    885                         (( j=j+1 )) 
    886                     done 
    887                 else 
    888                     eval IGCM_sys_Put_Rest ${file_in} \${R_OUT_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} 
    889                     if [ ! ${file_in} = ${file_outin} ] ; then 
    890                         if ( ${ExitFlag} ) ; then 
    891                             echo "IGCM_sys_Mv ${file_in} ${file_outin} not executed." 
    892                         else 
    893                             IGCM_sys_Mv ${file_in} ${file_outin} 
    894                         fi 
    895                     fi 
    896                     #eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 
    897                 fi 
    898  
    899                 (( i=i+3 )) 
    900             done 
    901         else 
    902             if [ X${FileName0} != XNONE ] ; then 
    903                 IGCM_debug_Exit "IGCM_comp_Finalize : No file in restart list for ${compname}." 
    904             else 
    905                 IGCM_debug_Print 1 "IGCM_comp_Finalize : NONE specified in Restart List ${compname}." 
    906             fi 
    907         fi 
    908  
    909         # Save Output files 
    910         #------------------ 
    911         IGCM_card_DefineArrayFromOption ${card} OutputFiles List 
    912         ListFilesName=${compname}_OutputFiles_List 
    913         eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    914  
    915         if [ X${FileName0} != X${NULL_STR} ] ; then 
    916             eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    917  
    918             (( i=0 )) 
    919             until [ $i -ge $NbFiles ]; do 
    920                 SaveOnArchive=true 
    921                 eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    922                 eval file_in=${file_in_} 
    923                 (( i_ = i+1 )) 
    924                 eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    925                 eval file_out=${file_out_} 
    926                 (( i_ = i+2 )) 
    927                 eval flag_post=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    928                 # 
    929                 generic_file_name=$( basename ${file_in} .nc ) 
    930                 nb_rebuild_file=$( ls | grep "^${generic_file_name}_[0-9]*.nc" | wc -l ) 
    931                 # 
    932                 if ( [ ${nb_rebuild_file} -eq 1 ] && [ -f ${generic_file_name}_0000.nc ] ) ; then 
    933                     IGCM_debug_Print 2 "Parallelism with 1 process. Rebuilding ${file_in} not needed" 
    934                     IGCM_sys_Mv ${generic_file_name}_0000.nc ${file_in} 
    935                 elif [ ${nb_rebuild_file} -gt 1 ] ; then 
    936                     IGCM_debug_Print 2 "Parallelism detected rebuilding ${file_in} is needed" 
    937                     if ( [ X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
    938                         IGCM_debug_Print 2 "Rebuilding ${file_in} online" 
    939                         IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc 
    940                     else 
    941                         IGCM_debug_Print 2 "Preparing offline rebuild for ${file_in}" 
    942                         [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
    943                         IGCM_sys_Mv ${generic_file_name}_????.nc ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
    944  
    945                         # Prepare headers for the shell dedicated to offline rebuild 
    946                         if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
    947                             if [ $DRYRUN -le 1 ]; then 
    948                             echo "#!/bin/ksh                                          " > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    949                             echo "function IGCM_FlushRebuild                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    950                             echo "{                                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    951                             echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\"          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    952                             echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    953                             echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\"            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    954                             echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    955                             echo "export R_SAVE=${R_SAVE}                             " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    956                             echo "export config_UserChoices_JobName=${config_UserChoices_JobName} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    957                             fi 
    958                         fi 
    959                         # Prepare the shell dedicated to offline rebuild 
    960                         if [ $DRYRUN -le 1 ]; then 
    961                             echo "IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    962                             echo "IGCM_debug_Verif_Exit_Post                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    963                         fi 
    964                         # 
    965                         # Load Patch we need to apply and apply 
    966                         if [ $DRYRUN -le 1 ]; then 
    967                             if [ X$( eval echo \${${compname}_${flag_post}_Patches[0]} ) !=  X${NULL_STR} ]; then 
    968                                 for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ); do 
    969                                     echo ". ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    970                                     echo "IGCM_${Patch} ${file_in}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    971                                     echo "IGCM_debug_Verif_Exit_Post                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    972                                 done 
    973                             fi 
    974                         fi 
    975                         # 
    976                         if [ $DRYRUN -le 1 ]; then 
    977                             echo "IGCM_sys_Put_Out ${file_in} ${file_out}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    978                             echo "IGCM_debug_Verif_Exit_Post                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    979                             echo "IGCM_sys_Rm ${generic_file_name}_*.nc                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    980                         fi 
    981                         SaveOnArchive=false 
    982                     fi 
    983                 fi 
    984                 # 
    985                 if [ ${SaveOnArchive} = true ] ; then 
    986                     # 
    987                     # If we need to apply a patch we use TMP DIRECTORY before ARCHIVING if asynchronous rebuild is on 
    988                     # 
    989                     thereisapatch=$( eval echo \${${compname}_${flag_post}_Patches[0]} ) 
    990                      
    991                     if ( [ ! X${thereisapatch} =  X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = X ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
    992                         if [ -f ${file_in} ] ; then 
    993                             [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
    994  
    995                             IGCM_sys_Mv ${file_in} ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
    996                             eval FileToBeDeleted[${#FileToBeDeleted[@]}]=REBUILD_${PeriodDateBegin}/${file_in} > /dev/null 2>&1 
    997                             # 
    998                             if [ $DRYRUN -le 1 ]; then 
    999                                 if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
    1000                                     echo "#!/bin/ksh                                          " > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1001                                     echo "function IGCM_FlushRebuild                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1002                                     echo "{                                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1003                                     echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\"          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1004                                     echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1005                                     echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\"            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1006                                     echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1007                                 fi 
    1008                                 # 
    1009                                 for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ); do 
    1010                                     echo ". ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1011                                     echo "IGCM_${Patch} ${file_in}                            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1012                                     echo "IGCM_debug_Verif_Exit_Post                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1013                                 done 
    1014                                 # 
    1015                                 echo "IGCM_sys_Put_Out ${file_in} ${file_out}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1016                                 echo "IGCM_debug_Verif_Exit_Post                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1017                                 # 
    1018                             fi 
    1019                         fi 
    1020                     else 
    1021                         [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin} 
    1022                         if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
    1023                             echo "#!/bin/ksh                                          " > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1024                             echo "function IGCM_FlushRebuild                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1025                             echo "{                                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1026                             echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\"          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1027                             echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1028                             echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\"            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1029                             echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    1030                         fi 
    1031  
    1032                         IGCM_sys_Put_Out ${file_in} ${file_out} 
    1033                         [ $? -eq 0 ] && eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 
    1034                         if [ ${nb_rebuild_file} -gt 1 ] ; then 
    1035                             for DelFile in $( ls | grep "${generic_file_name}[_0-9]*.nc" ) ; do 
    1036                                 eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${DelFile} > /dev/null 2>&1 
    1037                             done 
    1038                         fi 
    1039                     fi 
    1040                 fi 
    1041                 (( i=i+3 )) 
    1042             done 
    1043         fi 
    1044  
    1045         # Save Output Text files of models 
    1046         #--------------------------------- 
    1047          
    1048         IGCM_card_DefineArrayFromOption ${card} OutputText List 
    1049         ListTextName=${compname}_OutputText_List 
    1050          
    1051         eval TextName0=\${${ListTextName}[0]} > /dev/null 2>&1 
    1052         if [ X${TextName0} != X${NULL_STR} ] ; then 
    1053             eval NbFiles=\${#${ListTextName}[@]} > /dev/null 2>&1 
    1054  
    1055             (( i=0 )) 
    1056             until [ $i -eq $NbFiles ]; do 
    1057                 eval file_in=\${${ListTextName}[$i]} > /dev/null 2>&1 
    1058                 (( i=i+1 )) 
    1059  
    1060                 unset list_file 
    1061                 #set +A list_file -- $( ls ${file_in}* | sort 2>/dev/null ) 
    1062                 #  result for a a1 a10 a2 with file_in=a a a1 a2 a10 
    1063                 set +A list_file -- $( [ -f ${file_in} ] && ls ${file_in} ; for i in $(ls ${file_in}* 2>/dev/null | sed "s/${file_in}//" | sort -n) ; do ls ${file_in}$i ; done ) 
    1064                 nlist_file=${#list_file[@]} 
    1065                 if [ ${nlist_file} -gt 1 ] ; then 
    1066                     if ( ${compactoutputs} ) ; then 
    1067                         eval file_out=${PREFIX}_${file_in} 
    1068  
    1069                         IGCM_debug_Print 2 "Parallelism of Text Output with ${nlist_file} files." 
    1070                         IGCM_debug_Print 2 "Compact files in ${file_out} : " ${list_file[*]} 
    1071                         echo ${list_file[*]} > ${file_out} 
    1072                         echo " 
    1073 " >> ${file_out} 
    1074                          
    1075                         (( i_ = 0 )) 
    1076                         for file in ${list_file[@]} 
    1077                         do 
    1078                             echo "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ " >> ${file_out} 
    1079                             echo "| " ${i_} " " ${file} >> ${file_out} 
    1080                             echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " >> ${file_out} 
    1081                             cat ${file} | sed "s/\(.*\)/${i_}\1/" ${file} >> ${file_out} 
    1082                             echo " 
    1083 " >> ${file_out} 
    1084                             eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1 
    1085                             (( i_ = i_ + 1 )) 
    1086                         done 
    1087                         eval IGCM_sys_Put_Out ${file_out} \${R_OUT_${comp}_D}/${file_out} 
    1088                         eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_out}" > /dev/null 2>&1 
    1089  
    1090                         if ( ${ExecutionFail} ) ; then 
    1091                             IGCM_sys_Cp ${file_out} ${SUBMIT_DIR}/Debug 
    1092                         fi 
    1093                     else 
    1094                         for file in ${list_file[@]} 
    1095                         do 
    1096                             eval IGCM_sys_Put_Out ${file} \${R_OUT_${comp}_D}/${PREFIX}_${file} 
    1097                             eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1 
    1098                         done 
    1099                         if ( ${ExecutionFail} ) ; then 
    1100                             IGCM_sys_Cp ${file} ${SUBMIT_DIR}/Debug/${PREFIX}_${file} 
    1101                         fi 
    1102                     fi 
    1103                 else 
    1104                     if ( [ -f ${file_in}_0000 ] || [ -f ${file_in}0 ] ) ; then 
    1105                         eval IGCM_sys_Mv ${file_in}* ${file_in} 
    1106                     fi 
    1107                     eval IGCM_sys_Put_Out ${file_in} \${R_OUT_${comp}_D}/${PREFIX}_${file_in} 
    1108                     [ $? -eq 0 ] && eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 
    1109  
    1110                     if ( ${ExecutionFail} ) ; then 
    1111                         IGCM_sys_Cp ${file_in} ${SUBMIT_DIR}/Debug/${PREFIX}_${file_in} 
    1112                     fi 
    1113                 fi 
    1114             done 
    1115         fi 
    1116     done 
    1117  
    1118     IGCM_debug_PopStack "IGCM_comp_Finalize" 
     1156  done 
     1157  IGCM_debug_PopStack "IGCM_comp_Finalize" 
    11191158} 
  • trunk/libIGCM/libIGCM_config/libIGCM_config.ksh

    r541 r544  
    1515function IGCM_config_Initialize 
    1616{ 
    17     IGCM_debug_PushStack "IGCM_config_Initialize" 
    18  
    19     # Debug Print : 
     17  IGCM_debug_PushStack "IGCM_config_Initialize" 
     18 
     19  # Debug Print : 
     20  echo 
     21  IGCM_debug_Print 1 "IGCM_config_Initialize" 
     22 
     23  if [ ! -r ${SUBMIT_DIR}/run.card ]; then  
     24    #================================================# 
     25    #         The file run.card doesn't exist        # 
     26    #================================================# 
     27    FirstInitialize=true 
     28    #copy initial run.card 
     29    IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${SUBMIT_DIR}/run.card 
     30    IGCM_debug_Print 2 "run.card copied from run.card.init" 
     31  else 
     32    FirstInitialize=false 
     33    IGCM_debug_Print 2 "run.card exists" 
     34  fi 
     35 
     36  # Test modipsl tree existence. 
     37  IGCM_sys_TestDir ${MODIPSL} 
     38  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" 
     39  IGCM_sys_TestDir ${libIGCM} 
     40  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" 
     41  IGCM_sys_TestDir ${R_EXE} 
     42  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" 
     43  IGCM_sys_TestDir ${SUBMIT_DIR} 
     44  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" 
     45 
     46  if ( $DEBUG_debug ) ; then 
     47    echo "Keep trace of inital SUBMIT_DIR : " 
     48    ls -lta ${SUBMIT_DIR} 
     49  fi 
     50 
     51  #================================== 
     52 
     53  typeset option auxprint CompatibilityTag 
     54  # Read libIGCM compatibility version in config.card 
     55  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Compatibility libIGCM 
     56  eval CompatibilityTag=${config_Compatibility_libIGCM} > /dev/null 2>&1         
     57 
     58  if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then 
     59    IGCM_debug_Exit "config.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ." 
     60  fi 
     61 
     62  #================================== 
     63  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices 
     64 
     65  for option in ${config_UserChoices[*]} ; do 
     66    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option} 
     67  done 
     68  echo 
     69  IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices" 
     70  # Name Space of this experience  
     71  if [ X${config_UserChoices_SpaceName} != X ] ; then 
     72    IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName 
     73  fi 
     74  # Expericence class of the run 
     75  if [ X${config_UserChoices_ExperimentName} != X ] ; then 
     76    IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName 
     77  fi 
     78  IGCM_debug_PrintVariables 3 config_UserChoices_JobName 
     79  if [ 3 -le ${Verbosity} ] ; then 
     80    echo "--------------Debug3-->" "config_UserChoices_LongName=" 
     81    echo "--------------Debug3-->" \"${config_UserChoices_LongName}\" 
     82  fi 
     83  IGCM_debug_PrintVariables 3 config_UserChoices_TagName 
     84  IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType 
     85  IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin 
     86  IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd 
     87  IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength 
     88 
     89  #================================== 
     90 
     91  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ListOfComponents 
     92  for comp in ${config_ListOfComponents[*]} ; do 
     93    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} 
     94  done 
     95 
     96  echo 
     97  IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" 
     98  IGCM_debug_Print 3 ${config_ListOfComponents[*]} 
     99 
     100  NbComponents=${#config_ListOfComponents[*]} 
     101 
     102  #================================== 
     103  # Define principal executable 
     104  IGCM_card_DefineArrayFromSection   ${SUBMIT_DIR}/config.card Executable 
     105  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Executable Name 
     106   
     107  #================================== 
     108  # Define Outputs Name 
     109  IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output" 
     110  eval Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} 
     111  IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}" 
     112  eval Exe_Output=out_${config_Executable_Name} 
     113  IGCM_debug_Print 3 "Exe_Output           = ${Exe_Output}" 
     114 
     115  #================================== 
     116 
     117  #===================================================================# 
     118  # Prepare variables available for ${COMP}.card and ${COMP}.driver   # 
     119  #             But available to any son functions                    # 
     120  #===================================================================# 
     121 
     122  # Convert yyyy-mm-dd date to gregorian yyyymmdd 
     123  DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) 
     124  DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) 
     125 
     126  # Period Length In Days between DateBegin and DateEnd 
     127  (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 )) 
     128  if [ ${ExperienceLengthInDays} -lt 0 ] ; then 
     129    IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that." 
     130    IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates." 
     131    IGCM_debug_Verif_Exit  
     132  fi 
     133 
     134  # Day and Year of Initial State (Given in julian format) 
     135  InitDay=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 )) 
     136  InitYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 )) 
     137 
     138  #================================== 
     139  # Restarts : Gerneral rule or local for each component ? 
     140  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts 
     141 
     142  echo 
     143  IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts" 
     144 
     145  for option in ${config_Restarts[*]} ; do 
     146    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option} 
     147    eval auxprint=\${config_Restarts_${option}} 
     148    IGCM_debug_Print 3 "${option} : ${auxprint}" 
     149  done 
     150 
     151  #================================================================# 
     152  #                  Test and Prepare directories                  # 
     153  #================================================================# 
     154 
     155  # ==> 4 kinds of input files : 
     156  #     1) R_INIT  : Initial State Files   (Etat0, carteveg) 
     157  #     2) R_BC    : Boundary Conditions   (Forcages, lai) 
     158  #     3) Parameters files (allready define through ${SUBMIT_DIR}) 
     159  #     4) Restarts files   (allready define in IGCM_config_Initialize) 
     160 
     161  # Here we offer the possibility to redefine R_INIT, R_BC 
     162  # and PeriodNb through config.card 
     163  R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT} 
     164  IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and PeriodNb" 
     165  IGCM_debug_Print 3 "R_INIT=${R_INIT}" 
     166  R_BC=${config_UserChoices_R_BC:=${R_IN}/BC} 
     167  IGCM_debug_Print 3  "R_BC=${R_BC}" 
     168  PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}} 
     169  IGCM_debug_Print 3  "Loop in main Job with ${PeriodNb} period(s)" 
     170 
     171  # Test Archive input/output. 
     172  IGCM_sys_TestDirArchive ${ARCHIVE} 
     173  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 
     174  IGCM_sys_TestDirArchive ${R_IN} 
     175  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 
     176 
     177  #==================================================== 
     178  #R_SAVE : Job output directory 
     179  if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
     180    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
     181    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     182    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     183    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     184  else 
     185    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     186    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     187    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     188  fi 
     189 
     190  if ( ${FirstInitialize} ) ; then  
     191    IGCM_sys_MkdirArchive ${R_SAVE} 
     192    IGCM_sys_Mkdir        ${R_BUFR} 
     193  else 
     194    IGCM_sys_TestDirArchive ${R_SAVE} 
     195    [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive ${R_SAVE}" 
     196 
     197    IGCM_sys_TestDir        ${R_BUFR} 
     198    [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir ${R_BUFR}" 
     199    #Test state of run in run.card 
     200    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
     201     
     202    if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
     203      echo  
     204      IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" 
     205      IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" 
     206      IGCM_debug_Exit 
     207      IGCM_debug_Verif_Exit 
     208    fi 
     209  fi 
     210 
     211  #================================== 
     212  # Post :  
     213  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post 
     214 
     215  echo 
     216  IGCM_debug_Print 1 "DefineArrayFromOption : config_Post" 
     217 
     218  for option in ${config_Post[*]} ; do 
     219    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${option} 
     220    eval auxprint=\${config_Post_${option}} 
     221    IGCM_debug_Print 3 "${option} : ${auxprint}" 
     222  done 
     223 
     224  #==================================================== 
     225  # Define REBUILD_DIR : where we store files needing rebuild process 
     226  if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then 
     227    REBUILD_DIR=${R_SAVE}/TMP 
     228    IGCM_sys_MkdirArchive ${REBUILD_DIR} 
     229  else 
     230    REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     231    IGCM_sys_MkdirWork ${REBUILD_DIR} 
     232  fi 
     233 
     234  #==================================================== 
     235  # Experience type : DEB(ug), DEV(elopment), RUN  
     236  if [ X${JobType} != XRUN ] ; then 
    20237    echo 
    21     IGCM_debug_Print 1 "IGCM_config_Initialize" 
    22  
    23     if [ ! -r ${SUBMIT_DIR}/run.card ]; then  
    24         #================================================# 
    25         #         The file run.card doesn't exist        # 
    26         #================================================# 
    27         FirstInitialize=true 
    28         #copy initial run.card 
    29         IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${SUBMIT_DIR}/run.card 
    30         IGCM_debug_Print 2 "run.card copied from run.card.init" 
    31     else 
    32         FirstInitialize=false 
    33         IGCM_debug_Print 2 "run.card exists" 
     238    echo "====================================================" 
     239    echo "libIGCM JOB is NOT in RUN type mode." 
     240    echo "!! OUTPUT files will NOT be PROTECTED !!" 
     241    echo "Be carefull : you can ERASE the result of this job !" 
     242 
     243    case ${JobType} in 
     244    DEB) 
     245      echo "DEBUG mode : activation of 'set -vx' mode." 
     246      echo "DEBUG mode : no protection for output files." 
     247      echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency." 
     248      ;; 
     249    DEV) 
     250      echo "DEVelopment mode : no protection for output files." 
     251      echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency." 
     252      ;; 
     253    esac 
     254 
     255    if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then 
     256      if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then 
     257        echo "------------" 
     258        echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency" 
     259        echo "          to PeriodLength : ${config_UserChoices_PeriodLength}" 
     260        echo "------------" 
     261        config_Post_RebuildFrequency=${config_UserChoices_PeriodLength} 
     262      fi 
    34263    fi 
    35  
    36     # Test modipsl tree existence. 
    37     IGCM_sys_TestDir ${MODIPSL} 
    38     [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" 
    39     IGCM_sys_TestDir ${libIGCM} 
    40     [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" 
    41     IGCM_sys_TestDir ${R_EXE} 
    42     [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" 
    43     IGCM_sys_TestDir ${SUBMIT_DIR} 
    44     [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" 
    45  
    46     if ( $DEBUG_debug ) ; then 
    47         echo "Keep trace of inital SUBMIT_DIR : " 
    48         ls -lta ${SUBMIT_DIR} 
    49     fi 
    50  
    51     #================================== 
    52  
    53     typeset option auxprint CompatibilityTag 
    54     # Read libIGCM compatibility version in config.card 
    55     IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Compatibility libIGCM 
    56     eval CompatibilityTag=${config_Compatibility_libIGCM} > /dev/null 2>&1       
    57  
    58     if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then 
    59         IGCM_debug_Exit "config.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ." 
    60     fi 
    61  
    62     #================================== 
    63     IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices 
    64  
    65     for option in ${config_UserChoices[*]} ; do 
    66         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option} 
    67     done 
     264    echo "====================================================" 
    68265    echo 
    69     IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices" 
    70     # Name Space of this experience  
    71     if [ X${config_UserChoices_SpaceName} != X ] ; then 
    72         IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName 
    73     fi 
    74     # Expericence class of the run 
    75     if [ X${config_UserChoices_ExperimentName} != X ] ; then 
    76         IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName 
    77     fi 
    78     IGCM_debug_PrintVariables 3 config_UserChoices_JobName 
    79     if [ 3 -le ${Verbosity} ] ; then 
    80         echo "--------------Debug3-->" "config_UserChoices_LongName=" 
    81         echo "--------------Debug3-->" \"${config_UserChoices_LongName}\" 
    82     fi 
    83     IGCM_debug_PrintVariables 3 config_UserChoices_TagName 
    84     IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType 
    85     IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin 
    86     IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd 
    87     IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength 
    88  
    89     #================================== 
    90  
    91     IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ListOfComponents 
    92     for comp in ${config_ListOfComponents[*]} ; do 
    93         IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} 
    94     done 
    95  
    96     echo 
    97     IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" 
    98     IGCM_debug_Print 3 ${config_ListOfComponents[*]} 
    99  
    100     NbComponents=${#config_ListOfComponents[*]} 
    101  
    102     #================================== 
    103     # Define principal executable 
    104  
    105     IGCM_card_DefineArrayFromSection   ${SUBMIT_DIR}/config.card Executable 
    106     IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Executable Name 
    107      
    108     #================================== 
    109     # Define Outputs Name 
    110     IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output" 
    111     eval Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} 
    112     IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}" 
    113     eval Exe_Output=out_${config_Executable_Name} 
    114     IGCM_debug_Print 3 "Exe_Output           = ${Exe_Output}" 
    115  
    116     #================================== 
    117  
    118     #===================================================================# 
    119     # Prepare variables available for ${COMP}.card and ${COMP}.driver   # 
    120     #             But available to any son functions                    # 
    121     #===================================================================# 
    122  
    123     # Convert yyyy-mm-dd date to gregorian yyyymmdd 
    124     DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) 
    125     DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) 
    126  
    127     # Period Length In Days between DateBegin and DateEnd 
    128     (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 )) 
    129     if [ ${ExperienceLengthInDays} -lt 0 ] ; then 
    130         IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that." 
    131         IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates." 
    132         IGCM_debug_Verif_Exit  
    133     fi 
    134  
    135     # Day and Year of Initial State (Given in julian format) 
    136     InitDay=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 )) 
    137     InitYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 )) 
    138  
    139     #================================== 
    140     # Restarts : Gerneral rule or local for each component ? 
    141     IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts 
    142  
    143     echo 
    144     IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts" 
    145  
    146     for option in ${config_Restarts[*]} ; do 
    147         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option} 
    148         eval auxprint=\${config_Restarts_${option}} 
    149         IGCM_debug_Print 3 "${option} : ${auxprint}" 
    150     done 
    151  
    152     #================================================================# 
    153     #                  Test and Prepare directories                  # 
    154     #================================================================# 
    155  
    156     # ==> 4 kinds of input files : 
    157     #     1) R_INIT  : Initial State Files   (Etat0, carteveg) 
    158     #     2) R_BC    : Boundary Conditions   (Forcages, lai) 
    159     #     3) Parameters files (allready define through ${SUBMIT_DIR}) 
    160     #     4) Restarts files   (allready define in IGCM_config_Initialize) 
    161  
    162     # Here we offer the possibility to redefine R_INIT, R_BC 
    163     # and PeriodNb through config.card 
    164     R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT} 
    165     IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and PeriodNb" 
    166     IGCM_debug_Print 3 "R_INIT=${R_INIT}" 
    167     R_BC=${config_UserChoices_R_BC:=${R_IN}/BC} 
    168     IGCM_debug_Print 3  "R_BC=${R_BC}" 
    169     PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}} 
    170     IGCM_debug_Print 3  "Loop in main Job with ${PeriodNb} period(s)" 
    171  
    172     # Test Archive input/output. 
    173     IGCM_sys_TestDirArchive ${ARCHIVE} 
    174     [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 
    175     IGCM_sys_TestDirArchive ${R_IN} 
    176     [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 
    177  
    178     #==================================================== 
    179     #R_SAVE : Job output directory 
    180     if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    181         FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    182         R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    183         R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    184     else 
    185         R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    186         R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    187     fi 
    188  
    189     if ( ${FirstInitialize} ) ; then  
    190         IGCM_sys_MkdirArchive ${R_SAVE} 
    191     else 
    192         IGCM_sys_TestDirArchive ${R_SAVE} 
    193         [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 
    194         #Test state of run in run.card 
    195         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
    196          
    197         if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
    198             echo  
    199             IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" 
    200             IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" 
    201             IGCM_debug_Exit 
    202             IGCM_debug_Verif_Exit 
    203         fi 
    204     fi 
    205  
    206     #================================== 
    207     # Post :  
    208     IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post 
    209  
    210     echo 
    211     IGCM_debug_Print 1 "DefineArrayFromOption : config_Post" 
    212  
    213     for option in ${config_Post[*]} ; do 
    214         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${option} 
    215         eval auxprint=\${config_Post_${option}} 
    216         IGCM_debug_Print 3 "${option} : ${auxprint}" 
    217     done 
    218  
    219     #==================================================== 
    220     # Define REBUILD_DIR : where we store files needing rebuild process 
    221     if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then 
    222         REBUILD_DIR=${R_SAVE}/TMP 
    223         IGCM_sys_MkdirArchive ${REBUILD_DIR} 
    224     else 
    225         REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    226         IGCM_sys_MkdirWork ${REBUILD_DIR} 
    227     fi 
    228  
    229     #==================================================== 
    230     # Experience type : DEB(ug), DEV(elopment), RUN  
    231     if [ X${JobType} != XRUN ] ; then 
    232         echo 
    233         echo "====================================================" 
    234         echo "libIGCM JOB is NOT in RUN type mode." 
    235         echo "!! OUTPUT files will NOT be PROTECTED !!" 
    236         echo "Be carefull : you can ERASE the result of this job !" 
    237  
    238         case ${JobType} in 
    239             DEB) 
    240                 echo "DEBUG mode : activation of 'set -vx' mode." 
    241                 echo "DEBUG mode : no protection for output files." 
    242                 echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency." 
    243                 ;; 
    244             DEV) 
    245                 echo "DEVelopment mode : no protection for output files." 
    246                 echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency." 
    247                 ;; 
    248         esac 
    249  
    250         if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then 
    251             if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then 
    252                 echo "------------" 
    253                 echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency" 
    254                 echo "          to PeriodLength : ${config_UserChoices_PeriodLength}" 
    255                 echo "------------" 
    256                 config_Post_RebuildFrequency=${config_UserChoices_PeriodLength} 
    257             fi 
    258         fi 
    259         echo "====================================================" 
    260         echo 
    261     fi 
    262  
    263     #==================================================== 
    264     #R_OUT_KSH : Storage place for job output 
    265     #R_OUT_EXE : Storage place for binary used during simulation 
    266     R_OUT_KSH=${R_SAVE}/Out 
    267     R_OUT_EXE=${R_SAVE}/Exe 
    268  
    269     IGCM_debug_PopStack "IGCM_config_Initialize" 
     266  fi 
     267 
     268  #==================================================== 
     269  #R_OUT_KSH : Storage place for job output 
     270  #R_OUT_EXE : Storage place for binary used during simulation 
     271  R_OUT_KSH=${R_SAVE}/Out 
     272  R_OUT_EXE=${R_SAVE}/Exe 
     273 
     274  #==================================================== 
     275  #R_BUF_KSH : Buffer place for job output 
     276  #R_BUF_EXE : Buffer place for binary used during simulation 
     277  R_BUF_KSH=${R_BUFR}/Out 
     278  R_BUF_EXE=${R_BUFR}/Exe 
     279 
     280  IGCM_debug_PopStack "IGCM_config_Initialize" 
    270281} 
    271282 
     
    273284function IGCM_config_Analyse_PeriodLength 
    274285{ 
    275     IGCM_debug_PushStack "IGCM_config_Analyse_PeriodLength" 
    276  
    277     typeset i 
    278  
    279     # Determine number of day(s) in PeriodLength : 
    280     case ${config_UserChoices_PeriodLength} in 
    281         *Y|*y) 
    282             PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' )  
    283             IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}" 
    284             PeriodLengthInDays=0 
    285             i=0 
    286             until [ $i -ge $PeriodLengthInYears ] ; do  
    287                 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
    288                 (( i=i+1 ))  
    289             done  
    290             ;; 
    291         *M|*m) 
    292             PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' )  
    293             IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}" 
    294             PeriodLengthInDays=0 
    295             i=0 
    296             until [ $i -ge $PeriodLengthInMonths ] ; do  
    297                 if [ $(( month + i )) -lt 13 ] ; then  
    298                     (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) ))   
    299                 else  
    300                     (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) ))   
    301                 fi  
    302                 (( i=i+1 ))  
    303             done  
    304             ;; 
    305         *D|*d)   
    306             PeriodLengthInMonths=0 
    307             PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' );; 
    308         *)  
    309             IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." 
    310             IGCM_debug_Verif_Exit ;; 
    311     esac 
    312  
    313     IGCM_debug_PopStack "IGCM_config_Analyse_PeriodLength" 
     286  IGCM_debug_PushStack "IGCM_config_Analyse_PeriodLength" 
     287 
     288  typeset i 
     289 
     290  # Determine number of day(s) in PeriodLength : 
     291  case ${config_UserChoices_PeriodLength} in 
     292  *Y|*y) 
     293    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' )  
     294    IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}" 
     295    PeriodLengthInDays=0 
     296    i=0 
     297    until [ $i -ge $PeriodLengthInYears ] ; do  
     298      (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
     299      (( i=i+1 ))  
     300    done  
     301    ;; 
     302  *M|*m) 
     303    PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' )  
     304    IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}" 
     305    PeriodLengthInDays=0 
     306    i=0 
     307    until [ $i -ge $PeriodLengthInMonths ] ; do  
     308      if [ $(( month + i )) -lt 13 ] ; then  
     309        (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) ))   
     310      else  
     311        (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) ))   
     312      fi  
     313      (( i=i+1 ))  
     314    done  
     315    ;; 
     316  *D|*d)   
     317    PeriodLengthInMonths=0 
     318    PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' );; 
     319  *)  
     320    IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." 
     321    IGCM_debug_Verif_Exit ;; 
     322  esac 
     323 
     324  IGCM_debug_PopStack "IGCM_config_Analyse_PeriodLength" 
    314325} 
    315326 
     
    317328function IGCM_config_Check 
    318329{ 
    319     IGCM_debug_PushStack "IGCM_config_Check" 
    320  
    321     # If one of the following modulo is not zero : 
    322     # we will issue an error then explain and exit in 
    323     # AA_job IGCM_debug_Verif_Exit call before binary submission 
    324  
     330  IGCM_debug_PushStack "IGCM_config_Check" 
     331 
     332  # If one of the following modulo is not zero : 
     333  # we will issue an error then explain and exit in 
     334  # AA_job IGCM_debug_Verif_Exit call before binary submission 
     335 
     336  echo 
     337  IGCM_debug_Print 1 "IGCM_config_Check" 
     338  echo 
     339 
     340  typeset i 
     341 
     342  if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
     343    AsynchronousRebuild=true 
     344    IGCM_debug_Print 1 "Asynchronous rebuild has been activated." 
    325345    echo 
    326     IGCM_debug_Print 1 "IGCM_config_Check" 
     346    # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero 
     347    IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength" 
     348    IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength 
     349    IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency" 
     350    IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency 
     351    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency" 
     352    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency 
     353  else 
     354    AsynchronousRebuild=false 
     355    IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" 
     356    IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" 
    327357    echo 
    328  
    329     typeset i 
    330  
    331     if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
    332         AsynchronousRebuild=true 
    333         IGCM_debug_Print 1 "Asynchronous rebuild has been activated." 
    334         echo 
    335         # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero 
    336         IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength" 
    337         IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength 
    338         IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency" 
    339         IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency 
    340         IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency" 
    341         IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency 
    342     else 
    343         AsynchronousRebuild=false 
    344         IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" 
    345         IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" 
    346         echo 
    347         #modulo (TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero 
    348         IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength" 
    349         IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength 
    350         IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength" 
    351         IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency   config_UserChoices_PeriodLength 
    352     fi 
    353  
    354     #modulo (TimeSeriesFrequency and all Chunck2D) must be zero 
    355     NbJob=${#CHUNCK2D_SIZE[@]} 
    356     i=0 
    357     until [ $i -ge $NbJob ]; do 
    358         value=${CHUNCK2D_SIZE[${i}]} 
    359         IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency" 
    360         IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency 
    361         case ${value} in   
    362             *Y|*y) ;;  
    363             *)  IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card" 
    364                 IGCM_debug_Exit "This will stop the job" ;; 
    365         esac 
    366         (( i=i+1 )) 
    367     done 
    368  
    369     #modulo (TimeSeriesFrequency and all Chunck3D) must be zero 
    370     NbJob=${#CHUNCK3D_SIZE[@]} 
    371     i=0 
    372     until [ $i -ge $NbJob ]; do 
    373         value=${CHUNCK3D_SIZE[${i}]} 
    374         IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency" 
    375         IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency 
    376         case ${value} in   
    377             *Y|*y) ;;  
    378             *)  IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card" 
    379                 IGCM_debug_Exit "This will stop the job" ;; 
    380         esac 
    381         (( i=i+1 )) 
    382     done 
    383  
    384     IGCM_debug_PopStack "IGCM_config_Check" 
     358    #modulo (TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero 
     359    IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength" 
     360    IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength 
     361    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength" 
     362    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency   config_UserChoices_PeriodLength 
     363  fi 
     364 
     365  #modulo (TimeSeriesFrequency and all Chunck2D) must be zero 
     366  NbJob=${#CHUNCK2D_SIZE[@]} 
     367  i=0 
     368  until [ $i -ge $NbJob ]; do 
     369    value=${CHUNCK2D_SIZE[${i}]} 
     370    IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency" 
     371    IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency 
     372    case ${value} in   
     373    *Y|*y) ;;  
     374    *)  IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card" 
     375      IGCM_debug_Exit "This will stop the job" ;; 
     376    esac 
     377    (( i=i+1 )) 
     378  done 
     379 
     380  #modulo (TimeSeriesFrequency and all Chunck3D) must be zero 
     381  NbJob=${#CHUNCK3D_SIZE[@]} 
     382  i=0 
     383  until [ $i -ge $NbJob ]; do 
     384    value=${CHUNCK3D_SIZE[${i}]} 
     385    IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency" 
     386    IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency 
     387    case ${value} in   
     388    *Y|*y) ;;  
     389    *)  IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card" 
     390      IGCM_debug_Exit "This will stop the job" ;; 
     391    esac 
     392    (( i=i+1 )) 
     393  done 
     394 
     395  IGCM_debug_PopStack "IGCM_config_Check" 
    385396} 
    386397 
     
    388399function IGCM_config_PeriodStart 
    389400{ 
    390     IGCM_debug_PushStack "IGCM_config_PeriodStart" 
    391  
    392     echo 
    393     IGCM_debug_Print 1 "IGCM_config_PeriodStart" 
    394     echo 
    395  
    396     if ( ${FirstInitialize} ) ; then 
    397         #================================================# 
    398         #         Initialize date/period information     # 
    399         #================================================# 
    400  
    401         IGCM_date_GetYearMonthDay $DateBegin year month day 
    402         IGCM_config_Analyse_PeriodLength 
    403  
    404         eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1 
    405         PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) ) 
    406         eval CumulPeriod=1 > /dev/null 2>&1 
    407  
    408         #=================================================# 
    409         #              Write updated run.card             # 
    410         #=================================================# 
    411  
    412         #Correct run.card Configuration for this period 
    413         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} 
    414         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} 
    415         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} 
    416         if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then 
    417             IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR} 
    418         fi 
    419  
    420         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" 
    421   
     401  IGCM_debug_PushStack "IGCM_config_PeriodStart" 
     402 
     403  echo 
     404  IGCM_debug_Print 1 "IGCM_config_PeriodStart" 
     405  echo 
     406 
     407  if ( ${FirstInitialize} ) ; then 
     408    #================================================# 
     409    #         Initialize date/period information     # 
     410    #================================================# 
     411 
     412    IGCM_date_GetYearMonthDay $DateBegin year month day 
     413    IGCM_config_Analyse_PeriodLength 
     414 
     415    eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1 
     416    PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) ) 
     417    eval CumulPeriod=1 > /dev/null 2>&1 
     418 
     419    #=================================================# 
     420    #              Write updated run.card             # 
     421    #=================================================# 
     422 
     423    #Correct run.card Configuration for this period 
     424    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} 
     425    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} 
     426    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} 
     427    if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then 
     428      IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR} 
     429    fi 
     430 
     431    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" 
     432     
     433  else 
     434    #================================================# 
     435    #         The file run.card allready exist       # 
     436    #================================================# 
     437 
     438    #Test state of run in run.card 
     439    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
     440    if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
     441      echo  
     442      IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" 
     443      IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" 
     444      echo 
     445      IGCM_debug_Exit 
     446      IGCM_debug_Verif_Exit 
     447    fi 
     448 
     449    #===================================# 
     450    #        Read updated run.card      # 
     451    #===================================# 
     452 
     453    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix 
     454    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin 
     455    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd 
     456    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod 
     457 
     458    PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) 
     459    PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) 
     460    eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1 
     461 
     462    LastPeriodDateEnd=$( echo ${run_Configuration_OldPrefix} | sed -e "s/${config_UserChoices_JobName}_//" ) 
     463 
     464    typeset LastDate 
     465    set +A LastDate -- $( echo ${LastPeriodDateEnd} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \2 \3/" ) 
     466    LastYearDateEnd=${LastDate[0]} 
     467    LastMonthDateEnd=${LastDate[1]} 
     468    LastDayDateEnd=${LastDate[2]} 
     469 
     470    if [ ${Period} = 1 ]; then 
     471      # save last Job output 
     472      typeset LastPeriod iLastPeriod Last_Script_Output_Name 
     473      (( LastPeriod=CumulPeriod-PeriodNb )) 
     474      iLastPeriod=$( printf "%06d" ${LastPeriod} ) 
     475      Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${iLastPeriod}" 
     476      Last_run_card="run.card.${iLastPeriod}" 
     477      #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name} 
     478      #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1 
     479      IGCM_debug_Print 2 "Try to save previous ksh job output" 
     480      IGCM_sys_Cd ${SUBMIT_DIR}/ 
     481      IGCM_sys_PutBuffer_Out ${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name}.$$ rw 
     482 
     483      IGCM_card_CheckConflict run.card 
     484      IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/${Last_run_card}.$$ rw 
     485 
     486      IGCM_sys_Cd ${RUN_DIR} 
    422487    else 
    423         #================================================# 
    424         #         The file run.card allready exist       # 
    425         #================================================# 
    426  
    427         #Test state of run in run.card 
    428         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
    429         if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
    430             echo  
    431             IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" 
    432             IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" 
    433             echo 
    434             IGCM_debug_Exit 
    435             IGCM_debug_Verif_Exit 
    436         fi 
    437  
    438         #===================================# 
    439         #        Read updated run.card      # 
    440         #===================================# 
    441  
    442         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix 
    443         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin 
    444         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd 
    445         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod 
    446  
    447         PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) 
    448         PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) 
    449         eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1 
    450  
    451         LastPeriodDateEnd=$( echo ${run_Configuration_OldPrefix} | sed -e "s/${config_UserChoices_JobName}_//" ) 
    452  
    453         typeset LastDate 
    454         set +A LastDate -- $( echo ${LastPeriodDateEnd} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \2 \3/" ) 
    455         LastYearDateEnd=${LastDate[0]} 
    456         LastMonthDateEnd=${LastDate[1]} 
    457         LastDayDateEnd=${LastDate[2]} 
    458  
    459         if [ ${Period} = 1 ]; then 
    460            # save last Job output 
    461             typeset LastPeriod iLastPeriod Last_Script_Output_Name 
    462             (( LastPeriod=CumulPeriod-PeriodNb )) 
    463             iLastPeriod=$( printf "%06d" ${LastPeriod} ) 
    464             Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${iLastPeriod}" 
    465             Last_run_card="run.card.${iLastPeriod}" 
    466             #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name} 
    467             #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1 
    468             IGCM_debug_Print 2 "Try to save previous ksh job output" 
    469             IGCM_sys_Cd ${SUBMIT_DIR}/ 
    470             IGCM_sys_Put_Out ${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name}.$$ rw 
    471  
    472             IGCM_card_CheckConflict run.card 
    473             IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/${Last_run_card}.$$ rw 
    474  
    475             IGCM_sys_Cd ${RUN_DIR} 
    476         else 
    477             unset FileToBeDeleted 
    478         fi 
    479  
    480         IGCM_date_GetYearMonthDay $PeriodDateBegin year month day 
    481         IGCM_config_Analyse_PeriodLength 
    482  
    483         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" 
    484  
    485     fi     
    486     OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd} 
    487  
    488     # BEGIN: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh 
    489     # Compute year_m1 and year_p1 (year minus 1Y and year plus 1Y) 
    490     year_m1=$(( year - 1 )) 
    491     year_p1=$(( year + 1 ))      
    492     # Compute month_m1 (month minus 1M) 
    493     # Compute yyyymm_m1 (yyyymm minus 1M) 
    494     month_m1=$(( month - 1 )) 
    495     if [ ${month_m1} = 0 ]; then 
    496         month_m1=12 
    497         yyyymm_m1=${year_m1}12 
    498     elif [ ${month_m1} -le 9 ]; then 
    499         month_m1=0${month_m1} 
    500         yyyymm_m1=${year}${month_m1} 
    501     else 
    502         yyyymm_m1=${year}${month_m1} 
     488      unset FileToBeDeleted 
    503489    fi 
    504     # Compute month_p1 (month plus 1M) 
    505     # Compute yyyymm_p1 (yyyymm plus 1M) 
    506     month_p1=$(( month + 1 )) 
    507     if [ ${month_p1} = 13 ]; then 
    508         month_p1=01 
    509         yyyymm_p1=${year_p1}01 
    510     elif [ ${month_p1} -le 9 ]; then 
    511         month_p1=0${month_p1} 
    512         yyyymm_p1=${year}${month_p1} 
    513     else 
    514         yyyymm_p1=${year}${month_p1} 
     490 
     491    IGCM_date_GetYearMonthDay $PeriodDateBegin year month day 
     492    IGCM_config_Analyse_PeriodLength 
     493 
     494    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" 
     495 
     496  fi     
     497  OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd} 
     498 
     499  # BEGIN: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh 
     500  # Compute year_m1 and year_p1 (year minus 1Y and year plus 1Y) 
     501  year_m1=$(( year - 1 )) 
     502  year_p1=$(( year + 1 ))        
     503  # Compute month_m1 (month minus 1M) 
     504  # Compute yyyymm_m1 (yyyymm minus 1M) 
     505  month_m1=$(( month - 1 )) 
     506  if [ ${month_m1} = 0 ]; then 
     507    month_m1=12 
     508    yyyymm_m1=${year_m1}12 
     509  elif [ ${month_m1} -le 9 ]; then 
     510    month_m1=0${month_m1} 
     511    yyyymm_m1=${year}${month_m1} 
     512  else 
     513    yyyymm_m1=${year}${month_m1} 
     514  fi 
     515  # Compute month_p1 (month plus 1M) 
     516  # Compute yyyymm_p1 (yyyymm plus 1M) 
     517  month_p1=$(( month + 1 )) 
     518  if [ ${month_p1} = 13 ]; then 
     519    month_p1=01 
     520    yyyymm_p1=${year_p1}01 
     521  elif [ ${month_p1} -le 9 ]; then 
     522    month_p1=0${month_p1} 
     523    yyyymm_p1=${year}${month_p1} 
     524  else 
     525    yyyymm_p1=${year}${month_p1} 
     526  fi 
     527  #IGCM_debug_Print 1 "jg 1 month_m1 = ${month_m1} month_p1 = ${month_p1} " 
     528  #IGCM_debug_Print 1 "jg 1 calculate yyyymm_m1 = ${yyyymm_m1} " 
     529  #IGCM_debug_Print 1 "jg 1 calculate yyyymm_p1 = ${yyyymm_p1} " 
     530 
     531  # END: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh 
     532 
     533  #===================================================================# 
     534  # Prepare variables available for ${COMP}.card and ${COMP}.driver   # 
     535  #             But available to any son functions                    # 
     536  #===================================================================# 
     537 
     538  # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !) 
     539  (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 )) 
     540 
     541  # Debug Print : 
     542  IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution" 
     543  IGCM_debug_Print 1 "Year of simulation      : ${year}" 
     544  IGCM_debug_Print 1 "Month of simulation     : ${month}" 
     545  IGCM_debug_Print 1 "PeriodLengthInDays      : ${PeriodLengthInDays}" 
     546  IGCM_debug_Print 1 "PeriodDateBegin         : ${PeriodDateBegin}" 
     547  IGCM_debug_Print 1 "PeriodDateEnd           : ${PeriodDateEnd}" 
     548  IGCM_debug_Print 1 "SimulationLengthInDays  : ${SimulationLengthInDays}" 
     549  IGCM_debug_Print 1 "ExperienceLengthInDays  : ${ExperienceLengthInDays}" 
     550 
     551  #================================================================# 
     552  #         Prepare variables available for comp_finalyze          # 
     553  #================================================================# 
     554 
     555  # Period for save files 
     556  eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1 
     557 
     558  # Prefix for save files of this period 
     559  eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod}  > /dev/null 2>&1 
     560 
     561  # List of files that will be deleted in RUN_DIR after run 
     562  [ -f stack ] && FileToBeDeleted[0]="stack" 
     563 
     564  # Test if the same run as already been saved : 
     565  if [ X${JobType} = XRUN ] ; then 
     566    if [ ${DRYRUN} -le 0 ] ; then 
     567      if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then 
     568        IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job." 
     569        IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files" 
     570        IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or " 
     571        IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory." 
     572        IGCM_debug_Print 1 " This exit has been initiated because at least ${R_BUF_KSH}/${PREFIX}_${Exe_Output} exists." 
     573        IGCM_debug_Verif_Exit 
     574      fi 
    515575    fi 
    516     #IGCM_debug_Print 1 "jg 1 month_m1 = ${month_m1} month_p1 = ${month_p1} " 
    517     #IGCM_debug_Print 1 "jg 1 calculate yyyymm_m1 = ${yyyymm_m1} " 
    518     #IGCM_debug_Print 1 "jg 1 calculate yyyymm_p1 = ${yyyymm_p1} " 
    519  
    520     # END: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh 
    521  
    522     #===================================================================# 
    523     # Prepare variables available for ${COMP}.card and ${COMP}.driver   # 
    524     #             But available to any son functions                    # 
    525     #===================================================================# 
    526  
    527     # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !) 
    528     (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 )) 
    529  
    530     # Debug Print : 
    531     IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution" 
    532     IGCM_debug_Print 1 "Year of simulation      : ${year}" 
    533     IGCM_debug_Print 1 "Month of simulation     : ${month}" 
    534     IGCM_debug_Print 1 "PeriodLengthInDays      : ${PeriodLengthInDays}" 
    535     IGCM_debug_Print 1 "PeriodDateBegin         : ${PeriodDateBegin}" 
    536     IGCM_debug_Print 1 "PeriodDateEnd           : ${PeriodDateEnd}" 
    537     IGCM_debug_Print 1 "SimulationLengthInDays  : ${SimulationLengthInDays}" 
    538     IGCM_debug_Print 1 "ExperienceLengthInDays  : ${ExperienceLengthInDays}" 
    539  
    540     #================================================================# 
    541     #         Prepare variables available for comp_finalyze          # 
    542     #================================================================# 
    543  
    544     # Period for save files 
    545     eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1 
    546  
    547     # Prefix for save files of this period 
    548     eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod}  > /dev/null 2>&1 
    549  
    550     # List of files that will be deleted in RUN_DIR after run 
    551     [ -f stack ] && FileToBeDeleted[0]="stack" 
    552  
    553     # Test if the same run as already been saved : 
    554     if [ X${JobType} = XRUN ] ; then 
    555         if [ ${DRYRUN} -le 0 ] ; then 
    556             if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then 
    557                 IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job." 
    558                 IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files" 
    559                 IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or " 
    560                 IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory." 
    561                 IGCM_debug_Print 1 " This exit has been initiated because at least ${R_OUT_KSH}/${PREFIX}_${Exe_Output} exists." 
    562                 IGCM_debug_Verif_Exit 
    563             fi 
    564         fi 
    565     else 
    566         if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then 
    567             IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode." 
    568         fi 
     576  else 
     577    if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then 
     578      IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode." 
    569579    fi 
    570  
    571     ExecutionFail=false 
    572  
    573     IGCM_debug_PopStack "IGCM_config_PeriodStart" 
     580  fi 
     581 
     582  ExecutionFail=false 
     583 
     584  IGCM_debug_PopStack "IGCM_config_PeriodStart" 
    574585} 
    575586 
     
    577588function IGCM_config_SaveSourceModifications 
    578589{ 
    579     IGCM_debug_PushStack "IGCM_config_SaveSourceModifications" 
    580  
    581     typeset ExeOutDateMax listVarEnv 
    582     ExeOutDateMax=$1 
    583  
    584     listVarEnv="ExeOutDateMax,R_OUT_EXE,PREFIX,SUBMIT_DIR" 
    585     IGCM_sys_RshMaster "\ 
     590  IGCM_debug_PushStack "IGCM_config_SaveSourceModifications" 
     591 
     592  typeset ExeOutDateMax listVarEnv 
     593  ExeOutDateMax=$1 
     594 
     595  listVarEnv="ExeOutDateMax,R_OUT_EXE,PREFIX,SUBMIT_DIR" 
     596  IGCM_sys_RshMaster "\ 
    586597       . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh; \ 
    587        export ExeOutDateMax=${ExeOutDateMax};\ 
     598    export ExeOutDateMax=${ExeOutDateMax};\ 
    588599       export R_OUT_EXE=${R_OUT_EXE};\ 
    589600       export PREFIX=${PREFIX};\ 
     
    593604       IGCM_sys_Qsub ${libIGCM}/SaveSourceModifications.job ${ExeOutDateMax} ${R_OUT_EXE} ${PREFIX} ${SUBMIT_DIR}" 
    594605 
    595     IGCM_debug_PopStack "IGCM_config_SaveSourceModifications" 
     606  IGCM_debug_PopStack "IGCM_config_SaveSourceModifications" 
    596607} 
    597608 
     
    599610function IGCM_config_PeriodEnd 
    600611{ 
    601     IGCM_debug_PushStack "IGCM_config_PeriodEnd" 
    602  
    603     echo 
    604     IGCM_debug_Print 1 "IGCM_config_PeriodEnd" 
    605     echo 
    606  
    607     #==================================# 
    608     #         Save Job output          # 
    609     #==================================# 
    610     IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output} 
    611     eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}" 
    612  
    613     IGCM_card_CheckConflict run.card 
    614     IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/run.card rw 
    615  
    616     IGCM_debug_Print 1 "Check components binary : size and creation date" 
    617  
    618     typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize 
    619     typeset comp i     
    620     typeset ExeNameIn ExeNameOut UpdateExe ExeSecDateMax 
    621  
    622     #==================================# 
    623     #        Get last Exe Size         # 
    624     #==================================# 
    625  
    626     (( i=0 )) 
    627     if ( ${FirstInitialize} ) ; then 
     612  IGCM_debug_PushStack "IGCM_config_PeriodEnd" 
     613 
     614  echo 
     615  IGCM_debug_Print 1 "IGCM_config_PeriodEnd" 
     616  echo 
     617 
     618  #==================================# 
     619  #         Save Job output          # 
     620  #==================================# 
     621  IGCM_sys_PutBuffer_Out ${Exe_Output} ${R_BUF_KSH}/${PREFIX}_${Exe_Output} 
     622  eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}" 
     623 
     624      IGCM_card_CheckConflict run.card 
     625      IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/run.card rw 
     626 
     627      IGCM_debug_Print 1 "Check components binary : size and creation date" 
     628 
     629      typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize 
     630      typeset comp i     
     631      typeset ExeNameIn ExeNameOut UpdateExe ExeSecDateMax 
     632 
     633      #==================================# 
     634      #        Get last Exe Size         # 
     635      #==================================# 
     636 
     637      (( i=0 )) 
     638      if ( ${FirstInitialize} ) ; then 
    628639        run_Log_LastExeSize="" 
    629640        for comp in ${config_ListOfComponents[*]} ; do 
    630             run_Log_LastExeSize[$i]=0 
    631             (( i=i+1 )) 
     641          run_Log_LastExeSize[$i]=0 
     642          (( i=i+1 )) 
    632643        done 
    633     else 
     644      else 
    634645        IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize 
    635     fi 
    636     #==================================# 
    637     #         And Build ExeDate        # 
    638     #==================================# 
    639  
    640     # ExeDate = ATM_Jun_12_09:34-SRF_Jun_12_09:34-OCE_Jun_12_09:34-ICE_Jun_12_09:34-CPL_Jun_12_09:33 
    641     # Would be nice to have next line but no way to format ls output (need to ls -l --time-style "+%Y-%m-%dT%H:%M") 
    642     # ExeDate = ATM_2009-06-12T09:34+SRF_2009-06-12T09:34+OCE_2009-06-12T09:34+ICE_2009-06-12T09:34+CPL_2009-06-12T09:34 
    643     ExeDate="" 
    644     NextExeSize="( " 
    645     (( i=0 )) 
    646     UpdateExe=false 
    647     (( ExeSecDateMax = 0 )) 
    648     for comp in ${config_ListOfComponents[*]} ; do 
     646      fi 
     647      #==================================# 
     648      #         And Build ExeDate        # 
     649      #==================================# 
     650 
     651      # ExeDate = ATM_Jun_12_09:34-SRF_Jun_12_09:34-OCE_Jun_12_09:34-ICE_Jun_12_09:34-CPL_Jun_12_09:33 
     652      # Would be nice to have next line but no way to format ls output (need to ls -l --time-style "+%Y-%m-%dT%H:%M") 
     653      # ExeDate = ATM_2009-06-12T09:34+SRF_2009-06-12T09:34+OCE_2009-06-12T09:34+ICE_2009-06-12T09:34+CPL_2009-06-12T09:34 
     654      ExeDate="" 
     655      NextExeSize="( " 
     656      (( i=0 )) 
     657      UpdateExe=false 
     658      (( ExeSecDateMax = 0 )) 
     659      for comp in ${config_ListOfComponents[*]} ; do 
    649660 
    650661        IGCM_debug_Print 3 ${comp} 
     
    654665        # Only if we really have an executable for the component : 
    655666        if [ X${ExeNameIn} = X\"\" ] ; then 
    656             # If there is no exe file for this component 
    657             (( ExeSize=0 )) 
     667          # If there is no exe file for this component 
     668          (( ExeSize=0 )) 
    658669        else 
    659             eval LS_bin=${R_EXE}/${ExeNameIn} 
    660             IGCM_sys_FileSize ${LS_bin} ExeSize 
    661  
    662             set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} ) 
    663             if [ X${ExeDate} = X ] ; then  
    664                 # First component exe date 
    665                 ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]} 
    666             else 
    667                 ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]} 
    668             fi 
    669             ExeDate=${ExeDate}_${LS_comp[7]} 
     670          eval LS_bin=${R_EXE}/${ExeNameIn} 
     671          IGCM_sys_FileSize ${LS_bin} ExeSize 
     672 
     673          set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} ) 
     674          if [ X${ExeDate} = X ] ; then  
     675            # First component exe date 
     676            ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]} 
     677          else 
     678            ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]} 
     679          fi 
     680          ExeDate=${ExeDate}_${LS_comp[7]} 
    670681        fi 
    671682 
    672683        if [ ${i} -eq 0 ] ; then 
    673             # First component 
    674             NextExeSize="( "${ExeSize} 
     684          # First component 
     685          NextExeSize="( "${ExeSize} 
    675686        else 
    676             NextExeSize=${NextExeSize}", "${ExeSize} 
     687          NextExeSize=${NextExeSize}", "${ExeSize} 
    677688        fi 
    678689        eval LastCompExeSize=${run_Log_LastExeSize[$i]} 
     
    680691 
    681692        if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then 
    682             if ( ${FirstInitialize} ) ; then 
    683                 IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !" 
    684             else 
    685                 IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !" 
    686                 IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !" 
    687                 eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut} 
    688             fi 
    689             eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw 
    690             UpdateExe=true 
    691  
    692             IGCM_sys_GetDate_FichWork ${LS_bin} ExeSecDate 
    693             if [ $ExeSecDateMax -lt $ExeSecDate ] ; then 
    694                 ExeSecDateMax=$ExeSecDate 
    695             fi 
     693          if ( ${FirstInitialize} ) ; then 
     694            IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !" 
     695          else 
     696            IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !" 
     697            IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !" 
     698            eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut} 
     699          fi 
     700          eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw 
     701          UpdateExe=true 
     702 
     703          IGCM_sys_GetDate_FichWork ${LS_bin} ExeSecDate 
     704          if [ $ExeSecDateMax -lt $ExeSecDate ] ; then 
     705            ExeSecDateMax=$ExeSecDate 
     706          fi 
    696707        fi 
    697     done 
    698  
    699     if ( ${UpdateExe} ) ; then 
    700         echo "Launch SaveSourceModifications." 
    701         IGCM_config_SaveSourceModifications ${ExeSecDateMax} 
    702     fi 
    703  
    704     NextExeSize=${NextExeSize}" )" 
    705     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}" 
    706  
    707     if [ ${DRYRUN} -le 1 ] ; then 
     708      done 
     709 
     710# SD : switch off for now 
     711#      if ( ${UpdateExe} ) ; then 
     712#       echo "Launch SaveSourceModifications." 
     713#       IGCM_config_SaveSourceModifications ${ExeSecDateMax} 
     714#      fi 
     715 
     716      NextExeSize=${NextExeSize}" )" 
     717      IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}" 
     718 
     719      if [ ${DRYRUN} -le 1 ] ; then 
    708720        tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt 
    709721        ExeCpuLog=$( gawk -f ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt ) 
    710722        RET=$? 
    711723        if [ $RET -eq 0 ] ; then 
    712             # ExeCpuLog variable contents 5 fields 
    713             echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" |   \ 
    714              gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \ 
    715                               $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card 
     724          # ExeCpuLog variable contents 5 fields 
     725          echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" |   \ 
     726            gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \ 
     727            $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card 
    716728        fi 
    717729        eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}_tail.txt" 
    718     fi 
    719  
    720     # All was right ? no ? then we stop. 
    721     IGCM_debug_Verif_Exit 
    722  
    723     # If all was OK, we can delete all files not necessary for next Job 
    724     echo 
    725     IGCM_debug_Print 1 "Files that will be deleted before next period-run : " 
    726  
    727     if [ ${DRYRUN} -le 2 ] ; then 
     730      fi 
     731 
     732      # All was right ? no ? then we stop. 
     733      IGCM_debug_Verif_Exit 
     734 
     735      # If all was OK, we can delete all files not necessary for next Job 
     736      echo 
     737      IGCM_debug_Print 1 "Files that will be deleted before next period-run : " 
     738 
     739      if [ ${DRYRUN} -le 2 ] ; then 
    728740        for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done 
    729     else 
     741      else 
    730742        echo ${FileToBeDeleted[@]} 
    731     fi 
    732  
    733     #=================================================# 
    734     #         Modification of libIGCM behaviour       # 
    735     #=================================================# 
    736  
    737     # To use this function, one must copy libIGCM.card from ${libIGCM} directory 
    738     # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card, 
    739     # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop.  
    740     if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then 
     743      fi 
     744 
     745      #=================================================# 
     746      #         Modification of libIGCM behaviour       # 
     747      #=================================================# 
     748 
     749      # To use this function, one must copy libIGCM.card from ${libIGCM} directory 
     750      # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card, 
     751      # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop.  
     752      if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then 
    741753        echo 
    742754        echo "########################################################################" 
     
    750762        # Special treatments for libIGCM internals 
    751763        for option in ${libIGCM_UserChanges[*]} ; do 
    752             IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option} 
    753  
    754             echo "We will change : ${option}." 
    755             eval echo "Previous value : " \${${option}} 
    756             eval echo "Change to : " \${libIGCM_UserChanges_${option}} 
    757              
    758             eval ${option}=\${libIGCM_UserChanges_${option}} 
    759  
    760             case ${option} in 
    761                 config_UserChoices_DateEnd) 
    762                     IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd 
    763                     DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) 
    764  
    765                     # Period Length In Days between DateBegin and DateEnd 
    766                     (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 )) 
    767                     if [ ${ExperienceLengthInDays} -lt 0 ] ; then 
    768                         IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that." 
    769                         IGCM_debug_Exit "IGCM_PeriodEnd" " Wrong Dates." 
    770                         IGCM_debug_Verif_Exit  
    771                     fi 
    772                     ;; 
    773                 config_UserChoices_PeriodLength) 
    774                     IGCM_debug_Print 1  "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}" 
    775                     ;; 
    776                 PeriodNb) 
    777                     IGCM_debug_Print 1  "Loop in main Job with ${PeriodNb} period(s)" 
    778                     ;; 
    779                 config_Post_RebuildFrequency) 
    780                     IGCM_debug_Print 1  "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure" 
    781                     IGCM_post_Configure 
    782                     ;; 
    783                 config_Post_TimeSeriesFrequency) 
    784                     IGCM_debug_Print 1  "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Initialize" 
    785                     IGCM_post_Configure 
    786                     ;; 
    787                 config_Post_SeasonalFrequency) 
    788                     IGCM_debug_Print 1  "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Initialize" 
    789                     IGCM_post_Configure 
    790                     ;; 
    791             esac 
    792         done 
    793  
    794         echo 
    795         echo "########################################################################" 
    796         echo 
    797     fi 
    798  
    799     #=================================================# 
    800     #         Determine next computed period          # 
    801     #=================================================# 
    802  
    803     PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 ) 
    804     IGCM_date_GetYearMonthDay $PeriodDateBegin year month day 
    805     year_m1=$(( year - 1 )) 
    806     year_p1=$(( year + 1 )) 
    807     IGCM_config_Analyse_PeriodLength 
    808     PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) ) 
    809  
    810     # Debug Print : 
    811     echo 
    812     IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution" 
    813     IGCM_debug_Print 1 "PeriodDateBegin       : ${PeriodDateBegin}" 
    814     IGCM_debug_Print 1 "PeriodDateEnd         : ${PeriodDateEnd}" 
    815     IGCM_debug_Print 1 "PeriodLengthInDays    : ${PeriodLengthInDays}" 
    816  
    817     PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) 
    818     PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) 
    819  
    820     (( CumulPeriod = CumulPeriod + 1 )) 
    821  
    822     # Debug Print : 
    823     echo 
    824     IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}" 
    825     IGCM_debug_Print 3 "PeriodDateEnd Human   : ${PeriodDateEnd}" 
    826     IGCM_debug_Print 3 "CumulPeriod           : ${CumulPeriod}" 
    827  
    828     #=================================================# 
    829     #             Write updated run.card              # 
    830     #=================================================# 
    831  
    832     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix} 
    833     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} 
    834     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} 
    835     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} 
    836  
    837     if ( ${FirstInitialize} ) ; then 
    838         # It's no more the first time 
    839         FirstInitialize=false 
    840     fi 
    841  
    842     IGCM_debug_PopStack "IGCM_config_PeriodEnd" 
     764          IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option} 
     765 
     766          echo "We will change : ${option}." 
     767          eval echo "Previous value : " \${${option}} 
     768          eval echo "Change to : " \${libIGCM_UserChanges_${option}} 
     769           
     770          eval ${option}=\${libIGCM_UserChanges_${option}} 
     771 
     772          case ${option} in 
     773          config_UserChoices_DateEnd) 
     774          IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd 
     775          DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) 
     776 
     777          # Period Length In Days between DateBegin and DateEnd 
     778          (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 )) 
     779          if [ ${ExperienceLengthInDays} -lt 0 ] ; then 
     780            IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that." 
     781            IGCM_debug_Exit "IGCM_PeriodEnd" " Wrong Dates." 
     782            IGCM_debug_Verif_Exit  
     783          fi 
     784          ;; 
     785          config_UserChoices_PeriodLength) 
     786        IGCM_debug_Print 1  "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}" 
     787        ;; 
     788        PeriodNb) 
     789              IGCM_debug_Print 1  "Loop in main Job with ${PeriodNb} period(s)" 
     790              ;; 
     791              config_Post_RebuildFrequency) 
     792            IGCM_debug_Print 1  "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure" 
     793            IGCM_post_Configure 
     794            ;; 
     795            config_Post_TimeSeriesFrequency) 
     796    IGCM_debug_Print 1  "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Initialize" 
     797    IGCM_post_Configure 
     798    ;; 
     799    config_Post_SeasonalFrequency) 
     800  IGCM_debug_Print 1  "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Initialize" 
     801  IGCM_post_Configure 
     802  ;; 
     803  esac 
     804  done 
     805 
     806  echo 
     807  echo "########################################################################" 
     808  echo 
     809  fi 
     810 
     811  #=================================================# 
     812  #         Determine next computed period          # 
     813  #=================================================# 
     814 
     815  PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 ) 
     816  IGCM_date_GetYearMonthDay $PeriodDateBegin year month day 
     817  year_m1=$(( year - 1 )) 
     818  year_p1=$(( year + 1 )) 
     819  IGCM_config_Analyse_PeriodLength 
     820  PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) ) 
     821 
     822  # Debug Print : 
     823  echo 
     824  IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution" 
     825  IGCM_debug_Print 1 "PeriodDateBegin       : ${PeriodDateBegin}" 
     826  IGCM_debug_Print 1 "PeriodDateEnd         : ${PeriodDateEnd}" 
     827  IGCM_debug_Print 1 "PeriodLengthInDays    : ${PeriodLengthInDays}" 
     828 
     829  PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) 
     830  PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) 
     831 
     832  (( CumulPeriod = CumulPeriod + 1 )) 
     833 
     834  # Debug Print : 
     835  echo 
     836  IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}" 
     837  IGCM_debug_Print 3 "PeriodDateEnd Human   : ${PeriodDateEnd}" 
     838  IGCM_debug_Print 3 "CumulPeriod           : ${CumulPeriod}" 
     839 
     840  #=================================================# 
     841  #             Write updated run.card              # 
     842  #=================================================# 
     843 
     844  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix} 
     845  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} 
     846  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} 
     847  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} 
     848 
     849  if ( ${FirstInitialize} ) ; then 
     850    # It's no more the first time 
     851    FirstInitialize=false 
     852  fi 
     853 
     854  IGCM_debug_PopStack "IGCM_config_PeriodEnd" 
    843855} 
    844856 
     
    846858function IGCM_config_Finalize 
    847859{ 
    848     IGCM_debug_PushStack "IGCM_config_Finalize" 
    849  
    850     echo 
    851     IGCM_debug_Print 1 "IGCM_config_Finalize" 
    852     echo 
    853  
    854     if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then 
    855         #==========================# 
    856         # End of entire simulation # 
    857         #==========================# 
    858  
    859         # Mail notification 
    860         IGCM_sys_SendMail 
    861  
    862         # 
    863         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed" 
    864         IGCM_debug_Print 1 "Normal End of computation." 
    865         if ( $DEBUG_debug ) ; then 
    866             echo 
    867             IGCM_debug_Print 1 "Your files on ${R_OUT} :" 
    868             IGCM_sys_Tree ${R_SAVE} 
    869         fi 
    870     else 
    871         #=================# 
    872         # Submit next job # 
    873         #=================# 
    874  
    875         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" 
    876  
    877         # Name of next Ksh Script output : 
    878         eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )" 
    879  
    880         IGCM_debug_Print 1 "Submit next job" 
    881         # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR 
    882         IGCM_sys_Cd ${SUBMIT_DIR} 
    883         # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName} 
    884         ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l ) 
    885         [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) ) 
    886         # Submit next job and come back 
    887         IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} 
    888         IGCM_sys_Cd - 
     860  IGCM_debug_PushStack "IGCM_config_Finalize" 
     861 
     862  echo 
     863  IGCM_debug_Print 1 "IGCM_config_Finalize" 
     864  echo 
     865 
     866  if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then 
     867    #==========================# 
     868    # End of entire simulation # 
     869    #==========================# 
     870 
     871    # Mail notification 
     872    IGCM_sys_SendMail 
     873 
     874    # 
     875    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed" 
     876    IGCM_debug_Print 1 "Normal End of computation." 
     877    if ( $DEBUG_debug ) ; then 
     878      echo 
     879      IGCM_debug_Print 1 "Your files on ${R_SAVE} :" 
     880      IGCM_sys_Tree ${R_SAVE} 
     881 
     882      IGCM_debug_Print 1 "Your files on ${R_BUFR} :" 
     883      IGCM_sys_Tree ${R_BUFR} 
    889884    fi 
    890  
    891     # Supress Non Deleted Boundary files 
    892     if [ ${DRYRUN} -le 2 ] ; then 
    893         IGCM_comp_DelFixeBoundaryFiles 
    894         ls -la 
    895     fi 
    896      
    897     # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    898     # Only for production run (No clean up in DEV or DEB mode) 
    899     # and command sent from .. directory. 
    900     IGCM_sys_Cd .. 
    901     [ X${JobType} = XRUN ] && IGCM_sys_Rm -rf ${RUN_DIR} 
    902  
    903     IGCM_debug_PopStack "IGCM_config_Finalize" 
     885  else 
     886    #=================# 
     887    # Submit next job # 
     888    #=================# 
     889 
     890    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" 
     891 
     892    # Name of next Ksh Script output : 
     893    eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )" 
     894 
     895    IGCM_debug_Print 1 "Submit next job" 
     896    # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR 
     897    IGCM_sys_Cd ${SUBMIT_DIR} 
     898    # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName} 
     899    ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l ) 
     900    [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) ) 
     901    # Submit next job and come back 
     902    IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} 
     903    IGCM_sys_Cd - 
     904  fi 
     905 
     906  # Supress Non Deleted Boundary files 
     907  if [ ${DRYRUN} -le 2 ] ; then 
     908    IGCM_comp_DelFixeBoundaryFiles 
     909    ls -la 
     910  fi 
     911   
     912  # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     913  # Only for production run (No clean up in DEV or DEB mode) 
     914  # and command sent from .. directory. 
     915  IGCM_sys_Cd .. 
     916  [ X${JobType} = XRUN ] && IGCM_sys_Rm -rf ${RUN_DIR} 
     917 
     918  IGCM_debug_PopStack "IGCM_config_Finalize" 
    904919} 
    905920 
  • trunk/libIGCM/libIGCM_date/libIGCM_date.ksh

    r522 r544  
    4242function IGCM_date_YearDigit 
    4343{ 
    44     IGCM_debug_PushStack "IGCM_date_YearDigit" $@ 
    45  
    46     NUM=$(( 10#${1} )) 
    47     echo $( gawk "BEGIN { printf \"%0${dY}d\",${NUM} }" ) 
    48  
    49     IGCM_debug_PopStack "IGCM_date_YearDigit" 
     44  IGCM_debug_PushStack "IGCM_date_YearDigit" $@ 
     45 
     46  NUM=$(( 10#${1} )) 
     47  echo $( gawk "BEGIN { printf \"%0${dY}d\",${NUM} }" ) 
     48 
     49  IGCM_debug_PopStack "IGCM_date_YearDigit" 
    5050} 
    5151 
     
    5353function IGCM_date_GregorianDigit 
    5454{ 
    55     IGCM_debug_PushStack "IGCM_date_GregorianDigit" $@ 
    56  
    57     NUM=$(( 10#${1} )) 
    58     echo $( gawk "BEGIN { printf \"%0${pY}d\",${NUM} }" ) 
    59  
    60     IGCM_debug_PopStack "IGCM_date_GregorianDigit" 
     55  IGCM_debug_PushStack "IGCM_date_GregorianDigit" $@ 
     56 
     57  NUM=$(( 10#${1} )) 
     58  echo $( gawk "BEGIN { printf \"%0${pY}d\",${NUM} }" ) 
     59 
     60  IGCM_debug_PopStack "IGCM_date_GregorianDigit" 
    6161} 
    6262 
     
    6464function IGCM_date_HumanDigit 
    6565{ 
    66     IGCM_debug_PushStack "IGCM_date_HumanDigit" $@ 
    67  
    68     echo $( IGCM_date_GregorianDigit $( print ${1} | sed 's/-//g' ) ) \ 
    69         | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1-\2-\3/" 
    70  
    71     IGCM_debug_PopStack "IGCM_date_HumanDigit" 
     66  IGCM_debug_PushStack "IGCM_date_HumanDigit" $@ 
     67 
     68  echo $( IGCM_date_GregorianDigit $( print ${1} | sed 's/-//g' ) ) \ 
     69    | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1-\2-\3/" 
     70 
     71  IGCM_debug_PopStack "IGCM_date_HumanDigit" 
    7272} 
    7373 
     
    7575function IGCM_date_SupressZeros 
    7676{ 
    77     IGCM_debug_PushStack "IGCM_date_SupressZeros" $@ 
    78     echo $( print ${1} | sed -e "s/0*//" ) 
    79     IGCM_debug_PopStack "IGCM_date_SupressZeros" 
     77  IGCM_debug_PushStack "IGCM_date_SupressZeros" $@ 
     78  echo $( print ${1} | sed -e "s/0*//" ) 
     79  IGCM_debug_PopStack "IGCM_date_SupressZeros" 
    8080} 
    8181 
     
    8383function IGCM_date_ConvertFormatToGregorian 
    8484{ 
    85     IGCM_debug_PushStack "IGCM_date_ConvertFormatToGregorian" $@ 
    86  
    87     # from a yyyy-mm-dd date format return  
    88     # a yyymmdd date format 
    89     # usage IGCM_date_ConvertFormat yyyy-mm-dd 
    90  
    91     # if there is no argument on the command line,  
    92     # then assume that a y-m-d formated date is being  
    93     # piped in 
    94     typeset ymd 
    95     if [ $# = 0 ] 
    96         then 
    97         read ymd 
    98     else 
    99         ymd=$1 
    100     fi 
    101  
    102     IGCM_date_GregorianDigit $( print ${ymd} | sed 's/-//g' ) 
    103  
    104     IGCM_debug_PopStack "IGCM_date_ConvertFormatToGregorian" 
     85  IGCM_debug_PushStack "IGCM_date_ConvertFormatToGregorian" $@ 
     86 
     87  # from a yyyy-mm-dd date format return  
     88  # a yyymmdd date format 
     89  # usage IGCM_date_ConvertFormat yyyy-mm-dd 
     90 
     91  # if there is no argument on the command line,  
     92  # then assume that a y-m-d formated date is being  
     93  # piped in 
     94  typeset ymd 
     95  if [ $# = 0 ] 
     96  then 
     97    read ymd 
     98  else 
     99    ymd=$1 
     100  fi 
     101 
     102  IGCM_date_GregorianDigit $( print ${ymd} | sed 's/-//g' ) 
     103 
     104  IGCM_debug_PopStack "IGCM_date_ConvertFormatToGregorian" 
    105105} 
    106106 
     
    108108function IGCM_date_ConvertFormatToHuman 
    109109{ 
    110     IGCM_debug_PushStack "IGCM_date_ConvertFormatToHuman" $@ 
    111  
    112     # from a yyyymmdd date format return  
    113     # a yyyy-mm-dd date format 
    114     # usage IGCM_date_ConvertFormat yyyymmdd 
    115  
    116     # if there is no argument on the command line,  
    117     # then assume that a yyyymmdd formated date is being  
    118     # piped in 
    119     typeset dt 
    120     if [ $# = 0 ] 
    121         then 
    122         read dt 
    123     else 
    124         dt=$1 
    125     fi 
    126  
    127     # break the yyyymmdd into separate parts for year, month and day 
    128     echo $( IGCM_date_GregorianDigit ${dt} ) \ 
    129         | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1-\2-\3/" 
    130  
    131     IGCM_debug_PopStack "IGCM_date_ConvertFormatToHuman" 
     110  IGCM_debug_PushStack "IGCM_date_ConvertFormatToHuman" $@ 
     111 
     112  # from a yyyymmdd date format return  
     113  # a yyyy-mm-dd date format 
     114  # usage IGCM_date_ConvertFormat yyyymmdd 
     115 
     116  # if there is no argument on the command line,  
     117  # then assume that a yyyymmdd formated date is being  
     118  # piped in 
     119  typeset dt 
     120  if [ $# = 0 ] 
     121  then 
     122    read dt 
     123  else 
     124    dt=$1 
     125  fi 
     126 
     127  # break the yyyymmdd into separate parts for year, month and day 
     128  echo $( IGCM_date_GregorianDigit ${dt} ) \ 
     129    | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1-\2-\3/" 
     130 
     131  IGCM_debug_PopStack "IGCM_date_ConvertFormatToHuman" 
    132132} 
    133133 
     
    135135function IGCM_date_GetYearMonth 
    136136{ 
    137     IGCM_debug_PushStack "IGCM_date_GetYearMonth" $@ 
    138  
    139     # from a yyyymmdd date format return  
    140     # a yyyy year and mm month 
    141     # usage IGCM_date_GetYearMonth yyyymmdd year_var month_var 
    142  
    143     # if there is no argument on the command line,  
    144     # then assume that a yyyymmdd formated date is being  
    145     # piped in 
    146     typeset dt 
    147     if [ $# = 0 ] 
    148         then 
    149         read dt 
    150     else 
    151         dt=$1 
    152     fi 
    153  
    154     # break the yyyymmdd into separate parts for year, month and day 
    155     eval $2=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
    156         | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1/" ) 
    157     eval $3=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
    158         | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\2/" ) 
    159  
    160     IGCM_debug_PopStack "IGCM_date_GetYearMonth" 
     137  IGCM_debug_PushStack "IGCM_date_GetYearMonth" $@ 
     138 
     139  # from a yyyymmdd date format return  
     140  # a yyyy year and mm month 
     141  # usage IGCM_date_GetYearMonth yyyymmdd year_var month_var 
     142 
     143  # if there is no argument on the command line,  
     144  # then assume that a yyyymmdd formated date is being  
     145  # piped in 
     146  typeset dt 
     147  if [ $# = 0 ] 
     148  then 
     149    read dt 
     150  else 
     151    dt=$1 
     152  fi 
     153 
     154  # break the yyyymmdd into separate parts for year, month and day 
     155  eval $2=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
     156    | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1/" ) 
     157  eval $3=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
     158    | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\2/" ) 
     159 
     160  IGCM_debug_PopStack "IGCM_date_GetYearMonth" 
    161161} 
    162162 
     
    164164function IGCM_date_GetYearMonthDay 
    165165{ 
    166     IGCM_debug_PushStack "IGCM_date_GetYearMonthDay" $@ 
    167  
    168     # from a yyyymmdd date format return  
    169     # a yyyy year, mm month and dd day 
    170     # usage IGCM_date_GetYearMonthDay yyyymmdd year_var month_var day_var 
    171  
    172     # if there is no argument on the command line,  
    173     # then assume that a yyyymmdd formated date is being  
    174     # piped in 
    175     typeset dt 
    176     if [ $# = 0 ] 
    177         then 
    178         read dt 
    179     else 
    180         dt=$1 
    181     fi 
    182  
    183     # break the yyyymmdd into separate parts for year, month and day 
    184     eval $2=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
    185         | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1/" ) 
    186     eval $3=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
    187         | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\2/" ) 
    188     eval $4=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
    189         | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\3/" ) 
    190  
    191     IGCM_debug_PopStack "IGCM_date_GetYearMonthDay" 
     166  IGCM_debug_PushStack "IGCM_date_GetYearMonthDay" $@ 
     167 
     168  # from a yyyymmdd date format return  
     169  # a yyyy year, mm month and dd day 
     170  # usage IGCM_date_GetYearMonthDay yyyymmdd year_var month_var day_var 
     171 
     172  # if there is no argument on the command line,  
     173  # then assume that a yyyymmdd formated date is being  
     174  # piped in 
     175  typeset dt 
     176  if [ $# = 0 ] 
     177  then 
     178    read dt 
     179  else 
     180    dt=$1 
     181  fi 
     182 
     183  # break the yyyymmdd into separate parts for year, month and day 
     184  eval $2=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
     185    | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1/" ) 
     186  eval $3=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
     187    | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\2/" ) 
     188  eval $4=$( echo $( IGCM_date_GregorianDigit ${dt} ) \ 
     189    | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\3/" ) 
     190 
     191  IGCM_debug_PopStack "IGCM_date_GetYearMonthDay" 
    192192} 
    193193 
     
    202202{ 
    203203#    IGCM_debug_PushStack "IGCM_date_DaysInYear" $@ 
    204     # return the number of days in a year 
    205     # usage IGCM_date_DaysInYear yyyy 
    206  
    207     # What is the calendar : 
    208     case ${config_UserChoices_CalendarType} in 
    209         360d|360_day) 
    210             if [ X$2 = X ] ; then 
    211                 echo 360 
    212             else 
    213                 eval $2=360 > /dev/null 2>&1 
    214             fi 
     204  # return the number of days in a year 
     205  # usage IGCM_date_DaysInYear yyyy 
     206 
     207  # What is the calendar : 
     208  case ${config_UserChoices_CalendarType} in 
     209  360d|360_day) 
     210    if [ X$2 = X ] ; then 
     211      echo 360 
     212    else 
     213      eval $2=360 > /dev/null 2>&1 
     214    fi 
    215215#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    216             return;; 
    217         noleap|365_day) 
    218             if [ X$2 = X ] ; then 
    219                 echo 365 
    220             else 
    221                 eval $2=365 > /dev/null 2>&1 
    222             fi 
    223  
    224 #           IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    225             return;; 
    226         all_leap|366_day) 
    227             if [ X$2 = X ] ; then 
    228                 echo 366 
    229             else 
    230                 eval $2=366 > /dev/null 2>&1 
    231             fi 
    232  
    233 #               IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    234             return;; 
    235     esac 
    236  
    237     typeset y a 
    238  
    239     # if there is no argument on the command line,  
    240     # then assume that a yyyy is being piped in 
    241     if [ $# = 0 ] 
    242         then 
    243         read y 
    244     else 
    245         y=$(( 10#${1} )) 
    246     fi 
    247  
    248     # a year is a leap year if it is even divisible by 4 
    249     # but not evenly divisible by 100 
    250     # unless it is evenly divisible by 400 
    251  
    252     # if it is evenly divisible by 400 it must be a leap year 
    253     a=$(( $y % 400 )) 
    254     if [ $a = 0 ] 
    255         then 
    256         if [ X$2 = X ] ; then 
    257             echo 366 
    258         else 
    259             eval $2=366 > /dev/null 2>&1 
    260         fi 
     216    return;; 
     217  noleap|365_day) 
     218    if [ X$2 = X ] ; then 
     219      echo 365 
     220    else 
     221      eval $2=365 > /dev/null 2>&1 
     222    fi 
    261223 
    262224#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    263         return 
    264     fi 
    265  
    266     #if it is evenly divisible by 100 it must not be a leap year 
    267     a=$(( $y % 100 )) 
    268     if [ $a = 0 ] 
    269         then 
    270         if [ X$2 = X ] ; then 
    271             echo 365 
    272         else 
    273             eval $2=365 > /dev/null 2>&1 
    274         fi 
     225    return;; 
     226  all_leap|366_day) 
     227    if [ X$2 = X ] ; then 
     228      echo 366 
     229    else 
     230      eval $2=366 > /dev/null 2>&1 
     231    fi 
    275232 
    276233#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    277         return 
    278     fi 
    279          
    280     # if it is evenly divisible by 4 it must be a leap year 
    281     a=$(( $y % 4 )) 
    282     if [ $a = 0 ] 
    283         then 
    284         if [ X$2 = X ] ; then 
    285             echo 366 
    286         else 
    287             eval $2=366 > /dev/null 2>&1 
    288         fi 
     234    return;; 
     235  esac 
     236 
     237  typeset y a 
     238 
     239  # if there is no argument on the command line,  
     240  # then assume that a yyyy is being piped in 
     241  if [ $# = 0 ] 
     242  then 
     243    read y 
     244  else 
     245    y=$(( 10#${1} )) 
     246  fi 
     247 
     248  # a year is a leap year if it is even divisible by 4 
     249  # but not evenly divisible by 100 
     250  # unless it is evenly divisible by 400 
     251 
     252  # if it is evenly divisible by 400 it must be a leap year 
     253  a=$(( $y % 400 )) 
     254  if [ $a = 0 ] 
     255  then 
     256    if [ X$2 = X ] ; then 
     257      echo 366 
     258    else 
     259      eval $2=366 > /dev/null 2>&1 
     260    fi 
    289261 
    290262#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    291         return 
    292     fi 
    293  
    294     # otherwise it is not a leap year 
     263    return 
     264  fi 
     265 
     266  # if it is evenly divisible by 100 it must not be a leap year 
     267  a=$(( $y % 100 )) 
     268  if [ $a = 0 ] 
     269  then 
    295270    if [ X$2 = X ] ; then 
    296         echo 365 
    297     else 
    298         eval $2=365 > /dev/null 2>&1 
    299     fi 
     271      echo 365 
     272    else 
     273      eval $2=365 > /dev/null 2>&1 
     274    fi 
     275 
     276#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
     277    return 
     278  fi 
     279   
     280  # if it is evenly divisible by 4 it must be a leap year 
     281  a=$(( $y % 4 )) 
     282  if [ $a = 0 ] 
     283  then 
     284    if [ X$2 = X ] ; then 
     285      echo 366 
     286    else 
     287      eval $2=366 > /dev/null 2>&1 
     288    fi 
     289 
     290#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
     291    return 
     292  fi 
     293 
     294  # otherwise it is not a leap year 
     295  if [ X$2 = X ] ; then 
     296    echo 365 
     297  else 
     298    eval $2=365 > /dev/null 2>&1 
     299  fi 
    300300 
    301301#    IGCM_debug_PopStack "IGCM_date_DaysInYear" 
     
    315315#    IGCM_debug_PushStack "IGCM_date_DaysInMonth" $@ 
    316316 
    317     # calculates the number of days in a month  
    318     # usage IGCM_date_DaysInMonth yyyy mm 
    319     # or IGCM_date_DaysInMonth yyyymmdd 
     317  # calculates the number of days in a month  
     318  # usage IGCM_date_DaysInMonth yyyy mm 
     319  # or IGCM_date_DaysInMonth yyyymmdd 
     320   
     321  # What is the calendar : 
     322  if ( [ "${config_UserChoices_CalendarType}" = "360d" ] || [ "${config_UserChoices_CalendarType}" = "360_day" ] ) ; then 
     323    if [ X$3 = X ] ; then 
     324      echo 30 
     325    else 
     326      eval $3=30 > /dev/null 2>&1 
     327    fi 
     328 
     329#   IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
     330    return 
     331  fi 
     332 
     333  typeset ymd y m 
     334 
     335  # if there are no command line arguments then assume that a yyyymmdd is being 
     336  # piped in and read the value. 
     337  # if there is only one argument assume it is a yyyymmdd on the command line 
     338  # other wise it is a yyyy and mm on the command line 
     339  if [ $# = 0 ] 
     340  then 
     341    read ymd 
     342  elif [ $# = 1 ]  
     343  then 
     344    ymd=$1 
     345  else 
     346    ymd=$(( ( $1 * 10000 ) + ( $2 * 100 ) + 1 )) 
     347  fi 
     348 
     349  # extract the year and the month 
     350  y=$(( $ymd / 10000 )) ; 
     351  m=$(( ( $ymd % 10000 ) / 100 )) ; 
     352 
     353  # 30 days hath september etc. 
     354  case $m in 
     355  1|3|5|7|8|10|12)  
     356    if [ X$3 = X ] ; then 
     357      echo 31 
     358    else 
     359      eval $3=31 > /dev/null 2>&1 
     360    fi 
     361 
     362#           IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
     363    return ;; 
     364  4|6|9|11)  
     365    if [ X$3 = X ] ; then 
     366      echo 30 
     367    else 
     368      eval $3=30 > /dev/null 2>&1 
     369    fi 
    320370     
    321     # What is the calendar : 
    322     if ( [ "${config_UserChoices_CalendarType}" = "360d" ] || [ "${config_UserChoices_CalendarType}" = "360_day" ] ) ; then 
    323         if [ X$3 = X ] ; then 
    324             echo 30 
    325         else 
    326             eval $3=30 > /dev/null 2>&1 
    327         fi 
    328  
    329 #       IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    330         return 
    331     fi 
    332  
    333     typeset ymd y m 
    334  
    335     # if there are no command line arguments then assume that a yyyymmdd is being 
    336     # piped in and read the value. 
    337     # if there is only one argument assume it is a yyyymmdd on the command line 
    338     # other wise it is a yyyy and mm on the command line 
    339     if [ $# = 0 ] 
    340         then 
    341         read ymd 
    342     elif [ $# = 1 ]  
    343         then 
    344         ymd=$1 
    345     else 
    346         ymd=$(( ( $1 * 10000 ) + ( $2 * 100 ) + 1 )) 
    347     fi 
    348  
    349     # extract the year and the month 
    350     y=$(( $ymd / 10000 )) ; 
    351     m=$(( ( $ymd % 10000 ) / 100 )) ; 
    352  
    353     # 30 days hath september etc. 
    354     case $m in 
    355         1|3|5|7|8|10|12)  
    356             if [ X$3 = X ] ; then 
    357                 echo 31 
    358             else 
    359                 eval $3=31 > /dev/null 2>&1 
    360             fi 
    361  
    362371#           IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    363             return ;; 
    364         4|6|9|11)  
    365             if [ X$3 = X ] ; then 
    366                 echo 30 
    367             else 
    368                 eval $3=30 > /dev/null 2>&1 
    369             fi 
    370          
    371 #           IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    372             return ;; 
    373         *) ;; 
    374     esac 
    375  
    376     # except for month 2 which depends on whether the year is a leap year 
    377     # Use IGCM_date_DaysInYear to get the number of days in the year and return a value 
    378     # accordingly. 
    379     IGCM_date_DaysInYear $y diy 
    380     case $diy in 
    381         365)  
    382             if [ X$3 = X ] ; then 
    383                 echo 28 
    384             else 
    385                 eval $3=28 > /dev/null 2>&1 
    386             fi 
    387  
    388 #           IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    389             return ;; 
    390         366)  
    391             if [ X$3 = X ] ; then 
    392                 echo 29 
    393             else 
    394                 eval $3=29 > /dev/null 2>&1 
    395             fi 
    396  
    397 #           IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    398             return ;; 
    399     esac 
     372    return ;; 
     373  *) ;; 
     374  esac 
     375 
     376  # except for month 2 which depends on whether the year is a leap year 
     377  # Use IGCM_date_DaysInYear to get the number of days in the year and return a value 
     378  # accordingly. 
     379  IGCM_date_DaysInYear $y diy 
     380  case $diy in 
     381  365)  
     382    if [ X$3 = X ] ; then 
     383      echo 28 
     384    else 
     385      eval $3=28 > /dev/null 2>&1 
     386    fi 
     387 
     388#    IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
     389    return ;; 
     390  366)  
     391    if [ X$3 = X ] ; then 
     392      echo 29 
     393    else 
     394      eval $3=29 > /dev/null 2>&1 
     395    fi 
     396 
     397#    IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
     398    return ;; 
     399  esac 
    400400 
    401401#    IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
     
    411411function IGCM_date_ConvertGregorianDateToJulian 
    412412{ 
    413     IGCM_debug_PushStack "IGCM_date_ConvertGregorianDateToJulian" $@ 
    414  
    415     # IGCM_date_ConvertGregorianDateToJulian converts yyyymmdd to yyyyddd 
    416     # usage IGCM_date_ConvertGregorianDateToJulian 19980429 
    417  
    418     typeset dt y m d x jul 
    419  
    420     # if there is no command line argument, then assume that the date 
    421     # is coming in on a pipe and use read to collect it     
    422     if [ $# = 0 ] 
    423         then 
    424         read dt 
    425     else 
    426         dt=$( IGCM_date_SupressZeros $1 ) 
    427     fi 
    428  
    429     # break the yyyymmdd into separate parts for year, month and day 
    430     y=$(( $dt / 10000 )) 
    431     m=$(( ( $dt % 10000 ) / 100 )) 
    432     d=$(( ( $dt % 100 ) )) 
    433  
    434     # add the days in each month up to (but not including the month itself) 
    435     # into the days. For example if the date is 19980203 then extract the 
    436     # number of days in January and add it to 03. If the date is June 14, 1998 
    437     # then extract the number of days in January, February, March, April and May 
    438     # and add them to 14. 
    439     x=1 
    440     while [ $x -lt $m ] 
    441       do 
    442       IGCM_date_DaysInMonth $y $x md 
    443       d=$(( $d + $md )) 
    444       x=$(( $x + 1 )) 
    445     done 
    446  
    447     # combine the year and day back together again and you have the julian date. 
    448     jul=$(( ( $y * 1000 ) + $d )) 
    449     echo $jul 
    450  
    451     IGCM_debug_PopStack "IGCM_date_ConvertGregorianDateToJulian" 
     413  IGCM_debug_PushStack "IGCM_date_ConvertGregorianDateToJulian" $@ 
     414 
     415  # IGCM_date_ConvertGregorianDateToJulian converts yyyymmdd to yyyyddd 
     416  # usage IGCM_date_ConvertGregorianDateToJulian 19980429 
     417 
     418  typeset dt y m d x jul 
     419 
     420  # if there is no command line argument, then assume that the date 
     421  # is coming in on a pipe and use read to collect it     
     422  if [ $# = 0 ] 
     423  then 
     424    read dt 
     425  else 
     426    dt=$( IGCM_date_SupressZeros $1 ) 
     427  fi 
     428 
     429  # break the yyyymmdd into separate parts for year, month and day 
     430  y=$(( $dt / 10000 )) 
     431  m=$(( ( $dt % 10000 ) / 100 )) 
     432  d=$(( ( $dt % 100 ) )) 
     433 
     434  # add the days in each month up to (but not including the month itself) 
     435  # into the days. For example if the date is 19980203 then extract the 
     436  # number of days in January and add it to 03. If the date is June 14, 1998 
     437  # then extract the number of days in January, February, March, April and May 
     438  # and add them to 14. 
     439  x=1 
     440  while [ $x -lt $m ] 
     441  do 
     442    IGCM_date_DaysInMonth $y $x md 
     443    d=$(( $d + $md )) 
     444    x=$(( $x + 1 )) 
     445  done 
     446 
     447  # combine the year and day back together again and you have the julian date. 
     448  jul=$(( ( $y * 1000 ) + $d )) 
     449  echo $jul 
     450 
     451  IGCM_debug_PopStack "IGCM_date_ConvertGregorianDateToJulian" 
    452452} 
    453453 
     
    461461function IGCM_date_ConvertJulianDateToGregorian 
    462462{ 
    463     IGCM_debug_PushStack "IGCM_date_ConvertJulianDateToGregorian" $@ 
    464  
    465     # IGCM_date_ConvertJulianDateToGregorian converts yyyyddd to yyyymmdd 
    466     # usage IGCM_date_ConvertJulianDateToGregorian 1998213 
    467  
    468     typeset dt y m d grg 
    469  
    470     # if there is no command line argument, assume one is being  
    471     # piped in and read it 
    472     if [ X$1 = X ] 
    473         then 
    474         read dt 
    475     else 
    476         dt=$1 
    477     fi 
    478          
    479     # break apart the year and the days 
    480     y=$(( $dt / 1000 )) 
    481     d=$(( $dt % 1000 )) 
    482          
    483     # subtract the number of days in each month starting from 1 
    484     # from the days in the date. When the day goes below 1, you 
    485     # have the current month. Add back the number of days in the 
    486     # month to get the correct day of the month 
    487     m=1 
    488     while [ $d -gt 0 ] 
    489       do 
    490       IGCM_date_DaysInMonth $y $m md 
    491       d=$(( $d - $md )) 
    492       m=$(( $m + 1 )) 
    493     done 
    494  
    495     d=$(( $d + $md )) 
    496  
    497     # the loop steps one past the correct month, so back up the month 
    498     m=$(( $m - 1 )) 
    499  
    500     # assemble the results into a gregorian date 
    501     grg=$(( ( $y * 10000 ) + ( $m * 100 ) + $d )) 
    502     echo $( IGCM_date_GregorianDigit $grg ) 
    503  
    504     IGCM_debug_PopStack "IGCM_date_ConvertJulianDateToGregorian" 
     463  IGCM_debug_PushStack "IGCM_date_ConvertJulianDateToGregorian" $@ 
     464 
     465  # IGCM_date_ConvertJulianDateToGregorian converts yyyyddd to yyyymmdd 
     466  # usage IGCM_date_ConvertJulianDateToGregorian 1998213 
     467 
     468  typeset dt y m d grg 
     469 
     470  # if there is no command line argument, assume one is being  
     471  # piped in and read it 
     472  if [ X$1 = X ] 
     473  then 
     474    read dt 
     475  else 
     476    dt=$1 
     477  fi 
     478   
     479  # break apart the year and the days 
     480  y=$(( $dt / 1000 )) 
     481  d=$(( $dt % 1000 )) 
     482   
     483  # subtract the number of days in each month starting from 1 
     484  # from the days in the date. When the day goes below 1, you 
     485  # have the current month. Add back the number of days in the 
     486  # month to get the correct day of the month 
     487  m=1 
     488  while [ $d -gt 0 ] 
     489  do 
     490    IGCM_date_DaysInMonth $y $m md 
     491    d=$(( $d - $md )) 
     492    m=$(( $m + 1 )) 
     493  done 
     494 
     495  d=$(( $d + $md )) 
     496 
     497  # the loop steps one past the correct month, so back up the month 
     498  m=$(( $m - 1 )) 
     499 
     500  # assemble the results into a gregorian date 
     501  grg=$(( ( $y * 10000 ) + ( $m * 100 ) + $d )) 
     502  echo $( IGCM_date_GregorianDigit $grg ) 
     503 
     504  IGCM_debug_PopStack "IGCM_date_ConvertJulianDateToGregorian" 
    505505} 
    506506 
     
    514514function IGCM_date_AddDaysToJulianDate 
    515515{ 
    516     IGCM_debug_PushStack "IGCM_date_AddDaysToJulianDate" $@ 
    517  
    518     # IGCM_date_AddDaysToJulianDate adds days to a yyyyddd formatted date 
    519     # usage IGCM_date_AddDaysToJulianDate 1998312 { ,-}14 
    520  
    521     typeset dif yd d y 
    522  
    523     # Read the difference from the command lines 
    524     # and the date from the command line, or standard input 
    525     if [ X$2 = X ] 
    526         then 
    527         dif=$1 
    528         read yd 
    529     else 
    530         yd=$1 
    531         dif=$2 
    532     fi 
    533  
    534     # Break it into pieces 
    535     d=$(( $yd % 1000 )) 
    536     y=$(( $yd / 1000 )) 
    537  
    538     # Add the number of days (if days is negative this results is 
    539     # a subtraction) 
    540     d=$(( $d + $dif )) 
    541  
    542     # Extract the days in the year 
     516  IGCM_debug_PushStack "IGCM_date_AddDaysToJulianDate" $@ 
     517 
     518  # IGCM_date_AddDaysToJulianDate adds days to a yyyyddd formatted date 
     519  # usage IGCM_date_AddDaysToJulianDate 1998312 { ,-}14 
     520 
     521  typeset dif yd d y 
     522 
     523  # Read the difference from the command lines 
     524  # and the date from the command line, or standard input 
     525  if [ X$2 = X ] 
     526  then 
     527    dif=$1 
     528    read yd 
     529  else 
     530    yd=$1 
     531    dif=$2 
     532  fi 
     533 
     534  # Break it into pieces 
     535  d=$(( $yd % 1000 )) 
     536  y=$(( $yd / 1000 )) 
     537 
     538  # Add the number of days (if days is negative this results is 
     539  # a subtraction) 
     540  d=$(( $d + $dif )) 
     541 
     542  # Extract the days in the year 
     543  IGCM_date_DaysInYear $y diy 
     544 
     545  # If the calculated day exceeds the days in the year,  
     546  # add one year to the year and subtract the days in the year from the 
     547  # calculated days. Extract the days in the new year and repeat 
     548  # test until you end up with a day number that falls within the 
     549  # days of the year 
     550  while [ $d -gt $diy ] 
     551  do 
     552    d=$(( $d - $diy )) 
     553    y=$(( $y + 1 )) 
    543554    IGCM_date_DaysInYear $y diy 
    544  
    545     # If the calculated day exceeds the days in the year,  
    546     # add one year to the year and subtract the days in the year from the 
    547     # calculated days. Extract the days in the new year and repeat 
    548     # test until you end up with a day number that falls within the 
    549     # days of the year 
    550     while [ $d -gt $diy ] 
    551       do 
    552       d=$(( $d - $diy )) 
    553       y=$(( $y + 1 )) 
    554       IGCM_date_DaysInYear $y diy 
    555     done 
    556  
    557     # This is the reverse process. If the calculated number of days 
    558     # is less than 1, move back one year. Extract 
    559     # the days in this year and add the days in the year 
    560     # loop on this test until you end up with a number that 
    561     # falls within the days of the year 
    562     while [ $d -lt 1 ] 
    563       do 
    564       y=$(( $y - 1 )) 
    565       IGCM_date_DaysInYear $y diy 
    566       d=$(( $d + $diy )) 
    567     done 
    568  
    569     # put the year and day back together and echo the result 
    570     yd=$(( ( $y * 1000 ) + $d )) 
    571  
    572     echo $yd 
    573  
    574     IGCM_debug_PopStack "IGCM_date_AddDaysToJulianDate" 
     555  done 
     556 
     557  # This is the reverse process. If the calculated number of days 
     558  # is less than 1, move back one year. Extract 
     559  # the days in this year and add the days in the year 
     560  # loop on this test until you end up with a number that 
     561  # falls within the days of the year 
     562  while [ $d -lt 1 ] 
     563  do 
     564    y=$(( $y - 1 )) 
     565    IGCM_date_DaysInYear $y diy 
     566    d=$(( $d + $diy )) 
     567  done 
     568 
     569  # put the year and day back together and echo the result 
     570  yd=$(( ( $y * 1000 ) + $d )) 
     571 
     572  echo $yd 
     573 
     574  IGCM_debug_PopStack "IGCM_date_AddDaysToJulianDate" 
    575575} 
    576576 
     
    584584function IGCM_date_AddDaysToGregorianDate 
    585585{ 
    586     IGCM_debug_PushStack "IGCM_date_AddDaysToGregorianDate" $@ 
    587  
    588     # IGCM_date_AddDaysToGregorianDate adds days to a yyyymmdd formatted date 
    589     # usage IGCM_date_AddDaysToGregorianDate 19980312 { ,-}14 
    590  
    591     # Read the difference from the command lines 
    592     # and the date from the command line, or standard input 
    593     typeset dif yd tmp res 
    594     if [ X$2 = X ] 
    595         then 
    596         dif=$1 
    597         read yd 
    598     else 
    599         yd=$1 
    600         dif=$2 
    601     fi 
    602  
    603     tmp=$( IGCM_date_ConvertGregorianDateToJulian $yd ) 
    604     tmp=$( IGCM_date_AddDaysToJulianDate $tmp $dif ) 
    605     res=$( IGCM_date_ConvertJulianDateToGregorian $tmp ) 
    606      
    607     echo $res 
    608  
    609     IGCM_debug_PopStack "IGCM_date_AddDaysToGregorianDate" 
     586  IGCM_debug_PushStack "IGCM_date_AddDaysToGregorianDate" $@ 
     587 
     588  # IGCM_date_AddDaysToGregorianDate adds days to a yyyymmdd formatted date 
     589  # usage IGCM_date_AddDaysToGregorianDate 19980312 { ,-}14 
     590 
     591  # Read the difference from the command lines 
     592  # and the date from the command line, or standard input 
     593  typeset dif yd tmp res 
     594  if [ X$2 = X ] 
     595  then 
     596    dif=$1 
     597    read yd 
     598  else 
     599    yd=$1 
     600    dif=$2 
     601  fi 
     602 
     603  tmp=$( IGCM_date_ConvertGregorianDateToJulian $yd ) 
     604  tmp=$( IGCM_date_AddDaysToJulianDate $tmp $dif ) 
     605  res=$( IGCM_date_ConvertJulianDateToGregorian $tmp ) 
     606   
     607  echo $res 
     608 
     609  IGCM_debug_PopStack "IGCM_date_AddDaysToGregorianDate" 
    610610} 
    611611 
     
    619619function IGCM_date_DaysBetweenJulianDate 
    620620{ 
    621     IGCM_debug_PushStack "IGCM_date_DaysBetweenJulianDate" $@ 
    622  
    623     # calculates the days difference between two dates and reports  
    624     # the number days as jul1 - jul2  
    625     # usage IGCM_date_DaysBetweenJulianDate jul1 jul2 
    626     # where julian date is in the form yyyyddd 
    627      
    628     usage () { 
    629         echo "Usage:" 
    630         echo " IGCM_date_DaysBetweenJulianDate jul1 jul2" 
    631         echo "" 
    632         echo " Calculates the day difference between" 
    633         echo " two julian dates (jul1 -jul2)" 
    634         echo " where a julian date is in the form of yyyyddd." 
    635     } 
    636   
    637     if [ $# -lt 2 ]; then 
    638         usage 
    639         IGCM_debug_Exit "IGCM_date_DaysBetweenJulianDate" 
    640     fi 
    641   
    642     # This process subtracts arg2 from arg1. If arg2 is larger 
    643     # then reverse the arguments. The calculations are done, and 
    644     # then the sign is reversed 
    645     if [ $1 -lt $2 ] 
    646         then 
    647         jul1=$2 
    648         jul2=$1 
    649     elif [ $1 -gt $2 ] 
    650         then 
    651         jul1=$1 
    652         jul2=$2 
    653     else 
    654         echo 0 
    655         IGCM_debug_PopStack "IGCM_date_DaysBetweenJulianDate" 
    656         return 
    657     fi 
    658  
    659     # Break the dates in to year and day portions 
    660     yyyy1=$(( $jul1 / 1000 )) 
    661     yyyy2=$(( $jul2 / 1000 )) 
    662     ddd1=$(( $jul1 % 1000 )) 
    663     ddd2=$(( $jul2 % 1000 )) 
    664  
    665     # Subtract days 
    666     res=$(( $ddd1 - $ddd2 )) 
    667  
    668     # Then add days in year until year2 matches year1 
    669  
    670     case ${config_UserChoices_CalendarType} in 
    671         360d|360_day)  
    672             res=$(( ( ( $yyyy1 - $yyyy2 ) * 360 ) + $res )) ;; 
    673         noleap|365_day) 
    674             res=$(( ( ( $yyyy1 - $yyyy2 ) * 365 ) + $res )) ;; 
    675         all_leap|366_day) 
    676             res=$(( ( ( $yyyy1 - $yyyy2 ) * 366 ) + $res )) ;; 
    677         leap|gregorian|standard) 
    678             while [ $yyyy2 -lt $yyyy1 ] 
    679             do 
    680                 IGCM_date_DaysInYear $yyyy2 diy 
    681                 res=$(( $res + $diy )) 
    682                 yyyy2=$(( $yyyy2 + 1 )) 
    683             done 
    684             ;; 
    685     esac 
    686  
    687  
    688     # if argument 2 was larger than argument 1 then  
    689     # the arguments were reversed before calculating 
    690     # adjust by reversing the sign 
    691     if [ $1 -lt $2 ] 
    692         then 
    693         res=$(( $res * -1 )) 
    694     fi 
    695   
    696     # and output the results 
    697     echo $res 
    698  
     621  IGCM_debug_PushStack "IGCM_date_DaysBetweenJulianDate" $@ 
     622 
     623  # calculates the days difference between two dates and reports  
     624  # the number days as jul1 - jul2  
     625  # usage IGCM_date_DaysBetweenJulianDate jul1 jul2 
     626  # where julian date is in the form yyyyddd 
     627   
     628  usage () { 
     629    echo "Usage:" 
     630    echo " IGCM_date_DaysBetweenJulianDate jul1 jul2" 
     631    echo "" 
     632    echo " Calculates the day difference between" 
     633    echo " two julian dates (jul1 -jul2)" 
     634    echo " where a julian date is in the form of yyyyddd." 
     635  } 
     636   
     637  if [ $# -lt 2 ]; then 
     638    usage 
     639    IGCM_debug_Exit "IGCM_date_DaysBetweenJulianDate" 
     640  fi 
     641   
     642  # This process subtracts arg2 from arg1. If arg2 is larger 
     643  # then reverse the arguments. The calculations are done, and 
     644  # then the sign is reversed 
     645  if [ $1 -lt $2 ] 
     646  then 
     647    jul1=$2 
     648    jul2=$1 
     649  elif [ $1 -gt $2 ] 
     650  then 
     651    jul1=$1 
     652    jul2=$2 
     653  else 
     654    echo 0 
    699655    IGCM_debug_PopStack "IGCM_date_DaysBetweenJulianDate" 
     656    return 
     657  fi 
     658 
     659  # Break the dates in to year and day portions 
     660  yyyy1=$(( $jul1 / 1000 )) 
     661  yyyy2=$(( $jul2 / 1000 )) 
     662  ddd1=$(( $jul1 % 1000 )) 
     663  ddd2=$(( $jul2 % 1000 )) 
     664 
     665  # Subtract days 
     666  res=$(( $ddd1 - $ddd2 )) 
     667 
     668  # Then add days in year until year2 matches year1 
     669  case ${config_UserChoices_CalendarType} in 
     670  360d|360_day)  
     671    res=$(( ( ( $yyyy1 - $yyyy2 ) * 360 ) + $res )) ;; 
     672  noleap|365_day) 
     673    res=$(( ( ( $yyyy1 - $yyyy2 ) * 365 ) + $res )) ;; 
     674  all_leap|366_day) 
     675    res=$(( ( ( $yyyy1 - $yyyy2 ) * 366 ) + $res )) ;; 
     676  leap|gregorian|standard) 
     677    while [ $yyyy2 -lt $yyyy1 ] 
     678    do 
     679      IGCM_date_DaysInYear $yyyy2 diy 
     680      res=$(( $res + $diy )) 
     681      yyyy2=$(( $yyyy2 + 1 )) 
     682    done 
     683    ;; 
     684  esac 
     685 
     686 
     687  # if argument 2 was larger than argument 1 then  
     688  # the arguments were reversed before calculating 
     689  # adjust by reversing the sign 
     690  if [ $1 -lt $2 ] 
     691  then 
     692    res=$(( $res * -1 )) 
     693  fi 
     694 
     695  # and output the results 
     696  echo $res 
     697 
     698  IGCM_debug_PopStack "IGCM_date_DaysBetweenJulianDate" 
    700699} 
    701700 
     
    709708function IGCM_date_DaysBetweenGregorianDate 
    710709{ 
    711     IGCM_debug_PushStack "IGCM_date_DaysBetweenGregorianDate" $@ 
    712  
    713     # calculates the days difference between two dates and reports  
    714     # the number days as grg1 - grg2  
    715     # usage IGCM_date_DaysBetweenGregorianDate grg1 grg2 
    716     # where gregorian date is in the form yyyymmdd 
    717  
    718     usage () { 
    719         echo "Usage:" 
    720         echo " IGCM_date_DaysBetweenGregorianDate grg1 grg2" 
    721         echo "" 
    722         echo " Calculate day difference between" 
    723         echo " two gregorian dates (grg1 - grg2)" 
    724         echo " where a gregorian date is in the form of yyyymmdd." 
    725     } 
    726  
    727     if [ $# -lt 2 ]; then 
    728         usage 
    729         IGCM_debug_Exit "IGCM_date_DaysBetweenGregorianDate" 
    730     fi 
    731  
    732     # convert each date to julian 
    733     grg1=$1 
    734     grg2=$2 
    735  
    736     jul1=$( IGCM_date_ConvertGregorianDateToJulian $grg1 ) 
    737     jul2=$( IGCM_date_ConvertGregorianDateToJulian $grg2 ) 
    738  
    739     if [ $jul1 -ne $jul2 ]; then 
     710  IGCM_debug_PushStack "IGCM_date_DaysBetweenGregorianDate" $@ 
     711 
     712  # calculates the days difference between two dates and reports  
     713  # the number days as grg1 - grg2  
     714  # usage IGCM_date_DaysBetweenGregorianDate grg1 grg2 
     715  # where gregorian date is in the form yyyymmdd 
     716 
     717  usage () { 
     718    echo "Usage:" 
     719    echo " IGCM_date_DaysBetweenGregorianDate grg1 grg2" 
     720    echo "" 
     721    echo " Calculate day difference between" 
     722    echo " two gregorian dates (grg1 - grg2)" 
     723    echo " where a gregorian date is in the form of yyyymmdd." 
     724  } 
     725 
     726  if [ $# -lt 2 ]; then 
     727    usage 
     728    IGCM_debug_Exit "IGCM_date_DaysBetweenGregorianDate" 
     729  fi 
     730 
     731  # convert each date to julian 
     732  grg1=$1 
     733  grg2=$2 
     734 
     735  jul1=$( IGCM_date_ConvertGregorianDateToJulian $grg1 ) 
     736  jul2=$( IGCM_date_ConvertGregorianDateToJulian $grg2 ) 
     737 
     738  if [ $jul1 -ne $jul2 ]; then 
    740739    # calculate the answer using IGCM_date_DaysBetweenJulianDate 
    741         res=$( IGCM_date_DaysBetweenJulianDate $jul1 $jul2 ) 
     740    res=$( IGCM_date_DaysBetweenJulianDate $jul1 $jul2 ) 
    742741    # and output the results 
    743         echo $res 
    744     else 
    745         echo 0 
    746     fi 
    747  
    748     IGCM_debug_PopStack "IGCM_date_DaysBetweenGregorianDate" 
     742    echo $res 
     743  else 
     744    echo 0 
     745  fi 
     746 
     747  IGCM_debug_PopStack "IGCM_date_DaysBetweenGregorianDate" 
    749748} 
    750749 
     
    757756function IGCM_date_DaysSinceJC 
    758757{ 
    759     IGCM_debug_PushStack "IGCM_date_DaysSinceJC" $@ 
    760  
    761     # calculates the days difference between a date and 00010101 
    762     # usage IGCM_date_DaysSinceJC grg1 
    763     # where gregorian date is in the form yyyymmdd 
    764  
    765     usage () { 
    766         echo "Usage:" 
    767         echo " IGCM_date_DaysSinceJC grg1" 
    768         echo "" 
    769         echo " Calculate day difference between" 
    770         echo " a gregorian date and 00010101" 
    771         echo " where a gregorian date is in the form of yyyymmdd." 
    772     } 
    773  
    774     if [ $# -lt 1 ]; then 
    775         usage 
    776         IGCM_debug_Exit "IGCM_date_DaysSinceJC" 
    777     fi 
    778      
    779     typeset aux num 
    780  
    781     if   [ ${1} -lt  5000000 ]; then 
    782         case ${config_UserChoices_CalendarType} in 
    783             360d|360_day)  
    784                 aux=-360;; 
    785             noleap|365_day) 
    786                 aux=-365;; 
    787             all_leap|366_day)  
    788                 aux=-366;; 
    789             leap|gregorian|standard) 
    790                 aux=-366;; 
    791         esac 
    792         num=101 
    793     elif [ ${1} -lt 15000000 ]; then 
    794         # To save CPU type we use auxiliary value 
    795         # which is number of days since JC and 10000101 
    796         case ${config_UserChoices_CalendarType} in 
    797             360d|360_day)  
    798                 aux=359640;; 
    799             noleap|365_day) 
    800                 aux=364635;; 
    801             all_leap|366_day)  
    802                 aux=365634;; 
    803             leap|gregorian|standard) 
    804                 aux=364877;; 
    805         esac 
    806         num=10000101 
    807     else 
    808         # To save CPU type we use auxiliary value 
    809         # which is number of days since JC and 19000101 
    810         case ${config_UserChoices_CalendarType} in 
    811             360d|360_day)  
    812                 aux=683640;; 
    813             noleap|365_day) 
    814                 aux=693135;; 
    815             all_leap|366_day)  
    816                 aux=695034;; 
    817             leap|gregorian|standard) 
    818                 aux=693595;; 
    819         esac 
    820         num=19000101 
    821     fi 
    822     echo $(( $( IGCM_date_DaysBetweenGregorianDate $1 ${num} ) + $aux )) 
    823  
    824     IGCM_debug_PopStack "IGCM_date_DaysSinceJC" 
     758  IGCM_debug_PushStack "IGCM_date_DaysSinceJC" $@ 
     759 
     760  # calculates the days difference between a date and 00010101 
     761  # usage IGCM_date_DaysSinceJC grg1 
     762  # where gregorian date is in the form yyyymmdd 
     763 
     764  usage () { 
     765    echo "Usage:" 
     766    echo " IGCM_date_DaysSinceJC grg1" 
     767    echo "" 
     768    echo " Calculate day difference between" 
     769    echo " a gregorian date and 00010101" 
     770    echo " where a gregorian date is in the form of yyyymmdd." 
     771  } 
     772 
     773  if [ $# -lt 1 ]; then 
     774    usage 
     775    IGCM_debug_Exit "IGCM_date_DaysSinceJC" 
     776  fi 
     777   
     778  typeset aux num 
     779 
     780  if   [ ${1} -lt  5000000 ]; then 
     781    case ${config_UserChoices_CalendarType} in 
     782    360d|360_day)  
     783      aux=-360;; 
     784    noleap|365_day) 
     785      aux=-365;; 
     786    all_leap|366_day)  
     787      aux=-366;; 
     788    leap|gregorian|standard) 
     789      aux=-366;; 
     790    esac 
     791    num=101 
     792  elif [ ${1} -lt 15000000 ]; then 
     793    # To save CPU type we use auxiliary value 
     794    # which is number of days since JC and 10000101 
     795    case ${config_UserChoices_CalendarType} in 
     796    360d|360_day)  
     797      aux=359640;; 
     798    noleap|365_day) 
     799      aux=364635;; 
     800    all_leap|366_day)  
     801      aux=365634;; 
     802    leap|gregorian|standard) 
     803      aux=364877;; 
     804    esac 
     805    num=10000101 
     806  else 
     807    # To save CPU type we use auxiliary value 
     808    # which is number of days since JC and 19000101 
     809    case ${config_UserChoices_CalendarType} in 
     810    360d|360_day)  
     811      aux=683640;; 
     812    noleap|365_day) 
     813      aux=693135;; 
     814    all_leap|366_day)  
     815      aux=695034;; 
     816    leap|gregorian|standard) 
     817      aux=693595;; 
     818    esac 
     819    num=19000101 
     820  fi 
     821  echo $(( $( IGCM_date_DaysBetweenGregorianDate $1 ${num} ) + $aux )) 
     822 
     823  IGCM_debug_PopStack "IGCM_date_DaysSinceJC" 
    825824} 
    826825 
     
    830829function IGCM_date_Check 
    831830{ 
    832     IGCM_debug_PushStack "IGCM_date_Check" 
     831  IGCM_debug_PushStack "IGCM_date_Check" 
    833832 
    834833#--------------------- 
    835     if [ ! -n "${libIGCM}" ] ; then 
    836         echo "Check libIGCM_date ...........................................[ FAILED ]" 
    837         echo "--Error--> libIGCM variable is not defined" 
    838         IGCM_debug_Exit "IGCM_date_Check" 
    839     fi 
     834  if [ ! -n "${libIGCM}" ] ; then 
     835    echo "Check libIGCM_date ...........................................[ FAILED ]" 
     836    echo "--Error--> libIGCM variable is not defined" 
     837    IGCM_debug_Exit "IGCM_date_Check" 
     838  fi 
    840839 
    841840#--------------------- 
    842     whence -v gawk > /dev/null 2>&1 
    843     if [ ! $? -eq 0 ] ; then 
    844         echo "Check libIGCM_date ...........................................[ FAILED ]" 
    845         echo "--Error--> gawk command is not defined" 
    846         IGCM_debug_Exit "IGCM_date_Check" 
    847     fi 
     841  whence -v gawk > /dev/null 2>&1 
     842  if [ ! $? -eq 0 ] ; then 
     843    echo "Check libIGCM_date ...........................................[ FAILED ]" 
     844    echo "--Error--> gawk command is not defined" 
     845    IGCM_debug_Exit "IGCM_date_Check" 
     846  fi 
    848847 
    849848#--------------------- 
    850     ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh > IGCM_date_Test.ref.failed 2>&1 
    851      
    852     if diff IGCM_date_Test.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref > /dev/null 2>&1 ; then  
    853         echo "Check libIGCM_date ...............................................[ OK ]" 
    854         rm -f IGCM_date_Test.ref.failed 
    855     else  
    856         echo "Check libIGCM_date ...........................................[ FAILED ]" 
    857         echo "--Error--> Execution of ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh" 
    858         echo "           has produced the file IGCM_date_Test.ref.failed" 
    859         echo "           Please analyse differences with the reference file by typing:" 
    860         echo "           diff IGCM_date_Test.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref" 
    861         echo "           Report errors to the author: Sebastien.Denvil@ipsl.jussieu.fr" 
    862         IGCM_debug_Exit "IGCM_date_Check" 
    863     fi 
     849  ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh > IGCM_date_Test.ref.failed 2>&1 
     850   
     851  if diff IGCM_date_Test.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref > /dev/null 2>&1 ; then  
     852    echo "Check libIGCM_date ...............................................[ OK ]" 
     853    rm -f IGCM_date_Test.ref.failed 
     854  else  
     855    echo "Check libIGCM_date ...........................................[ FAILED ]" 
     856    echo "--Error--> Execution of ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh" 
     857    echo "           has produced the file IGCM_date_Test.ref.failed" 
     858    echo "           Please analyse differences with the reference file by typing:" 
     859    echo "           diff IGCM_date_Test.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref" 
     860    echo "           Report errors to the author: Sebastien.Denvil@ipsl.jussieu.fr" 
     861    IGCM_debug_Exit "IGCM_date_Check" 
     862  fi 
    864863 
    865864#--------------------- 
    866     IGCM_debug_PopStack "IGCM_date_Check" 
     865  IGCM_debug_PopStack "IGCM_date_Check" 
    867866} 
    868867 
  • trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh

    r457 r544  
    2828 
    2929if ( $DEBUG_debug ) ; then 
    30     if [ -f stack ] ; 
    31     then 
    32         echo "Stack of an libIGCM job :" >> stack 
    33     else 
    34         echo "Stack of an libIGCM job :" >  stack 
    35     fi 
     30  if [ -f stack ] ; 
     31  then 
     32    echo "Stack of an libIGCM job :" >> stack 
     33  else 
     34    echo "Stack of an libIGCM job :" >  stack 
     35  fi 
    3636fi 
    3737 
     
    6868#D- 
    6969function IGCM_debug_CallStack { 
    70     echo 
    71     echo "!!!!!!!!!!!!!!!!!!!!!!!!!!" 
    72     echo "!! IGCM_debug_CallStack !!" 
     70  echo 
     71  echo "!!!!!!!!!!!!!!!!!!!!!!!!!!" 
     72  echo "!! IGCM_debug_CallStack !!" 
     73  echo "!------------------------!" 
     74  echo 
     75  if ( $DEBUG_debug ) ; then 
     76    # La pile d'appels est affichée de la plus vieille à la plus récente  
     77    # (c'est donc l'inverse de la norme d'affichage). 
     78    typeset i decal 
     79    (( i=0 )) 
     80    until [ $i -eq ${IGCM_debug_LenStack} ]; do 
     81      decal=0 
     82      until [ $decal -eq ${i} ]; do 
     83        printf -- ' ' 
     84        let $(( decal=decal+1 )) 
     85      done 
     86      echo "$i - ${IGCM_debug_Stack[$(( $IGCM_debug_LenStack-$i-1 ))]}"\ 
     87                "(${IGCM_debug_StackArgs[$(( $IGCM_debug_LenStack-$i-1 ))]})" 
     88      let $((i=i+1)) 
     89    done 
    7390    echo "!------------------------!" 
    74     echo 
    75     if ( $DEBUG_debug ) ; then 
    76        # La pile d'appels est affichée de la plus vieille à la plus récente  
    77        # (c'est donc l'inverse de la norme d'affichage). 
    78         typeset i decal 
    79         (( i=0 )) 
    80         until [ $i -eq ${IGCM_debug_LenStack} ]; do 
    81             decal=0 
    82             until [ $decal -eq ${i} ]; do 
    83                 printf -- ' ' 
    84                 let $(( decal=decal+1 )) 
    85             done 
    86             echo "$i - ${IGCM_debug_Stack[$(( $IGCM_debug_LenStack-$i-1 ))]}"\ 
    87                 "(${IGCM_debug_StackArgs[$(( $IGCM_debug_LenStack-$i-1 ))]})" 
    88             let $((i=i+1)) 
    89         done 
    90         echo "!------------------------!" 
    91     fi 
     91  fi 
    9292} 
    9393 
     
    9797#D- 
    9898function IGCM_debug_PushStack { 
    99     if ( $DEBUG_debug ) ; then 
    100        typeset decal 
    101        echo >> stack 
    102        decal=0 
    103        while [ $decal -lt ${IGCM_debug_LenStack} ]; do 
     99  if ( $DEBUG_debug ) ; then 
     100    typeset decal 
     101    echo >> stack 
     102    decal=0 
     103    while [ $decal -lt ${IGCM_debug_LenStack} ]; do 
    104104#          printf -- ' ' >> stack 
    105            printf ' ' >> stack 
    106            let $(( decal=decal+1 )) 
    107        done 
    108        echo "> ${IGCM_debug_LenStack} : ${@}" >> stack 
    109  
    110        # We add function call name on beginning of the stack 
    111        set +A IGCM_debug_Stack -- ${1} ${IGCM_debug_Stack[*]} 
    112  
    113        # We include the "null" Args in the beginning of the StackArgs 
    114        set +A IGCM_debug_StackArgs ${NULL_STR} ${IGCM_debug_StackArgs[*]}  
    115        # Then, we shift StackArgs tabular 
    116        if [ $# -gt 1 ]; then  
    117            shift;  
    118            IGCM_debug_StackArgs[0]=$(echo ${@} | sed -e "s/\ /,/g") >&2 
    119        fi 
    120        (( IGCM_debug_LenStack = IGCM_debug_LenStack + 1 )) 
    121  
    122        # If you want to print CallStack each time : 
    123        # IGCM_debug_CallStack 
    124     fi 
     105      printf ' ' >> stack 
     106      let $(( decal=decal+1 )) 
     107    done 
     108    echo "> ${IGCM_debug_LenStack} : ${@}" >> stack 
     109 
     110    # We add function call name on beginning of the stack 
     111    set +A IGCM_debug_Stack -- ${1} ${IGCM_debug_Stack[*]} 
     112 
     113    # We include the "null" Args in the beginning of the StackArgs 
     114    set +A IGCM_debug_StackArgs ${NULL_STR} ${IGCM_debug_StackArgs[*]}  
     115    # Then, we shift StackArgs tabular 
     116    if [ $# -gt 1 ]; then  
     117      shift;  
     118      IGCM_debug_StackArgs[0]=$(echo ${@} | sed -e "s/\ /,/g") >&2 
     119    fi 
     120    (( IGCM_debug_LenStack = IGCM_debug_LenStack + 1 )) 
     121 
     122    # If you want to print CallStack each time : 
     123    # IGCM_debug_CallStack 
     124  fi 
    125125} 
    126126 
     
    130130#D- 
    131131function IGCM_debug_PopStack { 
    132     if ( $DEBUG_debug ) ; then 
    133         if ( ${ExitFlag} ) ; then 
    134             echo '!!! ExitFlag has been activated !!!' >> stack 
    135         fi 
    136         if [ "${IGCM_debug_Stack[0]}" = "${1}" ]; then 
    137             let $(( IGCM_debug_LenStack = IGCM_debug_LenStack - 1 )) 
    138  
    139             IGCM_debug_Stack[0]=""  
    140             IGCM_debug_StackArgs[0]="" 
    141              
    142             set +A tmpStack -- ${IGCM_debug_Stack[*]} 
    143             unset IGCM_debug_Stack 
    144             set +A IGCM_debug_Stack -- ${tmpStack[*]}  
    145  
    146             set +A tmpStack -- ${IGCM_debug_StackArgs[*]} 
    147             unset IGCM_debug_StackArgs 
    148             set +A IGCM_debug_StackArgs -- ${tmpStack[*]} 
    149             unset tmpStack 
    150         else 
    151             echo 'IGCM_debug_Exit : stack is corrupted ! LenStack =' ${IGCM_debug_LenStack} 
    152             IGCM_debug_Exit $@ 
    153         fi 
    154         typeset decal=0 
    155         while [ $decal -lt ${IGCM_debug_LenStack} ]; do 
    156           # printf -- ' ' >> stack 
    157           printf ' ' >> stack 
    158           (( decal=decal+1 )) 
    159         done 
    160       echo "< ${IGCM_debug_LenStack} : ${@}" >> stack 
    161  
    162       if [ ${IGCM_debug_LenStack} = 0 ]; then 
    163           # Reset array only when necessary 
    164           #echo 
    165           #IGCM_debug_Print 3 "Clean stack array" 
    166           #echo 
    167           #set -A IGCM_debug_Stack ${NULL_STR} 
    168           #set -A IGCM_debug_StackArgs ${NULL_STR} 
    169           unset IGCM_debug_Stack 
    170           unset IGCM_debug_StackArgs 
    171           IGCM_debug_Stack[0]=${NULL_STR} 
    172           IGCM_debug_StackArgs[0]=${NULL_STR} 
    173       fi 
    174  
    175     fi 
    176  
    177     #IGCM_debug_CallStack 
     132  if ( $DEBUG_debug ) ; then 
     133    if ( ${ExitFlag} ) ; then 
     134      echo '!!! ExitFlag has been activated !!!' >> stack 
     135    fi 
     136    if [ "${IGCM_debug_Stack[0]}" = "${1}" ]; then 
     137      let $(( IGCM_debug_LenStack = IGCM_debug_LenStack - 1 )) 
     138 
     139      IGCM_debug_Stack[0]=""  
     140      IGCM_debug_StackArgs[0]="" 
     141       
     142      set +A tmpStack -- ${IGCM_debug_Stack[*]} 
     143      unset IGCM_debug_Stack 
     144      set +A IGCM_debug_Stack -- ${tmpStack[*]}  
     145 
     146      set +A tmpStack -- ${IGCM_debug_StackArgs[*]} 
     147      unset IGCM_debug_StackArgs 
     148      set +A IGCM_debug_StackArgs -- ${tmpStack[*]} 
     149      unset tmpStack 
     150    else 
     151      echo 'IGCM_debug_Exit : stack is corrupted ! LenStack =' ${IGCM_debug_LenStack} 
     152      IGCM_debug_Exit $@ 
     153    fi 
     154    typeset decal=0 
     155    while [ $decal -lt ${IGCM_debug_LenStack} ]; do 
     156      # printf -- ' ' >> stack 
     157      printf ' ' >> stack 
     158      (( decal=decal+1 )) 
     159    done 
     160    echo "< ${IGCM_debug_LenStack} : ${@}" >> stack 
     161 
     162    if [ ${IGCM_debug_LenStack} = 0 ]; then 
     163      # Reset array only when necessary 
     164      #echo 
     165      #IGCM_debug_Print 3 "Clean stack array" 
     166      #echo 
     167      #set -A IGCM_debug_Stack ${NULL_STR} 
     168      #set -A IGCM_debug_StackArgs ${NULL_STR} 
     169      unset IGCM_debug_Stack 
     170      unset IGCM_debug_StackArgs 
     171      IGCM_debug_Stack[0]=${NULL_STR} 
     172      IGCM_debug_StackArgs[0]=${NULL_STR} 
     173    fi 
     174 
     175  fi 
     176  #IGCM_debug_CallStack 
    178177} 
    179178 
     
    183182#D- 
    184183function IGCM_debug_Exit { 
    185     IGCM_debug_PushStack "IGCM_debug_Exit" 
    186     echo "IGCM_debug_Exit : " "${@}" 
    187     IGCM_debug_CallStack 
    188     ExitFlag=true 
    189     IGCM_debug_PopStack "IGCM_debug_Exit" 
     184  IGCM_debug_PushStack "IGCM_debug_Exit" 
     185  echo "IGCM_debug_Exit : " "${@}" 
     186  IGCM_debug_CallStack 
     187  ExitFlag=true 
     188  IGCM_debug_PopStack "IGCM_debug_Exit" 
    190189} 
    191190 
     
    195194#D- 
    196195function IGCM_debug_Verif_Exit { 
    197     if ( ${ExitFlag} ) ; then 
    198         # Plan to send an email here with IGCM_sys_SendMail 
    199         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Fatal" 
    200         echo "IGCM_debug_Verif_Exit : Something wrong append." 
    201         echo "                        EXIT THE JOB." 
    202         echo 
    203         if ( $DEBUG_debug ) ; then 
    204             IGCM_sys_Cp stack ${SUBMIT_DIR}/stack_error 
    205             echo "Your files on ${R_OUT} :" 
    206             IGCM_sys_Tree ${R_SAVE} 
    207             echo 
    208         fi 
    209         # Mail notification 
    210         IGCM_sys_SendMail 
    211         # And Good Bye 
    212         date 
    213         exit 1 
    214     fi 
     196  if ( ${ExitFlag} ) ; then 
     197    # Plan to send an email here with IGCM_sys_SendMail 
     198    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Fatal" 
     199    echo "IGCM_debug_Verif_Exit : Something wrong append." 
     200    echo "                        EXIT THE JOB." 
     201    echo 
     202    if ( $DEBUG_debug ) ; then 
     203      IGCM_sys_Cp stack ${SUBMIT_DIR}/stack_error 
     204      echo "Your files on ${R_OUT} :" 
     205      IGCM_sys_Tree ${R_SAVE} 
     206      echo 
     207    fi 
     208    # Mail notification 
     209    IGCM_sys_SendMail 
     210    # And Good Bye 
     211    date 
     212    exit 1 
     213  fi 
    215214} 
    216215 
     
    220219#D- 
    221220function IGCM_debug_Verif_Exit_Post { 
    222     if ( ${ExitFlag} ) ; then 
    223         echo "IGCM_debug_Verif_Exit_Post : Something wrong append." 
    224         # If SpaceName is PROD then we stop if post_processing fails 
    225         # Plan to send an email here with IGCM_sys_SendMail 
    226         if ( [ X${config_UserChoices_SpaceName} = XPROD ] && [ X${JobType} = XRUN ] ) ; then 
    227             echo "                        EXIT THE JOB." 
    228             echo 
    229             if ( $DEBUG_debug ) ; then 
    230                 IGCM_sys_Cp stack ${SUBMIT_DIR}/stack_error 
    231                 echo 
    232             fi 
    233             # Mail notification 
    234             #IGCM_sys_SendMailPost 
    235             # And Good Bye 
    236             date 
    237             exit 1 
    238         else 
    239             echo "Either inside config.card the variable SpaceName is not in PROD" 
    240             echo "or insinde the main Job the variable JobType is not in RUN mode" 
    241             echo "              SO WE DO NOT EXIT THE JOB." 
    242             echo 
    243             date 
    244         fi 
    245     fi 
     221  if ( ${ExitFlag} ) ; then 
     222    echo "IGCM_debug_Verif_Exit_Post : Something wrong append." 
     223    # If SpaceName is PROD then we stop if post_processing fails 
     224    # Plan to send an email here with IGCM_sys_SendMail 
     225    if ( [ X${config_UserChoices_SpaceName} = XPROD ] && [ X${JobType} = XRUN ] ) ; then 
     226      echo "                        EXIT THE JOB." 
     227      echo 
     228      if ( $DEBUG_debug ) ; then 
     229        IGCM_sys_Cp stack ${SUBMIT_DIR}/stack_error 
     230        echo 
     231      fi 
     232      # Mail notification 
     233      #IGCM_sys_SendMailPost 
     234      # And Good Bye 
     235      date 
     236      exit 1 
     237    else 
     238      echo "Either inside config.card the variable SpaceName is not in PROD" 
     239      echo "or insinde the main Job the variable JobType is not in RUN mode" 
     240      echo "              SO WE DO NOT EXIT THE JOB." 
     241      echo 
     242      date 
     243    fi 
     244  fi 
    246245} 
    247246 
     
    252251function IGCM_debug_Print 
    253252{ 
    254     typeset level=$1 
     253  typeset level=$1 
     254  shift 
     255 
     256  if [ X"${1}" = X"-e" ]; then 
     257    typeset cmd_echo="echo -e" 
    255258    shift 
    256  
    257     if [ X"${1}" = X"-e" ]; then 
    258         typeset cmd_echo="echo -e" 
    259         shift 
    260     else 
    261         typeset cmd_echo="echo" 
    262     fi 
    263  
    264     if [ ${level} -le ${Verbosity} ] ; then 
    265         typeset i 
    266         case "${level}" in 
    267             1) for i in "$@" ; do 
    268                     ${cmd_echo} "--Debug1-->" ${i} 
    269               done ;;  
    270             2) for i in "$@" ; do 
    271                     ${cmd_echo} "--------Debug2-->" ${i} 
    272               done ;;  
    273             3) for i in "$@" ; do 
    274                     ${cmd_echo} "--------------Debug3-->" ${i} 
    275               done ;;  
    276         esac 
    277     fi 
     259  else 
     260    typeset cmd_echo="echo" 
     261  fi 
     262 
     263  if [ ${level} -le ${Verbosity} ] ; then 
     264    typeset i 
     265    case "${level}" in 
     266    1) for i in "$@" ; do 
     267      ${cmd_echo} "--Debug1-->" ${i} 
     268      done ;;  
     269    2) for i in "$@" ; do 
     270      ${cmd_echo} "--------Debug2-->" ${i} 
     271      done ;;  
     272    3) for i in "$@" ; do 
     273      ${cmd_echo} "--------------Debug3-->" ${i} 
     274      done ;;  
     275    esac 
     276  fi 
    278277} 
    279278 
     
    284283function IGCM_debug_PrintVariables 
    285284{ 
    286     typeset level=$1 
    287     shift 
    288  
    289     list=$( set | grep $1 | sed -e "s/'//g" ) 
    290  
    291     if [ "X${list}" != X ]  ; then 
    292         IGCM_debug_Print ${level} ${list} 
    293     fi 
     285  typeset level=$1 
     286  shift 
     287 
     288  list=$( set | grep $1 | sed -e "s/'//g" ) 
     289 
     290  if [ "X${list}" != X ]  ; then 
     291    IGCM_debug_Print ${level} ${list} 
     292  fi 
    294293} 
    295294 
     
    299298function IGCM_debug_Check 
    300299{ 
    301     #--------------------- 
    302     if [ ! -n "${libIGCM}" ] ; then 
    303         echo "Check libIGCM_debug ..........................................[ FAILED ]" 
    304         echo "--Error--> libIGCM variable is not defined" 
    305         exit 2 
    306     fi 
    307  
    308     #--------------------- 
    309     if [ ! -n "${Verbosity}" ] ; then 
    310         echo "Check libIGCM_debug ..........................................[ FAILED ]" 
    311         echo "--Error--> Verbosity variable is not defined" 
    312         exit 3 
    313     fi 
    314  
    315     #--------------------- 
    316     ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ksh > IGCM_debug_Test.ref.failed 2>&1 
    317     sleep 2 
    318  
    319     if diff IGCM_debug_Test.ref.failed ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ref > /dev/null 2>&1 ; then 
    320         echo "Check libIGCM_debug ..............................................[ OK ]" 
    321         rm -f IGCM_debug_Test.ref.failed 
    322     else 
    323         echo "Check libIGCM_debug ..........................................[ FAILED ]" 
    324         echo "--Error--> Execution of ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ksh" 
    325         echo "           has produced the file IGCM_debug_Test.ref.failed" 
    326         echo "           Please analyse differences with the reference file by typing:" 
    327         echo "           diff IGCM_debug_Test.ref.failed ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ref" 
    328         echo "           Report errors to the author: Patrick.Brockmann@cea.fr" 
    329         exit 4 
    330     fi 
    331     #--------------------- 
    332 } 
     300  #--------------------- 
     301  if [ ! -n "${libIGCM}" ] ; then 
     302    echo "Check libIGCM_debug ..........................................[ FAILED ]" 
     303    echo "--Error--> libIGCM variable is not defined" 
     304    exit 2 
     305  fi 
     306 
     307  #--------------------- 
     308  if [ ! -n "${Verbosity}" ] ; then 
     309    echo "Check libIGCM_debug ..........................................[ FAILED ]" 
     310    echo "--Error--> Verbosity variable is not defined" 
     311    exit 3 
     312  fi 
     313 
     314  #--------------------- 
     315  ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ksh > IGCM_debug_Test.ref.failed 2>&1 
     316  sleep 2 
     317 
     318  if diff IGCM_debug_Test.ref.failed ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ref > /dev/null 2>&1 ; then 
     319    echo "Check libIGCM_debug ..............................................[ OK ]" 
     320    rm -f IGCM_debug_Test.ref.failed 
     321  else 
     322    echo "Check libIGCM_debug ..........................................[ FAILED ]" 
     323    echo "--Error--> Execution of ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ksh" 
     324    echo "           has produced the file IGCM_debug_Test.ref.failed" 
     325    echo "           Please analyse differences with the reference file by typing:" 
     326    echo "           diff IGCM_debug_Test.ref.failed ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ref" 
     327    echo "           Report errors to the author: Patrick.Brockmann@cea.fr" 
     328    exit 4 
     329  fi 
     330  #--------------------- 
     331} 
  • trunk/libIGCM/libIGCM_post/libIGCM_post.ksh

    r457 r544  
    1616function IGCM_post_Configure 
    1717{ 
    18     IGCM_debug_PushStack "IGCM_post_Configure" 
    19  
    20     # Debug Print : 
    21     echo 
    22     IGCM_debug_Print 1 "IGCM_post_Configure" 
    23     # 
    24     # Initialize 
    25     # 
    26     POST=false 
    27     RebuildFrequency=false 
    28     TimeSeriesFrequency=false 
    29     SeasonalFrequency=false 
    30     # 
    31     # ONLY IF SOMETHING NEEDS TO BE DONE (EATHER TIME SERIES OR SEASONAL) COMPUTE THE MODULOS 
    32     # 
    33     if [ X${AsynchronousRebuild} = Xtrue ] ; then 
    34         list_post="RebuildFrequency" 
     18  IGCM_debug_PushStack "IGCM_post_Configure" 
     19 
     20  # Debug Print : 
     21  echo 
     22  IGCM_debug_Print 1 "IGCM_post_Configure" 
     23  # 
     24  # Initialize 
     25  # 
     26  POST=false 
     27  RebuildFrequency=false 
     28  TimeSeriesFrequency=false 
     29  SeasonalFrequency=false 
     30  # 
     31  # ONLY IF SOMETHING NEEDS TO BE DONE (EATHER TIME SERIES OR SEASONAL) COMPUTE THE MODULOS 
     32  # 
     33  if [ X${AsynchronousRebuild} = Xtrue ] ; then 
     34    list_post="RebuildFrequency" 
     35  fi 
     36  # 
     37  if ( [ X${TimeSeries} = Xtrue ] || [ X${TimeSeries2D} = Xtrue ] || [ X${TimeSeries3D} = Xtrue ] ) ; then 
     38    list_post="${list_post} TimeSeriesFrequency" 
     39  fi 
     40  # 
     41  if [ X${Seasonal} = Xtrue ] ; then 
     42    list_post="${list_post} SeasonalFrequency" 
     43  fi 
     44 
     45  # Overrule special cases 
     46  if ( [ ! X${config_Post_TimeSeriesFrequency} = X${NULL_STR} ] && \ 
     47    [ ! X${config_Post_TimeSeriesFrequency} = XNONE ]        && \ 
     48    [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then 
     49    TimeSeriesFrequency=true 
     50    POST=true 
     51  fi 
     52  # 
     53  if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && \ 
     54    [ ! X${config_Post_RebuildFrequency} = XNONE ]        && \ 
     55    [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then 
     56    RebuildFrequency=true 
     57    POST=true 
     58  fi 
     59 
     60  # READ REBUILD OR TIME SERIES OR SEASONAL FREQUENCY 
     61  # AND TURN ON THE SUBMISSION FLAG WHEN MODULO IS ZERO 
     62  for post_freq in ${list_post} ; do 
     63    # Extract frequency from previously defined variable 
     64    config_Post_post_freq=$( eval echo \${config_Post_${post_freq}} ) 
     65    # Offset for Seasonal Average starting period 
     66    if [ ${post_freq} = SeasonalFrequency ] ; then 
     67      if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then 
     68        PeriodOffset=0 
     69      else 
     70        PeriodOffset=${config_Post_SeasonalFrequencyOffset} 
     71      fi 
     72    else 
     73      PeriodOffset=0 
    3574    fi 
    36     # 
    37     if ( [ X${TimeSeries} = Xtrue ] || [ X${TimeSeries2D} = Xtrue ] || [ X${TimeSeries3D} = Xtrue ] ) ; then 
    38         list_post="${list_post} TimeSeriesFrequency" 
     75    # Compute Modulo between frequencys (/!\second argument will be multiplied by CumuPeriod/!\) 
     76    # RebuildFrequency needs additionnal information 
     77    if [ ${post_freq} = RebuildFrequency ] ; then 
     78      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength NbRebuildDir 
     79    else 
     80      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength 
    3981    fi 
    4082    # 
    41     if [ X${Seasonal} = Xtrue ] ; then 
    42         list_post="${list_post} SeasonalFrequency" 
    43     fi 
    44  
    45     # Overrule special cases 
    46     if ( [ ! X${config_Post_TimeSeriesFrequency} = X${NULL_STR} ] && \ 
    47          [ ! X${config_Post_TimeSeriesFrequency} = XNONE ]        && \ 
    48          [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then 
    49         TimeSeriesFrequency=true 
    50         POST=true 
    51     fi 
    52     # 
    53     if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && \ 
    54          [ ! X${config_Post_RebuildFrequency} = XNONE ]        && \ 
    55          [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then 
    56         RebuildFrequency=true 
    57         POST=true 
    58     fi 
    59  
    60     # READ REBUILD OR TIME SERIES OR SEASONAL FREQUENCY 
    61     # AND TURN ON THE SUBMISSION FLAG WHEN MODULO IS ZERO 
    62     for post_freq in ${list_post} ; do 
    63         # Extract frequency from previously defined variable 
    64         config_Post_post_freq=$( eval echo \${config_Post_${post_freq}} ) 
    65         # Offset for Seasonal Average starting period 
    66         if [ ${post_freq} = SeasonalFrequency ] ; then 
    67             if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then 
    68                 PeriodOffset=0 
    69             else 
    70                 PeriodOffset=${config_Post_SeasonalFrequencyOffset} 
    71             fi 
    72         else 
    73             PeriodOffset=0 
    74         fi 
    75         # Compute Modulo between frequencys (/!\second argument will be multiplied by CumuPeriod/!\) 
    76         # RebuildFrequency needs additionnal information 
    77         if [ ${post_freq} = RebuildFrequency ] ; then 
    78             IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength NbRebuildDir 
    79         else 
    80             IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength 
    81         fi 
    82         # 
    83         IGCM_debug_Print 1 "${post_freq} flag value : ${RebuildFrequency}" 
    84     done 
    85     # 
    86     IGCM_debug_Print 2 "POST-TREATEMENT flag value : ${POST}" 
    87     # 
    88     IGCM_debug_PopStack "IGCM_post_Configure" 
     83    IGCM_debug_Print 1 "${post_freq} flag value : ${RebuildFrequency}" 
     84  done 
     85  # 
     86  IGCM_debug_Print 2 "POST-TREATEMENT flag value : ${POST}" 
     87  # 
     88  IGCM_debug_PopStack "IGCM_post_Configure" 
    8989} 
    9090 
    9191function IGCM_post_Submit 
    9292{ 
    93     IGCM_debug_PushStack "IGCM_post_Submit" 
    94  
    95     typeset listVarEnv 
    96  
    97     POST_DIR=${R_OUT_POST}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    98  
    99     if [ ${POST} = true ]; then 
     93  IGCM_debug_PushStack "IGCM_post_Submit" 
     94 
     95  typeset listVarEnv 
     96 
     97  POST_DIR=${R_OUT_POST}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     98 
     99  if [ ${POST} = true ]; then 
     100    echo 
     101    IGCM_debug_Print 1 "IGCM_post_Submit" 
     102    echo 
     103    IGCM_debug_Print 2 "POST_DIR = ${POST_DIR}" 
     104  fi 
     105 
     106  #============ TIME SERIES POST-TREATMENT ===========# 
     107  if [ ${TimeSeriesFrequency} = true ] ; then 
     108 
     109    IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ACTIVATED" 
     110    echo 
     111 
     112 
     113 
     114    # Get information from last execution 
     115    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted 
     116    CompletedFlag=${run_PostProcessing_TimeSeriesCompleted} 
     117    # 
     118 
     119 
     120 
     121    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,CompletedFlag,TsTask,CompToRead,FlagToRead,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG" 
     122    # 
     123    jLoop=${#ListDimension[*]} 
     124    j=0 
     125    until [ $j -ge ${jLoop} ]; do 
     126      Dimension=${ListDimension[${j}]} 
     127      # 
     128      if [ X$( eval echo \${TimeSeries${Dimension}} ) = Xtrue ] ; then 
     129        # 
     130        IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED" 
    100131        echo 
    101         IGCM_debug_Print 1 "IGCM_post_Submit" 
    102         echo 
    103         IGCM_debug_Print 2 "POST_DIR = ${POST_DIR}" 
    104     fi 
    105  
    106     #============ TIME SERIES POST-TREATMENT ===========# 
    107     if [ ${TimeSeriesFrequency} = true ] ; then 
    108  
    109         IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ACTIVATED" 
    110         echo 
    111  
    112  
    113  
    114         # Get information from last execution 
    115         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted 
    116         CompletedFlag=${run_PostProcessing_TimeSeriesCompleted} 
    117132        # 
    118  
    119  
    120  
    121         listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,CompletedFlag,TsTask,CompToRead,FlagToRead,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG" 
     133        if [ X${Dimension} = X ] ; then 
     134          TsTask="empty" 
     135          Script_Post_Output=create_ts.${PeriodDateEnd} 
     136        else 
     137          TsTask=${Dimension} 
     138          Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask} 
     139        fi 
    122140        # 
    123         jLoop=${#ListDimension[*]} 
    124         j=0 
    125         until [ $j -ge ${jLoop} ]; do 
    126             Dimension=${ListDimension[${j}]} 
    127             # 
    128             if [ X$( eval echo \${TimeSeries${Dimension}} ) = Xtrue ] ; then 
    129                 # 
    130                 IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED" 
    131                 echo 
    132                 # 
    133                 if [ X${Dimension} = X ] ; then 
    134                     TsTask="empty" 
    135                     Script_Post_Output=create_ts.${PeriodDateEnd} 
    136                 else 
    137                     TsTask=${Dimension} 
    138                     Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask} 
    139                 fi 
    140                 # 
    141                 if [ ${RebuildFrequency} = true ] ; then 
    142                     # 
    143                     if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
    144                         if [ X${MASTER} = Xtitane ] ; then 
    145                             echo "IGCM_sys_RshPost <<-EOF"                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    146                         fi 
    147                         echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    148                         echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    149                         echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    150                         echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    151                         echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    152                         echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    153                         echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    154                         echo "export RebuildFrequency=${RebuildFrequency}    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    155                         echo "export DateBegin=${DateBegin}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    156                         echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    157                         echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    158                         echo "export CompletedFlag=${CompletedFlag}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    159                         echo "export TsTask=${TsTask}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    160                         echo "unset  CompToRead                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    161                         echo "unset  FlagToRead                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    162                         echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    163                         echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    164                         echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    165                         echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    166                         echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    167                         echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    168                         echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    169                         echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    170                         if [ X${MASTER} = Xtitane ] ; then 
    171                             echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    172                             echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    173                         fi 
    174                         echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    175                         echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    176                         echo "IGCM_sys_QsubPost create_ts                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    177                         if [ X${MASTER} = Xtitane ] ; then 
    178                             echo "EOF"                                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    179                         fi 
    180                     fi 
    181                     # 
    182                 else 
    183                     # 
    184                     IGCM_sys_RshPost <<-EOF 
     141        if [ ${RebuildFrequency} = true ] ; then 
     142          # 
     143          if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
     144#           if [ X${MASTER} = Xtitane ] ; then 
     145#             echo "IGCM_sys_RshPost <<-EOF"                       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     146#           fi 
     147            echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     148            echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     149            echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     150            echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     151            echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     152            echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     153            echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     154            echo "export RebuildFrequency=${RebuildFrequency}    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     155            echo "export DateBegin=${DateBegin}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     156            echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     157            echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     158            echo "export CompletedFlag=${CompletedFlag}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     159            echo "export TsTask=${TsTask}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     160            echo "unset  CompToRead                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     161            echo "unset  FlagToRead                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     162            echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     163            echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     164            echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     165            echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     166            echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     167            echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     168            echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     169            echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     170#           if [ X${MASTER} = Xtitane ] ; then 
     171#             echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     172#             echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     173#           fi 
     174            echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     175            echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     176            echo "IGCM_sys_QsubPost create_ts                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     177#           if [ X${MASTER} = Xtitane ] ; then 
     178#             echo "EOF"                                           >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     179#           fi 
     180          fi 
     181        else 
     182          IGCM_sys_RshPost <<-EOF 
    185183                    export DEBUG_debug=${DEBUG_debug} 
    186184                    export MODIPSL=${MODIPSL} 
     
    212210                    IGCM_sys_QsubPost create_ts 
    213211EOF 
    214                 fi 
     212        fi 
     213      fi 
     214      # 
     215      if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then 
     216        # 
     217        IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} WITH CHUNCK ACTIVATED" 
     218        echo 
     219        # Need to Remember This One 
     220        SavedDateBegin=${DateBegin} 
     221        # Kind of task create_ts will perform 
     222        TsTask=Chunck${Dimension} 
     223        # Number of chunck jobs to configure and submit 
     224        eval NbJob=\${#CHUNCK${Dimension}_COMP[@]} 
     225        typeset i 
     226        i=0 
     227        until [ $i -ge $NbJob ]; do 
     228          CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} ) 
     229          FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} ) 
     230          NameToRead=$( eval echo \${CHUNCK${Dimension}_NAME[\${i}]} ) 
     231          ChunckSize=$( eval echo \${CHUNCK${Dimension}_SIZE[\${i}]} ) 
     232          # Chunck Length (mandatory in Year) 
     233          YearsChunckLength=$( echo ${ChunckSize} | sed -e "s/[yY]//" ) 
     234          # 
     235          IGCM_date_GetYearMonth ${DateBegin}     YearBegin MonthBegin 
     236          # 
     237          IGCM_date_GetYearMonth ${PeriodDateEnd} YearEnd   MonthEnd 
     238          # How many chunck in total since simulation began 
     239          NbYearsChunckLoop=$(( ( ${YearEnd} - ${YearBegin} + 1 ) / ${YearsChunckLength} )) 
     240          #  Tweak special case 
     241          [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 )) 
     242          # Starting Year of the current chunck 
     243          ChunckTsYearBegin=$(( ${NbYearsChunckLoop} *  ${YearsChunckLength} + ${YearBegin} )) 
     244          # Starting date of the current chunck 
     245          ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01 
     246          # 
     247          Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}.${CompToRead}.${NameToRead} 
     248          # 
     249          if [ ${RebuildFrequency} = true ] ; then 
     250            # 
     251            if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
     252#             if [ X${MASTER} = Xtitane ] ; then 
     253#               echo "IGCM_sys_RshPost <<-EOF"                       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     254#             fi 
     255              echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     256              echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     257              echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     258              echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     259              echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     260              echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     261              echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     262              echo "export RebuildFrequency=${RebuildFrequency}    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     263              echo "export DateBegin=${ChunckTsDateBegin}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     264              echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     265              echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     266              echo "export CompletedFlag=${CompletedFlag}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     267              echo "export TsTask=${TsTask}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     268              echo "export CompToRead=${CompToRead}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     269              echo "export FlagToRead=${FlagToRead}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     270              echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     271              echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     272              echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     273              echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     274              echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     275              echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     276              echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     277              echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     278#             if [ X${MASTER} = Xtitane ] ; then 
     279#               echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     280#               echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     281#             fi 
     282              echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     283              echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     284              echo "IGCM_sys_QsubPost create_ts                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     285#             if [ X${MASTER} = Xtitane ] ; then 
     286#               echo "EOF"                                           >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     287#             fi 
    215288            fi 
    216             # 
    217             if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then 
    218                 # 
    219                 IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} WITH CHUNCK ACTIVATED" 
    220                 echo 
    221                 # Need to Remember This One 
    222                 SavedDateBegin=${DateBegin} 
    223                 # Kind of task create_ts will perform 
    224                 TsTask=Chunck${Dimension} 
    225                 # Number of chunck jobs to configure and submit 
    226                 eval NbJob=\${#CHUNCK${Dimension}_COMP[@]} 
    227                 typeset i 
    228                 i=0 
    229                 until [ $i -ge $NbJob ]; do 
    230                     CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} ) 
    231                     FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} ) 
    232                     NameToRead=$( eval echo \${CHUNCK${Dimension}_NAME[\${i}]} ) 
    233                     ChunckSize=$( eval echo \${CHUNCK${Dimension}_SIZE[\${i}]} ) 
    234                     # Chunck Length (mandatory in Year) 
    235                     YearsChunckLength=$( echo ${ChunckSize} | sed -e "s/[yY]//" ) 
    236                     # 
    237                     IGCM_date_GetYearMonth ${DateBegin}     YearBegin MonthBegin 
    238                     # 
    239                     IGCM_date_GetYearMonth ${PeriodDateEnd} YearEnd   MonthEnd 
    240                     # How many chunck in total since simulation began 
    241                     NbYearsChunckLoop=$(( ( ${YearEnd} - ${YearBegin} + 1 ) / ${YearsChunckLength} )) 
    242                     #  Tweak special case 
    243                     [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 )) 
    244                     # Starting Year of the current chunck 
    245                     ChunckTsYearBegin=$(( ${NbYearsChunckLoop} *  ${YearsChunckLength} + ${YearBegin} )) 
    246                     # Starting date of the current chunck 
    247                     ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01 
    248                     # 
    249                     Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}.${CompToRead}.${NameToRead} 
    250                     # 
    251                     if [ ${RebuildFrequency} = true ] ; then 
    252                         # 
    253                         if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
    254                             if [ X${MASTER} = Xtitane ] ; then 
    255                                 echo "IGCM_sys_RshPost <<-EOF"                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    256                             fi 
    257                             echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    258                             echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    259                             echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    260                             echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    261                             echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    262                             echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    263                             echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    264                             echo "export RebuildFrequency=${RebuildFrequency}    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    265                             echo "export DateBegin=${ChunckTsDateBegin}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    266                             echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    267                             echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    268                             echo "export CompletedFlag=${CompletedFlag}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    269                             echo "export TsTask=${TsTask}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    270                             echo "export CompToRead=${CompToRead}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    271                             echo "export FlagToRead=${FlagToRead}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    272                             echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    273                             echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    274                             echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    275                             echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    276                             echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    277                             echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    278                             echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    279                             echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    280                             if [ X${MASTER} = Xtitane ] ; then 
    281                                 echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    282                                 echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    283                             fi 
    284                             echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    285                             echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    286                             echo "IGCM_sys_QsubPost create_ts                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    287                             if [ X${MASTER} = Xtitane ] ; then 
    288                                 echo "EOF"                                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    289                             fi 
    290                         fi 
    291                         # 
    292                     else 
    293                         # 
    294                         IGCM_sys_RshPost <<-EOF 
     289          else 
     290            IGCM_sys_RshPost <<-EOF 
    295291                        export DEBUG_debug=${DEBUG_debug} 
    296292                        export MODIPSL=${MODIPSL} 
     
    322318                        IGCM_sys_QsubPost create_ts 
    323319EOF 
    324                         # 
    325                     fi 
    326                     # 
    327                     export DateBegin=${SavedDateBegin} 
    328                     # 
    329                     (( i=i+1 )) 
    330                     # 
    331                 done 
    332             fi 
    333             (( j=j+1 )) 
     320          # 
     321          fi 
     322          # 
     323          export DateBegin=${SavedDateBegin} 
     324          # 
     325          (( i=i+1 )) 
     326          # 
    334327        done 
    335     fi 
    336  
    337     #=============  SEASONAL POST-TREATMENT ============# 
    338     if [ ${SeasonalFrequency} = true ] ; then 
    339         # 
    340         IGCM_debug_Print 1 "SEASONNAL POST-TREATMENT" 
    341         echo 
     328      fi 
     329      (( j=j+1 )) 
     330    done 
     331  fi 
     332 
     333  #=============  SEASONAL POST-TREATMENT ============# 
     334  if [ ${SeasonalFrequency} = true ] ; then 
     335    # 
     336    IGCM_debug_Print 1 "SEASONNAL POST-TREATMENT" 
     337    echo 
     338    # 
     339    Script_Post_Output=create_se.${PeriodDateEnd} 
     340    # 
     341    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG" 
     342 
     343    if [ ${RebuildFrequency} = true ] ; then 
     344      # 
     345      if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
    342346        # 
    343         Script_Post_Output=create_se.${PeriodDateEnd} 
    344         # 
    345         listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG" 
    346  
    347         if [ ${RebuildFrequency} = true ] ; then 
    348             # 
    349             if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
    350                 # 
    351                 if [ X${MASTER} = Xtitane ] ; then 
    352                     echo "IGCM_sys_RshPost <<-EOF"                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    353                 fi 
    354                 echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    355                 echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    356                 echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    357                 echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    358                 echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    359                 echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    360                 echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    361                 echo "export RebuildFrequency=${RebuildFrequency}    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    362                 echo "export DateBegin=${DateBegin}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    363                 echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    364                 echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    365                 echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    366                 echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    367                 echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    368                 echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    369                 echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    370                 echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    371                 echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    372                 echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    373                 if [ X${MASTER} = Xtitane ] ; then 
    374                     echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    375                     echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    376                 fi 
    377                 echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    378                 echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    379                 echo "IGCM_sys_QsubPost create_se                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    380                 if [ X${MASTER} = Xtitane ] ; then 
    381                     echo "EOF"                                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    382                 fi 
    383                 # 
    384             fi 
    385         else 
    386             # 
    387             IGCM_sys_RshPost <<-EOF 
     347#       if [ X${MASTER} = Xtitane ] ; then 
     348#         echo "IGCM_sys_RshPost <<-EOF"                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     349#       fi 
     350        echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     351        echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     352        echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     353        echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     354        echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     355        echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     356        echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     357        echo "export RebuildFrequency=${RebuildFrequency}    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     358        echo "export DateBegin=${DateBegin}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     359        echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     360        echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     361        echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     362        echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     363        echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     364        echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     365        echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     366        echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     367        echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     368        echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     369#       if [ X${MASTER} = Xtitane ] ; then 
     370#         echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     371#         echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     372#       fi 
     373        echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     374        echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     375        echo "IGCM_sys_QsubPost create_se                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     376#       if [ X${MASTER} = Xtitane ] ; then 
     377#         echo "EOF"                                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     378#       fi 
     379      fi 
     380    else 
     381      IGCM_sys_RshPost <<-EOF 
    388382            export DEBUG_debug=${DEBUG_debug} 
    389383            export MODIPSL=${MODIPSL} 
     
    411405            IGCM_sys_QsubPost create_se 
    412406EOF 
    413         # 
    414         fi 
    415407    fi 
    416  
    417     #============== REBUILD POST-TREATMENT =============# 
    418     if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
    419         # ----------------------------------------------------------------------------------- 
    420         # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now 
    421         # ----------------------------------------------------------------------------------- 
    422         if [ ${DRYRUN} -le 1 ] ; then 
    423             echo "IGCM_debug_PopStack \"IGCM_FlushRebuild\" " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    424             echo "}                                         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    425         fi 
    426         if [ ${config_Post_RebuildFromArchive} = true ] ; then 
    427             IGCM_sys_Put_Dir REBUILD_${PeriodDateBegin} ${REBUILD_DIR} 
    428         else 
    429             IGCM_sys_Mv      REBUILD_${PeriodDateBegin} ${REBUILD_DIR} 
    430         fi 
     408  fi 
     409 
     410  #============== REBUILD POST-TREATMENT =============# 
     411  if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
     412    # ----------------------------------------------------------------------------------- 
     413    # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now 
     414    # ----------------------------------------------------------------------------------- 
     415    if [ ${DRYRUN} -le 1 ] ; then 
     416      echo "IGCM_debug_PopStack \"IGCM_FlushRebuild\" " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     417      echo "}                                         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
    431418    fi 
    432     # 
    433     if [ ${RebuildFrequency} = true ] ; then 
    434         if ( [ ${config_Post_RebuildFromArchive} = true ] ) ; then 
    435             IGCM_debug_Print 1 "REBUILD POST-TREATMENT FROM ARCHIVE" 
    436             echo 
    437             # 
    438             script=rebuild_fromArchive 
    439         else 
    440             IGCM_debug_Print 1 "REBUILD POST-TREATMENT FROM WORKDIR" 
    441             echo 
    442             # 
    443             script=rebuild_fromWorkdir 
    444         fi 
    445         # 
    446         Script_Post_Output=${script}.${PeriodDateEnd} 
    447         # 
    448         listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,POST_DIR,MASTER,RebuildFromArchive,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG" 
    449         IGCM_sys_RshPost <<-EOF 
    450         export DEBUG_debug=${DEBUG_debug} 
    451         export MODIPSL=${MODIPSL} 
    452         export libIGCM_SX=${libIGCM} 
    453         export libIGCM=${libIGCM_POST} 
    454         export SUBMIT_DIR=${SUBMIT_DIR} 
    455         export REBUILD_DIR=${REBUILD_DIR} 
    456         export POST_DIR=${POST_DIR} 
    457         export MASTER=${MASTER} 
    458         export RebuildFromArchive=${config_Post_RebuildFromArchive} 
    459         export DateBegin=${DateBegin} 
    460         export PeriodDateBegin=${PeriodDateBegin} 
    461         export PeriodDateEnd=${PeriodDateEnd} 
    462         export NbRebuildDir=${NbRebuildDir} 
    463         export StandAlone=false 
    464         export RESOL_ATM=${RESOL_ATM} 
    465         export RESOL_OCE=${RESOL_OCE} 
    466         export RESOL_ICE=${RESOL_ICE} 
    467         export RESOL_MBG=${RESOL_MBG} 
    468         export RESOL_SRF=${RESOL_SRF} 
    469         export RESOL_SBG=${RESOL_SBG} 
    470         export listVarEnv=${listVarEnv} 
    471         export Script_Post_Output=${Script_Post_Output} 
    472         . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh 
    473         . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh 
    474         IGCM_sys_MkdirWork ${POST_DIR} 
    475         IGCM_debug_Verif_Exit_Post 
    476         IGCM_sys_QsubPost ${script} 
     419    if [ ${config_Post_RebuildFromArchive} = true ] ; then 
     420      IGCM_sys_Put_Dir REBUILD_${PeriodDateBegin} ${REBUILD_DIR} 
     421    else 
     422      IGCM_sys_Mv      REBUILD_${PeriodDateBegin} ${REBUILD_DIR} 
     423    fi 
     424  fi 
     425  # 
     426  if [ ${RebuildFrequency} = true ] ; then 
     427    if ( [ ${config_Post_RebuildFromArchive} = true ] ) ; then 
     428      IGCM_debug_Print 1 "REBUILD POST-TREATMENT FROM ARCHIVE" 
     429      echo 
     430      # 
     431      script=rebuild_fromArchive 
     432    else 
     433      IGCM_debug_Print 1 "REBUILD POST-TREATMENT FROM WORKDIR" 
     434      echo 
     435      # 
     436      script=rebuild_fromWorkdir 
     437    fi 
     438    # 
     439    Script_Post_Output=${script}.${PeriodDateEnd} 
     440    # 
     441    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,POST_DIR,MASTER,RebuildFromArchive,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG" 
     442    IGCM_sys_RshPost <<-EOF 
     443    export DEBUG_debug=${DEBUG_debug} 
     444    export MODIPSL=${MODIPSL} 
     445    export libIGCM_SX=${libIGCM} 
     446    export libIGCM=${libIGCM_POST} 
     447    export SUBMIT_DIR=${SUBMIT_DIR} 
     448    export REBUILD_DIR=${REBUILD_DIR} 
     449    export POST_DIR=${POST_DIR} 
     450    export MASTER=${MASTER} 
     451    export RebuildFromArchive=${config_Post_RebuildFromArchive} 
     452    export DateBegin=${DateBegin} 
     453    export PeriodDateBegin=${PeriodDateBegin} 
     454    export PeriodDateEnd=${PeriodDateEnd} 
     455    export NbRebuildDir=${NbRebuildDir} 
     456    export StandAlone=false 
     457    export RESOL_ATM=${RESOL_ATM} 
     458    export RESOL_OCE=${RESOL_OCE} 
     459    export RESOL_ICE=${RESOL_ICE} 
     460    export RESOL_MBG=${RESOL_MBG} 
     461    export RESOL_SRF=${RESOL_SRF} 
     462    export RESOL_SBG=${RESOL_SBG} 
     463    export listVarEnv=${listVarEnv} 
     464    export Script_Post_Output=${Script_Post_Output} 
     465    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh 
     466    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh 
     467    IGCM_sys_MkdirWork ${POST_DIR} 
     468    IGCM_debug_Verif_Exit_Post 
     469    IGCM_sys_QsubPost ${script} 
    477470EOF 
    478  
    479     fi 
    480  
    481     IGCM_debug_PopStack "IGCM_post_Submit" 
     471  fi 
     472 
     473  IGCM_debug_PopStack "IGCM_post_Submit" 
    482474} 
    483475 
     
    485477function IGCM_post_CheckModuloFrequency 
    486478{ 
    487     IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $* 
    488  
    489     # Used by IGCM_config_Check 
    490     # from 2 libIGCM compatible frequency (*Y, *M, *D, *y, *m, *d) 
    491     # Issue an exit instruction IGCM_debug_Exit if there modulo is not zero 
    492     # Input parameter are the name of the variable, not the frequency value itself 
    493     # example 
    494     # IGCM_post_ModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength 
    495  
    496     typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay 
    497  
    498     # Get the name of the variable 
    499     MasterName=$1 
    500     SlaveName=$2 
    501     # Get the value the above name points to 
    502     MasterFrequency=$( eval echo \${${1}} ) 
    503     SlaveFrequency=$( eval echo \${${2}} ) 
    504  
    505     IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}" 
    506  
    507     case ${MasterFrequency} in 
    508         *y|*Y) 
    509             PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" ) 
    510             case ${SlaveFrequency} in 
    511                 *Y|*y) 
    512                     PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
    513                     if ( [ ${PeriodSlaveYear} -gt ${PeriodMasterYear} ] || \ 
    514                         [ $(( ${PeriodMasterYear} % ${PeriodSlaveYear} )) -ne 0 ] );  then 
    515                         IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
    516                         IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
    517                         IGCM_debug_Exit "Check your frequency" 
    518                     fi ;; 
    519                 *M|*m) 
    520                     PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
    521                     if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \ 
    522                         [ $(( ( ${PeriodMasterYear} * 12 ) % ${PeriodSlaveMonth} )) -ne 0 ] ) ; then 
    523                         IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
    524                         IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
    525                         IGCM_debug_Exit "Check your frequency" 
    526                     fi ;; 
    527                 *D|*d) 
    528                     PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
    529                     NbDays=$( IGCM_date_DaysInYear ${year} ) 
    530                     if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then 
    531                         if ( [ ${PeriodSlaveDay} -gt $(( ${PeriodMasterYear} * ${NbDays} )) ] || \ 
    532                             [ $(( ( ${PeriodMasterYear} * ${NbDays} ) % ${PeriodSlaveDay} )) -ne 0 ] ; ) then 
    533                             IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
    534                             IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
    535                             IGCM_debug_Exit "Check your frequency" 
    536                         fi 
    537                     else 
    538                         IGCM_debug_Print 1 "For ${MasterName} with leap calendar:" 
    539                         IGCM_debug_Print 1 "We have a daily ${SlaveName} frequency and ${MasterName}=${MasterFrequency}" 
    540                         IGCM_debug_Print 1 "No post-treatment. Case not properly handle at this moment by libIGCM. Sorry" 
    541                         IGCM_debug_Exit    "Check your frequency ${MasterName} and choose a daily frequency for this one too." 
    542                     fi ;; 
    543             esac ;; 
    544         *M|*m) 
    545             PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" ) 
    546             case ${SlaveFrequency} in                
    547                 *Y|*y) 
    548                     PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
    549                     if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \ 
    550                         [ $(( ${PeriodMasterMonth} % ( ${PeriodSlaveYear} * 12 ) )) -ne 0 ] ) ; then 
    551                         IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
    552                         IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
    553                         IGCM_debug_Exit "Check your frequency" 
    554                     fi ;; 
    555                 *M|*m) 
    556                     PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
    557                     if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \ 
    558                         [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then            
    559                         IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
    560                         IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
    561                         IGCM_debug_Exit "Check your frequency" 
    562                     fi ;; 
    563                 *D|*d) 
    564                     IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
    565                     IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
    566                     IGCM_debug_Exit "Check your frequency" ;; 
    567             esac ;; 
    568         *D|*d) 
    569             PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" ) 
    570             case ${SlaveFrequency} in 
    571                 *Y|*y) 
    572                     IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
    573                     IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}" 
    574                     IGCM_debug_Exit "Check your frequency" ;; 
    575                 *M|*m) 
    576                     IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
    577                     IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}" 
    578                     IGCM_debug_Exit "Check your frequency" ;; 
    579                 *D|*d) 
    580                     PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
    581                     if ( [ ${PeriodSlaveDay} -gt ${PeriodMasterDay} ] || \ 
    582                         [ $(( ${PeriodMasterDay} % ${PeriodSlaveDay} )) -ne 0 ] ) ;  then 
    583                         IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
    584                         IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
    585                         IGCM_debug_Exit "Check your frequency" 
    586                     fi ;; 
    587             esac ;; 
    588         NONE|none)  
    589             ;; 
    590         *) 
    591             IGCM_debug_Print 1 "KeyWord ${MasterFrequency} not allowed for ${MasterName} in config.card" 
    592             IGCM_debug_Exit "Check your ${MasterName} in config.card" ;; 
    593     esac 
    594  
    595     IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency" 
     479  IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $* 
     480 
     481  # Used by IGCM_config_Check 
     482  # from 2 libIGCM compatible frequency (*Y, *M, *D, *y, *m, *d) 
     483  # Issue an exit instruction IGCM_debug_Exit if there modulo is not zero 
     484  # Input parameter are the name of the variable, not the frequency value itself 
     485  # example 
     486  # IGCM_post_ModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength 
     487 
     488  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay 
     489 
     490  # Get the name of the variable 
     491  MasterName=$1 
     492  SlaveName=$2 
     493  # Get the value the above name points to 
     494  MasterFrequency=$( eval echo \${${1}} ) 
     495  SlaveFrequency=$( eval echo \${${2}} ) 
     496 
     497  IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}" 
     498 
     499  case ${MasterFrequency} in 
     500  *y|*Y) 
     501    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" ) 
     502    case ${SlaveFrequency} in 
     503    *Y|*y) 
     504      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
     505      if ( [ ${PeriodSlaveYear} -gt ${PeriodMasterYear} ] || \ 
     506        [ $(( ${PeriodMasterYear} % ${PeriodSlaveYear} )) -ne 0 ] );  then 
     507        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     508        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     509        IGCM_debug_Exit "Check your frequency" 
     510      fi ;; 
     511    *M|*m) 
     512      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
     513      if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \ 
     514        [ $(( ( ${PeriodMasterYear} * 12 ) % ${PeriodSlaveMonth} )) -ne 0 ] ) ; then 
     515        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     516        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     517        IGCM_debug_Exit "Check your frequency" 
     518      fi ;; 
     519    *D|*d) 
     520      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
     521      NbDays=$( IGCM_date_DaysInYear ${year} ) 
     522      if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then 
     523        if ( [ ${PeriodSlaveDay} -gt $(( ${PeriodMasterYear} * ${NbDays} )) ] || \ 
     524          [ $(( ( ${PeriodMasterYear} * ${NbDays} ) % ${PeriodSlaveDay} )) -ne 0 ] ; ) then 
     525          IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     526          IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     527          IGCM_debug_Exit "Check your frequency" 
     528        fi 
     529      else 
     530        IGCM_debug_Print 1 "For ${MasterName} with leap calendar:" 
     531        IGCM_debug_Print 1 "We have a daily ${SlaveName} frequency and ${MasterName}=${MasterFrequency}" 
     532        IGCM_debug_Print 1 "No post-treatment. Case not properly handle at this moment by libIGCM. Sorry" 
     533        IGCM_debug_Exit    "Check your frequency ${MasterName} and choose a daily frequency for this one too." 
     534      fi ;; 
     535    esac ;; 
     536  *M|*m) 
     537    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" ) 
     538    case ${SlaveFrequency} in                
     539    *Y|*y) 
     540      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
     541      if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \ 
     542        [ $(( ${PeriodMasterMonth} % ( ${PeriodSlaveYear} * 12 ) )) -ne 0 ] ) ; then 
     543        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     544        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     545        IGCM_debug_Exit "Check your frequency" 
     546      fi ;; 
     547    *M|*m) 
     548      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
     549      if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \ 
     550        [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then            
     551        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     552        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     553        IGCM_debug_Exit "Check your frequency" 
     554      fi ;; 
     555    *D|*d) 
     556      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     557      IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     558      IGCM_debug_Exit "Check your frequency" ;; 
     559    esac ;; 
     560  *D|*d) 
     561    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" ) 
     562    case ${SlaveFrequency} in 
     563    *Y|*y) 
     564      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     565      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}" 
     566      IGCM_debug_Exit "Check your frequency" ;; 
     567    *M|*m) 
     568      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     569      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}" 
     570      IGCM_debug_Exit "Check your frequency" ;; 
     571    *D|*d) 
     572      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
     573      if ( [ ${PeriodSlaveDay} -gt ${PeriodMasterDay} ] || \ 
     574        [ $(( ${PeriodMasterDay} % ${PeriodSlaveDay} )) -ne 0 ] ) ;  then 
     575        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     576        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     577        IGCM_debug_Exit "Check your frequency" 
     578      fi ;; 
     579    esac ;; 
     580  NONE|none)  
     581    ;; 
     582  *) 
     583    IGCM_debug_Print 1 "KeyWord ${MasterFrequency} not allowed for ${MasterName} in config.card" 
     584    IGCM_debug_Exit "Check your ${MasterName} in config.card" ;; 
     585  esac 
     586 
     587  IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency" 
    596588} 
    597589 
     
    599591function IGCM_post_ModuloRuntimeFrequency 
    600592{ 
    601     IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $* 
    602  
    603     # Used by IGCM_post_Configure 
    604     # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and  
    605     # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d) 
    606     # --> turn on post-processing submission when their modulo is zero 
    607     # Input parameter are the name of the variable, not the frequency value itself 
    608     # example 
    609     # IGCM_post_ModuloRuntimeFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength 
    610  
    611     typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay 
    612  
    613     # Get the name of the variable 
    614     MasterName=$1 
    615     SlaveName=$2 
    616   
    617     # Get the value the above name points to 
    618     eval MasterFrequency=\${${1}} 
    619     eval SlaveFrequency=\${${2}} 
    620  
    621     echo 
    622     IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}" 
    623  
    624     case ${MasterFrequency} in 
    625         *y|*Y) 
    626             PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" ) 
    627             case ${SlaveFrequency} in 
    628                 *Y|*y) 
    629                     PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
    630                     if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} ) % ${PeriodMasterYear} )) -eq 0 ] ;  then 
    631                         if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then 
    632                             eval ${post_freq}=true ; POST=true 
    633                             [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} )) 
    634                         fi 
    635                     fi;; 
    636                 *M|*m) 
    637                     PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
    638                     if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then 
    639                         if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 )) -ne 0 ] ; then 
    640                             eval ${post_freq}=true ; POST=true 
    641                             [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} )) 
    642                         fi 
    643                     fi;; 
    644                 *D|*d) 
    645                     PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
    646                     NbDays=$( IGCM_date_DaysInYear ${year} ) 
    647                     if [ $(( ( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) ) % ( ${NbDays} * ${PeriodMasterYear} / ${PeriodSlaveDay} ) )) -eq 0 ] ; then 
    648                         if [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) )) -ne 0 ] ; then 
    649                             eval ${post_freq}=true ; POST=true 
    650                             [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ( ${NbDays} * ${PeriodMasterYear} ) / ${PeriodSlaveDay} )) 
    651                         fi 
    652                     fi;; 
    653             esac ;; 
    654         *M|*m) 
    655             PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" ) 
    656             case ${SlaveFrequency} in 
    657                 *Y|*y) 
    658                     PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
    659                     if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} ) % ( ${PeriodMasterMonth} ) )) -eq 0 ] ; then 
    660                         if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} )) -ne 0 ] ; then 
    661                             eval ${post_freq}=true ; POST=true 
    662                             [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) )) 
    663                         fi 
    664                     fi;; 
    665                 *M|*m) 
    666                     PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
    667                     if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then 
    668                         if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then  
    669                             eval ${post_freq}=true ; POST=true 
    670                             [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} )) 
    671                         fi 
    672                     fi;; 
    673                 *D|*d) 
    674                     IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with" 
    675                     IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;; 
    676             esac ;; 
    677         *D|*d) 
    678             PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" ) 
    679             case ${SlaveFrequency} in 
    680                 *Y|*y) 
    681                     IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with" 
    682                     IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;; 
    683                 *M|*m) 
    684                     IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with" 
    685                     IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;; 
    686                 *D|*d) 
    687                     PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
    688                     if [ $(( ( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} ) % ${PeriodMasterDay} )) -eq 0 ] ;  then 
    689                         if [ $(( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} )) -ne 0 ] ; then 
    690                             eval ${post_freq}=true ; POST=true 
    691                             [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} )) 
    692                         fi 
    693                     fi;; 
    694             esac ;; 
    695         NONE|none) 
    696             ;; 
    697         *) 
    698             IGCM_debug_Print 1 "KeyWord not allowed for ${post_freq} in config.card" 
    699             ;; 
    700     esac 
    701  
    702     IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency" 
     593  IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $* 
     594 
     595  # Used by IGCM_post_Configure 
     596  # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and  
     597  # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d) 
     598  # --> turn on post-processing submission when their modulo is zero 
     599  # Input parameter are the name of the variable, not the frequency value itself 
     600  # example 
     601  # IGCM_post_ModuloRuntimeFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength 
     602 
     603  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay 
     604 
     605  # Get the name of the variable 
     606  MasterName=$1 
     607  SlaveName=$2 
     608   
     609  # Get the value the above name points to 
     610  eval MasterFrequency=\${${1}} 
     611  eval SlaveFrequency=\${${2}} 
     612 
     613  echo 
     614  IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}" 
     615 
     616  case ${MasterFrequency} in 
     617  *y|*Y) 
     618    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" ) 
     619    case ${SlaveFrequency} in 
     620    *Y|*y) 
     621      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
     622      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} ) % ${PeriodMasterYear} )) -eq 0 ] ;  then 
     623        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then 
     624          eval ${post_freq}=true ; POST=true 
     625          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} )) 
     626        fi 
     627      fi;; 
     628    *M|*m) 
     629      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
     630      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then 
     631        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 )) -ne 0 ] ; then 
     632          eval ${post_freq}=true ; POST=true 
     633          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} )) 
     634        fi 
     635      fi;; 
     636    *D|*d) 
     637      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
     638      NbDays=$( IGCM_date_DaysInYear ${year} ) 
     639      if [ $(( ( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) ) % ( ${NbDays} * ${PeriodMasterYear} / ${PeriodSlaveDay} ) )) -eq 0 ] ; then 
     640        if [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) )) -ne 0 ] ; then 
     641          eval ${post_freq}=true ; POST=true 
     642          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ( ${NbDays} * ${PeriodMasterYear} ) / ${PeriodSlaveDay} )) 
     643        fi 
     644      fi;; 
     645    esac ;; 
     646  *M|*m) 
     647    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" ) 
     648    case ${SlaveFrequency} in 
     649    *Y|*y) 
     650      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
     651      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} ) % ( ${PeriodMasterMonth} ) )) -eq 0 ] ; then 
     652        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} )) -ne 0 ] ; then 
     653          eval ${post_freq}=true ; POST=true 
     654          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) )) 
     655        fi 
     656      fi;; 
     657    *M|*m) 
     658      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
     659      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then 
     660        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then  
     661          eval ${post_freq}=true ; POST=true 
     662          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} )) 
     663        fi 
     664      fi;; 
     665    *D|*d) 
     666      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with" 
     667      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;; 
     668    esac ;; 
     669  *D|*d) 
     670    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" ) 
     671    case ${SlaveFrequency} in 
     672    *Y|*y) 
     673      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with" 
     674      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;; 
     675    *M|*m) 
     676      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with" 
     677      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;; 
     678    *D|*d) 
     679      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
     680      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} ) % ${PeriodMasterDay} )) -eq 0 ] ;  then 
     681        if [ $(( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} )) -ne 0 ] ; then 
     682          eval ${post_freq}=true ; POST=true 
     683          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} )) 
     684        fi 
     685      fi;; 
     686    esac ;; 
     687  NONE|none) 
     688    ;; 
     689  *) 
     690    IGCM_debug_Print 1 "KeyWord not allowed for ${post_freq} in config.card" 
     691    ;; 
     692  esac 
     693 
     694  IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency" 
    703695} 
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_cesium.ksh

    r520 r544  
    121121 
    122122#==================================================== 
    123 #- OUT 
     123#- R_OUT 
    124124typeset -r R_OUT=${ARCHIVE}/IGCM_OUT 
    125125 
    126126#==================================================== 
    127 #- OUT_SCR (ONLY FOR double copy an scratch) 
    128 typeset -r R_OUT_SCR=${SCRATCHDIR}/IGCM_OUT 
     127#- R_BUF (ONLY FOR double copy an scratch) 
     128typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT 
    129129 
    130130#==================================================== 
     
    151151#D- 
    152152function IGCM_sys_RshMaster { 
    153     IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    154     typeset NB_ESSAI DELAI status i 
    155     # number of tentative 
    156     NB_ESSAI=10 
    157     # time delay between tentative 
    158     DELAI=10 
    159     # 
    160     (( i = 0 )) 
    161     while [ $i -lt $NB_ESSAI ] ; do 
    162         ssh ${MASTER} exec /bin/ksh <<-EOF 
     153  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
     154  typeset NB_ESSAI DELAI status i 
     155  # number of tentative 
     156  NB_ESSAI=10 
     157  # time delay between tentative 
     158  DELAI=10 
     159  # 
     160  (( i = 0 )) 
     161  while [ $i -lt $NB_ESSAI ] ; do 
     162    ssh ${MASTER} exec /bin/ksh <<-EOF 
    163163    export libIGCM=${libIGCM_SX} 
    164164    export DEBUG_debug=${DEBUG_debug} 
     
    167167    ${@} 
    168168EOF 
    169         status=$? 
    170         if [ ${status} -gt 0 ]; then 
    171             IGCM_debug_Print 2 "IGCM_sys_RshMaster : ssh failed ${i}/${NB_ESSAI}" 
    172             IGCM_debug_Print 2 "IGCM_sys_RshMaster : sleep ${DELAI} seconds and try again." 
    173             sleep $DELAI 
    174         else 
    175             break 
    176         fi 
    177         (( i = i + 1 )) 
    178     done 
    179  
    180     IGCM_debug_PopStack "IGCM_sys_RshMaster" 
     169    status=$? 
     170    if [ ${status} -gt 0 ]; then 
     171      IGCM_debug_Print 2 "IGCM_sys_RshMaster : ssh failed ${i}/${NB_ESSAI}" 
     172      IGCM_debug_Print 2 "IGCM_sys_RshMaster : sleep ${DELAI} seconds and try again." 
     173      sleep $DELAI 
     174    else 
     175      break 
     176    fi 
     177    (( i = i + 1 )) 
     178  done 
     179 
     180  IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    181181} 
    182182 
     
    187187#D- 
    188188function IGCM_sys_RshArchive { 
    189     IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    190     /bin/ksh <<-EOF 
     189  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
     190  /bin/ksh <<-EOF 
    191191    ${@} 
    192192EOF 
    193     if [ $? -gt 0 ] ; then 
    194         echo "IGCM_sys_RshArchive : erreur." 
    195         IGCM_debug_Exit "IGCM_sys_RshArchive" 
    196     fi 
    197     IGCM_debug_PopStack "IGCM_sys_RshArchive" 
     193  if [ $? -gt 0 ] ; then 
     194    echo "IGCM_sys_RshArchive : erreur." 
     195    IGCM_debug_Exit "IGCM_sys_RshArchive" 
     196  fi 
     197  IGCM_debug_PopStack "IGCM_sys_RshArchive" 
    198198} 
    199199 
     
    204204#D- 
    205205function IGCM_sys_RshPost { 
    206     IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    207     if ( $DEBUG_sys ) ; then 
    208         echo "IGCM_sys_RshPost :" $@ 
    209     fi 
    210     /bin/ksh ${@} 
    211     if [ $? -gt 0 ] ; then 
    212         echo "IGCM_sys_RshPost : erreur." 
    213         IGCM_debug_Exit "IGCM_sys_RshPost" 
    214     fi 
    215     IGCM_debug_PopStack "IGCM_sys_RshPost" 
     206  IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
     207  if ( $DEBUG_sys ) ; then 
     208    echo "IGCM_sys_RshPost :" $@ 
     209  fi 
     210 
     211  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL 
     212  #cat tmp_IGCM_sys_RshPost_$$ 
     213  # keep standard input (stdin) for the loop onto temporary file 
     214  cat >tmp_IGCM_sys_RshPost_$$ 
     215 
     216  /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     217  if [ $? -gt 0 ] ; then 
     218    echo "IGCM_sys_RshPost : erreur." 
     219    IGCM_debug_Exit "IGCM_sys_RshPost" 
     220    cat tmp_IGCM_sys_RshPost_$$ 
     221  fi 
     222  # delete temporary file 
     223  \rm tmp_IGCM_sys_RshPost_$$ 
     224 
     225  IGCM_debug_PopStack "IGCM_sys_RshPost" 
    216226} 
    217227 
     
    222232#D- 
    223233function IGCM_sys_SendMail { 
    224     IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    225     if ( $DEBUG_sys ) ; then 
    226         echo "IGCM_sys_SendMail :" $@ 
    227     fi 
    228  
    229     if ( ${ExitFlag} ) ; then 
    230         status=failed 
    231     else 
    232         status=completed 
    233     fi 
    234  
    235     ssh mercure <<-EOF 
     234  IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
     235  if ( $DEBUG_sys ) ; then 
     236    echo "IGCM_sys_SendMail :" $@ 
     237  fi 
     238 
     239  if ( ${ExitFlag} ) ; then 
     240    status=failed 
     241  else 
     242    status=completed 
     243  fi 
     244 
     245  ssh mercure <<-EOF 
    236246    export LOGIN=${LOGIN} 
    237247    export config_UserChoices_JobName=${config_UserChoices_JobName} 
     
    262272EOF 
    263273 
    264     if [ $? -gt 0 ] ; then 
    265         echo "IGCM_sys_SendMail : erreur." 
    266         IGCM_debug_Exit "IGCM_sys_SendMail" 
    267     fi 
    268     IGCM_debug_PopStack "IGCM_sys_SendMail" 
     274  if [ $? -gt 0 ] ; then 
     275    echo "IGCM_sys_SendMail : erreur." 
     276    IGCM_debug_Exit "IGCM_sys_SendMail" 
     277  fi 
     278  IGCM_debug_PopStack "IGCM_sys_SendMail" 
    269279} 
    270280 
     
    275285#D- 
    276286function IGCM_sys_Mkdir { 
    277     IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    278     if ( $DEBUG_sys ) ; then 
    279         echo "IGCM_sys_Mkdir :" $@ 
    280     fi 
    281     if [ ! -d ${1} ]; then 
    282         \mkdir -p $1 
    283         if [ $? -gt 0 ] ; then 
    284             echo "IGCM_sys_Mkdir : erreur." 
    285             IGCM_debug_Exit "IGCM_sys_Mkdir" 
    286         fi 
    287     fi 
    288     # vérification : 
    289     if [ ! -d ${1} ] ; then 
    290         echo "IGCM_sys_Mkdir : erreur." 
    291         IGCM_debug_Exit "IGCM_sys_Mkdir" 
    292     fi 
    293     IGCM_debug_PopStack "IGCM_sys_Mkdir" 
     287  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
     288  if ( $DEBUG_sys ) ; then 
     289    echo "IGCM_sys_Mkdir :" $@ 
     290  fi 
     291  if [ ! -d ${1} ]; then 
     292    \mkdir -p $1 
     293    if [ $? -gt 0 ] ; then 
     294      echo "IGCM_sys_Mkdir : erreur." 
     295      IGCM_debug_Exit "IGCM_sys_Mkdir" 
     296    fi 
     297  fi 
     298  # vérification : 
     299  if [ ! -d ${1} ] ; then 
     300    echo "IGCM_sys_Mkdir : erreur." 
     301    IGCM_debug_Exit "IGCM_sys_Mkdir" 
     302  fi 
     303  IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    294304} 
    295305 
     
    300310#D- 
    301311function IGCM_sys_MkdirArchive { 
    302     IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
    303     if ( $DEBUG_sys ) ; then 
    304         echo "IGCM_sys_MkdirArchive :" $@ 
    305     fi 
    306     #- creation de repertoire sur le serveur fichier 
    307     if [ ! -d ${1} ]; then  
    308         \mkdir -p $1 
    309         if [ $? -gt 0 ] ; then 
    310             echo "IGCM_sys_MkdirArchive : erreur." 
    311             IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
    312         fi 
    313     fi 
    314     IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
     312  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
     313  if ( $DEBUG_sys ) ; then 
     314    echo "IGCM_sys_MkdirArchive :" $@ 
     315  fi 
     316  #- creation de repertoire sur le serveur fichier 
     317  if [ ! -d ${1} ]; then  
     318    \mkdir -p $1 
     319    if [ $? -gt 0 ] ; then 
     320      echo "IGCM_sys_MkdirArchive : erreur." 
     321      IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
     322    fi 
     323  fi 
     324  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    315325} 
    316326 
     
    321331#D- 
    322332function IGCM_sys_MkdirWork { 
    323     IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    324     if ( $DEBUG_sys ) ; then 
    325         echo "IGCM_sys_MkdirWork :" $@ 
    326     fi 
    327     #- creation de repertoire sur le serveur fichier 
    328     if [ ! -d ${1} ]; then  
    329         \mkdir -p $1 
    330         if [ $? -gt 0 ] ; then 
    331             echo "IGCM_sys_MkdirWork : erreur." 
    332             IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    333         fi 
    334     fi 
    335     IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
     333  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
     334  if ( $DEBUG_sys ) ; then 
     335    echo "IGCM_sys_MkdirWork :" $@ 
     336  fi 
     337  #- creation de repertoire sur le serveur fichier 
     338  if [ ! -d ${1} ]; then  
     339    \mkdir -p $1 
     340    if [ $? -gt 0 ] ; then 
     341      echo "IGCM_sys_MkdirWork : erreur." 
     342      IGCM_debug_Exit "IGCM_sys_MkdirWork" 
     343    fi 
     344  fi 
     345  IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    336346} 
    337347 
     
    342352#D- 
    343353function IGCM_sys_Cd { 
    344     IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    345     if ( $DEBUG_sys ) ; then 
    346         echo "IGCM_sys_Cd :" $@ 
    347     fi 
    348     \cd $1 
    349     if [ $? -gt 0 ] ; then 
    350         echo "IGCM_sys_Cd : erreur." 
    351         IGCM_debug_Exit "IGCM_sys_Cd" 
    352     fi 
    353     IGCM_debug_PopStack "IGCM_sys_Cd" 
     354  IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
     355  if ( $DEBUG_sys ) ; then 
     356    echo "IGCM_sys_Cd :" $@ 
     357  fi 
     358  \cd $1 
     359  if [ $? -gt 0 ] ; then 
     360    echo "IGCM_sys_Cd : erreur." 
     361    IGCM_debug_Exit "IGCM_sys_Cd" 
     362  fi 
     363  IGCM_debug_PopStack "IGCM_sys_Cd" 
    354364} 
    355365 
     
    360370#D- 
    361371function IGCM_sys_Chmod { 
    362     IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
    363     if ( $DEBUG_sys ) ; then 
    364         echo "IGCM_sys_Chmod :" $@ 
    365     fi 
    366     if [ $DRYRUN -le 1 ]; then 
    367         \chmod $@ 
    368         if [ $? -gt 0 ] ; then 
    369             echo "IGCM_sys_Chmod : erreur." 
    370             IGCM_debug_Exit "IGCM_sys_Chmod" 
    371         fi 
    372     else 
    373         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    374     fi 
    375     IGCM_debug_PopStack "IGCM_sys_Chmod" 
     372  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
     373  if ( $DEBUG_sys ) ; then 
     374    echo "IGCM_sys_Chmod :" $@ 
     375  fi 
     376  if [ $DRYRUN -le 1 ]; then 
     377    \chmod $@ 
     378    if [ $? -gt 0 ] ; then 
     379      echo "IGCM_sys_Chmod : erreur." 
     380      IGCM_debug_Exit "IGCM_sys_Chmod" 
     381    fi 
     382  else 
     383    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     384  fi 
     385  IGCM_debug_PopStack "IGCM_sys_Chmod" 
    376386} 
    377387 
     
    382392#D- 
    383393function IGCM_sys_FileSize { 
    384     IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    385  
    386     typeset sizeF 
    387     set +A sizeF -- $( ls -la ${1} ) 
    388     if [ $? -gt 0 ] ; then 
    389         IGCM_debug_Exit "IGCM_sys_FileSize" 
    390     fi 
    391     eval ${2}=${sizeF[4]} 
    392  
    393     IGCM_debug_PopStack "IGCM_sys_FileSize" 
     394  IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
     395 
     396  typeset sizeF 
     397  set +A sizeF -- $( ls -la ${1} ) 
     398  if [ $? -gt 0 ] ; then 
     399    IGCM_debug_Exit "IGCM_sys_FileSize" 
     400  fi 
     401  eval ${2}=${sizeF[4]} 
     402 
     403  IGCM_debug_PopStack "IGCM_sys_FileSize" 
    394404} 
    395405 
     
    400410#D- 
    401411function IGCM_sys_TestDir { 
    402     IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    403     if ( $DEBUG_sys ) ; then 
    404         echo "IGCM_sys_TestDir :" $@ 
    405     fi 
    406     typeset ExistFlag 
    407     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    408     IGCM_debug_PopStack "IGCM_sys_TestDir" 
    409  
    410     return ${ExistFlag} 
     412  IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
     413  if ( $DEBUG_sys ) ; then 
     414    echo "IGCM_sys_TestDir :" $@ 
     415  fi 
     416  typeset ExistFlag 
     417  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     418  IGCM_debug_PopStack "IGCM_sys_TestDir" 
     419 
     420  return ${ExistFlag} 
    411421} 
    412422 
     
    417427#D- 
    418428function IGCM_sys_TestDirArchive { 
    419     IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
    420     if ( $DEBUG_sys ) ; then 
    421         echo "IGCM_sys_TestDirArchive :" $@ 
    422     fi 
    423     typeset ExistFlag 
    424     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    425     IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
    426  
    427     return ${ExistFlag} 
     429  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
     430  if ( $DEBUG_sys ) ; then 
     431    echo "IGCM_sys_TestDirArchive :" $@ 
     432  fi 
     433  typeset ExistFlag 
     434  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     435  IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
     436 
     437  return ${ExistFlag} 
    428438} 
    429439 
     
    434444#D- 
    435445function IGCM_sys_TestFileArchive { 
    436     IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    437     if ( $DEBUG_sys ) ; then 
    438         echo "IGCM_sys_TestFileArchive :" $@ 
    439     fi 
    440     typeset ExistFlag 
    441     ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    442     IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    443  
    444     return ${ExistFlag} 
     446  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
     447  if ( $DEBUG_sys ) ; then 
     448    echo "IGCM_sys_TestFileArchive :" $@ 
     449  fi 
     450  typeset ExistFlag 
     451  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     452  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
     453 
     454  return ${ExistFlag} 
     455} 
     456 
     457#D-#================================================== 
     458#D-function IGCM_sys_TestFileBuffer 
     459#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     460#D-* Examples: 
     461#D- 
     462function IGCM_sys_TestFileBuffer { 
     463  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     464  typeset ExistFlag 
     465  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     466  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     467 
     468  return ${ExistFlag} 
    445469} 
    446470 
     
    451475#D- 
    452476function IGCM_sys_CountFileArchive { 
    453     IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
    454     ls ${@} 2>/dev/null | wc -l 
    455     if [ $? -gt 0 ] ; then 
    456         echo "IGCM_sys_CountFileArchive : erreur." 
    457     fi 
    458     IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     477  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
     478  ls ${@} 2>/dev/null | wc -l 
     479  if [ $? -gt 0 ] ; then 
     480    echo "IGCM_sys_CountFileArchive : erreur." 
     481  fi 
     482  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     483} 
     484 
     485#D-#================================================== 
     486#D-function IGCM_sys_CountFileBuffer 
     487#D-* Purpose: Count files on Master Scratch filesystem 
     488#D-* Examples: 
     489#D- 
     490function IGCM_sys_CountFileBuffer { 
     491  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     492  ls ${@} 2>/dev/null | wc -l 
     493  if [ $? -gt 0 ] ; then 
     494    echo "IGCM_sys_CountFileBuffer : erreur." 
     495  fi 
     496  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    459497} 
    460498 
     
    465503#D- 
    466504function IGCM_sys_Tree { 
    467     IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
    468     if ( $DEBUG_sys ) ; then 
    469         echo "IGCM_sys_Tree :" $@ 
    470     fi 
    471  
    472     \tree -f $@ 
    473  
    474     IGCM_debug_PopStack "IGCM_sys_Tree" 
     505  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     506  if ( $DEBUG_sys ) ; then 
     507    echo "IGCM_sys_Tree :" $@ 
     508  fi 
     509 
     510  \tree -f $@ 
     511 
     512  IGCM_debug_PopStack "IGCM_sys_Tree" 
    475513} 
    476514 
    477515#D-#================================================== 
    478516#D-function IGCM_sys_Tar 
    479 #D-* Purpose: master un-tar command 
     517#D-* Purpose: master tar command 
    480518#D-* Examples: 
    481519#D- 
    482520function IGCM_sys_Tar { 
    483     IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    484     if ( $DEBUG_sys ) ; then 
    485         echo "IGCM_sys_Tar :" $@ 
    486     fi 
    487     \tar cvf $@ 
    488     if [ $? -gt 0 ] ; then 
    489         echo "IGCM_sys_Tar : erreur." 
    490         IGCM_debug_Exit "IGCM_sys_Tar" 
    491     fi 
    492     \tar tvf $1 
    493  
    494     IGCM_debug_PopStack "IGCM_sys_Tar" 
     521  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     522  if ( $DEBUG_sys ) ; then 
     523    echo "IGCM_sys_Tar :" $@ 
     524  fi 
     525  \tar cf $@ 
     526  if [ $? -gt 0 ] ; then 
     527    echo "IGCM_sys_Tar : erreur." 
     528    IGCM_debug_Exit "IGCM_sys_Tar" 
     529  fi 
     530  IGCM_debug_PopStack "IGCM_sys_Tar" 
    495531} 
    496532 
     
    501537#D- 
    502538function IGCM_sys_UnTar { 
    503     IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    504     if ( $DEBUG_sys ) ; then 
    505         echo "IGCM_sys_UnTar :" $@ 
    506     fi 
    507     \tar xvf $1 
    508     if [ $? -gt 0 ] ; then 
    509         echo "IGCM_sys_UnTar : erreur." 
    510         IGCM_debug_Exit "IGCM_sys_UnTar" 
    511     fi 
    512     IGCM_debug_PopStack "IGCM_sys_UnTar" 
     539  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     540  if ( $DEBUG_sys ) ; then 
     541    echo "IGCM_sys_UnTar :" $@ 
     542  fi 
     543  \tar xvf $1 
     544  if [ $? -gt 0 ] ; then 
     545    echo "IGCM_sys_UnTar : erreur." 
     546    IGCM_debug_Exit "IGCM_sys_UnTar" 
     547  fi 
     548  IGCM_debug_PopStack "IGCM_sys_UnTar" 
    513549} 
    514550 
     
    519555#D- 
    520556function IGCM_sys_Qsub { 
    521     IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
    522     if ( $DEBUG_sys ) ; then 
    523         echo "IGCM_sys_Qsub :" $@ 
    524     fi 
    525     /usr/local/bin/ccc_msub -o ${Script_Output} -e ${Script_Output}.e < $1 
    526     if [ $? -gt 0 ] ; then 
    527         echo "IGCM_sys_Qsub : erreur  -o ${Script_Output} -e ${Script_Output}.e $@" 
    528         IGCM_debug_Exit "IGCM_sys_Qsub" 
    529     fi 
    530     IGCM_debug_PopStack "IGCM_sys_Qsub" 
     557  IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
     558  if ( $DEBUG_sys ) ; then 
     559    echo "IGCM_sys_Qsub :" $@ 
     560  fi 
     561  /usr/local/bin/ccc_msub -o ${Script_Output} -e ${Script_Output}.e < $1 
     562  if [ $? -gt 0 ] ; then 
     563    echo "IGCM_sys_Qsub : erreur  -o ${Script_Output} -e ${Script_Output}.e $@" 
     564    IGCM_debug_Exit "IGCM_sys_Qsub" 
     565  fi 
     566  IGCM_debug_PopStack "IGCM_sys_Qsub" 
    531567} 
    532568 
     
    537573#D- 
    538574function IGCM_sys_QsubPost { 
    539     IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
    540     if ( $DEBUG_sys ) ; then 
    541         echo "IGCM_sys_QsubPost :" $@ 
    542     fi 
    543     /usr/local/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.e.out -E "-v ${listVarEnv}" ${libIGCM}/$1.job 
    544     if [ $? -gt 0 ] ; then 
    545         echo "IGCM_sys_QsubPost : erreur " $@ 
    546         IGCM_debug_Exit "IGCM_sys_QsubPost" 
    547     fi 
    548     IGCM_debug_PopStack "IGCM_sys_QsubPost" 
     575  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     576  if ( $DEBUG_sys ) ; then 
     577    echo "IGCM_sys_QsubPost :" $@ 
     578  fi 
     579  /usr/local/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.e.out -E "-v ${listVarEnv}" ${libIGCM}/$1.job 
     580  if [ $? -gt 0 ] ; then 
     581    echo "IGCM_sys_QsubPost : erreur " $@ 
     582    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     583  fi 
     584  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    549585} 
    550586 
     
    560596#D-  Error values and explanations can depend on your system version. 
    561597function IGCM_sys_Rsync_out { 
    562     RET=$1 
    563     if [ ! $RET ] ; then 
    564         echo "rsync error !" 
    565     fi 
    566  
    567     if [ $MYLANG = "fr" ]; then 
    568         case $RET in 
    569             0)  return ;; 
    570             1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    571                 echo "Erreur de syntaxe ou d'utilisation." 
    572                 return;; 
    573             2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    574                 echo "Incompatibilité de protocole." 
    575                 return;; 
    576             3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    577                 echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    578                 echo "répertoires" 
    579                 return;; 
    580             4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    581                 echo "Action demandée non supportée : une tentative de manipulation de" 
    582                 echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    583                 echo "été faite ; ou une option qui est supportée par le  client  mais" 
    584                 echo "pas par le serveur a été spécifiée." 
    585                 return;; 
    586             10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    587                 echo "Erreur dans le socket d'entrée sortie" 
    588                 return;; 
    589             11) echo "Erreur de rsync ; RERR_FILEIO" 
    590                 echo "Erreur d'entrée sortie fichier" 
    591                 return;; 
    592             12) echo "Erreur de rsync ; RERR_STREAMIO" 
    593                 echo "Erreur dans flux de donnée du protocole rsync" 
    594                 return;; 
    595             13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    596                 echo "Erreur avec les diagnostics du programme" 
    597                 return;; 
    598             14) echo "Erreur de rsync ; RERR_IPC" 
    599                 echo "Erreur dans le code IPC" 
    600                 return;; 
    601             20) echo "Erreur de rsync ; RERR_SIGNAL" 
    602                 echo "SIGUSR1 ou SIGINT reçu" 
    603                 return;; 
    604             21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    605                 echo "Une erreur retournée par waitpid()" 
    606                 return;; 
    607             22) echo "Erreur de rsync ; RERR_MALLOC" 
    608                 echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    609                 return;; 
    610             23) echo "" 
    611                 echo "Erreur fichier inexistant" 
    612                 return;; 
    613             30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    614                 echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    615                 return;; 
    616             *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
    617                 return;; 
    618         esac 
    619     elif [ $MYLANG = "en" ] ; then 
    620         case $RET in 
    621             0)  return;;                 
    622             1)  echo "rsync error : Syntax or usage error " 
    623                 return;; 
    624             2)  echo "rsync error : Protocol incompatibility " 
    625                 return;; 
    626             3)  echo "rsync error : Errors selecting input/output files, dirs" 
    627                 return;; 
    628             4)  echo "rsync error : Requested action not supported: an attempt" 
    629                 echo "was made to manipulate 64-bit files on a platform that cannot support" 
    630                 echo "them; or an option was specified that is supported by the client and" 
    631                 echo "not by the server." 
    632                 return;; 
    633             5)  echo "rsync error : Error starting client-server protocol" 
    634                 return;; 
    635             10) echo "rsync error : Error in socket I/O " 
    636                 return;; 
    637             11) echo "rsync error : Error in file I/O " 
    638                 return;; 
    639             12) echo "rsync error : Error in rsync protocol data stream " 
    640                 return;; 
    641             13) echo "rsync error : Errors with program diagnostics " 
    642                 return;; 
    643             14) echo "rsync error : Error in IPC code " 
    644                 return;; 
    645             20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    646                 return;; 
    647             21) echo "rsync error : Some error returned by waitpid() " 
    648                 return;; 
    649             22) echo "rsync error : Error allocating core memory buffers " 
    650                 return;; 
    651             23) echo "rsync error : Partial transfer due to error" 
    652                 return;; 
    653             24) echo "rsync error : Partial transfer due to vanished source files" 
    654                 return;; 
    655             30) echo "rsync error : Timeout in data send/receive " 
    656                 return;; 
    657             *)  echo "rsync error : return code of rsync unknown :" $RET 
    658                 return;; 
    659         esac 
    660     else 
    661         echo "unknown language $MYLANG." 
    662         return 
    663     fi 
    664 } 
    665      
     598  RET=$1 
     599  if [ ! $RET ] ; then 
     600    echo "rsync error !" 
     601  fi 
     602 
     603  if [ $MYLANG = "fr" ]; then 
     604    case $RET in 
     605    0)  return ;; 
     606    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     607      echo "Erreur de syntaxe ou d'utilisation." 
     608      return;; 
     609    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     610      echo "Incompatibilité de protocole." 
     611      return;; 
     612    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     613      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     614      echo "répertoires" 
     615      return;; 
     616    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     617      echo "Action demandée non supportée : une tentative de manipulation de" 
     618      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     619      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     620      echo "pas par le serveur a été spécifiée." 
     621      return;; 
     622    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     623      echo "Erreur dans le socket d'entrée sortie" 
     624      return;; 
     625    11) echo "Erreur de rsync ; RERR_FILEIO" 
     626      echo "Erreur d'entrée sortie fichier" 
     627      return;; 
     628    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     629      echo "Erreur dans flux de donnée du protocole rsync" 
     630      return;; 
     631    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     632      echo "Erreur avec les diagnostics du programme" 
     633      return;; 
     634    14) echo "Erreur de rsync ; RERR_IPC" 
     635      echo "Erreur dans le code IPC" 
     636      return;; 
     637    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     638      echo "SIGUSR1 ou SIGINT reçu" 
     639      return;; 
     640    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     641      echo "Une erreur retournée par waitpid()" 
     642      return;; 
     643    22) echo "Erreur de rsync ; RERR_MALLOC" 
     644      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     645      return;; 
     646    23) echo "" 
     647      echo "Erreur fichier inexistant" 
     648      return;; 
     649    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     650      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     651      return;; 
     652    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     653      return;; 
     654    esac 
     655  elif [ $MYLANG = "en" ] ; then 
     656    case $RET in 
     657    0)  return;;                 
     658    1)  echo "rsync error : Syntax or usage error " 
     659      return;; 
     660    2)  echo "rsync error : Protocol incompatibility " 
     661      return;; 
     662    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     663      return;; 
     664    4)  echo "rsync error : Requested action not supported: an attempt" 
     665      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     666      echo "them; or an option was specified that is supported by the client and" 
     667      echo "not by the server." 
     668      return;; 
     669    5)  echo "rsync error : Error starting client-server protocol" 
     670      return;; 
     671    10) echo "rsync error : Error in socket I/O " 
     672      return;; 
     673    11) echo "rsync error : Error in file I/O " 
     674      return;; 
     675    12) echo "rsync error : Error in rsync protocol data stream " 
     676      return;; 
     677    13) echo "rsync error : Errors with program diagnostics " 
     678      return;; 
     679    14) echo "rsync error : Error in IPC code " 
     680      return;; 
     681    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     682      return;; 
     683    21) echo "rsync error : Some error returned by waitpid() " 
     684      return;; 
     685    22) echo "rsync error : Error allocating core memory buffers " 
     686      return;; 
     687    23) echo "rsync error : Partial transfer due to error" 
     688      return;; 
     689    24) echo "rsync error : Partial transfer due to vanished source files" 
     690      return;; 
     691    30) echo "rsync error : Timeout in data send/receive " 
     692      return;; 
     693    *)  echo "rsync error : return code of rsync unknown :" $RET 
     694      return;; 
     695    esac 
     696  else 
     697    echo "unknown language $MYLANG." 
     698    return 
     699  fi 
     700} 
     701 
    666702#D-#================================================== 
    667703#D-function IGCM_sys_Cp 
     
    670706#D- 
    671707function IGCM_sys_Cp { 
    672     IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    673     if ( $DEBUG_sys ) ; then 
    674         echo "IGCM_sys_Cp :" $@ 
    675     fi 
    676  
    677     typeset RET 
    678  
    679     echo cp $@ > out_rsync 2>&1 
    680     \cp $@ >> out_rsync 2>&1 
    681     RET=$? 
    682  
    683     if [ ${RET} -gt 0 ] ; then 
    684         echo "IGCM_sys_Cp : error." 
    685         cat out_rsync 
    686         IGCM_debug_Exit "IGCM_sys_Cp" 
    687      else 
    688         \rm out_rsync 
    689     fi 
    690     IGCM_debug_PopStack "IGCM_sys_Cp" 
     708  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     709  if ( $DEBUG_sys ) ; then 
     710    echo "IGCM_sys_Cp :" $@ 
     711  fi 
     712 
     713  typeset RET 
     714 
     715  echo cp $@ > out_rsync 2>&1 
     716  \cp $@ >> out_rsync 2>&1 
     717  RET=$? 
     718 
     719  if [ ${RET} -gt 0 ] ; then 
     720    echo "IGCM_sys_Cp : error." 
     721    cat out_rsync 
     722    IGCM_debug_Exit "IGCM_sys_Cp" 
     723  else 
     724    \rm out_rsync 
     725  fi 
     726  IGCM_debug_PopStack "IGCM_sys_Cp" 
    691727} 
    692728 
     
    697733#D- 
    698734function IGCM_sys_Rm { 
    699     IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
    700     if ( $DEBUG_sys ) ; then 
    701         echo "IGCM_sys_Rm :" $@ 
    702     fi 
    703  
    704     typeset RET 
    705  
    706     echo rm $@ > out_rsync 2>&1 
    707     \rm $@ >> out_rsync 2>&1 
    708     RET=$? 
    709  
    710     if [ ${RET} -gt 0 ] ; then 
    711         echo "IGCM_sys_Rm : error." 
    712         cat out_rsync 
    713         IGCM_debug_Exit "IGCM_sys_Rm" 
    714     else 
    715         \rm out_rsync 
    716     fi 
    717     IGCM_debug_PopStack "IGCM_sys_Rm" 
     735  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     736  if ( $DEBUG_sys ) ; then 
     737    echo "IGCM_sys_Rm :" $@ 
     738  fi 
     739 
     740  typeset RET 
     741 
     742  echo rm $@ > out_rsync 2>&1 
     743  \rm $@ >> out_rsync 2>&1 
     744  RET=$? 
     745 
     746  if [ ${RET} -gt 0 ] ; then 
     747    echo "IGCM_sys_Rm : error." 
     748    cat out_rsync 
     749    IGCM_debug_Exit "IGCM_sys_Rm" 
     750  else 
     751    \rm out_rsync 
     752  fi 
     753  IGCM_debug_PopStack "IGCM_sys_Rm" 
    718754} 
    719755 
     
    725761#D- 
    726762function IGCM_sys_RmRunDir { 
    727     IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
    728     if ( $DEBUG_sys ) ; then 
    729         echo "IGCM_sys_RmRunDir :" $@ 
    730     fi 
    731  
    732     typeset RET 
    733  
    734     echo rm $@ > out_rsync 2>&1 
    735     \rm $@ >> out_rsync 2>&1 
    736     RET=$? 
    737  
    738     if [ ${RET} -gt 0 ] ; then 
    739         echo "IGCM_sys_RmRunDir : error." 
    740         cat out_rsync 
    741         IGCM_debug_Exit "IGCM_sys_RmRunDir" 
    742     else 
    743         \rm out_rsync 
    744     fi 
    745  
    746     IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
     763  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
     764  if ( $DEBUG_sys ) ; then 
     765    echo "IGCM_sys_RmRunDir :" $@ 
     766  fi 
     767 
     768  typeset RET 
     769 
     770  echo rm $@ > out_rsync 2>&1 
     771  \rm $@ >> out_rsync 2>&1 
     772  RET=$? 
     773 
     774  if [ ${RET} -gt 0 ] ; then 
     775    echo "IGCM_sys_RmRunDir : error." 
     776    cat out_rsync 
     777    IGCM_debug_Exit "IGCM_sys_RmRunDir" 
     778  else 
     779    \rm out_rsync 
     780  fi 
     781  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    747782} 
    748783 
     
    753788#D- 
    754789function IGCM_sys_Mv { 
    755     IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    756     if ( $DEBUG_sys ) ; then 
    757         echo "IGCM_sys_Mv :" $@ 
    758     fi 
    759  
    760     if [ $DRYRUN = 0 ]; then 
    761  
    762         typeset RET 
    763              
    764         echo mv $@ > out_rsync 2>&1 
    765         \mv $@ >> out_rsync 2>&1 
    766         RET=$? 
     790  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     791  if ( $DEBUG_sys ) ; then 
     792    echo "IGCM_sys_Mv :" $@ 
     793  fi 
     794 
     795  if [ $DRYRUN = 0 ]; then 
     796 
     797    typeset RET 
    767798     
    768         if [ ${RET} -gt 0 ] ; then 
    769             echo "IGCM_sys_Mv : error in mv." 
    770             cat out_rsync 
    771             IGCM_debug_Exit "IGCM_sys_Mv" 
    772         else 
    773             \rm out_rsync 
    774         fi 
     799    echo mv $@ > out_rsync 2>&1 
     800    \mv $@ >> out_rsync 2>&1 
     801    RET=$? 
     802     
     803    if [ ${RET} -gt 0 ] ; then 
     804      echo "IGCM_sys_Mv : error in mv." 
     805      cat out_rsync 
     806      IGCM_debug_Exit "IGCM_sys_Mv" 
    775807    else 
    776         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    777     fi 
    778  
    779     IGCM_debug_PopStack "IGCM_sys_Mv" 
     808      \rm out_rsync 
     809    fi 
     810  else 
     811    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     812  fi 
     813 
     814  IGCM_debug_PopStack "IGCM_sys_Mv" 
    780815} 
    781816 
     
    786821#D- 
    787822function IGCM_sys_Put_Dir { 
    788     IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
    789     if ( $DEBUG_sys ) ; then 
    790         echo "IGCM_sys_Put_Dir :" $@ 
    791     fi 
    792     if [ $DRYRUN = 0 ]; then 
    793         if [ ! -d ${1} ] ; then 
    794             echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
    795             IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    796             return 
    797         fi 
    798  
    799         typeset RET 
    800  
    801         # Only if we use rsync 
    802         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    803         # 
    804         #USUAL WAY 
    805         \cp -r $1 $2 > out_rsync 2>&1 
    806         RET=$? 
    807  
    808         if [ ${RET} -gt 0 ] ; then 
    809             echo "IGCM_sys_Put_Dir : error." 
    810             cat out_rsync 
    811             IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    812         else 
    813             \rm out_rsync 
    814         fi 
     823  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     824  if ( $DEBUG_sys ) ; then 
     825    echo "IGCM_sys_Put_Dir :" $@ 
     826  fi 
     827  if [ $DRYRUN = 0 ]; then 
     828    if [ ! -d ${1} ] ; then 
     829      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     830      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     831      return 
     832    fi 
     833 
     834    typeset RET 
     835 
     836    # Only if we use rsync 
     837    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     838    # 
     839    #USUAL WAY 
     840    \cp -r $1 $2 > out_rsync 2>&1 
     841    RET=$? 
     842 
     843    if [ ${RET} -gt 0 ] ; then 
     844      echo "IGCM_sys_Put_Dir : error." 
     845      cat out_rsync 
     846      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    815847    else 
    816         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    817     fi 
    818     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     848      \rm out_rsync 
     849    fi 
     850  else 
     851    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     852  fi 
     853  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    819854} 
    820855 
    821856#D-#================================================== 
    822857#D-function IGCM_sys_Get_Dir 
    823 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     858#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    824859#D-* Examples: 
    825860#D- 
    826861function IGCM_sys_Get_Dir { 
    827     IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
    828     if ( $DEBUG_sys ) ; then 
    829         echo "IGCM_sys_Get_Dir :" $@ 
    830     fi 
    831     if [ $DRYRUN = 0 ]; then 
    832 #       if [ ! -d ${1} ] ; then 
    833 #           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
    834 #           IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    835 #           return 
    836 #       fi 
    837  
    838         typeset RET 
    839  
    840         # Only if we use rsync 
    841         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    842         # 
    843         #USUAL WAY 
    844         # add dmget (to demigrate all offline files) to reduce time of this command : 
    845         dmget $1/* 
    846         \cp -r $1 $2 > out_rsync 2>&1 
    847         RET=$? 
    848  
    849         if [ ${RET} -gt 0 ] ; then 
    850             echo "IGCM_sys_Get_Dir : error." 
    851             cat out_rsync 
    852             IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    853         else 
    854             \rm out_rsync 
    855         fi 
     862  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     863  if ( $DEBUG_sys ) ; then 
     864    echo "IGCM_sys_Get_Dir :" $@ 
     865  fi 
     866  if [ $DRYRUN = 0 ]; then 
     867#    if [ ! -d ${1} ] ; then 
     868#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     869#      IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     870#      return 
     871#    fi 
     872 
     873    typeset RET 
     874 
     875    # Only if we use rsync 
     876    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     877    # 
     878    # USUAL WAY 
     879    # add dmfind/dmget (to demigrate all offline files) : 
     880    dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget 
     881    \cp -r $1 $2 > out_rsync 2>&1 
     882    RET=$? 
     883 
     884    if [ ${RET} -gt 0 ] ; then 
     885      echo "IGCM_sys_Get_Dir : error." 
     886      cat out_rsync 
     887      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    856888    else 
    857         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    858     fi 
    859     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     889      \rm out_rsync 
     890    fi 
     891  else 
     892    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     893  fi 
     894  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    860895} 
    861896 
     
    866901#D- 
    867902function IGCM_sys_Get_Master { 
    868     IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
    869     if ( $DEBUG_sys ) ; then 
    870         echo "IGCM_sys_Get_Master :" $@ 
    871     fi 
    872     if [ $DRYRUN = 0 ]; then 
    873  
    874         typeset TEST NB_ESSAI DELAI status i 
    875          
    876         TEST=$( IGCM_sys_RshMaster [ -d $1 ] && echo 1 || echo 0 ) 
    877         if [ ${TEST} -ne 1 ] ; then 
    878             echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ON ${MASTER}." 
    879             IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    880             return 
    881         fi 
    882  
    883         # number of tentative 
    884         NB_ESSAI=10 
    885         # time delay between tentative 
    886         DELAI=10 
    887         # 
    888         (( i = 0 )) 
    889         while [ $i -lt $NB_ESSAI ] ; do 
     903  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
     904  if ( $DEBUG_sys ) ; then 
     905    echo "IGCM_sys_Get_Master :" $@ 
     906  fi 
     907  if [ $DRYRUN = 0 ]; then 
     908 
     909    typeset TEST NB_ESSAI DELAI status i 
     910     
     911    TEST=$( IGCM_sys_RshMaster [ -d $1 ] && echo 1 || echo 0 ) 
     912    if [ ${TEST} -ne 1 ] ; then 
     913      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ON ${MASTER}." 
     914      IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     915      return 
     916    fi 
     917 
     918    # number of tentative 
     919    NB_ESSAI=10 
     920    # time delay between tentative 
     921    DELAI=10 
     922    # 
     923    (( i = 0 )) 
     924    while [ $i -lt $NB_ESSAI ] ; do 
    890925            #USUAL WAY 
    891             scp -r ${MASTER}:$1 $2 > out_rsync 2>&1 
    892             status=$? 
    893             if [ ${status} -gt 0 ]; then 
    894                 IGCM_debug_Print 2 "IGCM_sys_Get_Master : scp failed ${i}/${NB_ESSAI}" 
    895                 IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 
    896                 sleep $DELAI 
    897             else 
    898                 break 
    899             fi 
    900             (( i = i + 1 )) 
    901         done 
    902  
    903         if [ ${status} -gt 0 ] ; then 
    904             echo "IGCM_sys_Get_Master : error." 
    905             cat out_rsync 
    906             IGCM_debug_Exit "IGCM_sys_Get_Master" 
    907         else 
    908             \rm out_rsync 
    909         fi 
     926      scp -r ${MASTER}:$1 $2 > out_rsync 2>&1 
     927      status=$? 
     928      if [ ${status} -gt 0 ]; then 
     929        IGCM_debug_Print 2 "IGCM_sys_Get_Master : scp failed ${i}/${NB_ESSAI}" 
     930        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 
     931        sleep $DELAI 
     932      else 
     933        break 
     934      fi 
     935      (( i = i + 1 )) 
     936    done 
     937 
     938    if [ ${status} -gt 0 ] ; then 
     939      echo "IGCM_sys_Get_Master : error." 
     940      cat out_rsync 
     941      IGCM_debug_Exit "IGCM_sys_Get_Master" 
    910942    else 
    911         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    912     fi 
    913     IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     943      \rm out_rsync 
     944    fi 
     945  else 
     946    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     947  fi 
     948  IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    914949} 
    915950 
    916951#D-#================================================== 
    917952#D-function IGCM_sys_Put_Rest 
    918 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     953#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    919954#D-           File and target directory must exist. 
    920955#D-* Examples: 
    921956#D- 
    922957function IGCM_sys_Put_Rest { 
    923     IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
    924     if ( $DEBUG_sys ) ; then 
    925         echo "IGCM_sys_Put_Rest :" $@ 
    926     fi 
    927     if [ $DRYRUN = 0 ]; then 
    928         if [ ! -f ${1} ] ; then 
    929             echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
    930             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    931         fi 
    932  
    933         typeset RET 
    934         # 
    935         if [ X${JobType} = XRUN ] ; then 
    936             IGCM_sys_Chmod 444 ${1} 
    937         fi 
    938         # 
    939         IGCM_sys_TestDirArchive $( dirname $2 ) 
    940         # 
    941         # USUAL WAY 
    942         \cp $1 $2 > out_rsync 2>&1 
    943         RET=$? 
     958  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     959  if ( $DEBUG_sys ) ; then 
     960    echo "IGCM_sys_Put_Rest :" $@ 
     961  fi 
     962  if [ $DRYRUN = 0 ]; then 
     963    if [ ! -f ${1} ] ; then 
     964      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     965      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     966    fi 
     967 
     968    typeset RET 
     969    # 
     970    if [ X${JobType} = XRUN ] ; then 
     971      IGCM_sys_Chmod 444 ${1} 
     972    fi 
     973 
     974    # 
     975    # USUAL WAY 
     976    \cp $1 $2 > out_rsync 2>&1 
     977    RET=$? 
    944978 
    945979#       #RSYNC WITH NETWORK SSH CALL 
    946 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    947 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     980#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     981#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    948982 
    949983#       #RSYNC WITH NFS USE 
     
    957991#       (( RET=RET+$? )) 
    958992 
    959         if [ ${RET} -gt 0 ] ; then 
    960             echo "IGCM_sys_Put_Rest : error." 
    961             cat out_rsync 
    962             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    963         else 
    964             \rm out_rsync 
    965         fi 
     993    if [ ${RET} -gt 0 ] ; then 
     994      echo "IGCM_sys_Put_Rest : error." 
     995      cat out_rsync 
     996      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    966997    else 
    967         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    968     fi 
    969     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     998      \rm out_rsync 
     999    fi 
     1000  else 
     1001    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1002  fi 
     1003  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
    9701004} 
    9711005 
    9721006#D-#================================================== 
    9731007#D-function IGCM_sys_Put_Out 
    974 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     1008#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    9751009#D-* Examples: 
    9761010#D- 
    9771011function IGCM_sys_Put_Out { 
    978     IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
    979     if ( $DEBUG_sys ) ; then 
    980         echo "IGCM_sys_Put_Out :" $@ 
    981     fi 
    982     if [ $DRYRUN = 0 ]; then 
    983         if [ ! -f ${1} ] ; then 
    984             echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
    985             IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    986             return 1 
    987         fi 
    988         # 
    989         IGCM_sys_MkdirArchive $( dirname $2 ) 
    990         # 
    991         typeset RET exist skip 
    992  
    993         #===================================================== 
    994         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    995         #===================================================== 
    996  
    997         #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
    998         #if [ $? -eq 0 ] ; then 
    999         #    typeset WORKPATH FILEPATH 
    1000         #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    1001         #    IGCM_sys_MkdirWork ${WORKPATH}  
    1002         #    FILEPATH=${WORKPATH}/$( basename $2 ) 
    1003         #    # 
    1004         #    IGCM_sys_Cp ${1} ${FILEPATH} 
    1005         #fi 
    1006  
    1007         if [ X${JobType} = XRUN ] ; then 
    1008             if [ X${3} = X ] ; then 
    1009                 IGCM_sys_Chmod 444 ${1} 
    1010             fi 
    1011         fi 
    1012  
    1013         exist=false 
     1012  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     1013  if ( $DEBUG_sys ) ; then 
     1014    echo "IGCM_sys_Put_Out :" $@ 
     1015  fi 
     1016  if [ $DRYRUN = 0 ]; then 
     1017    if [ ! -f ${1} ] ; then 
     1018      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     1019      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1020      return 1 
     1021    fi 
     1022    # 
     1023    IGCM_sys_MkdirArchive $( dirname $2 ) 
     1024    # 
     1025    typeset RET exist skip 
     1026 
     1027    #===================================================== 
     1028    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1029    #===================================================== 
     1030 
     1031    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     1032    #if [ $? -eq 0 ] ; then 
     1033    #    typeset WORKPATH FILEPATH 
     1034    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     1035    #    IGCM_sys_MkdirWork ${WORKPATH}  
     1036    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     1037    #    # 
     1038    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1039    #fi 
     1040 
     1041    if [ X${JobType} = XRUN ] ; then 
     1042      if [ X${3} = X ] ; then 
     1043        IGCM_sys_Chmod 444 ${1} 
     1044      fi 
     1045    fi 
     1046 
     1047    exist=false 
     1048    skip=false 
     1049    if [ -f $2 ] ; then 
     1050      IGCM_debug_Print 1 "$2 already exist" 
     1051      dmget $2 
     1052      exist=true 
     1053      if [ "X$( diff $1 $2 )" = X ] ; then 
     1054        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
     1055        skip=true 
     1056      else 
     1057        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    10141058        skip=false 
    1015         if [ -f $2 ] ; then 
    1016             IGCM_debug_Print 1 "$2 already exist" 
    1017             dmget $2 
    1018             exist=true 
    1019             if [ "X$( diff $1 $2 )" = X ] ; then 
    1020                 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
    1021                 skip=true 
    1022             else 
    1023                 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    1024                 skip=false 
    1025             fi 
    1026         fi 
     1059      fi 
     1060    fi 
    10271061        #  
    1028         if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
    1029             IGCM_sys_Chmod u+w $2 
    1030         fi 
     1062    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
     1063      IGCM_sys_Chmod u+w $2 
     1064    fi 
    10311065        # USUAL WAY 
    1032         if [ X${skip} = Xfalse ] ; then 
    1033             cp $1 $2 > out_rsync 2>&1 
    1034             RET=$? 
    1035             if [ ${RET} -gt 0 ] ; then 
    1036                 echo "IGCM_sys_Put_Out : error." 
    1037                 cat out_rsync 
    1038                 IGCM_debug_Exit "IGCM_sys_Put_Out" 
    1039             else 
    1040                 \rm out_rsync 
    1041             fi 
    1042         fi 
     1066    if [ X${skip} = Xfalse ] ; then 
     1067      cp $1 $2 > out_rsync 2>&1 
     1068      RET=$? 
     1069      if [ ${RET} -gt 0 ] ; then 
     1070        echo "IGCM_sys_Put_Out : error." 
     1071        cat out_rsync 
     1072        IGCM_debug_Exit "IGCM_sys_Put_Out" 
     1073      else 
     1074        \rm out_rsync 
     1075      fi 
     1076    fi 
    10431077 
    10441078#       #RSYNC WITH NETWORK RSH CALL 
     
    10571091 
    10581092 
    1059     else 
    1060         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1061     fi 
    1062     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1063     return 0 
     1093  else 
     1094    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1095  fi 
     1096  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1097  return 0 
    10641098} 
    10651099 
     
    10701104#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    10711105function IGCM_sys_Get { 
    1072     IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    1073  
    1074     typeset DEST RET dm_liste ifile target file_work  
    1075  
    1076     if ( $DEBUG_sys ) ; then 
    1077         echo "IGCM_sys_Get :" $@ 
    1078     fi 
    1079     if [ $DRYRUN -le 2 ]; then 
    1080         if [ X${1} = X'/l' ] ; then 
    1081             # test if the first file is present in the old computation : 
    1082             eval set +A dm_liste \${${2}} 
    1083         else 
    1084             eval set +A dm_liste ${1} 
    1085         fi 
    1086         eval DEST=\${${#}} 
    1087  
    1088         #===================================================== 
    1089         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1090         #===================================================== 
    1091  
    1092         # Is it an R_OUT file (not R_IN) ? 
    1093         #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
    1094         #if [ $? -eq 0 ] ; then 
    1095         #    # Yes  ? then we try to get it in SCRATCHDIR 
    1096         #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" ) 
    1097         #    if [ -f ${file_work[0]} ] ; then 
    1098         #       IGCM_sys_Cp ${file_work[*]} ${DEST} 
    1099         #       IGCM_debug_PopStack "IGCM_sys_Get" 
    1100         #       return 
    1101         #    fi 
    1102         #fi 
    1103  
    1104         # test if the (first) file is present in the old computation : 
    1105         IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1106         RET=$? 
    1107         if [ ${RET} -gt 0 ] ; then 
    1108             echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    1109             IGCM_debug_Exit "IGCM_sys_Get" 
    1110         fi 
    1111  
    1112         dmget ${dm_liste[*]} > out_rsync 2>&1 
    1113         RET=$? 
    1114  
    1115         if [ ${RET} -gt 0 ] ; then 
    1116             echo "WARNING IGCM_sys_Get : demigration error." 
    1117             cat out_rsync 
    1118             echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
    1119         fi 
    1120  
    1121         #if [ ${RET} -gt 0 ] ; then 
    1122         #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
    1123         #       cat out_rsync 
    1124         #       echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
    1125         #       sleep 30 
    1126         #       echo "We try another time" 
    1127         #       dmget ${dm_liste[*]} > out_rsync 2>&1 
    1128         #       RET=$? 
    1129         #       if [ ${RET} -gt 0 ] ; then 
    1130         #           echo "ERROR IGCM_sys_Get : again demigration error :" 
    1131         #           cat out_rsync 
    1132         #           IGCM_debug_Exit "IGCM_sys_Get" 
    1133         #       fi 
    1134         #    else 
    1135         #       echo "ERROR IGCM_sys_Get : demigration error :" 
    1136         #       cat out_rsync 
    1137         #       IGCM_debug_Exit "IGCM_sys_Get" 
    1138         #    fi 
    1139         #fi 
    1140  
    1141         #USUAL WAY 
    1142         (( RET=0 )) 
    1143         if [ X${1} = X'/l' ] ; then 
    1144             (( RET=0 )) 
    1145             for target in ${dm_liste[*]} ; do 
    1146                 local_file=$( basename ${target} ) 
    1147                 \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1148                 (( RET = RET + $? )) 
    1149             done 
    1150         else 
    1151             \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
    1152             RET=$? 
    1153         fi 
     1106  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1107 
     1108  typeset DEST RET dm_liste ifile target file_work  
     1109 
     1110  if ( $DEBUG_sys ) ; then 
     1111    echo "IGCM_sys_Get :" $@ 
     1112  fi 
     1113  if [ $DRYRUN -le 2 ]; then 
     1114    if [ X${1} = X'/l' ] ; then 
     1115      # test if the first file is present in the old computation : 
     1116      eval set +A dm_liste \${${2}} 
     1117    else 
     1118      eval set +A dm_liste ${1} 
     1119    fi 
     1120    eval DEST=\${${#}} 
     1121 
     1122    #===================================================== 
     1123    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1124    #===================================================== 
     1125 
     1126    # Is it an R_OUT file (not R_IN) ? 
     1127    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1128    #if [ $? -eq 0 ] ; then 
     1129    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1130    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1131    #    if [ -f ${file_work[0]} ] ; then 
     1132    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1133    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1134    #   return 
     1135    #    fi 
     1136    #fi 
     1137 
     1138    # test if the (first) file is present in the old computation : 
     1139    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1140    RET=$? 
     1141    if [ ${RET} -gt 0 ] ; then 
     1142      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1143      IGCM_debug_Exit "IGCM_sys_Get" 
     1144    fi 
     1145 
     1146    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1147    RET=$? 
     1148    if [ ${RET} -gt 0 ] ; then 
     1149      echo "WARNING IGCM_sys_Get : demigration error." 
     1150      cat out_rsync 
     1151      echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
     1152    fi 
     1153 
     1154    #if [ ${RET} -gt 0 ] ; then 
     1155    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1156    #   cat out_rsync 
     1157    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1158    #   sleep 30 
     1159    #   echo "We try another time" 
     1160    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1161    #   RET=$? 
     1162    #   if [ ${RET} -gt 0 ] ; then 
     1163    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1164    #       cat out_rsync 
     1165    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1166    #   fi 
     1167    #    else 
     1168    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1169    #   cat out_rsync 
     1170    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1171    #    fi 
     1172    #fi 
     1173 
     1174    #USUAL WAY 
     1175    if [ X${1} = X'/l' ] ; then 
     1176      (( RET=0 )) 
     1177      for target in ${dm_liste[*]} ; do 
     1178        local_file=$( basename ${target} ) 
     1179        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1180        (( RET = RET + $? )) 
     1181      done 
     1182    else 
     1183      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1184      RET=$? 
     1185    fi 
    11541186 
    11551187#       #RSYNC WITH NETWORK SSH CALL 
     
    11671199#       (( RET=RET+$? )) 
    11681200 
    1169         if [ ${RET} -gt 0 ] ; then 
    1170             echo "IGCM_sys_Get : copy error." 
    1171             cat out_rsync 
    1172             IGCM_debug_Exit "IGCM_sys_Get" 
    1173         else 
    1174             \rm out_rsync 
    1175         fi 
     1201    if [ ${RET} -gt 0 ] ; then 
     1202      echo "IGCM_sys_Get : copy error." 
     1203      cat out_rsync 
     1204      IGCM_debug_Exit "IGCM_sys_Get" 
    11761205    else 
    1177         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1178     fi 
    1179     IGCM_debug_PopStack "IGCM_sys_Get" 
     1206      \rm out_rsync 
     1207    fi 
     1208  else 
     1209    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1210  fi 
     1211  IGCM_debug_PopStack "IGCM_sys_Get" 
     1212} 
     1213 
     1214#D-#================================================== 
     1215#D-function IGCM_sys_GetBuffer 
     1216#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1217#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1218#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1219function IGCM_sys_GetBuffer { 
     1220  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1221 
     1222  typeset DEST RET buf_liste ifile target file_work  
     1223 
     1224  if ( $DEBUG_sys ) ; then 
     1225    echo "IGCM_sys_GetBuffer :" $@ 
     1226  fi 
     1227  if [ $DRYRUN -le 2 ]; then 
     1228    if [ X${1} = X'/l' ] ; then 
     1229      # test if the first file is present in the old computation : 
     1230      eval set +A buf_liste \${${2}} 
     1231    else 
     1232      eval set +A buf_liste ${1} 
     1233    fi 
     1234    eval DEST=\${${#}} 
     1235 
     1236    #USUAL WAY 
     1237    if [ X${1} = X'/l' ] ; then 
     1238      (( RET=0 )) 
     1239      for target in ${buf_liste[*]} ; do 
     1240        local_file=$( basename ${target} ) 
     1241        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1242        (( RET = RET + $? )) 
     1243      done 
     1244    else 
     1245      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1246      RET=$? 
     1247    fi 
     1248 
     1249    if [ ${RET} -gt 0 ] ; then 
     1250      echo "IGCM_sys_GetBuffer : copy error." 
     1251      cat out_rsync 
     1252      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1253    else 
     1254      \rm out_rsync 
     1255    fi 
     1256  else 
     1257    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1258  fi 
     1259  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
     1260} 
     1261 
     1262#D-#================================================== 
     1263#D-function IGCM_sys_GetDate_FichWork 
     1264#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
     1265#D-* Examples: 
     1266#D- 
     1267function IGCM_sys_GetDate_FichWork { 
     1268  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1269  if ( $DEBUG_sys ) ; then 
     1270    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1271  fi 
     1272    # donne la date filesys d'un fichier sur la machine work 
     1273  IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1274} 
     1275 
     1276#D-#================================================== 
     1277#D-function IGCM_sys_GetDate_FichArchive 
     1278#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE  
     1279#D-* Examples: 
     1280#D- 
     1281function IGCM_sys_GetDate_FichArchive { 
     1282  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1283  if ( $DEBUG_sys ) ; then 
     1284    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1285  fi 
     1286  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    11801287} 
    11811288 
    11821289#D-#================================================== 
    11831290#D-function IGCM_sys_Dods_Rm 
    1184 #D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole. 
     1291#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. 
    11851292#D-* Examples: 
    11861293#D- 
    11871294function IGCM_sys_Dods_Rm { 
    1188     if ( $DEBUG_sys ) ; then 
    1189         echo "IGCM_sys_Dods_Rm :" $@ 
    1190     fi 
    1191     typeset RET 
    1192     RET=0 
    1193     if [ $DRYRUN = 0 ]; then 
    1194         if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then 
    1195             echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." 
    1196             echo "Nothing has been done." 
    1197             return 
    1198         fi 
    1199         dods_rm public/${LOGIN}/${R_DODS}/${1} #> out_dods_rm 2>&1 
    1200         RET=$? 
    1201          
     1295  if ( $DEBUG_sys ) ; then 
     1296    echo "IGCM_sys_Dods_Rm :" $@ 
     1297  fi 
     1298  typeset RET 
     1299  RET=0 
     1300  if [ $DRYRUN = 0 ]; then 
     1301    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then 
     1302      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." 
     1303      echo "Nothing has been done." 
     1304      return 
     1305    fi 
     1306    dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 
     1307    RET=$? 
     1308     
    12021309#       if [ ${RET} -gt 0 ] ; then 
    12031310#           echo "IGCM_sys_Dods_Rm : error." 
     
    12081315#       fi 
    12091316 
    1210     else 
    1211         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1212     fi 
    1213     return $RET 
    1214 } 
    1215  
     1317  else 
     1318    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1319  fi 
     1320  return $RET 
     1321} 
    12161322 
    12171323#D-#================================================== 
     
    12211327#D- 
    12221328function IGCM_sys_Dods_Cp { 
    1223     if ( $DEBUG_sys ) ; then 
    1224         echo "IGCM_sys_Dods_Cp :" $@ 
    1225     fi 
    1226     typeset RET 
    1227     RET=0 
    1228     if [ $DRYRUN = 0 ]; then 
    1229         if [ ! -d ${R_SAVE}/${1} ] ; then 
    1230             echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." 
    1231             echo "Nothing has been done." 
    1232             return 
    1233         fi 
    1234         # 
    1235         dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 
    1236         RET=$? 
    1237          
     1329  if ( $DEBUG_sys ) ; then 
     1330    echo "IGCM_sys_Dods_Cp :" $@ 
     1331  fi 
     1332  typeset RET 
     1333  RET=0 
     1334  if [ $DRYRUN = 0 ]; then 
     1335    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1336      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." 
     1337      echo "Nothing has been done." 
     1338      return 
     1339    fi 
     1340    # 
     1341    dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 
     1342    RET=$? 
     1343 
    12381344#       if [ ${RET} -gt 0 ] ; then 
    12391345#           echo "IGCM_sys_Dods_Cp : error." 
     
    12441350#       fi 
    12451351 
    1246     else 
    1247         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1248     fi 
    1249     return $RET 
     1352  else 
     1353    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1354  fi 
     1355  return $RET 
    12501356} 
    12511357 
     
    12561362#D- 
    12571363function IGCM_sys_Put_Dods { 
    1258     IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ 
    1259     if ( $DEBUG_sys ) ; then 
    1260         echo "IGCM_sys_Put_Dods :" $@ 
    1261     fi 
    1262     if [ $DRYRUN = 0 ]; then 
    1263         if [ ! -d ${R_SAVE}/${1} ] ; then 
    1264             echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." 
    1265             IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    1266             return 
    1267         fi 
    1268  
    1269         typeset RET 
     1364  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ 
     1365  if ( $DEBUG_sys ) ; then 
     1366    echo "IGCM_sys_Put_Dods :" $@ 
     1367  fi 
     1368  if [ $DRYRUN = 0 ]; then 
     1369    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1370      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." 
     1371      IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
     1372      return 
     1373    fi 
     1374 
     1375    typeset RET 
    12701376        # 
    1271         cd ${R_SAVE} 
    1272         IGCM_sys_Dods_Rm ${1} 
    1273         IGCM_sys_Dods_Cp ${1} 
    1274         RET=0 
    1275          
    1276         if [ ${RET} -gt 0 ] ; then 
    1277             echo "IGCM_sys_Put_Dods : error." 
    1278             IGCM_debug_Exit "IGCM_sys_Put_Dods" 
    1279         fi 
    1280     else 
    1281         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1282     fi 
    1283     IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    1284 } 
    1285  
    1286 ############################################################## A FINIR !! 
    1287  
    1288 #D-#================================================== 
    1289 #D-function IGCM_sys_GetDate_FichWork 
    1290 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
    1291 #D-* Examples: 
    1292 #D- 
    1293 function IGCM_sys_GetDate_FichWork { 
    1294     IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1295     if ( $DEBUG_sys ) ; then 
    1296         echo "IGCM_sys_GetDate_FichWork :" $@ 
    1297     fi 
    1298     # donne la date filesys d'un fichier sur la machine work 
    1299     IGCM_debug_PopStack "IGCM_sys_FichWork" 
    1300 } 
    1301  
    1302 #D-#================================================== 
    1303 #D-function IGCM_sys_GetDate_FichArchive 
    1304 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE  
    1305 #D-* Examples: 
    1306 #D- 
    1307 function IGCM_sys_GetDate_FichArchive { 
    1308     IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1309     if ( $DEBUG_sys ) ; then 
    1310         echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1311     fi 
    1312     IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1377    cd ${R_SAVE} 
     1378    IGCM_sys_Dods_Rm ${1} 
     1379    IGCM_sys_Dods_Cp ${1} 
     1380    RET=0 
     1381     
     1382    if [ ${RET} -gt 0 ] ; then 
     1383      echo "IGCM_sys_Put_Dods : error." 
     1384      IGCM_debug_Exit "IGCM_sys_Put_Dods" 
     1385    fi 
     1386  else 
     1387    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1388  fi 
     1389  IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    13131390} 
    13141391 
     
    13171394 
    13181395function IGCM_sys_rebuild { 
    1319     IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
    1320     if ( $DEBUG_sys ) ; then 
    1321         echo "IGCM_sys_rebuild :" $@ 
    1322     fi 
    1323     /home/cont003/p86ipsl/CESIUM/bin/rebuild -f -o $@ 
    1324     if [ $? -gt 0 ] ; then 
    1325        echo "IGCM_sys_rebuild : erreur ${@}." 
    1326        IGCM_debug_Exit "rebuild" 
    1327     fi 
    1328  
    1329     IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1396  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1397  if ( $DEBUG_sys ) ; then 
     1398    echo "IGCM_sys_rebuild :" $@ 
     1399  fi 
     1400  /home/cont003/p86ipsl/CESIUM/bin/rebuild -f -o $@ 
     1401  if [ $? -gt 0 ] ; then 
     1402    echo "IGCM_sys_rebuild : erreur ${@}." 
     1403    IGCM_debug_Exit "rebuild" 
     1404  fi 
     1405 
     1406  IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1407} 
     1408 
     1409 
     1410############################################################ 
     1411# Activate Running Environnment Variables 
     1412 
     1413function IGCM_sys_activ_variables { 
     1414  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1415  if ( $DEBUG_sys ) ; then 
     1416    echo "IGCM_sys_activ_variables" 
     1417  fi 
     1418  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
     1419} 
     1420 
     1421############################################################ 
     1422# Desactivate Running Environnment Variables 
     1423 
     1424function IGCM_sys_desactiv_variables { 
     1425  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1426  if ( $DEBUG_sys ) ; then 
     1427    echo "IGCM_sys_desactiv_variables" 
     1428  fi 
     1429  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
     1430} 
     1431 
     1432############################################################ 
     1433# Build run file 
     1434 
     1435function IGCM_sys_build_run_file { 
     1436  IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
     1437  if ( $DEBUG_sys ) ; then 
     1438    echo "IGCM_sys_build_run_file" 
     1439  fi 
     1440  IGCM_debug_PopStack "IGCM_sys_build_run_file" 
    13301441} 
    13311442 
     
    13341445 
    13351446function IGCM_sys_ncap2 { 
    1336     IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ 
    1337     if ( $DEBUG_sys ) ; then 
    1338         echo "IGCM_sys_ncap2 :" $@ 
    1339     fi 
    1340     ncap2 "$@" 
    1341     if [ $? -gt 0 ] ; then 
    1342        echo "IGCM_sys_ncap2 : erreur ${@}." 
    1343        IGCM_debug_Exit "ncap2" 
    1344     fi 
    1345  
    1346     IGCM_debug_PopStack "IGCM_sys_ncap2" 
     1447  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ 
     1448  if ( $DEBUG_sys ) ; then 
     1449    echo "IGCM_sys_ncap2 :" $@ 
     1450  fi 
     1451  ncap2 "$@" 
     1452  if [ $? -gt 0 ] ; then 
     1453    echo "IGCM_sys_ncap2 : erreur ${@}." 
     1454    IGCM_debug_Exit "ncap2" 
     1455  fi 
     1456 
     1457  IGCM_debug_PopStack "IGCM_sys_ncap2" 
    13471458} 
    13481459 
    13491460function IGCM_sys_ncatted { 
    1350     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
    1351     if ( $DEBUG_sys ) ; then 
    1352         echo "IGCM_sys_ncatted :" $@ 
    1353     fi 
    1354     ncatted "$@" 
    1355     if [ $? -gt 0 ] ; then 
    1356        echo "IGCM_sys_ncatted : erreur ${@}." 
    1357        IGCM_debug_Exit "ncatted" 
    1358     fi 
    1359  
    1360     IGCM_debug_PopStack "IGCM_sys_ncatted" 
     1461  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
     1462  if ( $DEBUG_sys ) ; then 
     1463    echo "IGCM_sys_ncatted :" $@ 
     1464  fi 
     1465  ncatted "$@" 
     1466  if [ $? -gt 0 ] ; then 
     1467    echo "IGCM_sys_ncatted : erreur ${@}." 
     1468    IGCM_debug_Exit "ncatted" 
     1469  fi 
     1470 
     1471  IGCM_debug_PopStack "IGCM_sys_ncatted" 
    13611472} 
    13621473 
    13631474function IGCM_sys_ncbo { 
    1364     IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
    1365     if ( $DEBUG_sys ) ; then 
    1366         echo "IGCM_sys_ncbo :" $@ 
    1367     fi 
    1368     ncbo $@ 
    1369     if [ $? -gt 0 ] ; then 
    1370        echo "IGCM_sys_ncbo : erreur ${@}." 
    1371        IGCM_debug_Exit "ncbo" 
    1372     fi 
    1373  
    1374     IGCM_debug_PopStack "IGCM_sys_ncbo" 
     1475  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
     1476  if ( $DEBUG_sys ) ; then 
     1477    echo "IGCM_sys_ncbo :" $@ 
     1478  fi 
     1479  ncbo $@ 
     1480  if [ $? -gt 0 ] ; then 
     1481    echo "IGCM_sys_ncbo : erreur ${@}." 
     1482    IGCM_debug_Exit "ncbo" 
     1483  fi 
     1484 
     1485  IGCM_debug_PopStack "IGCM_sys_ncbo" 
    13751486} 
    13761487 
    13771488function IGCM_sys_ncdiff { 
    1378     IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
    1379     if ( $DEBUG_sys ) ; then 
    1380         echo "IGCM_sys_ncdiff :" $@ 
    1381     fi 
    1382     ncdiff $@ 
    1383     if [ $? -gt 0 ] ; then 
    1384        echo "IGCM_sys_ncdiff : erreur ${@}." 
    1385        IGCM_debug_Exit "ncdiff" 
    1386     fi 
    1387  
    1388     IGCM_debug_PopStack "IGCM_sys_ncdiff" 
     1489  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
     1490  if ( $DEBUG_sys ) ; then 
     1491    echo "IGCM_sys_ncdiff :" $@ 
     1492  fi 
     1493  ncdiff $@ 
     1494  if [ $? -gt 0 ] ; then 
     1495    echo "IGCM_sys_ncdiff : erreur ${@}." 
     1496    IGCM_debug_Exit "ncdiff" 
     1497  fi 
     1498 
     1499  IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    13891500} 
    13901501 
    13911502function IGCM_sys_ncea { 
    1392     IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
    1393     if ( $DEBUG_sys ) ; then 
    1394         echo "IGCM_sys_ncea :" $@ 
    1395     fi 
    1396     ncea $@ 
    1397     if [ $? -gt 0 ] ; then 
    1398        echo "IGCM_sys_ncea : erreur ${@}." 
    1399        IGCM_debug_Exit "ncea" 
    1400     fi 
    1401  
    1402     IGCM_debug_PopStack "IGCM_sys_ncea" 
     1503  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
     1504  if ( $DEBUG_sys ) ; then 
     1505    echo "IGCM_sys_ncea :" $@ 
     1506  fi 
     1507  ncea $@ 
     1508  if [ $? -gt 0 ] ; then 
     1509    echo "IGCM_sys_ncea : erreur ${@}." 
     1510    IGCM_debug_Exit "ncea" 
     1511  fi 
     1512 
     1513  IGCM_debug_PopStack "IGCM_sys_ncea" 
    14031514} 
    14041515 
    14051516function IGCM_sys_ncecat { 
    1406     IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
    1407     if ( $DEBUG_sys ) ; then 
    1408         echo "IGCM_sys_ncecat :" $@ 
    1409     fi 
    1410     ncecat $@ 
    1411     if [ $? -gt 0 ] ; then 
    1412        echo "IGCM_sys_ncecat : erreur ${@}." 
    1413        IGCM_debug_Exit "ncecat" 
    1414     fi 
    1415  
    1416     IGCM_debug_PopStack "IGCM_sys_ncecat" 
     1517  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
     1518  if ( $DEBUG_sys ) ; then 
     1519    echo "IGCM_sys_ncecat :" $@ 
     1520  fi 
     1521  ncecat $@ 
     1522  if [ $? -gt 0 ] ; then 
     1523    echo "IGCM_sys_ncecat : erreur ${@}." 
     1524    IGCM_debug_Exit "ncecat" 
     1525  fi 
     1526 
     1527  IGCM_debug_PopStack "IGCM_sys_ncecat" 
    14171528} 
    14181529 
    14191530function IGCM_sys_ncflint { 
    1420     IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
    1421     if ( $DEBUG_sys ) ; then 
    1422         echo "IGCM_sys_ncflint :" $@ 
    1423     fi 
    1424     ncflint $@ 
    1425     if [ $? -gt 0 ] ; then 
    1426        echo "IGCM_sys_ncflint : erreur ${@}." 
    1427        IGCM_debug_Exit "ncflint" 
    1428     fi 
    1429  
    1430     IGCM_debug_PopStack "IGCM_sys_ncflint" 
     1531  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
     1532  if ( $DEBUG_sys ) ; then 
     1533    echo "IGCM_sys_ncflint :" $@ 
     1534  fi 
     1535  ncflint $@ 
     1536  if [ $? -gt 0 ] ; then 
     1537    echo "IGCM_sys_ncflint : erreur ${@}." 
     1538    IGCM_debug_Exit "ncflint" 
     1539  fi 
     1540 
     1541  IGCM_debug_PopStack "IGCM_sys_ncflint" 
    14311542} 
    14321543 
    14331544function IGCM_sys_ncks { 
    1434     IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
    1435     if ( $DEBUG_sys ) ; then 
    1436         echo "IGCM_sys_ncks :" $@ 
    1437     fi 
    1438     ncks $@ 
    1439     if [ $? -gt 0 ] ; then 
    1440        echo "IGCM_sys_ncks : erreur ${@}." 
    1441        IGCM_debug_Exit "ncks" 
    1442     fi 
    1443  
    1444     IGCM_debug_PopStack "IGCM_sys_ncks" 
     1545  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
     1546  if ( $DEBUG_sys ) ; then 
     1547    echo "IGCM_sys_ncks :" $@ 
     1548  fi 
     1549  ncks $@ 
     1550  if [ $? -gt 0 ] ; then 
     1551    echo "IGCM_sys_ncks : erreur ${@}." 
     1552    IGCM_debug_Exit "ncks" 
     1553  fi 
     1554 
     1555  IGCM_debug_PopStack "IGCM_sys_ncks" 
    14451556} 
    14461557 
    14471558function IGCM_sys_ncpdq { 
    1448     IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
    1449     if ( $DEBUG_sys ) ; then 
    1450         echo "IGCM_sys_ncpdq :" $@ 
    1451     fi 
    1452     ncpdq $@ 
    1453     if [ $? -gt 0 ] ; then 
    1454        echo "IGCM_sys_ncpdq : erreur ${@}." 
    1455        IGCM_debug_Exit "ncpdq" 
    1456     fi 
    1457  
    1458     IGCM_debug_PopStack "IGCM_sys_ncpdq" 
     1559  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
     1560  if ( $DEBUG_sys ) ; then 
     1561    echo "IGCM_sys_ncpdq :" $@ 
     1562  fi 
     1563  ncpdq $@ 
     1564  if [ $? -gt 0 ] ; then 
     1565    echo "IGCM_sys_ncpdq : erreur ${@}." 
     1566    IGCM_debug_Exit "ncpdq" 
     1567  fi 
     1568 
     1569  IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    14591570} 
    14601571 
    14611572function IGCM_sys_ncra { 
    1462     IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
    1463     if ( $DEBUG_sys ) ; then 
    1464         echo "IGCM_sys_ncra :" $@ 
    1465     fi 
    1466     ncra $@ 
    1467     if [ $? -gt 0 ] ; then 
    1468        echo "IGCM_sys_ncra : erreur ${@}." 
    1469        IGCM_debug_Exit "ncra" 
    1470     fi 
    1471  
    1472     IGCM_debug_PopStack "IGCM_sys_ncra" 
     1573  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
     1574  if ( $DEBUG_sys ) ; then 
     1575    echo "IGCM_sys_ncra :" $@ 
     1576  fi 
     1577  ncra $@ 
     1578  if [ $? -gt 0 ] ; then 
     1579    echo "IGCM_sys_ncra : erreur ${@}." 
     1580    IGCM_debug_Exit "ncra" 
     1581  fi 
     1582 
     1583  IGCM_debug_PopStack "IGCM_sys_ncra" 
    14731584} 
    14741585 
    14751586function IGCM_sys_ncrcat { 
    1476     IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
    1477     if ( $DEBUG_sys ) ; then 
    1478         echo "IGCM_sys_ncrcat :" $@ 
    1479     fi 
    1480     ncrcat $@ 
    1481     if [ $? -gt 0 ] ; then 
    1482        echo "IGCM_sys_ncrcat : erreur ${@}." 
     1587  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
     1588  if ( $DEBUG_sys ) ; then 
     1589    echo "IGCM_sys_ncrcat :" $@ 
     1590  fi 
     1591  ncrcat $@ 
     1592  if [ $? -gt 0 ] ; then 
     1593    echo "IGCM_sys_ncrcat : erreur ${@}." 
    14831594#       IGCM_debug_Exit "ncrcat" 
    1484     fi 
    1485  
    1486     IGCM_debug_PopStack "IGCM_sys_ncrcat" 
     1595  fi 
     1596 
     1597  IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    14871598} 
    14881599 
    14891600function IGCM_sys_ncrename { 
    1490     IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
    1491     if ( $DEBUG_sys ) ; then 
    1492         echo "IGCM_sys_ncrename :" $@ 
    1493     fi 
    1494     ncrename $@ 
    1495     if [ $? -gt 0 ] ; then 
    1496        echo "IGCM_sys_ncrename : erreur ${@}." 
    1497        IGCM_debug_Exit "ncrename" 
    1498     fi 
    1499  
    1500     IGCM_debug_PopStack "IGCM_sys_ncrename" 
     1601  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
     1602  if ( $DEBUG_sys ) ; then 
     1603    echo "IGCM_sys_ncrename :" $@ 
     1604  fi 
     1605  ncrename $@ 
     1606  if [ $? -gt 0 ] ; then 
     1607    echo "IGCM_sys_ncrename : erreur ${@}." 
     1608    IGCM_debug_Exit "ncrename" 
     1609  fi 
     1610 
     1611  IGCM_debug_PopStack "IGCM_sys_ncrename" 
    15011612} 
    15021613 
    15031614function IGCM_sys_ncwa { 
    1504     IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
    1505     if ( $DEBUG_sys ) ; then 
    1506         echo "IGCM_sys_ncwa :" $@ 
    1507     fi 
    1508     ncwa $@ 
    1509     if [ $? -gt 0 ] ; then 
    1510        echo "IGCM_sys_ncwa : erreur ${@}." 
    1511        IGCM_debug_Exit "ncwa" 
    1512     fi 
    1513  
    1514     IGCM_debug_PopStack "IGCM_sys_ncwa" 
     1615  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
     1616  if ( $DEBUG_sys ) ; then 
     1617    echo "IGCM_sys_ncwa :" $@ 
     1618  fi 
     1619  ncwa $@ 
     1620  if [ $? -gt 0 ] ; then 
     1621    echo "IGCM_sys_ncwa : erreur ${@}." 
     1622    IGCM_debug_Exit "ncwa" 
     1623  fi 
     1624 
     1625  IGCM_debug_PopStack "IGCM_sys_ncwa" 
    15151626} 
    15161627 
     
    15191630 
    15201631function IGCM_sys_cdo { 
    1521     IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ 
    1522  
    1523     \cdo $@ 
    1524     if [ $? -gt 0 ] ; then 
    1525        echo "IGCM_sys_cdo : erreur ${@}." 
    1526        IGCM_debug_PopStack "IGCM_sys_cdo" 
    1527        return 1 
    1528     else 
    1529         IGCM_debug_PopStack "IGCM_sys_cdo" 
    1530         return 0 
    1531     fi 
    1532  
     1632  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ 
     1633  if ( $DEBUG_sys ) ; then 
     1634    echo "IGCM_sys_cdo :" $@ 
     1635  fi 
     1636  \cdo $@ 
     1637  if [ $? -gt 0 ] ; then 
     1638    echo "IGCM_sys_cdo : erreur ${@}." 
    15331639    IGCM_debug_PopStack "IGCM_sys_cdo" 
    1534 } 
    1535  
    1536 ############################################################ 
    1537 # Activate Running Environnment Variables 
    1538  
    1539 function IGCM_sys_activ_variables { 
    1540     IGCM_debug_PushStack "IGCM_sys_activ_variables" 
    1541     if ( $DEBUG_sys ) ; then 
    1542         echo "IGCM_sys_activ_variables" 
    1543     fi 
    1544     IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    1545 } 
    1546  
    1547 ############################################################ 
    1548 # Desactivate Running Environnment Variables 
    1549  
    1550 function IGCM_sys_desactiv_variables { 
    1551     IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
    1552     if ( $DEBUG_sys ) ; then 
    1553         echo "IGCM_sys_desactiv_variables" 
    1554     fi 
    1555     IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
    1556 } 
    1557  
    1558 ############################################################ 
    1559 # Build run file 
    1560  
    1561 function IGCM_sys_build_run_file { 
    1562     IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
    1563     if ( $DEBUG_sys ) ; then 
    1564         echo "IGCM_sys_build_run_file" 
    1565     fi 
    1566     IGCM_debug_PopStack "IGCM_sys_build_run_file" 
    1567 } 
     1640    return 1 
     1641  else 
     1642    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1643    return 0 
     1644  fi 
     1645 
     1646  IGCM_debug_PopStack "IGCM_sys_cdo" 
     1647} 
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh

    r520 r544  
    6262 
    6363#===================================================== 
    64 # Host and user names  
     64# Host and user names 
    6565# $hostname ou hostname 
    6666typeset  HOST=${HOST:=$( hostname )} 
     
    111111 
    112112#==================================================== 
    113 #- OUT 
     113#- R_OUT 
    114114typeset -r R_OUT=${ARCHIVE}/IGCM_OUT 
    115115 
    116116#==================================================== 
    117 #- OUT_SCR (ONLY FOR double copy an scratch) 
    118 typeset -r R_OUT_SCR=${SCRATCHDIR}/IGCM_OUT 
     117#- R_BUF (ONLY FOR double copy an scratch) 
     118typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT 
     119 
     120#==================================================== 
     121#- BIG_DIR : BIG_DIR to store files waiting for rebuild 
     122typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    119123 
    120124#==================================================== 
     
    125129#- RUN_DIR_PATH : Temporary working directory (=> TMP) 
    126130typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${CSCRATCHDIR}/TMPDIR_IGCM/${JOBID}} 
    127  
    128 #==================================================== 
    129 #- BIG_DIR : BIG_DIR to store files waiting for rebuild 
    130 typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    131131 
    132132#==================================================== 
     
    144144#D- 
    145145function IGCM_sys_RshMaster { 
    146     IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    147     /bin/ksh <<-EOF 
     146  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
     147  /bin/ksh <<-EOF 
    148148    export libIGCM=${libIGCM} 
    149149    export DEBUG_debug=${DEBUG_debug} 
     
    152152    ${@} 
    153153EOF 
    154     if [ $? -gt 0 ] ; then 
    155         echo "IGCM_sys_RshMaster : erreur." 
    156         IGCM_debug_Exit "IGCM_sys_RshMaster" 
    157     fi 
    158     IGCM_debug_PopStack "IGCM_sys_RshMaster" 
     154  if [ $? -gt 0 ] ; then 
     155    echo "IGCM_sys_RshMaster : erreur." 
     156    IGCM_debug_Exit "IGCM_sys_RshMaster" 
     157  fi 
     158  IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    159159} 
    160160 
     
    165165#D- 
    166166function IGCM_sys_RshArchive { 
    167     IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    168     /bin/ksh <<-EOF 
     167  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
     168  /bin/ksh <<-EOF 
    169169    ${@} 
    170170EOF 
    171     if [ $? -gt 0 ] ; then 
    172         echo "IGCM_sys_RshArchive : erreur." 
    173         IGCM_debug_Exit "IGCM_sys_RshArchive" 
    174     fi 
    175     IGCM_debug_PopStack "IGCM_sys_RshArchive" 
     171  if [ $? -gt 0 ] ; then 
     172    echo "IGCM_sys_RshArchive : erreur." 
     173    IGCM_debug_Exit "IGCM_sys_RshArchive" 
     174  fi 
     175  IGCM_debug_PopStack "IGCM_sys_RshArchive" 
    176176} 
    177177 
     
    182182#D- 
    183183function IGCM_sys_RshPost { 
    184     IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    185     if ( $DEBUG_sys ) ; then 
    186         echo "IGCM_sys_RshPost :" $@ 
    187     fi 
    188     /bin/ksh ${@} 
    189     if [ $? -gt 0 ] ; then 
    190         echo "IGCM_sys_RshPost : erreur." 
    191         IGCM_debug_Exit "IGCM_sys_RshPost" 
    192     fi 
    193     IGCM_debug_PopStack "IGCM_sys_RshPost" 
     184  IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
     185  if ( $DEBUG_sys ) ; then 
     186    echo "IGCM_sys_RshPost :" $@ 
     187  fi 
     188  /bin/ksh ${@} 
     189  if [ $? -gt 0 ] ; then 
     190    echo "IGCM_sys_RshPost : erreur." 
     191    IGCM_debug_Exit "IGCM_sys_RshPost" 
     192  fi 
     193  IGCM_debug_PopStack "IGCM_sys_RshPost" 
    194194} 
    195195 
     
    200200#D- 
    201201function IGCM_sys_SendMail { 
    202     IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    203     if ( $DEBUG_sys ) ; then 
    204         echo "IGCM_sys_SendMail :" $@ 
    205     fi 
    206  
    207     if ( ${ExitFlag} ) ; then 
    208         status=failed 
    209     else 
    210         status=completed 
    211     fi 
    212     cat  << END_MAIL > job_end.mail 
     202  IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
     203  if ( $DEBUG_sys ) ; then 
     204    echo "IGCM_sys_SendMail :" $@ 
     205  fi 
     206 
     207  if ( ${ExitFlag} ) ; then 
     208    status=failed 
     209  else 
     210    status=completed 
     211  fi 
     212  cat  << END_MAIL > job_end.mail 
    213213Dear ${LOGIN}, 
    214214 
     
    220220END_MAIL 
    221221 
    222     if  [ X"${config_UserChoices_MailName}" != X ] ; then 
    223        mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail 
    224     elif [ -f ~/.forward ] ; then 
    225        mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
    226     else 
    227        mailx -s "${config_UserChoices_JobName} ${status}" ${LOGIN} < job_end.mail 
    228     fi 
    229  
    230     if [ $? -gt 0 ] ; then 
    231         echo "IGCM_sys_SendMail : erreur." 
    232         IGCM_debug_Exit "IGCM_sys_SendMail" 
    233     fi 
    234     IGCM_debug_PopStack "IGCM_sys_SendMail" 
     222  if  [ X"${config_UserChoices_MailName}" != X ] ; then 
     223    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail 
     224  elif [ -f ~/.forward ] ; then 
     225    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
     226  else 
     227    mailx -s "${config_UserChoices_JobName} ${status}" ${LOGIN} < job_end.mail 
     228  fi 
     229 
     230  if [ $? -gt 0 ] ; then 
     231    echo "IGCM_sys_SendMail : erreur." 
     232    IGCM_debug_Exit "IGCM_sys_SendMail" 
     233  fi 
     234  IGCM_debug_PopStack "IGCM_sys_SendMail" 
    235235} 
    236236 
     
    241241#D- 
    242242function IGCM_sys_Mkdir { 
    243     IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    244     if ( $DEBUG_sys ) ; then 
    245         echo "IGCM_sys_Mkdir :" $@ 
    246     fi 
    247     if [ ! -d ${1} ]; then 
    248         \mkdir -p $1 
    249         if [ $? -gt 0 ] ; then 
    250             echo "IGCM_sys_Mkdir : erreur." 
    251             IGCM_debug_Exit "IGCM_sys_Mkdir" 
    252         fi 
    253     fi 
    254     # vérification : 
    255     if [ ! -d ${1} ] ; then 
    256         echo "IGCM_sys_Mkdir : erreur." 
    257         IGCM_debug_Exit "IGCM_sys_Mkdir" 
    258     fi 
    259     IGCM_debug_PopStack "IGCM_sys_Mkdir" 
     243  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
     244  if ( $DEBUG_sys ) ; then 
     245    echo "IGCM_sys_Mkdir :" $@ 
     246  fi 
     247  if [ ! -d ${1} ]; then 
     248    \mkdir -p $1 
     249    if [ $? -gt 0 ] ; then 
     250      echo "IGCM_sys_Mkdir : erreur." 
     251      IGCM_debug_Exit "IGCM_sys_Mkdir" 
     252    fi 
     253  fi 
     254  # vérification : 
     255  if [ ! -d ${1} ] ; then 
     256    echo "IGCM_sys_Mkdir : erreur." 
     257    IGCM_debug_Exit "IGCM_sys_Mkdir" 
     258  fi 
     259  IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    260260} 
    261261 
     
    266266#D- 
    267267function IGCM_sys_MkdirArchive { 
    268     IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
    269     if ( $DEBUG_sys ) ; then 
    270         echo "IGCM_sys_MkdirArchive :" $@ 
    271     fi 
    272     #- creation de repertoire sur le serveur fichier 
    273     if [ ! -d ${1} ]; then  
    274         \mkdir -p $1 
    275         if [ $? -gt 0 ] ; then 
    276             echo "IGCM_sys_MkdirArchive : erreur." 
    277             IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
    278         fi 
    279     fi 
    280     IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
     268  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
     269  if ( $DEBUG_sys ) ; then 
     270    echo "IGCM_sys_MkdirArchive :" $@ 
     271  fi 
     272  #- creation de repertoire sur le serveur fichier 
     273  if [ ! -d ${1} ]; then  
     274    \mkdir -p $1 
     275    if [ $? -gt 0 ] ; then 
     276      echo "IGCM_sys_MkdirArchive : erreur." 
     277      IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
     278    fi 
     279  fi 
     280  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    281281} 
    282282 
     
    287287#D- 
    288288function IGCM_sys_MkdirWork { 
    289     IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    290     if ( $DEBUG_sys ) ; then 
    291         echo "IGCM_sys_MkdirWork :" $@ 
    292     fi 
    293     #- creation de repertoire sur le serveur fichier 
    294     if [ ! -d ${1} ]; then  
    295         \mkdir -p $1 
    296         if [ $? -gt 0 ] ; then 
    297             echo "IGCM_sys_MkdirWork : erreur." 
    298             IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    299         fi 
    300     fi 
    301     IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
     289  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
     290  if ( $DEBUG_sys ) ; then 
     291    echo "IGCM_sys_MkdirWork :" $@ 
     292  fi 
     293  #- creation de repertoire sur le serveur fichier 
     294  if [ ! -d ${1} ]; then  
     295    \mkdir -p $1 
     296    if [ $? -gt 0 ] ; then 
     297      echo "IGCM_sys_MkdirWork : erreur." 
     298      IGCM_debug_Exit "IGCM_sys_MkdirWork" 
     299    fi 
     300  fi 
     301  IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    302302} 
    303303 
     
    308308#D- 
    309309function IGCM_sys_Cd { 
    310     IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    311     if ( $DEBUG_sys ) ; then 
    312         echo "IGCM_sys_Cd :" $@ 
    313     fi 
    314     \cd $1 
    315     if [ $? -gt 0 ] ; then 
    316         echo "IGCM_sys_Cd : erreur." 
    317         IGCM_debug_Exit "IGCM_sys_Cd" 
    318     fi 
    319     IGCM_debug_PopStack "IGCM_sys_Cd" 
     310  IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
     311  if ( $DEBUG_sys ) ; then 
     312    echo "IGCM_sys_Cd :" $@ 
     313  fi 
     314  \cd $1 
     315  if [ $? -gt 0 ] ; then 
     316    echo "IGCM_sys_Cd : erreur." 
     317    IGCM_debug_Exit "IGCM_sys_Cd" 
     318  fi 
     319  IGCM_debug_PopStack "IGCM_sys_Cd" 
    320320} 
    321321 
     
    326326#D- 
    327327function IGCM_sys_Chmod { 
    328     IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
    329     if ( $DEBUG_sys ) ; then 
    330         echo "IGCM_sys_Chmod :" $@ 
    331     fi 
    332     if [ $DRYRUN -le 1 ]; then 
    333         \chmod $@ 
    334         if [ $? -gt 0 ] ; then 
    335             echo "IGCM_sys_Chmod : erreur." 
    336             IGCM_debug_Exit "IGCM_sys_Chmod" 
    337         fi 
    338     else 
    339         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    340     fi 
    341     IGCM_debug_PopStack "IGCM_sys_Chmod" 
     328  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
     329  if ( $DEBUG_sys ) ; then 
     330    echo "IGCM_sys_Chmod :" $@ 
     331  fi 
     332  if [ $DRYRUN -le 1 ]; then 
     333    \chmod $@ 
     334    if [ $? -gt 0 ] ; then 
     335      echo "IGCM_sys_Chmod : erreur." 
     336      IGCM_debug_Exit "IGCM_sys_Chmod" 
     337    fi 
     338  else 
     339    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     340  fi 
     341  IGCM_debug_PopStack "IGCM_sys_Chmod" 
    342342} 
    343343 
     
    348348#D- 
    349349function IGCM_sys_FileSize { 
    350     IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    351  
    352     typeset sizeF 
    353     set +A sizeF -- $( ls -la ${1} ) 
    354     if [ $? -gt 0 ] ; then 
    355         IGCM_debug_Exit "IGCM_sys_FileSize" 
    356     fi 
    357     eval ${2}=${sizeF[4]} 
    358  
    359     IGCM_debug_PopStack "IGCM_sys_FileSize" 
     350  IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
     351 
     352  typeset sizeF 
     353  set +A sizeF -- $( ls -la ${1} ) 
     354  if [ $? -gt 0 ] ; then 
     355    IGCM_debug_Exit "IGCM_sys_FileSize" 
     356  fi 
     357  eval ${2}=${sizeF[4]} 
     358 
     359  IGCM_debug_PopStack "IGCM_sys_FileSize" 
    360360} 
    361361 
     
    366366#D- 
    367367function IGCM_sys_TestDir { 
    368     IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    369     if ( $DEBUG_sys ) ; then 
    370         echo "IGCM_sys_TestDir :" $@ 
    371     fi 
    372     typeset ExistFlag 
    373     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    374     IGCM_debug_PopStack "IGCM_sys_TestDir" 
    375  
    376     return ${ExistFlag} 
     368  IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
     369  if ( $DEBUG_sys ) ; then 
     370    echo "IGCM_sys_TestDir :" $@ 
     371  fi 
     372  typeset ExistFlag 
     373  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     374  IGCM_debug_PopStack "IGCM_sys_TestDir" 
     375 
     376  return ${ExistFlag} 
    377377} 
    378378 
     
    383383#D- 
    384384function IGCM_sys_TestDirArchive { 
    385     IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
    386     if ( $DEBUG_sys ) ; then 
    387         echo "IGCM_sys_TestDirArchive :" $@ 
    388     fi 
    389     typeset ExistFlag 
    390     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    391     IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
    392  
    393     return ${ExistFlag} 
     385  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
     386  if ( $DEBUG_sys ) ; then 
     387    echo "IGCM_sys_TestDirArchive :" $@ 
     388  fi 
     389  typeset ExistFlag 
     390  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     391  IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
     392 
     393  return ${ExistFlag} 
    394394} 
    395395 
     
    400400#D- 
    401401function IGCM_sys_TestFileArchive { 
    402     IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    403     if ( $DEBUG_sys ) ; then 
    404         echo "IGCM_sys_TestFileArchive :" $@ 
    405     fi 
    406     typeset ExistFlag 
    407     ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    408     IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    409  
    410     return ${ExistFlag} 
     402  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
     403  if ( $DEBUG_sys ) ; then 
     404    echo "IGCM_sys_TestFileArchive :" $@ 
     405  fi 
     406  typeset ExistFlag 
     407  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     408  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
     409 
     410  return ${ExistFlag} 
     411} 
     412 
     413#D-#================================================== 
     414#D-function IGCM_sys_TestFileBuffer 
     415#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     416#D-* Examples: 
     417#D- 
     418function IGCM_sys_TestFileBuffer { 
     419  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     420  typeset ExistFlag 
     421  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     422  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     423 
     424  return ${ExistFlag} 
    411425} 
    412426 
     
    417431#D- 
    418432function IGCM_sys_CountFileArchive { 
    419     IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
    420     ls ${@} 2>/dev/null | wc -l 
    421     if [ $? -gt 0 ] ; then 
    422         echo "IGCM_sys_CountFileArchive : erreur." 
    423     fi 
    424     IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     433  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
     434  ls ${@} 2>/dev/null | wc -l 
     435  if [ $? -gt 0 ] ; then 
     436    echo "IGCM_sys_CountFileArchive : erreur." 
     437  fi 
     438  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     439} 
     440 
     441#D-#================================================== 
     442#D-function IGCM_sys_CountFileBuffer 
     443#D-* Purpose: Count files on Scratch filesystem 
     444#D-* Examples: 
     445#D- 
     446function IGCM_sys_CountFileBuffer { 
     447  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     448  ls ${@} 2>/dev/null | wc -l 
     449  if [ $? -gt 0 ] ; then 
     450    echo "IGCM_sys_CountFileBuffer : erreur." 
     451  fi 
     452  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    425453} 
    426454 
     
    431459#D- 
    432460function IGCM_sys_Tree { 
    433     IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
    434     if ( $DEBUG_sys ) ; then 
    435         echo "IGCM_sys_Tree :" $@ 
    436     fi 
    437  
    438     \tree -f $@ 
    439  
    440     IGCM_debug_PopStack "IGCM_sys_Tree" 
     461  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     462  if ( $DEBUG_sys ) ; then 
     463    echo "IGCM_sys_Tree :" $@ 
     464  fi 
     465 
     466  \tree -f $@ 
     467 
     468  IGCM_debug_PopStack "IGCM_sys_Tree" 
    441469} 
    442470 
    443471#D-#================================================== 
    444472#D-function IGCM_sys_Tar 
    445 #D-* Purpose: master un-tar command 
     473#D-* Purpose: master tar command 
    446474#D-* Examples: 
    447475#D- 
    448476function IGCM_sys_Tar { 
    449     IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    450     if ( $DEBUG_sys ) ; then 
    451         echo "IGCM_sys_Tar :" $@ 
    452     fi 
    453     \tar cvf $@ 
    454     if [ $? -gt 0 ] ; then 
    455         echo "IGCM_sys_Tar : erreur." 
    456         IGCM_debug_Exit "IGCM_sys_Tar" 
    457     fi 
    458     \tar tvf $1 
    459  
    460     IGCM_debug_PopStack "IGCM_sys_Tar" 
     477  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     478  if ( $DEBUG_sys ) ; then 
     479    echo "IGCM_sys_Tar :" $@ 
     480  fi 
     481  \tar cf $@ 
     482  if [ $? -gt 0 ] ; then 
     483    echo "IGCM_sys_Tar : erreur." 
     484    IGCM_debug_Exit "IGCM_sys_Tar" 
     485  fi 
     486  IGCM_debug_PopStack "IGCM_sys_Tar" 
    461487} 
    462488 
     
    467493#D- 
    468494function IGCM_sys_UnTar { 
    469     IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    470     if ( $DEBUG_sys ) ; then 
    471         echo "IGCM_sys_UnTar :" $@ 
    472     fi 
    473     \tar xvf $1 
    474     if [ $? -gt 0 ] ; then 
    475         echo "IGCM_sys_UnTar : erreur." 
    476         IGCM_debug_Exit "IGCM_sys_UnTar" 
    477     fi 
    478     IGCM_debug_PopStack "IGCM_sys_UnTar" 
     495  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     496  if ( $DEBUG_sys ) ; then 
     497    echo "IGCM_sys_UnTar :" $@ 
     498  fi 
     499  \tar xvf $1 
     500  if [ $? -gt 0 ] ; then 
     501    echo "IGCM_sys_UnTar : erreur." 
     502    IGCM_debug_Exit "IGCM_sys_UnTar" 
     503  fi 
     504  IGCM_debug_PopStack "IGCM_sys_UnTar" 
    479505} 
    480506 
     
    485511#D- 
    486512function IGCM_sys_QsubPost { 
    487     IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
    488     if ( $DEBUG_sys ) ; then 
    489         echo "IGCM_sys_QsubPost :" $@ 
    490     fi 
    491     /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv} 
    492     if [ $? -gt 0 ] ; then 
    493         echo "IGCM_sys_QsubPost : erreur " $@ 
    494         IGCM_debug_Exit "IGCM_sys_QsubPost" 
    495     fi 
    496     IGCM_debug_PopStack "IGCM_sys_QsubPost" 
     513  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     514  if ( $DEBUG_sys ) ; then 
     515    echo "IGCM_sys_QsubPost :" $@ 
     516  fi 
     517  /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv} 
     518  if [ $? -gt 0 ] ; then 
     519    echo "IGCM_sys_QsubPost : erreur " $@ 
     520    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     521  fi 
     522  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    497523} 
    498524 
     
    508534#D-  Error values and explanations can depend on your system version. 
    509535function IGCM_sys_Rsync_out { 
    510     RET=$1 
    511     if [ ! $RET ] ; then 
    512         echo "rsync error !" 
    513     fi 
    514  
    515     if [ $MYLANG = "fr" ]; then 
    516         case $RET in 
    517             0)  return ;; 
    518             1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    519                 echo "Erreur de syntaxe ou d'utilisation." 
    520                 return;; 
    521             2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    522                 echo "Incompatibilité de protocole." 
    523                 return;; 
    524             3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    525                 echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    526                 echo "répertoires" 
    527                 return;; 
    528             4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    529                 echo "Action demandée non supportée : une tentative de manipulation de" 
    530                 echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    531                 echo "été faite ; ou une option qui est supportée par le  client  mais" 
    532                 echo "pas par le serveur a été spécifiée." 
    533                 return;; 
    534             10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    535                 echo "Erreur dans le socket d'entrée sortie" 
    536                 return;; 
    537             11) echo "Erreur de rsync ; RERR_FILEIO" 
    538                 echo "Erreur d'entrée sortie fichier" 
    539                 return;; 
    540             12) echo "Erreur de rsync ; RERR_STREAMIO" 
    541                 echo "Erreur dans flux de donnée du protocole rsync" 
    542                 return;; 
    543             13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    544                 echo "Erreur avec les diagnostics du programme" 
    545                 return;; 
    546             14) echo "Erreur de rsync ; RERR_IPC" 
    547                 echo "Erreur dans le code IPC" 
    548                 return;; 
    549             20) echo "Erreur de rsync ; RERR_SIGNAL" 
    550                 echo "SIGUSR1 ou SIGINT reçu" 
    551                 return;; 
    552             21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    553                 echo "Une erreur retournée par waitpid()" 
    554                 return;; 
    555             22) echo "Erreur de rsync ; RERR_MALLOC" 
    556                 echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    557                 return;; 
    558             23) echo "" 
    559                 echo "Erreur fichier inexistant" 
    560                 return;; 
    561             30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    562                 echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    563                 return;; 
    564             *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
    565                 return;; 
    566         esac 
    567     elif [ $MYLANG = "en" ] ; then 
    568         case $RET in 
    569             0)  return;;                 
    570             1)  echo "rsync error : Syntax or usage error " 
    571                 return;; 
    572             2)  echo "rsync error : Protocol incompatibility " 
    573                 return;; 
    574             3)  echo "rsync error : Errors selecting input/output files, dirs" 
    575                 return;; 
    576             4)  echo "rsync error : Requested action not supported: an attempt" 
    577                 echo "was made to manipulate 64-bit files on a platform that cannot support" 
    578                 echo "them; or an option was specified that is supported by the client and" 
    579                 echo "not by the server." 
    580                 return;; 
    581             5)  echo "rsync error : Error starting client-server protocol" 
    582                 return;; 
    583             10) echo "rsync error : Error in socket I/O " 
    584                 return;; 
    585             11) echo "rsync error : Error in file I/O " 
    586                 return;; 
    587             12) echo "rsync error : Error in rsync protocol data stream " 
    588                 return;; 
    589             13) echo "rsync error : Errors with program diagnostics " 
    590                 return;; 
    591             14) echo "rsync error : Error in IPC code " 
    592                 return;; 
    593             20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    594                 return;; 
    595             21) echo "rsync error : Some error returned by waitpid() " 
    596                 return;; 
    597             22) echo "rsync error : Error allocating core memory buffers " 
    598                 return;; 
    599             23) echo "rsync error : Partial transfer due to error" 
    600                 return;; 
    601             24) echo "rsync error : Partial transfer due to vanished source files" 
    602                 return;; 
    603             30) echo "rsync error : Timeout in data send/receive " 
    604                 return;; 
    605             *)  echo "rsync error : return code of rsync unknown :" $RET 
    606                 return;; 
    607         esac 
    608     else 
    609         echo "unknown language $MYLANG." 
    610         return 
    611     fi 
    612 } 
    613      
     536  RET=$1 
     537  if [ ! $RET ] ; then 
     538    echo "rsync error !" 
     539  fi 
     540 
     541  if [ $MYLANG = "fr" ]; then 
     542    case $RET in 
     543    0)  return ;; 
     544    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     545      echo "Erreur de syntaxe ou d'utilisation." 
     546      return;; 
     547    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     548      echo "Incompatibilité de protocole." 
     549      return;; 
     550    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     551      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     552      echo "répertoires" 
     553      return;; 
     554    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     555      echo "Action demandée non supportée : une tentative de manipulation de" 
     556      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     557      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     558      echo "pas par le serveur a été spécifiée." 
     559      return;; 
     560    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     561      echo "Erreur dans le socket d'entrée sortie" 
     562      return;; 
     563    11) echo "Erreur de rsync ; RERR_FILEIO" 
     564      echo "Erreur d'entrée sortie fichier" 
     565      return;; 
     566    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     567      echo "Erreur dans flux de donnée du protocole rsync" 
     568      return;; 
     569    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     570      echo "Erreur avec les diagnostics du programme" 
     571      return;; 
     572    14) echo "Erreur de rsync ; RERR_IPC" 
     573      echo "Erreur dans le code IPC" 
     574      return;; 
     575    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     576      echo "SIGUSR1 ou SIGINT reçu" 
     577      return;; 
     578    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     579      echo "Une erreur retournée par waitpid()" 
     580      return;; 
     581    22) echo "Erreur de rsync ; RERR_MALLOC" 
     582      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     583      return;; 
     584    23) echo "" 
     585      echo "Erreur fichier inexistant" 
     586      return;; 
     587    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     588      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     589      return;; 
     590    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     591      return;; 
     592    esac 
     593  elif [ $MYLANG = "en" ] ; then 
     594    case $RET in 
     595    0)  return;;                 
     596    1)  echo "rsync error : Syntax or usage error " 
     597      return;; 
     598    2)  echo "rsync error : Protocol incompatibility " 
     599      return;; 
     600    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     601      return;; 
     602    4)  echo "rsync error : Requested action not supported: an attempt" 
     603      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     604      echo "them; or an option was specified that is supported by the client and" 
     605      echo "not by the server." 
     606      return;; 
     607    5)  echo "rsync error : Error starting client-server protocol" 
     608      return;; 
     609    10) echo "rsync error : Error in socket I/O " 
     610      return;; 
     611    11) echo "rsync error : Error in file I/O " 
     612      return;; 
     613    12) echo "rsync error : Error in rsync protocol data stream " 
     614      return;; 
     615    13) echo "rsync error : Errors with program diagnostics " 
     616      return;; 
     617    14) echo "rsync error : Error in IPC code " 
     618      return;; 
     619    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     620      return;; 
     621    21) echo "rsync error : Some error returned by waitpid() " 
     622      return;; 
     623    22) echo "rsync error : Error allocating core memory buffers " 
     624      return;; 
     625    23) echo "rsync error : Partial transfer due to error" 
     626      return;; 
     627    24) echo "rsync error : Partial transfer due to vanished source files" 
     628      return;; 
     629    30) echo "rsync error : Timeout in data send/receive " 
     630      return;; 
     631    *)  echo "rsync error : return code of rsync unknown :" $RET 
     632      return;; 
     633    esac 
     634  else 
     635    echo "unknown language $MYLANG." 
     636    return 
     637  fi 
     638} 
     639 
    614640#D-#================================================== 
    615641#D-function IGCM_sys_Cp 
     
    618644#D- 
    619645function IGCM_sys_Cp { 
    620     IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    621     if ( $DEBUG_sys ) ; then 
    622         echo "IGCM_sys_Cp :" $@ 
    623     fi 
    624  
    625     typeset RET 
    626  
    627     echo cp $@ > out_rsync 2>&1 
    628     \cp $@ >> out_rsync 2>&1 
    629     RET=$? 
    630  
    631     if [ ${RET} -gt 0 ] ; then 
    632         echo "IGCM_sys_Cp : error." 
    633         cat out_rsync 
    634         IGCM_debug_Exit "IGCM_sys_Cp" 
    635      else 
    636         \rm out_rsync 
    637     fi 
    638     IGCM_debug_PopStack "IGCM_sys_Cp" 
     646  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     647  if ( $DEBUG_sys ) ; then 
     648    echo "IGCM_sys_Cp :" $@ 
     649  fi 
     650 
     651  typeset RET 
     652 
     653  echo cp $@ > out_rsync 2>&1 
     654  \cp $@ >> out_rsync 2>&1 
     655  RET=$? 
     656 
     657  if [ ${RET} -gt 0 ] ; then 
     658    echo "IGCM_sys_Cp : error." 
     659    cat out_rsync 
     660    IGCM_debug_Exit "IGCM_sys_Cp" 
     661  else 
     662    \rm out_rsync 
     663  fi 
     664  IGCM_debug_PopStack "IGCM_sys_Cp" 
    639665} 
    640666 
     
    645671#D- 
    646672function IGCM_sys_Rm { 
    647     IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
    648     if ( $DEBUG_sys ) ; then 
    649         echo "IGCM_sys_Rm :" $@ 
    650     fi 
    651  
    652     typeset RET 
    653  
    654     echo rm $@ > out_rsync 2>&1 
    655     \rm $@ >> out_rsync 2>&1 
    656     RET=$? 
    657  
    658     if [ ${RET} -gt 0 ] ; then 
    659         echo "IGCM_sys_Rm : error." 
    660         cat out_rsync 
    661         IGCM_debug_Exit "IGCM_sys_Rm" 
    662     else 
    663         \rm out_rsync 
    664     fi 
    665     IGCM_debug_PopStack "IGCM_sys_Rm" 
     673  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     674  if ( $DEBUG_sys ) ; then 
     675    echo "IGCM_sys_Rm :" $@ 
     676  fi 
     677 
     678  typeset RET 
     679 
     680  echo rm $@ > out_rsync 2>&1 
     681  \rm $@ >> out_rsync 2>&1 
     682  RET=$? 
     683 
     684  if [ ${RET} -gt 0 ] ; then 
     685    echo "IGCM_sys_Rm : error." 
     686    cat out_rsync 
     687    IGCM_debug_Exit "IGCM_sys_Rm" 
     688  else 
     689    \rm out_rsync 
     690  fi 
     691  IGCM_debug_PopStack "IGCM_sys_Rm" 
    666692} 
    667693 
     
    673699#D- 
    674700function IGCM_sys_RmRunDir { 
    675     IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
    676     if ( $DEBUG_sys ) ; then 
    677         echo "IGCM_sys_RmRunDir :" $@ 
    678     fi 
    679  
    680     typeset RET 
    681  
    682     echo rm $@ > out_rsync 2>&1 
    683     \rm $@ >> out_rsync 2>&1 
    684     RET=$? 
    685  
    686     if [ ${RET} -gt 0 ] ; then 
    687         echo "IGCM_sys_RmRunDir : error." 
    688         cat out_rsync 
    689         IGCM_debug_Exit "IGCM_sys_RmRunDir" 
    690     else 
    691         \rm out_rsync 
    692     fi 
    693     IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
     701  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
     702  if ( $DEBUG_sys ) ; then 
     703    echo "IGCM_sys_RmRunDir :" $@ 
     704  fi 
     705 
     706  typeset RET 
     707 
     708  echo rm $@ > out_rsync 2>&1 
     709  \rm $@ >> out_rsync 2>&1 
     710  RET=$? 
     711 
     712  if [ ${RET} -gt 0 ] ; then 
     713    echo "IGCM_sys_RmRunDir : error." 
     714    cat out_rsync 
     715    IGCM_debug_Exit "IGCM_sys_RmRunDir" 
     716  else 
     717    \rm out_rsync 
     718  fi 
     719  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    694720} 
    695721 
     
    700726#D- 
    701727function IGCM_sys_Mv { 
    702     IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    703     if ( $DEBUG_sys ) ; then 
    704         echo "IGCM_sys_Mv :" $@ 
    705     fi 
    706  
    707     if [ $DRYRUN = 0 ]; then 
    708  
    709         typeset RET 
    710              
    711         echo mv $@ > out_rsync 2>&1 
    712         \mv $@ >> out_rsync 2>&1 
    713         RET=$? 
     728  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     729  if ( $DEBUG_sys ) ; then 
     730    echo "IGCM_sys_Mv :" $@ 
     731  fi 
     732 
     733  if [ $DRYRUN = 0 ]; then 
     734 
     735    typeset RET 
    714736     
    715         if [ ${RET} -gt 0 ] ; then 
    716             echo "IGCM_sys_Mv : error in mv." 
    717             cat out_rsync 
    718             IGCM_debug_Exit "IGCM_sys_Mv" 
    719         else 
    720             \rm out_rsync 
    721         fi 
     737    echo mv $@ > out_rsync 2>&1 
     738    \mv $@ >> out_rsync 2>&1 
     739    RET=$? 
     740     
     741    if [ ${RET} -gt 0 ] ; then 
     742      echo "IGCM_sys_Mv : error in mv." 
     743      cat out_rsync 
     744      IGCM_debug_Exit "IGCM_sys_Mv" 
    722745    else 
    723         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    724     fi 
    725  
    726     IGCM_debug_PopStack "IGCM_sys_Mv" 
     746      \rm out_rsync 
     747    fi 
     748  else 
     749    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     750  fi 
     751 
     752  IGCM_debug_PopStack "IGCM_sys_Mv" 
    727753} 
    728754 
     
    733759#D- 
    734760function IGCM_sys_Put_Dir { 
    735     IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
    736     if ( $DEBUG_sys ) ; then 
    737         echo "IGCM_sys_Put_Dir :" $@ 
    738     fi 
    739     if [ $DRYRUN = 0 ]; then 
    740         if [ ! -d ${1} ] ; then 
    741             echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
    742             IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    743             return 
    744         fi 
    745  
    746         typeset RET 
    747  
    748         # Only if we use rsync 
    749         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    750         # 
    751         #USUAL WAY 
    752         \cp -r $1 $2 > out_rsync 2>&1 
    753         RET=$? 
    754  
    755         if [ ${RET} -gt 0 ] ; then 
    756             echo "IGCM_sys_Put_Dir : error." 
    757             cat out_rsync 
    758             IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    759         else 
    760             \rm out_rsync 
    761         fi 
     761  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     762  if ( $DEBUG_sys ) ; then 
     763    echo "IGCM_sys_Put_Dir :" $@ 
     764  fi 
     765  if [ $DRYRUN = 0 ]; then 
     766    if [ ! -d ${1} ] ; then 
     767      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     768      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     769      return 
     770    fi 
     771 
     772    typeset RET 
     773 
     774    # Only if we use rsync 
     775    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     776    # 
     777    #USUAL WAY 
     778    \cp -r $1 $2 > out_rsync 2>&1 
     779    RET=$? 
     780 
     781    if [ ${RET} -gt 0 ] ; then 
     782      echo "IGCM_sys_Put_Dir : error." 
     783      cat out_rsync 
     784      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    762785    else 
    763         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    764     fi 
    765     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     786      \rm out_rsync 
     787    fi 
     788  else 
     789    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     790  fi 
     791  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    766792} 
    767793 
     
    772798#D- 
    773799function IGCM_sys_Get_Dir { 
    774     IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
    775     if ( $DEBUG_sys ) ; then 
    776         echo "IGCM_sys_Get_Dir :" $@ 
    777     fi 
    778     if [ $DRYRUN = 0 ]; then 
     800  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     801  if ( $DEBUG_sys ) ; then 
     802    echo "IGCM_sys_Get_Dir :" $@ 
     803  fi 
     804  if [ $DRYRUN = 0 ]; then 
    779805#       if [ ! -d ${1} ] ; then 
    780806#           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     
    783809#       fi 
    784810 
    785         typeset RET 
    786  
    787         # Only if we use rsync 
    788         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    789         # 
    790         #USUAL WAY 
    791         # add dmget (to demigrate all offline files) to reduce time of this command : 
    792         dmget $1/* 
    793         \cp -r $1 $2 > out_rsync 2>&1 
    794         RET=$? 
    795  
    796         if [ ${RET} -gt 0 ] ; then 
    797             echo "IGCM_sys_Get_Dir : error." 
    798             cat out_rsync 
    799             IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    800         else 
    801             \rm out_rsync 
    802         fi 
     811    typeset RET 
     812 
     813    # Only if we use rsync 
     814    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     815    # 
     816    #USUAL WAY 
     817    # add dmget (to demigrate all offline files) to reduce time of this command : 
     818    dmget $1/* 
     819    \cp -r $1 $2 > out_rsync 2>&1 
     820    RET=$? 
     821 
     822    if [ ${RET} -gt 0 ] ; then 
     823      echo "IGCM_sys_Get_Dir : error." 
     824      cat out_rsync 
     825      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    803826    else 
    804         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    805     fi 
    806     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     827      \rm out_rsync 
     828    fi 
     829  else 
     830    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     831  fi 
     832  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    807833} 
    808834 
     
    813839#D- 
    814840function IGCM_sys_Get_Master { 
    815     IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
    816     if ( $DEBUG_sys ) ; then 
    817         echo "IGCM_sys_Get_Master :" $@ 
    818     fi 
    819     if [ $DRYRUN = 0 ]; then 
    820         if [ ! -d ${1} ] ; then 
    821             echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
    822             IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    823             return 
    824         fi 
    825  
    826         typeset RET 
    827  
    828         #USUAL WAY 
    829         \cp -r $1 $2 > out_rsync 2>&1 
    830         RET=$? 
    831  
    832         if [ ${RET} -gt 0 ] ; then 
    833             echo "IGCM_sys_Get_Master : error." 
    834             cat out_rsync 
    835             IGCM_debug_Exit "IGCM_sys_Get_Master" 
    836         else 
    837             \rm out_rsync 
    838         fi 
     841  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
     842  if ( $DEBUG_sys ) ; then 
     843    echo "IGCM_sys_Get_Master :" $@ 
     844  fi 
     845  if [ $DRYRUN = 0 ]; then 
     846    if [ ! -d ${1} ] ; then 
     847      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
     848      IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     849      return 
     850    fi 
     851 
     852    typeset RET 
     853 
     854    #USUAL WAY 
     855    \cp -r $1 $2 > out_rsync 2>&1 
     856    RET=$? 
     857 
     858    if [ ${RET} -gt 0 ] ; then 
     859      echo "IGCM_sys_Get_Master : error." 
     860      cat out_rsync 
     861      IGCM_debug_Exit "IGCM_sys_Get_Master" 
    839862    else 
    840         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    841     fi 
    842     IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     863      \rm out_rsync 
     864    fi 
     865  else 
     866    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     867  fi 
     868  IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    843869} 
    844870 
    845871#D-#================================================== 
    846872#D-function IGCM_sys_Put_Rest 
    847 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     873#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    848874#D-           File and target directory must exist. 
    849875#D-* Examples: 
    850876#D- 
    851877function IGCM_sys_Put_Rest { 
    852     IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
    853     if ( $DEBUG_sys ) ; then 
    854         echo "IGCM_sys_Put_Rest :" $@ 
    855     fi 
    856     if [ $DRYRUN = 0 ]; then 
    857         if [ ! -f ${1} ] ; then 
    858             echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
    859             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    860         fi 
    861  
    862         typeset RET 
    863         # 
    864         if [ X${JobType} = XRUN ] ; then 
    865             IGCM_sys_Chmod 444 ${1} 
    866         fi 
    867         # 
    868         IGCM_sys_TestDirArchive $( dirname $2 ) 
    869         # 
    870         # USUAL WAY 
    871         putfer $1 $2 > out_rsync 2>&1 
    872         RET=$? 
     878  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     879  if ( $DEBUG_sys ) ; then 
     880    echo "IGCM_sys_Put_Rest :" $@ 
     881  fi 
     882  if [ $DRYRUN = 0 ]; then 
     883    if [ ! -f ${1} ] ; then 
     884      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     885      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     886    fi 
     887 
     888    typeset RET 
     889    # 
     890    if [ X${JobType} = XRUN ] ; then 
     891      IGCM_sys_Chmod 444 ${1} 
     892    fi 
     893 
     894    # 
     895    # USUAL WAY 
     896    \cp $1 $2 > out_rsync 2>&1 
     897    RET=$? 
    873898 
    874899#       #RSYNC WITH NETWORK SSH CALL 
    875 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    876 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     900#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     901#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    877902 
    878903#       #RSYNC WITH NFS USE 
     
    886911#       (( RET=RET+$? )) 
    887912 
    888         if [ ${RET} -gt 0 ] ; then 
    889             echo "IGCM_sys_Put_Rest : error." 
    890             cat out_rsync 
    891             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    892         else 
    893             \rm out_rsync 
    894         fi 
     913    if [ ${RET} -gt 0 ] ; then 
     914      echo "IGCM_sys_Put_Rest : error." 
     915      cat out_rsync 
     916      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    895917    else 
    896         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    897     fi 
    898     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     918      \rm out_rsync 
     919    fi 
     920  else 
     921    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     922  fi 
     923  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     924} 
     925 
     926#D-#================================================== 
     927#D-function IGCM_sys_PutBuffer_Rest 
     928#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     929#D-           File and target directory must exist. 
     930#D-* Examples: 
     931#D- 
     932function IGCM_sys_PutBuffer_Rest { 
     933  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     934  if ( $DEBUG_sys ) ; then 
     935    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     936  fi 
     937  if [ $DRYRUN = 0 ]; then 
     938    if [ ! -f ${1} ] ; then 
     939      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     940      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     941    fi 
     942 
     943    typeset RET 
     944    # 
     945    if [ X${JobType} = XRUN ] ; then 
     946      IGCM_sys_Chmod 444 ${1} 
     947    fi 
     948 
     949    # 
     950    # USUAL WAY 
     951    \cp $1 $2 > out_rsync 2>&1 
     952    RET=$? 
     953 
     954    if [ ${RET} -gt 0 ] ; then 
     955      echo "IGCM_sys_PutBuffer_Rest : error." 
     956      cat out_rsync 
     957      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     958    else 
     959      \rm out_rsync 
     960    fi 
     961  else 
     962    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     963  fi 
     964  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    899965} 
    900966 
    901967#D-#================================================== 
    902968#D-function IGCM_sys_Put_Out 
    903 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     969#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    904970#D-* Examples: 
    905971#D- 
    906972function IGCM_sys_Put_Out { 
    907     IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
    908     if ( $DEBUG_sys ) ; then 
    909         echo "IGCM_sys_Put_Out :" $@ 
    910     fi 
    911     if [ $DRYRUN = 0 ]; then 
    912         if [ ! -f ${1} ] ; then 
    913             echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
    914             IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    915             return 1 
    916         fi 
    917         # 
    918         IGCM_sys_MkdirArchive $( dirname $2 ) 
    919         # 
    920         typeset RET exist skip 
    921  
    922         #===================================================== 
    923         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    924         #===================================================== 
    925  
    926         #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
    927         #if [ $? -eq 0 ] ; then 
    928         #    typeset WORKPATH FILEPATH 
    929         #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    930         #    IGCM_sys_MkdirWork ${WORKPATH}  
    931         #    FILEPATH=${WORKPATH}/$( basename $2 ) 
    932         #    # 
    933         #    IGCM_sys_Cp ${1} ${FILEPATH} 
    934         #fi 
    935  
    936         if [ X${JobType} = XRUN ] ; then 
    937             if [ X${3} = X ] ; then 
    938                 IGCM_sys_Chmod 444 ${1} 
    939             fi 
    940         fi 
    941  
    942         exist=false 
     973  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     974  if ( $DEBUG_sys ) ; then 
     975    echo "IGCM_sys_Put_Out :" $@ 
     976  fi 
     977  if [ $DRYRUN = 0 ]; then 
     978    if [ ! -f ${1} ] ; then 
     979      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     980      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     981      return 1 
     982    fi 
     983    # 
     984    IGCM_sys_MkdirArchive $( dirname $2 ) 
     985    # 
     986    typeset RET exist skip 
     987 
     988    #===================================================== 
     989    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     990    #===================================================== 
     991 
     992    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     993    #if [ $? -eq 0 ] ; then 
     994    #    typeset WORKPATH FILEPATH 
     995    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     996    #    IGCM_sys_MkdirWork ${WORKPATH}  
     997    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     998    #    # 
     999    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1000    #fi 
     1001 
     1002    if [ X${JobType} = XRUN ] ; then 
     1003      if [ X${3} = X ] ; then 
     1004        IGCM_sys_Chmod 444 ${1} 
     1005      fi 
     1006    fi 
     1007 
     1008    exist=false 
     1009    skip=false 
     1010    if [ -f $2 ] ; then 
     1011      IGCM_debug_Print 1 "$2 already exist" 
     1012      dmget $2 
     1013      exist=true 
     1014      if [ "X$( diff $1 $2 )" = X ] ; then 
     1015        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
     1016        skip=true 
     1017      else 
     1018        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    9431019        skip=false 
    944         if [ -f $2 ] ; then 
    945             IGCM_debug_Print 1 "$2 already exist" 
    946             dmget $2 
    947             exist=true 
    948             if [ "X$( diff $1 $2 )" = X ] ; then 
    949                 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
    950                 skip=true 
    951             else 
    952                 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    953                 skip=false 
    954             fi 
    955         fi 
    956         #  
    957         if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
    958             IGCM_sys_Chmod u+w $2 
    959         fi 
    960         # USUAL WAY 
    961         if [ X${skip} = Xfalse ] ; then 
    962             \cp $1 $2 > out_rsync 2>&1 
    963             RET=$? 
    964             if [ ${RET} -gt 0 ] ; then 
    965                 echo "IGCM_sys_Put_Out : error." 
    966                 cat out_rsync 
    967                 IGCM_debug_Exit "IGCM_sys_Put_Out" 
    968             else 
    969                 \rm out_rsync 
    970             fi 
    971         fi 
    972  
    973 #       #RSYNC WITH NETWORK RSH CALL 
    974 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    975 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     1020      fi 
     1021    fi 
     1022    #  
     1023    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
     1024      IGCM_sys_Chmod u+w $2 
     1025    fi 
     1026    # USUAL WAY 
     1027    if [ X${skip} = Xfalse ] ; then 
     1028      \cp $1 $2 > out_rsync 2>&1 
     1029      RET=$? 
     1030      if [ ${RET} -gt 0 ] ; then 
     1031        echo "IGCM_sys_Put_Out : error." 
     1032        cat out_rsync 
     1033        IGCM_debug_Exit "IGCM_sys_Put_Out" 
     1034      else 
     1035        \rm out_rsync 
     1036      fi 
     1037    fi 
     1038 
     1039#       #RSYNC WITH NETWORK SSH CALL 
     1040#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     1041#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    9761042 
    9771043#       #RSYNC WITH NFS USE 
     
    9851051#       (( RET=RET+$? )) 
    9861052 
     1053  else 
     1054    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1055  fi 
     1056  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1057  return 0 
     1058} 
     1059 
     1060#D-#================================================== 
     1061#D-function IGCM_sys_PutBuffer_Out 
     1062#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
     1063#D-* Examples: 
     1064#D- 
     1065function IGCM_sys_PutBuffer_Out { 
     1066  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     1067  if ( $DEBUG_sys ) ; then 
     1068    echo "IGCM_sys_PutBuffer_Out :" $@ 
     1069  fi 
     1070  if [ $DRYRUN = 0 ]; then 
     1071    if [ ! -f ${1} ] ; then 
     1072      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     1073      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1074      return 1 
     1075    fi 
     1076    # 
     1077    IGCM_sys_Mkdir $( dirname $2 ) 
     1078    # 
     1079    typeset RET 
     1080 
     1081    if [ X${JobType} = XRUN ] ; then 
     1082      if [ X${3} = X ] ; then 
     1083        IGCM_sys_Chmod 444 ${1} 
     1084      fi 
     1085    fi 
     1086    # 
     1087    # USUAL WAY 
     1088    \cp $1 $2 > out_rsync 2>&1 
     1089    RET=$? 
     1090 
     1091    if [ ${RET} -gt 0 ] ; then 
     1092      echo "IGCM_sys_PutBuffer_Out : error." 
     1093      cat out_rsync 
     1094      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
    9871095    else 
    988         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    989     fi 
    990     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    991     return 0 
     1096      \rm out_rsync 
     1097    fi 
     1098  else 
     1099    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1100  fi 
     1101  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1102  return 0 
    9921103} 
    9931104 
     
    9981109#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    9991110function IGCM_sys_Get { 
    1000     IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    1001  
    1002     typeset DEST RET dm_liste ifile target file_work  
    1003  
    1004     if ( $DEBUG_sys ) ; then 
    1005         echo "IGCM_sys_Get :" $@ 
    1006     fi 
    1007     if [ $DRYRUN -le 2 ]; then 
    1008         if [ X${1} = X'/l' ] ; then 
    1009             # test if the first file is present in the old computation : 
    1010             eval set +A dm_liste \${${2}} 
    1011         else 
    1012             eval set +A dm_liste ${1} 
    1013         fi 
    1014         eval DEST=\${${#}} 
    1015  
    1016         #===================================================== 
    1017         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1018         #===================================================== 
    1019  
    1020         # Is it an R_OUT file (not R_IN) ? 
    1021         #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
    1022         #if [ $? -eq 0 ] ; then 
    1023         #    # Yes  ? then we try to get it in SCRATCHDIR 
    1024         #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" ) 
    1025         #    if [ -f ${file_work[0]} ] ; then 
    1026         #       IGCM_sys_Cp ${file_work[*]} ${DEST} 
    1027         #       IGCM_debug_PopStack "IGCM_sys_Get" 
    1028         #       return 
    1029         #    fi 
    1030         #fi 
    1031  
    1032         # test if the (first) file is present in the old computation : 
    1033         IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1034         RET=$? 
    1035         if [ ${RET} -gt 0 ] ; then 
    1036             echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    1037             IGCM_debug_Exit "IGCM_sys_Get" 
    1038         fi 
    1039  
    1040         dmget ${dm_liste[*]} > out_rsync 2>&1 
    1041         RET=$? 
    1042  
    1043         if [ ${RET} -gt 0 ] ; then 
    1044             echo "WARNING IGCM_sys_Get : demigration error." 
    1045             cat out_rsync 
    1046             echo "WARNING IGCM_sys_Get : will later stop if the cp fails." 
    1047         fi 
    1048  
    1049         #if [ ${RET} -gt 0 ] ; then 
    1050         #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
    1051         #       cat out_rsync 
    1052         #       echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
    1053         #       sleep 30 
    1054         #       echo "We try another time" 
    1055         #       dmget ${dm_liste[*]} > out_rsync 2>&1 
    1056         #       RET=$? 
    1057         #       if [ ${RET} -gt 0 ] ; then 
    1058         #           echo "ERROR IGCM_sys_Get : again demigration error :" 
    1059         #           cat out_rsync 
    1060         #           IGCM_debug_Exit "IGCM_sys_Get" 
    1061         #       fi 
    1062         #    else 
    1063         #       echo "ERROR IGCM_sys_Get : demigration error :" 
    1064         #       cat out_rsync 
    1065         #       IGCM_debug_Exit "IGCM_sys_Get" 
    1066         #    fi 
    1067         #fi 
    1068  
    1069         #USUAL WAY 
    1070         (( RET=0 )) 
    1071         if [ X${1} = X'/l' ] ; then 
    1072             (( RET=0 )) 
    1073             for target in ${dm_liste[*]} ; do 
    1074                 local_file=$( basename ${target} ) 
    1075                 \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1076                 (( RET = RET + $? )) 
    1077             done 
    1078         else 
    1079             \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
    1080             RET=$? 
    1081         fi 
    1082  
    1083 #       #RSYNC WITH NETWORK RSH CALL 
    1084 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
    1085 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
     1111  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1112 
     1113  typeset DEST RET dm_liste ifile target file_work  
     1114 
     1115  if ( $DEBUG_sys ) ; then 
     1116    echo "IGCM_sys_Get :" $@ 
     1117  fi 
     1118  if [ $DRYRUN -le 2 ]; then 
     1119    if [ X${1} = X'/l' ] ; then 
     1120      # test if the first file is present in the old computation : 
     1121      eval set +A dm_liste \${${2}} 
     1122    else 
     1123      eval set +A dm_liste ${1} 
     1124    fi 
     1125    eval DEST=\${${#}} 
     1126 
     1127    #===================================================== 
     1128    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1129    #===================================================== 
     1130 
     1131    # Is it an R_OUT file (not R_IN) ? 
     1132    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1133    #if [ $? -eq 0 ] ; then 
     1134    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1135    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1136    #    if [ -f ${file_work[0]} ] ; then 
     1137    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1138    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1139    #   return 
     1140    #    fi 
     1141    #fi 
     1142 
     1143    # test if the (first) file is present in the old computation : 
     1144    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1145    RET=$? 
     1146    if [ ${RET} -gt 0 ] ; then 
     1147      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1148      IGCM_debug_Exit "IGCM_sys_Get" 
     1149    fi 
     1150 
     1151    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1152    RET=$? 
     1153 
     1154    if [ ${RET} -gt 0 ] ; then 
     1155      echo "WARNING IGCM_sys_Get : demigration error." 
     1156      cat out_rsync 
     1157      echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
     1158    fi 
     1159 
     1160    #if [ ${RET} -gt 0 ] ; then 
     1161    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1162    #   cat out_rsync 
     1163    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1164    #   sleep 30 
     1165    #   echo "We try another time" 
     1166    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1167    #   RET=$? 
     1168    #   if [ ${RET} -gt 0 ] ; then 
     1169    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1170    #       cat out_rsync 
     1171    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1172    #   fi 
     1173    #    else 
     1174    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1175    #   cat out_rsync 
     1176    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1177    #    fi 
     1178    #fi 
     1179 
     1180    #USUAL WAY 
     1181    if [ X${1} = X'/l' ] ; then 
     1182      (( RET=0 )) 
     1183      for target in ${dm_liste[*]} ; do 
     1184        local_file=$( basename ${target} ) 
     1185        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1186        (( RET = RET + $? )) 
     1187      done 
     1188    else 
     1189      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1190      RET=$? 
     1191    fi 
     1192 
     1193#       #RSYNC WITH NETWORK SSH CALL 
     1194#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
     1195#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
    10861196 
    10871197#       #RSYNC WITH NFS USE 
     
    10951205#       (( RET=RET+$? )) 
    10961206 
    1097         if [ ${RET} -gt 0 ] ; then 
    1098             echo "IGCM_sys_Get : copy error." 
    1099             cat out_rsync 
    1100 #           IGCM_debug_Exit "IGCM_sys_Get" 
    1101         else 
    1102             \rm out_rsync 
    1103         fi 
     1207    if [ ${RET} -gt 0 ] ; then 
     1208      echo "IGCM_sys_Get : copy error." 
     1209      cat out_rsync 
     1210#      IGCM_debug_Exit "IGCM_sys_Get" 
    11041211    else 
    1105         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1106     fi 
    1107     IGCM_debug_PopStack "IGCM_sys_Get" 
     1212      \rm out_rsync 
     1213    fi 
     1214  else 
     1215    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1216  fi 
     1217  IGCM_debug_PopStack "IGCM_sys_Get" 
     1218} 
     1219 
     1220#D-#================================================== 
     1221#D-function IGCM_sys_GetBuffer 
     1222#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1223#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1224#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1225function IGCM_sys_GetBuffer { 
     1226  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1227 
     1228  typeset DEST RET buf_liste ifile target file_work  
     1229 
     1230  if ( $DEBUG_sys ) ; then 
     1231    echo "IGCM_sys_GetBuffer :" $@ 
     1232  fi 
     1233  if [ $DRYRUN -le 2 ]; then 
     1234    if [ X${1} = X'/l' ] ; then 
     1235      # test if the first file is present in the old computation : 
     1236      eval set +A buf_liste \${${2}} 
     1237    else 
     1238      eval set +A buf_liste ${1} 
     1239    fi 
     1240    eval DEST=\${${#}} 
     1241 
     1242    #USUAL WAY 
     1243    if [ X${1} = X'/l' ] ; then 
     1244      (( RET=0 )) 
     1245      for target in ${buf_liste[*]} ; do 
     1246        local_file=$( basename ${target} ) 
     1247        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1248        (( RET = RET + $? )) 
     1249      done 
     1250    else 
     1251      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1252      RET=$? 
     1253    fi 
     1254 
     1255    if [ ${RET} -gt 0 ] ; then 
     1256      echo "IGCM_sys_GetBuffer : copy error." 
     1257      cat out_rsync 
     1258      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1259    else 
     1260      \rm out_rsync 
     1261    fi 
     1262  else 
     1263    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1264  fi 
     1265  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
     1266} 
     1267 
     1268#D-#================================================== 
     1269#D-function IGCM_sys_GetDate_FichWork 
     1270#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
     1271#D-* Examples: 
     1272#D- 
     1273function IGCM_sys_GetDate_FichWork { 
     1274  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1275  if ( $DEBUG_sys ) ; then 
     1276    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1277  fi 
     1278  # donne la date filesys d'un fichier sur la machine work 
     1279  IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1280} 
     1281 
     1282#D-#================================================== 
     1283#D-function IGCM_sys_GetDate_FichArchive 
     1284#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE  
     1285#D-* Examples: 
     1286#D- 
     1287function IGCM_sys_GetDate_FichArchive { 
     1288  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1289  if ( $DEBUG_sys ) ; then 
     1290    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1291  fi 
     1292  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    11081293} 
    11091294 
     
    11141299#D- 
    11151300function IGCM_sys_Dods_Rm { 
    1116     if ( $DEBUG_sys ) ; then 
    1117         echo "IGCM_sys_Dods_Rm :" $@ 
    1118     fi 
    1119     typeset RET 
    1120     RET=0 
    1121     if [ $DRYRUN = 0 ]; then 
    1122         if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then 
    1123             echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." 
    1124             echo "Nothing has been done." 
    1125             return 
    1126         fi 
    1127         dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 
    1128         RET=$? 
    1129          
     1301  if ( $DEBUG_sys ) ; then 
     1302    echo "IGCM_sys_Dods_Rm :" $@ 
     1303  fi 
     1304  typeset RET 
     1305  RET=0 
     1306  if [ $DRYRUN = 0 ]; then 
     1307    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then 
     1308      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." 
     1309      echo "Nothing has been done." 
     1310      return 
     1311    fi 
     1312    dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 
     1313    RET=$? 
     1314     
    11301315#       if [ ${RET} -gt 0 ] ; then 
    11311316#           echo "IGCM_sys_Dods_Rm : error." 
     
    11361321#       fi 
    11371322 
    1138     else 
    1139         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1140     fi 
    1141     return $RET 
    1142 } 
    1143  
     1323  else 
     1324    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1325  fi 
     1326  return $RET 
     1327} 
    11441328 
    11451329#D-#================================================== 
     
    11491333#D- 
    11501334function IGCM_sys_Dods_Cp { 
    1151     if ( $DEBUG_sys ) ; then 
    1152         echo "IGCM_sys_Dods_Cp :" $@ 
    1153     fi 
    1154     typeset RET 
    1155     RET=0 
    1156     if [ $DRYRUN = 0 ]; then 
    1157         if [ ! -d ${R_SAVE}/${1} ] ; then 
    1158             echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." 
    1159             echo "Nothing has been done." 
    1160             return 
    1161         fi 
    1162         # 
    1163         dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 
    1164         RET=$? 
    1165          
     1335  if ( $DEBUG_sys ) ; then 
     1336    echo "IGCM_sys_Dods_Cp :" $@ 
     1337  fi 
     1338  typeset RET 
     1339  RET=0 
     1340  if [ $DRYRUN = 0 ]; then 
     1341    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1342      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." 
     1343      echo "Nothing has been done." 
     1344      return 
     1345    fi 
     1346    # 
     1347    dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 
     1348    RET=$? 
     1349 
    11661350#       if [ ${RET} -gt 0 ] ; then 
    11671351#           echo "IGCM_sys_Dods_Cp : error." 
     
    11721356#       fi 
    11731357 
    1174     else 
    1175         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1176     fi 
    1177     return $RET 
     1358  else 
     1359    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1360  fi 
     1361  return $RET 
    11781362} 
    11791363 
     
    11841368#D- 
    11851369function IGCM_sys_Put_Dods { 
    1186     IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ 
    1187     if ( $DEBUG_sys ) ; then 
    1188         echo "IGCM_sys_Put_Dods :" $@ 
    1189     fi 
    1190     if [ $DRYRUN = 0 ]; then 
    1191         if [ ! -d ${R_SAVE}/${1} ] ; then 
    1192             echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." 
    1193             IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    1194             return 
    1195         fi 
    1196  
    1197         typeset RET 
     1370  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ 
     1371  if ( $DEBUG_sys ) ; then 
     1372    echo "IGCM_sys_Put_Dods :" $@ 
     1373  fi 
     1374  if [ $DRYRUN = 0 ]; then 
     1375    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1376      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." 
     1377      IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
     1378      return 
     1379    fi 
     1380 
     1381    typeset RET 
    11981382        # 
    1199         cd ${R_SAVE} 
    1200         IGCM_sys_Dods_Rm ${1} 
    1201         IGCM_sys_Dods_Cp ${1} 
    1202         RET=0 
    1203          
    1204         if [ ${RET} -gt 0 ] ; then 
    1205             echo "IGCM_sys_Put_Dods : error." 
    1206             IGCM_debug_Exit "IGCM_sys_Put_Dods" 
    1207         fi 
    1208     else 
    1209         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1210     fi 
    1211     IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    1212 } 
    1213  
    1214 ############################################################## A FINIR !! 
    1215  
    1216 #D-#================================================== 
    1217 #D-function IGCM_sys_GetDate_FichWork 
    1218 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
    1219 #D-* Examples: 
    1220 #D- 
    1221 function IGCM_sys_GetDate_FichWork { 
    1222     IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1223     if ( $DEBUG_sys ) ; then 
    1224         echo "IGCM_sys_GetDate_FichWork :" $@ 
    1225     fi 
    1226     # donne la date filesys d'un fichier sur la machine work 
    1227     IGCM_debug_PopStack "IGCM_sys_FichWork" 
    1228 } 
    1229  
    1230 #D-#================================================== 
    1231 #D-function IGCM_sys_GetDate_FichArchive 
    1232 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE  
    1233 #D-* Examples: 
    1234 #D- 
    1235 function IGCM_sys_GetDate_FichArchive { 
    1236     IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1237     if ( $DEBUG_sys ) ; then 
    1238         echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1239     fi 
    1240     IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1383    cd ${R_SAVE} 
     1384    IGCM_sys_Dods_Rm ${1} 
     1385    IGCM_sys_Dods_Cp ${1} 
     1386    RET=0 
     1387     
     1388    if [ ${RET} -gt 0 ] ; then 
     1389      echo "IGCM_sys_Put_Dods : error." 
     1390      IGCM_debug_Exit "IGCM_sys_Put_Dods" 
     1391    fi 
     1392  else 
     1393    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1394  fi 
     1395  IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    12411396} 
    12421397 
     
    12451400 
    12461401function IGCM_sys_rebuild { 
    1247     IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
    1248     if ( $DEBUG_sys ) ; then 
    1249         echo "IGCM_sys_rebuild :" $@ 
    1250     fi 
    1251     /home/cont003/p86ipsl/X86_64/bin/rebuild -f -o $@ 
    1252     if [ $? -gt 0 ] ; then 
    1253        echo "IGCM_sys_rebuild : erreur ${@}." 
    1254        IGCM_debug_Exit "rebuild" 
    1255     fi 
    1256  
    1257     IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1402  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1403  if ( $DEBUG_sys ) ; then 
     1404    echo "IGCM_sys_rebuild :" $@ 
     1405  fi 
     1406  /home/cont003/p86ipsl/X86_64/bin/rebuild -f -o $@ 
     1407  if [ $? -gt 0 ] ; then 
     1408    echo "IGCM_sys_rebuild : erreur ${@}." 
     1409    IGCM_debug_Exit "rebuild" 
     1410  fi 
     1411 
     1412  IGCM_debug_PopStack "IGCM_sys_rebuild" 
    12581413} 
    12591414 
     
    12621417 
    12631418function IGCM_sys_ncap2 { 
    1264     IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ 
    1265     if ( $DEBUG_sys ) ; then 
    1266         echo "IGCM_sys_ncap2 :" $@ 
    1267     fi 
    1268     ncap2 "$@" 
    1269     if [ $? -gt 0 ] ; then 
    1270        echo "IGCM_sys_ncap2 : erreur ${@}." 
    1271        IGCM_debug_Exit "ncap2" 
    1272     fi 
    1273  
    1274     IGCM_debug_PopStack "IGCM_sys_ncap2" 
     1419  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ 
     1420  if ( $DEBUG_sys ) ; then 
     1421    echo "IGCM_sys_ncap2 :" $@ 
     1422  fi 
     1423  ncap2 "$@" 
     1424  if [ $? -gt 0 ] ; then 
     1425    echo "IGCM_sys_ncap2 : erreur ${@}." 
     1426    IGCM_debug_Exit "ncap2" 
     1427  fi 
     1428 
     1429  IGCM_debug_PopStack "IGCM_sys_ncap2" 
    12751430} 
    12761431 
    12771432function IGCM_sys_ncatted { 
    1278     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
    1279     if ( $DEBUG_sys ) ; then 
    1280         echo "IGCM_sys_ncatted :" $@ 
    1281     fi 
    1282     ncatted "$@" 
    1283     if [ $? -gt 0 ] ; then 
    1284        echo "IGCM_sys_ncatted : erreur ${@}." 
    1285        IGCM_debug_Exit "ncatted" 
    1286     fi 
    1287  
    1288     IGCM_debug_PopStack "IGCM_sys_ncatted" 
     1433  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
     1434  if ( $DEBUG_sys ) ; then 
     1435    echo "IGCM_sys_ncatted :" $@ 
     1436  fi 
     1437  ncatted "$@" 
     1438  if [ $? -gt 0 ] ; then 
     1439    echo "IGCM_sys_ncatted : erreur ${@}." 
     1440    IGCM_debug_Exit "ncatted" 
     1441  fi 
     1442 
     1443  IGCM_debug_PopStack "IGCM_sys_ncatted" 
    12891444} 
    12901445 
    12911446function IGCM_sys_ncbo { 
    1292     IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
    1293     if ( $DEBUG_sys ) ; then 
    1294         echo "IGCM_sys_ncbo :" $@ 
    1295     fi 
    1296     ncbo $@ 
    1297     if [ $? -gt 0 ] ; then 
    1298        echo "IGCM_sys_ncbo : erreur ${@}." 
    1299        IGCM_debug_Exit "ncbo" 
    1300     fi 
    1301  
    1302     IGCM_debug_PopStack "IGCM_sys_ncbo" 
     1447  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
     1448  if ( $DEBUG_sys ) ; then 
     1449    echo "IGCM_sys_ncbo :" $@ 
     1450  fi 
     1451  ncbo $@ 
     1452  if [ $? -gt 0 ] ; then 
     1453    echo "IGCM_sys_ncbo : erreur ${@}." 
     1454    IGCM_debug_Exit "ncbo" 
     1455  fi 
     1456 
     1457  IGCM_debug_PopStack "IGCM_sys_ncbo" 
    13031458} 
    13041459 
    13051460function IGCM_sys_ncdiff { 
    1306     IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
    1307     if ( $DEBUG_sys ) ; then 
    1308         echo "IGCM_sys_ncdiff :" $@ 
    1309     fi 
    1310     ncdiff $@ 
    1311     if [ $? -gt 0 ] ; then 
    1312        echo "IGCM_sys_ncdiff : erreur ${@}." 
    1313        IGCM_debug_Exit "ncdiff" 
    1314     fi 
    1315  
    1316     IGCM_debug_PopStack "IGCM_sys_ncdiff" 
     1461  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
     1462  if ( $DEBUG_sys ) ; then 
     1463    echo "IGCM_sys_ncdiff :" $@ 
     1464  fi 
     1465  ncdiff $@ 
     1466  if [ $? -gt 0 ] ; then 
     1467    echo "IGCM_sys_ncdiff : erreur ${@}." 
     1468    IGCM_debug_Exit "ncdiff" 
     1469  fi 
     1470 
     1471  IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    13171472} 
    13181473 
    13191474function IGCM_sys_ncea { 
    1320     IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
    1321     if ( $DEBUG_sys ) ; then 
    1322         echo "IGCM_sys_ncea :" $@ 
    1323     fi 
    1324     ncea $@ 
    1325     if [ $? -gt 0 ] ; then 
    1326        echo "IGCM_sys_ncea : erreur ${@}." 
    1327        IGCM_debug_Exit "ncea" 
    1328     fi 
    1329  
    1330     IGCM_debug_PopStack "IGCM_sys_ncea" 
     1475  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
     1476  if ( $DEBUG_sys ) ; then 
     1477    echo "IGCM_sys_ncea :" $@ 
     1478  fi 
     1479  ncea $@ 
     1480  if [ $? -gt 0 ] ; then 
     1481    echo "IGCM_sys_ncea : erreur ${@}." 
     1482    IGCM_debug_Exit "ncea" 
     1483  fi 
     1484 
     1485  IGCM_debug_PopStack "IGCM_sys_ncea" 
    13311486} 
    13321487 
    13331488function IGCM_sys_ncecat { 
    1334     IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
    1335     if ( $DEBUG_sys ) ; then 
    1336         echo "IGCM_sys_ncecat :" $@ 
    1337     fi 
    1338     ncecat $@ 
    1339     if [ $? -gt 0 ] ; then 
    1340        echo "IGCM_sys_ncecat : erreur ${@}." 
    1341        IGCM_debug_Exit "ncecat" 
    1342     fi 
    1343  
    1344     IGCM_debug_PopStack "IGCM_sys_ncecat" 
     1489  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
     1490  if ( $DEBUG_sys ) ; then 
     1491    echo "IGCM_sys_ncecat :" $@ 
     1492  fi 
     1493  ncecat $@ 
     1494  if [ $? -gt 0 ] ; then 
     1495    echo "IGCM_sys_ncecat : erreur ${@}." 
     1496    IGCM_debug_Exit "ncecat" 
     1497  fi 
     1498 
     1499  IGCM_debug_PopStack "IGCM_sys_ncecat" 
    13451500} 
    13461501 
    13471502function IGCM_sys_ncflint { 
    1348     IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
    1349     if ( $DEBUG_sys ) ; then 
    1350         echo "IGCM_sys_ncflint :" $@ 
    1351     fi 
    1352     ncflint $@ 
    1353     if [ $? -gt 0 ] ; then 
    1354        echo "IGCM_sys_ncflint : erreur ${@}." 
    1355        IGCM_debug_Exit "ncflint" 
    1356     fi 
    1357  
    1358     IGCM_debug_PopStack "IGCM_sys_ncflint" 
     1503  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
     1504  if ( $DEBUG_sys ) ; then 
     1505    echo "IGCM_sys_ncflint :" $@ 
     1506  fi 
     1507  ncflint $@ 
     1508  if [ $? -gt 0 ] ; then 
     1509    echo "IGCM_sys_ncflint : erreur ${@}." 
     1510    IGCM_debug_Exit "ncflint" 
     1511  fi 
     1512 
     1513  IGCM_debug_PopStack "IGCM_sys_ncflint" 
    13591514} 
    13601515 
    13611516function IGCM_sys_ncks { 
    1362     IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
    1363     if ( $DEBUG_sys ) ; then 
    1364         echo "IGCM_sys_ncks :" $@ 
    1365     fi 
    1366     ncks $@ 
    1367     if [ $? -gt 0 ] ; then 
    1368        echo "IGCM_sys_ncks : erreur ${@}." 
    1369        IGCM_debug_Exit "ncks" 
    1370     fi 
    1371  
    1372     IGCM_debug_PopStack "IGCM_sys_ncks" 
     1517  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
     1518  if ( $DEBUG_sys ) ; then 
     1519    echo "IGCM_sys_ncks :" $@ 
     1520  fi 
     1521  ncks $@ 
     1522  if [ $? -gt 0 ] ; then 
     1523    echo "IGCM_sys_ncks : erreur ${@}." 
     1524    IGCM_debug_Exit "ncks" 
     1525  fi 
     1526 
     1527  IGCM_debug_PopStack "IGCM_sys_ncks" 
    13731528} 
    13741529 
    13751530function IGCM_sys_ncpdq { 
    1376     IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
    1377     if ( $DEBUG_sys ) ; then 
    1378         echo "IGCM_sys_ncpdq :" $@ 
    1379     fi 
    1380     ncpdq $@ 
    1381     if [ $? -gt 0 ] ; then 
    1382        echo "IGCM_sys_ncpdq : erreur ${@}." 
    1383        IGCM_debug_Exit "ncpdq" 
    1384     fi 
    1385  
    1386     IGCM_debug_PopStack "IGCM_sys_ncpdq" 
     1531  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
     1532  if ( $DEBUG_sys ) ; then 
     1533    echo "IGCM_sys_ncpdq :" $@ 
     1534  fi 
     1535  ncpdq $@ 
     1536  if [ $? -gt 0 ] ; then 
     1537    echo "IGCM_sys_ncpdq : erreur ${@}." 
     1538    IGCM_debug_Exit "ncpdq" 
     1539  fi 
     1540 
     1541  IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    13871542} 
    13881543 
    13891544function IGCM_sys_ncra { 
    1390     IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
    1391     if ( $DEBUG_sys ) ; then 
    1392         echo "IGCM_sys_ncra :" $@ 
    1393     fi 
    1394     ncra $@ 
    1395     if [ $? -gt 0 ] ; then 
    1396        echo "IGCM_sys_ncra : erreur ${@}." 
    1397        IGCM_debug_Exit "ncra" 
    1398     fi 
    1399  
    1400     IGCM_debug_PopStack "IGCM_sys_ncra" 
     1545  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
     1546  if ( $DEBUG_sys ) ; then 
     1547    echo "IGCM_sys_ncra :" $@ 
     1548  fi 
     1549  ncra $@ 
     1550  if [ $? -gt 0 ] ; then 
     1551    echo "IGCM_sys_ncra : erreur ${@}." 
     1552    IGCM_debug_Exit "ncra" 
     1553  fi 
     1554 
     1555  IGCM_debug_PopStack "IGCM_sys_ncra" 
    14011556} 
    14021557 
    14031558function IGCM_sys_ncrcat { 
    1404     IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
    1405     if ( $DEBUG_sys ) ; then 
    1406         echo "IGCM_sys_ncrcat :" $@ 
    1407     fi 
    1408     ncrcat $@ 
    1409     if [ $? -gt 0 ] ; then 
    1410        echo "IGCM_sys_ncrcat : erreur ${@}." 
     1559  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
     1560  if ( $DEBUG_sys ) ; then 
     1561    echo "IGCM_sys_ncrcat :" $@ 
     1562  fi 
     1563  ncrcat $@ 
     1564  if [ $? -gt 0 ] ; then 
     1565    echo "IGCM_sys_ncrcat : erreur ${@}." 
    14111566#       IGCM_debug_Exit "ncrcat" 
    1412     fi 
    1413  
    1414     IGCM_debug_PopStack "IGCM_sys_ncrcat" 
     1567  fi 
     1568 
     1569  IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    14151570} 
    14161571 
    14171572function IGCM_sys_ncrename { 
    1418     IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
    1419     if ( $DEBUG_sys ) ; then 
    1420         echo "IGCM_sys_ncrename :" $@ 
    1421     fi 
    1422     ncrename $@ 
    1423     if [ $? -gt 0 ] ; then 
    1424        echo "IGCM_sys_ncrename : erreur ${@}." 
    1425        IGCM_debug_Exit "ncrename" 
    1426     fi 
    1427  
    1428     IGCM_debug_PopStack "IGCM_sys_ncrename" 
     1573  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
     1574  if ( $DEBUG_sys ) ; then 
     1575    echo "IGCM_sys_ncrename :" $@ 
     1576  fi 
     1577  ncrename $@ 
     1578  if [ $? -gt 0 ] ; then 
     1579    echo "IGCM_sys_ncrename : erreur ${@}." 
     1580    IGCM_debug_Exit "ncrename" 
     1581  fi 
     1582 
     1583  IGCM_debug_PopStack "IGCM_sys_ncrename" 
    14291584} 
    14301585 
    14311586function IGCM_sys_ncwa { 
    1432     IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
    1433     if ( $DEBUG_sys ) ; then 
    1434         echo "IGCM_sys_ncwa :" $@ 
    1435     fi 
    1436     ncwa $@ 
    1437     if [ $? -gt 0 ] ; then 
    1438        echo "IGCM_sys_ncwa : erreur ${@}." 
    1439        IGCM_debug_Exit "ncwa" 
    1440     fi 
    1441  
    1442     IGCM_debug_PopStack "IGCM_sys_ncwa" 
     1587  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
     1588  if ( $DEBUG_sys ) ; then 
     1589    echo "IGCM_sys_ncwa :" $@ 
     1590  fi 
     1591  ncwa $@ 
     1592  if [ $? -gt 0 ] ; then 
     1593    echo "IGCM_sys_ncwa : erreur ${@}." 
     1594    IGCM_debug_Exit "ncwa" 
     1595  fi 
     1596 
     1597  IGCM_debug_PopStack "IGCM_sys_ncwa" 
    14431598} 
    14441599 
     
    14471602 
    14481603function IGCM_sys_cdo { 
    1449     IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ 
    1450  
    1451     \cdo $@ 
    1452     if [ $? -gt 0 ] ; then 
    1453        echo "IGCM_sys_cdo : erreur ${@}." 
    1454        IGCM_debug_PopStack "IGCM_sys_cdo" 
    1455        return 1 
    1456     else 
    1457         IGCM_debug_PopStack "IGCM_sys_cdo" 
    1458         return 0 
    1459     fi 
    1460  
     1604  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ 
     1605  if ( $DEBUG_sys ) ; then 
     1606    echo "IGCM_sys_cdo :" $@ 
     1607  fi 
     1608  \cdo $@ 
     1609  if [ $? -gt 0 ] ; then 
     1610    echo "IGCM_sys_cdo : erreur ${@}." 
    14611611    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1612    return 1 
     1613  else 
     1614    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1615    return 0 
     1616  fi 
     1617 
     1618  IGCM_debug_PopStack "IGCM_sys_cdo" 
    14621619} 
    14631620 
     
    14661623 
    14671624function IGCM_sys_activ_variables { 
    1468     IGCM_debug_PushStack "IGCM_sys_activ_variables" 
    1469     if ( $DEBUG_sys ) ; then 
    1470         echo "IGCM_sys_activ_variables" 
    1471     fi 
    1472     IGCM_debug_PopStack "IGCM_sys_activ_variables" 
     1625  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1626  if ( $DEBUG_sys ) ; then 
     1627    echo "IGCM_sys_activ_variables" 
     1628  fi 
     1629  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    14731630} 
    14741631 
     
    14771634 
    14781635function IGCM_sys_desactiv_variables { 
    1479     IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
    1480     if ( $DEBUG_sys ) ; then 
    1481         echo "IGCM_sys_desactiv_variables" 
    1482     fi 
    1483     IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
     1636  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1637  if ( $DEBUG_sys ) ; then 
     1638    echo "IGCM_sys_desactiv_variables" 
     1639  fi 
     1640  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
    14841641} 
    14851642 
     
    14881645 
    14891646function IGCM_sys_build_run_file { 
    1490     IGCM_debug_PushStack "IGCM_sys_build_run_file" 
    1491     if ( $DEBUG_sys ) ; then 
    1492         echo "IGCM_sys_build_run_file" 
    1493     fi 
    1494     IGCM_debug_PopStack "IGCM_sys_build_run_file" 
    1495 } 
     1647  IGCM_debug_PushStack "IGCM_sys_build_run_file" 
     1648  if ( $DEBUG_sys ) ; then 
     1649    echo "IGCM_sys_build_run_file" 
     1650  fi 
     1651  IGCM_debug_PopStack "IGCM_sys_build_run_file" 
     1652} 
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex8.ksh

    r539 r544  
    137137 
    138138#==================================================== 
    139 #- OUT 
     139#- R_OUT 
    140140typeset -r R_OUT=${ARCHIVE}/IGCM_OUT 
     141 
     142#==================================================== 
     143#- R_BUF (ONLY FOR double copy an scratch) 
     144typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT 
     145 
     146#==================================================== 
     147#- BIG_DIR : BIG_DIR to store files waiting for rebuild 
     148typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    141149 
    142150#==================================================== 
     
    149157 
    150158#==================================================== 
    151 #- BIG_DIR : BIG_DIR to store files waiting for rebuild 
    152 typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    153  
    154 #==================================================== 
    155159#- HOST_MPIRUN_COMMAND 
    156160typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="mpirun"} 
     
    166170#D- 
    167171function IGCM_sys_RshMaster { 
    168     IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    169     ssh -t ${MASTER} /bin/ksh <<-EOF 
    170     export libIGCM=${libIGCM} 
    171     export DEBUG_debug=${DEBUG_debug} 
    172     . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
    173     . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
     172  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
     173  ssh -t ${MASTER} /bin/ksh <<-EOF 
     174  export libIGCM=${libIGCM} 
     175  export DEBUG_debug=${DEBUG_debug} 
     176  . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
     177  . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
     178  ${@} 
     179EOF 
     180  if [ $? -gt 0 ] ; then 
     181    echo "IGCM_sys_RshMaster : erreur." 
     182    IGCM_debug_Exit "IGCM_sys_RshMaster" 
     183  fi 
     184  IGCM_debug_PopStack "IGCM_sys_RshMaster" 
     185} 
     186 
     187#D-#================================================== 
     188#D-function IGCM_sys_RshArchive 
     189#D-* Purpose: Archive rsh command 
     190#D-* Examples: 
     191#D- 
     192function IGCM_sys_RshArchive { 
     193  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
     194  /bin/ksh <<-EOF 
    174195    ${@} 
    175196EOF 
    176     if [ $? -gt 0 ] ; then 
    177         echo "IGCM_sys_RshMaster : erreur." 
    178         IGCM_debug_Exit "IGCM_sys_RshMaster" 
    179     fi 
    180     IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    181 } 
    182  
    183 #D-#================================================== 
    184 #D-function IGCM_sys_RshArchive 
    185 #D-* Purpose: Archive rsh command 
    186 #D-* Examples: 
    187 #D- 
    188 function IGCM_sys_RshArchive { 
    189     IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    190     /bin/ksh <<-EOF 
    191 ${@} 
    192 EOF 
    193     if [ $? -gt 0 ] ; then 
    194         echo "IGCM_sys_RshArchive : erreur." 
    195         IGCM_debug_Exit "IGCM_sys_RshArchive" 
    196     fi 
    197     IGCM_debug_PopStack "IGCM_sys_RshArchive" 
     197  if [ $? -gt 0 ] ; then 
     198    echo "IGCM_sys_RshArchive : erreur." 
     199    IGCM_debug_Exit "IGCM_sys_RshArchive" 
     200  fi 
     201  IGCM_debug_PopStack "IGCM_sys_RshArchive" 
    198202} 
    199203 
     
    204208#D- 
    205209function IGCM_sys_RshPost { 
    206     IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    207     if ( $DEBUG_sys ) ; then 
    208         echo "IGCM_sys_RshPost :" $@ 
    209     fi 
     210  IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
     211  if ( $DEBUG_sys ) ; then 
     212    echo "IGCM_sys_RshPost :" $@ 
     213  fi 
     214 
     215  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL 
     216  #cat tmp_IGCM_sys_RshPost_$$ 
     217  # keep standard input (stdin) for the loop onto temporary file 
     218  cat >tmp_IGCM_sys_RshPost_$$ 
     219 
     220# ============ FRONTEND START ============ # 
     221 
     222  /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     223  if [ $? -gt 0 ] ; then 
     224    echo "IGCM_sys_RshPost : erreur." 
     225    IGCM_debug_Exit "IGCM_sys_RshPost" 
     226  fi 
     227  \rm tmp_IGCM_sys_RshPost_$$ 
     228 
     229# ============ FRONTEND  END  ============ # 
    210230 
    211231# ============ CESIUM START ============ # 
    212 #    typeset NB_ESSAI DELAI status 
    213 #    #nombre d'essai avant abandon 
    214 #    NB_ESSAI=5 
    215 #    #temps entre chaque essai 
    216 #    DELAI=10 
    217 #    i=0 
    218 #    while [ $i -ne $NB_ESSAI ] ; do 
    219 #        ssh -t mercure ssh cesium /bin/ksh ${@} 2>/dev/null 
    220 #        status=$? 
    221 #        if [ ${status} -ne 0 ]; 
    222 #        then 
    223 #            sleep $DELAI 
    224 #        else 
    225 #            break 
    226 #        fi 
    227 #        let i=$i+1 
    228 #    done  
     232#  typeset NB_ESSAI DELAI status i 
     233#  # number of tentative 
     234#  NB_ESSAI=10 
     235#  # time delay between tentative 
     236#  DELAI=10 
     237#  (( i = 0 )) 
     238#  while [ $i -lt $NB_ESSAI ] ; do 
     239#    ssh -t mercure01 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     240#    status=$? 
     241#    if [ ${status} -gt 0 ]; then 
     242#      IGCM_debug_Print 2 "IGCM_sys_RshPost : ssh failed ${i}/${NB_ESSAI}" 
     243#      IGCM_debug_Print 2 "IGCM_sys_RshPost : sleep ${DELAI} seconds and try again." 
     244#      sleep $DELAI 
     245#    else 
     246#      break 
     247#    fi 
     248#    (( i = i + 1 )) 
     249#  done  
     250#  # delete temporary file 
     251#  /bin/rm tmp_IGCM_sys_RshPost_$$ 
    229252# ============ CESIUM  END  ============ # 
    230253 
    231     /bin/ksh ${@} 
    232     if [ $? -gt 0 ] ; then 
    233         echo "IGCM_sys_RshPost : erreur." 
    234         IGCM_debug_Exit "IGCM_sys_RshPost" 
    235     fi 
    236     IGCM_debug_PopStack "IGCM_sys_RshPost" 
     254  IGCM_debug_PopStack "IGCM_sys_RshPost" 
    237255} 
    238256 
     
    243261#D- 
    244262function IGCM_sys_SendMail { 
    245     IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    246     if ( $DEBUG_sys ) ; then 
    247         echo "IGCM_sys_SendMail :" $@ 
    248     fi 
    249  
    250     if ( ${ExitFlag} ) ; then 
    251         status=failed 
    252         # Nothing fo now 
    253     else 
    254         status=completed 
    255     fi 
    256  
    257     ssh ${MASTER} /bin/ksh <<-EOF 
    258     export LOGIN=${LOGIN} 
    259     export config_UserChoices_JobName=${config_UserChoices_JobName} 
    260     export config_UserChoices_MailName=${config_UserChoices_MailName} 
    261     export DateBegin=${DateBegin} 
    262     export DateEnd=${DateEnd} 
    263     export R_SAVE=${R_SAVE} 
    264     export SUBMIT_DIR=${SUBMIT_DIR} 
    265     export status=${status} 
    266  
    267     cat  << END_MAIL > job_end.mail 
    268 Dear ${LOGIN}, 
     263  IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
     264  if ( $DEBUG_sys ) ; then 
     265    echo "IGCM_sys_SendMail :" $@ 
     266  fi 
     267 
     268  if ( ${ExitFlag} ) ; then 
     269    status=failed 
     270  else 
     271    status=completed 
     272  fi 
     273 
     274  ssh ${MASTER} /bin/ksh <<-EOF 
     275  export LOGIN=${LOGIN} 
     276  export config_UserChoices_JobName=${config_UserChoices_JobName} 
     277  export config_UserChoices_MailName=${config_UserChoices_MailName} 
     278  export DateBegin=${DateBegin} 
     279  export DateEnd=${DateEnd} 
     280  export R_SAVE=${R_SAVE} 
     281  export SUBMIT_DIR=${SUBMIT_DIR} 
     282  export status=${status} 
     283 
     284  cat  << END_MAIL > job_end.mail 
     285  Dear ${LOGIN}, 
    269286 
    270287  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`. 
     
    275292END_MAIL 
    276293 
    277     if [ ! -z ${config_UserChoices_MailName} ] ; then 
    278        mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail 
    279     elif [ -f ~/.forward ] ; then 
    280        mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
    281     fi 
    282  
    283     sleep 10 
    284     rm -f job_end.mail 
     294  if  [ X"${config_UserChoices_MailName}" != X ] ; then 
     295    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail 
     296  elif [ -f ~/.forward ] ; then 
     297    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
     298  fi 
     299 
     300  sleep 10 
     301  rm -f job_end.mail 
    285302EOF 
    286303 
    287     if [ $? -gt 0 ] ; then 
    288         echo "IGCM_sys_SendMail : erreur." 
    289         IGCM_debug_Exit "IGCM_sys_SendMail" 
    290     fi 
    291     IGCM_debug_PopStack "IGCM_sys_SendMail" 
     304  if [ $? -gt 0 ] ; then 
     305    echo "IGCM_sys_SendMail : erreur." 
     306    IGCM_debug_Exit "IGCM_sys_SendMail" 
     307  fi 
     308  IGCM_debug_PopStack "IGCM_sys_SendMail" 
    292309} 
    293310 
     
    298315#D- 
    299316function IGCM_sys_Mkdir { 
    300     IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    301     if ( $DEBUG_sys ) ; then 
    302         echo "IGCM_sys_Mkdir :" $@ 
    303     fi 
    304     if [ ! -d ${1} ]; then 
    305         \mkdir -p $1 
    306         if [ $? -gt 0 ] ; then 
    307             echo "IGCM_sys_Mkdir : erreur." 
    308             IGCM_debug_Exit "IGCM_sys_Mkdir" 
    309         fi 
    310     fi 
    311     # vérification : 
    312     if [ ! -d ${1} ] ; then 
    313         echo "IGCM_sys_Mkdir : erreur." 
    314         IGCM_debug_Exit "IGCM_sys_Mkdir" 
    315     fi 
    316     IGCM_debug_PopStack "IGCM_sys_Mkdir" 
     317  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
     318  if ( $DEBUG_sys ) ; then 
     319    echo "IGCM_sys_Mkdir :" $@ 
     320  fi 
     321  if [ ! -d ${1} ]; then 
     322    \mkdir -p $1 
     323    if [ $? -gt 0 ] ; then 
     324      echo "IGCM_sys_Mkdir : erreur." 
     325      IGCM_debug_Exit "IGCM_sys_Mkdir" 
     326    fi 
     327  fi 
     328  # vérification : 
     329  if [ ! -d ${1} ] ; then 
     330    echo "IGCM_sys_Mkdir : erreur." 
     331    IGCM_debug_Exit "IGCM_sys_Mkdir" 
     332  fi 
     333  IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    317334} 
    318335 
     
    323340#D- 
    324341function IGCM_sys_MkdirArchive { 
    325     IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
    326     if ( $DEBUG_sys ) ; then 
    327         echo "IGCM_sys_MkdirArchive :" $@ 
    328     fi 
    329     #- creation de repertoire sur le serveur fichier 
    330     if [ ! -d ${1} ]; then  
    331         \mkdir -p $1 
    332         if [ $? -gt 0 ] ; then 
    333             echo "IGCM_sys_MkdirArchive : erreur." 
    334             IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
    335         fi 
    336     fi 
    337     IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
     342  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
     343  if ( $DEBUG_sys ) ; then 
     344    echo "IGCM_sys_MkdirArchive :" $@ 
     345  fi 
     346  #- creation de repertoire sur le serveur fichier 
     347  if [ ! -d ${1} ]; then  
     348    \mkdir -p $1 
     349    if [ $? -gt 0 ] ; then 
     350      echo "IGCM_sys_MkdirArchive : erreur." 
     351      IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
     352    fi 
     353  fi 
     354  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    338355} 
    339356 
     
    344361#D- 
    345362function IGCM_sys_MkdirWork { 
    346     IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    347     if ( $DEBUG_sys ) ; then 
    348         echo "IGCM_sys_MkdirWork :" $@ 
    349     fi 
    350     #- creation de repertoire sur le serveur fichier 
    351     if [ ! -d ${1} ]; then  
    352         \mkdir -p $1 
    353         if [ $? -gt 0 ] ; then 
    354             echo "IGCM_sys_MkdirWork : erreur." 
    355             IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    356         fi 
    357     fi 
    358     IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
     363  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
     364  if ( $DEBUG_sys ) ; then 
     365    echo "IGCM_sys_MkdirWork :" $@ 
     366  fi 
     367  #- creation de repertoire sur le serveur fichier 
     368  if [ ! -d ${1} ]; then  
     369    \mkdir -p $1 
     370    if [ $? -gt 0 ] ; then 
     371      echo "IGCM_sys_MkdirWork : erreur." 
     372      IGCM_debug_Exit "IGCM_sys_MkdirWork" 
     373    fi 
     374  fi 
     375  IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    359376} 
    360377 
     
    365382#D- 
    366383function IGCM_sys_Cd { 
    367     IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    368     if ( $DEBUG_sys ) ; then 
    369         echo "IGCM_sys_Cd :" $@ 
    370     fi 
    371     \cd $1 
    372     if [ $? -gt 0 ] ; then 
    373         echo "IGCM_sys_Cd : erreur." 
    374         IGCM_debug_Exit "IGCM_sys_Cd" 
    375     fi 
    376     IGCM_debug_PopStack "IGCM_sys_Cd" 
     384  IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
     385  if ( $DEBUG_sys ) ; then 
     386    echo "IGCM_sys_Cd :" $@ 
     387  fi 
     388  \cd $1 
     389  if [ $? -gt 0 ] ; then 
     390    echo "IGCM_sys_Cd : erreur." 
     391    IGCM_debug_Exit "IGCM_sys_Cd" 
     392  fi 
     393  IGCM_debug_PopStack "IGCM_sys_Cd" 
    377394} 
    378395 
     
    383400#D- 
    384401function IGCM_sys_Chmod { 
    385     IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
    386     if ( $DEBUG_sys ) ; then 
    387         echo "IGCM_sys_Chmod :" $@ 
    388     fi 
    389     if [ $DRYRUN -le 1 ]; then 
    390         \chmod $@ 
    391         if [ $? -gt 0 ] ; then 
    392             echo "IGCM_sys_Chmod : erreur." 
    393             IGCM_debug_Exit "IGCM_sys_Chmod" 
    394         fi 
    395     else 
    396         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    397     fi 
    398     IGCM_debug_PopStack "IGCM_sys_Chmod" 
     402  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
     403  if ( $DEBUG_sys ) ; then 
     404    echo "IGCM_sys_Chmod :" $@ 
     405  fi 
     406  if [ $DRYRUN -le 1 ]; then 
     407    \chmod $@ 
     408    if [ $? -gt 0 ] ; then 
     409      echo "IGCM_sys_Chmod : erreur." 
     410      IGCM_debug_Exit "IGCM_sys_Chmod" 
     411    fi 
     412  else 
     413    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     414  fi 
     415  IGCM_debug_PopStack "IGCM_sys_Chmod" 
    399416} 
    400417 
     
    405422#D- 
    406423function IGCM_sys_FileSize { 
    407     IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    408  
    409     typeset sizeF 
    410     set +A sizeF -- $( ls -la ${1} ) 
    411     if [ $? -gt 0 ] ; then 
    412         IGCM_debug_Exit "IGCM_sys_FileSize" 
    413     fi 
    414     eval ${2}=${sizeF[4]} 
    415  
    416     IGCM_debug_PopStack "IGCM_sys_FileSize" 
     424  IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
     425 
     426  typeset sizeF 
     427  set +A sizeF -- $( ls -la ${1} ) 
     428  if [ $? -gt 0 ] ; then 
     429    IGCM_debug_Exit "IGCM_sys_FileSize" 
     430  fi 
     431  eval ${2}=${sizeF[4]} 
     432 
     433  IGCM_debug_PopStack "IGCM_sys_FileSize" 
    417434} 
    418435 
     
    423440#D- 
    424441function IGCM_sys_TestDir { 
    425     IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    426     if ( $DEBUG_sys ) ; then 
    427         echo "IGCM_sys_TestDir :" $@ 
    428     fi 
    429     typeset ExistFlag 
    430     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    431     IGCM_debug_PopStack "IGCM_sys_TestDir" 
    432  
    433     return ${ExistFlag} 
     442  IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
     443  if ( $DEBUG_sys ) ; then 
     444    echo "IGCM_sys_TestDir :" $@ 
     445  fi 
     446  typeset ExistFlag 
     447  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     448  IGCM_debug_PopStack "IGCM_sys_TestDir" 
     449 
     450  return ${ExistFlag} 
    434451} 
    435452 
     
    440457#D- 
    441458function IGCM_sys_TestDirArchive { 
    442     IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
    443     if ( $DEBUG_sys ) ; then 
    444         echo "IGCM_sys_TestDirArchive :" $@ 
    445     fi 
    446     typeset ExistFlag 
    447     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    448     IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
    449  
    450     return ${ExistFlag} 
     459  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
     460  if ( $DEBUG_sys ) ; then 
     461    echo "IGCM_sys_TestDirArchive :" $@ 
     462  fi 
     463  typeset ExistFlag 
     464  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     465  IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
     466 
     467  return ${ExistFlag} 
    451468} 
    452469 
     
    457474#D- 
    458475function IGCM_sys_TestFileArchive { 
    459     IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    460     typeset ExistFlag 
    461     ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    462     IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    463  
    464     return ${ExistFlag} 
     476  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
     477  if ( $DEBUG_sys ) ; then 
     478    echo "IGCM_sys_TestFileArchive :" $@ 
     479  fi 
     480  typeset ExistFlag 
     481  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     482  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
     483 
     484  return ${ExistFlag} 
     485} 
     486 
     487#D-#================================================== 
     488#D-function IGCM_sys_TestFileBuffer 
     489#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     490#D-* Examples: 
     491#D- 
     492function IGCM_sys_TestFileBuffer { 
     493  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     494  typeset ExistFlag 
     495  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     496  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     497 
     498  return ${ExistFlag} 
    465499} 
    466500 
     
    471505#D- 
    472506function IGCM_sys_CountFileArchive { 
    473     IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
    474     ls ${@} 2>/dev/null | wc -l 
    475     if [ $? -gt 0 ] ; then 
    476         echo "IGCM_sys_CountFileArchive : erreur." 
    477     fi 
    478     IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     507  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
     508  ls ${@} 2>/dev/null | wc -l 
     509  if [ $? -gt 0 ] ; then 
     510    echo "IGCM_sys_CountFileArchive : erreur." 
     511  fi 
     512  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     513} 
     514 
     515#D-#================================================== 
     516#D-function IGCM_sys_CountFileBuffer 
     517#D-* Purpose: Count files on Scratch filesystem 
     518#D-* Examples: 
     519#D- 
     520function IGCM_sys_CountFileBuffer { 
     521  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     522  ls ${@} 2>/dev/null | wc -l 
     523  if [ $? -gt 0 ] ; then 
     524    echo "IGCM_sys_CountFileBuffer : erreur." 
     525  fi 
     526  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    479527} 
    480528 
     
    485533#D- 
    486534function IGCM_sys_Tree { 
    487     IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
    488     if ( $DEBUG_sys ) ; then 
    489         echo "IGCM_sys_Tree :" $@ 
    490     fi 
    491  
    492     \ls -lR ${@} 
    493  
    494     IGCM_debug_PopStack "IGCM_sys_Tree" 
     535  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     536  if ( $DEBUG_sys ) ; then 
     537    echo "IGCM_sys_Tree :" $@ 
     538  fi 
     539 
     540  \ls -lR ${@} 
     541 
     542  IGCM_debug_PopStack "IGCM_sys_Tree" 
    495543} 
    496544 
    497545#D-#================================================== 
    498546#D-function IGCM_sys_Tar 
    499 #D-* Purpose: master un-tar command 
     547#D-* Purpose: master tar command 
    500548#D-* Examples: 
    501549#D- 
    502550function IGCM_sys_Tar { 
    503     IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    504     if ( $DEBUG_sys ) ; then 
    505         echo "IGCM_sys_Tar :" $@ 
    506     fi 
    507     \tar cf $@ 
    508     if [ $? -gt 0 ] ; then 
    509         echo "IGCM_sys_Tar : erreur." 
    510         IGCM_debug_Exit "IGCM_sys_Tar" 
    511     fi 
    512     IGCM_debug_PopStack "IGCM_sys_Tar" 
     551  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     552  if ( $DEBUG_sys ) ; then 
     553    echo "IGCM_sys_Tar :" $@ 
     554  fi 
     555  \tar cf $@ 
     556  if [ $? -gt 0 ] ; then 
     557    echo "IGCM_sys_Tar : erreur." 
     558    IGCM_debug_Exit "IGCM_sys_Tar" 
     559  fi 
     560  IGCM_debug_PopStack "IGCM_sys_Tar" 
    513561} 
    514562 
     
    519567#D- 
    520568function IGCM_sys_UnTar { 
    521     IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    522     if ( $DEBUG_sys ) ; then 
    523         echo "IGCM_sys_UnTar :" $@ 
    524     fi 
    525     \tar xvf $1 
    526     if [ $? -gt 0 ] ; then 
    527         echo "IGCM_sys_UnTar : erreur." 
    528         IGCM_debug_Exit "IGCM_sys_UnTar" 
    529     fi 
    530     IGCM_debug_PopStack "IGCM_sys_UnTar" 
     569  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     570  if ( $DEBUG_sys ) ; then 
     571    echo "IGCM_sys_UnTar :" $@ 
     572  fi 
     573  \tar xvf $1 
     574  if [ $? -gt 0 ] ; then 
     575    echo "IGCM_sys_UnTar : erreur." 
     576    IGCM_debug_Exit "IGCM_sys_UnTar" 
     577  fi 
     578  IGCM_debug_PopStack "IGCM_sys_UnTar" 
    531579} 
    532580 
     
    537585#D- 
    538586function IGCM_sys_Qsub { 
    539     IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
    540     if ( $DEBUG_sys ) ; then 
    541         echo "IGCM_sys_Qsub :" $@ 
    542     fi 
    543     /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1 
    544     if [ $? -gt 0 ] ; then 
    545         echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@." 
    546         IGCM_debug_Exit "IGCM_sys_Qsub" 
    547     fi 
    548     IGCM_debug_PopStack "IGCM_sys_Qsub" 
     587  IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
     588  if ( $DEBUG_sys ) ; then 
     589    echo "IGCM_sys_Qsub :" $@ 
     590  fi 
     591  /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1 
     592  if [ $? -gt 0 ] ; then 
     593    echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@." 
     594    IGCM_debug_Exit "IGCM_sys_Qsub" 
     595  fi 
     596  IGCM_debug_PopStack "IGCM_sys_Qsub" 
    549597} 
    550598 
     
    555603#D- 
    556604function IGCM_sys_QsubPost { 
    557     IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
    558     if ( $DEBUG_sys ) ; then 
    559         echo "IGCM_sys_QsubPost :" $@ 
    560     fi 
    561     # ============ CESIUM START ============ # 
    562     #/usr/local/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.e.out -E "-v ${listVarEnv}" ${libIGCM_POST}/$1.job 
    563     # ============ CESIUM  END  ============ # 
    564     /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv} 
    565     if [ $? -gt 0 ] ; then 
    566         echo "IGCM_sys_QsubPost : erreur " $@ 
    567         IGCM_debug_Exit "IGCM_sys_QsubPost" 
    568     fi 
    569     IGCM_debug_PopStack "IGCM_sys_QsubPost" 
     605  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     606  if ( $DEBUG_sys ) ; then 
     607    echo "IGCM_sys_QsubPost :" $@ 
     608  fi 
     609 
     610# ============ FRONTEND START ============ # 
     611 
     612  /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv} 
     613 
     614# ============ FRONTEND  END  ============ # 
     615 
     616# ============ CESIUM START ============ # 
     617 
     618#  typeset NB_ESSAI DELAI status i 
     619#  # number of tentative 
     620#  NB_ESSAI=10 
     621#  # time delay between tentative 
     622#  DELAI=10 
     623#  (( i = 0 )) 
     624#  while [ $i -lt $NB_ESSAI ] ; do 
     625#    /usr/local/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.e.out -E "-v ${listVarEnv}" ${libIGCM_POST}/$1.job 
     626#    status=$? 
     627#    if [ ${status} -gt 0 ]; then 
     628#      sleep $DELAI 
     629#    else 
     630#      break 
     631#    fi 
     632#    (( i = i + 1 )) 
     633#  done  
     634 
     635# ============ CESIUM  END  ============ # 
     636 
     637  if [ $? -gt 0 ] ; then 
     638    echo "IGCM_sys_QsubPost : erreur " $@ 
     639    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     640  fi 
     641  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    570642} 
    571643 
     
    581653#D-  Error values and explanations can depend on your system version. 
    582654function IGCM_sys_Rsync_out { 
    583     RET=$1 
    584     if [ ! $RET ] ; then 
    585         echo "rsync error !" 
    586     fi 
    587  
    588     if [ $MYLANG = "fr" ]; then 
    589         case $RET in 
    590             0)  return ;; 
    591             1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    592                 echo "Erreur de syntaxe ou d'utilisation." 
    593                 return;; 
    594             2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    595                 echo "Incompatibilité de protocole." 
    596                 return;; 
    597             3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    598                 echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    599                 echo "répertoires" 
    600                 return;; 
    601             4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    602                 echo "Action demandée non supportée : une tentative de manipulation de" 
    603                 echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    604                 echo "été faite ; ou une option qui est supportée par le  client  mais" 
    605                 echo "pas par le serveur a été spécifiée." 
    606                 return;; 
    607             10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    608                 echo "Erreur dans le socket d'entrée sortie" 
    609                 return;; 
    610             11) echo "Erreur de rsync ; RERR_FILEIO" 
    611                 echo "Erreur d'entrée sortie fichier" 
    612                 return;; 
    613             12) echo "Erreur de rsync ; RERR_STREAMIO" 
    614                 echo "Erreur dans flux de donnée du protocole rsync" 
    615                 return;; 
    616             13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    617                 echo "Erreur avec les diagnostics du programme" 
    618                 return;; 
    619             14) echo "Erreur de rsync ; RERR_IPC" 
    620                 echo "Erreur dans le code IPC" 
    621                 return;; 
    622             20) echo "Erreur de rsync ; RERR_SIGNAL" 
    623                 echo "SIGUSR1 ou SIGINT reçu" 
    624                 return;; 
    625             21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    626                 echo "Une erreur retournée par waitpid()" 
    627                 return;; 
    628             22) echo "Erreur de rsync ; RERR_MALLOC" 
    629                 echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    630                 return;; 
    631             23) echo "" 
    632                 echo "Erreur fichier inexistant" 
    633                 return;; 
    634             30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    635                 echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    636                 return;; 
    637             *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
    638                 return;; 
    639         esac 
    640     elif [ $MYLANG = "en" ] ; then 
    641         case $RET in 
    642             0)  return;;                 
    643             1)  echo "rsync error : Syntax or usage error " 
    644                 return;; 
    645             2)  echo "rsync error : Protocol incompatibility " 
    646                 return;; 
    647             3)  echo "rsync error : Errors selecting input/output files, dirs" 
    648                 return;; 
    649             4)  echo "rsync error : Requested action not supported: an attempt" 
    650                 echo "was made to manipulate 64-bit files on a platform that cannot support" 
    651                 echo "them; or an option was specified that is supported by the client and" 
    652                 echo "not by the server." 
    653                 return;; 
    654             5)  echo "rsync error : Error starting client-server protocol" 
    655                 return;; 
    656             10) echo "rsync error : Error in socket I/O " 
    657                 return;; 
    658             11) echo "rsync error : Error in file I/O " 
    659                 return;; 
    660             12) echo "rsync error : Error in rsync protocol data stream " 
    661                 return;; 
    662             13) echo "rsync error : Errors with program diagnostics " 
    663                 return;; 
    664             14) echo "rsync error : Error in IPC code " 
    665                 return;; 
    666             20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    667                 return;; 
    668             21) echo "rsync error : Some error returned by waitpid() " 
    669                 return;; 
    670             22) echo "rsync error : Error allocating core memory buffers " 
    671                 return;; 
    672             23) echo "rsync error : Partial transfer due to error" 
    673                 return;; 
    674             24) echo "rsync error : Partial transfer due to vanished source files" 
    675                 return;; 
    676             30) echo "rsync error : Timeout in data send/receive " 
    677                 return;; 
    678             *)  echo "rsync error : return code of rsync unknown :" $RET 
    679                 return;; 
    680         esac 
    681     else 
    682         echo "unknown language $MYLANG." 
    683         return 
    684     fi 
    685 } 
    686      
     655  RET=$1 
     656  if [ ! $RET ] ; then 
     657    echo "rsync error !" 
     658  fi 
     659 
     660  if [ $MYLANG = "fr" ]; then 
     661    case $RET in 
     662    0)  return ;; 
     663    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     664      echo "Erreur de syntaxe ou d'utilisation." 
     665      return;; 
     666    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     667      echo "Incompatibilité de protocole." 
     668      return;; 
     669    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     670      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     671      echo "répertoires" 
     672      return;; 
     673    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     674      echo "Action demandée non supportée : une tentative de manipulation de" 
     675      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     676      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     677      echo "pas par le serveur a été spécifiée." 
     678      return;; 
     679    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     680      echo "Erreur dans le socket d'entrée sortie" 
     681      return;; 
     682    11) echo "Erreur de rsync ; RERR_FILEIO" 
     683      echo "Erreur d'entrée sortie fichier" 
     684      return;; 
     685    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     686      echo "Erreur dans flux de donnée du protocole rsync" 
     687      return;; 
     688    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     689      echo "Erreur avec les diagnostics du programme" 
     690      return;; 
     691    14) echo "Erreur de rsync ; RERR_IPC" 
     692      echo "Erreur dans le code IPC" 
     693      return;; 
     694    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     695      echo "SIGUSR1 ou SIGINT reçu" 
     696      return;; 
     697    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     698      echo "Une erreur retournée par waitpid()" 
     699      return;; 
     700    22) echo "Erreur de rsync ; RERR_MALLOC" 
     701      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     702      return;; 
     703    23) echo "" 
     704      echo "Erreur fichier inexistant" 
     705      return;; 
     706    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     707      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     708      return;; 
     709    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     710      return;; 
     711    esac 
     712  elif [ $MYLANG = "en" ] ; then 
     713    case $RET in 
     714    0)  return;;                 
     715    1)  echo "rsync error : Syntax or usage error " 
     716      return;; 
     717    2)  echo "rsync error : Protocol incompatibility " 
     718      return;; 
     719    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     720      return;; 
     721    4)  echo "rsync error : Requested action not supported: an attempt" 
     722      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     723      echo "them; or an option was specified that is supported by the client and" 
     724      echo "not by the server." 
     725      return;; 
     726    5)  echo "rsync error : Error starting client-server protocol" 
     727      return;; 
     728    10) echo "rsync error : Error in socket I/O " 
     729      return;; 
     730    11) echo "rsync error : Error in file I/O " 
     731      return;; 
     732    12) echo "rsync error : Error in rsync protocol data stream " 
     733      return;; 
     734    13) echo "rsync error : Errors with program diagnostics " 
     735      return;; 
     736    14) echo "rsync error : Error in IPC code " 
     737      return;; 
     738    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     739      return;; 
     740    21) echo "rsync error : Some error returned by waitpid() " 
     741      return;; 
     742    22) echo "rsync error : Error allocating core memory buffers " 
     743      return;; 
     744    23) echo "rsync error : Partial transfer due to error" 
     745      return;; 
     746    24) echo "rsync error : Partial transfer due to vanished source files" 
     747      return;; 
     748    30) echo "rsync error : Timeout in data send/receive " 
     749      return;; 
     750    *)  echo "rsync error : return code of rsync unknown :" $RET 
     751      return;; 
     752    esac 
     753  else 
     754    echo "unknown language $MYLANG." 
     755    return 
     756  fi 
     757} 
    687758 
    688759#D-#================================================== 
     
    692763#D- 
    693764function IGCM_sys_Mirror_libIGCM { 
    694     IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    695     if ( $DEBUG_sys ) ; then 
    696         echo "IGCM_sys_Mirror_libIGCM" 
    697     fi 
    698  
    699     typeset RET DEST 
    700  
    701     mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    702  
    703     echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
    704     ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
    705     RET=$? 
    706  
    707     if [ ${RET} -gt 0 ] ; then 
    708         echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
    709         cat out_rsync 
    710     fi 
    711     IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
     765  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
     766  if ( $DEBUG_sys ) ; then 
     767    echo "IGCM_sys_Mirror_libIGCM" 
     768  fi 
     769 
     770  typeset RET DEST 
     771 
     772  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
     773 
     774  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
     775  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
     776  RET=$? 
     777 
     778  if [ ${RET} -gt 0 ] ; then 
     779    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
     780    cat out_rsync 
     781  fi 
     782  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    712783} 
    713784 
     
    715786#- Call IGCM_sys_Mirror_libIGCM now ! 
    716787if ( $MirrorlibIGCM ) ; then 
    717     IGCM_sys_Mirror_libIGCM 
     788  IGCM_sys_Mirror_libIGCM 
    718789fi 
    719790 
     
    724795#D- 
    725796function IGCM_sys_Cp { 
    726     IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    727     if ( $DEBUG_sys ) ; then 
    728         echo "IGCM_sys_Cp :" $@ 
    729     fi 
    730  
    731     typeset RET 
    732  
    733     echo cp $@ > out_rsync 2>&1 
    734     \cp $@ >> out_rsync 2>&1 
    735     RET=$? 
    736  
    737     if [ ${RET} -gt 0 ] ; then 
    738         echo "IGCM_sys_Cp : error." 
    739         cat out_rsync 
    740         IGCM_debug_Exit "IGCM_sys_Cp" 
    741      else 
    742         \rm out_rsync 
    743     fi 
    744     IGCM_debug_PopStack "IGCM_sys_Cp" 
     797  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     798  if ( $DEBUG_sys ) ; then 
     799    echo "IGCM_sys_Cp :" $@ 
     800  fi 
     801 
     802  typeset RET 
     803 
     804  echo cp $@ > out_rsync 2>&1 
     805  \cp $@ >> out_rsync 2>&1 
     806  RET=$? 
     807 
     808  if [ ${RET} -gt 0 ] ; then 
     809    echo "IGCM_sys_Cp : error." 
     810    cat out_rsync 
     811    IGCM_debug_Exit "IGCM_sys_Cp" 
     812  else 
     813    \rm out_rsync 
     814  fi 
     815  IGCM_debug_PopStack "IGCM_sys_Cp" 
    745816} 
    746817 
     
    751822#D- 
    752823function IGCM_sys_Rm { 
    753     IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
    754     if ( $DEBUG_sys ) ; then 
    755         echo "IGCM_sys_Rm :" $@ 
    756     fi 
    757  
    758     typeset RET 
    759  
    760     echo rm $@ > out_rsync 2>&1 
    761     \rm $@ >> out_rsync 2>&1 
    762     RET=$? 
    763  
    764     if [ ${RET} -gt 0 ] ; then 
    765         echo "IGCM_sys_Rm : error." 
    766         cat out_rsync 
    767         IGCM_debug_Exit "IGCM_sys_Rm" 
    768     else 
    769         \rm out_rsync 
    770     fi 
    771     IGCM_debug_PopStack "IGCM_sys_Rm" 
     824  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     825  if ( $DEBUG_sys ) ; then 
     826    echo "IGCM_sys_Rm :" $@ 
     827  fi 
     828 
     829  typeset RET 
     830 
     831  echo rm $@ > out_rsync 2>&1 
     832  \rm $@ >> out_rsync 2>&1 
     833  RET=$? 
     834 
     835  if [ ${RET} -gt 0 ] ; then 
     836    echo "IGCM_sys_Rm : error." 
     837    cat out_rsync 
     838    IGCM_debug_Exit "IGCM_sys_Rm" 
     839  else 
     840    \rm out_rsync 
     841  fi 
     842  IGCM_debug_PopStack "IGCM_sys_Rm" 
    772843} 
    773844 
     
    778849#D- 
    779850function IGCM_sys_Mv { 
    780     IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    781     if ( $DEBUG_sys ) ; then 
    782         echo "IGCM_sys_Mv :" $@ 
    783     fi 
    784  
    785     if [ $DRYRUN = 0 ]; then 
    786  
    787         typeset RET 
    788              
    789         echo mv $@ > out_rsync 2>&1 
    790         \mv $@ >> out_rsync 2>&1 
    791         RET=$? 
     851  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     852  if ( $DEBUG_sys ) ; then 
     853    echo "IGCM_sys_Mv :" $@ 
     854  fi 
     855 
     856  if [ $DRYRUN = 0 ]; then 
     857 
     858    typeset RET 
    792859     
    793         if [ ${RET} -gt 0 ] ; then 
    794             echo "IGCM_sys_Mv : error in mv." 
    795             cat out_rsync 
    796             IGCM_debug_Exit "IGCM_sys_Mv" 
    797         else 
    798             \rm out_rsync 
    799         fi 
     860    echo mv $@ > out_rsync 2>&1 
     861    \mv $@ >> out_rsync 2>&1 
     862    RET=$? 
     863     
     864    if [ ${RET} -gt 0 ] ; then 
     865      echo "IGCM_sys_Mv : error in mv." 
     866      cat out_rsync 
     867      IGCM_debug_Exit "IGCM_sys_Mv" 
    800868    else 
    801         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    802     fi 
    803  
    804     IGCM_debug_PopStack "IGCM_sys_Mv" 
     869      \rm out_rsync 
     870    fi 
     871  else 
     872    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     873  fi 
     874 
     875  IGCM_debug_PopStack "IGCM_sys_Mv" 
    805876} 
    806877 
     
    811882#D- 
    812883function IGCM_sys_Put_Dir { 
    813     IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
    814     if ( $DEBUG_sys ) ; then 
    815         echo "IGCM_sys_Put_Dir :" $@ 
    816     fi 
    817     if [ $DRYRUN = 0 ]; then 
    818         if [ ! -d ${1} ] ; then 
    819             echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
    820             IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    821             return 
    822         fi 
    823  
    824         typeset RET 
    825  
    826         # Only if we use rsync 
    827         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    828         # 
    829         #USUAL WAY 
    830         \cp -r $1 $2 > out_rsync 2>&1 
    831         RET=$? 
    832  
    833         if [ ${RET} -gt 0 ] ; then 
    834             echo "IGCM_sys_Put_Dir : error." 
    835             cat out_rsync 
    836             IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    837         else 
    838             \rm out_rsync 
    839         fi 
     884  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     885  if ( $DEBUG_sys ) ; then 
     886    echo "IGCM_sys_Put_Dir :" $@ 
     887  fi 
     888  if [ $DRYRUN = 0 ]; then 
     889    if [ ! -d ${1} ] ; then 
     890      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     891      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     892      return 
     893    fi 
     894 
     895    typeset RET 
     896 
     897    # Only if we use rsync 
     898    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     899    # 
     900    #USUAL WAY 
     901    \cp -r $1 $2 > out_rsync 2>&1 
     902    RET=$? 
     903 
     904    if [ ${RET} -gt 0 ] ; then 
     905      echo "IGCM_sys_Put_Dir : error." 
     906      cat out_rsync 
     907      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    840908    else 
    841         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    842     fi 
    843     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     909      \rm out_rsync 
     910    fi 
     911  else 
     912    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     913  fi 
     914  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    844915} 
    845916 
    846917#D-#================================================== 
    847918#D-function IGCM_sys_Get_Dir 
    848 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     919#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    849920#D-* Examples: 
    850921#D- 
    851922function IGCM_sys_Get_Dir { 
    852     IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
    853     if ( $DEBUG_sys ) ; then 
    854         echo "IGCM_sys_Get_Dir :" $@ 
    855     fi 
    856     if [ $DRYRUN = 0 ]; then 
    857         if [ ! -d ${1} ] ; then 
    858             echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
    859             IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    860             return 
    861         fi 
    862  
    863         typeset RET 
    864  
    865         # Only if we use rsync 
    866         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    867         # 
    868         #USUAL WAY 
    869         \cp -r $1 $2 > out_rsync 2>&1 
    870         RET=$? 
    871  
    872         if [ ${RET} -gt 0 ] ; then 
    873             echo "IGCM_sys_Get_Dir : error." 
    874             cat out_rsync 
    875             IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    876         else 
    877             \rm out_rsync 
    878         fi 
     923  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     924  if ( $DEBUG_sys ) ; then 
     925    echo "IGCM_sys_Get_Dir :" $@ 
     926  fi 
     927  if [ $DRYRUN = 0 ]; then 
     928#    if [ ! -d ${1} ] ; then 
     929#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     930#      IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     931#      return 
     932#    fi 
     933 
     934    typeset RET 
     935 
     936    # Only if we use rsync 
     937    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     938    # 
     939    # USUAL WAY 
     940    # add dmfind/dmget (to demigrate all offline files) : 
     941    dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget 
     942    \cp -r $1 $2 > out_rsync 2>&1 
     943    RET=$? 
     944 
     945    if [ ${RET} -gt 0 ] ; then 
     946      echo "IGCM_sys_Get_Dir : error." 
     947      cat out_rsync 
     948      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    879949    else 
    880         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    881     fi 
    882     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     950      \rm out_rsync 
     951    fi 
     952  else 
     953    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     954  fi 
     955  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    883956} 
    884957 
    885958#D-#================================================== 
    886959#D-function IGCM_sys_Put_Rest 
    887 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     960#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    888961#D-           File and target directory must exist. 
    889962#D-* Examples: 
    890963#D- 
    891964function IGCM_sys_Put_Rest { 
    892     IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
    893     if ( $DEBUG_sys ) ; then 
    894         echo "IGCM_sys_Put_Rest :" $@ 
    895     fi 
    896     if [ $DRYRUN = 0 ]; then 
    897         if [ ! -f ${1} ] ; then 
    898             echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
    899             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    900         fi 
    901  
    902         typeset RET 
    903         # 
    904         if [ X${JobType} = XRUN ] ; then 
    905             IGCM_sys_Chmod 444 ${1} 
    906         fi 
    907         # 
    908         IGCM_sys_TestDirArchive $( dirname $2 ) 
    909         # 
    910         # USUAL WAY 
    911         putfer $1 $2 > out_rsync 2>&1 
    912         RET=$? 
     965  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     966  if ( $DEBUG_sys ) ; then 
     967    echo "IGCM_sys_Put_Rest :" $@ 
     968  fi 
     969  if [ $DRYRUN = 0 ]; then 
     970    if [ ! -f ${1} ] ; then 
     971      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     972      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     973    fi 
     974 
     975    typeset RET 
     976    # 
     977    if [ X${JobType} = XRUN ] ; then 
     978      IGCM_sys_Chmod 444 ${1} 
     979    fi 
     980 
     981    # 
     982    # USUAL WAY 
     983    \cp $1 $2 > out_rsync 2>&1 
     984    RET=$? 
    913985 
    914986#       #RSYNC WITH NETWORK SSH CALL 
     
    926998#       (( RET=RET+$? )) 
    927999 
    928         if [ ${RET} -gt 0 ] ; then 
    929             echo "IGCM_sys_Put_Rest : error." 
    930             cat out_rsync 
    931             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    932         else 
    933             \rm out_rsync 
    934         fi 
     1000    if [ ${RET} -gt 0 ] ; then 
     1001      echo "IGCM_sys_Put_Rest : error." 
     1002      cat out_rsync 
     1003      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    9351004    else 
    936         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    937     fi 
    938     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1005      \rm out_rsync 
     1006    fi 
     1007  else 
     1008    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1009  fi 
     1010  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1011} 
     1012 
     1013#D-#================================================== 
     1014#D-function IGCM_sys_PutBuffer_Rest 
     1015#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     1016#D-           File and target directory must exist. 
     1017#D-* Examples: 
     1018#D- 
     1019function IGCM_sys_PutBuffer_Rest { 
     1020  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     1021  if ( $DEBUG_sys ) ; then 
     1022    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     1023  fi 
     1024  if [ $DRYRUN = 0 ]; then 
     1025    if [ ! -f ${1} ] ; then 
     1026      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     1027      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1028    fi 
     1029 
     1030    typeset RET 
     1031    # 
     1032    if [ X${JobType} = XRUN ] ; then 
     1033      IGCM_sys_Chmod 444 ${1} 
     1034    fi 
     1035 
     1036    # 
     1037    # USUAL WAY 
     1038    \cp $1 $2 > out_rsync 2>&1 
     1039    RET=$? 
     1040 
     1041    if [ ${RET} -gt 0 ] ; then 
     1042      echo "IGCM_sys_PutBuffer_Rest : error." 
     1043      cat out_rsync 
     1044      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1045    else 
     1046      \rm out_rsync 
     1047    fi 
     1048  else 
     1049    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1050  fi 
     1051  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    9391052} 
    9401053 
    9411054#D-#================================================== 
    9421055#D-function IGCM_sys_Put_Out 
    943 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     1056#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    9441057#D-* Examples: 
    9451058#D- 
    9461059function IGCM_sys_Put_Out { 
    947     IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
    948     if ( $DEBUG_sys ) ; then 
    949         echo "IGCM_sys_Put_Out :" $@ 
    950     fi 
    951     if [ $DRYRUN = 0 ]; then 
    952         if [ ! -f ${1} ] ; then 
    953             echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
    954             IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    955             return 1 
    956         fi 
    957         # 
    958         IGCM_sys_MkdirArchive $( dirname $2 ) 
    959         # 
    960         typeset RET 
    961  
    962         #===================================================== 
    963         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    964         #===================================================== 
    965  
    966         #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
    967         #if [ $? -eq 0 ] ; then 
    968         #    typeset WORKPATH FILEPATH 
    969         #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    970         #    IGCM_sys_MkdirWork ${WORKPATH}  
    971         #    FILEPATH=${WORKPATH}/$( basename $2 ) 
    972         #    # 
    973         #    IGCM_sys_Cp ${1} ${FILEPATH} 
    974         #fi 
    975  
    976         if [ X${JobType} = XRUN ] ; then 
    977             if [ X${3} = X ] ; then 
    978                 IGCM_sys_Chmod 444 ${1} 
    979             fi 
    980         fi 
    981         # 
    982         # USUAL WAY 
    983         putfer $1 $2 > out_rsync 2>&1 
    984         RET=$? 
     1060  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     1061  if ( $DEBUG_sys ) ; then 
     1062    echo "IGCM_sys_Put_Out :" $@ 
     1063  fi 
     1064  if [ $DRYRUN = 0 ]; then 
     1065    if [ ! -f ${1} ] ; then 
     1066      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     1067      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1068      return 1 
     1069    fi 
     1070    # 
     1071    IGCM_sys_MkdirArchive $( dirname $2 ) 
     1072    # 
     1073    typeset RET 
     1074 
     1075    #===================================================== 
     1076    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1077    #===================================================== 
     1078 
     1079    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     1080    #if [ $? -eq 0 ] ; then 
     1081    #    typeset WORKPATH FILEPATH 
     1082    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     1083    #    IGCM_sys_MkdirWork ${WORKPATH}  
     1084    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     1085    #    # 
     1086    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1087    #fi 
     1088 
     1089    if [ X${JobType} = XRUN ] ; then 
     1090      if [ X${3} = X ] ; then 
     1091        IGCM_sys_Chmod 444 ${1} 
     1092      fi 
     1093    fi 
     1094    # 
     1095    # USUAL WAY 
     1096    \cp $1 $2 > out_rsync 2>&1 
     1097    RET=$? 
    9851098 
    9861099#       #RSYNC WITH NETWORK SSH CALL 
     
    9981111#       (( RET=RET+$? )) 
    9991112 
    1000         if [ ${RET} -gt 0 ] ; then 
    1001             echo "IGCM_sys_Put_Out : error." 
    1002             cat out_rsync 
    1003             IGCM_debug_Exit "IGCM_sys_Put_Out" 
    1004         else 
    1005             \rm out_rsync 
    1006         fi 
     1113    if [ ${RET} -gt 0 ] ; then 
     1114      echo "IGCM_sys_Put_Out : error." 
     1115      cat out_rsync 
     1116      IGCM_debug_Exit "IGCM_sys_Put_Out" 
    10071117    else 
    1008         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1009     fi 
    1010     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1011     return 0 
     1118      \rm out_rsync 
     1119    fi 
     1120  else 
     1121    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1122  fi 
     1123  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1124  return 0 
     1125} 
     1126 
     1127#D-#================================================== 
     1128#D-function IGCM_sys_PutBuffer_Out 
     1129#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
     1130#D-* Examples: 
     1131#D- 
     1132function IGCM_sys_PutBuffer_Out { 
     1133  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     1134  if ( $DEBUG_sys ) ; then 
     1135    echo "IGCM_sys_PutBuffer_Out :" $@ 
     1136  fi 
     1137  if [ $DRYRUN = 0 ]; then 
     1138    if [ ! -f ${1} ] ; then 
     1139      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     1140      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1141      return 1 
     1142    fi 
     1143    # 
     1144    IGCM_sys_Mkdir $( dirname $2 ) 
     1145    # 
     1146    typeset RET 
     1147 
     1148    if [ X${JobType} = XRUN ] ; then 
     1149      if [ X${3} = X ] ; then 
     1150        IGCM_sys_Chmod 444 ${1} 
     1151      fi 
     1152    fi 
     1153    # 
     1154    # USUAL WAY 
     1155    \cp $1 $2 > out_rsync 2>&1 
     1156    RET=$? 
     1157 
     1158    if [ ${RET} -gt 0 ] ; then 
     1159      echo "IGCM_sys_PutBuffer_Out : error." 
     1160      cat out_rsync 
     1161      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
     1162    else 
     1163      \rm out_rsync 
     1164    fi 
     1165  else 
     1166    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1167  fi 
     1168  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1169  return 0 
    10121170} 
    10131171 
     
    10181176#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    10191177function IGCM_sys_Get { 
    1020     IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    1021  
    1022     typeset DEST RET dm_liste ifile target file_work  
    1023  
    1024     if ( $DEBUG_sys ) ; then 
    1025         echo "IGCM_sys_Get :" $@ 
    1026     fi 
    1027     if [ $DRYRUN -le 2 ]; then 
    1028         if [ X${1} = X'/l' ] ; then 
    1029             # test if the first file is present in the old computation : 
    1030             eval set +A dm_liste \${${2}} 
    1031         else 
    1032             eval set +A dm_liste ${1} 
    1033         fi 
    1034         eval DEST=\${${#}} 
    1035  
    1036         #===================================================== 
    1037         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1038         #===================================================== 
    1039  
    1040         # Is it an R_OUT file (not R_IN) ? 
    1041         #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
    1042         #if [ $? -eq 0 ] ; then 
    1043         #    # Yes  ? then we try to get it in SCRATCHDIR 
    1044         #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    1045         #    if [ -f ${file_work[0]} ] ; then 
    1046         #       IGCM_sys_Cp ${file_work[*]} ${DEST} 
    1047         #       IGCM_debug_PopStack "IGCM_sys_Get" 
    1048         #       return 
    1049         #    fi 
    1050         #fi 
    1051  
    1052         # test if the (first) file is present in the old computation : 
    1053         IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1054         RET=$? 
    1055         if [ ${RET} -gt 0 ] ; then 
    1056             echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    1057             IGCM_debug_Exit "IGCM_sys_Get" 
    1058             IGCM_debug_PopStack "IGCM_sys_Get" 
    1059             return 
    1060         fi 
    1061  
    1062         dmget ${dm_liste[*]} > out_rsync 2>&1 
    1063         RET=$? 
    1064         if [ ${RET} -gt 0 ] ; then 
    1065             echo "IGCM_sys_Get : demigration error." 
    1066             cat out_rsync 
    1067             IGCM_debug_Exit "IGCM_sys_Get" 
    1068         fi 
    1069  
    1070         #USUAL WAY 
    1071         if [ X${1} = X'/l' ] ; then 
    1072             (( RET=0 )) 
    1073             for target in ${dm_liste[*]} ; do 
    1074                 local_file=$( basename ${target} ) 
    1075                 \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1076                 (( RET = RET + $? )) 
    1077             done 
    1078         else 
    1079             \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
    1080             RET=$? 
    1081         fi 
     1178  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1179 
     1180  typeset DEST RET dm_liste ifile target file_work  
     1181 
     1182  if ( $DEBUG_sys ) ; then 
     1183    echo "IGCM_sys_Get :" $@ 
     1184  fi 
     1185  if [ $DRYRUN -le 2 ]; then 
     1186    if [ X${1} = X'/l' ] ; then 
     1187      # test if the first file is present in the old computation : 
     1188      eval set +A dm_liste \${${2}} 
     1189    else 
     1190      eval set +A dm_liste ${1} 
     1191    fi 
     1192    eval DEST=\${${#}} 
     1193 
     1194    #===================================================== 
     1195    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1196    #===================================================== 
     1197 
     1198    # Is it an R_OUT file (not R_IN) ? 
     1199    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1200    #if [ $? -eq 0 ] ; then 
     1201    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1202    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1203    #    if [ -f ${file_work[0]} ] ; then 
     1204    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1205    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1206    #   return 
     1207    #    fi 
     1208    #fi 
     1209 
     1210    # test if the (first) file is present in the old computation : 
     1211    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1212    RET=$? 
     1213    if [ ${RET} -gt 0 ] ; then 
     1214      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1215      IGCM_debug_Exit "IGCM_sys_Get" 
     1216    fi 
     1217 
     1218    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1219    RET=$? 
     1220    if [ ${RET} -gt 0 ] ; then 
     1221      echo "WARNING IGCM_sys_Get : demigration error." 
     1222      cat out_rsync 
     1223      echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
     1224    fi 
     1225 
     1226    #if [ ${RET} -gt 0 ] ; then 
     1227    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1228    #   cat out_rsync 
     1229    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1230    #   sleep 30 
     1231    #   echo "We try another time" 
     1232    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1233    #   RET=$? 
     1234    #   if [ ${RET} -gt 0 ] ; then 
     1235    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1236    #       cat out_rsync 
     1237    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1238    #   fi 
     1239    #    else 
     1240    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1241    #   cat out_rsync 
     1242    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1243    #    fi 
     1244    #fi 
     1245 
     1246    #USUAL WAY 
     1247    if [ X${1} = X'/l' ] ; then 
     1248      (( RET=0 )) 
     1249      for target in ${dm_liste[*]} ; do 
     1250        local_file=$( basename ${target} ) 
     1251        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1252        (( RET = RET + $? )) 
     1253      done 
     1254    else 
     1255      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1256      RET=$? 
     1257    fi 
    10821258 
    10831259#       #RSYNC WITH NETWORK SSH CALL 
     
    10951271#       (( RET=RET+$? )) 
    10961272 
    1097         if [ ${RET} -gt 0 ] ; then 
    1098             echo "IGCM_sys_Get : copy error." 
    1099             cat out_rsync 
    1100             IGCM_debug_Exit "IGCM_sys_Get" 
    1101         else 
    1102             \rm out_rsync 
    1103         fi 
     1273    if [ ${RET} -gt 0 ] ; then 
     1274      echo "IGCM_sys_Get : copy error." 
     1275      cat out_rsync 
     1276      IGCM_debug_Exit "IGCM_sys_Get" 
    11041277    else 
    1105         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1106     fi 
    1107     IGCM_debug_PopStack "IGCM_sys_Get" 
     1278      \rm out_rsync 
     1279    fi 
     1280  else 
     1281    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1282  fi 
     1283  IGCM_debug_PopStack "IGCM_sys_Get" 
     1284} 
     1285 
     1286#D-#================================================== 
     1287#D-function IGCM_sys_GetBuffer 
     1288#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1289#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1290#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1291function IGCM_sys_GetBuffer { 
     1292  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1293 
     1294  typeset DEST RET buf_liste ifile target file_work  
     1295 
     1296  if ( $DEBUG_sys ) ; then 
     1297    echo "IGCM_sys_GetBuffer :" $@ 
     1298  fi 
     1299  if [ $DRYRUN -le 2 ]; then 
     1300    if [ X${1} = X'/l' ] ; then 
     1301      # test if the first file is present in the old computation : 
     1302      eval set +A buf_liste \${${2}} 
     1303    else 
     1304      eval set +A buf_liste ${1} 
     1305    fi 
     1306    eval DEST=\${${#}} 
     1307 
     1308    #USUAL WAY 
     1309    if [ X${1} = X'/l' ] ; then 
     1310      (( RET=0 )) 
     1311      for target in ${buf_liste[*]} ; do 
     1312        local_file=$( basename ${target} ) 
     1313        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1314        (( RET = RET + $? )) 
     1315      done 
     1316    else 
     1317      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1318      RET=$? 
     1319    fi 
     1320 
     1321    if [ ${RET} -gt 0 ] ; then 
     1322      echo "IGCM_sys_GetBuffer : copy error." 
     1323      cat out_rsync 
     1324      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1325    else 
     1326      \rm out_rsync 
     1327    fi 
     1328  else 
     1329    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1330  fi 
     1331  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
    11081332} 
    11091333 
     
    11141338#D- 
    11151339function IGCM_sys_GetDate_FichWork { 
    1116     IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1117     if ( $DEBUG_sys ) ; then 
    1118         echo "IGCM_sys_GetDate_FichWork :" $@ 
    1119     fi 
    1120     typeset dateF 
    1121     set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1122     eval ${2}=${dateF[5]} 
     1340  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1341  if ( $DEBUG_sys ) ; then 
     1342    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1343  fi 
     1344  typeset dateF 
     1345  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1346  eval ${2}=${dateF[5]} 
    11231347 
    11241348    # donne la date filesys d'un fichier sur la machine work 
    1125     IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1349  IGCM_debug_PopStack "IGCM_sys_FichWork" 
    11261350} 
    11271351 
     
    11321356#D- 
    11331357function IGCM_sys_GetDate_FichArchive { 
    1134     IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1135     if ( $DEBUG_sys ) ; then 
    1136         echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1137     fi 
    1138     typeset dateF 
    1139     set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1140     eval ${2}=${dateF[5]} 
    1141  
    1142     IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1358  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1359  if ( $DEBUG_sys ) ; then 
     1360    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1361  fi 
     1362  typeset dateF 
     1363  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1364  eval ${2}=${dateF[5]} 
     1365 
     1366  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    11431367} 
    11441368 
     
    11471371 
    11481372function IGCM_sys_rebuild { 
    1149     IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
    1150     if ( $DEBUG_sys ) ; then 
    1151         echo "IGCM_sys_rebuild :" $@ 
    1152     fi 
    1153     /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@ 
    1154     if [ $? -gt 0 ] ; then 
    1155        echo "IGCM_sys_rebuild : erreur ${@}." 
    1156        IGCM_debug_Exit "rebuild" 
    1157     fi 
    1158  
    1159     IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1373  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1374  if ( $DEBUG_sys ) ; then 
     1375    echo "IGCM_sys_rebuild :" $@ 
     1376  fi 
     1377  /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@ 
     1378  if [ $? -gt 0 ] ; then 
     1379    echo "IGCM_sys_rebuild : erreur ${@}." 
     1380    IGCM_debug_Exit "rebuild" 
     1381  fi 
     1382 
     1383  IGCM_debug_PopStack "IGCM_sys_rebuild" 
    11601384} 
    11611385 
     
    11641388 
    11651389function IGCM_sys_activ_variables { 
    1166     IGCM_debug_PushStack "IGCM_sys_activ_variables" 
    1167     if ( $DEBUG_sys ) ; then 
    1168         echo "IGCM_sys_activ_variables" 
    1169     fi 
     1390  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1391  if ( $DEBUG_sys ) ; then 
     1392    echo "IGCM_sys_activ_variables" 
     1393  fi 
    11701394 
    11711395# -------------------------------------------------------------------- 
     
    11741398 
    11751399#D-- MPISUSPEND 
    1176     export MPISUSPEND=${MPISUSPEND:=OFF} 
     1400  export MPISUSPEND=${MPISUSPEND:=OFF} 
    11771401 
    11781402#D-- MPIPROGINF #other choices : ALL_DETAIL2 
    1179     export MPIPROGINF=ALL 
     1403  export MPIPROGINF=ALL 
    11801404#D- activate ftrace (with -ftrace) 
    1181     export F_FTRACE=YES 
     1405  export F_FTRACE=YES 
    11821406#D- communication information (with -ftrace) 
    1183     export MPICOMMINF=DETAIL 
     1407  export MPICOMMINF=DETAIL 
    11841408 
    11851409# -------------------------------------------------------------------- 
     
    11881412 
    11891413#D- max number of character/line in output job 
    1190     export F_SYSLEN=5000 
     1414  export F_SYSLEN=5000 
    11911415#D- number of error that can be admitted on the NEC 
    1192     export F_ERRCNT=0 
     1416  export F_ERRCNT=0 
    11931417#D- global performance 
    1194     export F_PROGINF=DETAIL 
     1418  export F_PROGINF=DETAIL 
    11951419 
    11961420#D- I/O performance (FORTRAN I/O only not netCDF) 
    1197     export F_FILEINF=${F_FILEINF:=NO} 
     1421  export F_FILEINF=${F_FILEINF:=NO} 
    11981422#D- netCDF I/O performance 
    1199     export NC_FILEINF=${NC_FILEINF:=NO} 
    1200  
    1201     IGCM_debug_PopStack "IGCM_sys_activ_variables" 
     1423  export NC_FILEINF=${NC_FILEINF:=NO} 
     1424 
     1425  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    12021426} 
    12031427 
     
    12061430 
    12071431function IGCM_sys_desactiv_variables { 
    1208     IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
    1209     if ( $DEBUG_sys ) ; then 
    1210         echo "IGCM_sys_desactiv_variables" 
    1211     fi 
     1432  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1433  if ( $DEBUG_sys ) ; then 
     1434    echo "IGCM_sys_desactiv_variables" 
     1435  fi 
    12121436# -------------------------------------------------------------------- 
    12131437#D- MPI specifications 
     
    12151439 
    12161440#D-- MPIPROGINF 
    1217     export MPIPROGINF=NO 
     1441  export MPIPROGINF=NO 
    12181442 
    12191443# -------------------------------------------------------------------- 
     
    12221446 
    12231447#D- global performance 
    1224     export F_PROGINF=NO   
    1225  
    1226     IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
     1448  export F_PROGINF=NO   
     1449 
     1450  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
    12271451} 
    12281452 
     
    12311455 
    12321456function IGCM_sys_build_run_file { 
    1233     IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
    1234     if ( $DEBUG_sys ) ; then 
    1235         echo "IGCM_sys_build_run_file " $@ 
    1236     fi 
    1237     (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 )) 
    1238     (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
    1239     (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
    1240      
    1241     if [ $1 = MPI2 ]; then 
    1242         cat <<EOF > run_file 
     1457  IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
     1458  if ( $DEBUG_sys ) ; then 
     1459    echo "IGCM_sys_build_run_file " $@ 
     1460  fi 
     1461  (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 )) 
     1462  (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
     1463  (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
     1464   
     1465  if [ $1 = MPI2 ]; then 
     1466    cat <<EOF > run_file 
    12431467-p 1 -np 1 -e ./oasis 
    12441468EOF 
    1245         (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 )) 
    1246         config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"' 
    1247  
    1248     elif [ $1 = MPI1 ]; then 
    1249         cat <<EOF > run_file 
     1469    (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 )) 
     1470    config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"' 
     1471 
     1472  elif [ $1 = MPI1 ]; then 
     1473    cat <<EOF > run_file 
    12501474-p $NUM_PROC_OASIS -e ./oasis 
    12511475-p $NUM_PROC_ATM -e ./lmdz.x 
    12521476-p $NUM_PROC_OCE -e ./opa.xx 
    12531477EOF 
    1254   
    1255     fi 
    1256  
    1257     IGCM_debug_PopStack "IGCM_sys_build_run_file" 
    1258    
    1259 } 
     1478  fi 
     1479  IGCM_debug_PopStack "IGCM_sys_build_run_file" 
     1480} 
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh

    r540 r544  
    99# IPSL (2006) 
    1010#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC 
    11 # History: 
    12 # Modification: 
    1311# 
    1412#************************************************************** 
     
    107105#==================================================== 
    108106#- Mirror libIGCM from mercure to cesium if needed 
    109 ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $2}' ) 
     107ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $3}' ) 
    110108if [ ! ${ROOTSYS} = "home" ] ; then 
    111     typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true} 
     109  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true} 
    112110else 
    113     typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} 
     111  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} 
    114112fi 
    115113 
     
    117115#- libIGCM_POST 
    118116if ( ${MirrorlibIGCM} ) ; then 
    119     PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" ) 
    120     typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM 
     117  PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" ) 
     118  typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM 
    121119else 
    122     typeset -r libIGCM_POST=${libIGCM} 
     120  typeset -r libIGCM_POST=${libIGCM} 
    123121fi 
    124122 
     
    139137 
    140138#==================================================== 
    141 #- OUT 
     139#- R_OUT 
    142140typeset -r R_OUT=${ARCHIVE}/IGCM_OUT 
     141 
     142#==================================================== 
     143#- R_BUF (ONLY FOR double copy an scratch) 
     144typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT 
     145 
     146#==================================================== 
     147#- BIG_DIR : BIG_DIR to store files waiting for rebuild 
     148typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    143149 
    144150#==================================================== 
     
    151157 
    152158#==================================================== 
    153 #- BIG_DIR : BIG_DIR to store files waiting for rebuild 
    154 typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    155  
    156 #==================================================== 
    157159#- HOST_MPIRUN_COMMAND 
    158160typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="mpirun"} 
     
    168170#D- 
    169171function IGCM_sys_RshMaster { 
    170     IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    171     ssh -t ${MASTER} /bin/ksh <<-EOF 
    172     export libIGCM=${libIGCM} 
    173     export DEBUG_debug=${DEBUG_debug} 
    174     . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
    175     . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
     172  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
     173  ssh -t ${MASTER} /bin/ksh <<-EOF 
     174  export libIGCM=${libIGCM} 
     175  export DEBUG_debug=${DEBUG_debug} 
     176  . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
     177  . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
     178  ${@} 
     179EOF 
     180  if [ $? -gt 0 ] ; then 
     181    echo "IGCM_sys_RshMaster : erreur." 
     182    IGCM_debug_Exit "IGCM_sys_RshMaster" 
     183  fi 
     184  IGCM_debug_PopStack "IGCM_sys_RshMaster" 
     185} 
     186 
     187#D-#================================================== 
     188#D-function IGCM_sys_RshArchive 
     189#D-* Purpose: Archive rsh command 
     190#D-* Examples: 
     191#D- 
     192function IGCM_sys_RshArchive { 
     193  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
     194  /bin/ksh <<-EOF 
    176195    ${@} 
    177196EOF 
    178     if [ $? -gt 0 ] ; then 
    179         echo "IGCM_sys_RshMaster : erreur." 
    180         IGCM_debug_Exit "IGCM_sys_RshMaster" 
    181     fi 
    182     IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    183 } 
    184  
    185 #D-#================================================== 
    186 #D-function IGCM_sys_RshArchive 
    187 #D-* Purpose: Archive rsh command 
    188 #D-* Examples: 
    189 #D- 
    190 function IGCM_sys_RshArchive { 
    191     IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    192     /bin/ksh <<-EOF 
    193 ${@} 
    194 EOF 
    195     if [ $? -gt 0 ] ; then 
    196         echo "IGCM_sys_RshArchive : erreur." 
    197         IGCM_debug_Exit "IGCM_sys_RshArchive" 
    198     fi 
    199     IGCM_debug_PopStack "IGCM_sys_RshArchive" 
     197  if [ $? -gt 0 ] ; then 
     198    echo "IGCM_sys_RshArchive : erreur." 
     199    IGCM_debug_Exit "IGCM_sys_RshArchive" 
     200  fi 
     201  IGCM_debug_PopStack "IGCM_sys_RshArchive" 
    200202} 
    201203 
     
    206208#D- 
    207209function IGCM_sys_RshPost { 
    208     IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    209     if ( $DEBUG_sys ) ; then 
    210         echo "IGCM_sys_RshPost :" $@ 
    211     fi 
     210  IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
     211  if ( $DEBUG_sys ) ; then 
     212    echo "IGCM_sys_RshPost :" $@ 
     213  fi 
     214 
     215  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL 
     216  #cat tmp_IGCM_sys_RshPost_$$ 
     217  # keep standard input (stdin) for the loop onto temporary file 
     218  cat >tmp_IGCM_sys_RshPost_$$ 
     219 
     220# ============ FRONTEND START ============ # 
     221 
     222#  /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     223#  if [ $? -gt 0 ] ; then 
     224#    echo "IGCM_sys_RshPost : erreur." 
     225#    IGCM_debug_Exit "IGCM_sys_RshPost" 
     226#  fi 
     227#  \rm tmp_IGCM_sys_RshPost_$$ 
     228 
     229# ============ FRONTEND  END  ============ # 
    212230 
    213231# ============ CESIUM START ============ # 
    214     typeset NB_ESSAI DELAI status i 
    215     # keep standard input for the loop onto temporary file 
    216     cat >tmp_IGCM_sys_RshPost_$$ 
    217     # number of tentative 
    218     NB_ESSAI=10 
    219     # time delay between tentative 
    220     DELAI=10 
    221     (( i = 0 )) 
    222     while [ $i -lt $NB_ESSAI ] ; do 
    223         ssh -t mercure01 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
    224         status=$? 
    225         if [ ${status} -gt 0 ]; then 
    226             IGCM_debug_Print 2 "IGCM_sys_RshPost : ssh failed ${i}/${NB_ESSAI}" 
    227             IGCM_debug_Print 2 "IGCM_sys_RshPost : sleep ${DELAI} seconds and try again." 
    228             sleep $DELAI 
    229         else 
    230             break 
    231         fi 
    232         (( i = i + 1 )) 
    233     done  
    234     # delete temporary file 
    235     /bin/rm tmp_IGCM_sys_RshPost_$$ 
     232  typeset NB_ESSAI DELAI status i 
     233  # number of tentative 
     234  NB_ESSAI=10 
     235  # time delay between tentative 
     236  DELAI=10 
     237  (( i = 0 )) 
     238  while [ $i -lt $NB_ESSAI ] ; do 
     239    ssh -t mercure01 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     240    status=$? 
     241    if [ ${status} -gt 0 ]; then 
     242      IGCM_debug_Print 2 "IGCM_sys_RshPost : ssh failed ${i}/${NB_ESSAI}" 
     243      IGCM_debug_Print 2 "IGCM_sys_RshPost : sleep ${DELAI} seconds and try again." 
     244      sleep $DELAI 
     245    else 
     246      break 
     247    fi 
     248    (( i = i + 1 )) 
     249  done  
     250  # delete temporary file 
     251  /bin/rm tmp_IGCM_sys_RshPost_$$ 
    236252# ============ CESIUM  END  ============ # 
    237253 
    238 # Uncomment for frontend  
    239 #    /bin/ksh ${@} 
    240 #    if [ $? -gt 0 ] ; then 
    241 #       echo "IGCM_sys_RshPost : erreur." 
    242 #       IGCM_debug_Exit "IGCM_sys_RshPost" 
    243 #    fi 
    244  
    245     IGCM_debug_PopStack "IGCM_sys_RshPost" 
     254  IGCM_debug_PopStack "IGCM_sys_RshPost" 
    246255} 
    247256 
     
    252261#D- 
    253262function IGCM_sys_SendMail { 
    254     IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    255     if ( $DEBUG_sys ) ; then 
    256         echo "IGCM_sys_SendMail :" $@ 
    257     fi 
    258  
    259     if ( ${ExitFlag} ) ; then 
    260         status=failed 
    261     else 
    262         status=completed 
    263     fi 
    264     cat  << END_MAIL > job_end.mail 
    265 Dear ${LOGIN}, 
     263  IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
     264  if ( $DEBUG_sys ) ; then 
     265    echo "IGCM_sys_SendMail :" $@ 
     266  fi 
     267 
     268  if ( ${ExitFlag} ) ; then 
     269    status=failed 
     270  else 
     271    status=completed 
     272  fi 
     273  cat  << END_MAIL > job_end.mail 
     274  Dear ${LOGIN}, 
    266275 
    267276  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`. 
     
    272281END_MAIL 
    273282 
    274     if  [ X"${config_UserChoices_MailName}" != X ] ; then 
    275        mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail 
    276     elif [ -f ~/.forward ] ; then 
    277        mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
    278     else 
    279        mailx -s "${config_UserChoices_JobName} ${status}" ${LOGIN} < job_end.mail 
    280     fi 
    281  
    282     if [ $? -gt 0 ] ; then 
    283         echo "IGCM_sys_SendMail : erreur." 
    284         IGCM_debug_Exit "IGCM_sys_SendMail" 
    285     fi 
    286     IGCM_debug_PopStack "IGCM_sys_SendMail" 
     283  if  [ X"${config_UserChoices_MailName}" != X ] ; then 
     284    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail 
     285  elif [ -f ~/.forward ] ; then 
     286    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
     287  else 
     288    mailx -s "${config_UserChoices_JobName} ${status}" ${LOGIN} < job_end.mail 
     289  fi 
     290 
     291  if [ $? -gt 0 ] ; then 
     292    echo "IGCM_sys_SendMail : erreur." 
     293    IGCM_debug_Exit "IGCM_sys_SendMail" 
     294  fi 
     295  IGCM_debug_PopStack "IGCM_sys_SendMail" 
    287296} 
    288297 
     
    293302#D- 
    294303function IGCM_sys_Mkdir { 
    295     IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    296     if ( $DEBUG_sys ) ; then 
    297         echo "IGCM_sys_Mkdir :" $@ 
    298     fi 
    299     if [ ! -d ${1} ]; then 
    300         \mkdir -p $1 
    301         if [ $? -gt 0 ] ; then 
    302             echo "IGCM_sys_Mkdir : erreur." 
    303             IGCM_debug_Exit "IGCM_sys_Mkdir" 
    304         fi 
    305     fi 
    306     # vérification : 
    307     if [ ! -d ${1} ] ; then 
    308         echo "IGCM_sys_Mkdir : erreur." 
    309         IGCM_debug_Exit "IGCM_sys_Mkdir" 
    310     fi 
    311     IGCM_debug_PopStack "IGCM_sys_Mkdir" 
     304  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
     305  if ( $DEBUG_sys ) ; then 
     306    echo "IGCM_sys_Mkdir :" $@ 
     307  fi 
     308  if [ ! -d ${1} ]; then 
     309    \mkdir -p $1 
     310    if [ $? -gt 0 ] ; then 
     311      echo "IGCM_sys_Mkdir : erreur." 
     312      IGCM_debug_Exit "IGCM_sys_Mkdir" 
     313    fi 
     314  fi 
     315  # vérification : 
     316  if [ ! -d ${1} ] ; then 
     317    echo "IGCM_sys_Mkdir : erreur." 
     318    IGCM_debug_Exit "IGCM_sys_Mkdir" 
     319  fi 
     320  IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    312321} 
    313322 
     
    318327#D- 
    319328function IGCM_sys_MkdirArchive { 
    320     IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
    321     if ( $DEBUG_sys ) ; then 
    322         echo "IGCM_sys_MkdirArchive :" $@ 
    323     fi 
    324     #- creation de repertoire sur le serveur fichier 
    325     if [ ! -d ${1} ]; then  
    326         \mkdir -p $1 
    327         if [ $? -gt 0 ] ; then 
    328             echo "IGCM_sys_MkdirArchive : erreur." 
    329             IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
    330         fi 
    331     fi 
    332     IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
     329  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
     330  if ( $DEBUG_sys ) ; then 
     331    echo "IGCM_sys_MkdirArchive :" $@ 
     332  fi 
     333  #- creation de repertoire sur le serveur fichier 
     334  if [ ! -d ${1} ]; then  
     335    \mkdir -p $1 
     336    if [ $? -gt 0 ] ; then 
     337      echo "IGCM_sys_MkdirArchive : erreur." 
     338      IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
     339    fi 
     340  fi 
     341  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    333342} 
    334343 
     
    339348#D- 
    340349function IGCM_sys_MkdirWork { 
    341     IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    342     if ( $DEBUG_sys ) ; then 
    343         echo "IGCM_sys_MkdirWork :" $@ 
    344     fi 
    345     #- creation de repertoire sur le serveur fichier 
    346     if [ ! -d ${1} ]; then  
    347         \mkdir -p $1 
    348         if [ $? -gt 0 ] ; then 
    349             echo "IGCM_sys_MkdirWork : erreur." 
    350             IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    351         fi 
    352     fi 
    353     IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
     350  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
     351  if ( $DEBUG_sys ) ; then 
     352    echo "IGCM_sys_MkdirWork :" $@ 
     353  fi 
     354  #- creation de repertoire sur le serveur fichier 
     355  if [ ! -d ${1} ]; then  
     356    \mkdir -p $1 
     357    if [ $? -gt 0 ] ; then 
     358      echo "IGCM_sys_MkdirWork : erreur." 
     359      IGCM_debug_Exit "IGCM_sys_MkdirWork" 
     360    fi 
     361  fi 
     362  IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    354363} 
    355364 
     
    360369#D- 
    361370function IGCM_sys_Cd { 
    362     IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    363     if ( $DEBUG_sys ) ; then 
    364         echo "IGCM_sys_Cd :" $@ 
    365     fi 
    366     \cd $1 
    367     if [ $? -gt 0 ] ; then 
    368         echo "IGCM_sys_Cd : erreur." 
    369         IGCM_debug_Exit "IGCM_sys_Cd" 
    370     fi 
    371     IGCM_debug_PopStack "IGCM_sys_Cd" 
     371  IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
     372  if ( $DEBUG_sys ) ; then 
     373    echo "IGCM_sys_Cd :" $@ 
     374  fi 
     375  \cd $1 
     376  if [ $? -gt 0 ] ; then 
     377    echo "IGCM_sys_Cd : erreur." 
     378    IGCM_debug_Exit "IGCM_sys_Cd" 
     379  fi 
     380  IGCM_debug_PopStack "IGCM_sys_Cd" 
    372381} 
    373382 
     
    378387#D- 
    379388function IGCM_sys_Chmod { 
    380     IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
    381     if ( $DEBUG_sys ) ; then 
    382         echo "IGCM_sys_Chmod :" $@ 
    383     fi 
    384     if [ $DRYRUN -le 1 ]; then 
    385         \chmod $@ 
    386         if [ $? -gt 0 ] ; then 
    387             echo "IGCM_sys_Chmod : erreur." 
    388             IGCM_debug_Exit "IGCM_sys_Chmod" 
    389         fi 
    390     else 
    391         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    392     fi 
    393     IGCM_debug_PopStack "IGCM_sys_Chmod" 
     389  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
     390  if ( $DEBUG_sys ) ; then 
     391    echo "IGCM_sys_Chmod :" $@ 
     392  fi 
     393  if [ $DRYRUN -le 1 ]; then 
     394    \chmod $@ 
     395    if [ $? -gt 0 ] ; then 
     396      echo "IGCM_sys_Chmod : erreur." 
     397      IGCM_debug_Exit "IGCM_sys_Chmod" 
     398    fi 
     399  else 
     400    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     401  fi 
     402  IGCM_debug_PopStack "IGCM_sys_Chmod" 
    394403} 
    395404 
    396405#D-#================================================== 
    397406#D-function IGCM_sys_FileSize 
    398 #D-* Purpose: File size 
     407#D-* Purpose: Filesize 
    399408#D-* Examples: 
    400409#D- 
    401410function IGCM_sys_FileSize { 
    402     IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    403  
    404     typeset sizeF 
    405     set +A sizeF -- $( ls -la ${1} ) 
    406     if [ $? -gt 0 ] ; then 
    407         IGCM_debug_Exit "IGCM_sys_FileSize" 
    408     fi 
    409     eval ${2}=${sizeF[4]} 
    410  
    411     IGCM_debug_PopStack "IGCM_sys_FileSize" 
     411  IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
     412 
     413  typeset sizeF 
     414  set +A sizeF -- $( ls -la ${1} ) 
     415  if [ $? -gt 0 ] ; then 
     416    IGCM_debug_Exit "IGCM_sys_FileSize" 
     417  fi 
     418  eval ${2}=${sizeF[4]} 
     419 
     420  IGCM_debug_PopStack "IGCM_sys_FileSize" 
    412421} 
    413422 
     
    418427#D- 
    419428function IGCM_sys_TestDir { 
    420     IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    421     if ( $DEBUG_sys ) ; then 
    422         echo "IGCM_sys_TestDir :" $@ 
    423     fi 
    424     typeset ExistFlag 
    425     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    426     IGCM_debug_PopStack "IGCM_sys_TestDir" 
    427  
    428     return ${ExistFlag} 
     429  IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
     430  if ( $DEBUG_sys ) ; then 
     431    echo "IGCM_sys_TestDir :" $@ 
     432  fi 
     433  typeset ExistFlag 
     434  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     435  IGCM_debug_PopStack "IGCM_sys_TestDir" 
     436 
     437  return ${ExistFlag} 
    429438} 
    430439 
     
    435444#D- 
    436445function IGCM_sys_TestDirArchive { 
    437     IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
    438     if ( $DEBUG_sys ) ; then 
    439         echo "IGCM_sys_TestDirArchive :" $@ 
    440     fi 
    441     typeset ExistFlag 
    442     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    443     IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
    444  
    445     return ${ExistFlag} 
     446  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
     447  if ( $DEBUG_sys ) ; then 
     448    echo "IGCM_sys_TestDirArchive :" $@ 
     449  fi 
     450  typeset ExistFlag 
     451  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     452  IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
     453 
     454  return ${ExistFlag} 
    446455} 
    447456 
     
    452461#D- 
    453462function IGCM_sys_TestFileArchive { 
    454     IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    455     typeset ExistFlag 
    456     ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    457     IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    458  
    459     return ${ExistFlag} 
     463  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
     464  if ( $DEBUG_sys ) ; then 
     465    echo "IGCM_sys_TestFileArchive :" $@ 
     466  fi 
     467  typeset ExistFlag 
     468  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     469  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
     470 
     471  return ${ExistFlag} 
     472} 
     473 
     474#D-#================================================== 
     475#D-function IGCM_sys_TestFileBuffer 
     476#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     477#D-* Examples: 
     478#D- 
     479function IGCM_sys_TestFileBuffer { 
     480  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     481  typeset ExistFlag 
     482  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     483  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     484 
     485  return ${ExistFlag} 
    460486} 
    461487 
     
    466492#D- 
    467493function IGCM_sys_CountFileArchive { 
    468     IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
    469     ls ${@} 2>/dev/null | wc -l 
    470     if [ $? -gt 0 ] ; then 
    471         echo "IGCM_sys_CountFileArchive : erreur." 
    472     fi 
    473     IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     494  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
     495  ls ${@} 2>/dev/null | wc -l 
     496  if [ $? -gt 0 ] ; then 
     497    echo "IGCM_sys_CountFileArchive : erreur." 
     498  fi 
     499  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     500} 
     501 
     502#D-#================================================== 
     503#D-function IGCM_sys_CountFileBuffer 
     504#D-* Purpose: Count files on Scratch filesystem 
     505#D-* Examples: 
     506#D- 
     507function IGCM_sys_CountFileBuffer { 
     508  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     509  ls ${@} 2>/dev/null | wc -l 
     510  if [ $? -gt 0 ] ; then 
     511    echo "IGCM_sys_CountFileBuffer : erreur." 
     512  fi 
     513  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    474514} 
    475515 
     
    480520#D- 
    481521function IGCM_sys_Tree { 
    482     IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
    483     if ( $DEBUG_sys ) ; then 
    484         echo "IGCM_sys_Tree :" $@ 
    485     fi 
    486  
    487     \ls -lR ${@} 
    488  
    489     IGCM_debug_PopStack "IGCM_sys_Tree" 
     522  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     523  if ( $DEBUG_sys ) ; then 
     524    echo "IGCM_sys_Tree :" $@ 
     525  fi 
     526 
     527  \ls -lR ${@} 
     528 
     529  IGCM_debug_PopStack "IGCM_sys_Tree" 
    490530} 
    491531 
    492532#D-#================================================== 
    493533#D-function IGCM_sys_Tar 
    494 #D-* Purpose: master un-tar command 
     534#D-* Purpose: master tar command 
    495535#D-* Examples: 
    496536#D- 
    497537function IGCM_sys_Tar { 
    498     IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    499     if ( $DEBUG_sys ) ; then 
    500         echo "IGCM_sys_Tar :" $@ 
    501     fi 
    502     \tar cf $@ 
    503     if [ $? -gt 0 ] ; then 
    504         echo "IGCM_sys_Tar : erreur." 
    505         IGCM_debug_Exit "IGCM_sys_Tar" 
    506     fi 
    507     IGCM_debug_PopStack "IGCM_sys_Tar" 
     538  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     539  if ( $DEBUG_sys ) ; then 
     540    echo "IGCM_sys_Tar :" $@ 
     541  fi 
     542  \tar cf $@ 
     543  if [ $? -gt 0 ] ; then 
     544    echo "IGCM_sys_Tar : erreur." 
     545    IGCM_debug_Exit "IGCM_sys_Tar" 
     546  fi 
     547  IGCM_debug_PopStack "IGCM_sys_Tar" 
    508548} 
    509549 
     
    514554#D- 
    515555function IGCM_sys_UnTar { 
    516     IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    517     if ( $DEBUG_sys ) ; then 
    518         echo "IGCM_sys_UnTar :" $@ 
    519     fi 
    520     \tar xvf $1 
    521     if [ $? -gt 0 ] ; then 
    522         echo "IGCM_sys_UnTar : erreur." 
    523         IGCM_debug_Exit "IGCM_sys_UnTar" 
    524     fi 
    525     IGCM_debug_PopStack "IGCM_sys_UnTar" 
     556  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     557  if ( $DEBUG_sys ) ; then 
     558    echo "IGCM_sys_UnTar :" $@ 
     559  fi 
     560  \tar xvf $1 
     561  if [ $? -gt 0 ] ; then 
     562    echo "IGCM_sys_UnTar : erreur." 
     563    IGCM_debug_Exit "IGCM_sys_UnTar" 
     564  fi 
     565  IGCM_debug_PopStack "IGCM_sys_UnTar" 
    526566} 
    527567 
     
    532572#D- 
    533573function IGCM_sys_Qsub { 
    534     IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
    535     if ( $DEBUG_sys ) ; then 
    536         echo "IGCM_sys_Qsub :" $@ 
    537     fi 
    538     /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1 
    539     if [ $? -gt 0 ] ; then 
    540         echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@." 
    541         IGCM_debug_Exit "IGCM_sys_Qsub" 
    542     fi 
    543     IGCM_debug_PopStack "IGCM_sys_Qsub" 
     574  IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
     575  if ( $DEBUG_sys ) ; then 
     576    echo "IGCM_sys_Qsub :" $@ 
     577  fi 
     578  /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1 
     579  if [ $? -gt 0 ] ; then 
     580    echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@." 
     581    IGCM_debug_Exit "IGCM_sys_Qsub" 
     582  fi 
     583  IGCM_debug_PopStack "IGCM_sys_Qsub" 
    544584} 
    545585 
     
    550590#D- 
    551591function IGCM_sys_QsubPost { 
    552     IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
    553     if ( $DEBUG_sys ) ; then 
    554         echo "IGCM_sys_QsubPost :" $@ 
    555     fi 
    556     # ============ CESIUM START ============ # 
    557     typeset NB_ESSAI DELAI status i 
    558     # number of tentative 
    559     NB_ESSAI=10 
    560     # time delay between tentative 
    561     DELAI=10 
    562     (( i = 0 )) 
    563     while [ $i -lt $NB_ESSAI ] ; do 
    564         /usr/local/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.e.out -E "-v ${listVarEnv}" ${libIGCM_POST}/$1.job 
    565         status=$? 
    566         if [ ${status} -gt 0 ]; 
    567         then 
    568             sleep $DELAI 
    569         else 
    570             break 
    571         fi 
    572         (( i = i + 1 )) 
    573     done  
    574     # ============ CESIUM  END  ============ # 
    575     #/usr/bin/nqsII/qsub -o ${POST_DIR}/$1.${PeriodDateEnd}.out ${libIGCM}/$1.job -v ${listVarEnv} 
    576     if [ $? -gt 0 ] ; then 
    577         echo "IGCM_sys_QsubPost : erreur " $@ 
    578         IGCM_debug_Exit "IGCM_sys_QsubPost" 
    579     fi 
    580     IGCM_debug_PopStack "IGCM_sys_QsubPost" 
     592  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     593  if ( $DEBUG_sys ) ; then 
     594    echo "IGCM_sys_QsubPost :" $@ 
     595  fi 
     596 
     597# ============ FRONTEND START ============ # 
     598 
     599#  /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv} 
     600 
     601# ============ FRONTEND  END  ============ # 
     602 
     603# ============ CESIUM START ============ # 
     604  typeset NB_ESSAI DELAI status i 
     605  # number of tentative 
     606  NB_ESSAI=10 
     607  # time delay between tentative 
     608  DELAI=10 
     609  (( i = 0 )) 
     610  while [ $i -lt $NB_ESSAI ] ; do 
     611    /usr/local/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.e.out -E "-v ${listVarEnv}" ${libIGCM_POST}/$1.job 
     612    status=$? 
     613    if [ ${status} -gt 0 ]; then 
     614      sleep $DELAI 
     615    else 
     616      break 
     617    fi 
     618    (( i = i + 1 )) 
     619  done  
     620# ============ CESIUM  END  ============ # 
     621 
     622  if [ $? -gt 0 ] ; then 
     623    echo "IGCM_sys_QsubPost : erreur " $@ 
     624    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     625  fi 
     626  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    581627} 
    582628 
     
    592638#D-  Error values and explanations can depend on your system version. 
    593639function IGCM_sys_Rsync_out { 
    594     RET=$1 
    595     if [ ! $RET ] ; then 
    596         echo "rsync error !" 
    597     fi 
    598  
    599     if [ $MYLANG = "fr" ]; then 
    600         case $RET in 
    601             0)  return ;; 
    602             1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    603                 echo "Erreur de syntaxe ou d'utilisation." 
    604                 return;; 
    605             2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    606                 echo "Incompatibilité de protocole." 
    607                 return;; 
    608             3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    609                 echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    610                 echo "répertoires" 
    611                 return;; 
    612             4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    613                 echo "Action demandée non supportée : une tentative de manipulation de" 
    614                 echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    615                 echo "été faite ; ou une option qui est supportée par le  client  mais" 
    616                 echo "pas par le serveur a été spécifiée." 
    617                 return;; 
    618             10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    619                 echo "Erreur dans le socket d'entrée sortie" 
    620                 return;; 
    621             11) echo "Erreur de rsync ; RERR_FILEIO" 
    622                 echo "Erreur d'entrée sortie fichier" 
    623                 return;; 
    624             12) echo "Erreur de rsync ; RERR_STREAMIO" 
    625                 echo "Erreur dans flux de donnée du protocole rsync" 
    626                 return;; 
    627             13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    628                 echo "Erreur avec les diagnostics du programme" 
    629                 return;; 
    630             14) echo "Erreur de rsync ; RERR_IPC" 
    631                 echo "Erreur dans le code IPC" 
    632                 return;; 
    633             20) echo "Erreur de rsync ; RERR_SIGNAL" 
    634                 echo "SIGUSR1 ou SIGINT reçu" 
    635                 return;; 
    636             21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    637                 echo "Une erreur retournée par waitpid()" 
    638                 return;; 
    639             22) echo "Erreur de rsync ; RERR_MALLOC" 
    640                 echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    641                 return;; 
    642             23) echo "" 
    643                 echo "Erreur fichier inexistant" 
    644                 return;; 
    645             30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    646                 echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    647                 return;; 
    648             *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
    649                 return;; 
    650         esac 
    651     elif [ $MYLANG = "en" ] ; then 
    652         case $RET in 
    653             0)  return;;                 
    654             1)  echo "rsync error : Syntax or usage error " 
    655                 return;; 
    656             2)  echo "rsync error : Protocol incompatibility " 
    657                 return;; 
    658             3)  echo "rsync error : Errors selecting input/output files, dirs" 
    659                 return;; 
    660             4)  echo "rsync error : Requested action not supported: an attempt" 
    661                 echo "was made to manipulate 64-bit files on a platform that cannot support" 
    662                 echo "them; or an option was specified that is supported by the client and" 
    663                 echo "not by the server." 
    664                 return;; 
    665             5)  echo "rsync error : Error starting client-server protocol" 
    666                 return;; 
    667             10) echo "rsync error : Error in socket I/O " 
    668                 return;; 
    669             11) echo "rsync error : Error in file I/O " 
    670                 return;; 
    671             12) echo "rsync error : Error in rsync protocol data stream " 
    672                 return;; 
    673             13) echo "rsync error : Errors with program diagnostics " 
    674                 return;; 
    675             14) echo "rsync error : Error in IPC code " 
    676                 return;; 
    677             20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    678                 return;; 
    679             21) echo "rsync error : Some error returned by waitpid() " 
    680                 return;; 
    681             22) echo "rsync error : Error allocating core memory buffers " 
    682                 return;; 
    683             23) echo "rsync error : Partial transfer due to error" 
    684                 return;; 
    685             24) echo "rsync error : Partial transfer due to vanished source files" 
    686                 return;; 
    687             30) echo "rsync error : Timeout in data send/receive " 
    688                 return;; 
    689             *)  echo "rsync error : return code of rsync unknown :" $RET 
    690                 return;; 
    691         esac 
    692     else 
    693         echo "unknown language $MYLANG." 
    694         return 
    695     fi 
    696 } 
    697      
     640  RET=$1 
     641  if [ ! $RET ] ; then 
     642    echo "rsync error !" 
     643  fi 
     644 
     645  if [ $MYLANG = "fr" ]; then 
     646    case $RET in 
     647    0)  return ;; 
     648    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     649      echo "Erreur de syntaxe ou d'utilisation." 
     650      return;; 
     651    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     652      echo "Incompatibilité de protocole." 
     653      return;; 
     654    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     655      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     656      echo "répertoires" 
     657      return;; 
     658    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     659      echo "Action demandée non supportée : une tentative de manipulation de" 
     660      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     661      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     662      echo "pas par le serveur a été spécifiée." 
     663      return;; 
     664    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     665      echo "Erreur dans le socket d'entrée sortie" 
     666      return;; 
     667    11) echo "Erreur de rsync ; RERR_FILEIO" 
     668      echo "Erreur d'entrée sortie fichier" 
     669      return;; 
     670    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     671      echo "Erreur dans flux de donnée du protocole rsync" 
     672      return;; 
     673    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     674      echo "Erreur avec les diagnostics du programme" 
     675      return;; 
     676    14) echo "Erreur de rsync ; RERR_IPC" 
     677      echo "Erreur dans le code IPC" 
     678      return;; 
     679    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     680      echo "SIGUSR1 ou SIGINT reçu" 
     681      return;; 
     682    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     683      echo "Une erreur retournée par waitpid()" 
     684      return;; 
     685    22) echo "Erreur de rsync ; RERR_MALLOC" 
     686      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     687      return;; 
     688    23) echo "" 
     689      echo "Erreur fichier inexistant" 
     690      return;; 
     691    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     692      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     693      return;; 
     694    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     695      return;; 
     696    esac 
     697  elif [ $MYLANG = "en" ] ; then 
     698    case $RET in 
     699    0)  return;;                 
     700    1)  echo "rsync error : Syntax or usage error " 
     701      return;; 
     702    2)  echo "rsync error : Protocol incompatibility " 
     703      return;; 
     704    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     705      return;; 
     706    4)  echo "rsync error : Requested action not supported: an attempt" 
     707      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     708      echo "them; or an option was specified that is supported by the client and" 
     709      echo "not by the server." 
     710      return;; 
     711    5)  echo "rsync error : Error starting client-server protocol" 
     712      return;; 
     713    10) echo "rsync error : Error in socket I/O " 
     714      return;; 
     715    11) echo "rsync error : Error in file I/O " 
     716      return;; 
     717    12) echo "rsync error : Error in rsync protocol data stream " 
     718      return;; 
     719    13) echo "rsync error : Errors with program diagnostics " 
     720      return;; 
     721    14) echo "rsync error : Error in IPC code " 
     722      return;; 
     723    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     724      return;; 
     725    21) echo "rsync error : Some error returned by waitpid() " 
     726      return;; 
     727    22) echo "rsync error : Error allocating core memory buffers " 
     728      return;; 
     729    23) echo "rsync error : Partial transfer due to error" 
     730      return;; 
     731    24) echo "rsync error : Partial transfer due to vanished source files" 
     732      return;; 
     733    30) echo "rsync error : Timeout in data send/receive " 
     734      return;; 
     735    *)  echo "rsync error : return code of rsync unknown :" $RET 
     736      return;; 
     737    esac 
     738  else 
     739    echo "unknown language $MYLANG." 
     740    return 
     741  fi 
     742} 
    698743 
    699744#D-#================================================== 
     
    703748#D- 
    704749function IGCM_sys_Mirror_libIGCM { 
    705     IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    706     if ( $DEBUG_sys ) ; then 
    707         echo "IGCM_sys_Mirror_libIGCM" 
    708     fi 
    709  
    710     typeset RET DEST 
    711  
    712     mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    713  
    714     echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
    715     ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
    716     RET=$? 
    717  
    718     if [ ${RET} -gt 0 ] ; then 
    719         echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
    720         cat out_rsync 
    721     fi 
    722     IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
     750  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
     751  if ( $DEBUG_sys ) ; then 
     752    echo "IGCM_sys_Mirror_libIGCM" 
     753  fi 
     754 
     755  typeset RET DEST 
     756 
     757  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
     758 
     759  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
     760  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
     761  RET=$? 
     762 
     763  if [ ${RET} -gt 0 ] ; then 
     764    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
     765    cat out_rsync 
     766  fi 
     767  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    723768} 
    724769 
     
    726771#- Call IGCM_sys_Mirror_libIGCM now ! 
    727772if ( $MirrorlibIGCM ) ; then 
    728     IGCM_sys_Mirror_libIGCM 
     773  IGCM_sys_Mirror_libIGCM 
    729774fi 
    730775 
     
    735780#D- 
    736781function IGCM_sys_Cp { 
    737     IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    738     if ( $DEBUG_sys ) ; then 
    739         echo "IGCM_sys_Cp :" $@ 
    740     fi 
    741  
    742     typeset RET 
    743  
    744     echo cp $@ > out_rsync 2>&1 
    745     \cp $@ >> out_rsync 2>&1 
    746     RET=$? 
    747  
    748     if [ ${RET} -gt 0 ] ; then 
    749         echo "IGCM_sys_Cp : error." 
    750         cat out_rsync 
    751         IGCM_debug_Exit "IGCM_sys_Cp" 
    752      else 
    753         \rm out_rsync 
    754     fi 
    755     IGCM_debug_PopStack "IGCM_sys_Cp" 
     782  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     783  if ( $DEBUG_sys ) ; then 
     784    echo "IGCM_sys_Cp :" $@ 
     785  fi 
     786 
     787  typeset RET 
     788 
     789  echo cp $@ > out_rsync 2>&1 
     790  \cp $@ >> out_rsync 2>&1 
     791  RET=$? 
     792 
     793  if [ ${RET} -gt 0 ] ; then 
     794    echo "IGCM_sys_Cp : error." 
     795    cat out_rsync 
     796    IGCM_debug_Exit "IGCM_sys_Cp" 
     797  else 
     798    \rm out_rsync 
     799  fi 
     800  IGCM_debug_PopStack "IGCM_sys_Cp" 
    756801} 
    757802 
     
    762807#D- 
    763808function IGCM_sys_Rm { 
    764     IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
    765     if ( $DEBUG_sys ) ; then 
    766         echo "IGCM_sys_Rm :" $@ 
    767     fi 
    768  
    769     typeset RET 
    770  
    771     echo rm $@ > out_rsync 2>&1 
    772     \rm $@ >> out_rsync 2>&1 
    773     RET=$? 
    774  
    775     if [ ${RET} -gt 0 ] ; then 
    776         echo "IGCM_sys_Rm : error." 
    777         cat out_rsync 
    778         IGCM_debug_Exit "IGCM_sys_Rm" 
    779     else 
    780         \rm out_rsync 
    781     fi 
    782     IGCM_debug_PopStack "IGCM_sys_Rm" 
     809  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     810  if ( $DEBUG_sys ) ; then 
     811    echo "IGCM_sys_Rm :" $@ 
     812  fi 
     813 
     814  typeset RET 
     815 
     816  echo rm $@ > out_rsync 2>&1 
     817  \rm $@ >> out_rsync 2>&1 
     818  RET=$? 
     819 
     820  if [ ${RET} -gt 0 ] ; then 
     821    echo "IGCM_sys_Rm : error." 
     822    cat out_rsync 
     823    IGCM_debug_Exit "IGCM_sys_Rm" 
     824  else 
     825    \rm out_rsync 
     826  fi 
     827  IGCM_debug_PopStack "IGCM_sys_Rm" 
    783828} 
    784829 
     
    789834#D- 
    790835function IGCM_sys_Mv { 
    791     IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    792     if ( $DEBUG_sys ) ; then 
    793         echo "IGCM_sys_Mv :" $@ 
    794     fi 
    795  
    796     if [ $DRYRUN = 0 ]; then 
    797  
    798         typeset RET 
    799              
    800         echo mv $@ > out_rsync 2>&1 
    801         \mv $@ >> out_rsync 2>&1 
    802         RET=$? 
     836  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     837  if ( $DEBUG_sys ) ; then 
     838    echo "IGCM_sys_Mv :" $@ 
     839  fi 
     840 
     841  if [ $DRYRUN = 0 ]; then 
     842 
     843    typeset RET 
    803844     
    804         if [ ${RET} -gt 0 ] ; then 
    805             echo "IGCM_sys_Mv : error in mv." 
    806             cat out_rsync 
    807             IGCM_debug_Exit "IGCM_sys_Mv" 
    808         else 
    809             \rm out_rsync 
    810         fi 
     845    echo mv $@ > out_rsync 2>&1 
     846    \mv $@ >> out_rsync 2>&1 
     847    RET=$? 
     848     
     849    if [ ${RET} -gt 0 ] ; then 
     850      echo "IGCM_sys_Mv : error in mv." 
     851      cat out_rsync 
     852      IGCM_debug_Exit "IGCM_sys_Mv" 
    811853    else 
    812         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    813     fi 
    814  
    815     IGCM_debug_PopStack "IGCM_sys_Mv" 
     854      \rm out_rsync 
     855    fi 
     856  else 
     857    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     858  fi 
     859 
     860  IGCM_debug_PopStack "IGCM_sys_Mv" 
    816861} 
    817862 
     
    822867#D- 
    823868function IGCM_sys_Put_Dir { 
    824     IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
    825     if ( $DEBUG_sys ) ; then 
    826         echo "IGCM_sys_Put_Dir :" $@ 
    827     fi 
    828     if [ $DRYRUN = 0 ]; then 
    829         if [ ! -d ${1} ] ; then 
    830             echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
    831             IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    832             return 
    833         fi 
    834  
    835         typeset RET 
    836  
    837         # Only if we use rsync 
    838         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    839         # 
    840         #USUAL WAY 
    841         \cp -r $1 $2 > out_rsync 2>&1 
    842         RET=$? 
    843  
    844         if [ ${RET} -gt 0 ] ; then 
    845             echo "IGCM_sys_Put_Dir : error." 
    846             cat out_rsync 
    847             IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    848         else 
    849             \rm out_rsync 
    850         fi 
     869  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     870  if ( $DEBUG_sys ) ; then 
     871    echo "IGCM_sys_Put_Dir :" $@ 
     872  fi 
     873  if [ $DRYRUN = 0 ]; then 
     874    if [ ! -d ${1} ] ; then 
     875      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     876      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     877      return 
     878    fi 
     879 
     880    typeset RET 
     881 
     882    # Only if we use rsync 
     883    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     884    # 
     885    #USUAL WAY 
     886    \cp -r $1 $2 > out_rsync 2>&1 
     887    RET=$? 
     888 
     889    if [ ${RET} -gt 0 ] ; then 
     890      echo "IGCM_sys_Put_Dir : error." 
     891      cat out_rsync 
     892      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    851893    else 
    852         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    853     fi 
    854     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     894      \rm out_rsync 
     895    fi 
     896  else 
     897    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     898  fi 
     899  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    855900} 
    856901 
    857902#D-#================================================== 
    858903#D-function IGCM_sys_Get_Dir 
    859 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     904#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    860905#D-* Examples: 
    861906#D- 
    862907function IGCM_sys_Get_Dir { 
    863     IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
    864     if ( $DEBUG_sys ) ; then 
    865         echo "IGCM_sys_Get_Dir :" $@ 
    866     fi 
    867     if [ $DRYRUN = 0 ]; then 
    868         if [ ! -d ${1} ] ; then 
    869             echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
    870             IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    871             return 
    872         fi 
    873  
    874         typeset RET 
    875  
    876         # Only if we use rsync 
    877         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    878         # 
    879         #USUAL WAY 
    880         \cp -r $1 $2 > out_rsync 2>&1 
    881         RET=$? 
    882  
    883         if [ ${RET} -gt 0 ] ; then 
    884             echo "IGCM_sys_Get_Dir : error." 
    885             cat out_rsync 
    886             IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    887         else 
    888             \rm out_rsync 
    889         fi 
     908  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     909  if ( $DEBUG_sys ) ; then 
     910    echo "IGCM_sys_Get_Dir :" $@ 
     911  fi 
     912  if [ $DRYRUN = 0 ]; then 
     913#    if [ ! -d ${1} ] ; then 
     914#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     915#      IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     916#      return 
     917#    fi 
     918 
     919    typeset RET 
     920 
     921    # Only if we use rsync 
     922    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     923    # 
     924    # USUAL WAY 
     925    # add dmfind/dmget (to demigrate all offline files) : 
     926    dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget 
     927    \cp -r $1 $2 > out_rsync 2>&1 
     928    RET=$? 
     929 
     930    if [ ${RET} -gt 0 ] ; then 
     931      echo "IGCM_sys_Get_Dir : error." 
     932      cat out_rsync 
     933      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    890934    else 
    891         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    892     fi 
    893     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     935      \rm out_rsync 
     936    fi 
     937  else 
     938    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     939  fi 
     940  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    894941} 
    895942 
    896943#D-#================================================== 
    897944#D-function IGCM_sys_Put_Rest 
    898 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     945#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    899946#D-           File and target directory must exist. 
    900947#D-* Examples: 
    901948#D- 
    902949function IGCM_sys_Put_Rest { 
    903     IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
    904     if ( $DEBUG_sys ) ; then 
    905         echo "IGCM_sys_Put_Rest :" $@ 
    906     fi 
    907     if [ $DRYRUN = 0 ]; then 
    908         if [ ! -f ${1} ] ; then 
    909             echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
    910             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    911         fi 
    912  
    913         typeset RET 
    914         # 
    915         if [ X${JobType} = XRUN ] ; then 
    916             IGCM_sys_Chmod 444 ${1} 
    917         fi 
    918         # 
    919         IGCM_sys_TestDirArchive $( dirname $2 ) 
    920         # 
    921         # USUAL WAY 
    922         putfer $1 $2 > out_rsync 2>&1 
    923         RET=$? 
     950  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     951  if ( $DEBUG_sys ) ; then 
     952    echo "IGCM_sys_Put_Rest :" $@ 
     953  fi 
     954  if [ $DRYRUN = 0 ]; then 
     955    if [ ! -f ${1} ] ; then 
     956      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     957      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     958    fi 
     959 
     960    typeset RET 
     961    # 
     962    if [ X${JobType} = XRUN ] ; then 
     963      IGCM_sys_Chmod 444 ${1} 
     964    fi 
     965 
     966    # 
     967    # USUAL WAY 
     968    \cp $1 $2 > out_rsync 2>&1 
     969    RET=$? 
    924970 
    925971#       #RSYNC WITH NETWORK SSH CALL 
     
    937983#       (( RET=RET+$? )) 
    938984 
    939         if [ ${RET} -gt 0 ] ; then 
    940             echo "IGCM_sys_Put_Rest : error." 
    941             cat out_rsync 
    942             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    943         else 
    944             \rm out_rsync 
    945         fi 
     985    if [ ${RET} -gt 0 ] ; then 
     986      echo "IGCM_sys_Put_Rest : error." 
     987      cat out_rsync 
     988      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    946989    else 
    947         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    948     fi 
    949     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     990      \rm out_rsync 
     991    fi 
     992  else 
     993    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     994  fi 
     995  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     996} 
     997 
     998#D-#================================================== 
     999#D-function IGCM_sys_PutBuffer_Rest 
     1000#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     1001#D-           File and target directory must exist. 
     1002#D-* Examples: 
     1003#D- 
     1004function IGCM_sys_PutBuffer_Rest { 
     1005  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     1006  if ( $DEBUG_sys ) ; then 
     1007    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     1008  fi 
     1009  if [ $DRYRUN = 0 ]; then 
     1010    if [ ! -f ${1} ] ; then 
     1011      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     1012      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1013    fi 
     1014 
     1015    typeset RET 
     1016    # 
     1017    if [ X${JobType} = XRUN ] ; then 
     1018      IGCM_sys_Chmod 444 ${1} 
     1019    fi 
     1020 
     1021    # 
     1022    # USUAL WAY 
     1023    \cp $1 $2 > out_rsync 2>&1 
     1024    RET=$? 
     1025 
     1026    if [ ${RET} -gt 0 ] ; then 
     1027      echo "IGCM_sys_PutBuffer_Rest : error." 
     1028      cat out_rsync 
     1029      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1030    else 
     1031      \rm out_rsync 
     1032    fi 
     1033  else 
     1034    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1035  fi 
     1036  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    9501037} 
    9511038 
    9521039#D-#================================================== 
    9531040#D-function IGCM_sys_Put_Out 
    954 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     1041#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    9551042#D-* Examples: 
    9561043#D- 
    9571044function IGCM_sys_Put_Out { 
    958     IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
    959     if ( $DEBUG_sys ) ; then 
    960         echo "IGCM_sys_Put_Out :" $@ 
    961     fi 
    962     if [ $DRYRUN = 0 ]; then 
    963         if [ ! -f ${1} ] ; then 
    964             echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
    965             IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    966             return 1 
    967         fi 
    968         # 
    969         IGCM_sys_MkdirArchive $( dirname $2 ) 
    970         # 
    971         typeset RET 
    972  
    973         #===================================================== 
    974         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    975         #===================================================== 
    976  
    977         #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
    978         #if [ $? -eq 0 ] ; then 
    979         #    typeset WORKPATH FILEPATH 
    980         #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    981         #    IGCM_sys_MkdirWork ${WORKPATH}  
    982         #    FILEPATH=${WORKPATH}/$( basename $2 ) 
    983         #    # 
    984         #    IGCM_sys_Cp ${1} ${FILEPATH} 
    985         #fi 
    986  
    987         if [ X${JobType} = XRUN ] ; then 
    988             if [ X${3} = X ] ; then 
    989                 IGCM_sys_Chmod 444 ${1} 
    990             fi 
    991         fi 
    992         # 
    993         # USUAL WAY 
    994         putfer $1 $2 > out_rsync 2>&1 
    995         RET=$? 
     1045  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     1046  if ( $DEBUG_sys ) ; then 
     1047    echo "IGCM_sys_Put_Out :" $@ 
     1048  fi 
     1049  if [ $DRYRUN = 0 ]; then 
     1050    if [ ! -f ${1} ] ; then 
     1051      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     1052      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1053      return 1 
     1054    fi 
     1055    # 
     1056    IGCM_sys_MkdirArchive $( dirname $2 ) 
     1057    # 
     1058    typeset RET 
     1059 
     1060    #===================================================== 
     1061    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1062    #===================================================== 
     1063 
     1064    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     1065    #if [ $? -eq 0 ] ; then 
     1066    #    typeset WORKPATH FILEPATH 
     1067    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     1068    #    IGCM_sys_MkdirWork ${WORKPATH}  
     1069    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     1070    #    # 
     1071    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1072    #fi 
     1073 
     1074    if [ X${JobType} = XRUN ] ; then 
     1075      if [ X${3} = X ] ; then 
     1076        IGCM_sys_Chmod 444 ${1} 
     1077      fi 
     1078    fi 
     1079    # 
     1080    # USUAL WAY 
     1081    \cp $1 $2 > out_rsync 2>&1 
     1082    RET=$? 
    9961083 
    9971084#       #RSYNC WITH NETWORK SSH CALL 
     
    10091096#       (( RET=RET+$? )) 
    10101097 
    1011         if [ ${RET} -gt 0 ] ; then 
    1012             echo "IGCM_sys_Put_Out : error." 
    1013             cat out_rsync 
    1014             IGCM_debug_Exit "IGCM_sys_Put_Out" 
    1015         else 
    1016             \rm out_rsync 
    1017         fi 
     1098    if [ ${RET} -gt 0 ] ; then 
     1099      echo "IGCM_sys_Put_Out : error." 
     1100      cat out_rsync 
     1101      IGCM_debug_Exit "IGCM_sys_Put_Out" 
    10181102    else 
    1019         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1020     fi 
    1021     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1022     return 0 
     1103      \rm out_rsync 
     1104    fi 
     1105  else 
     1106    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1107  fi 
     1108  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1109  return 0 
     1110} 
     1111 
     1112#D-#================================================== 
     1113#D-function IGCM_sys_PutBuffer_Out 
     1114#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
     1115#D-* Examples: 
     1116#D- 
     1117function IGCM_sys_PutBuffer_Out { 
     1118  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     1119  if ( $DEBUG_sys ) ; then 
     1120    echo "IGCM_sys_PutBuffer_Out :" $@ 
     1121  fi 
     1122  if [ $DRYRUN = 0 ]; then 
     1123    if [ ! -f ${1} ] ; then 
     1124      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     1125      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1126      return 1 
     1127    fi 
     1128    # 
     1129    IGCM_sys_Mkdir $( dirname $2 ) 
     1130    # 
     1131    typeset RET 
     1132 
     1133    if [ X${JobType} = XRUN ] ; then 
     1134      if [ X${3} = X ] ; then 
     1135        IGCM_sys_Chmod 444 ${1} 
     1136      fi 
     1137    fi 
     1138    # 
     1139    # USUAL WAY 
     1140    \cp $1 $2 > out_rsync 2>&1 
     1141    RET=$? 
     1142 
     1143    if [ ${RET} -gt 0 ] ; then 
     1144      echo "IGCM_sys_PutBuffer_Out : error." 
     1145      cat out_rsync 
     1146      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
     1147    else 
     1148      \rm out_rsync 
     1149    fi 
     1150  else 
     1151    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1152  fi 
     1153  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1154  return 0 
    10231155} 
    10241156 
     
    10291161#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    10301162function IGCM_sys_Get { 
    1031     IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    1032  
    1033     typeset DEST RET dm_liste ifile target file_work  
    1034  
    1035     if ( $DEBUG_sys ) ; then 
    1036         echo "IGCM_sys_Get :" $@ 
    1037     fi 
    1038     if [ $DRYRUN -le 2 ]; then 
    1039         if [ X${1} = X'/l' ] ; then 
    1040             # test if the first file is present in the old computation : 
    1041             eval set +A dm_liste \${${2}} 
    1042         else 
    1043             eval set +A dm_liste ${1} 
    1044         fi 
    1045         eval DEST=\${${#}} 
    1046  
    1047         #===================================================== 
    1048         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1049         #===================================================== 
    1050  
    1051         # Is it an R_OUT file (not R_IN) ? 
    1052         #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
    1053         #if [ $? -eq 0 ] ; then 
    1054         #    # Yes  ? then we try to get it in SCRATCHDIR 
    1055         #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    1056         #    if [ -f ${file_work[0]} ] ; then 
    1057         #       IGCM_sys_Cp ${file_work[*]} ${DEST} 
    1058         #       IGCM_debug_PopStack "IGCM_sys_Get" 
    1059         #       return 
    1060         #    fi 
    1061         #fi 
    1062  
    1063         # test if the (first) file is present in the old computation : 
    1064         IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1065         RET=$? 
    1066         if [ ${RET} -gt 0 ] ; then 
    1067             echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    1068             IGCM_debug_Exit "IGCM_sys_Get" 
    1069             IGCM_debug_PopStack "IGCM_sys_Get" 
    1070             return 
    1071         fi 
    1072  
    1073         dmget ${dm_liste[*]} > out_rsync 2>&1 
    1074         RET=$? 
    1075         if [ ${RET} -gt 0 ] ; then 
    1076             echo "IGCM_sys_Get : demigration error." 
    1077             cat out_rsync 
    1078             IGCM_debug_Exit "IGCM_sys_Get" 
    1079         fi 
    1080  
    1081         #USUAL WAY 
    1082         if [ X${1} = X'/l' ] ; then 
    1083             (( RET=0 )) 
    1084             for target in ${dm_liste[*]} ; do 
    1085                 local_file=$( basename ${target} ) 
    1086                 \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1087                 (( RET = RET + $? )) 
    1088             done 
    1089         else 
    1090             \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
    1091             RET=$? 
    1092         fi 
     1163  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1164 
     1165  typeset DEST RET dm_liste ifile target file_work  
     1166 
     1167  if ( $DEBUG_sys ) ; then 
     1168    echo "IGCM_sys_Get :" $@ 
     1169  fi 
     1170  if [ $DRYRUN -le 2 ]; then 
     1171    if [ X${1} = X'/l' ] ; then 
     1172      # test if the first file is present in the old computation : 
     1173      eval set +A dm_liste \${${2}} 
     1174    else 
     1175      eval set +A dm_liste ${1} 
     1176    fi 
     1177    eval DEST=\${${#}} 
     1178 
     1179    #===================================================== 
     1180    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1181    #===================================================== 
     1182 
     1183    # Is it an R_OUT file (not R_IN) ? 
     1184    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1185    #if [ $? -eq 0 ] ; then 
     1186    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1187    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1188    #    if [ -f ${file_work[0]} ] ; then 
     1189    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1190    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1191    #   return 
     1192    #    fi 
     1193    #fi 
     1194 
     1195    # test if the (first) file is present in the old computation : 
     1196    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1197    RET=$? 
     1198    if [ ${RET} -gt 0 ] ; then 
     1199      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1200      IGCM_debug_Exit "IGCM_sys_Get" 
     1201    fi 
     1202 
     1203    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1204    RET=$? 
     1205    if [ ${RET} -gt 0 ] ; then 
     1206      echo "WARNING IGCM_sys_Get : demigration error." 
     1207      cat out_rsync 
     1208      echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
     1209    fi 
     1210 
     1211    #if [ ${RET} -gt 0 ] ; then 
     1212    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1213    #   cat out_rsync 
     1214    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1215    #   sleep 30 
     1216    #   echo "We try another time" 
     1217    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1218    #   RET=$? 
     1219    #   if [ ${RET} -gt 0 ] ; then 
     1220    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1221    #       cat out_rsync 
     1222    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1223    #   fi 
     1224    #    else 
     1225    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1226    #   cat out_rsync 
     1227    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1228    #    fi 
     1229    #fi 
     1230 
     1231    #USUAL WAY 
     1232    if [ X${1} = X'/l' ] ; then 
     1233      (( RET=0 )) 
     1234      for target in ${dm_liste[*]} ; do 
     1235        local_file=$( basename ${target} ) 
     1236        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1237        (( RET = RET + $? )) 
     1238      done 
     1239    else 
     1240      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1241      RET=$? 
     1242    fi 
    10931243 
    10941244#       #RSYNC WITH NETWORK SSH CALL 
     
    11061256#       (( RET=RET+$? )) 
    11071257 
    1108         if [ ${RET} -gt 0 ] ; then 
    1109             echo "IGCM_sys_Get : copy error." 
    1110             cat out_rsync 
    1111             IGCM_debug_Exit "IGCM_sys_Get" 
    1112         else 
    1113             \rm out_rsync 
    1114         fi 
     1258    if [ ${RET} -gt 0 ] ; then 
     1259      echo "IGCM_sys_Get : copy error." 
     1260      cat out_rsync 
     1261      IGCM_debug_Exit "IGCM_sys_Get" 
    11151262    else 
    1116         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1117     fi 
    1118     IGCM_debug_PopStack "IGCM_sys_Get" 
     1263      \rm out_rsync 
     1264    fi 
     1265  else 
     1266    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1267  fi 
     1268  IGCM_debug_PopStack "IGCM_sys_Get" 
     1269} 
     1270 
     1271#D-#================================================== 
     1272#D-function IGCM_sys_GetBuffer 
     1273#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1274#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1275#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1276function IGCM_sys_GetBuffer { 
     1277  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1278 
     1279  typeset DEST RET buf_liste ifile target file_work  
     1280 
     1281  if ( $DEBUG_sys ) ; then 
     1282    echo "IGCM_sys_GetBuffer :" $@ 
     1283  fi 
     1284  if [ $DRYRUN -le 2 ]; then 
     1285    if [ X${1} = X'/l' ] ; then 
     1286      # test if the first file is present in the old computation : 
     1287      eval set +A buf_liste \${${2}} 
     1288    else 
     1289      eval set +A buf_liste ${1} 
     1290    fi 
     1291    eval DEST=\${${#}} 
     1292 
     1293    #USUAL WAY 
     1294    if [ X${1} = X'/l' ] ; then 
     1295      (( RET=0 )) 
     1296      for target in ${buf_liste[*]} ; do 
     1297        local_file=$( basename ${target} ) 
     1298        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1299        (( RET = RET + $? )) 
     1300      done 
     1301    else 
     1302      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1303      RET=$? 
     1304    fi 
     1305 
     1306    if [ ${RET} -gt 0 ] ; then 
     1307      echo "IGCM_sys_GetBuffer : copy error." 
     1308      cat out_rsync 
     1309      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1310    else 
     1311      \rm out_rsync 
     1312    fi 
     1313  else 
     1314    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1315  fi 
     1316  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
    11191317} 
    11201318 
     
    11251323#D- 
    11261324function IGCM_sys_GetDate_FichWork { 
    1127     IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1128     if ( $DEBUG_sys ) ; then 
    1129         echo "IGCM_sys_GetDate_FichWork :" $@ 
    1130     fi 
    1131     typeset dateF 
    1132     set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1133     eval ${2}=${dateF[5]} 
     1325  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1326  if ( $DEBUG_sys ) ; then 
     1327    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1328  fi 
     1329  typeset dateF 
     1330  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1331  eval ${2}=${dateF[5]} 
    11341332 
    11351333    # donne la date filesys d'un fichier sur la machine work 
    1136     IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1334  IGCM_debug_PopStack "IGCM_sys_FichWork" 
    11371335} 
    11381336 
     
    11431341#D- 
    11441342function IGCM_sys_GetDate_FichArchive { 
    1145     IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1146     if ( $DEBUG_sys ) ; then 
    1147         echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1148     fi 
    1149     typeset dateF 
    1150     set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1151     eval ${2}=${dateF[5]} 
    1152  
    1153     IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1343  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1344  if ( $DEBUG_sys ) ; then 
     1345    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1346  fi 
     1347  typeset dateF 
     1348  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1349  eval ${2}=${dateF[5]} 
     1350 
     1351  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    11541352} 
    11551353 
     
    11581356 
    11591357function IGCM_sys_rebuild { 
    1160     IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
    1161     if ( $DEBUG_sys ) ; then 
    1162         echo "IGCM_sys_rebuild :" $@ 
    1163     fi 
    1164     /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@ 
    1165     if [ $? -gt 0 ] ; then 
    1166        echo "IGCM_sys_rebuild : erreur ${@}." 
    1167        IGCM_debug_Exit "rebuild" 
    1168     fi 
    1169  
    1170     IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1358  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1359  if ( $DEBUG_sys ) ; then 
     1360    echo "IGCM_sys_rebuild :" $@ 
     1361  fi 
     1362  /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@ 
     1363  if [ $? -gt 0 ] ; then 
     1364    echo "IGCM_sys_rebuild : erreur ${@}." 
     1365    IGCM_debug_Exit "rebuild" 
     1366  fi 
     1367 
     1368  IGCM_debug_PopStack "IGCM_sys_rebuild" 
    11711369} 
    11721370 
     
    11751373 
    11761374function IGCM_sys_activ_variables { 
    1177     IGCM_debug_PushStack "IGCM_sys_activ_variables" 
    1178     if ( $DEBUG_sys ) ; then 
    1179         echo "IGCM_sys_activ_variables" 
    1180     fi 
     1375  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1376  if ( $DEBUG_sys ) ; then 
     1377    echo "IGCM_sys_activ_variables" 
     1378  fi 
    11811379 
    11821380# -------------------------------------------------------------------- 
     
    11851383 
    11861384#D-- MPISUSPEND 
    1187     export MPISUSPEND=${MPISUSPEND:=OFF} 
     1385  export MPISUSPEND=${MPISUSPEND:=OFF} 
    11881386 
    11891387#D-- MPIPROGINF #other choices : ALL_DETAIL2 
    1190     export MPIPROGINF=ALL 
     1388  export MPIPROGINF=ALL 
    11911389#D- activate ftrace (with -ftrace) 
    1192     export F_FTRACE=YES 
     1390  export F_FTRACE=YES 
    11931391#D- communication information (with -ftrace) 
    1194     export MPICOMMINF=DETAIL 
     1392  export MPICOMMINF=DETAIL 
    11951393 
    11961394# -------------------------------------------------------------------- 
     
    11991397 
    12001398#D- max number of character/line in output job 
    1201     export F_SYSLEN=5000 
     1399  export F_SYSLEN=5000 
    12021400#D- number of error that can be admitted on the NEC 
    1203     export F_ERRCNT=0 
     1401  export F_ERRCNT=0 
    12041402#D- global performance 
    1205     export F_PROGINF=DETAIL 
     1403  export F_PROGINF=DETAIL 
    12061404 
    12071405#D- I/O performance (FORTRAN I/O only not netCDF) 
    1208     export F_FILEINF=${F_FILEINF:=NO} 
     1406  export F_FILEINF=${F_FILEINF:=NO} 
    12091407#D- netCDF I/O performance 
    1210     export NC_FILEINF=${NC_FILEINF:=NO} 
    1211  
    1212     IGCM_debug_PopStack "IGCM_sys_activ_variables" 
     1408  export NC_FILEINF=${NC_FILEINF:=NO} 
     1409 
     1410  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    12131411} 
    12141412 
     
    12171415 
    12181416function IGCM_sys_desactiv_variables { 
    1219     IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
    1220     if ( $DEBUG_sys ) ; then 
    1221         echo "IGCM_sys_desactiv_variables" 
    1222     fi 
     1417  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1418  if ( $DEBUG_sys ) ; then 
     1419    echo "IGCM_sys_desactiv_variables" 
     1420  fi 
    12231421# -------------------------------------------------------------------- 
    12241422#D- MPI specifications 
     
    12261424 
    12271425#D-- MPIPROGINF 
    1228     export MPIPROGINF=NO 
     1426  export MPIPROGINF=NO 
    12291427 
    12301428# -------------------------------------------------------------------- 
     
    12331431 
    12341432#D- global performance 
    1235     export F_PROGINF=NO   
    1236  
    1237     IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
     1433  export F_PROGINF=NO   
     1434 
     1435  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
    12381436} 
    12391437 
     
    12421440 
    12431441function IGCM_sys_build_run_file { 
    1244     IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
    1245     if ( $DEBUG_sys ) ; then 
    1246         echo "IGCM_sys_build_run_file " $@ 
    1247     fi 
    1248     (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 )) 
    1249     (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
    1250     (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
    1251      
    1252     if [ $1 = MPI2 ]; then 
    1253         cat <<EOF > run_file 
     1442  IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
     1443  if ( $DEBUG_sys ) ; then 
     1444    echo "IGCM_sys_build_run_file " $@ 
     1445  fi 
     1446  (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 )) 
     1447  (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
     1448  (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
     1449   
     1450  if [ $1 = MPI2 ]; then 
     1451    cat <<EOF > run_file 
    12541452-p 1 -np 1 -e ./oasis 
    12551453EOF 
    1256         (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 )) 
    1257         config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"' 
    1258  
    1259     elif [ $1 = MPI1 ]; then 
    1260         cat <<EOF > run_file 
     1454    (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 )) 
     1455    config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"' 
     1456 
     1457  elif [ $1 = MPI1 ]; then 
     1458    cat <<EOF > run_file 
    12611459-p $NUM_PROC_OASIS -e ./oasis 
    12621460-p $NUM_PROC_ATM -e ./lmdz.x 
    12631461-p $NUM_PROC_OCE -e ./opa.xx 
    12641462EOF 
    1265   
    1266     fi 
    1267  
    1268     IGCM_debug_PopStack "IGCM_sys_build_run_file" 
    1269    
    1270 } 
     1463  fi 
     1464  IGCM_debug_PopStack "IGCM_sys_build_run_file" 
     1465} 
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh

    r538 r544  
    6868typeset  LOGIN=${LOGIN:=$( whoami )} 
    6969# $hostname of the MASTER job 
    70 typeset MASTER=titane1000 
     70typeset MASTER=titane 
    7171 
    7272#D- 
     
    113113typeset -r ARCHIVE=${DMFDIR} 
    114114 
     115# ============ CESIUM START ============ # 
     116 
    115117#==================================================== 
    116118#- Mirror libIGCM from titane to cesium if needed 
    117 ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $2}' ) 
    118 if [ ! ${ROOTSYS} = "home" ] ; then 
    119     typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true} 
    120 else 
    121     typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} 
    122 fi 
     119#ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $3}' ) 
     120#if [ ! ${ROOTSYS} = "home" ] ; then 
     121#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true} 
     122#else 
     123#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} 
     124#fi 
    123125 
    124126#==================================================== 
    125127#- libIGCM_POST 
    126 if ( ${MirrorlibIGCM} ) ; then 
    127     PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" ) 
    128     typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM 
    129 else 
    130     typeset -r libIGCM_POST=${libIGCM} 
    131 fi 
     128#if ( ${MirrorlibIGCM} ) ; then 
     129#  PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" ) 
     130#  typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM 
     131#else 
     132#  typeset -r libIGCM_POST=${libIGCM} 
     133#fi 
     134 
     135# ============ CESIUM  END  ============ # 
     136 
     137#==================================================== 
     138#- MirrorlibIGCM for frontend 
     139typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} 
     140 
     141#==================================================== 
     142#- libIGCM_POST for frontend 
     143typeset -r libIGCM_POST=${libIGCM} 
    132144 
    133145#==================================================== 
     
    137149 
    138150#==================================================== 
    139 #- OUT 
     151#- R_OUT 
    140152typeset -r R_OUT=${ARCHIVE}/IGCM_OUT 
    141153 
    142154#==================================================== 
    143 #- OUT_SCR (ONLY FOR double copy an scratch) 
    144 typeset -r R_OUT_SCR=${SCRATCHDIR}/IGCM_OUT 
     155#- R_BUF (ONLY FOR double copy an scratch) 
     156typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT 
     157 
     158#==================================================== 
     159#- BIG_DIR : BIG_DIR to store files waiting for rebuild 
     160typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    145161 
    146162#==================================================== 
     
    151167#- RUN_DIR_PATH : Temporary working directory (=> TMP) 
    152168if [ ! X${LSB_QUEUE} = Xmono ] ; then 
    153     typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${LSB_JOBID}} 
     169  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${LSB_JOBID}} 
    154170else 
    155     typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/TMPDIR_IGCM/${LSB_JOBID}} 
     171  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/TMPDIR_IGCM/${LSB_JOBID}} 
    156172fi 
    157  
    158 #==================================================== 
    159 #- BIG_DIR : BIG_DIR to store files waiting for rebuild 
    160 typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    161173 
    162174#==================================================== 
     
    174186#D- 
    175187function IGCM_sys_RshMaster { 
    176     IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    177     ssh -t ${MASTER} /bin/ksh <<-EOF 
     188  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
     189  /bin/ksh <<-EOF 
    178190    export libIGCM=${libIGCM} 
    179191    export DEBUG_debug=${DEBUG_debug} 
     
    182194    ${@} 
    183195EOF 
    184     if [ $? -gt 0 ] ; then 
    185         echo "IGCM_sys_RshMaster : erreur." 
    186         IGCM_debug_Exit "IGCM_sys_RshMaster" 
    187     fi 
    188     IGCM_debug_PopStack "IGCM_sys_RshMaster" 
     196  if [ $? -gt 0 ] ; then 
     197    echo "IGCM_sys_RshMaster : erreur." 
     198    IGCM_debug_Exit "IGCM_sys_RshMaster" 
     199  fi 
     200  IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    189201} 
    190202 
     
    195207#D- 
    196208function IGCM_sys_RshArchive { 
    197     IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    198     /bin/ksh <<-EOF 
     209  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
     210  /bin/ksh <<-EOF 
    199211    ${@} 
    200212EOF 
    201     if [ $? -gt 0 ] ; then 
    202         echo "IGCM_sys_RshArchive : erreur." 
    203         IGCM_debug_Exit "IGCM_sys_RshArchive" 
    204     fi 
    205     IGCM_debug_PopStack "IGCM_sys_RshArchive" 
     213  if [ $? -gt 0 ] ; then 
     214    echo "IGCM_sys_RshArchive : erreur." 
     215    IGCM_debug_Exit "IGCM_sys_RshArchive" 
     216  fi 
     217  IGCM_debug_PopStack "IGCM_sys_RshArchive" 
    206218} 
    207219 
     
    212224#D- 
    213225function IGCM_sys_RshPost { 
    214     IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    215     if ( $DEBUG_sys ) ; then 
    216         echo "IGCM_sys_RshPost :" $@ 
    217     fi 
    218  
    219     typeset NB_ESSAI DELAI status i 
    220     # keep standard input for the loop onto temporary file 
    221     cat >tmp_IGCM_sys_RshPost_$$ 
    222  
    223     #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL 
    224     #cat tmp_IGCM_sys_RshPost_$$ 
    225  
    226     if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then 
    227         # little hack so that rebuild submission is done on titane not an cesium 
    228         # 
    229         libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' ) 
    230         POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' ) 
    231         sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
    232         sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
    233         sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
    234         sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
    235         #\mv tmp.txt tmp_IGCM_sys_RshPost_$$ 
    236         # 
    237         #echo cat tmp_IGCM_sys_RshPost_$$ AFTER 
    238         #cat tmp_IGCM_sys_RshPost_$$ 
    239         /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
    240         if [ $? -gt 0 ] ; then 
    241             echo "IGCM_sys_RshPost : erreur." 
    242             IGCM_debug_Exit "IGCM_sys_RshPost" 
    243         fi 
    244         # delete temporary file 
    245         \rm tmp_IGCM_sys_RshPost_$$ 
    246     else 
    247         # number of tentative 
    248         NB_ESSAI=10 
    249         # time delay between tentative 
    250         DELAI=10 
    251         i=0 
    252         while [ $i -ne $NB_ESSAI ] ; do 
    253             ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
    254             status=$? 
    255             if [ ${status} -ne 0 ]; 
    256             then 
    257                 sleep $DELAI 
    258             else 
    259                 break 
    260             fi 
    261             let i=$i+1 
    262         done 
    263         # delete temporary file 
    264         \rm tmp_IGCM_sys_RshPost_$$ 
    265  
    266         if [ ${status} -gt 0 ] ; then 
    267             echo "IGCM_sys_RshPost : erreur." 
    268             IGCM_debug_Exit "IGCM_sys_RshPost" 
    269         fi 
    270     fi 
    271     IGCM_debug_PopStack "IGCM_sys_RshPost" 
     226  IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
     227  if ( $DEBUG_sys ) ; then 
     228    echo "IGCM_sys_RshPost :" $@ 
     229  fi 
     230 
     231  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL 
     232  #cat tmp_IGCM_sys_RshPost_$$ 
     233  # keep standard input (stdin) for the loop onto temporary file 
     234  cat >tmp_IGCM_sys_RshPost_$$ 
     235 
     236# ============ FRONTEND START ============ # 
     237 
     238  /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     239  if [ $? -gt 0 ] ; then 
     240    echo "IGCM_sys_RshPost : erreur." 
     241    IGCM_debug_Exit "IGCM_sys_RshPost" 
     242  fi 
     243  # delete temporary file 
     244  \rm tmp_IGCM_sys_RshPost_$$ 
     245 
     246# ============ FRONTEND  END  ============ # 
     247 
     248# ============ CESIUM START ============ # 
     249#  typeset NB_ESSAI DELAI status i 
     250#  if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then 
     251#    #little hack so that rebuild submission is done on titane not an cesium 
     252#     
     253#    libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' ) 
     254#    POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' ) 
     255#    sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
     256#    sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
     257#    sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
     258#    sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
     259#    \mv tmp.txt tmp_IGCM_sys_RshPost_$$ 
     260#     
     261#    echo cat tmp_IGCM_sys_RshPost_$$ AFTER 
     262#    cat tmp_IGCM_sys_RshPost_$$ 
     263# 
     264#    /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     265#    if [ $? -gt 0 ] ; then 
     266#      echo "IGCM_sys_RshPost : erreur." 
     267#      IGCM_debug_Exit "IGCM_sys_RshPost" 
     268#    fi 
     269#    # delete temporary file 
     270#    \rm tmp_IGCM_sys_RshPost_$$ 
     271# 
     272#  else 
     273#    # number of tentative 
     274#    NB_ESSAI=10 
     275#    # time delay between tentative 
     276#    DELAI=10 
     277#    i=0 
     278#    while [ $i -ne $NB_ESSAI ] ; do 
     279#      ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     280#      status=$? 
     281#      if [ ${status} -ne 0 ]; 
     282#      then 
     283#       sleep $DELAI 
     284#      else 
     285#       break 
     286#      fi 
     287#      let i=$i+1 
     288#    done 
     289#    # delete temporary file 
     290#    \rm tmp_IGCM_sys_RshPost_$$ 
     291# 
     292#    if [ ${status} -gt 0 ] ; then 
     293#      echo "IGCM_sys_RshPost : erreur." 
     294#      IGCM_debug_Exit "IGCM_sys_RshPost" 
     295#    fi 
     296#  fi 
     297 
     298# ============ CESIUM  END  ============ # 
     299 
     300  IGCM_debug_PopStack "IGCM_sys_RshPost" 
    272301} 
    273302 
     
    278307#D- 
    279308function IGCM_sys_SendMail { 
    280     IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    281     if ( $DEBUG_sys ) ; then 
    282        echo "IGCM_sys_SendMail :" $@ 
    283     fi 
    284  
    285     if ( ${ExitFlag} ) ; then 
    286         status=failed 
    287     else 
    288         status=completed 
    289     fi 
    290  
    291     ssh -t titane996 ssh platine /bin/ksh <<-EOF 
     309  IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
     310  if ( $DEBUG_sys ) ; then 
     311    echo "IGCM_sys_SendMail :" $@ 
     312  fi 
     313 
     314  if ( ${ExitFlag} ) ; then 
     315    status=failed 
     316  else 
     317    status=completed 
     318  fi 
     319 
     320  ssh -t titane996 ssh platine /bin/ksh <<-EOF 
    292321    export LOGIN=${LOGIN} 
    293322    export config_UserChoices_JobName=${config_UserChoices_JobName} 
     
    314343        mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
    315344    fi 
    316  
    317345    sleep 10 
    318346    rm -f job_end.mail 
    319347EOF 
    320348 
    321     if [ $? -gt 0 ] ; then 
    322         echo "IGCM_sys_SendMail : erreur." 
    323         IGCM_debug_Exit "IGCM_sys_SendMail" 
    324     fi 
    325     IGCM_debug_PopStack "IGCM_sys_SendMail" 
     349  if [ $? -gt 0 ] ; then 
     350    echo "IGCM_sys_SendMail : erreur." 
     351    IGCM_debug_Exit "IGCM_sys_SendMail" 
     352  fi 
     353  IGCM_debug_PopStack "IGCM_sys_SendMail" 
    326354} 
    327355 
     
    332360#D- 
    333361function IGCM_sys_Mkdir { 
    334     IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    335     if ( $DEBUG_sys ) ; then 
    336         echo "IGCM_sys_Mkdir :" $@ 
    337     fi 
    338     if [ ! -d ${1} ]; then 
    339         \mkdir -p $1 
    340         if [ $? -gt 0 ] ; then 
    341             echo "IGCM_sys_Mkdir : erreur." 
    342             IGCM_debug_Exit "IGCM_sys_Mkdir" 
    343         fi 
    344     fi 
    345     # vérification : 
    346     if [ ! -d ${1} ] ; then 
    347         echo "IGCM_sys_Mkdir : erreur." 
    348         IGCM_debug_Exit "IGCM_sys_Mkdir" 
    349     fi 
    350     IGCM_debug_PopStack "IGCM_sys_Mkdir" 
     362  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
     363  if ( $DEBUG_sys ) ; then 
     364    echo "IGCM_sys_Mkdir :" $@ 
     365  fi 
     366  if [ ! -d ${1} ]; then 
     367    \mkdir -p $1 
     368    if [ $? -gt 0 ] ; then 
     369      echo "IGCM_sys_Mkdir : erreur." 
     370      IGCM_debug_Exit "IGCM_sys_Mkdir" 
     371    fi 
     372  fi 
     373  # vérification : 
     374  if [ ! -d ${1} ] ; then 
     375    echo "IGCM_sys_Mkdir : erreur." 
     376    IGCM_debug_Exit "IGCM_sys_Mkdir" 
     377  fi 
     378  IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    351379} 
    352380 
     
    357385#D- 
    358386function IGCM_sys_MkdirArchive { 
    359     IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
    360     if ( $DEBUG_sys ) ; then 
    361         echo "IGCM_sys_MkdirArchive :" $@ 
    362     fi 
    363     #- creation de repertoire sur le serveur fichier 
    364     if [ ! -d ${1} ]; then  
    365         \mkdir -p $1 
    366         if [ $? -gt 0 ] ; then 
    367             echo "IGCM_sys_MkdirArchive : erreur." 
    368             IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
    369         fi 
    370     fi 
    371     IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
     387  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
     388  if ( $DEBUG_sys ) ; then 
     389    echo "IGCM_sys_MkdirArchive :" $@ 
     390  fi 
     391  #- creation de repertoire sur le serveur fichier 
     392  if [ ! -d ${1} ]; then  
     393    \mkdir -p $1 
     394    if [ $? -gt 0 ] ; then 
     395      echo "IGCM_sys_MkdirArchive : erreur." 
     396      IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
     397    fi 
     398  fi 
     399  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    372400} 
    373401 
     
    378406#D- 
    379407function IGCM_sys_MkdirWork { 
    380     IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    381     if ( $DEBUG_sys ) ; then 
    382         echo "IGCM_sys_MkdirWork :" $@ 
    383     fi 
    384     #- creation de repertoire sur le serveur fichier 
    385     if [ ! -d ${1} ]; then  
    386         \mkdir -p $1 
    387         if [ $? -gt 0 ] ; then 
    388             echo "IGCM_sys_MkdirWork : erreur." 
    389             IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    390         fi 
    391     fi 
    392     IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
     408  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
     409  if ( $DEBUG_sys ) ; then 
     410    echo "IGCM_sys_MkdirWork :" $@ 
     411  fi 
     412  #- creation de repertoire sur le serveur fichier 
     413  if [ ! -d ${1} ]; then  
     414    \mkdir -p $1 
     415    if [ $? -gt 0 ] ; then 
     416      echo "IGCM_sys_MkdirWork : erreur." 
     417      IGCM_debug_Exit "IGCM_sys_MkdirWork" 
     418    fi 
     419  fi 
     420  IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    393421} 
    394422 
     
    399427#D- 
    400428function IGCM_sys_Cd { 
    401     IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    402     if ( $DEBUG_sys ) ; then 
    403         echo "IGCM_sys_Cd :" $@ 
    404     fi 
    405     \cd $1 
    406     if [ $? -gt 0 ] ; then 
    407         echo "IGCM_sys_Cd : erreur." 
    408         IGCM_debug_Exit "IGCM_sys_Cd" 
    409     fi 
    410     IGCM_debug_PopStack "IGCM_sys_Cd" 
     429  IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
     430  if ( $DEBUG_sys ) ; then 
     431    echo "IGCM_sys_Cd :" $@ 
     432  fi 
     433  \cd $1 
     434  if [ $? -gt 0 ] ; then 
     435    echo "IGCM_sys_Cd : erreur." 
     436    IGCM_debug_Exit "IGCM_sys_Cd" 
     437  fi 
     438  IGCM_debug_PopStack "IGCM_sys_Cd" 
    411439} 
    412440 
     
    417445#D- 
    418446function IGCM_sys_Chmod { 
    419     IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
    420     if ( $DEBUG_sys ) ; then 
    421         echo "IGCM_sys_Chmod :" $@ 
    422     fi 
    423     if [ $DRYRUN -le 1 ]; then 
    424         \chmod $@ 
    425         if [ $? -gt 0 ] ; then 
    426             echo "IGCM_sys_Chmod : erreur." 
    427             IGCM_debug_Exit "IGCM_sys_Chmod" 
    428         fi 
    429     else 
    430         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    431     fi 
    432     IGCM_debug_PopStack "IGCM_sys_Chmod" 
     447  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
     448  if ( $DEBUG_sys ) ; then 
     449    echo "IGCM_sys_Chmod :" $@ 
     450  fi 
     451  if [ $DRYRUN -le 1 ]; then 
     452    \chmod $@ 
     453    if [ $? -gt 0 ] ; then 
     454      echo "IGCM_sys_Chmod : erreur." 
     455      IGCM_debug_Exit "IGCM_sys_Chmod" 
     456    fi 
     457  else 
     458    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     459  fi 
     460  IGCM_debug_PopStack "IGCM_sys_Chmod" 
    433461} 
    434462 
     
    439467#D- 
    440468function IGCM_sys_FileSize { 
    441     IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    442  
    443     typeset sizeF 
    444     set +A sizeF -- $( ls -la ${1} ) 
    445     if [ $? -gt 0 ] ; then 
    446         IGCM_debug_Exit "IGCM_sys_FileSize" 
    447     fi 
    448     eval ${2}=${sizeF[4]} 
    449  
    450     IGCM_debug_PopStack "IGCM_sys_FileSize" 
     469  IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
     470 
     471  typeset sizeF 
     472  set +A sizeF -- $( ls -la ${1} ) 
     473  if [ $? -gt 0 ] ; then 
     474    IGCM_debug_Exit "IGCM_sys_FileSize" 
     475  fi 
     476  eval ${2}=${sizeF[4]} 
     477 
     478  IGCM_debug_PopStack "IGCM_sys_FileSize" 
    451479} 
    452480 
     
    457485#D- 
    458486function IGCM_sys_TestDir { 
    459     IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    460     if ( $DEBUG_sys ) ; then 
    461         echo "IGCM_sys_TestDir :" $@ 
    462     fi 
    463     typeset ExistFlag 
    464     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    465     IGCM_debug_PopStack "IGCM_sys_TestDir" 
    466  
    467     return ${ExistFlag} 
     487  IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
     488  if ( $DEBUG_sys ) ; then 
     489    echo "IGCM_sys_TestDir :" $@ 
     490  fi 
     491  typeset ExistFlag 
     492  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     493  IGCM_debug_PopStack "IGCM_sys_TestDir" 
     494 
     495  return ${ExistFlag} 
    468496} 
    469497 
     
    474502#D- 
    475503function IGCM_sys_TestDirArchive { 
    476     IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
    477     if ( $DEBUG_sys ) ; then 
    478         echo "IGCM_sys_TestDirArchive :" $@ 
    479     fi 
    480     typeset ExistFlag 
    481     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    482     IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
    483  
    484     return ${ExistFlag} 
     504  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
     505  if ( $DEBUG_sys ) ; then 
     506    echo "IGCM_sys_TestDirArchive :" $@ 
     507  fi 
     508  typeset ExistFlag 
     509  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     510  IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
     511 
     512  return ${ExistFlag} 
    485513} 
    486514 
     
    491519#D- 
    492520function IGCM_sys_TestFileArchive { 
    493     IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    494     typeset ExistFlag 
    495     ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    496     IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    497  
    498     return ${ExistFlag} 
     521  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
     522  if ( $DEBUG_sys ) ; then 
     523    echo "IGCM_sys_TestFileArchive :" $@ 
     524  fi 
     525  typeset ExistFlag 
     526  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     527  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
     528 
     529  return ${ExistFlag} 
     530} 
     531 
     532#D-#================================================== 
     533#D-function IGCM_sys_TestFileBuffer 
     534#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     535#D-* Examples: 
     536#D- 
     537function IGCM_sys_TestFileBuffer { 
     538  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     539  typeset ExistFlag 
     540  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     541  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     542 
     543  return ${ExistFlag} 
    499544} 
    500545 
     
    505550#D- 
    506551function IGCM_sys_CountFileArchive { 
    507     IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
    508     ls ${@} 2>/dev/null | wc -l 
    509     if [ $? -gt 0 ] ; then 
    510         echo "IGCM_sys_CountFileArchive : erreur." 
    511     fi 
    512     IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     552  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
     553  ls ${@} 2>/dev/null | wc -l 
     554  if [ $? -gt 0 ] ; then 
     555    echo "IGCM_sys_CountFileArchive : erreur." 
     556  fi 
     557  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     558} 
     559 
     560#D-#================================================== 
     561#D-function IGCM_sys_CountFileBuffer 
     562#D-* Purpose: Count files on Scratch filesystem 
     563#D-* Examples: 
     564#D- 
     565function IGCM_sys_CountFileBuffer { 
     566  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     567  ls ${@} 2>/dev/null | wc -l 
     568  if [ $? -gt 0 ] ; then 
     569    echo "IGCM_sys_CountFileBuffer : erreur." 
     570  fi 
     571  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    513572} 
    514573 
     
    519578#D- 
    520579function IGCM_sys_Tree { 
    521     IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
    522     if ( $DEBUG_sys ) ; then 
    523         echo "IGCM_sys_Tree :" $@ 
    524     fi 
    525  
    526     \ls -lR ${@} 
    527  
    528     IGCM_debug_PopStack "IGCM_sys_Tree" 
     580  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     581  if ( $DEBUG_sys ) ; then 
     582    echo "IGCM_sys_Tree :" $@ 
     583  fi 
     584 
     585  \ls -lR ${@} 
     586 
     587  IGCM_debug_PopStack "IGCM_sys_Tree" 
    529588} 
    530589 
    531590#D-#================================================== 
    532591#D-function IGCM_sys_Tar 
    533 #D-* Purpose: master un-tar command 
     592#D-* Purpose: master tar command 
    534593#D-* Examples: 
    535594#D- 
    536595function IGCM_sys_Tar { 
    537     IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    538     if ( $DEBUG_sys ) ; then 
    539         echo "IGCM_sys_Tar :" $@ 
    540     fi 
    541     \tar cf $@ 
    542     if [ $? -gt 0 ] ; then 
    543         echo "IGCM_sys_Tar : erreur." 
    544         IGCM_debug_Exit "IGCM_sys_Tar" 
    545     fi 
    546     IGCM_debug_PopStack "IGCM_sys_Tar" 
     596  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     597  if ( $DEBUG_sys ) ; then 
     598    echo "IGCM_sys_Tar :" $@ 
     599  fi 
     600  \tar cf $@ 
     601  if [ $? -gt 0 ] ; then 
     602    echo "IGCM_sys_Tar : erreur." 
     603    IGCM_debug_Exit "IGCM_sys_Tar" 
     604  fi 
     605  IGCM_debug_PopStack "IGCM_sys_Tar" 
    547606} 
    548607 
     
    553612#D- 
    554613function IGCM_sys_UnTar { 
    555     IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    556     if ( $DEBUG_sys ) ; then 
    557         echo "IGCM_sys_UnTar :" $@ 
    558     fi 
    559     \tar xvf $1 
    560     if [ $? -gt 0 ] ; then 
    561         echo "IGCM_sys_UnTar : erreur." 
    562         IGCM_debug_Exit "IGCM_sys_UnTar" 
    563     fi 
    564     IGCM_debug_PopStack "IGCM_sys_UnTar" 
     614  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     615  if ( $DEBUG_sys ) ; then 
     616    echo "IGCM_sys_UnTar :" $@ 
     617  fi 
     618  \tar xvf $1 
     619  if [ $? -gt 0 ] ; then 
     620    echo "IGCM_sys_UnTar : erreur." 
     621    IGCM_debug_Exit "IGCM_sys_UnTar" 
     622  fi 
     623  IGCM_debug_PopStack "IGCM_sys_UnTar" 
    565624} 
    566625 
     
    571630#D- 
    572631function IGCM_sys_Qsub { 
    573     IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
    574     if ( $DEBUG_sys ) ; then 
    575         echo "IGCM_sys_Qsub :" $@ 
    576     fi 
    577  
    578     if [ ${config_UserChoices_JobName}.${CumulPeriod} = "." ] ; then 
    579         /usr/local/bin/ccc_msub -o ${Script_Output} -e ${Script_Output} < $1 
    580     else 
    581         /usr/local/bin/ccc_msub -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod} < $1 
    582     fi 
    583  
    584     if [ $? -gt 0 ] ; then 
    585         echo "IGCM_sys_Qsub : erreur " $@ 
    586         IGCM_debug_Exit "IGCM_sys_Qsub" 
    587     fi 
    588     IGCM_debug_PopStack "IGCM_sys_Qsub" 
     632  IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
     633  if ( $DEBUG_sys ) ; then 
     634    echo "IGCM_sys_Qsub :" $@ 
     635  fi 
     636  typeset options 
     637  if [ ${config_UserChoices_JobName}.${CumulPeriod} = "." ] ; then 
     638    options=" -o ${Script_Output} -e ${Script_Output}" 
     639  else 
     640    options=" -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod}" 
     641  fi 
     642 
     643  /usr/local/bin/ccc_msub ${options} < $1 
     644  if [ $? -gt 0 ] ; then 
     645    echo "IGCM_sys_Qsub : erreur ${options} $1" 
     646    IGCM_debug_Exit "IGCM_sys_Qsub" 
     647  fi 
     648  IGCM_debug_PopStack "IGCM_sys_Qsub" 
    589649} 
    590650 
     
    595655#D- 
    596656function IGCM_sys_QsubPost { 
    597     IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
    598     if ( $DEBUG_sys ) ; then 
    599         echo "IGCM_sys_QsubPost :" $@ 
    600     fi 
    601     /usr/local/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.e.out -E "-v ${listVarEnv}" ${libIGCM_POST}/$1.job 
    602     if [ $? -gt 0 ] ; then 
    603         echo "IGCM_sys_QsubPost : erreur " $@ 
    604         IGCM_debug_Exit "IGCM_sys_QsubPost" 
    605     fi 
    606     IGCM_debug_PopStack "IGCM_sys_QsubPost" 
     657  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     658  if ( $DEBUG_sys ) ; then 
     659    echo "IGCM_sys_QsubPost :" $@ 
     660  fi 
     661 
     662  # Need to export listVarEnv for cesium 
     663  # NO Need to export listVarEnv for titane 
     664# ============ FRONTEND START ============ # 
     665 
     666  /usr/local/bin/ccc_msub -p ${BRIDGE_MSUB_PROJECT} -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out ${libIGCM_POST}/$1.job 
     667 
     668# ============ FRONTEND  END  ============ # 
     669 
     670# ============ CESIUM START ============ # 
     671#  typeset NB_ESSAI DELAI status i 
     672#  # number of tentative 
     673#  NB_ESSAI=10 
     674#  # time delay between tentative 
     675#  DELAI=10 
     676#  (( i = 0 )) 
     677#  while [ $i -lt $NB_ESSAI ] ; do 
     678#    /usr/local/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.e.out -E "-v ${listVarEnv}" ${libIGCM_POST}/$1.job 
     679#    status=$? 
     680#    if [ ${status} -gt 0 ]; then 
     681#      sleep $DELAI 
     682#    else 
     683#      break 
     684#    fi 
     685#    (( i = i + 1 )) 
     686#  done  
     687# ============ CESIUM  END  ============ # 
     688 
     689  if [ $? -gt 0 ] ; then 
     690    echo "IGCM_sys_QsubPost : erreur " $@ 
     691    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     692  fi 
     693  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    607694} 
    608695 
     
    618705#D-  Error values and explanations can depend on your system version. 
    619706function IGCM_sys_Rsync_out { 
    620     RET=$1 
    621     if [ ! $RET ] ; then 
    622         echo "rsync error !" 
    623     fi 
    624  
    625     if [ $MYLANG = "fr" ]; then 
    626         case $RET in 
    627             0)  return ;; 
    628             1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    629                 echo "Erreur de syntaxe ou d'utilisation." 
    630                 return;; 
    631             2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    632                 echo "Incompatibilité de protocole." 
    633                 return;; 
    634             3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    635                 echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    636                 echo "répertoires" 
    637                 return;; 
    638             4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    639                 echo "Action demandée non supportée : une tentative de manipulation de" 
    640                 echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    641                 echo "été faite ; ou une option qui est supportée par le  client  mais" 
    642                 echo "pas par le serveur a été spécifiée." 
    643                 return;; 
    644             10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    645                 echo "Erreur dans le socket d'entrée sortie" 
    646                 return;; 
    647             11) echo "Erreur de rsync ; RERR_FILEIO" 
    648                 echo "Erreur d'entrée sortie fichier" 
    649                 return;; 
    650             12) echo "Erreur de rsync ; RERR_STREAMIO" 
    651                 echo "Erreur dans flux de donnée du protocole rsync" 
    652                 return;; 
    653             13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    654                 echo "Erreur avec les diagnostics du programme" 
    655                 return;; 
    656             14) echo "Erreur de rsync ; RERR_IPC" 
    657                 echo "Erreur dans le code IPC" 
    658                 return;; 
    659             20) echo "Erreur de rsync ; RERR_SIGNAL" 
    660                 echo "SIGUSR1 ou SIGINT reçu" 
    661                 return;; 
    662             21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    663                 echo "Une erreur retournée par waitpid()" 
    664                 return;; 
    665             22) echo "Erreur de rsync ; RERR_MALLOC" 
    666                 echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    667                 return;; 
    668             23) echo "" 
    669                 echo "Erreur fichier inexistant" 
    670                 return;; 
    671             30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    672                 echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    673                 return;; 
    674             *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
    675                 return;; 
    676         esac 
    677     elif [ $MYLANG = "en" ] ; then 
    678         case $RET in 
    679             0)  return;;                 
    680             1)  echo "rsync error : Syntax or usage error " 
    681                 return;; 
    682             2)  echo "rsync error : Protocol incompatibility " 
    683                 return;; 
    684             3)  echo "rsync error : Errors selecting input/output files, dirs" 
    685                 return;; 
    686             4)  echo "rsync error : Requested action not supported: an attempt" 
    687                 echo "was made to manipulate 64-bit files on a platform that cannot support" 
    688                 echo "them; or an option was specified that is supported by the client and" 
    689                 echo "not by the server." 
    690                 return;; 
    691             5)  echo "rsync error : Error starting client-server protocol" 
    692                 return;; 
    693             10) echo "rsync error : Error in socket I/O " 
    694                 return;; 
    695             11) echo "rsync error : Error in file I/O " 
    696                 return;; 
    697             12) echo "rsync error : Error in rsync protocol data stream " 
    698                 return;; 
    699             13) echo "rsync error : Errors with program diagnostics " 
    700                 return;; 
    701             14) echo "rsync error : Error in IPC code " 
    702                 return;; 
    703             20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    704                 return;; 
    705             21) echo "rsync error : Some error returned by waitpid() " 
    706                 return;; 
    707             22) echo "rsync error : Error allocating core memory buffers " 
    708                 return;; 
    709             23) echo "rsync error : Partial transfer due to error" 
    710                 return;; 
    711             24) echo "rsync error : Partial transfer due to vanished source files" 
    712                 return;; 
    713             30) echo "rsync error : Timeout in data send/receive " 
    714                 return;; 
    715             *)  echo "rsync error : return code of rsync unknown :" $RET 
    716                 return;; 
    717         esac 
    718     else 
    719         echo "unknown language $MYLANG." 
    720         return 
    721     fi 
    722 } 
    723      
     707  RET=$1 
     708  if [ ! $RET ] ; then 
     709    echo "rsync error !" 
     710  fi 
     711 
     712  if [ $MYLANG = "fr" ]; then 
     713    case $RET in 
     714    0)  return ;; 
     715    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     716      echo "Erreur de syntaxe ou d'utilisation." 
     717      return;; 
     718    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     719      echo "Incompatibilité de protocole." 
     720      return;; 
     721    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     722      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     723      echo "répertoires" 
     724      return;; 
     725    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     726      echo "Action demandée non supportée : une tentative de manipulation de" 
     727      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     728      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     729      echo "pas par le serveur a été spécifiée." 
     730      return;; 
     731    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     732      echo "Erreur dans le socket d'entrée sortie" 
     733      return;; 
     734    11) echo "Erreur de rsync ; RERR_FILEIO" 
     735      echo "Erreur d'entrée sortie fichier" 
     736      return;; 
     737    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     738      echo "Erreur dans flux de donnée du protocole rsync" 
     739      return;; 
     740    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     741      echo "Erreur avec les diagnostics du programme" 
     742      return;; 
     743    14) echo "Erreur de rsync ; RERR_IPC" 
     744      echo "Erreur dans le code IPC" 
     745      return;; 
     746    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     747      echo "SIGUSR1 ou SIGINT reçu" 
     748      return;; 
     749    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     750      echo "Une erreur retournée par waitpid()" 
     751      return;; 
     752    22) echo "Erreur de rsync ; RERR_MALLOC" 
     753      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     754      return;; 
     755    23) echo "" 
     756      echo "Erreur fichier inexistant" 
     757      return;; 
     758    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     759      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     760      return;; 
     761    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     762      return;; 
     763    esac 
     764  elif [ $MYLANG = "en" ] ; then 
     765    case $RET in 
     766    0)  return;;                 
     767    1)  echo "rsync error : Syntax or usage error " 
     768      return;; 
     769    2)  echo "rsync error : Protocol incompatibility " 
     770      return;; 
     771    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     772      return;; 
     773    4)  echo "rsync error : Requested action not supported: an attempt" 
     774      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     775      echo "them; or an option was specified that is supported by the client and" 
     776      echo "not by the server." 
     777      return;; 
     778    5)  echo "rsync error : Error starting client-server protocol" 
     779      return;; 
     780    10) echo "rsync error : Error in socket I/O " 
     781      return;; 
     782    11) echo "rsync error : Error in file I/O " 
     783      return;; 
     784    12) echo "rsync error : Error in rsync protocol data stream " 
     785      return;; 
     786    13) echo "rsync error : Errors with program diagnostics " 
     787      return;; 
     788    14) echo "rsync error : Error in IPC code " 
     789      return;; 
     790    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     791      return;; 
     792    21) echo "rsync error : Some error returned by waitpid() " 
     793      return;; 
     794    22) echo "rsync error : Error allocating core memory buffers " 
     795      return;; 
     796    23) echo "rsync error : Partial transfer due to error" 
     797      return;; 
     798    24) echo "rsync error : Partial transfer due to vanished source files" 
     799      return;; 
     800    30) echo "rsync error : Timeout in data send/receive " 
     801      return;; 
     802    *)  echo "rsync error : return code of rsync unknown :" $RET 
     803      return;; 
     804    esac 
     805  else 
     806    echo "unknown language $MYLANG." 
     807    return 
     808  fi 
     809} 
    724810 
    725811#D-#================================================== 
     
    729815#D- 
    730816function IGCM_sys_Mirror_libIGCM { 
    731     IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    732     if ( $DEBUG_sys ) ; then 
    733         echo "IGCM_sys_Mirror_libIGCM" 
    734     fi 
    735  
    736     typeset RET DEST 
    737  
    738     mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    739  
    740     echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
    741     ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
    742     RET=$? 
    743  
    744     if [ ${RET} -gt 0 ] ; then 
    745         echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
    746         cat out_rsync 
    747     fi 
    748     IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
     817  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
     818  if ( $DEBUG_sys ) ; then 
     819    echo "IGCM_sys_Mirror_libIGCM" 
     820  fi 
     821 
     822  typeset RET DEST 
     823 
     824  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
     825 
     826  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
     827  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
     828  RET=$? 
     829 
     830  if [ ${RET} -gt 0 ] ; then 
     831    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
     832    cat out_rsync 
     833  fi 
     834  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    749835} 
    750836 
     
    752838#- Call IGCM_sys_Mirror_libIGCM now ! 
    753839if ( $MirrorlibIGCM ) ; then 
    754     IGCM_sys_Mirror_libIGCM 
     840  IGCM_sys_Mirror_libIGCM 
    755841fi 
    756842 
     
    761847#D- 
    762848function IGCM_sys_Cp { 
    763     IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    764     if ( $DEBUG_sys ) ; then 
    765         echo "IGCM_sys_Cp :" $@ 
    766     fi 
    767  
    768     typeset RET 
    769  
    770     echo cp $@ > out_rsync 2>&1 
    771     \cp $@ >> out_rsync 2>&1 
    772     RET=$? 
    773  
    774     if [ ${RET} -gt 0 ] ; then 
    775         echo "IGCM_sys_Cp : error." 
    776         cat out_rsync 
    777         IGCM_debug_Exit "IGCM_sys_Cp" 
    778      else 
    779         \rm out_rsync 
    780     fi 
    781     IGCM_debug_PopStack "IGCM_sys_Cp" 
     849  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     850  if ( $DEBUG_sys ) ; then 
     851    echo "IGCM_sys_Cp :" $@ 
     852  fi 
     853 
     854  typeset RET 
     855 
     856  echo cp $@ > out_rsync 2>&1 
     857  \cp $@ >> out_rsync 2>&1 
     858  RET=$? 
     859 
     860  if [ ${RET} -gt 0 ] ; then 
     861    echo "IGCM_sys_Cp : error." 
     862    cat out_rsync 
     863    IGCM_debug_Exit "IGCM_sys_Cp" 
     864  else 
     865    \rm out_rsync 
     866  fi 
     867  IGCM_debug_PopStack "IGCM_sys_Cp" 
    782868} 
    783869 
     
    788874#D- 
    789875function IGCM_sys_Rm { 
    790     IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
    791     if ( $DEBUG_sys ) ; then 
    792         echo "IGCM_sys_Rm :" $@ 
    793     fi 
    794  
    795     typeset RET 
    796  
    797     echo rm $@ > out_rsync 2>&1 
    798     \rm $@ >> out_rsync 2>&1 
    799     RET=$? 
    800  
    801     if [ ${RET} -gt 0 ] ; then 
    802         echo "IGCM_sys_Rm : error." 
    803         cat out_rsync 
    804         IGCM_debug_Exit "IGCM_sys_Rm" 
    805     else 
    806         \rm out_rsync 
    807     fi 
    808     IGCM_debug_PopStack "IGCM_sys_Rm" 
     876  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     877  if ( $DEBUG_sys ) ; then 
     878    echo "IGCM_sys_Rm :" $@ 
     879  fi 
     880 
     881  typeset RET 
     882 
     883  echo rm $@ > out_rsync 2>&1 
     884  \rm $@ >> out_rsync 2>&1 
     885  RET=$? 
     886 
     887  if [ ${RET} -gt 0 ] ; then 
     888    echo "IGCM_sys_Rm : error." 
     889    cat out_rsync 
     890    IGCM_debug_Exit "IGCM_sys_Rm" 
     891  else 
     892    \rm out_rsync 
     893  fi 
     894  IGCM_debug_PopStack "IGCM_sys_Rm" 
    809895} 
    810896 
     
    816902#D- 
    817903function IGCM_sys_RmRunDir { 
    818     IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
    819     if ( $DEBUG_sys ) ; then 
    820         echo "IGCM_sys_RmRunDir :" $@ 
    821     fi 
    822  
    823     typeset RET 
    824  
    825     echo rm $@ > out_rsync 2>&1 
    826     \rm $@ >> out_rsync 2>&1 
    827     RET=$? 
    828  
    829     if [ ${RET} -gt 0 ] ; then 
    830         echo "IGCM_sys_RmRunDir : error." 
    831         cat out_rsync 
    832         IGCM_debug_Exit "IGCM_sys_RmRunDir" 
    833     else 
    834         \rm out_rsync 
    835     fi 
    836  
    837     IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
     904  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
     905  if ( $DEBUG_sys ) ; then 
     906    echo "IGCM_sys_RmRunDir :" $@ 
     907  fi 
     908 
     909  typeset RET 
     910 
     911  echo rm $@ > out_rsync 2>&1 
     912  \rm $@ >> out_rsync 2>&1 
     913  RET=$? 
     914 
     915  if [ ${RET} -gt 0 ] ; then 
     916    echo "IGCM_sys_RmRunDir : error." 
     917    cat out_rsync 
     918    IGCM_debug_Exit "IGCM_sys_RmRunDir" 
     919  else 
     920    \rm out_rsync 
     921  fi 
     922  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    838923} 
    839924 
     
    844929#D- 
    845930function IGCM_sys_Mv { 
    846     IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    847     if ( $DEBUG_sys ) ; then 
    848         echo "IGCM_sys_Mv :" $@ 
    849     fi 
    850  
    851     if [ $DRYRUN = 0 ]; then 
    852  
    853         typeset RET 
    854              
    855         echo mv $@ > out_rsync 2>&1 
    856         \mv $@ >> out_rsync 2>&1 
    857         RET=$? 
     931  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     932  if ( $DEBUG_sys ) ; then 
     933    echo "IGCM_sys_Mv :" $@ 
     934  fi 
     935 
     936  if [ $DRYRUN = 0 ]; then 
     937 
     938    typeset RET 
    858939     
    859         if [ ${RET} -gt 0 ] ; then 
    860             echo "IGCM_sys_Mv : error in mv." 
    861             cat out_rsync 
    862             IGCM_debug_Exit "IGCM_sys_Mv" 
    863         else 
    864             \rm out_rsync 
    865         fi 
     940    echo mv $@ > out_rsync 2>&1 
     941    \mv $@ >> out_rsync 2>&1 
     942    RET=$? 
     943     
     944    if [ ${RET} -gt 0 ] ; then 
     945      echo "IGCM_sys_Mv : error in mv." 
     946      cat out_rsync 
     947      IGCM_debug_Exit "IGCM_sys_Mv" 
    866948    else 
    867         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    868     fi 
    869  
    870     IGCM_debug_PopStack "IGCM_sys_Mv" 
     949      \rm out_rsync 
     950    fi 
     951  else 
     952    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     953  fi 
     954 
     955  IGCM_debug_PopStack "IGCM_sys_Mv" 
    871956} 
    872957 
     
    877962#D- 
    878963function IGCM_sys_Put_Dir { 
    879     IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
    880     if ( $DEBUG_sys ) ; then 
    881         echo "IGCM_sys_Put_Dir :" $@ 
    882     fi 
    883     if [ $DRYRUN = 0 ]; then 
    884         if [ ! -d ${1} ] ; then 
    885             echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
    886             IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    887             return 
    888         fi 
    889  
    890         typeset RET 
    891  
    892         # Only if we use rsync 
    893         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    894         # 
    895         #USUAL WAY 
    896         \cp -r $1 $2 > out_rsync 2>&1 
    897         RET=$? 
    898  
    899         if [ ${RET} -gt 0 ] ; then 
    900             echo "IGCM_sys_Put_Dir : error." 
    901             cat out_rsync 
    902             IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    903         else 
    904             \rm out_rsync 
    905         fi 
     964  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     965  if ( $DEBUG_sys ) ; then 
     966    echo "IGCM_sys_Put_Dir :" $@ 
     967  fi 
     968  if [ $DRYRUN = 0 ]; then 
     969    if [ ! -d ${1} ] ; then 
     970      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     971      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     972      return 
     973    fi 
     974 
     975    typeset RET 
     976 
     977    # Only if we use rsync 
     978    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     979    # 
     980    #USUAL WAY 
     981    \cp -r $1 $2 > out_rsync 2>&1 
     982    RET=$? 
     983 
     984    if [ ${RET} -gt 0 ] ; then 
     985      echo "IGCM_sys_Put_Dir : error." 
     986      cat out_rsync 
     987      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    906988    else 
    907         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    908     fi 
    909     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     989      \rm out_rsync 
     990    fi 
     991  else 
     992    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     993  fi 
     994  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    910995} 
    911996 
    912997#D-#================================================== 
    913998#D-function IGCM_sys_Get_Dir 
    914 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     999#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    9151000#D-* Examples: 
    9161001#D- 
    9171002function IGCM_sys_Get_Dir { 
    918     IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
    919     if ( $DEBUG_sys ) ; then 
    920         echo "IGCM_sys_Get_Dir :" $@ 
    921     fi 
    922     if [ $DRYRUN = 0 ]; then 
    923 #       if [ ! -d ${1} ] ; then 
    924 #           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
    925 #           IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    926 #           return 
    927 #       fi 
    928  
    929         typeset RET 
    930  
    931         # Only if we use rsync 
    932         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    933         # 
    934         #USUAL WAY 
    935         # add dmget (to demigrate all offline files) to reduce time of this command : 
    936         dmget $1/* 
    937         \cp -r $1 $2 > out_rsync 2>&1 
    938         RET=$? 
    939  
    940         if [ ${RET} -gt 0 ] ; then 
    941             echo "IGCM_sys_Get_Dir : error." 
    942             cat out_rsync 
    943             IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    944         else 
    945             \rm out_rsync 
    946         fi 
     1003  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     1004  if ( $DEBUG_sys ) ; then 
     1005    echo "IGCM_sys_Get_Dir :" $@ 
     1006  fi 
     1007  if [ $DRYRUN = 0 ]; then 
     1008#    if [ ! -d ${1} ] ; then 
     1009#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     1010#      IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     1011#      return 
     1012#    fi 
     1013 
     1014    typeset RET 
     1015 
     1016    # Only if we use rsync 
     1017    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     1018    # 
     1019    # USUAL WAY 
     1020    # add dmfind/dmget (to demigrate all offline files) : 
     1021    dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget 
     1022    \cp -r $1 $2 > out_rsync 2>&1 
     1023    RET=$? 
     1024 
     1025    if [ ${RET} -gt 0 ] ; then 
     1026      echo "IGCM_sys_Get_Dir : error." 
     1027      cat out_rsync 
     1028      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    9471029    else 
    948         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    949     fi 
    950     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     1030      \rm out_rsync 
     1031    fi 
     1032  else 
     1033    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1034  fi 
     1035  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    9511036} 
    9521037 
     
    9571042#D- 
    9581043function IGCM_sys_Get_Master { 
    959     IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
    960     if ( $DEBUG_sys ) ; then 
    961         echo "IGCM_sys_Get_Master :" $@ 
    962     fi 
    963     if [ $DRYRUN = 0 ]; then 
    964         if [ ! -d ${1} ] ; then 
    965             echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
    966             IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    967             return 
    968         fi 
    969  
    970         typeset RET 
    971  
    972         #USUAL WAY 
    973         \cp -r $1 $2 > out_rsync 2>&1 
    974         RET=$? 
    975  
    976         if [ ${RET} -gt 0 ] ; then 
    977             echo "IGCM_sys_Get_Master : error." 
    978             cat out_rsync 
    979             IGCM_debug_Exit "IGCM_sys_Get_Master" 
    980         fi 
     1044  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
     1045  if ( $DEBUG_sys ) ; then 
     1046    echo "IGCM_sys_Get_Master :" $@ 
     1047  fi 
     1048  if [ $DRYRUN = 0 ]; then 
     1049    if [ ! -d ${1} ] ; then 
     1050      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
     1051      IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     1052      return 
     1053    fi 
     1054 
     1055    typeset RET 
     1056 
     1057    #USUAL WAY 
     1058    \cp -r $1 $2 > out_rsync 2>&1 
     1059    RET=$? 
     1060 
     1061    if [ ${RET} -gt 0 ] ; then 
     1062      echo "IGCM_sys_Get_Master : error." 
     1063      cat out_rsync 
     1064      IGCM_debug_Exit "IGCM_sys_Get_Master" 
    9811065    else 
    982         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    983     fi 
    984     IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     1066      \rm out_rsync 
     1067    fi 
     1068  else 
     1069    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1070  fi 
     1071  IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    9851072} 
    9861073 
    9871074#D-#================================================== 
    9881075#D-function IGCM_sys_Put_Rest 
    989 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     1076#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    9901077#D-           File and target directory must exist. 
    9911078#D-* Examples: 
    9921079#D- 
    9931080function IGCM_sys_Put_Rest { 
    994     IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
    995     if ( $DEBUG_sys ) ; then 
    996         echo "IGCM_sys_Put_Rest :" $@ 
    997     fi 
    998     if [ $DRYRUN = 0 ]; then 
    999         if [ ! -f ${1} ] ; then 
    1000             echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
    1001             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    1002         fi 
    1003  
    1004         typeset RET 
    1005         # 
    1006         if [ X${JobType} = XRUN ] ; then 
    1007             IGCM_sys_Chmod 444 ${1} 
    1008         fi 
    1009         # 
    1010         IGCM_sys_TestDirArchive $( dirname $2 ) 
    1011         # 
    1012         # USUAL WAY 
    1013         \cp $1 $2 > out_rsync 2>&1 
    1014         RET=$? 
     1081  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     1082  if ( $DEBUG_sys ) ; then 
     1083    echo "IGCM_sys_Put_Rest :" $@ 
     1084  fi 
     1085  if [ $DRYRUN = 0 ]; then 
     1086    if [ ! -f ${1} ] ; then 
     1087      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     1088      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     1089    fi 
     1090 
     1091    typeset RET 
     1092    # 
     1093    if [ X${JobType} = XRUN ] ; then 
     1094      IGCM_sys_Chmod 444 ${1} 
     1095    fi 
     1096 
     1097    # 
     1098    # USUAL WAY 
     1099    \cp $1 $2 > out_rsync 2>&1 
     1100    RET=$? 
    10151101 
    10161102#       #RSYNC WITH NETWORK SSH CALL 
     
    10281114#       (( RET=RET+$? )) 
    10291115 
    1030         if [ ${RET} -gt 0 ] ; then 
    1031             echo "IGCM_sys_Put_Rest : error." 
    1032             cat out_rsync 
    1033             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    1034         else 
    1035             \rm out_rsync 
    1036         fi 
     1116    if [ ${RET} -gt 0 ] ; then 
     1117      echo "IGCM_sys_Put_Rest : error." 
     1118      cat out_rsync 
     1119      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    10371120    else 
    1038         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1039     fi 
    1040     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1121      \rm out_rsync 
     1122    fi 
     1123  else 
     1124    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1125  fi 
     1126  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1127} 
     1128 
     1129#D-#================================================== 
     1130#D-function IGCM_sys_PutBuffer_Rest 
     1131#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     1132#D-           File and target directory must exist. 
     1133#D-* Examples: 
     1134#D- 
     1135function IGCM_sys_PutBuffer_Rest { 
     1136  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     1137  if ( $DEBUG_sys ) ; then 
     1138    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     1139  fi 
     1140  if [ $DRYRUN = 0 ]; then 
     1141    if [ ! -f ${1} ] ; then 
     1142      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     1143      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1144    fi 
     1145 
     1146    typeset RET 
     1147    # 
     1148    if [ X${JobType} = XRUN ] ; then 
     1149      IGCM_sys_Chmod 444 ${1} 
     1150    fi 
     1151 
     1152    # 
     1153    # USUAL WAY 
     1154    \cp $1 $2 > out_rsync 2>&1 
     1155    RET=$? 
     1156 
     1157    if [ ${RET} -gt 0 ] ; then 
     1158      echo "IGCM_sys_PutBuffer_Rest : error." 
     1159      cat out_rsync 
     1160      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1161    else 
     1162      \rm out_rsync 
     1163    fi 
     1164  else 
     1165    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1166  fi 
     1167  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    10411168} 
    10421169 
    10431170#D-#================================================== 
    10441171#D-function IGCM_sys_Put_Out 
    1045 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     1172#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    10461173#D-* Examples: 
    10471174#D- 
    10481175function IGCM_sys_Put_Out { 
    1049     IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
    1050     if ( $DEBUG_sys ) ; then 
    1051         echo "IGCM_sys_Put_Out :" $@ 
    1052     fi 
    1053     if [ $DRYRUN = 0 ]; then 
    1054         if [ ! -f ${1} ] ; then 
    1055             echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
    1056             IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1057             return 1 
    1058         fi 
    1059         # 
    1060         IGCM_sys_MkdirArchive $( dirname $2 ) 
    1061         # 
    1062         typeset RET 
    1063  
    1064         #===================================================== 
    1065         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1066         #===================================================== 
    1067  
    1068         #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
    1069         #if [ $? -eq 0 ] ; then 
    1070         #    typeset WORKPATH FILEPATH 
    1071         #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    1072         #    IGCM_sys_MkdirWork ${WORKPATH}  
    1073         #    FILEPATH=${WORKPATH}/$( basename $2 ) 
    1074         #    # 
    1075         #    IGCM_sys_Cp ${1} ${FILEPATH} 
    1076         #fi 
    1077  
    1078         if [ X${JobType} = XRUN ] ; then 
    1079             if [ X${3} = X ] ; then 
    1080                 IGCM_sys_Chmod 444 ${1} 
    1081             fi 
    1082         fi 
    1083         # 
    1084         # USUAL WAY 
    1085         \cp $1 $2 > out_rsync 2>&1 
    1086         RET=$? 
     1176  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     1177  if ( $DEBUG_sys ) ; then 
     1178    echo "IGCM_sys_Put_Out :" $@ 
     1179  fi 
     1180  if [ $DRYRUN = 0 ]; then 
     1181    if [ ! -f ${1} ] ; then 
     1182      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     1183      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1184      return 1 
     1185    fi 
     1186    # 
     1187    IGCM_sys_MkdirArchive $( dirname $2 ) 
     1188    # 
     1189    typeset RET 
     1190 
     1191    #===================================================== 
     1192    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1193    #===================================================== 
     1194 
     1195    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     1196    #if [ $? -eq 0 ] ; then 
     1197    #    typeset WORKPATH FILEPATH 
     1198    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     1199    #    IGCM_sys_MkdirWork ${WORKPATH}  
     1200    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     1201    #    # 
     1202    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1203    #fi 
     1204 
     1205    if [ X${JobType} = XRUN ] ; then 
     1206      if [ X${3} = X ] ; then 
     1207        IGCM_sys_Chmod 444 ${1} 
     1208      fi 
     1209    fi 
     1210    # 
     1211    # USUAL WAY 
     1212    \cp $1 $2 > out_rsync 2>&1 
     1213    RET=$? 
    10871214 
    10881215#       #RSYNC WITH NETWORK SSH CALL 
     
    11001227#       (( RET=RET+$? )) 
    11011228 
    1102         if [ ${RET} -gt 0 ] ; then 
    1103             echo "IGCM_sys_Put_Out : error." 
    1104             cat out_rsync 
    1105             IGCM_debug_Exit "IGCM_sys_Put_Out" 
    1106         else 
    1107             \rm out_rsync 
    1108         fi 
     1229    if [ ${RET} -gt 0 ] ; then 
     1230      echo "IGCM_sys_Put_Out : error." 
     1231      cat out_rsync 
     1232      IGCM_debug_Exit "IGCM_sys_Put_Out" 
    11091233    else 
    1110         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1111     fi 
    1112     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1113     return 0 
     1234      \rm out_rsync 
     1235    fi 
     1236  else 
     1237    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1238  fi 
     1239  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1240  return 0 
     1241} 
     1242 
     1243#D-#================================================== 
     1244#D-function IGCM_sys_PutBuffer_Out 
     1245#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
     1246#D-* Examples: 
     1247#D- 
     1248function IGCM_sys_PutBuffer_Out { 
     1249  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     1250  if ( $DEBUG_sys ) ; then 
     1251    echo "IGCM_sys_PutBuffer_Out :" $@ 
     1252  fi 
     1253  if [ $DRYRUN = 0 ]; then 
     1254    if [ ! -f ${1} ] ; then 
     1255      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     1256      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1257      return 1 
     1258    fi 
     1259    # 
     1260    IGCM_sys_Mkdir $( dirname $2 ) 
     1261    # 
     1262    typeset RET 
     1263 
     1264    if [ X${JobType} = XRUN ] ; then 
     1265      if [ X${3} = X ] ; then 
     1266        IGCM_sys_Chmod 444 ${1} 
     1267      fi 
     1268    fi 
     1269    # 
     1270    # USUAL WAY 
     1271    \cp $1 $2 > out_rsync 2>&1 
     1272    RET=$? 
     1273 
     1274    if [ ${RET} -gt 0 ] ; then 
     1275      echo "IGCM_sys_PutBuffer_Out : error." 
     1276      cat out_rsync 
     1277      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
     1278    else 
     1279      \rm out_rsync 
     1280    fi 
     1281  else 
     1282    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1283  fi 
     1284  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1285  return 0 
    11141286} 
    11151287 
     
    11201292#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    11211293function IGCM_sys_Get { 
    1122     IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    1123  
    1124     typeset DEST RET dm_liste ifile target file_work  
    1125  
    1126     if ( $DEBUG_sys ) ; then 
    1127         echo "IGCM_sys_Get :" $@ 
    1128     fi 
    1129     if [ $DRYRUN -le 2 ]; then 
    1130         if [ X${1} = X'/l' ] ; then 
    1131             # test if the first file is present in the old computation : 
    1132             eval set +A dm_liste \${${2}} 
    1133         else 
    1134             eval set +A dm_liste ${1} 
    1135         fi 
    1136         eval DEST=\${${#}} 
    1137  
    1138         #===================================================== 
    1139         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1140         #===================================================== 
    1141  
    1142         # Is it an R_OUT file (not R_IN) ? 
    1143         #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
    1144         #if [ $? -eq 0 ] ; then 
    1145         #    # Yes  ? then we try to get it in SCRATCHDIR 
    1146         #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" ) 
    1147         #    if [ -f ${file_work[0]} ] ; then 
    1148         #       IGCM_sys_Cp ${file_work[*]} ${DEST} 
    1149         #       IGCM_debug_PopStack "IGCM_sys_Get" 
    1150         #       return 
    1151         #    fi 
    1152         #fi 
    1153  
    1154         # test if the (first) file is present in the old computation : 
    1155         IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1156         RET=$? 
    1157         if [ ${RET} -gt 0 ] ; then 
    1158             echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    1159             IGCM_debug_Exit "IGCM_sys_Get" 
    1160         fi 
    1161  
    1162         dmget ${dm_liste[*]} > out_rsync 2>&1 
    1163         RET=$? 
    1164  
    1165         if [ ${RET} -gt 0 ] ; then 
    1166             echo "WARNING IGCM_sys_Get : demigration error." 
    1167             cat out_rsync 
    1168             echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
    1169         fi 
    1170  
    1171         #if [ ${RET} -gt 0 ] ; then 
    1172         #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
    1173         #       cat out_rsync 
    1174         #       echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
    1175         #       sleep 30 
    1176         #       echo "We try another time" 
    1177         #       dmget ${dm_liste[*]} > out_rsync 2>&1 
    1178         #       RET=$? 
    1179         #       if [ ${RET} -gt 0 ] ; then 
    1180         #           echo "ERROR IGCM_sys_Get : again demigration error :" 
    1181         #           cat out_rsync 
    1182         #           IGCM_debug_Exit "IGCM_sys_Get" 
    1183         #       fi 
    1184         #    else 
    1185         #       echo "ERROR IGCM_sys_Get : demigration error :" 
    1186         #       cat out_rsync 
    1187         #       IGCM_debug_Exit "IGCM_sys_Get" 
    1188         #    fi 
    1189         #fi 
    1190  
    1191         #USUAL WAY 
    1192         if [ X${1} = X'/l' ] ; then 
    1193             (( RET=0 )) 
    1194             for target in ${dm_liste[*]} ; do 
    1195                 local_file=$( basename ${target} ) 
    1196                 \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1197                 (( RET = RET + $? )) 
    1198             done 
    1199         else 
    1200             \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
    1201             RET=$? 
    1202         fi 
     1294  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1295 
     1296  typeset DEST RET dm_liste ifile target file_work  
     1297 
     1298  if ( $DEBUG_sys ) ; then 
     1299    echo "IGCM_sys_Get :" $@ 
     1300  fi 
     1301  if [ $DRYRUN -le 2 ]; then 
     1302    if [ X${1} = X'/l' ] ; then 
     1303      # test if the first file is present in the old computation : 
     1304      eval set +A dm_liste \${${2}} 
     1305    else 
     1306      eval set +A dm_liste ${1} 
     1307    fi 
     1308    eval DEST=\${${#}} 
     1309 
     1310    #===================================================== 
     1311    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1312    #===================================================== 
     1313 
     1314    # Is it an R_OUT file (not R_IN) ? 
     1315    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1316    #if [ $? -eq 0 ] ; then 
     1317    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1318    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1319    #    if [ -f ${file_work[0]} ] ; then 
     1320    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1321    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1322    #   return 
     1323    #    fi 
     1324    #fi 
     1325 
     1326    # test if the (first) file is present in the old computation : 
     1327    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1328    RET=$? 
     1329    if [ ${RET} -gt 0 ] ; then 
     1330      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1331      IGCM_debug_Exit "IGCM_sys_Get" 
     1332    fi 
     1333 
     1334    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1335    RET=$? 
     1336    if [ ${RET} -gt 0 ] ; then 
     1337      echo "WARNING IGCM_sys_Get : demigration error." 
     1338      cat out_rsync 
     1339      echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
     1340    fi 
     1341 
     1342    #if [ ${RET} -gt 0 ] ; then 
     1343    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1344    #   cat out_rsync 
     1345    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1346    #   sleep 30 
     1347    #   echo "We try another time" 
     1348    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1349    #   RET=$? 
     1350    #   if [ ${RET} -gt 0 ] ; then 
     1351    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1352    #       cat out_rsync 
     1353    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1354    #   fi 
     1355    #    else 
     1356    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1357    #   cat out_rsync 
     1358    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1359    #    fi 
     1360    #fi 
     1361 
     1362    #USUAL WAY 
     1363    if [ X${1} = X'/l' ] ; then 
     1364      (( RET=0 )) 
     1365      for target in ${dm_liste[*]} ; do 
     1366        local_file=$( basename ${target} ) 
     1367        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1368        (( RET = RET + $? )) 
     1369      done 
     1370    else 
     1371      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1372      RET=$? 
     1373    fi 
    12031374 
    12041375#       #RSYNC WITH NETWORK SSH CALL 
     
    12161387#       (( RET=RET+$? )) 
    12171388 
    1218         if [ ${RET} -gt 0 ] ; then 
    1219             echo "IGCM_sys_Get : copy error." 
    1220             cat out_rsync 
    1221             IGCM_debug_Exit "IGCM_sys_Get" 
    1222         else 
    1223             \rm out_rsync 
    1224         fi 
     1389    if [ ${RET} -gt 0 ] ; then 
     1390      echo "IGCM_sys_Get : copy error." 
     1391      cat out_rsync 
     1392      IGCM_debug_Exit "IGCM_sys_Get" 
    12251393    else 
    1226         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1227     fi 
    1228     IGCM_debug_PopStack "IGCM_sys_Get" 
     1394      \rm out_rsync 
     1395    fi 
     1396  else 
     1397    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1398  fi 
     1399  IGCM_debug_PopStack "IGCM_sys_Get" 
     1400} 
     1401 
     1402#D-#================================================== 
     1403#D-function IGCM_sys_GetBuffer 
     1404#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1405#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1406#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1407function IGCM_sys_GetBuffer { 
     1408  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1409 
     1410  typeset DEST RET buf_liste ifile target file_work  
     1411 
     1412  if ( $DEBUG_sys ) ; then 
     1413    echo "IGCM_sys_GetBuffer :" $@ 
     1414  fi 
     1415  if [ $DRYRUN -le 2 ]; then 
     1416    if [ X${1} = X'/l' ] ; then 
     1417      # test if the first file is present in the old computation : 
     1418      eval set +A buf_liste \${${2}} 
     1419    else 
     1420      eval set +A buf_liste ${1} 
     1421    fi 
     1422    eval DEST=\${${#}} 
     1423 
     1424    #USUAL WAY 
     1425    if [ X${1} = X'/l' ] ; then 
     1426      (( RET=0 )) 
     1427      for target in ${buf_liste[*]} ; do 
     1428        local_file=$( basename ${target} ) 
     1429        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1430        (( RET = RET + $? )) 
     1431      done 
     1432    else 
     1433      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1434      RET=$? 
     1435    fi 
     1436 
     1437    if [ ${RET} -gt 0 ] ; then 
     1438      echo "IGCM_sys_GetBuffer : copy error." 
     1439      cat out_rsync 
     1440      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1441    else 
     1442      \rm out_rsync 
     1443    fi 
     1444  else 
     1445    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1446  fi 
     1447  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
    12291448} 
    12301449 
     
    12351454#D- 
    12361455function IGCM_sys_GetDate_FichWork { 
    1237     IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1238     if ( $DEBUG_sys ) ; then 
    1239         echo "IGCM_sys_GetDate_FichWork :" $@ 
    1240     fi 
    1241     typeset dateF 
    1242     set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1243     eval ${2}=${dateF[5]} 
     1456  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1457  if ( $DEBUG_sys ) ; then 
     1458    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1459  fi 
     1460  typeset dateF 
     1461  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1462  eval ${2}=${dateF[5]} 
    12441463 
    12451464    # donne la date filesys d'un fichier sur la machine work 
    1246     IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1465  IGCM_debug_PopStack "IGCM_sys_FichWork" 
    12471466} 
    12481467 
     
    12531472#D- 
    12541473function IGCM_sys_GetDate_FichArchive { 
    1255     IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1256     if ( $DEBUG_sys ) ; then 
    1257         echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1258     fi 
    1259     typeset dateF 
    1260     set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1261     eval ${2}=${dateF[5]} 
    1262  
    1263     IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1474  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1475  if ( $DEBUG_sys ) ; then 
     1476    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1477  fi 
     1478  typeset dateF 
     1479  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1480  eval ${2}=${dateF[5]} 
     1481 
     1482  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1483} 
     1484 
     1485#D-#================================================== 
     1486#D-function IGCM_sys_Dods_Rm 
     1487#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. 
     1488#D-* Examples: 
     1489#D- 
     1490function IGCM_sys_Dods_Rm { 
     1491  if ( $DEBUG_sys ) ; then 
     1492    echo "IGCM_sys_Dods_Rm :" $@ 
     1493  fi 
     1494  typeset RET 
     1495  RET=0 
     1496  if [ $DRYRUN = 0 ]; then 
     1497    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then 
     1498      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." 
     1499      echo "Nothing has been done." 
     1500      return 
     1501    fi 
     1502    dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 
     1503    RET=$? 
     1504     
     1505#       if [ ${RET} -gt 0 ] ; then 
     1506#           echo "IGCM_sys_Dods_Rm : error." 
     1507#           cat out_dods_rm 
     1508#           IGCM_debug_Exit "IGCM_sys_Dods_Rm" 
     1509#       else 
     1510#           rm out_dods_rm 
     1511#       fi 
     1512 
     1513  else 
     1514    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1515  fi 
     1516  return $RET 
     1517} 
     1518 
     1519#D-#================================================== 
     1520#D-function IGCM_sys_Dods_Cp 
     1521#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. 
     1522#D-* Examples: 
     1523#D- 
     1524function IGCM_sys_Dods_Cp { 
     1525  if ( $DEBUG_sys ) ; then 
     1526    echo "IGCM_sys_Dods_Cp :" $@ 
     1527  fi 
     1528  typeset RET 
     1529  RET=0 
     1530  if [ $DRYRUN = 0 ]; then 
     1531    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1532      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." 
     1533      echo "Nothing has been done." 
     1534      return 
     1535    fi 
     1536    # 
     1537    dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 
     1538    RET=$? 
     1539 
     1540#       if [ ${RET} -gt 0 ] ; then 
     1541#           echo "IGCM_sys_Dods_Cp : error." 
     1542#           cat out_dods_cp 
     1543#           IGCM_debug_Exit "IGCM_sys_Dods_Cp" 
     1544#       else 
     1545#           rm out_dods_cp 
     1546#       fi 
     1547 
     1548  else 
     1549    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1550  fi 
     1551  return $RET 
     1552} 
     1553 
     1554#D-#================================================== 
     1555#D-function IGCM_sys_Put_Dods 
     1556#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole. 
     1557#D-* Examples: 
     1558#D- 
     1559function IGCM_sys_Put_Dods { 
     1560  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ 
     1561  if ( $DEBUG_sys ) ; then 
     1562    echo "IGCM_sys_Put_Dods :" $@ 
     1563  fi 
     1564  if [ $DRYRUN = 0 ]; then 
     1565    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1566      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." 
     1567      IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
     1568      return 
     1569    fi 
     1570 
     1571    typeset RET 
     1572        # 
     1573    cd ${R_SAVE} 
     1574    IGCM_sys_Dods_Rm ${1} 
     1575    IGCM_sys_Dods_Cp ${1} 
     1576    RET=0 
     1577     
     1578    if [ ${RET} -gt 0 ] ; then 
     1579      echo "IGCM_sys_Put_Dods : error." 
     1580      IGCM_debug_Exit "IGCM_sys_Put_Dods" 
     1581    fi 
     1582  else 
     1583    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1584  fi 
     1585  IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    12641586} 
    12651587 
     
    12681590 
    12691591function IGCM_sys_rebuild { 
    1270     IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
    1271     if ( $DEBUG_sys ) ; then 
    1272         echo "IGCM_sys_rebuild :" $@ 
    1273     fi 
    1274     /home/cont003/p86ipsl/X64/bin/rebuild -f -o $@ 
    1275     if [ $? -gt 0 ] ; then 
    1276        echo "IGCM_sys_rebuild : erreur ${@}." 
    1277        IGCM_debug_Exit "rebuild" 
    1278     fi 
    1279  
    1280     IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1592  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1593  if ( $DEBUG_sys ) ; then 
     1594    echo "IGCM_sys_rebuild :" $@ 
     1595  fi 
     1596  /home/cont003/p86ipsl/X64/bin/rebuild -f -o $@ 
     1597  if [ $? -gt 0 ] ; then 
     1598    echo "IGCM_sys_rebuild : erreur ${@}." 
     1599    IGCM_debug_Exit "rebuild" 
     1600  fi 
     1601 
     1602  IGCM_debug_PopStack "IGCM_sys_rebuild" 
    12811603} 
    12821604 
     
    12851607 
    12861608function IGCM_sys_activ_variables { 
    1287     IGCM_debug_PushStack "IGCM_sys_activ_variables" 
    1288     if ( $DEBUG_sys ) ; then 
    1289         echo "IGCM_sys_activ_variables" 
    1290     fi 
    1291     ulimit -s 2097152 
    1292     IGCM_debug_PopStack "IGCM_sys_activ_variables" 
     1609  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1610  if ( $DEBUG_sys ) ; then 
     1611    echo "IGCM_sys_activ_variables" 
     1612  fi 
     1613  ulimit -s 2097152 
     1614  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    12931615} 
    12941616 
     
    12971619 
    12981620function IGCM_sys_desactiv_variables { 
    1299     IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
    1300     if ( $DEBUG_sys ) ; then 
    1301         echo "IGCM_sys_desactiv_variables" 
    1302     fi 
    1303     IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
     1621  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1622  if ( $DEBUG_sys ) ; then 
     1623    echo "IGCM_sys_desactiv_variables" 
     1624  fi 
     1625  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
    13041626} 
    13051627 
     
    13081630 
    13091631function IGCM_sys_build_run_file { 
    1310     IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
    1311     if ( $DEBUG_sys ) ; then 
    1312         echo "IGCM_sys_build_run_file " $@ 
    1313     fi 
    1314  
    1315     # set Number of processors for OCE here 
    1316     NUM_PROC_OCE=5 
    1317  
    1318     (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE - 1)) 
    1319     (( nb_tot_m1    = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE )) 
    1320     if [ $1 = MPI1 ]; then 
    1321         cat <<EOF > run_file 
     1632  IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
     1633  if ( $DEBUG_sys ) ; then 
     1634    echo "IGCM_sys_build_run_file " $@ 
     1635  fi 
     1636 
     1637  # set Number of processors for OCE here 
     1638  NUM_PROC_OCE=5 
     1639 
     1640  (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE - 1)) 
     1641  (( nb_tot_m1    = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE )) 
     1642  if [ $1 = MPI1 ]; then 
     1643    cat <<EOF > run_file 
    13221644-np 1 ./oasis 
    13231645-np ${NUM_PROC_ATM} ./lmdz.x 
    13241646-np ${NUM_PROC_OCE} ./opa.xx 
    13251647EOF 
    1326         config_UserChoices_JobRunOptions='"--app"' 
    1327         IGCM_sys_Chmod u+x run_file 
    1328     fi 
    1329     IGCM_debug_PopStack "IGCM_sys_build_run_file" 
     1648    config_UserChoices_JobRunOptions='"--app"' 
     1649    IGCM_sys_Chmod u+x run_file 
     1650  fi 
     1651  IGCM_debug_PopStack "IGCM_sys_build_run_file" 
    13301652   
    13311653} 
     
    13341656# NCO OPERATOR 
    13351657 
     1658function IGCM_sys_ncap2 { 
     1659  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ 
     1660  if ( $DEBUG_sys ) ; then 
     1661    echo "IGCM_sys_ncap2 :" $@ 
     1662  fi 
     1663  ncap2 "$@" 
     1664  if [ $? -gt 0 ] ; then 
     1665    echo "IGCM_sys_ncap2 : erreur ${@}." 
     1666    IGCM_debug_Exit "ncap2" 
     1667  fi 
     1668 
     1669  IGCM_debug_PopStack "IGCM_sys_ncap2" 
     1670} 
     1671 
    13361672function IGCM_sys_ncatted { 
    1337     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
    1338     if ( $DEBUG_sys ) ; then 
    1339         echo "IGCM_sys_ncatted :" $@ 
    1340     fi 
    1341     ncatted "$@" 
    1342     if [ $? -gt 0 ] ; then 
    1343        echo "IGCM_sys_ncatted : erreur ${@}." 
    1344        IGCM_debug_Exit "ncatted" 
    1345     fi 
    1346  
    1347     IGCM_debug_PopStack "IGCM_sys_ncatted" 
     1673  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
     1674  if ( $DEBUG_sys ) ; then 
     1675    echo "IGCM_sys_ncatted :" $@ 
     1676  fi 
     1677  ncatted "$@" 
     1678  if [ $? -gt 0 ] ; then 
     1679    echo "IGCM_sys_ncatted : erreur ${@}." 
     1680    IGCM_debug_Exit "ncatted" 
     1681  fi 
     1682 
     1683  IGCM_debug_PopStack "IGCM_sys_ncatted" 
    13481684} 
    13491685 
    13501686function IGCM_sys_ncbo { 
    1351     IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
    1352     if ( $DEBUG_sys ) ; then 
    1353         echo "IGCM_sys_ncbo :" $@ 
    1354     fi 
    1355     ncbo $@ 
    1356     if [ $? -gt 0 ] ; then 
    1357        echo "IGCM_sys_ncbo : erreur ${@}." 
    1358        IGCM_debug_Exit "ncbo" 
    1359     fi 
    1360  
    1361     IGCM_debug_PopStack "IGCM_sys_ncbo" 
     1687  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
     1688  if ( $DEBUG_sys ) ; then 
     1689    echo "IGCM_sys_ncbo :" $@ 
     1690  fi 
     1691  ncbo $@ 
     1692  if [ $? -gt 0 ] ; then 
     1693    echo "IGCM_sys_ncbo : erreur ${@}." 
     1694    IGCM_debug_Exit "ncbo" 
     1695  fi 
     1696 
     1697  IGCM_debug_PopStack "IGCM_sys_ncbo" 
    13621698} 
    13631699 
    13641700function IGCM_sys_ncdiff { 
    1365     IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
    1366     if ( $DEBUG_sys ) ; then 
    1367         echo "IGCM_sys_ncdiff :" $@ 
    1368     fi 
    1369     ncdiff $@ 
    1370     if [ $? -gt 0 ] ; then 
    1371        echo "IGCM_sys_ncdiff : erreur ${@}." 
    1372        IGCM_debug_Exit "ncdiff" 
    1373     fi 
    1374  
    1375     IGCM_debug_PopStack "IGCM_sys_ncdiff" 
     1701  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
     1702  if ( $DEBUG_sys ) ; then 
     1703    echo "IGCM_sys_ncdiff :" $@ 
     1704  fi 
     1705  ncdiff $@ 
     1706  if [ $? -gt 0 ] ; then 
     1707    echo "IGCM_sys_ncdiff : erreur ${@}." 
     1708    IGCM_debug_Exit "ncdiff" 
     1709  fi 
     1710 
     1711  IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    13761712} 
    13771713 
    13781714function IGCM_sys_ncea { 
    1379     IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
    1380     if ( $DEBUG_sys ) ; then 
    1381         echo "IGCM_sys_ncea :" $@ 
    1382     fi 
    1383     ncea $@ 
    1384     if [ $? -gt 0 ] ; then 
    1385        echo "IGCM_sys_ncea : erreur ${@}." 
    1386        IGCM_debug_Exit "ncea" 
    1387     fi 
    1388  
    1389     IGCM_debug_PopStack "IGCM_sys_ncea" 
     1715  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
     1716  if ( $DEBUG_sys ) ; then 
     1717    echo "IGCM_sys_ncea :" $@ 
     1718  fi 
     1719  ncea $@ 
     1720  if [ $? -gt 0 ] ; then 
     1721    echo "IGCM_sys_ncea : erreur ${@}." 
     1722    IGCM_debug_Exit "ncea" 
     1723  fi 
     1724 
     1725  IGCM_debug_PopStack "IGCM_sys_ncea" 
    13901726} 
    13911727 
    13921728function IGCM_sys_ncecat { 
    1393     IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
    1394     if ( $DEBUG_sys ) ; then 
    1395         echo "IGCM_sys_ncecat :" $@ 
    1396     fi 
    1397     ncecat $@ 
    1398     if [ $? -gt 0 ] ; then 
    1399        echo "IGCM_sys_ncecat : erreur ${@}." 
    1400        IGCM_debug_Exit "ncecat" 
    1401     fi 
    1402  
    1403     IGCM_debug_PopStack "IGCM_sys_ncecat" 
     1729  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
     1730  if ( $DEBUG_sys ) ; then 
     1731    echo "IGCM_sys_ncecat :" $@ 
     1732  fi 
     1733  ncecat $@ 
     1734  if [ $? -gt 0 ] ; then 
     1735    echo "IGCM_sys_ncecat : erreur ${@}." 
     1736    IGCM_debug_Exit "ncecat" 
     1737  fi 
     1738 
     1739  IGCM_debug_PopStack "IGCM_sys_ncecat" 
    14041740} 
    14051741 
    14061742function IGCM_sys_ncflint { 
    1407     IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
    1408     if ( $DEBUG_sys ) ; then 
    1409         echo "IGCM_sys_ncflint :" $@ 
    1410     fi 
    1411     ncflint $@ 
    1412     if [ $? -gt 0 ] ; then 
    1413        echo "IGCM_sys_ncflint : erreur ${@}." 
    1414        IGCM_debug_Exit "ncflint" 
    1415     fi 
    1416  
    1417     IGCM_debug_PopStack "IGCM_sys_ncflint" 
     1743  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
     1744  if ( $DEBUG_sys ) ; then 
     1745    echo "IGCM_sys_ncflint :" $@ 
     1746  fi 
     1747  ncflint $@ 
     1748  if [ $? -gt 0 ] ; then 
     1749    echo "IGCM_sys_ncflint : erreur ${@}." 
     1750    IGCM_debug_Exit "ncflint" 
     1751  fi 
     1752 
     1753  IGCM_debug_PopStack "IGCM_sys_ncflint" 
    14181754} 
    14191755 
    14201756function IGCM_sys_ncks { 
    1421     IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
    1422     if ( $DEBUG_sys ) ; then 
    1423         echo "IGCM_sys_ncks :" $@ 
    1424     fi 
    1425     ncks $@ 
    1426     if [ $? -gt 0 ] ; then 
    1427        echo "IGCM_sys_ncks : erreur ${@}." 
    1428        IGCM_debug_Exit "ncks" 
    1429     fi 
    1430  
    1431     IGCM_debug_PopStack "IGCM_sys_ncks" 
     1757  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
     1758  if ( $DEBUG_sys ) ; then 
     1759    echo "IGCM_sys_ncks :" $@ 
     1760  fi 
     1761  ncks $@ 
     1762  if [ $? -gt 0 ] ; then 
     1763    echo "IGCM_sys_ncks : erreur ${@}." 
     1764    IGCM_debug_Exit "ncks" 
     1765  fi 
     1766 
     1767  IGCM_debug_PopStack "IGCM_sys_ncks" 
    14321768} 
    14331769 
    14341770function IGCM_sys_ncpdq { 
    1435     IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
    1436     if ( $DEBUG_sys ) ; then 
    1437         echo "IGCM_sys_ncpdq :" $@ 
    1438     fi 
    1439     ncpdq $@ 
    1440     if [ $? -gt 0 ] ; then 
    1441        echo "IGCM_sys_ncpdq : erreur ${@}." 
    1442        IGCM_debug_Exit "ncpdq" 
    1443     fi 
    1444  
    1445     IGCM_debug_PopStack "IGCM_sys_ncpdq" 
     1771  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
     1772  if ( $DEBUG_sys ) ; then 
     1773    echo "IGCM_sys_ncpdq :" $@ 
     1774  fi 
     1775  ncpdq $@ 
     1776  if [ $? -gt 0 ] ; then 
     1777    echo "IGCM_sys_ncpdq : erreur ${@}." 
     1778    IGCM_debug_Exit "ncpdq" 
     1779  fi 
     1780 
     1781  IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    14461782} 
    14471783 
    14481784function IGCM_sys_ncra { 
    1449     IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
    1450     if ( $DEBUG_sys ) ; then 
    1451         echo "IGCM_sys_ncra :" $@ 
    1452     fi 
    1453     ncra $@ 
    1454     if [ $? -gt 0 ] ; then 
    1455        echo "IGCM_sys_ncra : erreur ${@}." 
    1456        IGCM_debug_Exit "ncra" 
    1457     fi 
    1458  
    1459     IGCM_debug_PopStack "IGCM_sys_ncra" 
     1785  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
     1786  if ( $DEBUG_sys ) ; then 
     1787    echo "IGCM_sys_ncra :" $@ 
     1788  fi 
     1789  ncra $@ 
     1790  if [ $? -gt 0 ] ; then 
     1791    echo "IGCM_sys_ncra : erreur ${@}." 
     1792    IGCM_debug_Exit "ncra" 
     1793  fi 
     1794 
     1795  IGCM_debug_PopStack "IGCM_sys_ncra" 
    14601796} 
    14611797 
    14621798function IGCM_sys_ncrcat { 
    1463     IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
    1464     if ( $DEBUG_sys ) ; then 
    1465         echo "IGCM_sys_ncrcat :" $@ 
    1466     fi 
    1467     ncrcat $@ 
    1468     if [ $? -gt 0 ] ; then 
    1469        echo "IGCM_sys_ncrcat : erreur ${@}." 
     1799  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
     1800  if ( $DEBUG_sys ) ; then 
     1801    echo "IGCM_sys_ncrcat :" $@ 
     1802  fi 
     1803  ncrcat $@ 
     1804  if [ $? -gt 0 ] ; then 
     1805    echo "IGCM_sys_ncrcat : erreur ${@}." 
    14701806#       IGCM_debug_Exit "ncrcat" 
    1471     fi 
    1472  
    1473     IGCM_debug_PopStack "IGCM_sys_ncrcat" 
     1807  fi 
     1808 
     1809  IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    14741810} 
    14751811 
    14761812function IGCM_sys_ncrename { 
    1477     IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
    1478     if ( $DEBUG_sys ) ; then 
    1479         echo "IGCM_sys_ncrename :" $@ 
    1480     fi 
    1481     ncrename $@ 
    1482     if [ $? -gt 0 ] ; then 
    1483        echo "IGCM_sys_ncrename : erreur ${@}." 
    1484        IGCM_debug_Exit "ncrename" 
    1485     fi 
    1486  
    1487     IGCM_debug_PopStack "IGCM_sys_ncrename" 
     1813  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
     1814  if ( $DEBUG_sys ) ; then 
     1815    echo "IGCM_sys_ncrename :" $@ 
     1816  fi 
     1817  ncrename $@ 
     1818  if [ $? -gt 0 ] ; then 
     1819    echo "IGCM_sys_ncrename : erreur ${@}." 
     1820    IGCM_debug_Exit "ncrename" 
     1821  fi 
     1822 
     1823  IGCM_debug_PopStack "IGCM_sys_ncrename" 
    14881824} 
    14891825 
    14901826function IGCM_sys_ncwa { 
    1491     IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
    1492     if ( $DEBUG_sys ) ; then 
    1493         echo "IGCM_sys_ncwa :" $@ 
    1494     fi 
    1495     ncwa $@ 
    1496     if [ $? -gt 0 ] ; then 
    1497        echo "IGCM_sys_ncwa : erreur ${@}." 
    1498        IGCM_debug_Exit "ncwa" 
    1499     fi 
    1500  
    1501     IGCM_debug_PopStack "IGCM_sys_ncwa" 
    1502 } 
     1827  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
     1828  if ( $DEBUG_sys ) ; then 
     1829    echo "IGCM_sys_ncwa :" $@ 
     1830  fi 
     1831  ncwa $@ 
     1832  if [ $? -gt 0 ] ; then 
     1833    echo "IGCM_sys_ncwa : erreur ${@}." 
     1834    IGCM_debug_Exit "ncwa" 
     1835  fi 
     1836 
     1837  IGCM_debug_PopStack "IGCM_sys_ncwa" 
     1838} 
     1839 
     1840############################################################## 
     1841# CDO OPERATOR 
     1842 
     1843function IGCM_sys_cdo { 
     1844  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ 
     1845  if ( $DEBUG_sys ) ; then 
     1846    echo "IGCM_sys_cdo :" $@ 
     1847  fi 
     1848  \cdo $@ 
     1849  if [ $? -gt 0 ] ; then 
     1850    echo "IGCM_sys_cdo : erreur ${@}." 
     1851    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1852    return 1 
     1853  else 
     1854    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1855    return 0 
     1856  fi 
     1857 
     1858  IGCM_debug_PopStack "IGCM_sys_cdo" 
     1859} 
Note: See TracChangeset for help on using the changeset viewer.