Changeset 571 for branches


Ignore:
Timestamp:
03/07/12 10:39:55 (12 years ago)
Author:
mafoipsl
Message:

First try to merge libIGCM_MPI_OpenMP branch with libIGCM trunk revision 569. Tested on vargas with PackFrequency?=NONE included into config.card.

Location:
branches/libIGCM_MPI_OpenMP
Files:
30 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/libIGCM_MPI_OpenMP

  • branches/libIGCM_MPI_OpenMP/AA_SE_Checker

    r436 r571  
    1818# all TS to last PeriodDateEnd value, give by run.card->Configuration->OldPrefix string. 
    1919 
    20 # Chemin vers libIGCM 
     20#D- Path to libIGCM 
     21#D- Default : value from AA_job if any 
     22# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     23# WARNING you must check MirrorlibIGCM variable in sys library. 
     24# WARNING If this variable is true, you must use libIGCM_POST path instead 
     25# WARNING of your running libIGCM directory. 
    2126libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    22 # Attention : à changer si la machine de post-traitement n'est pas la frontale du serveur de calcul ! 
    23 #             voir précence de la variable MirrorlibIGCM dans votre couche systÚme. 
    2427 
    2528# Expericence class of the run 
     
    8386#==================================================== 
    8487#R_SAVE : Job output directory 
     88#R_BUFR : Job output buffered directory 
    8589if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    8690    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    8791    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     92    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    8893    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    8994else 
    9095    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     96    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    9197    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    9298fi 
  • branches/libIGCM_MPI_OpenMP/AA_TimeSeries_Checker

    r526 r571  
    1818# all TS to last PeriodDateEnd value, give by run.card->Configuration->OldPrefix string. 
    1919 
    20 # Chemin vers libIGCM 
     20#D- Path to libIGCM 
     21#D- Default : value from AA_job if any 
     22# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     23# WARNING you must check MirrorlibIGCM variable in sys library. 
     24# WARNING If this variable is true, you must use libIGCM_POST path instead 
     25# WARNING of your running libIGCM directory. 
    2126libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    22 # Attention : à changer si la machine de post-traitement n'est pas la frontale du serveur de calcul ! 
    23 #             voir précence de la variable MirrorlibIGCM dans votre couche systÚme. 
    2427 
    2528# Expericence class of the run 
     
    128131#==================================================== 
    129132#R_SAVE : Job output directory 
     133#R_BUFR : Job output buffered directory 
    130134if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    131135    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    132136    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     137    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    133138    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    134139else 
    135140    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     141    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    136142    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    137143fi 
     
    392398                                        ChunckCompletedFlag=${PotentialCompletedFlag[0]} 
    393399                                        IGCM_debug_Print 2 -e "\033[1;31mToo Many Potential CompletedFlag\033[m Let start with first CompletedPeriod" 
    394                                         IGCM_debug_Print 2 -e "\033[1;31mYou will have to redo TimeSeries_Checker\033[m for other period. 
     400                                        IGCM_debug_Print 2 -e "\033[1;31mYou will have to redo TimeSeries_Checker\033[m for other period." 
    395401                                    fi 
    396402                                fi 
  • branches/libIGCM_MPI_OpenMP/AA_additionnal

    r563 r571  
    8989#-Q- sx9mercure ## CESIUM FOR SX9  CEA ## 
    9090#-Q- sx9mercure ######################### 
    91 #-Q- sx9mercure #MSUB -r ATL_ADD        # Nom du job                 
     91#-Q- sx9mercure #MSUB -r ATL_ADD        # Nom du job 
    9292#-Q- sx9mercure #MSUB -N 1              # Reservation du noeud 
    9393#-Q- sx9mercure #MSUB -n 2              # Reservation du processus 
     
    100100#-Q- titane ## TITANE   CEA ## 
    101101#-Q- titane ###################### 
    102 #-Q- titane #MSUB -r ATL_ADD        # Nom du job                 
    103 #-Q- titane #MSUB -N 1              # Reservation du noeud 
    104 #-Q- titane #MSUB -n 2              # Reservation du processus 
    105 #-Q- titane #MSUB -c 4              # Reservation du core 
     102#-Q- titane #MSUB -r ATL_ADD        # Nom du job 
     103#-Q- titane #MSUB -eo 
     104#-Q- titane #MSUB -n 1              # Reservation du processus 
    106105#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    107 #-Q- titane #MSUB -E "-j o" 
    108 #-Q- titane #MSUB -E "-S /bin/ksh" 
    109 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    110 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     106#-Q- titane #MSUB -q mono 
    111107#-Q- default #!/bin/ksh 
    112108#-Q- default ################## 
  • branches/libIGCM_MPI_OpenMP/AA_atlas_LMDZ

    r563 r571  
    9999#-Q- titane ###################### 
    100100#-Q- titane #MSUB -r ATL_LMDZ       # Nom du job                 
    101 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     101#-Q- titane #MSUB -eo 
    102102#-Q- titane #MSUB -n 1              # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -E "-j o" 
    105 #-Q- titane #MSUB -E "-S /bin/ksh" 
    106 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    107 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     104#-Q- titane #MSUB -q mono 
    108105#-Q- default #!/bin/ksh 
    109106#-Q- default ################## 
     
    188185    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    189186    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     187    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    190188    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    191189else 
    192190    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     191    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    193192    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    194193fi 
  • branches/libIGCM_MPI_OpenMP/AA_atlas_ORCA_LIM

    r563 r571  
    9999#-Q- titane ###################### 
    100100#-Q- titane #MSUB -r ATL_OPA        # Nom du job                 
    101 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     101#-Q- titane #MSUB -eo 
    102102#-Q- titane #MSUB -n 1              # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -E "-j o" 
    105 #-Q- titane #MSUB -E "-S /bin/ksh" 
    106 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    107 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     104#-Q- titane #MSUB -q mono 
    108105#-Q- default #!/bin/ksh 
    109106#-Q- default ################## 
     
    184181#================================== 
    185182#R_SAVE : Job output directory 
     183#R_BUFR : Job output buffered directory 
    186184if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    187185    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    188186    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     187    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    189188    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    190189else 
    191190    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     191    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    192192    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    193193fi 
  • branches/libIGCM_MPI_OpenMP/AA_atlas_ORCHIDEE

    r563 r571  
    9999#-Q- titane ###################### 
    100100#-Q- titane #MSUB -r ATL_ORCH       # Nom du job                 
    101 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     101#-Q- titane #MSUB -eo 
    102102#-Q- titane #MSUB -n 1              # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -E "-j o" 
    105 #-Q- titane #MSUB -E "-S /bin/ksh" 
    106 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    107 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     104#-Q- titane #MSUB -q mono 
    108105#-Q- lxiv8 ###################### 
    109106#-Q- lxiv8 ## OBELIX      LSCE ## 
     
    193190#================================== 
    194191#R_SAVE : Job output directory 
     192#R_BUFR : Job output buffered directory 
    195193if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    196194    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    197195    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     196    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    198197    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    199198else 
    200199    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     200    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    201201    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    202202fi 
  • branches/libIGCM_MPI_OpenMP/AA_atlas_PISCES

    r563 r571  
    9898#-Q- titane ## TITANE   CEA ## 
    9999#-Q- titane ###################### 
    100 #-Q- titane #MSUB -r ATL_PIS        # Nom du job                 
    101 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     100#-Q- titane #MSUB -r ATL_PIS        # Nom du job 
     101#-Q- titane #MSUB -eo 
    102102#-Q- titane #MSUB -n 1              # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -E "-j o" 
    105 #-Q- titane #MSUB -E "-S /bin/ksh" 
    106 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    107 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     104#-Q- titane #MSUB -q mono 
    108105#-Q- default #!/bin/ksh 
    109106#-Q- default ################## 
     
    185182#================================== 
    186183#R_SAVE : Job output directory 
     184#R_BUFR : Job output buffered directory 
    187185if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    188186    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    189187    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     188    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    190189    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    191190else 
    192191    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     192    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    193193    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    194194fi 
  • branches/libIGCM_MPI_OpenMP/AA_clean_month

    r428 r571  
    7777#==================================================== 
    7878#R_SAVE : Job output directory 
     79#R_BUFR : Job output buffered directory 
    7980if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    8081    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    8182    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     83    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    8284else 
    8385    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     86    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    8487fi 
    8588IGCM_sys_TestDirArchive ${R_SAVE} 
     
    8891if [ ! -f ${SUBMIT_DIR}/run.card ]; then  
    8992    echo "You seem NOT to have a run.card in this directory !!" 
    90     echo "This script will fail because it doesn't know what to do without run.card avaible." 
     93    echo "This script will fail because it doesn't know what to do without run.card available." 
    9194    exit 1 
    9295else 
     
    104107    set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " ) 
    105108    CountListFiles=${#ListFiles[@]} 
     109 
     110    echo "Search files with ${PeriodDateEnd} in ${R_BUFR}" 
     111    set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " ) 
     112    CountListFilesBuf=${#ListFilesBuf[@]} 
    106113 
    107114    # If exist, erase REBUILD DIR 
     
    124131            IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" 
    125132        done 
     133        for file in ${ListFilesBuf[@]} ; do 
     134            IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" 
     135        done 
    126136 
    127         echo "\033[1;32mDo you REALLY want to erase all those files ?" 
    128         echo -n " Your answer (y/n) : \033[m" 
     137        echo -e "\033[1;32mDo you REALLY want to erase all those files ?" 
     138        echo -n -e " Your answer (y/n) : \033[m" 
    129139        read reponse 
    130140        case ${reponse} in 
     
    133143                echo "OK. It will be erased." 
    134144                IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" 
     145                IGCM_sys_RshMaster  "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" 
    135146                echo "done." 
    136147                ;; 
     
    147158        done 
    148159 
    149         echo "\033[1;32mDo you REALLY want to erase all those Directories ?" 
    150         echo -n " Your answer (y/n) : \033[m" 
     160        echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?" 
     161        echo -n -e " Your answer (y/n) : \033[m" 
    151162        read reponse 
    152163        case ${reponse} in 
  • branches/libIGCM_MPI_OpenMP/AA_create_multi_se

    r563 r571  
    3131#-Q- sx8brodie ####################### 
    3232#-Q- sx8brodie # Temps Elapsed max. d'une requete hh:mm:ss 
    33 #-Q- sx8brodie # @ wall_clock_limit = 10:00:00 
     33#-Q- sx8brodie # @ wall_clock_limit = 1:00:00 
    3434#-Q- sx8brodie # Nom du travail LoadLeveler 
    3535#-Q- sx8brodie # @ job_name   = MULTISE 
     
    4747#-Q- aix6 ####################### 
    4848#-Q- aix6 # Temps Elapsed max. d'une requete hh:mm:ss 
    49 #-Q- aix6 # @ wall_clock_limit = 10:00:00 
     49#-Q- aix6 # @ wall_clock_limit = 1:00:00 
    5050#-Q- aix6 # Nom du travail LoadLeveler 
    5151#-Q- aix6 # @ job_name   = MULTISE 
     
    6363#-Q- ulam ####################### 
    6464#-Q- ulam # Temps Elapsed max. d'une requete hh:mm:ss 
    65 #-Q- ulam # @ wall_clock_limit = 10:00:00 
     65#-Q- ulam # @ wall_clock_limit = 1:00:00 
    6666#-Q- ulam # Nom du travail LoadLeveler 
    6767#-Q- ulam # @ job_name   = MULTISE 
     
    9999#-Q- titane ###################### 
    100100#-Q- titane #MSUB -r MULTISE             # Nom du job                 
    101 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     101#-Q- titane #MSUB -eo 
    102102#-Q- titane #MSUB -n 1              # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -E "-j o" 
    105 #-Q- titane #MSUB -E "-S /bin/ksh" 
    106 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    107 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     104#-Q- titane #MSUB -q mono 
    108105#-Q- lxiv8 ###################### 
    109106#-Q- lxiv8 ## OBELIX      LSCE ## 
     
    146143StandAlone=${StandAlone:=true} 
    147144 
    148 #D- Low level debug : to bypass lib test checks and stack construction 
     145#D- Path to libIGCM 
    149146#D- Default : value from AA_job if any 
     147# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     148# WARNING you must check MirrorlibIGCM variable in sys library. 
     149# WARNING If this variable is true, you must use libIGCM_POST path instead 
     150# WARNING of your running libIGCM directory. 
    150151libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    151 # WARNING for StandAlone used : To run this script on some machine, 
    152 # you must check MirrorlibIGCM variable in sys library. 
    153 # If this variable is true, you must use libIGCM_POST path instead 
    154 # of your running libIGCM directory. 
    155152 
    156153#D- Flag to determine atlas job's output directory 
     
    241238#================================== 
    242239#R_SAVE : Job output directory 
     240#R_BUFR : Job output buffered directory 
    243241if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    244242    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    245243    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     244    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    246245    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    247246else 
    248247    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     248    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    249249    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    250250fi 
  • branches/libIGCM_MPI_OpenMP/AA_create_se

    r563 r571  
    9999#-Q- titane ###################### 
    100100#-Q- titane #MSUB -r SE             # Nom du job                 
    101 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     101#-Q- titane #MSUB -eo 
    102102#-Q- titane #MSUB -n 1              # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -E "-j o" 
    105 #-Q- titane #MSUB -E "-S /bin/ksh" 
    106 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    107 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     104#-Q- titane #MSUB -q mono 
    108105#-Q- lxiv8 ###################### 
    109106#-Q- lxiv8 ## OBELIX      LSCE ## 
     
    146143StandAlone=${StandAlone:=true} 
    147144 
    148 #D- Low level debug : to bypass lib test checks and stack construction 
     145#D- Path to libIGCM 
    149146#D- Default : value from AA_job if any 
     147# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     148# WARNING you must check MirrorlibIGCM variable in sys library. 
     149# WARNING If this variable is true, you must use libIGCM_POST path instead 
     150# WARNING of your running libIGCM directory. 
    150151libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    151 # WARNING for StandAlone used : To run this script on some machine, 
    152 # you must check MirrorlibIGCM variable in sys library. 
    153 # If this variable is true, you must use libIGCM_POST path instead 
    154 # of your running libIGCM directory. 
    155152 
    156153#D- Flag to determine if rebuild process has been performed asynchronously 
     
    251248#================================== 
    252249#R_SAVE : Job output directory 
     250#R_BUFR : Job output buffered directory 
    253251if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    254252    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    255253    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     254    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    256255    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    257256else 
    258257    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     258    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    259259    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    260260fi 
  • branches/libIGCM_MPI_OpenMP/AA_create_ts

    r563 r571  
    9999#-Q- titane ###################### 
    100100#-Q- titane #MSUB -r TS             # Nom du job                 
    101 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     101#-Q- titane #MSUB -eo 
    102102#-Q- titane #MSUB -n 1              # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -E "-j o" 
    105 #-Q- titane #MSUB -E "-S /bin/ksh" 
    106 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    107 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     104#-Q- titane #MSUB -q mono 
    108105#-Q- lxiv8 ###################### 
    109106#-Q- lxiv8 ## OBELIX      LSCE ## 
     
    146143StandAlone=${StandAlone:=true} 
    147144 
    148 #D- Low level debug : to bypass lib test checks and stack construction 
     145#D- Path to libIGCM 
    149146#D- Default : value from AA_job if any 
     147# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     148# WARNING you must check MirrorlibIGCM variable in sys library. 
     149# WARNING If this variable is true, you must use libIGCM_POST path instead 
     150# WARNING of your running libIGCM directory. 
    150151libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    151 # WARNING for StandAlone used : To run this script on some machine, 
    152 # you must check MirrorlibIGCM variable in sys library. 
    153 # If this variable is true, you must use libIGCM_POST path instead 
    154 # of your running libIGCM directory. 
    155152 
    156153#D- Flag to determine allready produced time series. Empty if you start from the beginning 
     
    271268#================================== 
    272269#R_SAVE : Job output directory 
     270#R_BUFR : Job output buffered directory 
    273271if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    274272    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    275273    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     274    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    276275    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    277276else 
    278277    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     278    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    279279    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    280280fi 
     
    469469######################################################################## 
    470470# 
    471 #                          DEFINE DATE FUNCTIONS 
    472 # 
    473 ######################################################################## 
    474  
    475 # Give the end of the next $1 period from $2 date 
    476 function create_ts_next_date { 
    477     IGCM_debug_PushStack "create_ts_next_date" $@ 
    478     typeset Length 
    479     case ${config_UserChoices_PeriodLength} in 
    480         *Y|*y)  
    481             PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 
    482             IGCM_date_GetYearMonth ${1} year month 
    483             year=$( IGCM_date_SupressZeros ${year} ) 
    484             (( Length=0 )) 
    485             (( i=0 )) 
    486             until [ $i -ge $PeriodLengthInYears ] ; do 
    487                 (( Length = Length + $( IGCM_date_DaysInYear $(( year + i + 1 )) ) ))  
    488                 (( i=i+1 )) 
    489             done 
    490             ;; 
    491         *M|*m)  
    492             PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 
    493             IGCM_date_GetYearMonth ${1} year month 
    494             year=$( IGCM_date_SupressZeros ${year} ) 
    495             (( year0 = year )) 
    496             if [ $(( month + 1 )) -lt 13 ] ; then 
    497                 month0=$(( month + 1 )) 
    498             else 
    499                 month0=$(( month + 1 - 12 )) 
    500                 (( year = year0 + 1 )) 
    501             fi 
    502             (( Length=0 )) 
    503             (( i=0 )) 
    504             until [ $i -ge $PeriodLengthInMonths ] ; do 
    505                 if [ $(( month0 + i )) -lt 13 ] ; then 
    506                     (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) )) 
    507                 else 
    508                     (( year = year0 + 1 )) 
    509                     (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) ) )) 
    510                 fi 
    511                 (( i=i+1 )) 
    512             done 
    513             ;; 
    514         *D|*d) 
    515             Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;; 
    516         *) 
    517             IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in *Y, *M, *D." 
    518             IGCM_debug_Verif_Exit_Post ;; 
    519     esac 
    520     echo ${Length} 
    521  
    522     IGCM_debug_PopStack "create_ts_next_date" 
    523 } 
    524  
    525 # Give the end of the actual $1 period from $2 date 
    526 function create_ts_begin_date { 
    527     IGCM_debug_PushStack "create_ts_begin_date" $@ 
    528     typeset Length 
    529     case ${config_UserChoices_PeriodLength} in 
    530         *Y|*y)  
    531             PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 
    532             IGCM_date_GetYearMonth ${1} year month 
    533             year=$( IGCM_date_SupressZeros ${year} ) 
    534             if [ X${2} = Xend ] ; then 
    535                 (( year = year - PeriodLengthInYears + 1)) 
    536             fi 
    537             (( Length=0 )) 
    538             (( i=0 )) 
    539             until [ $i -ge $PeriodLengthInYears ] ; do 
    540                 (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
    541                 (( i=i+1 )) 
    542             done 
    543             ;; 
    544         *M|*m)  
    545             PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 
    546             IGCM_date_GetYearMonth ${1} year month 
    547             year=$( IGCM_date_SupressZeros ${year} ) 
    548             if [ X${2} = Xend ] ; then 
    549                 (( month = month - PeriodLengthInMonths + 1 )) 
    550             fi       
    551             (( year0 = year )) 
    552             if [ $month -le 0 ] ; then 
    553                 (( month = month + 12 )) 
    554                 year=$( printf "%04i\n" $(( year - 1 )) ) 
    555             fi 
    556             month=$( printf "%02i\n" ${month} ) 
    557             (( Length=0 )) 
    558             (( i=0 )) 
    559             until [ $i -ge $PeriodLengthInMonths ] ; do 
    560                 if [ $(( month + i )) -lt 13 ] ; then 
    561                     (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 
    562                 else 
    563                     (( year = year0 + 1 )) 
    564                     (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 
    565                 fi 
    566                 (( i=i+1 )) 
    567             done 
    568             ;; 
    569         *D|*d) 
    570             Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;; 
    571         *) 
    572             IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in *Y, *M, *D." 
    573             IGCM_debug_Verif_Exit_Post ;; 
    574     esac 
    575     echo ${Length} 
    576  
    577     IGCM_debug_PopStack "create_ts_begin_date" 
    578 } 
    579  
    580 ######################################################################## 
    581 # 
    582471#               IS THERE SOME ALLREADY PRODUCED TIME SERIES ? 
    583472#                 IF SO BRING THEM IN THE WORKING DIRECTORY 
     
    622511    # First Time Series Submission 
    623512    FIRST_PASS=TRUE 
    624     Length=$( create_ts_begin_date ${DateBegin} begin) 
     513    Length=$( IGCM_date_DaysInPreviousPeriod ${DateBegin} ${config_UserChoices_PeriodLength} begin) 
    625514    DATE_FIN_JOB_B=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( Length - 1 )) ) 
    626515else 
     
    692581    while [ ${DATE_COUNT} -lt ${PeriodDateEnd} ] ; do 
    693582        (( NBRE_FILE_TOT = NBRE_FILE_TOT + 1 )) 
    694         Length=$( create_ts_next_date ${DATE_COUNT} ) 
     583        Length=$( IGCM_date_DaysInNextPeriod ${DATE_COUNT} ${config_UserChoices_PeriodLength} ) 
    695584        DATE_COUNT=$( IGCM_date_AddDaysToGregorianDate ${DATE_COUNT} ${Length} ) 
    696585    done 
     
    723612            DATE_COURANTE=${DATE_FIN_JOB_B_LOOP} 
    724613        else 
    725             Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} ) 
     614            Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN_JOB_B_LOOP} ${config_UserChoices_PeriodLength} ) 
    726615            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} ) 
    727616        fi 
     
    740629 
    741630        if [ ! ${FIRST_PASS} = TRUE ] && [ ${CURRENT_LOOP} -eq 1 ] ; then 
    742             Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} ) 
     631            Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN_JOB_B_LOOP} ${config_UserChoices_PeriodLength} ) 
    743632            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} ) 
    744633        elif [ -z "${DATE_COURANTE}" ] ; then 
    745634            DATE_COURANTE=${DATE_FIN_JOB_B} 
    746635        else 
    747             Length=$( create_ts_next_date ${DATE_FIN} ) 
     636            Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} ) 
    748637            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} ) 
    749638        fi 
     
    755644        while [ ${COMPTEUR} -lt ${NBRE_FILE_LOOP} ] ; do 
    756645            # 
    757             Length=$( create_ts_next_date ${DATE_LOOP} ) 
     646            Length=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} ) 
    758647            DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length} ) 
    759648            (( TotLength = TotLength + Length )) 
     
    772661        [ ${NBRE_FILE_LOOP} -eq 0 ] && NBRE_FILE_LOOP=${UNIX_MAX_LIMIT} 
    773662 
    774         Length=$( create_ts_next_date ${DATE_FIN} ) 
     663        Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} ) 
    775664        DATE_COURANTE=$(IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} ) 
    776665        DATE_FIN=${PeriodDateEnd} 
     
    823712            while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] ; do 
    824713                # 
    825                 Length1=$( create_ts_begin_date ${DATE_LOOP} end) 
     714                Length1=$( IGCM_date_DaysInPreviousPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} end) 
    826715                DATE_TAB=$(  IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} $(( 1 - Length1 )) )_${DATE_LOOP} 
    827716 
    828                 Length2=$( create_ts_next_date ${DATE_LOOP} end) 
     717                Length2=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} ) 
    829718                DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length2} ) 
    830719 
     
    856745            # WE CAN CONCATENATE FILES AT THIS POINT 
    857746            [ "${FLAG_B}" = "TRUE" ] && DATE_BUILD_B=${DateBegin}_${DATE_FIN_JOB_B_LOOP_PREC} 
    858             Length=$( create_ts_begin_date ${DATE_COURANTE} end) 
     747            Length=$( IGCM_date_DaysInPreviousPeriod ${DATE_COURANTE} ${config_UserChoices_PeriodLength} end) 
    859748            DATE_BUILD1=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} -$(( Length - 1 )) ) 
    860749            DATE_BUILD=${DATE_BUILD1}_${DATE_FIN} 
  • branches/libIGCM_MPI_OpenMP/AA_monitoring

    r563 r571  
    9999#-Q- titane ###################### 
    100100#-Q- titane #MSUB -r MONITORING     # Nom du job                 
    101 #-Q- titane #MSUB -N 1              # Reservation du noeud 
     101#-Q- titane #MSUB -eo 
    102102#-Q- titane #MSUB -n 1              # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -E "-j o" 
    105 #-Q- titane #MSUB -E "-S /bin/ksh" 
    106 #-Q- titane ##MSUB -e nco.out        # Sortie standard 
    107 #-Q- titane ##MSUB -o nco.out        # Sortie standard 
     104#-Q- titane #MSUB -q mono 
    108105#-Q- lxiv8 ###################### 
    109106#-Q- lxiv8 ## OBELIX      LSCE ## 
     
    146143StandAlone=${StandAlone:=true} 
    147144 
    148 #D- Low level debug : to bypass lib test checks and stack construction 
     145#D- Path to libIGCM 
    149146#D- Default : value from AA_job if any 
     147# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     148# WARNING you must check MirrorlibIGCM variable in sys library. 
     149# WARNING If this variable is true, you must use libIGCM_POST path instead 
     150# WARNING of your running libIGCM directory. 
    150151libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    151 # WARNING for StandAlone used : To run this script on some machine, 
    152 # you must check MirrorlibIGCM variable in sys library. 
    153 # If this variable is true, you must use libIGCM_POST path instead 
    154 # of your running libIGCM directory. 
    155152 
    156153#D- Increased verbosity (1, 2, 3) 
     
    230227#================================== 
    231228#R_SAVE : Job output directory 
     229#R_BUFR : Job output buffered directory 
    232230if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
    233231    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
    234232    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     233    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    235234    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    236235else 
    237236    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     237    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    238238    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    239239fi 
  • branches/libIGCM_MPI_OpenMP/AA_move-and-rename

    r509 r571  
    3333######################################################################## 
    3434 
    35 # Chemin vers MODIPSL 
     35# Path to modipsl 
    3636MODIPSL=${MODIPSL:=::modipsl::} 
    3737 
    38 # Chemin vers libIGCM 
    39 libIGCM=${libIGCM:=${MODIPSL}/libIGCM} 
    40 # Attention : à changer si la machine de post-traitement n'est pas la frontale du serveur de calcul ! 
    41 #             voir précence de la variable MirrorlibIGCM dans votre couche systÚme. 
    42  
     38#D- Path to libIGCM 
     39#D- Default : value from AA_job if any 
     40# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     41# WARNING you must check MirrorlibIGCM variable in sys library. 
     42# WARNING If this variable is true, you must use libIGCM_POST path instead 
     43# WARNING of your running libIGCM directory. 
     44libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    4345 
    4446DEBUG_sys=false 
  • branches/libIGCM_MPI_OpenMP/AA_pack_debug

    r565 r571  
    145145#D- Flag to determine begin date for restart pack 
    146146#D- Default : value from AA_job if any 
    147 DateBegin=${DateBegin:=20000101) 
     147DateBegin=${DateBegin:=20000101} 
    148148 
    149149#D- Flag to determine end date for restart pack 
     
    347347 
    348348  # Add 1 day to date_end_pack to have the new date_begin_pack 
    349   date_begin_pack=$( $( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 ) 
     349  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 ) 
    350350 
    351351done 
  • branches/libIGCM_MPI_OpenMP/AA_pack_restart

    r565 r571  
    145145#D- Flag to determine begin date for restart pack 
    146146#D- Default : value from AA_job if any 
    147 DateBegin=${DateBegin:=20000101) 
     147DateBegin=${DateBegin:=20000101} 
    148148 
    149149#D- Flag to determine end date for restart pack 
     
    347347 
    348348  # Add 1 day to date_end_pack to have the new date_begin_pack 
    349   date_begin_pack=$( $( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 ) 
     349  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 ) 
    350350 
    351351done 
  • branches/libIGCM_MPI_OpenMP/AA_rebuild_fromArchive

    r563 r571  
    102102#-Q- titane #MSUB -n 1               # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400           # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -p gen2211 
    105104#-Q- titane #MSUB -q mono 
    106105#-Q- lxiv8 ###################### 
     
    144143StandAlone=${StandAlone:=true} 
    145144 
    146 #D- Low level debug : to bypass lib test checks and stack construction 
    147 #D- Default : value from AA_job if any 
     145#D- Path to libIGCM 
     146#D- Default : value from AA_job if any 
     147# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     148# WARNING you must check MirrorlibIGCM variable in sys library. 
     149# WARNING If this variable is true, you must use libIGCM_POST path instead 
     150# WARNING of your running libIGCM directory. 
    148151libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    149 # WARNING for StandAlone used : To run this script on some machine, 
    150 # you must check MirrorlibIGCM variable in sys library. 
    151 # If this variable is true, you must use libIGCM_POST path instead 
    152 # of your running libIGCM directory. 
    153152 
    154153#-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer. 
  • branches/libIGCM_MPI_OpenMP/AA_rebuild_fromWorkdir

    r563 r571  
    102102#-Q- titane #MSUB -n 1              # Reservation du processus 
    103103#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job 
    104 #-Q- titane #MSUB -p gen2211 
    105104#-Q- titane #MSUB -q mono 
    106105#-Q- lxiv8 ###################### 
     
    144143StandAlone=${StandAlone:=true} 
    145144 
    146 #D- Low level debug : to bypass lib test checks and stack construction 
    147 #D- Default : value from AA_job if any 
     145#D- Path to libIGCM 
     146#D- Default : value from AA_job if any 
     147# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     148# WARNING you must check MirrorlibIGCM variable in sys library. 
     149# WARNING If this variable is true, you must use libIGCM_POST path instead 
     150# WARNING of your running libIGCM directory. 
    148151libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    149 # WARNING for StandAlone used : To run this script on some machine, 
    150 # you must check MirrorlibIGCM variable in sys library. 
    151 # If this variable is true, you must use libIGCM_POST path instead 
    152 # of your running libIGCM directory. 
    153152 
    154153#-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer. 
  • branches/libIGCM_MPI_OpenMP/libIGCM_comp/libIGCM_comp.ksh

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

    r562 r571  
    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  IGCM_card_DefineArrayFromSection   ${SUBMIT_DIR}/config.card Executable 
     116  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Executable Name 
     117     
     118  #================================== 
     119  # Define Outputs Name 
     120  IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output" 
     121  eval Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} 
     122  IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}" 
     123  Exe_Output=out_execution 
     124  #================================== 
     125 
     126  #===================================================================# 
     127  # Prepare variables available for ${COMP}.card and ${COMP}.driver   # 
     128  #             But available to any son functions                    # 
     129  #===================================================================# 
     130 
     131  # Convert yyyy-mm-dd date to gregorian yyyymmdd 
     132  DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) 
     133  DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) 
     134 
     135  # Period Length In Days between DateBegin and DateEnd 
     136  (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 )) 
     137  if [ ${ExperienceLengthInDays} -lt 0 ] ; then 
     138    IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that." 
     139    IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates." 
     140    IGCM_debug_Verif_Exit  
     141  fi 
     142 
     143  # Day and Year of Initial State (Given in julian format) 
     144  InitDay=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 )) 
     145  InitYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 )) 
     146 
     147  #================================== 
     148  # Restarts : Gerneral rule or local for each component ? 
     149  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts 
     150 
     151  echo 
     152  IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts" 
     153 
     154  for option in ${config_Restarts[*]} ; do 
     155    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option} 
     156    eval auxprint=\${config_Restarts_${option}} 
     157    IGCM_debug_Print 3 "${option} : ${auxprint}" 
     158  done 
     159 
     160  #================================================================# 
     161  #                  Test and Prepare directories                  # 
     162  #================================================================# 
     163 
     164  # ==> 4 kinds of input files : 
     165  #     1) R_INIT  : Initial State Files   (Etat0, carteveg) 
     166  #     2) R_BC    : Boundary Conditions   (Forcages, lai) 
     167  #     3) Parameters files (allready define through ${SUBMIT_DIR}) 
     168  #     4) Restarts files   (allready define in IGCM_config_Initialize) 
     169 
     170  # Here we offer the possibility to redefine R_INIT, R_BC 
     171  # and PeriodNb through config.card 
     172  R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT} 
     173  IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and PeriodNb" 
     174  IGCM_debug_Print 3 "R_INIT=${R_INIT}" 
     175  R_BC=${config_UserChoices_R_BC:=${R_IN}/BC} 
     176  IGCM_debug_Print 3  "R_BC=${R_BC}" 
     177  PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}} 
     178  IGCM_debug_Print 3  "Loop in main Job with ${PeriodNb} period(s)" 
     179 
     180  # Test Archive input/output. 
     181  IGCM_sys_TestDirArchive ${ARCHIVE} 
     182  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 
     183  IGCM_sys_TestDirArchive ${R_IN} 
     184  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 
     185 
     186  #==================================================== 
     187  #R_SAVE : Job output directory 
     188  if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then 
     189    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) 
     190    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     191    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     192    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
     193  else 
     194    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     195    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     196    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     197  fi 
     198 
     199  if ( ${FirstInitialize} ) ; then  
     200    IGCM_sys_MkdirArchive ${R_SAVE} 
     201    IGCM_sys_Mkdir        ${R_BUFR} 
     202  else 
     203    IGCM_sys_TestDirArchive ${R_SAVE} 
     204    [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive ${R_SAVE}" 
     205 
     206    IGCM_sys_TestDir        ${R_BUFR} 
     207    [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir ${R_BUFR}" 
     208 
     209    #Test state of run in run.card 
     210    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
     211     
     212    if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
     213      echo  
     214      IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" 
     215      IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" 
     216      IGCM_debug_Exit 
     217      IGCM_debug_Verif_Exit 
     218    fi 
     219  fi 
     220 
     221  #================================== 
     222  # Read Post section:  
     223  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post 
     224 
     225  echo 
     226  IGCM_debug_Print 1 "DefineArrayFromOption : config_Post" 
     227 
     228  for option in ${config_Post[*]} ; do 
     229    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${option} 
     230    eval auxprint=\${config_Post_${option}} 
     231    IGCM_debug_Print 3 "${option} : ${auxprint}" 
     232  done 
     233 
     234  #================================== 
     235  # Define default value to keep compatibility with previous card: means before changes due to TGCC  
     236  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency} 
     237 
     238  #==================================================== 
     239  # Define REBUILD_DIR : where we store files needing rebuild process 
     240  if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then 
     241    REBUILD_DIR=${R_SAVE}/TMP 
     242    IGCM_sys_MkdirArchive ${REBUILD_DIR} 
     243  else 
     244    REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     245    IGCM_sys_MkdirWork ${REBUILD_DIR} 
     246  fi 
     247 
     248  #==================================================== 
     249  # Experience type : DEB(ug), DEV(elopment), RUN  
     250  if [ X${JobType} != XRUN ] ; then 
    20251    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 
     252    echo "====================================================" 
     253    echo "libIGCM JOB is NOT in RUN type mode." 
     254    echo "!! OUTPUT files will NOT be PROTECTED !!" 
     255    echo "Be carefull : you can ERASE the result of this job !" 
     256 
     257    case ${JobType} in 
     258    DEB) 
     259      echo "DEBUG mode : activation of 'set -vx' mode." 
     260      echo "DEBUG mode : no protection for output files." 
     261      echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency." 
     262      ;; 
     263    DEV) 
     264      echo "DEVelopment mode : no protection for output files." 
     265      echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency." 
     266      ;; 
     267    esac 
     268 
     269    if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then 
     270      if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then 
     271        echo "------------" 
     272        echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency" 
     273        echo "          to PeriodLength : ${config_UserChoices_PeriodLength}" 
     274        echo "------------" 
     275        config_Post_RebuildFrequency=${config_UserChoices_PeriodLength} 
     276      fi 
     277    fi 
     278    echo "====================================================" 
    68279    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  
    93     echo 
    94     IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" 
    95     IGCM_debug_Print 3 ${config_ListOfComponents[*]} 
    96  
    97     NbComponents=${#config_ListOfComponents[*]} 
    98  
    99     #================================== 
    100     # Define principal executable 
    101  
    102     IGCM_card_DefineArrayFromSection   ${SUBMIT_DIR}/config.card Executable 
    103     IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Executable Name 
    104      
    105     #================================== 
    106     # Define Outputs Name 
    107     IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output" 
    108     eval Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} 
    109     IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}" 
    110 #MM : obsolete ! 
    111 #    eval Exe_Output=out_${config_Executable_Name} 
    112     eval Exe_Output=out_execution 
    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_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} 
    183     else 
    184         R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    185         R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    186     fi 
    187  
    188     if ( ${FirstInitialize} ) ; then  
    189         IGCM_sys_MkdirArchive ${R_SAVE} 
    190     else 
    191         IGCM_sys_TestDirArchive ${R_SAVE} 
    192         [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 
    193         #Test state of run in run.card 
    194         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
    195          
    196         if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
    197             echo  
    198             IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" 
    199             IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" 
    200             IGCM_debug_Exit 
    201             IGCM_debug_Verif_Exit 
    202         fi 
    203     fi 
    204  
    205     #================================== 
    206     # Post :  
    207     IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post 
    208  
    209     echo 
    210     IGCM_debug_Print 1 "DefineArrayFromOption : config_Post" 
    211  
    212     for option in ${config_Post[*]} ; do 
    213         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${option} 
    214         eval auxprint=\${config_Post_${option}} 
    215         IGCM_debug_Print 3 "${option} : ${auxprint}" 
    216     done 
    217  
    218     #==================================================== 
    219     # Define REBUILD_DIR : where we store files needing rebuild process 
    220     if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then 
    221         REBUILD_DIR=${R_SAVE}/TMP 
    222         IGCM_sys_MkdirArchive ${REBUILD_DIR} 
    223     else 
    224         REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    225         IGCM_sys_MkdirWork ${REBUILD_DIR} 
    226     fi 
    227  
    228     #==================================================== 
    229     # Experience type : DEB(ug), DEV(elopment), RUN  
    230     if [ X${JobType} != XRUN ] ; then 
    231         echo 
    232         echo "====================================================" 
    233         echo "libIGCM JOB is NOT in RUN type mode." 
    234         echo "!! OUTPUT files will NOT be PROTECTED !!" 
    235         echo "Be carefull : you can ERASE the result of this job !" 
    236  
    237         case ${JobType} in 
    238             DEB) 
    239                 echo "DEBUG mode : activation of 'set -vx' mode." 
    240                 echo "DEBUG mode : no protection for output files." 
    241                 echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency." 
    242                 ;; 
    243             DEV) 
    244                 echo "DEVelopment mode : no protection for output files." 
    245                 echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency." 
    246                 ;; 
    247         esac 
    248  
    249         if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then 
    250             if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then 
    251                 echo "------------" 
    252                 echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency" 
    253                 echo "          to PeriodLength : ${config_UserChoices_PeriodLength}" 
    254                 echo "------------" 
    255                 config_Post_RebuildFrequency=${config_UserChoices_PeriodLength} 
    256             fi 
    257         fi 
    258         echo "====================================================" 
    259         echo 
    260     fi 
    261  
    262     #==================================================== 
    263     #R_OUT_KSH : Storage place for job output 
    264     #R_OUT_EXE : Storage place for binary used during simulation 
    265     R_OUT_KSH=${R_SAVE}/Out 
    266     R_OUT_EXE=${R_SAVE}/Exe 
    267  
    268     IGCM_debug_PopStack "IGCM_config_Initialize" 
     280  fi 
     281 
     282  #==================================================== 
     283  #R_OUT_KSH : Storage place for job output 
     284  #R_OUT_EXE : Storage place for binary used during simulation 
     285  R_OUT_KSH=${R_SAVE}/Out 
     286  R_OUT_EXE=${R_SAVE}/Exe 
     287 
     288  #==================================================== 
     289  #R_BUF_KSH : Buffer place for job output 
     290  #R_BUF_EXE : Buffer place for binary used during simulation 
     291  R_BUF_KSH=${R_BUFR}/Out 
     292  R_BUF_EXE=${R_BUFR}/Exe 
     293 
     294  IGCM_debug_PopStack "IGCM_config_Initialize" 
    269295} 
    270296 
     
    272298function IGCM_config_Analyse_PeriodLength 
    273299{ 
    274     IGCM_debug_PushStack "IGCM_config_Analyse_PeriodLength" 
    275  
    276     typeset i 
    277  
    278     # Determine number of day(s) in PeriodLength : 
    279     case ${config_UserChoices_PeriodLength} in 
    280         *Y|*y) 
    281             PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' )  
    282             IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}" 
    283             PeriodLengthInDays=0 
    284             i=0 
    285             until [ $i -ge $PeriodLengthInYears ] ; do  
    286                 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
    287                 (( i=i+1 ))  
    288             done  
    289             ;; 
    290         *M|*m) 
    291             PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' )  
    292             IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}" 
    293             PeriodLengthInDays=0 
    294             i=0 
    295             until [ $i -ge $PeriodLengthInMonths ] ; do  
    296                 if [ $(( month + i )) -lt 13 ] ; then  
    297                     (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) ))   
    298                 else  
    299                     (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) ))   
    300                 fi  
    301                 (( i=i+1 ))  
    302             done  
    303             ;; 
    304         *D|*d)   
    305             PeriodLengthInMonths=0 
    306             PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' );; 
    307         *)  
    308             IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." 
    309             IGCM_debug_Verif_Exit ;; 
    310     esac 
    311  
    312     IGCM_debug_PopStack "IGCM_config_Analyse_PeriodLength" 
     300  IGCM_debug_PushStack "IGCM_config_Analyse_PeriodLength" 
     301 
     302  typeset i 
     303 
     304  # Determine number of day(s) in PeriodLength : 
     305  case ${config_UserChoices_PeriodLength} in 
     306  *Y|*y) 
     307    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' )  
     308    IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}" 
     309    PeriodLengthInDays=0 
     310    i=0 
     311    until [ $i -ge $PeriodLengthInYears ] ; do  
     312      (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
     313      (( i=i+1 ))  
     314    done  
     315    ;; 
     316  *M|*m) 
     317    PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' )  
     318    IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}" 
     319    PeriodLengthInDays=0 
     320    i=0 
     321    until [ $i -ge $PeriodLengthInMonths ] ; do  
     322      if [ $(( month + i )) -lt 13 ] ; then  
     323        (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) ))   
     324      else  
     325        (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) ))   
     326      fi  
     327      (( i=i+1 ))  
     328    done  
     329    ;; 
     330  *D|*d)   
     331    PeriodLengthInMonths=0 
     332    PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' );; 
     333  *)  
     334    IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." 
     335    IGCM_debug_Verif_Exit ;; 
     336  esac 
     337 
     338  IGCM_debug_PopStack "IGCM_config_Analyse_PeriodLength" 
    313339} 
    314340 
     
    316342function IGCM_config_Check 
    317343{ 
    318     IGCM_debug_PushStack "IGCM_config_Check" 
    319  
    320     # If one of the following modulo is not zero : 
    321     # we will issue an error then explain and exit in 
    322     # AA_job IGCM_debug_Verif_Exit call before binary submission 
    323  
     344  IGCM_debug_PushStack "IGCM_config_Check" 
     345 
     346  # If one of the following modulo is not zero : 
     347  # we will issue an error then explain and exit in 
     348  # AA_job IGCM_debug_Verif_Exit call before binary submission 
     349 
     350  echo 
     351  IGCM_debug_Print 1 "IGCM_config_Check" 
     352  echo 
     353 
     354  typeset i 
     355 
     356  # Check RebuildFrequency against key frequencies : PeriodLength ; PackFrequency ; TimeSeriesFrequency ; SeasonalFrequency 
     357  if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
     358    AsynchronousRebuild=true 
     359    IGCM_debug_Print 1 "Asynchronous rebuild has been activated." 
    324360    echo 
    325     IGCM_debug_Print 1 "IGCM_config_Check" 
     361    # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero 
     362    IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength" 
     363    IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength 
     364    IGCM_debug_Print 1 "Check coherence between PackFrequency and RebuildFrequency" 
     365    IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_Post_RebuildFrequency 
     366    IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency" 
     367    IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency 
     368    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency" 
     369    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency 
     370  else 
     371    AsynchronousRebuild=false 
     372    IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" 
     373    IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" 
    326374    echo 
    327  
    328     typeset i 
    329  
    330     if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then 
    331         AsynchronousRebuild=true 
    332         IGCM_debug_Print 1 "Asynchronous rebuild has been activated." 
    333         echo 
    334         # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero 
    335         IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength" 
    336         IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength 
    337         IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency" 
    338         IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency 
    339         IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency" 
    340         IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency 
    341     else 
    342         AsynchronousRebuild=false 
    343         IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" 
    344         IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" 
    345         echo 
    346         #modulo (TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero 
    347         IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength" 
    348         IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength 
    349         IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength" 
    350         IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency   config_UserChoices_PeriodLength 
    351     fi 
    352  
    353     #modulo (TimeSeriesFrequency and all Chunck2D) must be zero 
    354     NbJob=${#CHUNCK2D_SIZE[@]} 
    355     i=0 
    356     until [ $i -ge $NbJob ]; do 
    357         value=${CHUNCK2D_SIZE[${i}]} 
    358         IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency" 
    359         IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency 
    360         case ${value} in   
    361             *Y|*y) ;;  
    362             *)  IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card" 
    363                 IGCM_debug_Exit "This will stop the job" ;; 
    364         esac 
    365         (( i=i+1 )) 
    366     done 
    367  
    368     #modulo (TimeSeriesFrequency and all Chunck3D) must be zero 
    369     NbJob=${#CHUNCK3D_SIZE[@]} 
    370     i=0 
    371     until [ $i -ge $NbJob ]; do 
    372         value=${CHUNCK3D_SIZE[${i}]} 
    373         IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency" 
    374         IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency 
    375         case ${value} in   
    376             *Y|*y) ;;  
    377             *)  IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card" 
    378                 IGCM_debug_Exit "This will stop the job" ;; 
    379         esac 
    380         (( i=i+1 )) 
    381     done 
    382  
    383     IGCM_debug_PopStack "IGCM_config_Check" 
     375    #modulo (PeriodLength and TimeSeriesFrequency/SeasonalFrequency) must be zero 
     376    IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength" 
     377    IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength 
     378    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength" 
     379    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency   config_UserChoices_PeriodLength 
     380  fi 
     381 
     382  # Check PackFrequency against other key frequencies  
     383  # Modulo (PackFrequency and TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero 
     384  if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then 
     385    Pack=true 
     386    # 
     387    IGCM_debug_Print 1 "Check coherence between PackFrequency and PeriodLength" 
     388    IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_UserChoices_PeriodLength 
     389    IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PackFrequency" 
     390    IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_PackFrequency 
     391    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PackFrequency" 
     392    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_PackFrequency 
     393  else 
     394    Pack=false 
     395  fi 
     396 
     397  #modulo (TimeSeriesFrequency and all Chunck2D) must be zero 
     398  NbJob=${#CHUNCK2D_SIZE[@]} 
     399  i=0 
     400  until [ $i -ge $NbJob ]; do 
     401    value=${CHUNCK2D_SIZE[${i}]} 
     402    IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency" 
     403    IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency 
     404    case ${value} in   
     405    *Y|*y) ;;  
     406    *)  IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card" 
     407      IGCM_debug_Exit "This will stop the job" ;; 
     408    esac 
     409    (( i=i+1 )) 
     410  done 
     411 
     412  #modulo (TimeSeriesFrequency and all Chunck3D) must be zero 
     413  NbJob=${#CHUNCK3D_SIZE[@]} 
     414  i=0 
     415  until [ $i -ge $NbJob ]; do 
     416    value=${CHUNCK3D_SIZE[${i}]} 
     417    IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency" 
     418    IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency 
     419    case ${value} in   
     420    *Y|*y) ;;  
     421    *)  IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card" 
     422      IGCM_debug_Exit "This will stop the job" ;; 
     423    esac 
     424    (( i=i+1 )) 
     425  done 
     426 
     427  IGCM_debug_PopStack "IGCM_config_Check" 
    384428} 
    385429 
     
    387431function IGCM_config_PeriodStart 
    388432{ 
    389     IGCM_debug_PushStack "IGCM_config_PeriodStart" 
    390  
    391     echo 
    392     IGCM_debug_Print 1 "IGCM_config_PeriodStart" 
    393     echo 
    394  
    395     if ( ${FirstInitialize} ) ; then 
    396         #================================================# 
    397         #         Initialize date/period information     # 
    398         #================================================# 
    399  
    400         IGCM_date_GetYearMonth $DateBegin year month 
    401         year_m1=$(( year - 1 )) 
    402         year_p1=$(( year + 1 ))  
    403         IGCM_config_Analyse_PeriodLength 
    404  
    405         eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1 
    406         PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) ) 
    407         eval CumulPeriod=1 > /dev/null 2>&1 
    408  
    409         #=================================================# 
    410         #              Write updated run.card             # 
    411         #=================================================# 
    412  
    413         #Correct run.card Configuration for this period 
    414         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} 
    415         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} 
    416         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} 
    417         if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then 
    418             IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR} 
    419         fi 
    420  
    421         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" 
    422   
     433  IGCM_debug_PushStack "IGCM_config_PeriodStart" 
     434 
     435  echo 
     436  IGCM_debug_Print 1 "IGCM_config_PeriodStart" 
     437  echo 
     438 
     439  if ( ${FirstInitialize} ) ; then 
     440    #================================================# 
     441    #         Initialize date/period information     # 
     442    #================================================# 
     443 
     444    IGCM_date_GetYearMonthDay $DateBegin year month day 
     445    IGCM_config_Analyse_PeriodLength 
     446 
     447    eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1 
     448    PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) ) 
     449    eval CumulPeriod=1 > /dev/null 2>&1 
     450 
     451    #=================================================# 
     452    #              Write updated run.card             # 
     453    #=================================================# 
     454 
     455    #Correct run.card Configuration for this period 
     456    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} 
     457    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} 
     458    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} 
     459    if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then 
     460      IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR} 
     461    fi 
     462 
     463    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" 
     464     
     465  else 
     466    #================================================# 
     467    #         The file run.card allready exist       # 
     468    #================================================# 
     469 
     470    #Test state of run in run.card 
     471    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
     472    if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
     473      echo  
     474      IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" 
     475      IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" 
     476      echo 
     477      IGCM_debug_Exit 
     478      IGCM_debug_Verif_Exit 
     479    fi 
     480 
     481    #===================================# 
     482    #        Read updated run.card      # 
     483    #===================================# 
     484 
     485    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix 
     486    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin 
     487    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd 
     488    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod 
     489 
     490    PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) 
     491    PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) 
     492    eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1 
     493 
     494    LastPeriodDateEnd=$( echo ${run_Configuration_OldPrefix} | sed -e "s/${config_UserChoices_JobName}_//" ) 
     495 
     496    typeset LastDate 
     497    set +A LastDate -- $( echo ${LastPeriodDateEnd} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \2 \3/" ) 
     498    LastYearDateEnd=${LastDate[0]} 
     499    LastMonthDateEnd=${LastDate[1]} 
     500    LastDayDateEnd=${LastDate[2]} 
     501 
     502    if [ ${Period} = 1 ]; then 
     503      # save last Job output 
     504      typeset LastPeriod iLastPeriod Last_Script_Output_Name 
     505      (( LastPeriod=CumulPeriod-PeriodNb )) 
     506      iLastPeriod=$( printf "%06d" ${LastPeriod} ) 
     507      Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${iLastPeriod}" 
     508      Last_run_card="run.card.${iLastPeriod}" 
     509      #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name} 
     510      #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1 
     511      IGCM_debug_Print 2 "Try to save previous ksh job output" 
     512      IGCM_sys_Cd ${SUBMIT_DIR}/ 
     513      IGCM_sys_PutBuffer_Out ${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name}.$$ rw 
     514 
     515      IGCM_card_CheckConflict run.card 
     516      IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/${Last_run_card}.$$ rw 
     517 
     518      IGCM_sys_Cd ${RUN_DIR} 
    423519    else 
    424         #================================================# 
    425         #         The file run.card allready exist       # 
    426         #================================================# 
    427  
    428         #Test state of run in run.card 
    429         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
    430         if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
    431             echo  
    432             IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" 
    433             IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" 
    434             echo 
    435             IGCM_debug_Exit 
    436             IGCM_debug_Verif_Exit 
    437         fi 
    438  
    439         #===================================# 
    440         #        Read updated run.card      # 
    441         #===================================# 
    442  
    443         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix 
    444         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin 
    445         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd 
    446         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod 
    447  
    448         PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) 
    449         PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) 
    450         eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1 
    451  
    452         LastPeriodDateEnd=$( echo ${run_Configuration_OldPrefix} | sed -e "s/${config_UserChoices_JobName}_//" ) 
    453  
    454         typeset LastDate 
    455         set +A LastDate -- $( echo ${LastPeriodDateEnd} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \2 \3/" ) 
    456         LastYearDateEnd=${LastDate[0]} 
    457         LastMonthDateEnd=${LastDate[1]} 
    458         LastDayDateEnd=${LastDate[2]} 
    459  
    460         if [ ${Period} = 1 ]; then 
    461            # save last Job output 
    462             typeset LastPeriod iLastPeriod Last_Script_Output_Name 
    463             (( LastPeriod=CumulPeriod-PeriodNb )) 
    464             iLastPeriod=$( printf "%06d" ${LastPeriod} ) 
    465             Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${iLastPeriod}" 
    466             Last_run_card="run.card.${iLastPeriod}" 
    467             #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name} 
    468             #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1 
    469             IGCM_debug_Print 2 "Try to save previous ksh job output" 
    470             IGCM_sys_Cd ${SUBMIT_DIR}/ 
    471             IGCM_sys_Put_Out ${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name}.$$ rw 
    472  
    473             IGCM_card_CheckConflict run.card 
    474             IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/${Last_run_card}.$$ rw 
    475  
    476             IGCM_sys_Cd ${RUN_DIR} 
    477         else 
    478             unset FileToBeDeleted 
    479         fi 
    480  
    481         IGCM_date_GetYearMonth $PeriodDateBegin year month 
    482         year_m1=$(( year - 1 )) 
    483         year_p1=$(( year + 1 ))  
    484         IGCM_config_Analyse_PeriodLength 
    485  
    486         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" 
    487  
    488     fi     
    489     OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd} 
    490    
    491     #===================================================================# 
    492     # Prepare variables available for ${COMP}.card and ${COMP}.driver   # 
    493     #             But available to any son functions                    # 
    494     #===================================================================# 
    495  
    496     # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !) 
    497     (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 )) 
    498  
    499     # Debug Print : 
    500     IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution" 
    501     IGCM_debug_Print 1 "Year of simulation      : ${year}" 
    502     IGCM_debug_Print 1 "Month of simulation     : ${month}" 
    503     IGCM_debug_Print 1 "PeriodLengthInDays      : ${PeriodLengthInDays}" 
    504     IGCM_debug_Print 1 "PeriodDateBegin         : ${PeriodDateBegin}" 
    505     IGCM_debug_Print 1 "PeriodDateEnd           : ${PeriodDateEnd}" 
    506     IGCM_debug_Print 1 "SimulationLengthInDays  : ${SimulationLengthInDays}" 
    507     IGCM_debug_Print 1 "ExperienceLengthInDays  : ${ExperienceLengthInDays}" 
    508  
    509     #================================================================# 
    510     #         Prepare variables available for comp_finalyze          # 
    511     #================================================================# 
    512  
    513     # Period for save files 
    514     eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1 
    515  
    516     # Prefix for save files of this period 
    517     eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod}  > /dev/null 2>&1 
    518  
    519     # List of files that will be deleted in RUN_DIR after run 
    520     [ -f stack ] && FileToBeDeleted[0]="stack" 
    521  
    522     # Test if the same run as already been saved : 
    523     if [ X${JobType} = XRUN ] ; then 
    524         if [ ${DRYRUN} -le 0 ] ; then 
    525             if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then 
    526                 IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job." 
    527                 IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files" 
    528                 IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or " 
    529                 IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory." 
    530                 IGCM_debug_Print 1 " This exit has been initiated because at least ${R_OUT_KSH}/${PREFIX}_${Exe_Output} exists." 
    531                 IGCM_debug_Verif_Exit 
    532             fi 
    533         fi 
     520      unset FileToBeDeleted 
     521    fi 
     522 
     523    IGCM_date_GetYearMonthDay $PeriodDateBegin year month day 
     524    IGCM_config_Analyse_PeriodLength 
     525 
     526    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" 
     527 
     528  fi     
     529  OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd} 
     530 
     531  # BEGIN: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh 
     532  # Compute year_m1 and year_p1 (year minus 1Y and year plus 1Y) 
     533  year_m1=$(( year - 1 )) 
     534  year_p1=$(( year + 1 ))        
     535  # Compute month_m1 (month minus 1M) 
     536  # Compute yyyymm_m1 (yyyymm minus 1M) 
     537  month_m1=$(( month - 1 )) 
     538  if [ ${month_m1} = 0 ]; then 
     539    month_m1=12 
     540    yyyymm_m1=${year_m1}12 
     541  elif [ ${month_m1} -le 9 ]; then 
     542    month_m1=0${month_m1} 
     543    yyyymm_m1=${year}${month_m1} 
     544  else 
     545    yyyymm_m1=${year}${month_m1} 
     546  fi 
     547  # Compute month_p1 (month plus 1M) 
     548  # Compute yyyymm_p1 (yyyymm plus 1M) 
     549  month_p1=$(( month + 1 )) 
     550  if [ ${month_p1} = 13 ]; then 
     551    month_p1=01 
     552    yyyymm_p1=${year_p1}01 
     553  elif [ ${month_p1} -le 9 ]; then 
     554    month_p1=0${month_p1} 
     555    yyyymm_p1=${year}${month_p1} 
     556  else 
     557    yyyymm_p1=${year}${month_p1} 
     558  fi 
     559  #IGCM_debug_Print 1 "jg 1 month_m1 = ${month_m1} month_p1 = ${month_p1} " 
     560  #IGCM_debug_Print 1 "jg 1 calculate yyyymm_m1 = ${yyyymm_m1} " 
     561  #IGCM_debug_Print 1 "jg 1 calculate yyyymm_p1 = ${yyyymm_p1} " 
     562 
     563  # END: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh 
     564 
     565  #===================================================================# 
     566  # Prepare variables available for ${COMP}.card and ${COMP}.driver   # 
     567  #             But available to any son functions                    # 
     568  #===================================================================# 
     569 
     570  # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !) 
     571  (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 )) 
     572 
     573  # Debug Print : 
     574  IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution" 
     575  IGCM_debug_Print 1 "Year of simulation      : ${year}" 
     576  IGCM_debug_Print 1 "Month of simulation     : ${month}" 
     577  IGCM_debug_Print 1 "PeriodLengthInDays      : ${PeriodLengthInDays}" 
     578  IGCM_debug_Print 1 "PeriodDateBegin         : ${PeriodDateBegin}" 
     579  IGCM_debug_Print 1 "PeriodDateEnd           : ${PeriodDateEnd}" 
     580  IGCM_debug_Print 1 "SimulationLengthInDays  : ${SimulationLengthInDays}" 
     581  IGCM_debug_Print 1 "ExperienceLengthInDays  : ${ExperienceLengthInDays}" 
     582 
     583  #================================================================# 
     584  #         Prepare variables available for comp_finalyze          # 
     585  #================================================================# 
     586 
     587  # Period for save files 
     588  eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1 
     589 
     590  # Prefix for save files of this period 
     591  eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod}  > /dev/null 2>&1 
     592 
     593  # List of files that will be deleted in RUN_DIR after run 
     594  [ -f stack ] && FileToBeDeleted[0]="stack" 
     595 
     596  # Test if the same run as already been saved : 
     597  if [ X${JobType} = XRUN ] ; then 
     598    if [ ${DRYRUN} -le 0 ] ; then 
     599      if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then 
     600        IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job." 
     601        IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files" 
     602        IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or " 
     603        IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory." 
     604        IGCM_debug_Print 1 " This exit has been initiated because at least ${R_BUF_KSH}/${PREFIX}_${Exe_Output} exists." 
     605        IGCM_debug_Verif_Exit 
     606      fi 
     607    fi 
     608  else 
     609    if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then 
     610      IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode." 
     611    fi 
     612  fi 
     613 
     614  typeset ExeNameIn ExeNameFirst CompNameFirst 
     615  typeset comp i 
     616  typeset tempvar tempvarMPI tempvarNOD NbElts j NbExec 
     617 
     618  (( PROCESSUS_NUMBER = 0 )) 
     619  (( i=0 )) 
     620  (( NbExec=0 )) 
     621 
     622  OK_PARA_MPI=false 
     623  OK_PARA_OMP=false 
     624  OK_PARA_NOD=false 
     625  OK_PARA_MPMD=false 
     626 
     627  for comp in ${config_ListOfComponents[*]} ; do 
     628 
     629    IGCM_debug_Print 1 ${comp} 
     630 
     631    eval ExeNameIn=\${config_Executable_${comp}[0]} 
     632 
     633    # NO order in config.card for parallelized values !  
     634    # just use suffix : MPI , OMP and NOD (for number of NODes.) 
     635 
     636    # NOD is the number of NODes allocated 
     637    eval ${comp}_PROC_NOD=0 
     638 
     639    # MPI is the number of MPI processus per nodes 
     640    eval ${comp}_PROC_MPI=0 
     641 
     642    # OMP is the number of OpenMP threads per MPI processus 
     643    eval ${comp}_PROC_OMP=0 
     644         
     645    # Only if we really have an executable for the component : 
     646    if [ X${ExeNameIn} != X\"\" ] ; then 
     647 
     648      # Keep the first executable found and the first CompName 
     649      ExeNameFirst=${ExeNameIn} 
     650      CompNameFirst=${comp} 
     651 
     652      # Are we a second executable? 
     653      (( NbExec = NbExec + 1 )) 
     654 
     655      # set 1 MPI task, 1 OpenMP thread and 1 node as default 
     656      eval ${comp}_PROC_MPI=1 
     657      eval ${comp}_PROC_OMP=1 
     658      eval ${comp}_PROC_NOD=1 
     659 
     660      eval NbElts=\${#config_Executable_${comp}[@]} 
     661 
     662      if [ ${NbElts} -ge 2 ] ; then 
     663        (( j = 2 )) 
     664 
     665        while [ $j -lt ${NbElts} ] ; do  
     666          eval tempvar=\${config_Executable_${comp}[${j}]} 
     667 
     668          if [ X${tempvar} == X ] ; then 
     669            echo "Error reading MPI/OMP parameters !!!"  
     670            echo "Check your config.card."  
     671            exit 1 
     672          fi 
     673 
     674          eval IGCM_debug_Print 2 ${tempvar} 
     675 
     676          case ${tempvar} in 
     677            *[mM][pP][iI]*) 
     678               # Read MPI parameter for composante 
     679               eval ${comp}_PROC_MPI=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/MPI//" ) 
     680               OK_PARA_MPI=true;; 
     681            *[oO][mM][pP]*) 
     682               # Read OMP parameter for composante 
     683               eval ${comp}_PROC_OMP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/OMP//" ) 
     684               OK_PARA_OMP=true;; 
     685            *[nN][oO][dD]*) 
     686               # Read NOD (NumBer of Nodes) parameter for composante 
     687               eval ${comp}_PROC_NOD=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/NOD//" ) 
     688               OK_PARA_NOD=true 
     689               OK_PARA_MPI=true;; 
     690          esac 
     691 
     692          (( j = j + 1 )) 
     693        done 
     694 
     695      fi 
     696 
     697      eval tempvarMPI=\${${comp}_PROC_MPI} 
     698      eval tempvarNOD=\${${comp}_PROC_NOD} 
     699      eval tempvarOMP=\${${comp}_PROC_OMP} 
     700 
     701      (( PROCESSUS_NUMBER = PROCESSUS_NUMBER + tempvarMPI * tempvarNOD * tempvarOMP )) 
     702 
     703    fi 
     704 
     705    (( i=i+1 )) 
     706  done 
     707 
     708  # set MPMD mode if more than 2 executable names. 
     709  [ ${NbExec} -ge 2 ] && OK_PARA_MPMD=true 
     710 
     711  # Verification of BATCH_NUM_PROC_TOT total number of processors set in job header. 
     712  if [ X${BATCH_NUM_PROC_TOT} != X ] ; then 
     713    # BATCH_NUM_PROC_TOT is set 
     714    if ( ${OK_PARA_MPI} ) ; then 
     715      IGCM_debug_Print 1 "MPI/OMP/NOD found into config.card and BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} " 
    534716    else 
    535         if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then 
    536             IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode." 
    537         fi 
    538     fi 
    539  
    540     typeset ExeNameIn ExeNameFirst CompNameFirst 
    541     typeset comp i 
    542     typeset tempvar tempvarMPI tempvarNOD NbElts j NbExec 
    543  
    544     (( PROCESSUS_NUMBER = 0 )) 
    545     (( i=0 )) 
    546     (( NbExec=0 )) 
    547  
    548     OK_PARA_MPI=false 
    549     OK_PARA_OMP=false 
    550     OK_PARA_NOD=false 
    551     OK_PARA_MPMD=false 
    552  
    553     for comp in ${config_ListOfComponents[*]} ; do 
    554  
    555         IGCM_debug_Print 1 ${comp} 
    556  
    557         eval ExeNameIn=\${config_Executable_${comp}[0]} 
    558  
    559         # NO order in config.card for parallelized values !  
    560         # just use suffix : MPI , OMP and NOD (for number of NODes.) 
    561  
    562         # NOD is the number of NODes allocated 
    563         eval ${comp}_PROC_NOD=0 
    564  
    565         # MPI is the number of MPI processus per nodes 
    566         eval ${comp}_PROC_MPI=0 
    567  
    568         # OMP is the number of OpenMP threads per MPI processus 
    569         eval ${comp}_PROC_OMP=0 
    570          
    571         # Only if we really have an executable for the component : 
    572         if [ X${ExeNameIn} != X\"\" ] ; then 
    573  
    574             # Keep the first executable found and the first CompName 
    575             ExeNameFirst=${ExeNameIn} 
    576             CompNameFirst=${comp} 
    577  
    578             # Are we a second executable? 
    579             (( NbExec = NbExec + 1 )) 
    580  
    581             # set 1 MPI task, 1 OpenMP thread and 1 node as default 
    582             eval ${comp}_PROC_MPI=1 
    583             eval ${comp}_PROC_OMP=1 
    584             eval ${comp}_PROC_NOD=1 
    585  
    586             eval NbElts=\${#config_Executable_${comp}[@]} 
    587  
    588             if [ ${NbElts} -ge 2 ] ; then 
    589                 (( j = 2 )) 
    590  
    591                 while [ $j -lt ${NbElts} ] ; do  
    592                     eval tempvar=\${config_Executable_${comp}[${j}]} 
    593  
    594                     echo  
    595 #MM BUG impossible ?! 
    596                     if [ X${tempvar} == X ] ; then 
    597                         echo "Error reading MPI/OMP parameters !!!"  
    598                         echo "Check your config.card."  
    599                     # MM : A  enlever : 
    600                         exit 1 
    601                         #break 
    602                     fi 
    603  
    604                     eval IGCM_debug_Print 2 ${tempvar} 
    605  
    606                     case ${tempvar} in 
    607                         *[mM][pP][iI]*) 
    608                             # Read MPI parameter for composante 
    609                             eval ${comp}_PROC_MPI=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/MPI//" ) 
    610                             OK_PARA_MPI=true;; 
    611                         *[oO][mM][pP]*) 
    612                             # Read OMP parameter for composante 
    613                             eval ${comp}_PROC_OMP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/OMP//" ) 
    614                             OK_PARA_OMP=true;; 
    615                         *[nN][oO][dD]*) 
    616                             # Read NOD (NumBer of Nodes) parameter for composante 
    617                             eval ${comp}_PROC_NOD=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/NOD//" ) 
    618                             OK_PARA_NOD=true 
    619                             OK_PARA_MPI=true;; 
    620                     esac 
    621  
    622                     (( j = j + 1 )) 
    623                 done 
    624  
    625             fi 
    626  
    627             eval tempvarMPI=\${${comp}_PROC_MPI} 
    628             eval tempvarNOD=\${${comp}_PROC_NOD} 
    629             eval tempvarOMP=\${${comp}_PROC_OMP} 
    630  
    631             (( PROCESSUS_NUMBER = PROCESSUS_NUMBER + tempvarMPI * tempvarNOD * tempvarOMP )) 
    632  
    633         fi 
    634  
    635         (( i=i+1 )) 
    636     done 
    637  
    638     # set MPMD mode if more than 2 executable names. 
    639     [ ${NbExec} -ge 2 ] && OK_PARA_MPMD=true 
    640  
    641     # Verification of BATCH_NUM_PROC_TOT total number of processors set in job header. 
    642     if [ X${BATCH_NUM_PROC_TOT} != X ] ; then 
    643         # BATCH_NUM_PROC_TOT is set 
    644         if ( ${OK_PARA_MPI} ) ; then 
    645             IGCM_debug_Print 1 "MPI/OMP/NOD fund into config.card and BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} " 
    646         else 
    647             # with previous method. 
    648             if [ ${BATCH_NUM_PROC_TOT} -gt 1 ] ; then 
    649                 # with more than 1 proc 
    650                 if ( ${OK_PARA_MPMD} ) ; then 
    651                      # with MPMD ie CPL/oasis method 
    652                      echo "We will use default number of MPI tasks for this machine : " 
    653                      echo "${DEFAULT_NUM_PROC_OCE} for OCE; " 
    654                      echo "${DEFAULT_NUM_PROC_CPL} for CPL; " 
    655                      echo "${DEFAULT_NUM_PROC_ATM} for ATM; " 
    656                      echo "${DEFAULT_NUM_PROC_TOTAL} for the total number of processors; " 
    657                      OK_PARA_MPI=true 
    658                      CPL_PROC_MPI=${DEFAULT_NUM_PROC_CPL} 
    659                      OCE_PROC_MPI=${DEFAULT_NUM_PROC_OCE} 
    660                      ATM_PROC_MPI=${DEFAULT_NUM_PROC_ATM} 
    661                      NUM_PROC_CPL=${DEFAULT_NUM_PROC_CPL} # for backward compatibility 
    662                      NUM_PROC_OCE=${DEFAULT_NUM_PROC_OCE} # for backward compatibility 
    663                      NUM_PROC_ATM=${DEFAULT_NUM_PROC_ATM} # for backward compatibility 
    664                      PROCESSUS_NUMBER=${DEFAULT_NUM_PROC_TOTAL} 
    665                 else 
    666                      # with have only one executable 
    667                      echo "We will use ${BATCH_NUM_PROC_TOT} MPI tasks for ${CompNameFirst} : ${config_Executable_Name} " 
    668                      OK_PARA_MPI=true 
    669                      eval ${CompNameFirst}_PROC_MPI=${BATCH_NUM_PROC_TOT} 
    670                      PROCESSUS_NUMBER=${BATCH_NUM_PROC_TOT} 
    671                 fi 
    672             else  
    673                 PROCESSUS_NUMBER=1 
    674             fi 
    675         fi 
    676         # Verification with PBS parameter 
    677         if [ ${BATCH_NUM_PROC_TOT} -ne ${PROCESSUS_NUMBER} ] ; then 
    678             echo "Warning with parallelization parameters !" 
    679             echo "Job header variable BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} " 
    680             echo "is the total number of _processors_ reserved." 
    681             echo "It is not equal to the sum of _processus_  = ${PROCESSUS_NUMBER}." 
    682             echo "We stop now." 
    683             exit 1 
     717      # with previous method. 
     718      if [ ${BATCH_NUM_PROC_TOT} -gt 1 ] ; then 
     719        # with more than 1 proc 
     720        if ( ${OK_PARA_MPMD} ) ; then 
     721          # with MPMD ie CPL/oasis method 
     722          echo "We will use default number of MPI tasks for this machine : " 
     723          echo "${DEFAULT_NUM_PROC_OCE} for OCE; " 
     724          echo "${DEFAULT_NUM_PROC_CPL} for CPL; " 
     725          echo "${DEFAULT_NUM_PROC_ATM} for ATM; " 
     726          echo "${DEFAULT_NUM_PROC_TOTAL} for the total number of processors; " 
     727          OK_PARA_MPI=true 
     728          CPL_PROC_MPI=${DEFAULT_NUM_PROC_CPL} 
     729          OCE_PROC_MPI=${DEFAULT_NUM_PROC_OCE} 
     730          ATM_PROC_MPI=${DEFAULT_NUM_PROC_ATM} 
     731          NUM_PROC_CPL=${DEFAULT_NUM_PROC_CPL} # for backward compatibility 
     732          NUM_PROC_OCE=${DEFAULT_NUM_PROC_OCE} # for backward compatibility 
     733          NUM_PROC_ATM=${DEFAULT_NUM_PROC_ATM} # for backward compatibility 
     734          PROCESSUS_NUMBER=${DEFAULT_NUM_PROC_TOTAL} 
     735        else 
     736          # with have only one executable 
     737          echo "We will use ${BATCH_NUM_PROC_TOT} MPI tasks for ${CompNameFirst} : ${config_Executable_Name} " 
     738          OK_PARA_MPI=true 
     739          eval ${CompNameFirst}_PROC_MPI=${BATCH_NUM_PROC_TOT} 
     740          PROCESSUS_NUMBER=${BATCH_NUM_PROC_TOT} 
    684741        fi 
    685  
    686     else # BATCH_NUM_PROC_TOT="" 
    687         if ( ${OK_PARA_MPI} ) ; then 
    688             echo "You have not given a value of ${BATCH_NUM_PROC_TOT} processors," 
    689             echo "but you have filled the parallel parameter in config->Executable->list." 
    690             echo "Please add BATCH_NUM_PROC_TOT variable in job header." 
    691             echo "We stop now." 
    692             exit 1 
    693         else 
    694         # sequential case ! 
    695             if [ ${PROCESSUS_NUMBER} -eq 0 ] ; then 
    696                (( PROCESSUS_NUMBER = 1 )) 
    697                echo "PROCESSUS_NUMBER is all 0 (sequential use of old definition in config->Executable->list)." 
    698                echo "We set it to 1." 
    699             fi 
    700         fi 
    701     fi 
    702  
    703     IGCM_debug_Print 1 "MPI/OMP treatment PROCESSUS_NUMBER = ${PROCESSUS_NUMBER}" 
    704  
    705 #     if ( ${OK_PARA_MPI} || ${OK_PARA_OMP} || ${OK_PARA_NOD} ) ; then 
    706     IGCM_sys_build_execution_scripts 
    707 #     fi 
    708  
    709     ExecutionFail=false 
    710  
    711     IGCM_debug_PopStack "IGCM_config_PeriodStart" 
     742      else  
     743        PROCESSUS_NUMBER=1 
     744      fi 
     745    fi 
     746    # Verification with PBS parameter 
     747    if [ ${BATCH_NUM_PROC_TOT} -ne ${PROCESSUS_NUMBER} ] ; then 
     748      echo "Warning with parallelization parameters !" 
     749      echo "Job header variable BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} " 
     750      echo "is the total number of _processors_ reserved." 
     751      echo "It is not equal to the sum of _processus_  = ${PROCESSUS_NUMBER}." 
     752      echo "We stop now." 
     753      exit 1 
     754    fi 
     755  else # BATCH_NUM_PROC_TOT="" 
     756    if ( ${OK_PARA_MPI} ) ; then 
     757      echo "You have not given a value of ${BATCH_NUM_PROC_TOT} processors," 
     758      echo "but you have filled the parallel parameter in config->Executable->list." 
     759      echo "Please add BATCH_NUM_PROC_TOT variable in job header." 
     760      echo "We stop now." 
     761      exit 1 
     762    else 
     763      # sequential case ! 
     764      if [ ${PROCESSUS_NUMBER} -eq 0 ] ; then 
     765        (( PROCESSUS_NUMBER = 1 )) 
     766        echo "PROCESSUS_NUMBER is all 0 (sequential use of old definition in config->Executable->list)." 
     767        echo "We set it to 1." 
     768      fi 
     769    fi 
     770  fi 
     771 
     772  IGCM_debug_Print 1 "MPI/OMP treatment PROCESSUS_NUMBER = ${PROCESSUS_NUMBER}" 
     773 
     774  IGCM_sys_build_execution_scripts 
     775 
     776  ExecutionFail=false 
     777 
     778  IGCM_debug_PopStack "IGCM_config_PeriodStart" 
     779} 
     780 
     781#=================================== 
     782function IGCM_config_SaveSourceModifications 
     783{ 
     784  IGCM_debug_PushStack "IGCM_config_SaveSourceModifications" 
     785 
     786  typeset ExeOutDateMax listVarEnv 
     787  ExeOutDateMax=$1 
     788 
     789  listVarEnv="ExeOutDateMax,R_OUT_EXE,PREFIX,SUBMIT_DIR" 
     790  IGCM_sys_RshMaster "\ 
     791    . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh; \ 
     792    export ExeOutDateMax=${ExeOutDateMax};\ 
     793    export R_OUT_EXE=${R_OUT_EXE};\ 
     794    export PREFIX=${PREFIX};\ 
     795    export SUBMIT_DIR=${SUBMIT_DIR};\ 
     796    export listVarEnv=${listVarEnv};\ 
     797    Script_Output=out_SaveSourceModifications;\ 
     798    IGCM_sys_Qsub ${libIGCM}/SaveSourceModifications.job ${ExeOutDateMax} ${R_OUT_EXE} ${PREFIX} ${SUBMIT_DIR}" 
     799 
     800  IGCM_debug_PopStack "IGCM_config_SaveSourceModifications" 
    712801} 
    713802 
     
    715804function IGCM_config_PeriodEnd 
    716805{ 
    717     IGCM_debug_PushStack "IGCM_config_PeriodEnd" 
    718  
    719     echo 
    720     IGCM_debug_Print 1 "IGCM_config_PeriodEnd" 
    721     echo 
    722  
    723     #==================================# 
    724     #         Save Job output          # 
    725     #==================================# 
    726     IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output} 
    727     eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}" 
    728  
    729     IGCM_card_CheckConflict run.card 
    730     IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/run.card rw 
    731  
    732 if [ ${DRYRUN} -le 1 ] ; then 
     806  IGCM_debug_PushStack "IGCM_config_PeriodEnd" 
     807 
     808  echo 
     809  IGCM_debug_Print 1 "IGCM_config_PeriodEnd" 
     810  echo 
     811 
     812  #==================================# 
     813  #         Save Job output          # 
     814  #==================================# 
     815  IGCM_sys_PutBuffer_Out ${Exe_Output} ${R_BUF_KSH}/${PREFIX}_${Exe_Output} 
     816  eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}" 
     817 
     818      IGCM_card_CheckConflict run.card 
     819      IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/run.card rw 
     820 
     821 
     822  if [ ${DRYRUN} -le 1 ] ; then 
    733823    IGCM_debug_Print 1 "Check components binary : size and creation date" 
    734824 
    735825    typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize 
    736826    typeset comp i     
    737     typeset ExeNameIn ExeNameOut  
     827    typeset ExeNameIn ExeNameOut UpdateExe ExeSecDateMax 
    738828 
    739829    #==================================# 
     
    743833    (( i=0 )) 
    744834    if ( ${FirstInitialize} ) ; then 
    745         run_Log_LastExeSize="" 
    746         for comp in ${config_ListOfComponents[*]} ; do 
    747             run_Log_LastExeSize[$i]=0 
    748             (( i=i+1 )) 
    749         done 
     835      run_Log_LastExeSize="" 
     836      for comp in ${config_ListOfComponents[*]} ; do 
     837        run_Log_LastExeSize[$i]=0 
     838       (( i=i+1 )) 
     839      done 
    750840    else 
    751         IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize 
     841      IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize 
    752842    fi 
    753843    #==================================# 
     
    761851    NextExeSize="( " 
    762852    (( i=0 )) 
    763  
     853    UpdateExe=false 
     854    (( ExeSecDateMax = 0 )) 
    764855    for comp in ${config_ListOfComponents[*]} ; do 
    765856 
    766         IGCM_debug_Print 3 ${comp} 
    767  
    768         eval ExeNameIn=\${config_Executable_${comp}[0]} 
    769         eval ExeNameOut=\${config_Executable_${comp}[1]} 
    770         # Only if we really have an executable for the component : 
    771         if [ X${ExeNameIn} = X\"\" ] ; then 
    772             # If there is no exe file for this component 
    773             (( ExeSize=0 )) 
    774         else 
    775             eval LS_bin=${R_EXE}/${ExeNameIn} 
    776             IGCM_sys_FileSize ${LS_bin} ExeSize 
    777  
    778             set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} ) 
    779             if [ X${ExeDate} = X ] ; then  
    780                 # First component exe date 
    781                 ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]} 
    782             else 
    783                 ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]} 
    784             fi 
    785             ExeDate=${ExeDate}_${LS_comp[7]} 
    786         fi 
    787  
    788         if [ ${i} -eq 0 ] ; then 
    789             # First component 
    790             NextExeSize="( "${ExeSize} 
    791         else 
    792             NextExeSize=${NextExeSize}", "${ExeSize} 
    793         fi 
    794         eval LastCompExeSize=${run_Log_LastExeSize[$i]} 
    795         (( i=i+1 )) 
    796  
    797         if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then 
    798             if ( ${FirstInitialize} ) ; then 
    799                 IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !" 
    800             else 
    801                 IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !" 
    802                 IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !" 
    803                 eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut} 
    804             fi 
    805             eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw 
    806         fi 
     857      IGCM_debug_Print 3 ${comp} 
     858 
     859      eval ExeNameIn=\${config_Executable_${comp}[0]} 
     860      eval ExeNameOut=\${config_Executable_${comp}[1]} 
     861      # Only if we really have an executable for the component : 
     862      if [ X${ExeNameIn} = X\"\" ] ; then 
     863        # If there is no exe file for this component 
     864        (( ExeSize=0 )) 
     865      else 
     866        eval LS_bin=${R_EXE}/${ExeNameIn} 
     867        IGCM_sys_FileSize ${LS_bin} ExeSize 
     868 
     869        set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} ) 
     870        if [ X${ExeDate} = X ] ; then  
     871          # First component exe date 
     872          ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]} 
     873        else 
     874          ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]} 
     875        fi 
     876        ExeDate=${ExeDate}_${LS_comp[7]} 
     877      fi 
     878 
     879      if [ ${i} -eq 0 ] ; then 
     880        # First component 
     881        NextExeSize="( "${ExeSize} 
     882      else 
     883        NextExeSize=${NextExeSize}", "${ExeSize} 
     884      fi 
     885      eval LastCompExeSize=${run_Log_LastExeSize[$i]} 
     886      (( i=i+1 )) 
     887 
     888      if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then 
     889        if ( ${FirstInitialize} ) ; then 
     890          IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !" 
     891        else 
     892          IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !" 
     893          IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !" 
     894          eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut} 
     895        fi 
     896        eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw 
     897        UpdateExe=true 
     898 
     899        IGCM_sys_GetDate_FichWork ${LS_bin} ExeSecDate 
     900        if [ $ExeSecDateMax -lt $ExeSecDate ] ; then 
     901          ExeSecDateMax=$ExeSecDate 
     902        fi 
     903      fi 
    807904    done 
     905 
     906# SD : switch off for now 
     907#      if ( ${UpdateExe} ) ; then 
     908#       echo "Launch SaveSourceModifications." 
     909#       IGCM_config_SaveSourceModifications ${ExeSecDateMax} 
     910#      fi 
    808911 
    809912    NextExeSize=${NextExeSize}" )" 
     
    814917    RET=$? 
    815918    if [ $RET -eq 0 ] ; then 
    816             # ExeCpuLog variable contents 5 fields 
    817             echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" |   \ 
    818             gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \ 
    819                               $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card 
     919      # ExeCpuLog variable contents 5 fields 
     920      echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" |   \ 
     921      gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \ 
     922            $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card 
    820923    fi 
    821924    eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}_tail.txt" 
    822 fi 
    823  
    824     # All was right ? no ? then we stop. 
    825     IGCM_debug_Verif_Exit 
    826  
    827     # If all was OK, we can delete all files not necessary for next Job 
     925  
     926  fi  
     927 
     928  # All was right ? no ? then we stop. 
     929  IGCM_debug_Verif_Exit 
     930 
     931  # If all was OK, we can delete all files not necessary for next Job 
     932  echo 
     933  IGCM_debug_Print 1 "Files that will be deleted before next period-run : " 
     934 
     935  if [ ${DRYRUN} -le 2 ] ; then 
     936    for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done 
     937  else 
     938    echo ${FileToBeDeleted[@]} 
     939  fi 
     940 
     941  #=================================================# 
     942  #         Modification of libIGCM behaviour       # 
     943  #=================================================# 
     944 
     945  # To use this function, one must copy libIGCM.card from ${libIGCM} directory 
     946  # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card, 
     947  # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop.  
     948  if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then 
    828949    echo 
    829     IGCM_debug_Print 1 "Files that will be deleted before next period-run : " 
    830  
    831     if [ ${DRYRUN} -le 2 ] ; then 
    832         for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done 
    833     else 
    834         echo ${FileToBeDeleted[@]} 
    835     fi 
    836  
    837     #=================================================# 
    838     #         Modification of libIGCM behaviour       # 
    839     #=================================================# 
    840  
    841     # To use this function, one must copy libIGCM.card from ${libIGCM} directory 
    842     # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card, 
    843     # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop.  
    844     if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then 
    845         echo 
    846         echo "########################################################################" 
    847         echo "!!!                 Modification of libIGCM behaviour                !!!" 
    848         echo 
    849  
    850         IGCM_debug_Print 1 "DefineArrayFromOption  : libIGCM_UserChanges in libIGCM.card" 
    851         IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/libIGCM.card UserChanges 
    852         IGCM_debug_Print 2 "libIGCM_UserChanges" ${libIGCM_UserChanges[*]} 
    853  
    854         # Special treatments for libIGCM internals 
    855         for option in ${libIGCM_UserChanges[*]} ; do 
    856             IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option} 
    857  
    858             echo "We will change : ${option}." 
    859             eval echo "Previous value : " \${${option}} 
    860             eval echo "Change to : " \${libIGCM_UserChanges_${option}} 
    861              
    862             eval ${option}=\${libIGCM_UserChanges_${option}} 
    863  
    864             case ${option} in 
    865                 config_UserChoices_DateEnd) 
    866                     IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd 
    867                     DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) 
    868  
    869                     # Period Length In Days between DateBegin and DateEnd 
    870                     (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 )) 
    871                     if [ ${ExperienceLengthInDays} -lt 0 ] ; then 
    872                         IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that." 
    873                         IGCM_debug_Exit "IGCM_PeriodEnd" " Wrong Dates." 
    874                         IGCM_debug_Verif_Exit  
    875                     fi 
    876                     ;; 
    877                 config_UserChoices_PeriodLength) 
    878                     IGCM_debug_Print 1  "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}" 
    879                     ;; 
    880                 PeriodNb) 
    881                     IGCM_debug_Print 1  "Loop in main Job with ${PeriodNb} period(s)" 
    882                     ;; 
    883                 config_Post_RebuildFrequency) 
    884                     IGCM_debug_Print 1  "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure" 
    885                     IGCM_post_Configure 
    886                     ;; 
    887                 config_Post_TimeSeriesFrequency) 
    888                     IGCM_debug_Print 1  "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Initialize" 
    889                     IGCM_post_Configure 
    890                     ;; 
    891                 config_Post_SeasonalFrequency) 
    892                     IGCM_debug_Print 1  "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Initialize" 
    893                     IGCM_post_Configure 
    894                     ;; 
    895             esac 
    896         done 
    897  
    898         echo 
    899         echo "########################################################################" 
    900         echo 
    901     fi 
    902  
    903     #=================================================# 
    904     #         Determine next computed period          # 
    905     #=================================================# 
    906  
    907     PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 ) 
    908     IGCM_date_GetYearMonth $PeriodDateBegin year month 
    909     year_m1=$(( year - 1 )) 
    910     year_p1=$(( year + 1 )) 
    911     IGCM_config_Analyse_PeriodLength 
    912     PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) ) 
    913  
    914     # Debug Print : 
     950    echo "########################################################################" 
     951    echo "!!!                 Modification of libIGCM behaviour                !!!" 
    915952    echo 
    916     IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution" 
    917     IGCM_debug_Print 1 "PeriodDateBegin       : ${PeriodDateBegin}" 
    918     IGCM_debug_Print 1 "PeriodDateEnd         : ${PeriodDateEnd}" 
    919     IGCM_debug_Print 1 "PeriodLengthInDays    : ${PeriodLengthInDays}" 
    920  
    921     PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) 
    922     PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) 
    923  
    924     (( CumulPeriod = CumulPeriod + 1 )) 
    925  
    926     # Debug Print : 
     953 
     954    IGCM_debug_Print 1 "DefineArrayFromOption  : libIGCM_UserChanges in libIGCM.card" 
     955    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/libIGCM.card UserChanges 
     956    IGCM_debug_Print 2 "libIGCM_UserChanges" ${libIGCM_UserChanges[*]} 
     957 
     958    # Special treatments for libIGCM internals 
     959    for option in ${libIGCM_UserChanges[*]} ; do 
     960      IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option} 
     961 
     962      echo "We will change : ${option}." 
     963      eval echo "Previous value : " \${${option}} 
     964      eval echo "Change to : " \${libIGCM_UserChanges_${option}} 
     965           
     966      eval ${option}=\${libIGCM_UserChanges_${option}} 
     967 
     968      case ${option} in 
     969        config_UserChoices_DateEnd) 
     970          IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd 
     971          DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) 
     972 
     973          # Period Length In Days between DateBegin and DateEnd 
     974          (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 )) 
     975          if [ ${ExperienceLengthInDays} -lt 0 ] ; then 
     976            IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that." 
     977            IGCM_debug_Exit "IGCM_PeriodEnd" " Wrong Dates." 
     978            IGCM_debug_Verif_Exit  
     979          fi 
     980        ;; 
     981        config_UserChoices_PeriodLength) 
     982          IGCM_debug_Print 1  "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}" 
     983        ;; 
     984        PeriodNb) 
     985          IGCM_debug_Print 1  "Loop in main Job with ${PeriodNb} period(s)" 
     986        ;; 
     987        config_Post_RebuildFrequency) 
     988          IGCM_debug_Print 1  "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure" 
     989          IGCM_post_Configure 
     990        ;; 
     991        config_Post_TimeSeriesFrequency) 
     992          IGCM_debug_Print 1  "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Initialize" 
     993          IGCM_post_Configure 
     994        ;; 
     995        config_Post_SeasonalFrequency) 
     996        IGCM_debug_Print 1  "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Initialize" 
     997        IGCM_post_Configure 
     998        ;; 
     999      esac 
     1000    done 
     1001 
    9271002    echo 
    928     IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}" 
    929     IGCM_debug_Print 3 "PeriodDateEnd Human   : ${PeriodDateEnd}" 
    930     IGCM_debug_Print 3 "CumulPeriod           : ${CumulPeriod}" 
    931  
    932     #=================================================# 
    933     #             Write updated run.card              # 
    934     #=================================================# 
    935  
    936     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix} 
    937     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} 
    938     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} 
    939     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} 
    940  
    941     if ( ${FirstInitialize} ) ; then 
    942         # It's no more the first time 
    943         FirstInitialize=false 
    944     fi 
    945  
    946     IGCM_debug_PopStack "IGCM_config_PeriodEnd" 
     1003    echo "########################################################################" 
     1004    echo 
     1005  fi 
     1006 
     1007  #=================================================# 
     1008  #         Determine next computed period          # 
     1009  #=================================================# 
     1010 
     1011  PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 ) 
     1012  IGCM_date_GetYearMonthDay $PeriodDateBegin year month day 
     1013  year_m1=$(( year - 1 )) 
     1014  year_p1=$(( year + 1 )) 
     1015  IGCM_config_Analyse_PeriodLength 
     1016  PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) ) 
     1017 
     1018  # Debug Print : 
     1019  echo 
     1020  IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution" 
     1021  IGCM_debug_Print 1 "PeriodDateBegin       : ${PeriodDateBegin}" 
     1022  IGCM_debug_Print 1 "PeriodDateEnd         : ${PeriodDateEnd}" 
     1023  IGCM_debug_Print 1 "PeriodLengthInDays    : ${PeriodLengthInDays}" 
     1024 
     1025  PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) 
     1026  PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) 
     1027 
     1028  (( CumulPeriod = CumulPeriod + 1 )) 
     1029 
     1030  # Debug Print : 
     1031  echo 
     1032  IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}" 
     1033  IGCM_debug_Print 3 "PeriodDateEnd Human   : ${PeriodDateEnd}" 
     1034  IGCM_debug_Print 3 "CumulPeriod           : ${CumulPeriod}" 
     1035 
     1036  #=================================================# 
     1037  #             Write updated run.card              # 
     1038  #=================================================# 
     1039 
     1040  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix} 
     1041  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} 
     1042  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} 
     1043  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} 
     1044 
     1045  if ( ${FirstInitialize} ) ; then 
     1046    # It's no more the first time 
     1047    FirstInitialize=false 
     1048  fi 
     1049 
     1050  IGCM_debug_PopStack "IGCM_config_PeriodEnd" 
    9471051} 
    9481052 
     
    9501054function IGCM_config_Finalize 
    9511055{ 
    952     IGCM_debug_PushStack "IGCM_config_Finalize" 
    953  
    954     echo 
    955     IGCM_debug_Print 1 "IGCM_config_Finalize" 
    956     echo 
    957  
    958     if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then 
    959         #==========================# 
    960         # End of entire simulation # 
    961         #==========================# 
    962  
    963         # Mail notification 
    964         IGCM_sys_SendMail 
    965  
    966         # 
    967         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed" 
    968         IGCM_debug_Print 1 "Normal End of computation." 
    969         if ( $DEBUG_debug ) ; then 
    970             echo 
    971             IGCM_debug_Print 1 "Your files on ${R_OUT} :" 
    972             IGCM_sys_Tree ${R_SAVE} 
    973         fi 
    974     else 
    975         #=================# 
    976         # Submit next job # 
    977         #=================# 
    978  
    979         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" 
    980  
    981         # Name of next Ksh Script output : 
    982         eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )" 
    983  
    984         IGCM_debug_Print 1 "Submit next job" 
    985         # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR 
    986         IGCM_sys_Cd ${SUBMIT_DIR} 
    987         # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName} 
    988         ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l ) 
    989         [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) ) 
    990         # Submit next job and come back 
    991         IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} 
    992         IGCM_sys_Cd - 
    993     fi 
    994  
    995     # Supress Non Deleted Boundary files 
    996     if [ ${DRYRUN} -le 2 ] ; then 
    997         IGCM_comp_DelFixeBoundaryFiles 
    998         ls -la 
    999     fi 
    1000      
    1001     # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    1002     # Only for production run (No clean up in DEV or DEB mode) 
    1003     # and command sent from .. directory. 
    1004     IGCM_sys_Cd .. 
    1005     [ X${JobType} = XRUN ] && IGCM_sys_Rm -rf ${RUN_DIR} 
    1006  
    1007     IGCM_debug_PopStack "IGCM_config_Finalize" 
     1056  IGCM_debug_PushStack "IGCM_config_Finalize" 
     1057 
     1058  echo 
     1059  IGCM_debug_Print 1 "IGCM_config_Finalize" 
     1060  echo 
     1061 
     1062  if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then 
     1063    #==========================# 
     1064    # End of entire simulation # 
     1065    #==========================# 
     1066 
     1067    # Mail notification 
     1068    IGCM_sys_SendMail 
     1069 
     1070    # 
     1071    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed" 
     1072    IGCM_debug_Print 1 "Normal End of computation." 
     1073    if ( $DEBUG_debug ) ; then 
     1074      echo 
     1075      IGCM_debug_Print 1 "Your files on ${R_SAVE} :" 
     1076      IGCM_sys_Tree ${R_SAVE} 
     1077 
     1078      IGCM_debug_Print 1 "Your files on ${R_BUFR} :" 
     1079      IGCM_sys_Tree ${R_BUFR} 
     1080    fi 
     1081  else 
     1082    #=================# 
     1083    # Submit next job # 
     1084    #=================# 
     1085 
     1086    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" 
     1087 
     1088    # Name of next Ksh Script output : 
     1089    eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )" 
     1090 
     1091    IGCM_debug_Print 1 "Submit next job" 
     1092    # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR 
     1093    IGCM_sys_Cd ${SUBMIT_DIR} 
     1094    # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName} 
     1095    ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l ) 
     1096    [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) ) 
     1097    # Submit next job and come back 
     1098    IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} 
     1099    IGCM_sys_Cd - 
     1100  fi 
     1101 
     1102  # Supress Non Deleted Boundary files 
     1103  if [ ${DRYRUN} -le 2 ] ; then 
     1104    IGCM_comp_DelFixeBoundaryFiles 
     1105    ls -la 
     1106  fi 
     1107   
     1108  # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     1109  # Only for production run (No clean up in DEV or DEB mode) 
     1110  # and command sent from .. directory. 
     1111  IGCM_sys_Cd .. 
     1112  [ X${JobType} = XRUN ] && IGCM_sys_Rm -rf ${RUN_DIR} 
     1113 
     1114  IGCM_debug_PopStack "IGCM_config_Finalize" 
    10081115} 
    10091116 
  • branches/libIGCM_MPI_OpenMP/libIGCM_date/libIGCM_date.ksh

    r435 r571  
    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" 
     161} 
     162 
     163#================================================================== 
     164function IGCM_date_GetYearMonthDay 
     165{ 
     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" 
    161192} 
    162193 
     
    171202{ 
    172203#    IGCM_debug_PushStack "IGCM_date_DaysInYear" $@ 
    173     # return the number of days in a year 
    174     # usage IGCM_date_DaysInYear yyyy 
    175  
    176     # What is the calendar : 
    177     case ${config_UserChoices_CalendarType} in 
    178         360d|360_day) 
    179             if [ X$2 = X ] ; then 
    180                 echo 360 
    181             else 
    182                 eval $2=360 > /dev/null 2>&1 
    183             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 
    184215#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    185             return;; 
    186         noleap|365_day) 
    187             if [ X$2 = X ] ; then 
    188                 echo 365 
    189             else 
    190                 eval $2=365 > /dev/null 2>&1 
    191             fi 
    192  
    193 #           IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    194             return;; 
    195         all_leap|366_day) 
    196             if [ X$2 = X ] ; then 
    197                 echo 366 
    198             else 
    199                 eval $2=366 > /dev/null 2>&1 
    200             fi 
    201  
    202 #               IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    203             return;; 
    204     esac 
    205  
    206     typeset y a 
    207  
    208     # if there is no argument on the command line,  
    209     # then assume that a yyyy is being piped in 
    210     if [ $# = 0 ] 
    211         then 
    212         read y 
    213     else 
    214         y=$(( 10#${1} )) 
    215     fi 
    216  
    217     # a year is a leap year if it is even divisible by 4 
    218     # but not evenly divisible by 100 
    219     # unless it is evenly divisible by 400 
    220  
    221     # if it is evenly divisible by 400 it must be a leap year 
    222     a=$(( $y % 400 )) 
    223     if [ $a = 0 ] 
    224         then 
    225         if [ X$2 = X ] ; then 
    226             echo 366 
    227         else 
    228             eval $2=366 > /dev/null 2>&1 
    229         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 
    230223 
    231224#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    232         return 
    233     fi 
    234  
    235     #if it is evenly divisible by 100 it must not be a leap year 
    236     a=$(( $y % 100 )) 
    237     if [ $a = 0 ] 
    238         then 
    239         if [ X$2 = X ] ; then 
    240             echo 365 
    241         else 
    242             eval $2=365 > /dev/null 2>&1 
    243         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 
    244232 
    245233#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    246         return 
    247     fi 
    248          
    249     # if it is evenly divisible by 4 it must be a leap year 
    250     a=$(( $y % 4 )) 
    251     if [ $a = 0 ] 
    252         then 
    253         if [ X$2 = X ] ; then 
    254             echo 366 
    255         else 
    256             eval $2=366 > /dev/null 2>&1 
    257         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 
    258261 
    259262#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    260         return 
    261     fi 
    262  
    263     # 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 
    264270    if [ X$2 = X ] ; then 
    265         echo 365 
    266     else 
    267         eval $2=365 > /dev/null 2>&1 
    268     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 
    269300 
    270301#    IGCM_debug_PopStack "IGCM_date_DaysInYear" 
     
    284315#    IGCM_debug_PushStack "IGCM_date_DaysInMonth" $@ 
    285316 
    286     # calculates the number of days in a month  
    287     # usage IGCM_date_DaysInMonth yyyy mm 
    288     # 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 
    289370     
    290     # What is the calendar : 
    291     if ( [ "${config_UserChoices_CalendarType}" = "360d" ] || [ "${config_UserChoices_CalendarType}" = "360_day" ] ) ; then 
    292         if [ X$3 = X ] ; then 
    293             echo 30 
    294         else 
    295             eval $3=30 > /dev/null 2>&1 
    296         fi 
    297  
    298 #       IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    299         return 
    300     fi 
    301  
    302     typeset ymd y m 
    303  
    304     # if there are no command line arguments then assume that a yyyymmdd is being 
    305     # piped in and read the value. 
    306     # if there is only one argument assume it is a yyyymmdd on the command line 
    307     # other wise it is a yyyy and mm on the command line 
    308     if [ $# = 0 ] 
    309         then 
    310         read ymd 
    311     elif [ $# = 1 ]  
    312         then 
    313         ymd=$1 
    314     else 
    315         ymd=$(( ( $1 * 10000 ) + ( $2 * 100 ) + 1 )) 
    316     fi 
    317  
    318     # extract the year and the month 
    319     y=$(( $ymd / 10000 )) ; 
    320     m=$(( ( $ymd % 10000 ) / 100 )) ; 
    321  
    322     # 30 days hath september etc. 
    323     case $m in 
    324         1|3|5|7|8|10|12)  
    325             if [ X$3 = X ] ; then 
    326                 echo 31 
    327             else 
    328                 eval $3=31 > /dev/null 2>&1 
    329             fi 
    330  
    331371#           IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    332             return ;; 
    333         4|6|9|11)  
    334             if [ X$3 = X ] ; then 
    335                 echo 30 
    336             else 
    337                 eval $3=30 > /dev/null 2>&1 
    338             fi 
    339          
    340 #           IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    341             return ;; 
    342         *) ;; 
    343     esac 
    344  
    345     # except for month 2 which depends on whether the year is a leap year 
    346     # Use IGCM_date_DaysInYear to get the number of days in the year and return a value 
    347     # accordingly. 
    348     IGCM_date_DaysInYear $y diy 
    349     case $diy in 
    350         365)  
    351             if [ X$3 = X ] ; then 
    352                 echo 28 
    353             else 
    354                 eval $3=28 > /dev/null 2>&1 
    355             fi 
    356  
    357 #           IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    358             return ;; 
    359         366)  
    360             if [ X$3 = X ] ; then 
    361                 echo 29 
    362             else 
    363                 eval $3=29 > /dev/null 2>&1 
    364             fi 
    365  
    366 #           IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
    367             return ;; 
    368     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 
    369400 
    370401#    IGCM_debug_PopStack "IGCM_date_DaysInMonth" 
     
    380411function IGCM_date_ConvertGregorianDateToJulian 
    381412{ 
    382     IGCM_debug_PushStack "IGCM_date_ConvertGregorianDateToJulian" $@ 
    383  
    384     # IGCM_date_ConvertGregorianDateToJulian converts yyyymmdd to yyyyddd 
    385     # usage IGCM_date_ConvertGregorianDateToJulian 19980429 
    386  
    387     typeset dt y m d x jul 
    388  
    389     # if there is no command line argument, then assume that the date 
    390     # is coming in on a pipe and use read to collect it     
    391     if [ $# = 0 ] 
    392         then 
    393         read dt 
    394     else 
    395         dt=$( IGCM_date_SupressZeros $1 ) 
    396     fi 
    397  
    398     # break the yyyymmdd into separate parts for year, month and day 
    399     y=$(( $dt / 10000 )) 
    400     m=$(( ( $dt % 10000 ) / 100 )) 
    401     d=$(( ( $dt % 100 ) )) 
    402  
    403     # add the days in each month up to (but not including the month itself) 
    404     # into the days. For example if the date is 19980203 then extract the 
    405     # number of days in January and add it to 03. If the date is June 14, 1998 
    406     # then extract the number of days in January, February, March, April and May 
    407     # and add them to 14. 
    408     x=1 
    409     while [ $x -lt $m ] 
    410       do 
    411       IGCM_date_DaysInMonth $y $x md 
    412       d=$(( $d + $md )) 
    413       x=$(( $x + 1 )) 
    414     done 
    415  
    416     # combine the year and day back together again and you have the julian date. 
    417     jul=$(( ( $y * 1000 ) + $d )) 
    418     echo $jul 
    419  
    420     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" 
    421452} 
    422453 
     
    430461function IGCM_date_ConvertJulianDateToGregorian 
    431462{ 
    432     IGCM_debug_PushStack "IGCM_date_ConvertJulianDateToGregorian" $@ 
    433  
    434     # IGCM_date_ConvertJulianDateToGregorian converts yyyyddd to yyyymmdd 
    435     # usage IGCM_date_ConvertJulianDateToGregorian 1998213 
    436  
    437     typeset dt y m d grg 
    438  
    439     # if there is no command line argument, assume one is being  
    440     # piped in and read it 
    441     if [ X$1 = X ] 
    442         then 
    443         read dt 
    444     else 
    445         dt=$1 
    446     fi 
    447          
    448     # break apart the year and the days 
    449     y=$(( $dt / 1000 )) 
    450     d=$(( $dt % 1000 )) 
    451          
    452     # subtract the number of days in each month starting from 1 
    453     # from the days in the date. When the day goes below 1, you 
    454     # have the current month. Add back the number of days in the 
    455     # month to get the correct day of the month 
    456     m=1 
    457     while [ $d -gt 0 ] 
    458       do 
    459       IGCM_date_DaysInMonth $y $m md 
    460       d=$(( $d - $md )) 
    461       m=$(( $m + 1 )) 
    462     done 
    463  
    464     d=$(( $d + $md )) 
    465  
    466     # the loop steps one past the correct month, so back up the month 
    467     m=$(( $m - 1 )) 
    468  
    469     # assemble the results into a gregorian date 
    470     grg=$(( ( $y * 10000 ) + ( $m * 100 ) + $d )) 
    471     echo $( IGCM_date_GregorianDigit $grg ) 
    472  
    473     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" 
    474505} 
    475506 
     
    483514function IGCM_date_AddDaysToJulianDate 
    484515{ 
    485     IGCM_debug_PushStack "IGCM_date_AddDaysToJulianDate" $@ 
    486  
    487     # IGCM_date_AddDaysToJulianDate adds days to a yyyyddd formatted date 
    488     # usage IGCM_date_AddDaysToJulianDate 1998312 { ,-}14 
    489  
    490     typeset dif yd d y 
    491  
    492     # Read the difference from the command lines 
    493     # and the date from the command line, or standard input 
    494     if [ X$2 = X ] 
    495         then 
    496         dif=$1 
    497         read yd 
    498     else 
    499         yd=$1 
    500         dif=$2 
    501     fi 
    502  
    503     # Break it into pieces 
    504     d=$(( $yd % 1000 )) 
    505     y=$(( $yd / 1000 )) 
    506  
    507     # Add the number of days (if days is negative this results is 
    508     # a subtraction) 
    509     d=$(( $d + $dif )) 
    510  
    511     # 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 )) 
    512554    IGCM_date_DaysInYear $y diy 
    513  
    514     # If the calculated day exceeds the days in the year,  
    515     # add one year to the year and subtract the days in the year from the 
    516     # calculated days. Extract the days in the new year and repeat 
    517     # test until you end up with a day number that falls within the 
    518     # days of the year 
    519     while [ $d -gt $diy ] 
    520       do 
    521       d=$(( $d - $diy )) 
    522       y=$(( $y + 1 )) 
    523       IGCM_date_DaysInYear $y diy 
    524     done 
    525  
    526     # This is the reverse process. If the calculated number of days 
    527     # is less than 1, move back one year. Extract 
    528     # the days in this year and add the days in the year 
    529     # loop on this test until you end up with a number that 
    530     # falls within the days of the year 
    531     while [ $d -lt 1 ] 
    532       do 
    533       y=$(( $y - 1 )) 
    534       IGCM_date_DaysInYear $y diy 
    535       d=$(( $d + $diy )) 
    536     done 
    537  
    538     # put the year and day back together and echo the result 
    539     yd=$(( ( $y * 1000 ) + $d )) 
    540  
    541     echo $yd 
    542  
    543     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" 
    544575} 
    545576 
     
    553584function IGCM_date_AddDaysToGregorianDate 
    554585{ 
    555     IGCM_debug_PushStack "IGCM_date_AddDaysToGregorianDate" $@ 
    556  
    557     # IGCM_date_AddDaysToGregorianDate adds days to a yyyymmdd formatted date 
    558     # usage IGCM_date_AddDaysToGregorianDate 19980312 { ,-}14 
    559  
    560     # Read the difference from the command lines 
    561     # and the date from the command line, or standard input 
    562     typeset dif yd tmp res 
    563     if [ X$2 = X ] 
    564         then 
    565         dif=$1 
    566         read yd 
    567     else 
    568         yd=$1 
    569         dif=$2 
    570     fi 
    571  
    572     tmp=$( IGCM_date_ConvertGregorianDateToJulian $yd ) 
    573     tmp=$( IGCM_date_AddDaysToJulianDate $tmp $dif ) 
    574     res=$( IGCM_date_ConvertJulianDateToGregorian $tmp ) 
    575      
    576     echo $res 
    577  
    578     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" 
    579610} 
    580611 
     
    588619function IGCM_date_DaysBetweenJulianDate 
    589620{ 
    590     IGCM_debug_PushStack "IGCM_date_DaysBetweenJulianDate" $@ 
    591  
    592     # calculates the days difference between two dates and reports  
    593     # the number days as jul1 - jul2  
    594     # usage IGCM_date_DaysBetweenJulianDate jul1 jul2 
    595     # where julian date is in the form yyyyddd 
    596      
    597     usage () { 
    598         echo "Usage:" 
    599         echo " IGCM_date_DaysBetweenJulianDate jul1 jul2" 
    600         echo "" 
    601         echo " Calculates the day difference between" 
    602         echo " two julian dates (jul1 -jul2)" 
    603         echo " where a julian date is in the form of yyyyddd." 
    604     } 
    605   
    606     if [ $# -lt 2 ]; then 
    607         usage 
    608         IGCM_debug_Exit "IGCM_date_DaysBetweenJulianDate" 
    609     fi 
    610   
    611     # This process subtracts arg2 from arg1. If arg2 is larger 
    612     # then reverse the arguments. The calculations are done, and 
    613     # then the sign is reversed 
    614     if [ $1 -lt $2 ] 
    615         then 
    616         jul1=$2 
    617         jul2=$1 
    618     elif [ $1 -gt $2 ] 
    619         then 
    620         jul1=$1 
    621         jul2=$2 
    622     else 
    623         echo 0 
    624         IGCM_debug_PopStack "IGCM_date_DaysBetweenJulianDate" 
    625         return 
    626     fi 
    627  
    628     # Break the dates in to year and day portions 
    629     yyyy1=$(( $jul1 / 1000 )) 
    630     yyyy2=$(( $jul2 / 1000 )) 
    631     ddd1=$(( $jul1 % 1000 )) 
    632     ddd2=$(( $jul2 % 1000 )) 
    633  
    634     # Subtract days 
    635     res=$(( $ddd1 - $ddd2 )) 
    636  
    637     # Then add days in year until year2 matches year1 
    638  
    639     case ${config_UserChoices_CalendarType} in 
    640         360d|360_day)  
    641             res=$(( ( ( $yyyy1 - $yyyy2 ) * 360 ) + $res )) ;; 
    642         noleap|365_day) 
    643             res=$(( ( ( $yyyy1 - $yyyy2 ) * 365 ) + $res )) ;; 
    644         all_leap|366_day) 
    645             res=$(( ( ( $yyyy1 - $yyyy2 ) * 366 ) + $res )) ;; 
    646         leap|gregorian|standard) 
    647             while [ $yyyy2 -lt $yyyy1 ] 
    648             do 
    649                 IGCM_date_DaysInYear $yyyy2 diy 
    650                 res=$(( $res + $diy )) 
    651                 yyyy2=$(( $yyyy2 + 1 )) 
    652             done 
    653             ;; 
    654     esac 
    655  
    656  
    657     # if argument 2 was larger than argument 1 then  
    658     # the arguments were reversed before calculating 
    659     # adjust by reversing the sign 
    660     if [ $1 -lt $2 ] 
    661         then 
    662         res=$(( $res * -1 )) 
    663     fi 
    664   
    665     # and output the results 
    666     echo $res 
    667  
     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 
    668655    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" 
    669699} 
    670700 
     
    678708function IGCM_date_DaysBetweenGregorianDate 
    679709{ 
    680     IGCM_debug_PushStack "IGCM_date_DaysBetweenGregorianDate" $@ 
    681  
    682     # calculates the days difference between two dates and reports  
    683     # the number days as grg1 - grg2  
    684     # usage IGCM_date_DaysBetweenGregorianDate grg1 grg2 
    685     # where gregorian date is in the form yyyymmdd 
    686  
    687     usage () { 
    688         echo "Usage:" 
    689         echo " IGCM_date_DaysBetweenGregorianDate grg1 grg2" 
    690         echo "" 
    691         echo " Calculate day difference between" 
    692         echo " two gregorian dates (grg1 - grg2)" 
    693         echo " where a gregorian date is in the form of yyyymmdd." 
    694     } 
    695  
    696     if [ $# -lt 2 ]; then 
    697         usage 
    698         IGCM_debug_Exit "IGCM_date_DaysBetweenGregorianDate" 
    699     fi 
    700  
    701     # convert each date to julian 
    702     grg1=$1 
    703     grg2=$2 
    704  
    705     jul1=$( IGCM_date_ConvertGregorianDateToJulian $grg1 ) 
    706     jul2=$( IGCM_date_ConvertGregorianDateToJulian $grg2 ) 
    707  
    708     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 
    709739    # calculate the answer using IGCM_date_DaysBetweenJulianDate 
    710         res=$( IGCM_date_DaysBetweenJulianDate $jul1 $jul2 ) 
     740    res=$( IGCM_date_DaysBetweenJulianDate $jul1 $jul2 ) 
    711741    # and output the results 
    712         echo $res 
    713     else 
    714         echo 0 
    715     fi 
    716  
    717     IGCM_debug_PopStack "IGCM_date_DaysBetweenGregorianDate" 
     742    echo $res 
     743  else 
     744    echo 0 
     745  fi 
     746 
     747  IGCM_debug_PopStack "IGCM_date_DaysBetweenGregorianDate" 
    718748} 
    719749 
     
    726756function IGCM_date_DaysSinceJC 
    727757{ 
    728     IGCM_debug_PushStack "IGCM_date_DaysSinceJC" $@ 
    729  
    730     # calculates the days difference between a date and 00010101 
    731     # usage IGCM_date_DaysSinceJC grg1 
    732     # where gregorian date is in the form yyyymmdd 
    733  
    734     usage () { 
    735         echo "Usage:" 
    736         echo " IGCM_date_DaysSinceJC grg1" 
    737         echo "" 
    738         echo " Calculate day difference between" 
    739         echo " a gregorian date and 00010101" 
    740         echo " where a gregorian date is in the form of yyyymmdd." 
    741     } 
    742  
    743     if [ $# -lt 1 ]; then 
    744         usage 
    745         IGCM_debug_Exit "IGCM_date_DaysSinceJC" 
    746     fi 
    747      
    748     typeset aux num 
    749  
    750     if   [ ${1} -lt  5000000 ]; then 
    751         case ${config_UserChoices_CalendarType} in 
    752             360d|360_day)  
    753                 aux=-360;; 
    754             noleap|365_day) 
    755                 aux=-365;; 
    756             all_leap|366_day)  
    757                 aux=-366;; 
    758             leap|gregorian|standard) 
    759                 aux=-366;; 
    760         esac 
    761         num=101 
    762     elif [ ${1} -lt 15000000 ]; then 
    763         # To save CPU type we use auxiliary value 
    764         # which is number of days since JC and 10000101 
    765         case ${config_UserChoices_CalendarType} in 
    766             360d|360_day)  
    767                 aux=359640;; 
    768             noleap|365_day) 
    769                 aux=364635;; 
    770             all_leap|366_day)  
    771                 aux=365634;; 
    772             leap|gregorian|standard) 
    773                 aux=364877;; 
    774         esac 
    775         num=10000101 
    776     else 
    777         # To save CPU type we use auxiliary value 
    778         # which is number of days since JC and 19000101 
    779         case ${config_UserChoices_CalendarType} in 
    780             360d|360_day)  
    781                 aux=683640;; 
    782             noleap|365_day) 
    783                 aux=693135;; 
    784             all_leap|366_day)  
    785                 aux=695034;; 
    786             leap|gregorian|standard) 
    787                 aux=693595;; 
    788         esac 
    789         num=19000101 
    790     fi 
    791     echo $(( $( IGCM_date_DaysBetweenGregorianDate $1 ${num} ) + $aux )) 
    792  
    793     IGCM_debug_PopStack "IGCM_date_DaysSinceJC" 
    794 } 
     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" 
     824} 
     825 
     826#D-#================================================================== 
     827#D-function IGCM_date_DaysInPreviousPeriod () 
     828#D-* Purpose: Give the numbers of days during the previous prd1 period from grg1 date # OLD create_ts_begin_date 
     829#D-* Usage: IGCM_date_DaysInPreviousPeriod grg1 prd1 [end] 
     830#D-         where grg1 gregorian date is in the form yyyymmdd 
     831#D-         where prd1 period is in the form N[Yy], N[Mm], N[Dd]. N integer 
     832#D-         where [end] is an optionnal keyword to specify grg1 is the end of prd1 
     833#D- 
     834function IGCM_date_DaysInPreviousPeriod { 
     835  IGCM_debug_PushStack "IGCM_date_DaysInPreviousPeriod" $@ 
     836  typeset Length Period 
     837  Period=${2} 
     838  case ${Period} in 
     839  *Y|*y) 
     840    PeriodLengthInYears=$( echo ${Period} | awk -F '[yY]' '{print $1}' ) 
     841    IGCM_date_GetYearMonth ${1} year month 
     842    year=$( IGCM_date_SupressZeros ${year} ) 
     843    if [ X${2} = Xend ] ; then 
     844      (( year = year - PeriodLengthInYears + 1)) 
     845    fi 
     846    (( Length=0 )) 
     847    (( i=0 )) 
     848    until [ $i -ge $PeriodLengthInYears ] ; do 
     849      (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
     850      (( i=i+1 )) 
     851    done 
     852    ;; 
     853  *M|*m) 
     854    PeriodLengthInMonths=$( echo ${Period} | awk -F '[mM]' '{print $1}' ) 
     855    IGCM_date_GetYearMonth ${1} year month 
     856    year=$( IGCM_date_SupressZeros ${year} ) 
     857    if [ X${2} = Xend ] ; then 
     858      (( month = month - PeriodLengthInMonths + 1 )) 
     859    fi       
     860    (( year0 = year )) 
     861    if [ $month -le 0 ] ; then 
     862      (( month = month + 12 )) 
     863      year=$( printf "%04i\n" $(( year - 1 )) ) 
     864    fi 
     865    month=$( printf "%02i\n" ${month} ) 
     866    (( Length=0 )) 
     867    (( i=0 )) 
     868    until [ $i -ge $PeriodLengthInMonths ] ; do 
     869      if [ $(( month + i )) -lt 13 ] ; then 
     870        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 
     871      else 
     872        (( year = year0 + 1 )) 
     873        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 
     874      fi 
     875      (( i=i+1 )) 
     876    done 
     877    ;; 
     878  *D|*d) 
     879    Length=$( echo ${Period} | sed -e "s/[dD]//" ) ;; 
     880  *) 
     881    IGCM_debug_Exit "IGCM_date_DaysInPreviousPeriod " ${Period} " invalid PeriodLength : choose in *Y, *M, *D." 
     882    IGCM_debug_Verif_Exit_Post ;; 
     883  esac 
     884  echo ${Length} 
     885 
     886  IGCM_debug_PopStack "IGCM_date_DaysInPreviousPeriod" 
     887} 
     888 
     889#D-#================================================================== 
     890#D-function IGCM_date_DaysInNextPeriod () 
     891#D-* Purpose: Give the numbers of days during the next prd1 period from grg1 date # OLD create_ts_next_date 
     892#D-* Usage: IGCM_date_DaysInNextPeriod grg1 prd1 
     893#D-         where grg1 gregorian date is in the form yyyymmdd 
     894#D-         where prd1 period is in the form N[Yy], N[Mm], N[Dd]. N integer 
     895#D- 
     896function IGCM_date_DaysInNextPeriod { 
     897  IGCM_debug_PushStack "IGCM_date_DaysInNextPeriod" $@ 
     898  typeset Length Period 
     899  Period=${2} 
     900  case ${Period} in 
     901  *Y|*y)  
     902    PeriodLengthInYears=$( echo ${Period} | awk -F '[yY]' '{print $1}' ) 
     903    IGCM_date_GetYearMonth ${1} year month 
     904    year=$( IGCM_date_SupressZeros ${year} ) 
     905    (( Length=0 )) 
     906    (( i=0 )) 
     907    until [ $i -ge $PeriodLengthInYears ] ; do 
     908      (( Length = Length + $( IGCM_date_DaysInYear $(( year + i + 1 )) ) ))  
     909      (( i=i+1 )) 
     910    done 
     911    ;; 
     912  *M|*m)  
     913    PeriodLengthInMonths=$( echo ${Period} | awk -F '[mM]' '{print $1}' ) 
     914    IGCM_date_GetYearMonth ${1} year month 
     915    year=$( IGCM_date_SupressZeros ${year} ) 
     916    (( year0 = year )) 
     917    if [ $(( month + 1 )) -lt 13 ] ; then 
     918      month0=$(( month + 1 )) 
     919    else 
     920      month0=$(( month + 1 - 12 )) 
     921      (( year = year0 + 1 )) 
     922    fi 
     923    (( Length=0 )) 
     924    (( i=0 )) 
     925    until [ $i -ge $PeriodLengthInMonths ] ; do 
     926      if [ $(( month0 + i )) -lt 13 ] ; then 
     927        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) )) 
     928      else 
     929        (( year = year0 + 1 )) 
     930        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) ) )) 
     931      fi 
     932      (( i=i+1 )) 
     933    done 
     934    ;; 
     935  *D|*d) 
     936    Length=$( echo ${Period} | sed -e "s/[dD]//" ) ;; 
     937  *) 
     938    IGCM_debug_Exit "IGCM_date_DaysInNextPeriod " ${Period} " invalid PeriodLength : choose in *Y, *M, *D." 
     939    IGCM_debug_Verif_Exit_Post ;; 
     940  esac 
     941  echo ${Length} 
     942 
     943  IGCM_debug_PopStack "IGCM_date_DaysInNextPeriod" 
     944} 
     945 
    795946 
    796947#D-#================================================================== 
     
    799950function IGCM_date_Check 
    800951{ 
    801     IGCM_debug_PushStack "IGCM_date_Check" 
     952  IGCM_debug_PushStack "IGCM_date_Check" 
    802953 
    803954#--------------------- 
    804     if [ ! -n "${libIGCM}" ] ; then 
    805         echo "Check libIGCM_date ...........................................[ FAILED ]" 
    806         echo "--Error--> libIGCM variable is not defined" 
    807         IGCM_debug_Exit "IGCM_date_Check" 
    808     fi 
     955  if [ ! -n "${libIGCM}" ] ; then 
     956    echo "Check libIGCM_date ...........................................[ FAILED ]" 
     957    echo "--Error--> libIGCM variable is not defined" 
     958    IGCM_debug_Exit "IGCM_date_Check" 
     959  fi 
    809960 
    810961#--------------------- 
    811     whence -v gawk > /dev/null 2>&1 
    812     if [ ! $? -eq 0 ] ; then 
    813         echo "Check libIGCM_date ...........................................[ FAILED ]" 
    814         echo "--Error--> gawk command is not defined" 
    815         IGCM_debug_Exit "IGCM_date_Check" 
    816     fi 
     962  whence -v gawk > /dev/null 2>&1 
     963  if [ ! $? -eq 0 ] ; then 
     964    echo "Check libIGCM_date ...........................................[ FAILED ]" 
     965    echo "--Error--> gawk command is not defined" 
     966    IGCM_debug_Exit "IGCM_date_Check" 
     967  fi 
    817968 
    818969#--------------------- 
    819     ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh > IGCM_date_Test.ref.failed 2>&1 
    820      
    821     if diff IGCM_date_Test.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref > /dev/null 2>&1 ; then  
    822         echo "Check libIGCM_date ...............................................[ OK ]" 
    823         rm -f IGCM_date_Test.ref.failed 
    824     else  
    825         echo "Check libIGCM_date ...........................................[ FAILED ]" 
    826         echo "--Error--> Execution of ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh" 
    827         echo "           has produced the file IGCM_date_Test.ref.failed" 
    828         echo "           Please analyse differences with the reference file by typing:" 
    829         echo "           diff IGCM_date_Test.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref" 
    830         echo "           Report errors to the author: Sebastien.Denvil@ipsl.jussieu.fr" 
    831         IGCM_debug_Exit "IGCM_date_Check" 
    832     fi 
     970  ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh > IGCM_date_Test.ref.failed 2>&1 
     971   
     972  if diff IGCM_date_Test.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref > /dev/null 2>&1 ; then  
     973    echo "Check libIGCM_date ...............................................[ OK ]" 
     974    rm -f IGCM_date_Test.ref.failed 
     975  else  
     976    echo "Check libIGCM_date ...........................................[ FAILED ]" 
     977    echo "--Error--> Execution of ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh" 
     978    echo "           has produced the file IGCM_date_Test.ref.failed" 
     979    echo "           Please analyse differences with the reference file by typing:" 
     980    echo "           diff IGCM_date_Test.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref" 
     981    echo "           Report errors to the author: Sebastien.Denvil@ipsl.jussieu.fr" 
     982    IGCM_debug_Exit "IGCM_date_Check" 
     983  fi 
    833984 
    834985#--------------------- 
    835     IGCM_debug_PopStack "IGCM_date_Check" 
     986  IGCM_debug_PopStack "IGCM_date_Check" 
    836987} 
    837988 
  • branches/libIGCM_MPI_OpenMP/libIGCM_debug/libIGCM_debug.ksh

    r457 r571  
    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} 
  • branches/libIGCM_MPI_OpenMP/libIGCM_post/check_expe_files_size.sh

    r408 r571  
    125125# On deduit de la liste des fichiers des patterns de annee+mois, annee, intervalles de date ... 
    126126sed -r \ 
    127     -e 's/[0-2][0-9]{3}[01][0-9]/YYMM/g' \ 
     127    -e 's/[0-5][0-9]{3}[01][0-9]/YYMM/g' \ 
    128128    -e 's/YYMM01_YYMM(28|29|30|31)/YYmmdd_YYmmdd/g' \ 
    129129                                           /tmp/$$.ldir | sort -u > /tmp/$$.lpat 
     
    146146        # On transforme le pattern pour mettre une sequences   
    147147        # de capture des annees de debut et fin d'intervalle 
    148         p2=$(echo $pattern | sed -e 's/YYmmdd_YYmmdd/([0-2][0-9]{3}[01][0-9])01_[0-2][0-9]{3}[01][0-9](28|29|30|31)/g' ) 
     148        p2=$(echo $pattern | sed -e 's/YYmmdd_YYmmdd/([0-5][0-9]{3}[01][0-9])01_[0-5][0-9]{3}[01][0-9](28|29|30|31)/g' ) 
    149149 
    150150       # On balaye le repertoire avec le(s) pattern(s) transforme(s) pour capturer les annees 
     
    162162    awk '{ 
    163163        if (NR==1) {avant=$1; print $1} 
    164         else { for (i=avant+1 ; i<=$1 ; i++) print i}}' 
     164        else { for (i=avant+1 ; i<=$1 ; i++) printf "%04i\n", i}}' 
    165165} 
    166166sort -u /tmp/$$.dates > /tmp/$$.toutes_dates 
     
    227227           # On transforme le pattern pour mettre une sequences   
    228228           # avec le mois courant 
    229            px=$(echo $pattern | sed -e "s/YYmmdd_YYmmdd/([0-2][0-9]{3})${mois}01_[0-2][0-9]{3}${mois}(28|29|30|31)/g" ) 
     229           px=$(echo $pattern | sed -e "s/YYmmdd_YYmmdd/([0-5][0-9]{3})${mois}01_[0-5][0-9]{3}${mois}(28|29|30|31)/g" ) 
    230230 
    231231           # On balaye le repertoire avec le(s) pattern(s) transforme(s) pour capturer les tailles des fichiers de ce mois 
  • branches/libIGCM_MPI_OpenMP/libIGCM_post/libIGCM_post.ksh

    r457 r571  
    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  PackFrequency=false 
     29  TimeSeriesFrequency=false 
     30  SeasonalFrequency=false 
     31  unset list_post 
     32  # 
     33  # ONLY IF SOMETHING NEEDS TO BE DONE (EATHER TIME SERIES OR SEASONAL) COMPUTE THE MODULOS 
     34  # 
     35  if [ X${AsynchronousRebuild} = Xtrue ] ; then 
     36    list_post="RebuildFrequency" 
     37  fi 
     38  # 
     39  if [ X${Pack} = Xtrue ] ; then 
     40    list_post="${list_post} PackFrequency" 
     41  fi 
     42  # 
     43  if ( [ X${TimeSeries} = Xtrue ] || [ X${TimeSeries2D} = Xtrue ] || [ X${TimeSeries3D} = Xtrue ] ) ; then 
     44    list_post="${list_post} TimeSeriesFrequency" 
     45  fi 
     46  # 
     47  if [ X${Seasonal} = Xtrue ] ; then 
     48    list_post="${list_post} SeasonalFrequency" 
     49  fi 
     50 
     51  # Overrule special cases 
     52  if ( [ ! X${config_Post_TimeSeriesFrequency} = X${NULL_STR} ] && \ 
     53    [ ! X${config_Post_TimeSeriesFrequency} = XNONE ]           && \ 
     54    [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then 
     55    TimeSeriesFrequency=true 
     56    POST=true 
     57  fi 
     58  # 
     59  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then 
     60    RebuildFrequency=true 
     61    POST=true 
     62  fi 
     63 
     64  # READ REBUILD OR TIME SERIES OR SEASONAL FREQUENCY 
     65  # AND TURN ON THE SUBMISSION FLAG WHEN MODULO IS ZERO 
     66  for post_freq in ${list_post} ; do 
     67    # Extract frequency from previously defined variable 
     68    config_Post_post_freq=$( eval echo \${config_Post_${post_freq}} ) 
     69    # Offset for Seasonal Average starting period 
     70    if [ ${post_freq} = SeasonalFrequency ] ; then 
     71      if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then 
     72        PeriodOffset=0 
     73      else 
     74        PeriodOffset=${config_Post_SeasonalFrequencyOffset} 
     75      fi 
     76    else 
     77      PeriodOffset=0 
    3578    fi 
    36     # 
    37     if ( [ X${TimeSeries} = Xtrue ] || [ X${TimeSeries2D} = Xtrue ] || [ X${TimeSeries3D} = Xtrue ] ) ; then 
    38         list_post="${list_post} TimeSeriesFrequency" 
     79    # Compute Modulo between frequencys (/!\second argument will be multiplied by CumuPeriod/!\) 
     80    # RebuildFrequency needs additionnal information 
     81    if [ ${post_freq} = RebuildFrequency ] ; then 
     82      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength NbRebuildDir 
     83    else 
     84      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength 
    3985    fi 
    4086    # 
    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" 
     87    IGCM_debug_Print 1 "${post_freq} flag value : ${RebuildFrequency}" 
     88  done 
     89  # 
     90  IGCM_debug_Print 2 "POST-TREATEMENT flag value : ${POST}" 
     91  # 
     92  IGCM_debug_PopStack "IGCM_post_Configure" 
    8993} 
    9094 
    9195function IGCM_post_Submit 
    9296{ 
    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 
     97  IGCM_debug_PushStack "IGCM_post_Submit" 
     98 
     99  typeset listVarEnv DaysTemp 
     100 
     101  #POST_DIR=${R_OUT_POST}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
     102  POST_DIR=${R_BUF_KSH} 
     103  # trick for IDRIS 
     104  POST_DIR=$( echo ${R_BUF_KSH} | sed -e "s/workgpfs/workdir/" ) 
     105 
     106  if [ ${POST} = true ]; then 
     107    echo 
     108    IGCM_debug_Print 1 "IGCM_post_Submit" 
     109    echo 
     110    IGCM_debug_Print 2 "POST_DIR = ${POST_DIR}" 
     111  fi 
     112 
     113  #============ TIME SERIES POST-PROCESSING ===========# 
     114  if [ ${TimeSeriesFrequency} = true ] ; then 
     115 
     116    IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ACTIVATED" 
     117    echo 
     118 
     119 
     120 
     121    # Get information from last execution 
     122    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted 
     123    CompletedFlag=${run_PostProcessing_TimeSeriesCompleted} 
     124    # 
     125 
     126 
     127 
     128    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" 
     129    # 
     130    jLoop=${#ListDimension[*]} 
     131    j=0 
     132    until [ $j -ge ${jLoop} ]; do 
     133      Dimension=${ListDimension[${j}]} 
     134      # 
     135      if [ X$( eval echo \${TimeSeries${Dimension}} ) = Xtrue ] ; then 
     136        # 
     137        IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED" 
    100138        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} 
    117139        # 
    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" 
     140        if [ X${Dimension} = X ] ; then 
     141          TsTask="empty" 
     142          Script_Post_Output=create_ts.${PeriodDateEnd} 
     143        else 
     144          TsTask=${Dimension} 
     145          Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask} 
     146        fi 
    122147        # 
    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 
     148        if [ ${RebuildFrequency} = true ] ; then 
     149          # 
     150          if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
     151#           if [ X${MASTER} = Xtitane ] ; then 
     152#             echo "IGCM_sys_RshPost <<-EOF"                       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     153#           fi 
     154            echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     155            echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     156            echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     157            echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     158            echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     159            echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     160            echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     161            echo "export RebuildFrequency=${RebuildFrequency}    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     162            echo "export DateBegin=${DateBegin}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     163            echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     164            echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     165            echo "export CompletedFlag=${CompletedFlag}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     166            echo "export TsTask=${TsTask}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     167            echo "unset  CompToRead                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     168            echo "unset  FlagToRead                              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     169            echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     170            echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     171            echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     172            echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     173            echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     174            echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     175            echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     176            echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     177#           if [ X${MASTER} = Xtitane ] ; then 
     178#             echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     179#             echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     180#           fi 
     181            echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     182            echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     183            echo "IGCM_sys_QsubPost create_ts                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     184#           if [ X${MASTER} = Xtitane ] ; then 
     185#             echo "EOF"                                           >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     186#           fi 
     187          fi 
     188        else 
     189          IGCM_sys_RshPost <<-EOF 
    185190                    export DEBUG_debug=${DEBUG_debug} 
    186191                    export MODIPSL=${MODIPSL} 
     
    212217                    IGCM_sys_QsubPost create_ts 
    213218EOF 
    214                 fi 
     219        fi 
     220      fi 
     221      # 
     222      if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then 
     223        # 
     224        IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} WITH CHUNCK ACTIVATED" 
     225        echo 
     226        # Need to Remember This One 
     227        SavedDateBegin=${DateBegin} 
     228        # Kind of task create_ts will perform 
     229        TsTask=Chunck${Dimension} 
     230        # Number of chunck jobs to configure and submit 
     231        eval NbJob=\${#CHUNCK${Dimension}_COMP[@]} 
     232        typeset i 
     233        i=0 
     234        until [ $i -ge $NbJob ]; do 
     235          CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} ) 
     236          FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} ) 
     237          NameToRead=$( eval echo \${CHUNCK${Dimension}_NAME[\${i}]} ) 
     238          ChunckSize=$( eval echo \${CHUNCK${Dimension}_SIZE[\${i}]} ) 
     239          # Chunck Length (mandatory in Year) 
     240          YearsChunckLength=$( echo ${ChunckSize} | sed -e "s/[yY]//" ) 
     241          # 
     242          IGCM_date_GetYearMonth ${DateBegin}     YearBegin MonthBegin 
     243          # 
     244          IGCM_date_GetYearMonth ${PeriodDateEnd} YearEnd   MonthEnd 
     245          # How many chunck in total since simulation began 
     246          NbYearsChunckLoop=$(( ( ${YearEnd} - ${YearBegin} + 1 ) / ${YearsChunckLength} )) 
     247          #  Tweak special case 
     248          [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 )) 
     249          # Starting Year of the current chunck 
     250          ChunckTsYearBegin=$(( ${NbYearsChunckLoop} *  ${YearsChunckLength} + ${YearBegin} )) 
     251          # Starting date of the current chunck 
     252          ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01 
     253          # 
     254          Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}.${CompToRead}.${NameToRead} 
     255          # 
     256          if [ ${RebuildFrequency} = true ] ; then 
     257            # 
     258            if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
     259#             if [ X${MASTER} = Xtitane ] ; then 
     260#               echo "IGCM_sys_RshPost <<-EOF"                       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     261#             fi 
     262              echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     263              echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     264              echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     265              echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     266              echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     267              echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     268              echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     269              echo "export RebuildFrequency=${RebuildFrequency}    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     270              echo "export DateBegin=${ChunckTsDateBegin}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     271              echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     272              echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     273              echo "export CompletedFlag=${CompletedFlag}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     274              echo "export TsTask=${TsTask}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     275              echo "export CompToRead=${CompToRead}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     276              echo "export FlagToRead=${FlagToRead}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     277              echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     278              echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     279              echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     280              echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     281              echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     282              echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     283              echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     284              echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     285#             if [ X${MASTER} = Xtitane ] ; then 
     286#               echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     287#               echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     288#             fi 
     289              echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     290              echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     291              echo "IGCM_sys_QsubPost create_ts                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     292#             if [ X${MASTER} = Xtitane ] ; then 
     293#               echo "EOF"                                           >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     294#             fi 
    215295            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 
     296          else 
     297            IGCM_sys_RshPost <<-EOF 
    295298                        export DEBUG_debug=${DEBUG_debug} 
    296299                        export MODIPSL=${MODIPSL} 
     
    322325                        IGCM_sys_QsubPost create_ts 
    323326EOF 
    324                         # 
    325                     fi 
    326                     # 
    327                     export DateBegin=${SavedDateBegin} 
    328                     # 
    329                     (( i=i+1 )) 
    330                     # 
    331                 done 
    332             fi 
    333             (( j=j+1 )) 
     327          # 
     328          fi 
     329          # 
     330          export DateBegin=${SavedDateBegin} 
     331          # 
     332          (( i=i+1 )) 
     333          # 
    334334        done 
    335     fi 
    336  
    337     #=============  SEASONAL POST-TREATMENT ============# 
    338     if [ ${SeasonalFrequency} = true ] ; then 
    339         # 
    340         IGCM_debug_Print 1 "SEASONNAL POST-TREATMENT" 
    341         echo 
     335      fi 
     336      (( j=j+1 )) 
     337    done 
     338  fi 
     339 
     340  #=============  SEASONAL POST-PROCESSING ============# 
     341  if [ ${SeasonalFrequency} = true ] ; then 
     342    # 
     343    IGCM_debug_Print 1 "SEASONNAL POST-PROCESSING" 
     344    echo 
     345    # 
     346    Script_Post_Output=create_se.${PeriodDateEnd} 
     347    # 
     348    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" 
     349 
     350    if [ ${RebuildFrequency} = true ] ; then 
     351      # 
     352      if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 
    342353        # 
    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 
     354#       if [ X${MASTER} = Xtitane ] ; then 
     355#         echo "IGCM_sys_RshPost <<-EOF"                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     356#       fi 
     357        echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     358        echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     359        echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     360        echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     361        echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     362        echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     363        echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     364        echo "export RebuildFrequency=${RebuildFrequency}    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     365        echo "export DateBegin=${DateBegin}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     366        echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     367        echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     368        echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     369        echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     370        echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     371        echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     372        echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     373        echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     374        echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     375        echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     376#       if [ X${MASTER} = Xtitane ] ; then 
     377#         echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     378#         echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     379#       fi 
     380        echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     381        echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     382        echo "IGCM_sys_QsubPost create_se                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     383#       if [ X${MASTER} = Xtitane ] ; then 
     384#         echo "EOF"                                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 
     385#       fi 
     386      fi 
     387    else 
     388      IGCM_sys_RshPost <<-EOF 
    388389            export DEBUG_debug=${DEBUG_debug} 
    389390            export MODIPSL=${MODIPSL} 
     
    411412            IGCM_sys_QsubPost create_se 
    412413EOF 
    413         # 
    414         fi 
    415414    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 
     415  fi 
     416 
     417  #============== REBUILD POST-PROCESSING =============# 
     418  if [ X${AsynchronousRebuild} = Xtrue ] ; 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 
    431425    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} 
     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 
     431  fi 
     432  # 
     433  if [ ${RebuildFrequency} = true ] ; then 
     434    if ( [ ${config_Post_RebuildFromArchive} = true ] ) ; then 
     435      IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM ARCHIVE" 
     436      echo 
     437      # 
     438      script=rebuild_fromArchive 
     439    else 
     440      IGCM_debug_Print 1 "REBUILD POST-PROCESSING 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} 
    477477EOF 
    478  
    479     fi 
    480  
    481     IGCM_debug_PopStack "IGCM_post_Submit" 
     478  fi 
     479 
     480  #============== PACK PROCESSING FOR RESTART AND DEBUG FILES =============# 
     481  if [ ${PackFrequency} = true ] ; then 
     482    IGCM_debug_Print 1 "PACK POST-PROCESSING" 
     483    echo 
     484    ## Need to Remember This One 
     485    SavedDateBegin=${DateBegin} 
     486    ## Need to Remember This One 
     487    SavedDateEnd=${DateEnd} 
     488    # 
     489    DaysTemp=$(( $( IGCM_date_DaysInPreviousPeriod ${PeriodDateEnd} ${config_Post_PackFrequency} end ) - 1 )) 
     490    # 
     491    PackDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} -${DaysTemp} ) 
     492    # 
     493    script=pack_debug 
     494    # 
     495    Script_Post_Output=${script}.${PeriodDateEnd} 
     496    # 
     497    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,DateBegin,DateEnd,PeriodPack,StandAlone" 
     498    IGCM_sys_RshPost <<-EOF 
     499    export DEBUG_debug=${DEBUG_debug} 
     500    export MODIPSL=${MODIPSL} 
     501    export libIGCM_SX=${libIGCM} 
     502    export libIGCM=${libIGCM_POST} 
     503    export SUBMIT_DIR=${SUBMIT_DIR} 
     504    export POST_DIR=${POST_DIR} 
     505    export MASTER=${MASTER} 
     506    export DateBegin=${PackDateBegin} 
     507    export DateEnd=${PeriodDateEnd} 
     508    export PeriodPack=${config_Post_PackFrequency} 
     509    export StandAlone=false 
     510    export listVarEnv=${listVarEnv} 
     511    export Script_Post_Output=${Script_Post_Output} 
     512    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh 
     513    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh 
     514    IGCM_sys_MkdirWork ${POST_DIR} 
     515    IGCM_debug_Verif_Exit_Post 
     516    IGCM_sys_QsubPost ${script} 
     517EOF 
     518    # 
     519    script=pack_restart 
     520    # 
     521    Script_Post_Output=${script}.${PeriodDateEnd} 
     522    # 
     523    IGCM_sys_RshPost <<-EOF 
     524    export DEBUG_debug=${DEBUG_debug} 
     525    export MODIPSL=${MODIPSL} 
     526    export libIGCM_SX=${libIGCM} 
     527    export libIGCM=${libIGCM_POST} 
     528    export SUBMIT_DIR=${SUBMIT_DIR} 
     529    export POST_DIR=${POST_DIR} 
     530    export MASTER=${MASTER} 
     531    export DateBegin=${PackDateBegin} 
     532    export DateEnd=${PeriodDateEnd} 
     533    export PeriodPack=${config_Post_PackFrequency} 
     534    export StandAlone=false 
     535    export listVarEnv=${listVarEnv} 
     536    export Script_Post_Output=${Script_Post_Output} 
     537    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh 
     538    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh 
     539    IGCM_sys_MkdirWork ${POST_DIR} 
     540    IGCM_debug_Verif_Exit_Post 
     541    IGCM_sys_QsubPost ${script} 
     542EOF 
     543 
     544    export DateBegin=${SavedDateBegin} 
     545    export DateEnd=${SavedDateEnd} 
     546  fi 
     547  IGCM_debug_PopStack "IGCM_post_Submit" 
    482548} 
    483549 
     
    485551function IGCM_post_CheckModuloFrequency 
    486552{ 
    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" 
     553  IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $* 
     554 
     555  # Used by IGCM_config_Check 
     556  # from 2 libIGCM compatible frequency (*Y, *M, *D, *y, *m, *d) 
     557  # Issue an exit instruction IGCM_debug_Exit if there modulo is not zero 
     558  # Input parameter are the name of the variable, not the frequency value itself 
     559  # example 
     560  # IGCM_post_ModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength 
     561 
     562  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay 
     563 
     564  # Get the name of the variable 
     565  MasterName=$1 
     566  SlaveName=$2 
     567  # Get the value the above name points to 
     568  MasterFrequency=$( eval echo \${${1}} ) 
     569  SlaveFrequency=$( eval echo \${${2}} ) 
     570 
     571  IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}" 
     572 
     573  case ${MasterFrequency} in 
     574  *y|*Y) 
     575    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" ) 
     576    case ${SlaveFrequency} in 
     577    *Y|*y) 
     578      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
     579      if ( [ ${PeriodSlaveYear} -gt ${PeriodMasterYear} ] || \ 
     580        [ $(( ${PeriodMasterYear} % ${PeriodSlaveYear} )) -ne 0 ] );  then 
     581        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     582        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     583        IGCM_debug_Exit "Check your frequency" 
     584      fi ;; 
     585    *M|*m) 
     586      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
     587      if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \ 
     588        [ $(( ( ${PeriodMasterYear} * 12 ) % ${PeriodSlaveMonth} )) -ne 0 ] ) ; then 
     589        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     590        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     591        IGCM_debug_Exit "Check your frequency" 
     592      fi ;; 
     593    *D|*d) 
     594      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
     595      NbDays=$( IGCM_date_DaysInYear ${year} ) 
     596      if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then 
     597        if ( [ ${PeriodSlaveDay} -gt $(( ${PeriodMasterYear} * ${NbDays} )) ] || \ 
     598          [ $(( ( ${PeriodMasterYear} * ${NbDays} ) % ${PeriodSlaveDay} )) -ne 0 ] ; ) then 
     599          IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     600          IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     601          IGCM_debug_Exit "Check your frequency" 
     602        fi 
     603      else 
     604        IGCM_debug_Print 1 "For ${MasterName} with leap calendar:" 
     605        IGCM_debug_Print 1 "We have a daily ${SlaveName} frequency and ${MasterName}=${MasterFrequency}" 
     606        IGCM_debug_Print 1 "No post-treatment. Case not properly handle at this moment by libIGCM. Sorry" 
     607        IGCM_debug_Exit    "Check your frequency ${MasterName} and choose a daily frequency for this one too." 
     608      fi ;; 
     609    esac ;; 
     610  *M|*m) 
     611    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" ) 
     612    case ${SlaveFrequency} in                
     613    *Y|*y) 
     614      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
     615      if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \ 
     616        [ $(( ${PeriodMasterMonth} % ( ${PeriodSlaveYear} * 12 ) )) -ne 0 ] ) ; then 
     617        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     618        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     619        IGCM_debug_Exit "Check your frequency" 
     620      fi ;; 
     621    *M|*m) 
     622      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
     623      if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \ 
     624        [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then            
     625        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     626        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     627        IGCM_debug_Exit "Check your frequency" 
     628      fi ;; 
     629    *D|*d) 
     630      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     631      IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     632      IGCM_debug_Exit "Check your frequency" ;; 
     633    esac ;; 
     634  *D|*d) 
     635    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" ) 
     636    case ${SlaveFrequency} in 
     637    *Y|*y) 
     638      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     639      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}" 
     640      IGCM_debug_Exit "Check your frequency" ;; 
     641    *M|*m) 
     642      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     643      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}" 
     644      IGCM_debug_Exit "Check your frequency" ;; 
     645    *D|*d) 
     646      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
     647      if ( [ ${PeriodSlaveDay} -gt ${PeriodMasterDay} ] || \ 
     648        [ $(( ${PeriodMasterDay} % ${PeriodSlaveDay} )) -ne 0 ] ) ;  then 
     649        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with" 
     650        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}" 
     651        IGCM_debug_Exit "Check your frequency" 
     652      fi ;; 
     653    esac ;; 
     654  NONE|none) 
     655    ;; 
     656  *) 
     657    IGCM_debug_Print 1 "KeyWord ${MasterFrequency} not allowed for ${MasterName} in config.card" 
     658    IGCM_debug_Exit "Check your ${MasterName} in config.card" ;; 
     659  esac 
     660 
     661  IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency" 
    596662} 
    597663 
     
    599665function IGCM_post_ModuloRuntimeFrequency 
    600666{ 
    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" 
     667  IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $* 
     668 
     669  # Used by IGCM_post_Configure 
     670  # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and  
     671  # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d) 
     672  # --> turn on post-processing submission when their modulo is zero 
     673  # Input parameter are the name of the variable, not the frequency value itself 
     674  # example 
     675  # IGCM_post_ModuloRuntimeFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength 
     676 
     677  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay 
     678 
     679  # Get the name of the variable 
     680  MasterName=$1 
     681  SlaveName=$2 
     682   
     683  # Get the value the above name points to 
     684  eval MasterFrequency=\${${1}} 
     685  eval SlaveFrequency=\${${2}} 
     686 
     687  echo 
     688  IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}" 
     689 
     690  case ${MasterFrequency} in 
     691  *y|*Y) 
     692    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" ) 
     693    case ${SlaveFrequency} in 
     694    *Y|*y) 
     695      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
     696      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} ) % ${PeriodMasterYear} )) -eq 0 ] ;  then 
     697        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then 
     698          eval ${post_freq}=true ; POST=true 
     699          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} )) 
     700        fi 
     701      fi;; 
     702    *M|*m) 
     703      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
     704      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then 
     705        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 )) -ne 0 ] ; then 
     706          eval ${post_freq}=true ; POST=true 
     707          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} )) 
     708        fi 
     709      fi;; 
     710    *D|*d) 
     711      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
     712      NbDays=$( IGCM_date_DaysInYear ${year} ) 
     713      if [ $(( ( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) ) % ( ${NbDays} * ${PeriodMasterYear} / ${PeriodSlaveDay} ) )) -eq 0 ] ; then 
     714        if [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) )) -ne 0 ] ; then 
     715          eval ${post_freq}=true ; POST=true 
     716          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ( ${NbDays} * ${PeriodMasterYear} ) / ${PeriodSlaveDay} )) 
     717        fi 
     718      fi;; 
     719    esac ;; 
     720  *M|*m) 
     721    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" ) 
     722    case ${SlaveFrequency} in 
     723    *Y|*y) 
     724      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" ) 
     725      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} ) % ( ${PeriodMasterMonth} ) )) -eq 0 ] ; then 
     726        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} )) -ne 0 ] ; then 
     727          eval ${post_freq}=true ; POST=true 
     728          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) )) 
     729        fi 
     730      fi;; 
     731    *M|*m) 
     732      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" ) 
     733      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then 
     734        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then  
     735          eval ${post_freq}=true ; POST=true 
     736          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} )) 
     737        fi 
     738      fi;; 
     739    *D|*d) 
     740      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with" 
     741      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;; 
     742    esac ;; 
     743  *D|*d) 
     744    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" ) 
     745    case ${SlaveFrequency} in 
     746    *Y|*y) 
     747      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with" 
     748      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;; 
     749    *M|*m) 
     750      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with" 
     751      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;; 
     752    *D|*d) 
     753      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" ) 
     754      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} ) % ${PeriodMasterDay} )) -eq 0 ] ;  then 
     755        if [ $(( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} )) -ne 0 ] ; then 
     756          eval ${post_freq}=true ; POST=true 
     757          [ X${3} = XNbRebuildDir ] && NbRebuildDir=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} )) 
     758        fi 
     759      fi;; 
     760    esac ;; 
     761  NONE|none) 
     762    ;; 
     763  *) 
     764    IGCM_debug_Print 1 "KeyWord not allowed for ${post_freq} in config.card" 
     765    ;; 
     766  esac 
     767 
     768  IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency" 
    703769} 
  • branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_cesium.ksh

    r521 r571  
    117117#==================================================== 
    118118#- IN 
    119 typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM} 
     119typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM} 
    120120typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data} 
    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} 
     438} 
     439 
     440#D-#================================================== 
     441#D-function IGCM_sys_IsFileArchived 
     442#D-* Purpose: Test file that must NOT EXISTS on Archive 
     443#D-* Examples: 
     444#D- 
     445function IGCM_sys_IsFileArchived { 
     446  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ 
     447  if ( $DEBUG_sys ) ; then 
     448    echo "IGCM_sys_IsFileArchived :" $@ 
     449  fi 
     450  typeset IsArchivedFlag 
     451  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/dmnfs ) != X ] && echo 0 || echo 1 ) 
     452  IGCM_debug_PopStack "IGCM_sys_IsFileArchived" 
     453 
     454  return ${IsArchivedFlag} 
    428455} 
    429456 
     
    434461#D- 
    435462function 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} 
     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} 
    445486} 
    446487 
     
    451492#D- 
    452493function 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" 
     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 Master 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" 
    459514} 
    460515 
     
    465520#D- 
    466521function 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" 
     522  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     523  if ( $DEBUG_sys ) ; then 
     524    echo "IGCM_sys_Tree :" $@ 
     525  fi 
     526 
     527  \tree -f $@ 
     528 
     529  IGCM_debug_PopStack "IGCM_sys_Tree" 
    475530} 
    476531 
    477532#D-#================================================== 
    478533#D-function IGCM_sys_Tar 
    479 #D-* Purpose: master un-tar command 
     534#D-* Purpose: master tar command 
    480535#D-* Examples: 
    481536#D- 
    482537function 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" 
     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" 
    495548} 
    496549 
     
    501554#D- 
    502555function 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" 
     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" 
    513566} 
    514567 
     
    519572#D- 
    520573function 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" 
     574  IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
     575  if ( $DEBUG_sys ) ; then 
     576    echo "IGCM_sys_Qsub :" $@ 
     577  fi 
     578  /usr/local/bin/ccc_msub -o ${Script_Output} -e ${Script_Output}.e < $1 
     579  if [ $? -gt 0 ] ; then 
     580    echo "IGCM_sys_Qsub : erreur  -o ${Script_Output} -e ${Script_Output}.e $@" 
     581    IGCM_debug_Exit "IGCM_sys_Qsub" 
     582  fi 
     583  IGCM_debug_PopStack "IGCM_sys_Qsub" 
    531584} 
    532585 
     
    537590#D- 
    538591function 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" 
     592  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     593  if ( $DEBUG_sys ) ; then 
     594    echo "IGCM_sys_QsubPost :" $@ 
     595  fi 
     596  /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 
     597  if [ $? -gt 0 ] ; then 
     598    echo "IGCM_sys_QsubPost : erreur " $@ 
     599    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     600  fi 
     601  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    549602} 
    550603 
     
    560613#D-  Error values and explanations can depend on your system version. 
    561614function 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      
     615  RET=$1 
     616  if [ ! $RET ] ; then 
     617    echo "rsync error !" 
     618  fi 
     619 
     620  if [ $MYLANG = "fr" ]; then 
     621    case $RET in 
     622    0)  return ;; 
     623    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     624      echo "Erreur de syntaxe ou d'utilisation." 
     625      return;; 
     626    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     627      echo "Incompatibilité de protocole." 
     628      return;; 
     629    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     630      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     631      echo "répertoires" 
     632      return;; 
     633    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     634      echo "Action demandée non supportée : une tentative de manipulation de" 
     635      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     636      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     637      echo "pas par le serveur a été spécifiée." 
     638      return;; 
     639    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     640      echo "Erreur dans le socket d'entrée sortie" 
     641      return;; 
     642    11) echo "Erreur de rsync ; RERR_FILEIO" 
     643      echo "Erreur d'entrée sortie fichier" 
     644      return;; 
     645    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     646      echo "Erreur dans flux de donnée du protocole rsync" 
     647      return;; 
     648    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     649      echo "Erreur avec les diagnostics du programme" 
     650      return;; 
     651    14) echo "Erreur de rsync ; RERR_IPC" 
     652      echo "Erreur dans le code IPC" 
     653      return;; 
     654    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     655      echo "SIGUSR1 ou SIGINT reçu" 
     656      return;; 
     657    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     658      echo "Une erreur retournée par waitpid()" 
     659      return;; 
     660    22) echo "Erreur de rsync ; RERR_MALLOC" 
     661      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     662      return;; 
     663    23) echo "" 
     664      echo "Erreur fichier inexistant" 
     665      return;; 
     666    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     667      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     668      return;; 
     669    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     670      return;; 
     671    esac 
     672  elif [ $MYLANG = "en" ] ; then 
     673    case $RET in 
     674    0)  return;;                 
     675    1)  echo "rsync error : Syntax or usage error " 
     676      return;; 
     677    2)  echo "rsync error : Protocol incompatibility " 
     678      return;; 
     679    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     680      return;; 
     681    4)  echo "rsync error : Requested action not supported: an attempt" 
     682      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     683      echo "them; or an option was specified that is supported by the client and" 
     684      echo "not by the server." 
     685      return;; 
     686    5)  echo "rsync error : Error starting client-server protocol" 
     687      return;; 
     688    10) echo "rsync error : Error in socket I/O " 
     689      return;; 
     690    11) echo "rsync error : Error in file I/O " 
     691      return;; 
     692    12) echo "rsync error : Error in rsync protocol data stream " 
     693      return;; 
     694    13) echo "rsync error : Errors with program diagnostics " 
     695      return;; 
     696    14) echo "rsync error : Error in IPC code " 
     697      return;; 
     698    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     699      return;; 
     700    21) echo "rsync error : Some error returned by waitpid() " 
     701      return;; 
     702    22) echo "rsync error : Error allocating core memory buffers " 
     703      return;; 
     704    23) echo "rsync error : Partial transfer due to error" 
     705      return;; 
     706    24) echo "rsync error : Partial transfer due to vanished source files" 
     707      return;; 
     708    30) echo "rsync error : Timeout in data send/receive " 
     709      return;; 
     710    *)  echo "rsync error : return code of rsync unknown :" $RET 
     711      return;; 
     712    esac 
     713  else 
     714    echo "unknown language $MYLANG." 
     715    return 
     716  fi 
     717} 
     718 
    666719#D-#================================================== 
    667720#D-function IGCM_sys_Cp 
     
    670723#D- 
    671724function 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" 
     725  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     726  if ( $DEBUG_sys ) ; then 
     727    echo "IGCM_sys_Cp :" $@ 
     728  fi 
     729 
     730  typeset RET 
     731 
     732  echo cp $@ > out_rsync 2>&1 
     733  \cp $@ >> out_rsync 2>&1 
     734  RET=$? 
     735 
     736  if [ ${RET} -gt 0 ] ; then 
     737    echo "IGCM_sys_Cp : error." 
     738    cat out_rsync 
     739    IGCM_debug_Exit "IGCM_sys_Cp" 
     740  else 
     741    \rm out_rsync 
     742  fi 
     743  IGCM_debug_PopStack "IGCM_sys_Cp" 
    691744} 
    692745 
     
    697750#D- 
    698751function 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" 
     752  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     753  if ( $DEBUG_sys ) ; then 
     754    echo "IGCM_sys_Rm :" $@ 
     755  fi 
     756 
     757  typeset RET 
     758 
     759  echo rm $@ > out_rsync 2>&1 
     760  \rm $@ >> out_rsync 2>&1 
     761  RET=$? 
     762 
     763  if [ ${RET} -gt 0 ] ; then 
     764    echo "IGCM_sys_Rm : error." 
     765    cat out_rsync 
     766    IGCM_debug_Exit "IGCM_sys_Rm" 
     767  else 
     768    \rm out_rsync 
     769  fi 
     770  IGCM_debug_PopStack "IGCM_sys_Rm" 
    718771} 
    719772 
     
    725778#D- 
    726779function 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" 
     780  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
     781  if ( $DEBUG_sys ) ; then 
     782    echo "IGCM_sys_RmRunDir :" $@ 
     783  fi 
     784 
     785  typeset RET 
     786 
     787  echo rm $@ > out_rsync 2>&1 
     788  \rm $@ >> out_rsync 2>&1 
     789  RET=$? 
     790 
     791  if [ ${RET} -gt 0 ] ; then 
     792    echo "IGCM_sys_RmRunDir : error." 
     793    cat out_rsync 
     794    IGCM_debug_Exit "IGCM_sys_RmRunDir" 
     795  else 
     796    \rm out_rsync 
     797  fi 
     798  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    747799} 
    748800 
     
    753805#D- 
    754806function 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=$? 
     807  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     808  if ( $DEBUG_sys ) ; then 
     809    echo "IGCM_sys_Mv :" $@ 
     810  fi 
     811 
     812  if [ $DRYRUN = 0 ]; then 
     813 
     814    typeset RET 
    767815     
    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 
     816    echo mv $@ > out_rsync 2>&1 
     817    \mv $@ >> out_rsync 2>&1 
     818    RET=$? 
     819     
     820    if [ ${RET} -gt 0 ] ; then 
     821      echo "IGCM_sys_Mv : error in mv." 
     822      cat out_rsync 
     823      IGCM_debug_Exit "IGCM_sys_Mv" 
    775824    else 
    776         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    777     fi 
    778  
    779     IGCM_debug_PopStack "IGCM_sys_Mv" 
     825      \rm out_rsync 
     826    fi 
     827  else 
     828    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     829  fi 
     830 
     831  IGCM_debug_PopStack "IGCM_sys_Mv" 
    780832} 
    781833 
     
    786838#D- 
    787839function 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 
     840  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     841  if ( $DEBUG_sys ) ; then 
     842    echo "IGCM_sys_Put_Dir :" $@ 
     843  fi 
     844  if [ $DRYRUN = 0 ]; then 
     845    if [ ! -d ${1} ] ; then 
     846      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     847      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     848      return 
     849    fi 
     850 
     851    typeset RET 
     852 
     853    # Only if we use rsync 
     854    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     855    # 
     856    #USUAL WAY 
     857    \cp -r $1 $2 > out_rsync 2>&1 
     858    RET=$? 
     859 
     860    if [ ${RET} -gt 0 ] ; then 
     861      echo "IGCM_sys_Put_Dir : error." 
     862      cat out_rsync 
     863      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    815864    else 
    816         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    817     fi 
    818     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     865      \rm out_rsync 
     866    fi 
     867  else 
     868    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     869  fi 
     870  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    819871} 
    820872 
    821873#D-#================================================== 
    822874#D-function IGCM_sys_Get_Dir 
    823 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     875#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    824876#D-* Examples: 
    825877#D- 
    826878function 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 
     879  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     880  if ( $DEBUG_sys ) ; then 
     881    echo "IGCM_sys_Get_Dir :" $@ 
     882  fi 
     883  if [ $DRYRUN = 0 ]; then 
     884#    if [ ! -d ${1} ] ; then 
     885#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     886#      IGCM_debug_PopStack "IGCM_sys_Get_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    # add dmfind/dmget (to demigrate all offline files) : 
     897    dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget 
     898    \cp -r $1 $2 > out_rsync 2>&1 
     899    RET=$? 
     900 
     901    if [ ${RET} -gt 0 ] ; then 
     902      echo "IGCM_sys_Get_Dir : error." 
     903      cat out_rsync 
     904      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    856905    else 
    857         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    858     fi 
    859     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     906      \rm out_rsync 
     907    fi 
     908  else 
     909    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     910  fi 
     911  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    860912} 
    861913 
     
    866918#D- 
    867919function 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 
     920  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
     921  if ( $DEBUG_sys ) ; then 
     922    echo "IGCM_sys_Get_Master :" $@ 
     923  fi 
     924  if [ $DRYRUN = 0 ]; then 
     925 
     926    typeset TEST NB_ESSAI DELAI status i 
     927     
     928    TEST=$( IGCM_sys_RshMaster [ -d $1 ] && echo 1 || echo 0 ) 
     929    if [ ${TEST} -ne 1 ] ; then 
     930      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ON ${MASTER}." 
     931      IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     932      return 
     933    fi 
     934 
     935    # number of tentative 
     936    NB_ESSAI=10 
     937    # time delay between tentative 
     938    DELAI=10 
     939    # 
     940    (( i = 0 )) 
     941    while [ $i -lt $NB_ESSAI ] ; do 
    890942            #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 
     943      scp -r ${MASTER}:$1 $2 > out_rsync 2>&1 
     944      status=$? 
     945      if [ ${status} -gt 0 ]; then 
     946        IGCM_debug_Print 2 "IGCM_sys_Get_Master : scp failed ${i}/${NB_ESSAI}" 
     947        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 
     948        sleep $DELAI 
     949      else 
     950        break 
     951      fi 
     952      (( i = i + 1 )) 
     953    done 
     954 
     955    if [ ${status} -gt 0 ] ; then 
     956      echo "IGCM_sys_Get_Master : error." 
     957      cat out_rsync 
     958      IGCM_debug_Exit "IGCM_sys_Get_Master" 
    910959    else 
    911         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    912     fi 
    913     IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     960      \rm out_rsync 
     961    fi 
     962  else 
     963    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     964  fi 
     965  IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    914966} 
    915967 
    916968#D-#================================================== 
    917969#D-function IGCM_sys_Put_Rest 
    918 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     970#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    919971#D-           File and target directory must exist. 
    920972#D-* Examples: 
    921973#D- 
    922974function 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=$? 
     975  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     976  if ( $DEBUG_sys ) ; then 
     977    echo "IGCM_sys_Put_Rest :" $@ 
     978  fi 
     979  if [ $DRYRUN = 0 ]; then 
     980    if [ ! -f ${1} ] ; then 
     981      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     982      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     983    fi 
     984 
     985    typeset RET 
     986    # 
     987    if [ X${JobType} = XRUN ] ; then 
     988      IGCM_sys_Chmod 444 ${1} 
     989    fi 
     990 
     991    # 
     992    # USUAL WAY 
     993    \cp $1 $2 > out_rsync 2>&1 
     994    RET=$? 
    944995 
    945996#       #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 
     997#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     998#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    948999 
    9491000#       #RSYNC WITH NFS USE 
     
    9571008#       (( RET=RET+$? )) 
    9581009 
    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 
     1010    if [ ${RET} -gt 0 ] ; then 
     1011      echo "IGCM_sys_Put_Rest : error." 
     1012      cat out_rsync 
     1013      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    9661014    else 
    967         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    968     fi 
    969     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1015      \rm out_rsync 
     1016    fi 
     1017  else 
     1018    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1019  fi 
     1020  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
    9701021} 
    9711022 
    9721023#D-#================================================== 
    9731024#D-function IGCM_sys_Put_Out 
    974 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     1025#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    9751026#D-* Examples: 
    9761027#D- 
    9771028function 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 
     1029  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     1030  if ( $DEBUG_sys ) ; then 
     1031    echo "IGCM_sys_Put_Out :" $@ 
     1032  fi 
     1033  if [ $DRYRUN = 0 ]; then 
     1034    if [ ! -f ${1} ] ; then 
     1035      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     1036      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1037      return 1 
     1038    fi 
     1039    # 
     1040    IGCM_sys_MkdirArchive $( dirname $2 ) 
     1041    # 
     1042    typeset RET exist skip 
     1043 
     1044    #===================================================== 
     1045    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1046    #===================================================== 
     1047 
     1048    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     1049    #if [ $? -eq 0 ] ; then 
     1050    #    typeset WORKPATH FILEPATH 
     1051    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     1052    #    IGCM_sys_MkdirWork ${WORKPATH}  
     1053    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     1054    #    # 
     1055    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1056    #fi 
     1057 
     1058    if [ X${JobType} = XRUN ] ; then 
     1059      if [ X${3} = X ] ; then 
     1060        IGCM_sys_Chmod 444 ${1} 
     1061      fi 
     1062    fi 
     1063 
     1064    exist=false 
     1065    skip=false 
     1066    if [ -f $2 ] ; then 
     1067      IGCM_debug_Print 1 "$2 already exist" 
     1068      dmget $2 
     1069      exist=true 
     1070      if [ "X$( diff $1 $2 )" = X ] ; then 
     1071        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
     1072        skip=true 
     1073      else 
     1074        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    10141075        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 
     1076      fi 
     1077    fi 
    10271078        #  
    1028         if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
    1029             IGCM_sys_Chmod u+w $2 
    1030         fi 
     1079    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
     1080      IGCM_sys_Chmod u+w $2 
     1081    fi 
    10311082        # 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 
     1083    if [ X${skip} = Xfalse ] ; then 
     1084      cp $1 $2 > out_rsync 2>&1 
     1085      RET=$? 
     1086      if [ ${RET} -gt 0 ] ; then 
     1087        echo "IGCM_sys_Put_Out : error." 
     1088        cat out_rsync 
     1089        IGCM_debug_Exit "IGCM_sys_Put_Out" 
     1090      else 
     1091        \rm out_rsync 
     1092      fi 
     1093    fi 
    10431094 
    10441095#       #RSYNC WITH NETWORK RSH CALL 
     
    10571108 
    10581109 
    1059     else 
    1060         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1061     fi 
    1062     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1063     return 0 
     1110  else 
     1111    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1112  fi 
     1113  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1114  return 0 
    10641115} 
    10651116 
     
    10701121#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    10711122function 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 
     1123  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1124 
     1125  typeset DEST RET dm_liste ifile target file_work  
     1126 
     1127  if ( $DEBUG_sys ) ; then 
     1128    echo "IGCM_sys_Get :" $@ 
     1129  fi 
     1130  if [ $DRYRUN -le 2 ]; then 
     1131    if [ X${1} = X'/l' ] ; then 
     1132      # test if the first file is present in the old computation : 
     1133      eval set +A dm_liste \${${2}} 
     1134    else 
     1135      eval set +A dm_liste ${1} 
     1136    fi 
     1137    eval DEST=\${${#}} 
     1138 
     1139    #===================================================== 
     1140    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1141    #===================================================== 
     1142 
     1143    # Is it an R_OUT file (not R_IN) ? 
     1144    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1145    #if [ $? -eq 0 ] ; then 
     1146    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1147    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1148    #    if [ -f ${file_work[0]} ] ; then 
     1149    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1150    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1151    #   return 
     1152    #    fi 
     1153    #fi 
     1154 
     1155    # test if the (first) file is present in the old computation : 
     1156    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1157    RET=$? 
     1158    if [ ${RET} -gt 0 ] ; then 
     1159      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1160      IGCM_debug_Exit "IGCM_sys_Get" 
     1161    fi 
     1162 
     1163    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1164    RET=$? 
     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    #if [ ${RET} -gt 0 ] ; then 
     1171    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1172    #   cat out_rsync 
     1173    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1174    #   sleep 30 
     1175    #   echo "We try another time" 
     1176    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1177    #   RET=$? 
     1178    #   if [ ${RET} -gt 0 ] ; then 
     1179    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1180    #       cat out_rsync 
     1181    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1182    #   fi 
     1183    #    else 
     1184    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1185    #   cat out_rsync 
     1186    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1187    #    fi 
     1188    #fi 
     1189 
     1190    #USUAL WAY 
     1191    if [ X${1} = X'/l' ] ; then 
     1192      (( RET=0 )) 
     1193      for target in ${dm_liste[*]} ; do 
     1194        local_file=$( basename ${target} ) 
     1195        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1196        (( RET = RET + $? )) 
     1197      done 
     1198    else 
     1199      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1200      RET=$? 
     1201    fi 
    11541202 
    11551203#       #RSYNC WITH NETWORK SSH CALL 
     
    11671215#       (( RET=RET+$? )) 
    11681216 
    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 
     1217    if [ ${RET} -gt 0 ] ; then 
     1218      echo "IGCM_sys_Get : copy error." 
     1219      cat out_rsync 
     1220      IGCM_debug_Exit "IGCM_sys_Get" 
    11761221    else 
    1177         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1178     fi 
    1179     IGCM_debug_PopStack "IGCM_sys_Get" 
     1222      \rm out_rsync 
     1223    fi 
     1224  else 
     1225    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1226  fi 
     1227  IGCM_debug_PopStack "IGCM_sys_Get" 
     1228} 
     1229 
     1230#D-#================================================== 
     1231#D-function IGCM_sys_GetBuffer 
     1232#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1233#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1234#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1235function IGCM_sys_GetBuffer { 
     1236  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1237 
     1238  typeset DEST RET buf_liste ifile target file_work  
     1239 
     1240  if ( $DEBUG_sys ) ; then 
     1241    echo "IGCM_sys_GetBuffer :" $@ 
     1242  fi 
     1243  if [ $DRYRUN -le 2 ]; then 
     1244    if [ X${1} = X'/l' ] ; then 
     1245      # test if the first file is present in the old computation : 
     1246      eval set +A buf_liste \${${2}} 
     1247    else 
     1248      eval set +A buf_liste ${1} 
     1249    fi 
     1250    eval DEST=\${${#}} 
     1251 
     1252    #USUAL WAY 
     1253    if [ X${1} = X'/l' ] ; then 
     1254      (( RET=0 )) 
     1255      for target in ${buf_liste[*]} ; do 
     1256        local_file=$( basename ${target} ) 
     1257        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1258        (( RET = RET + $? )) 
     1259      done 
     1260    else 
     1261      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1262      RET=$? 
     1263    fi 
     1264 
     1265    if [ ${RET} -gt 0 ] ; then 
     1266      echo "IGCM_sys_GetBuffer : copy error." 
     1267      cat out_rsync 
     1268      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1269    else 
     1270      \rm out_rsync 
     1271    fi 
     1272  else 
     1273    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1274  fi 
     1275  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
     1276} 
     1277 
     1278#D-#================================================== 
     1279#D-function IGCM_sys_GetDate_FichWork 
     1280#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
     1281#D-* Examples: 
     1282#D- 
     1283function IGCM_sys_GetDate_FichWork { 
     1284  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1285  if ( $DEBUG_sys ) ; then 
     1286    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1287  fi 
     1288    # donne la date filesys d'un fichier sur la machine work 
     1289  IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1290} 
     1291 
     1292#D-#================================================== 
     1293#D-function IGCM_sys_GetDate_FichArchive 
     1294#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE  
     1295#D-* Examples: 
     1296#D- 
     1297function IGCM_sys_GetDate_FichArchive { 
     1298  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1299  if ( $DEBUG_sys ) ; then 
     1300    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1301  fi 
     1302  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    11801303} 
    11811304 
    11821305#D-#================================================== 
    11831306#D-function IGCM_sys_Dods_Rm 
    1184 #D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole. 
     1307#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. 
    11851308#D-* Examples: 
    11861309#D- 
    11871310function 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          
     1311  if ( $DEBUG_sys ) ; then 
     1312    echo "IGCM_sys_Dods_Rm :" $@ 
     1313  fi 
     1314  typeset RET 
     1315  RET=0 
     1316  if [ $DRYRUN = 0 ]; then 
     1317    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then 
     1318      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." 
     1319      echo "Nothing has been done." 
     1320      return 
     1321    fi 
     1322    dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 
     1323    RET=$? 
     1324     
    12021325#       if [ ${RET} -gt 0 ] ; then 
    12031326#           echo "IGCM_sys_Dods_Rm : error." 
     
    12081331#       fi 
    12091332 
    1210     else 
    1211         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1212     fi 
    1213     return $RET 
    1214 } 
    1215  
     1333  else 
     1334    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1335  fi 
     1336  return $RET 
     1337} 
    12161338 
    12171339#D-#================================================== 
     
    12211343#D- 
    12221344function 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          
     1345  if ( $DEBUG_sys ) ; then 
     1346    echo "IGCM_sys_Dods_Cp :" $@ 
     1347  fi 
     1348  typeset RET 
     1349  RET=0 
     1350  if [ $DRYRUN = 0 ]; then 
     1351    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1352      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." 
     1353      echo "Nothing has been done." 
     1354      return 
     1355    fi 
     1356    # 
     1357    dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 
     1358    RET=$? 
     1359 
    12381360#       if [ ${RET} -gt 0 ] ; then 
    12391361#           echo "IGCM_sys_Dods_Cp : error." 
     
    12441366#       fi 
    12451367 
    1246     else 
    1247         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1248     fi 
    1249     return $RET 
     1368  else 
     1369    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1370  fi 
     1371  return $RET 
    12501372} 
    12511373 
     
    12561378#D- 
    12571379function 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 
     1380  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ 
     1381  if ( $DEBUG_sys ) ; then 
     1382    echo "IGCM_sys_Put_Dods :" $@ 
     1383  fi 
     1384  if [ $DRYRUN = 0 ]; then 
     1385    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1386      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." 
     1387      IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
     1388      return 
     1389    fi 
     1390 
     1391    typeset RET 
    12701392        # 
    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" 
     1393    cd ${R_SAVE} 
     1394    IGCM_sys_Dods_Rm ${1} 
     1395    IGCM_sys_Dods_Cp ${1} 
     1396    RET=0 
     1397     
     1398    if [ ${RET} -gt 0 ] ; then 
     1399      echo "IGCM_sys_Put_Dods : error." 
     1400      IGCM_debug_Exit "IGCM_sys_Put_Dods" 
     1401    fi 
     1402  else 
     1403    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1404  fi 
     1405  IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    13131406} 
    13141407 
     
    13171410 
    13181411function 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" 
     1412  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1413  if ( $DEBUG_sys ) ; then 
     1414    echo "IGCM_sys_rebuild :" $@ 
     1415  fi 
     1416  /home/cont003/p86ipsl/CESIUM/bin/rebuild -f -o $@ 
     1417  if [ $? -gt 0 ] ; then 
     1418    echo "IGCM_sys_rebuild : erreur ${@}." 
     1419    IGCM_debug_Exit "rebuild" 
     1420  fi 
     1421 
     1422  IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1423} 
     1424 
     1425 
     1426############################################################ 
     1427# Activate Running Environnment Variables 
     1428 
     1429function IGCM_sys_activ_variables { 
     1430  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1431  if ( $DEBUG_sys ) ; then 
     1432    echo "IGCM_sys_activ_variables" 
     1433  fi 
     1434  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
     1435} 
     1436 
     1437############################################################ 
     1438# Desactivate Running Environnment Variables 
     1439 
     1440function IGCM_sys_desactiv_variables { 
     1441  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1442  if ( $DEBUG_sys ) ; then 
     1443    echo "IGCM_sys_desactiv_variables" 
     1444  fi 
     1445  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
     1446} 
     1447 
     1448############################################################ 
     1449# Build run file 
     1450 
     1451function IGCM_sys_build_run_file { 
     1452  IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
     1453  if ( $DEBUG_sys ) ; then 
     1454    echo "IGCM_sys_build_run_file" 
     1455  fi 
     1456  IGCM_debug_PopStack "IGCM_sys_build_run_file" 
    13301457} 
    13311458 
     
    13341461 
    13351462function 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" 
     1463  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ 
     1464  if ( $DEBUG_sys ) ; then 
     1465    echo "IGCM_sys_ncap2 :" $@ 
     1466  fi 
     1467  ncap2 "$@" 
     1468  if [ $? -gt 0 ] ; then 
     1469    echo "IGCM_sys_ncap2 : erreur ${@}." 
     1470    IGCM_debug_Exit "ncap2" 
     1471  fi 
     1472 
     1473  IGCM_debug_PopStack "IGCM_sys_ncap2" 
    13471474} 
    13481475 
    13491476function 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" 
     1477  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
     1478  if ( $DEBUG_sys ) ; then 
     1479    echo "IGCM_sys_ncatted :" $@ 
     1480  fi 
     1481  ncatted "$@" 
     1482  if [ $? -gt 0 ] ; then 
     1483    echo "IGCM_sys_ncatted : erreur ${@}." 
     1484    IGCM_debug_Exit "ncatted" 
     1485  fi 
     1486 
     1487  IGCM_debug_PopStack "IGCM_sys_ncatted" 
    13611488} 
    13621489 
    13631490function 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" 
     1491  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
     1492  if ( $DEBUG_sys ) ; then 
     1493    echo "IGCM_sys_ncbo :" $@ 
     1494  fi 
     1495  ncbo $@ 
     1496  if [ $? -gt 0 ] ; then 
     1497    echo "IGCM_sys_ncbo : erreur ${@}." 
     1498    IGCM_debug_Exit "ncbo" 
     1499  fi 
     1500 
     1501  IGCM_debug_PopStack "IGCM_sys_ncbo" 
    13751502} 
    13761503 
    13771504function 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" 
     1505  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
     1506  if ( $DEBUG_sys ) ; then 
     1507    echo "IGCM_sys_ncdiff :" $@ 
     1508  fi 
     1509  ncdiff $@ 
     1510  if [ $? -gt 0 ] ; then 
     1511    echo "IGCM_sys_ncdiff : erreur ${@}." 
     1512    IGCM_debug_Exit "ncdiff" 
     1513  fi 
     1514 
     1515  IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    13891516} 
    13901517 
    13911518function 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" 
     1519  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
     1520  if ( $DEBUG_sys ) ; then 
     1521    echo "IGCM_sys_ncea :" $@ 
     1522  fi 
     1523  ncea $@ 
     1524  if [ $? -gt 0 ] ; then 
     1525    echo "IGCM_sys_ncea : erreur ${@}." 
     1526    IGCM_debug_Exit "ncea" 
     1527  fi 
     1528 
     1529  IGCM_debug_PopStack "IGCM_sys_ncea" 
    14031530} 
    14041531 
    14051532function 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" 
     1533  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
     1534  if ( $DEBUG_sys ) ; then 
     1535    echo "IGCM_sys_ncecat :" $@ 
     1536  fi 
     1537  ncecat $@ 
     1538  if [ $? -gt 0 ] ; then 
     1539    echo "IGCM_sys_ncecat : erreur ${@}." 
     1540    IGCM_debug_Exit "ncecat" 
     1541  fi 
     1542 
     1543  IGCM_debug_PopStack "IGCM_sys_ncecat" 
    14171544} 
    14181545 
    14191546function 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" 
     1547  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
     1548  if ( $DEBUG_sys ) ; then 
     1549    echo "IGCM_sys_ncflint :" $@ 
     1550  fi 
     1551  ncflint $@ 
     1552  if [ $? -gt 0 ] ; then 
     1553    echo "IGCM_sys_ncflint : erreur ${@}." 
     1554    IGCM_debug_Exit "ncflint" 
     1555  fi 
     1556 
     1557  IGCM_debug_PopStack "IGCM_sys_ncflint" 
    14311558} 
    14321559 
    14331560function 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" 
     1561  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
     1562  if ( $DEBUG_sys ) ; then 
     1563    echo "IGCM_sys_ncks :" $@ 
     1564  fi 
     1565  ncks $@ 
     1566  if [ $? -gt 0 ] ; then 
     1567    echo "IGCM_sys_ncks : erreur ${@}." 
     1568    IGCM_debug_Exit "ncks" 
     1569  fi 
     1570 
     1571  IGCM_debug_PopStack "IGCM_sys_ncks" 
    14451572} 
    14461573 
    14471574function 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" 
     1575  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
     1576  if ( $DEBUG_sys ) ; then 
     1577    echo "IGCM_sys_ncpdq :" $@ 
     1578  fi 
     1579  ncpdq $@ 
     1580  if [ $? -gt 0 ] ; then 
     1581    echo "IGCM_sys_ncpdq : erreur ${@}." 
     1582    IGCM_debug_Exit "ncpdq" 
     1583  fi 
     1584 
     1585  IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    14591586} 
    14601587 
    14611588function 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" 
     1589  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
     1590  if ( $DEBUG_sys ) ; then 
     1591    echo "IGCM_sys_ncra :" $@ 
     1592  fi 
     1593  ncra $@ 
     1594  if [ $? -gt 0 ] ; then 
     1595    echo "IGCM_sys_ncra : erreur ${@}." 
     1596    IGCM_debug_Exit "ncra" 
     1597  fi 
     1598 
     1599  IGCM_debug_PopStack "IGCM_sys_ncra" 
    14731600} 
    14741601 
    14751602function 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 ${@}." 
     1603  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
     1604  if ( $DEBUG_sys ) ; then 
     1605    echo "IGCM_sys_ncrcat :" $@ 
     1606  fi 
     1607  ncrcat $@ 
     1608  if [ $? -gt 0 ] ; then 
     1609    echo "IGCM_sys_ncrcat : erreur ${@}." 
    14831610#       IGCM_debug_Exit "ncrcat" 
    1484     fi 
    1485  
    1486     IGCM_debug_PopStack "IGCM_sys_ncrcat" 
     1611  fi 
     1612 
     1613  IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    14871614} 
    14881615 
    14891616function 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" 
     1617  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
     1618  if ( $DEBUG_sys ) ; then 
     1619    echo "IGCM_sys_ncrename :" $@ 
     1620  fi 
     1621  ncrename $@ 
     1622  if [ $? -gt 0 ] ; then 
     1623    echo "IGCM_sys_ncrename : erreur ${@}." 
     1624    IGCM_debug_Exit "ncrename" 
     1625  fi 
     1626 
     1627  IGCM_debug_PopStack "IGCM_sys_ncrename" 
    15011628} 
    15021629 
    15031630function 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" 
     1631  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
     1632  if ( $DEBUG_sys ) ; then 
     1633    echo "IGCM_sys_ncwa :" $@ 
     1634  fi 
     1635  ncwa $@ 
     1636  if [ $? -gt 0 ] ; then 
     1637    echo "IGCM_sys_ncwa : erreur ${@}." 
     1638    IGCM_debug_Exit "ncwa" 
     1639  fi 
     1640 
     1641  IGCM_debug_PopStack "IGCM_sys_ncwa" 
    15151642} 
    15161643 
     
    15191646 
    15201647function 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  
     1648  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ 
     1649  if ( $DEBUG_sys ) ; then 
     1650    echo "IGCM_sys_cdo :" $@ 
     1651  fi 
     1652  \cdo $@ 
     1653  if [ $? -gt 0 ] ; then 
     1654    echo "IGCM_sys_cdo : erreur ${@}." 
    15331655    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 } 
     1656    return 1 
     1657  else 
     1658    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1659    return 0 
     1660  fi 
     1661 
     1662  IGCM_debug_PopStack "IGCM_sys_cdo" 
     1663} 
  • branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_mercure.ksh

    r521 r571  
    6262 
    6363#===================================================== 
    64 # Host and user names  
     64# Host and user names 
    6565# $hostname ou hostname 
    6666typeset  HOST=${HOST:=$( hostname )} 
     
    107107#==================================================== 
    108108#- IN 
    109 typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM} 
     109typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM} 
    110110typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data} 
    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} 
     394} 
     395 
     396#D-#================================================== 
     397#D-function IGCM_sys_IsFileArchived 
     398#D-* Purpose: Test file that must NOT EXISTS on Archive 
     399#D-* Examples: 
     400#D- 
     401function IGCM_sys_IsFileArchived { 
     402  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ 
     403  if ( $DEBUG_sys ) ; then 
     404    echo "IGCM_sys_IsFileArchived :" $@ 
     405  fi 
     406  typeset IsArchivedFlag 
     407  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/dmnfs ) != X ] && echo 0 || echo 1 ) 
     408  IGCM_debug_PopStack "IGCM_sys_IsFileArchived" 
     409 
     410  return ${IsArchivedFlag} 
    394411} 
    395412 
     
    400417#D- 
    401418function 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} 
     419  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
     420  if ( $DEBUG_sys ) ; then 
     421    echo "IGCM_sys_TestFileArchive :" $@ 
     422  fi 
     423  typeset ExistFlag 
     424  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     425  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
     426 
     427  return ${ExistFlag} 
     428} 
     429 
     430#D-#================================================== 
     431#D-function IGCM_sys_TestFileBuffer 
     432#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     433#D-* Examples: 
     434#D- 
     435function IGCM_sys_TestFileBuffer { 
     436  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     437  typeset ExistFlag 
     438  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     439  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     440 
     441  return ${ExistFlag} 
    411442} 
    412443 
     
    417448#D- 
    418449function 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" 
     450  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
     451  ls ${@} 2>/dev/null | wc -l 
     452  if [ $? -gt 0 ] ; then 
     453    echo "IGCM_sys_CountFileArchive : erreur." 
     454  fi 
     455  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     456} 
     457 
     458#D-#================================================== 
     459#D-function IGCM_sys_CountFileBuffer 
     460#D-* Purpose: Count files on Scratch filesystem 
     461#D-* Examples: 
     462#D- 
     463function IGCM_sys_CountFileBuffer { 
     464  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     465  ls ${@} 2>/dev/null | wc -l 
     466  if [ $? -gt 0 ] ; then 
     467    echo "IGCM_sys_CountFileBuffer : erreur." 
     468  fi 
     469  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    425470} 
    426471 
     
    431476#D- 
    432477function 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" 
     478  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     479  if ( $DEBUG_sys ) ; then 
     480    echo "IGCM_sys_Tree :" $@ 
     481  fi 
     482 
     483  \tree -f $@ 
     484 
     485  IGCM_debug_PopStack "IGCM_sys_Tree" 
    441486} 
    442487 
    443488#D-#================================================== 
    444489#D-function IGCM_sys_Tar 
    445 #D-* Purpose: master un-tar command 
     490#D-* Purpose: master tar command 
    446491#D-* Examples: 
    447492#D- 
    448493function 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" 
     494  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     495  if ( $DEBUG_sys ) ; then 
     496    echo "IGCM_sys_Tar :" $@ 
     497  fi 
     498  \tar cf $@ 
     499  if [ $? -gt 0 ] ; then 
     500    echo "IGCM_sys_Tar : erreur." 
     501    IGCM_debug_Exit "IGCM_sys_Tar" 
     502  fi 
     503  IGCM_debug_PopStack "IGCM_sys_Tar" 
    461504} 
    462505 
     
    467510#D- 
    468511function 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" 
     512  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     513  if ( $DEBUG_sys ) ; then 
     514    echo "IGCM_sys_UnTar :" $@ 
     515  fi 
     516  \tar xvf $1 
     517  if [ $? -gt 0 ] ; then 
     518    echo "IGCM_sys_UnTar : erreur." 
     519    IGCM_debug_Exit "IGCM_sys_UnTar" 
     520  fi 
     521  IGCM_debug_PopStack "IGCM_sys_UnTar" 
    479522} 
    480523 
     
    485528#D- 
    486529function 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" 
     530  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     531  if ( $DEBUG_sys ) ; then 
     532    echo "IGCM_sys_QsubPost :" $@ 
     533  fi 
     534  /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv} 
     535  if [ $? -gt 0 ] ; then 
     536    echo "IGCM_sys_QsubPost : erreur " $@ 
     537    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     538  fi 
     539  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    497540} 
    498541 
     
    508551#D-  Error values and explanations can depend on your system version. 
    509552function 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      
     553  RET=$1 
     554  if [ ! $RET ] ; then 
     555    echo "rsync error !" 
     556  fi 
     557 
     558  if [ $MYLANG = "fr" ]; then 
     559    case $RET in 
     560    0)  return ;; 
     561    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     562      echo "Erreur de syntaxe ou d'utilisation." 
     563      return;; 
     564    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     565      echo "Incompatibilité de protocole." 
     566      return;; 
     567    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     568      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     569      echo "répertoires" 
     570      return;; 
     571    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     572      echo "Action demandée non supportée : une tentative de manipulation de" 
     573      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     574      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     575      echo "pas par le serveur a été spécifiée." 
     576      return;; 
     577    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     578      echo "Erreur dans le socket d'entrée sortie" 
     579      return;; 
     580    11) echo "Erreur de rsync ; RERR_FILEIO" 
     581      echo "Erreur d'entrée sortie fichier" 
     582      return;; 
     583    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     584      echo "Erreur dans flux de donnée du protocole rsync" 
     585      return;; 
     586    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     587      echo "Erreur avec les diagnostics du programme" 
     588      return;; 
     589    14) echo "Erreur de rsync ; RERR_IPC" 
     590      echo "Erreur dans le code IPC" 
     591      return;; 
     592    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     593      echo "SIGUSR1 ou SIGINT reçu" 
     594      return;; 
     595    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     596      echo "Une erreur retournée par waitpid()" 
     597      return;; 
     598    22) echo "Erreur de rsync ; RERR_MALLOC" 
     599      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     600      return;; 
     601    23) echo "" 
     602      echo "Erreur fichier inexistant" 
     603      return;; 
     604    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     605      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     606      return;; 
     607    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     608      return;; 
     609    esac 
     610  elif [ $MYLANG = "en" ] ; then 
     611    case $RET in 
     612    0)  return;;                 
     613    1)  echo "rsync error : Syntax or usage error " 
     614      return;; 
     615    2)  echo "rsync error : Protocol incompatibility " 
     616      return;; 
     617    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     618      return;; 
     619    4)  echo "rsync error : Requested action not supported: an attempt" 
     620      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     621      echo "them; or an option was specified that is supported by the client and" 
     622      echo "not by the server." 
     623      return;; 
     624    5)  echo "rsync error : Error starting client-server protocol" 
     625      return;; 
     626    10) echo "rsync error : Error in socket I/O " 
     627      return;; 
     628    11) echo "rsync error : Error in file I/O " 
     629      return;; 
     630    12) echo "rsync error : Error in rsync protocol data stream " 
     631      return;; 
     632    13) echo "rsync error : Errors with program diagnostics " 
     633      return;; 
     634    14) echo "rsync error : Error in IPC code " 
     635      return;; 
     636    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     637      return;; 
     638    21) echo "rsync error : Some error returned by waitpid() " 
     639      return;; 
     640    22) echo "rsync error : Error allocating core memory buffers " 
     641      return;; 
     642    23) echo "rsync error : Partial transfer due to error" 
     643      return;; 
     644    24) echo "rsync error : Partial transfer due to vanished source files" 
     645      return;; 
     646    30) echo "rsync error : Timeout in data send/receive " 
     647      return;; 
     648    *)  echo "rsync error : return code of rsync unknown :" $RET 
     649      return;; 
     650    esac 
     651  else 
     652    echo "unknown language $MYLANG." 
     653    return 
     654  fi 
     655} 
     656 
    614657#D-#================================================== 
    615658#D-function IGCM_sys_Cp 
     
    618661#D- 
    619662function 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" 
     663  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     664  if ( $DEBUG_sys ) ; then 
     665    echo "IGCM_sys_Cp :" $@ 
     666  fi 
     667 
     668  typeset RET 
     669 
     670  echo cp $@ > out_rsync 2>&1 
     671  \cp $@ >> out_rsync 2>&1 
     672  RET=$? 
     673 
     674  if [ ${RET} -gt 0 ] ; then 
     675    echo "IGCM_sys_Cp : error." 
     676    cat out_rsync 
     677    IGCM_debug_Exit "IGCM_sys_Cp" 
     678  else 
     679    \rm out_rsync 
     680  fi 
     681  IGCM_debug_PopStack "IGCM_sys_Cp" 
    639682} 
    640683 
     
    645688#D- 
    646689function 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" 
     690  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     691  if ( $DEBUG_sys ) ; then 
     692    echo "IGCM_sys_Rm :" $@ 
     693  fi 
     694 
     695  typeset RET 
     696 
     697  echo rm $@ > out_rsync 2>&1 
     698  \rm $@ >> out_rsync 2>&1 
     699  RET=$? 
     700 
     701  if [ ${RET} -gt 0 ] ; then 
     702    echo "IGCM_sys_Rm : error." 
     703    cat out_rsync 
     704    IGCM_debug_Exit "IGCM_sys_Rm" 
     705  else 
     706    \rm out_rsync 
     707  fi 
     708  IGCM_debug_PopStack "IGCM_sys_Rm" 
    666709} 
    667710 
     
    673716#D- 
    674717function 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" 
     718  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
     719  if ( $DEBUG_sys ) ; then 
     720    echo "IGCM_sys_RmRunDir :" $@ 
     721  fi 
     722 
     723  typeset RET 
     724 
     725  echo rm $@ > out_rsync 2>&1 
     726  \rm $@ >> out_rsync 2>&1 
     727  RET=$? 
     728 
     729  if [ ${RET} -gt 0 ] ; then 
     730    echo "IGCM_sys_RmRunDir : error." 
     731    cat out_rsync 
     732    IGCM_debug_Exit "IGCM_sys_RmRunDir" 
     733  else 
     734    \rm out_rsync 
     735  fi 
     736  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    694737} 
    695738 
     
    700743#D- 
    701744function 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=$? 
     745  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     746  if ( $DEBUG_sys ) ; then 
     747    echo "IGCM_sys_Mv :" $@ 
     748  fi 
     749 
     750  if [ $DRYRUN = 0 ]; then 
     751 
     752    typeset RET 
    714753     
    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 
     754    echo mv $@ > out_rsync 2>&1 
     755    \mv $@ >> out_rsync 2>&1 
     756    RET=$? 
     757     
     758    if [ ${RET} -gt 0 ] ; then 
     759      echo "IGCM_sys_Mv : error in mv." 
     760      cat out_rsync 
     761      IGCM_debug_Exit "IGCM_sys_Mv" 
    722762    else 
    723         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    724     fi 
    725  
    726     IGCM_debug_PopStack "IGCM_sys_Mv" 
     763      \rm out_rsync 
     764    fi 
     765  else 
     766    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     767  fi 
     768 
     769  IGCM_debug_PopStack "IGCM_sys_Mv" 
    727770} 
    728771 
     
    733776#D- 
    734777function 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 
     778  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     779  if ( $DEBUG_sys ) ; then 
     780    echo "IGCM_sys_Put_Dir :" $@ 
     781  fi 
     782  if [ $DRYRUN = 0 ]; then 
     783    if [ ! -d ${1} ] ; then 
     784      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     785      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     786      return 
     787    fi 
     788 
     789    typeset RET 
     790 
     791    # Only if we use rsync 
     792    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     793    # 
     794    #USUAL WAY 
     795    \cp -r $1 $2 > out_rsync 2>&1 
     796    RET=$? 
     797 
     798    if [ ${RET} -gt 0 ] ; then 
     799      echo "IGCM_sys_Put_Dir : error." 
     800      cat out_rsync 
     801      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    762802    else 
    763         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    764     fi 
    765     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     803      \rm out_rsync 
     804    fi 
     805  else 
     806    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     807  fi 
     808  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    766809} 
    767810 
     
    772815#D- 
    773816function 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 
     817  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     818  if ( $DEBUG_sys ) ; then 
     819    echo "IGCM_sys_Get_Dir :" $@ 
     820  fi 
     821  if [ $DRYRUN = 0 ]; then 
    779822#       if [ ! -d ${1} ] ; then 
    780823#           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     
    783826#       fi 
    784827 
    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 
     828    typeset RET 
     829 
     830    # Only if we use rsync 
     831    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     832    # 
     833    #USUAL WAY 
     834    # add dmget (to demigrate all offline files) to reduce time of this command : 
     835    dmget $1/* 
     836    \cp -r $1 $2 > out_rsync 2>&1 
     837    RET=$? 
     838 
     839    if [ ${RET} -gt 0 ] ; then 
     840      echo "IGCM_sys_Get_Dir : error." 
     841      cat out_rsync 
     842      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    803843    else 
    804         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    805     fi 
    806     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     844      \rm out_rsync 
     845    fi 
     846  else 
     847    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     848  fi 
     849  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    807850} 
    808851 
     
    813856#D- 
    814857function 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 
     858  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
     859  if ( $DEBUG_sys ) ; then 
     860    echo "IGCM_sys_Get_Master :" $@ 
     861  fi 
     862  if [ $DRYRUN = 0 ]; then 
     863    if [ ! -d ${1} ] ; then 
     864      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
     865      IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     866      return 
     867    fi 
     868 
     869    typeset RET 
     870 
     871    #USUAL WAY 
     872    \cp -r $1 $2 > out_rsync 2>&1 
     873    RET=$? 
     874 
     875    if [ ${RET} -gt 0 ] ; then 
     876      echo "IGCM_sys_Get_Master : error." 
     877      cat out_rsync 
     878      IGCM_debug_Exit "IGCM_sys_Get_Master" 
    839879    else 
    840         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    841     fi 
    842     IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     880      \rm out_rsync 
     881    fi 
     882  else 
     883    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     884  fi 
     885  IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    843886} 
    844887 
    845888#D-#================================================== 
    846889#D-function IGCM_sys_Put_Rest 
    847 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     890#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    848891#D-           File and target directory must exist. 
    849892#D-* Examples: 
    850893#D- 
    851894function 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=$? 
     895  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     896  if ( $DEBUG_sys ) ; then 
     897    echo "IGCM_sys_Put_Rest :" $@ 
     898  fi 
     899  if [ $DRYRUN = 0 ]; then 
     900    if [ ! -f ${1} ] ; then 
     901      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     902      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     903    fi 
     904 
     905    typeset RET 
     906    # 
     907    if [ X${JobType} = XRUN ] ; then 
     908      IGCM_sys_Chmod 444 ${1} 
     909    fi 
     910 
     911    # 
     912    # USUAL WAY 
     913    \cp $1 $2 > out_rsync 2>&1 
     914    RET=$? 
    873915 
    874916#       #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 
     917#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     918#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    877919 
    878920#       #RSYNC WITH NFS USE 
     
    886928#       (( RET=RET+$? )) 
    887929 
    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 
     930    if [ ${RET} -gt 0 ] ; then 
     931      echo "IGCM_sys_Put_Rest : error." 
     932      cat out_rsync 
     933      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    895934    else 
    896         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    897     fi 
    898     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     935      \rm out_rsync 
     936    fi 
     937  else 
     938    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     939  fi 
     940  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     941} 
     942 
     943#D-#================================================== 
     944#D-function IGCM_sys_PutBuffer_Rest 
     945#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     946#D-           File and target directory must exist. 
     947#D-* Examples: 
     948#D- 
     949function IGCM_sys_PutBuffer_Rest { 
     950  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     951  if ( $DEBUG_sys ) ; then 
     952    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     953  fi 
     954  if [ $DRYRUN = 0 ]; then 
     955    if [ ! -f ${1} ] ; then 
     956      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     957      IGCM_debug_Exit "IGCM_sys_PutBuffer_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=$? 
     970 
     971    if [ ${RET} -gt 0 ] ; then 
     972      echo "IGCM_sys_PutBuffer_Rest : error." 
     973      cat out_rsync 
     974      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     975    else 
     976      \rm out_rsync 
     977    fi 
     978  else 
     979    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     980  fi 
     981  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    899982} 
    900983 
    901984#D-#================================================== 
    902985#D-function IGCM_sys_Put_Out 
    903 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     986#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    904987#D-* Examples: 
    905988#D- 
    906989function 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 
     990  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     991  if ( $DEBUG_sys ) ; then 
     992    echo "IGCM_sys_Put_Out :" $@ 
     993  fi 
     994  if [ $DRYRUN = 0 ]; then 
     995    if [ ! -f ${1} ] ; then 
     996      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     997      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     998      return 1 
     999    fi 
     1000    # 
     1001    IGCM_sys_MkdirArchive $( dirname $2 ) 
     1002    # 
     1003    typeset RET exist skip 
     1004 
     1005    #===================================================== 
     1006    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1007    #===================================================== 
     1008 
     1009    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     1010    #if [ $? -eq 0 ] ; then 
     1011    #    typeset WORKPATH FILEPATH 
     1012    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     1013    #    IGCM_sys_MkdirWork ${WORKPATH}  
     1014    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     1015    #    # 
     1016    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1017    #fi 
     1018 
     1019    if [ X${JobType} = XRUN ] ; then 
     1020      if [ X${3} = X ] ; then 
     1021        IGCM_sys_Chmod 444 ${1} 
     1022      fi 
     1023    fi 
     1024 
     1025    exist=false 
     1026    skip=false 
     1027    if [ -f $2 ] ; then 
     1028      IGCM_debug_Print 1 "$2 already exist" 
     1029      dmget $2 
     1030      exist=true 
     1031      if [ "X$( diff $1 $2 )" = X ] ; then 
     1032        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
     1033        skip=true 
     1034      else 
     1035        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    9431036        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 
     1037      fi 
     1038    fi 
     1039    #  
     1040    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
     1041      IGCM_sys_Chmod u+w $2 
     1042    fi 
     1043    # USUAL WAY 
     1044    if [ X${skip} = Xfalse ] ; then 
     1045      \cp $1 $2 > out_rsync 2>&1 
     1046      RET=$? 
     1047      if [ ${RET} -gt 0 ] ; then 
     1048        echo "IGCM_sys_Put_Out : error." 
     1049        cat out_rsync 
     1050        IGCM_debug_Exit "IGCM_sys_Put_Out" 
     1051      else 
     1052        \rm out_rsync 
     1053      fi 
     1054    fi 
     1055 
     1056#       #RSYNC WITH NETWORK SSH CALL 
     1057#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     1058#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    9761059 
    9771060#       #RSYNC WITH NFS USE 
     
    9851068#       (( RET=RET+$? )) 
    9861069 
     1070  else 
     1071    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1072  fi 
     1073  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1074  return 0 
     1075} 
     1076 
     1077#D-#================================================== 
     1078#D-function IGCM_sys_PutBuffer_Out 
     1079#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
     1080#D-* Examples: 
     1081#D- 
     1082function IGCM_sys_PutBuffer_Out { 
     1083  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     1084  if ( $DEBUG_sys ) ; then 
     1085    echo "IGCM_sys_PutBuffer_Out :" $@ 
     1086  fi 
     1087  if [ $DRYRUN = 0 ]; then 
     1088    if [ ! -f ${1} ] ; then 
     1089      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     1090      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1091      return 1 
     1092    fi 
     1093    # 
     1094    IGCM_sys_Mkdir $( dirname $2 ) 
     1095    # 
     1096    typeset RET 
     1097 
     1098    if [ X${JobType} = XRUN ] ; then 
     1099      if [ X${3} = X ] ; then 
     1100        IGCM_sys_Chmod 444 ${1} 
     1101      fi 
     1102    fi 
     1103    # 
     1104    # USUAL WAY 
     1105    \cp $1 $2 > out_rsync 2>&1 
     1106    RET=$? 
     1107 
     1108    if [ ${RET} -gt 0 ] ; then 
     1109      echo "IGCM_sys_PutBuffer_Out : error." 
     1110      cat out_rsync 
     1111      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
    9871112    else 
    988         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    989     fi 
    990     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    991     return 0 
     1113      \rm out_rsync 
     1114    fi 
     1115  else 
     1116    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1117  fi 
     1118  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1119  return 0 
    9921120} 
    9931121 
     
    9981126#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    9991127function 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 
     1128  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1129 
     1130  typeset DEST RET dm_liste ifile target file_work  
     1131 
     1132  if ( $DEBUG_sys ) ; then 
     1133    echo "IGCM_sys_Get :" $@ 
     1134  fi 
     1135  if [ $DRYRUN -le 2 ]; then 
     1136    if [ X${1} = X'/l' ] ; then 
     1137      # test if the first file is present in the old computation : 
     1138      eval set +A dm_liste \${${2}} 
     1139    else 
     1140      eval set +A dm_liste ${1} 
     1141    fi 
     1142    eval DEST=\${${#}} 
     1143 
     1144    #===================================================== 
     1145    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1146    #===================================================== 
     1147 
     1148    # Is it an R_OUT file (not R_IN) ? 
     1149    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1150    #if [ $? -eq 0 ] ; then 
     1151    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1152    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1153    #    if [ -f ${file_work[0]} ] ; then 
     1154    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1155    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1156    #   return 
     1157    #    fi 
     1158    #fi 
     1159 
     1160    # test if the (first) file is present in the old computation : 
     1161    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1162    RET=$? 
     1163    if [ ${RET} -gt 0 ] ; then 
     1164      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1165      IGCM_debug_Exit "IGCM_sys_Get" 
     1166    fi 
     1167 
     1168    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1169    RET=$? 
     1170    if [ ${RET} -gt 0 ] ; then 
     1171      echo "WARNING IGCM_sys_Get : demigration error." 
     1172      cat out_rsync 
     1173      echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
     1174    fi 
     1175 
     1176    #if [ ${RET} -gt 0 ] ; then 
     1177    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1178    #   cat out_rsync 
     1179    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1180    #   sleep 30 
     1181    #   echo "We try another time" 
     1182    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1183    #   RET=$? 
     1184    #   if [ ${RET} -gt 0 ] ; then 
     1185    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1186    #       cat out_rsync 
     1187    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1188    #   fi 
     1189    #    else 
     1190    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1191    #   cat out_rsync 
     1192    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1193    #    fi 
     1194    #fi 
     1195 
     1196    #USUAL WAY 
     1197    if [ X${1} = X'/l' ] ; then 
     1198      (( RET=0 )) 
     1199      for target in ${dm_liste[*]} ; do 
     1200        local_file=$( basename ${target} ) 
     1201        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1202        (( RET = RET + $? )) 
     1203      done 
     1204    else 
     1205      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1206      RET=$? 
     1207    fi 
     1208 
     1209#       #RSYNC WITH NETWORK SSH CALL 
     1210#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
     1211#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
    10861212 
    10871213#       #RSYNC WITH NFS USE 
     
    10951221#       (( RET=RET+$? )) 
    10961222 
    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 
     1223    if [ ${RET} -gt 0 ] ; then 
     1224      echo "IGCM_sys_Get : copy error." 
     1225      cat out_rsync 
     1226#      IGCM_debug_Exit "IGCM_sys_Get" 
    11041227    else 
    1105         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1106     fi 
    1107     IGCM_debug_PopStack "IGCM_sys_Get" 
     1228      \rm out_rsync 
     1229    fi 
     1230  else 
     1231    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1232  fi 
     1233  IGCM_debug_PopStack "IGCM_sys_Get" 
     1234} 
     1235 
     1236#D-#================================================== 
     1237#D-function IGCM_sys_GetBuffer 
     1238#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1239#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1240#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1241function IGCM_sys_GetBuffer { 
     1242  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1243 
     1244  typeset DEST RET buf_liste ifile target file_work  
     1245 
     1246  if ( $DEBUG_sys ) ; then 
     1247    echo "IGCM_sys_GetBuffer :" $@ 
     1248  fi 
     1249  if [ $DRYRUN -le 2 ]; then 
     1250    if [ X${1} = X'/l' ] ; then 
     1251      # test if the first file is present in the old computation : 
     1252      eval set +A buf_liste \${${2}} 
     1253    else 
     1254      eval set +A buf_liste ${1} 
     1255    fi 
     1256    eval DEST=\${${#}} 
     1257 
     1258    #USUAL WAY 
     1259    if [ X${1} = X'/l' ] ; then 
     1260      (( RET=0 )) 
     1261      for target in ${buf_liste[*]} ; do 
     1262        local_file=$( basename ${target} ) 
     1263        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1264        (( RET = RET + $? )) 
     1265      done 
     1266    else 
     1267      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1268      RET=$? 
     1269    fi 
     1270 
     1271    if [ ${RET} -gt 0 ] ; then 
     1272      echo "IGCM_sys_GetBuffer : copy error." 
     1273      cat out_rsync 
     1274      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1275    else 
     1276      \rm out_rsync 
     1277    fi 
     1278  else 
     1279    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1280  fi 
     1281  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
     1282} 
     1283 
     1284#D-#================================================== 
     1285#D-function IGCM_sys_GetDate_FichWork 
     1286#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
     1287#D-* Examples: 
     1288#D- 
     1289function IGCM_sys_GetDate_FichWork { 
     1290  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1291  if ( $DEBUG_sys ) ; then 
     1292    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1293  fi 
     1294  # donne la date filesys d'un fichier sur la machine work 
     1295  IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1296} 
     1297 
     1298#D-#================================================== 
     1299#D-function IGCM_sys_GetDate_FichArchive 
     1300#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE  
     1301#D-* Examples: 
     1302#D- 
     1303function IGCM_sys_GetDate_FichArchive { 
     1304  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1305  if ( $DEBUG_sys ) ; then 
     1306    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1307  fi 
     1308  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    11081309} 
    11091310 
     
    11141315#D- 
    11151316function 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          
     1317  if ( $DEBUG_sys ) ; then 
     1318    echo "IGCM_sys_Dods_Rm :" $@ 
     1319  fi 
     1320  typeset RET 
     1321  RET=0 
     1322  if [ $DRYRUN = 0 ]; then 
     1323    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then 
     1324      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." 
     1325      echo "Nothing has been done." 
     1326      return 
     1327    fi 
     1328    dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 
     1329    RET=$? 
     1330     
    11301331#       if [ ${RET} -gt 0 ] ; then 
    11311332#           echo "IGCM_sys_Dods_Rm : error." 
     
    11361337#       fi 
    11371338 
    1138     else 
    1139         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1140     fi 
    1141     return $RET 
    1142 } 
    1143  
     1339  else 
     1340    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1341  fi 
     1342  return $RET 
     1343} 
    11441344 
    11451345#D-#================================================== 
     
    11491349#D- 
    11501350function 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          
     1351  if ( $DEBUG_sys ) ; then 
     1352    echo "IGCM_sys_Dods_Cp :" $@ 
     1353  fi 
     1354  typeset RET 
     1355  RET=0 
     1356  if [ $DRYRUN = 0 ]; then 
     1357    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1358      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." 
     1359      echo "Nothing has been done." 
     1360      return 
     1361    fi 
     1362    # 
     1363    dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 
     1364    RET=$? 
     1365 
    11661366#       if [ ${RET} -gt 0 ] ; then 
    11671367#           echo "IGCM_sys_Dods_Cp : error." 
     
    11721372#       fi 
    11731373 
    1174     else 
    1175         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1176     fi 
    1177     return $RET 
     1374  else 
     1375    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1376  fi 
     1377  return $RET 
    11781378} 
    11791379 
     
    11841384#D- 
    11851385function 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 
     1386  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ 
     1387  if ( $DEBUG_sys ) ; then 
     1388    echo "IGCM_sys_Put_Dods :" $@ 
     1389  fi 
     1390  if [ $DRYRUN = 0 ]; then 
     1391    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1392      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." 
     1393      IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
     1394      return 
     1395    fi 
     1396 
     1397    typeset RET 
    11981398        # 
    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" 
     1399    cd ${R_SAVE} 
     1400    IGCM_sys_Dods_Rm ${1} 
     1401    IGCM_sys_Dods_Cp ${1} 
     1402    RET=0 
     1403     
     1404    if [ ${RET} -gt 0 ] ; then 
     1405      echo "IGCM_sys_Put_Dods : error." 
     1406      IGCM_debug_Exit "IGCM_sys_Put_Dods" 
     1407    fi 
     1408  else 
     1409    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1410  fi 
     1411  IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    12411412} 
    12421413 
     
    12451416 
    12461417function 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" 
     1418  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1419  if ( $DEBUG_sys ) ; then 
     1420    echo "IGCM_sys_rebuild :" $@ 
     1421  fi 
     1422  /home/cont003/p86ipsl/X86_64/bin/rebuild -f -o $@ 
     1423  if [ $? -gt 0 ] ; then 
     1424    echo "IGCM_sys_rebuild : erreur ${@}." 
     1425    IGCM_debug_Exit "rebuild" 
     1426  fi 
     1427 
     1428  IGCM_debug_PopStack "IGCM_sys_rebuild" 
    12581429} 
    12591430 
     
    12621433 
    12631434function 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" 
     1435  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ 
     1436  if ( $DEBUG_sys ) ; then 
     1437    echo "IGCM_sys_ncap2 :" $@ 
     1438  fi 
     1439  ncap2 "$@" 
     1440  if [ $? -gt 0 ] ; then 
     1441    echo "IGCM_sys_ncap2 : erreur ${@}." 
     1442    IGCM_debug_Exit "ncap2" 
     1443  fi 
     1444 
     1445  IGCM_debug_PopStack "IGCM_sys_ncap2" 
    12751446} 
    12761447 
    12771448function 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" 
     1449  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
     1450  if ( $DEBUG_sys ) ; then 
     1451    echo "IGCM_sys_ncatted :" $@ 
     1452  fi 
     1453  ncatted "$@" 
     1454  if [ $? -gt 0 ] ; then 
     1455    echo "IGCM_sys_ncatted : erreur ${@}." 
     1456    IGCM_debug_Exit "ncatted" 
     1457  fi 
     1458 
     1459  IGCM_debug_PopStack "IGCM_sys_ncatted" 
    12891460} 
    12901461 
    12911462function 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" 
     1463  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
     1464  if ( $DEBUG_sys ) ; then 
     1465    echo "IGCM_sys_ncbo :" $@ 
     1466  fi 
     1467  ncbo $@ 
     1468  if [ $? -gt 0 ] ; then 
     1469    echo "IGCM_sys_ncbo : erreur ${@}." 
     1470    IGCM_debug_Exit "ncbo" 
     1471  fi 
     1472 
     1473  IGCM_debug_PopStack "IGCM_sys_ncbo" 
    13031474} 
    13041475 
    13051476function 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" 
     1477  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
     1478  if ( $DEBUG_sys ) ; then 
     1479    echo "IGCM_sys_ncdiff :" $@ 
     1480  fi 
     1481  ncdiff $@ 
     1482  if [ $? -gt 0 ] ; then 
     1483    echo "IGCM_sys_ncdiff : erreur ${@}." 
     1484    IGCM_debug_Exit "ncdiff" 
     1485  fi 
     1486 
     1487  IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    13171488} 
    13181489 
    13191490function 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" 
     1491  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
     1492  if ( $DEBUG_sys ) ; then 
     1493    echo "IGCM_sys_ncea :" $@ 
     1494  fi 
     1495  ncea $@ 
     1496  if [ $? -gt 0 ] ; then 
     1497    echo "IGCM_sys_ncea : erreur ${@}." 
     1498    IGCM_debug_Exit "ncea" 
     1499  fi 
     1500 
     1501  IGCM_debug_PopStack "IGCM_sys_ncea" 
    13311502} 
    13321503 
    13331504function 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" 
     1505  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
     1506  if ( $DEBUG_sys ) ; then 
     1507    echo "IGCM_sys_ncecat :" $@ 
     1508  fi 
     1509  ncecat $@ 
     1510  if [ $? -gt 0 ] ; then 
     1511    echo "IGCM_sys_ncecat : erreur ${@}." 
     1512    IGCM_debug_Exit "ncecat" 
     1513  fi 
     1514 
     1515  IGCM_debug_PopStack "IGCM_sys_ncecat" 
    13451516} 
    13461517 
    13471518function 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" 
     1519  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
     1520  if ( $DEBUG_sys ) ; then 
     1521    echo "IGCM_sys_ncflint :" $@ 
     1522  fi 
     1523  ncflint $@ 
     1524  if [ $? -gt 0 ] ; then 
     1525    echo "IGCM_sys_ncflint : erreur ${@}." 
     1526    IGCM_debug_Exit "ncflint" 
     1527  fi 
     1528 
     1529  IGCM_debug_PopStack "IGCM_sys_ncflint" 
    13591530} 
    13601531 
    13611532function 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" 
     1533  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
     1534  if ( $DEBUG_sys ) ; then 
     1535    echo "IGCM_sys_ncks :" $@ 
     1536  fi 
     1537  ncks $@ 
     1538  if [ $? -gt 0 ] ; then 
     1539    echo "IGCM_sys_ncks : erreur ${@}." 
     1540    IGCM_debug_Exit "ncks" 
     1541  fi 
     1542 
     1543  IGCM_debug_PopStack "IGCM_sys_ncks" 
    13731544} 
    13741545 
    13751546function 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" 
     1547  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
     1548  if ( $DEBUG_sys ) ; then 
     1549    echo "IGCM_sys_ncpdq :" $@ 
     1550  fi 
     1551  ncpdq $@ 
     1552  if [ $? -gt 0 ] ; then 
     1553    echo "IGCM_sys_ncpdq : erreur ${@}." 
     1554    IGCM_debug_Exit "ncpdq" 
     1555  fi 
     1556 
     1557  IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    13871558} 
    13881559 
    13891560function 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" 
     1561  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
     1562  if ( $DEBUG_sys ) ; then 
     1563    echo "IGCM_sys_ncra :" $@ 
     1564  fi 
     1565  ncra $@ 
     1566  if [ $? -gt 0 ] ; then 
     1567    echo "IGCM_sys_ncra : erreur ${@}." 
     1568    IGCM_debug_Exit "ncra" 
     1569  fi 
     1570 
     1571  IGCM_debug_PopStack "IGCM_sys_ncra" 
    14011572} 
    14021573 
    14031574function 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 ${@}." 
     1575  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
     1576  if ( $DEBUG_sys ) ; then 
     1577    echo "IGCM_sys_ncrcat :" $@ 
     1578  fi 
     1579  ncrcat $@ 
     1580  if [ $? -gt 0 ] ; then 
     1581    echo "IGCM_sys_ncrcat : erreur ${@}." 
    14111582#       IGCM_debug_Exit "ncrcat" 
    1412     fi 
    1413  
    1414     IGCM_debug_PopStack "IGCM_sys_ncrcat" 
     1583  fi 
     1584 
     1585  IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    14151586} 
    14161587 
    14171588function 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" 
     1589  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
     1590  if ( $DEBUG_sys ) ; then 
     1591    echo "IGCM_sys_ncrename :" $@ 
     1592  fi 
     1593  ncrename $@ 
     1594  if [ $? -gt 0 ] ; then 
     1595    echo "IGCM_sys_ncrename : erreur ${@}." 
     1596    IGCM_debug_Exit "ncrename" 
     1597  fi 
     1598 
     1599  IGCM_debug_PopStack "IGCM_sys_ncrename" 
    14291600} 
    14301601 
    14311602function 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" 
     1603  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
     1604  if ( $DEBUG_sys ) ; then 
     1605    echo "IGCM_sys_ncwa :" $@ 
     1606  fi 
     1607  ncwa $@ 
     1608  if [ $? -gt 0 ] ; then 
     1609    echo "IGCM_sys_ncwa : erreur ${@}." 
     1610    IGCM_debug_Exit "ncwa" 
     1611  fi 
     1612 
     1613  IGCM_debug_PopStack "IGCM_sys_ncwa" 
    14431614} 
    14441615 
     
    14471618 
    14481619function 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  
     1620  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ 
     1621  if ( $DEBUG_sys ) ; then 
     1622    echo "IGCM_sys_cdo :" $@ 
     1623  fi 
     1624  \cdo $@ 
     1625  if [ $? -gt 0 ] ; then 
     1626    echo "IGCM_sys_cdo : erreur ${@}." 
    14611627    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1628    return 1 
     1629  else 
     1630    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1631    return 0 
     1632  fi 
     1633 
     1634  IGCM_debug_PopStack "IGCM_sys_cdo" 
    14621635} 
    14631636 
     
    14661639 
    14671640function 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" 
     1641  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1642  if ( $DEBUG_sys ) ; then 
     1643    echo "IGCM_sys_activ_variables" 
     1644  fi 
     1645  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    14731646} 
    14741647 
     
    14771650 
    14781651function 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" 
     1652  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1653  if ( $DEBUG_sys ) ; then 
     1654    echo "IGCM_sys_desactiv_variables" 
     1655  fi 
     1656  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
    14841657} 
    14851658 
     
    14881661 
    14891662function 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 } 
     1663  IGCM_debug_PushStack "IGCM_sys_build_run_file" 
     1664  if ( $DEBUG_sys ) ; then 
     1665    echo "IGCM_sys_build_run_file" 
     1666  fi 
     1667  IGCM_debug_PopStack "IGCM_sys_build_run_file" 
     1668} 
  • branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_mercurex8.ksh

    r458 r571  
    8383typeset -r RSYNC_opt="-va" 
    8484# ie storage filesystem 
    85 typeset -r RHOST=mercure 
     85typeset -r STOREHOST=${MASTER} 
    8686 
    8787#==================================================== 
     
    133133#==================================================== 
    134134#- IN 
    135 typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM} 
     135typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM} 
    136136typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data} 
    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"} 
     
    161165 
    162166#D-#================================================== 
     167#D-function IGCM_sys_RshMaster 
     168#D-* Purpose: Connection to frontend machine. 
     169#D-* Examples: 
     170#D- 
     171function IGCM_sys_RshMaster { 
     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-#================================================== 
    163188#D-function IGCM_sys_RshArchive 
    164189#D-* Purpose: Archive rsh command 
     
    166191#D- 
    167192function IGCM_sys_RshArchive { 
    168     IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    169     /bin/ksh <<-EOF 
    170 ${@} 
     193  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
     194  /bin/ksh <<-EOF 
     195    ${@} 
    171196EOF 
    172     if [ $? -gt 0 ] ; then 
    173         echo "IGCM_sys_RshArchive : erreur." 
    174         IGCM_debug_Exit "IGCM_sys_RshArchive" 
    175     fi 
    176     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" 
    177202} 
    178203 
     
    183208#D- 
    184209function IGCM_sys_RshPost { 
    185     IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    186     if ( $DEBUG_sys ) ; then 
    187         echo "IGCM_sys_RshPost :" $@ 
    188     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  ============ # 
    189230 
    190231# ============ CESIUM START ============ # 
    191 #    typeset NB_ESSAI DELAI status 
    192 #    #nombre d'essai avant abandon 
    193 #    NB_ESSAI=5 
    194 #    #temps entre chaque essai 
    195 #    DELAI=10 
    196 #    i=0 
    197 #    while [ $i -ne $NB_ESSAI ] ; do 
    198 #        ssh -t mercure ssh cesium /bin/ksh ${@} 2>/dev/null 
    199 #        status=$? 
    200 #        if [ ${status} -ne 0 ]; 
    201 #        then 
    202 #            sleep $DELAI 
    203 #        else 
    204 #            break 
    205 #        fi 
    206 #        let i=$i+1 
    207 #    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_$$ 
    208252# ============ CESIUM  END  ============ # 
    209253 
    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" 
     254  IGCM_debug_PopStack "IGCM_sys_RshPost" 
    216255} 
    217256 
     
    222261#D- 
    223262function 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         # Nothing fo now 
    232     else 
    233         status=completed 
    234     fi 
    235  
    236     ssh ${MASTER} /bin/ksh <<-EOF 
    237     export LOGIN=${LOGIN} 
    238     export config_UserChoices_JobName=${config_UserChoices_JobName} 
    239     export config_UserChoices_MailName=${config_UserChoices_MailName} 
    240     export DateBegin=${DateBegin} 
    241     export DateEnd=${DateEnd} 
    242     export R_SAVE=${R_SAVE} 
    243     export SUBMIT_DIR=${SUBMIT_DIR} 
    244     export status=${status} 
    245  
    246     cat  << END_MAIL > job_end.mail 
    247 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}, 
    248286 
    249287  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`. 
     
    254292END_MAIL 
    255293 
    256     if [ ! -z ${config_UserChoices_MailName} ] ; then 
    257        mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail 
    258     elif [ -f ~/.forward ] ; then 
    259        mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
    260     fi 
    261  
    262     sleep 10 
    263     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 
    264302EOF 
    265303 
    266     if [ $? -gt 0 ] ; then 
    267         echo "IGCM_sys_SendMail : erreur." 
    268         IGCM_debug_Exit "IGCM_sys_SendMail" 
    269     fi 
    270     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" 
    271309} 
    272310 
     
    277315#D- 
    278316function IGCM_sys_Mkdir { 
    279     IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    280     if ( $DEBUG_sys ) ; then 
    281         echo "IGCM_sys_Mkdir :" $@ 
    282     fi 
    283     if [ ! -d ${1} ]; then 
    284         \mkdir -p $1 
    285         if [ $? -gt 0 ] ; then 
    286             echo "IGCM_sys_Mkdir : erreur." 
    287             IGCM_debug_Exit "IGCM_sys_Mkdir" 
    288         fi 
    289     fi 
    290     # vérification : 
    291     if [ ! -d ${1} ] ; then 
    292         echo "IGCM_sys_Mkdir : erreur." 
    293         IGCM_debug_Exit "IGCM_sys_Mkdir" 
    294     fi 
    295     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" 
    296334} 
    297335 
     
    302340#D- 
    303341function IGCM_sys_MkdirArchive { 
    304     IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
    305     if ( $DEBUG_sys ) ; then 
    306         echo "IGCM_sys_MkdirArchive :" $@ 
    307     fi 
    308     #- creation de repertoire sur le serveur fichier 
    309     if [ ! -d ${1} ]; then  
    310         \mkdir -p $1 
    311         if [ $? -gt 0 ] ; then 
    312             echo "IGCM_sys_MkdirArchive : erreur." 
    313             IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
    314         fi 
    315     fi 
    316     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" 
    317355} 
    318356 
     
    323361#D- 
    324362function IGCM_sys_MkdirWork { 
    325     IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    326     if ( $DEBUG_sys ) ; then 
    327         echo "IGCM_sys_MkdirWork :" $@ 
    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_MkdirWork : erreur." 
    334             IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    335         fi 
    336     fi 
    337     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" 
    338376} 
    339377 
     
    344382#D- 
    345383function IGCM_sys_Cd { 
    346     IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    347     if ( $DEBUG_sys ) ; then 
    348         echo "IGCM_sys_Cd :" $@ 
    349     fi 
    350     \cd $1 
    351     if [ $? -gt 0 ] ; then 
    352         echo "IGCM_sys_Cd : erreur." 
    353         IGCM_debug_Exit "IGCM_sys_Cd" 
    354     fi 
    355     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" 
    356394} 
    357395 
     
    362400#D- 
    363401function IGCM_sys_Chmod { 
    364     IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
    365     if ( $DEBUG_sys ) ; then 
    366         echo "IGCM_sys_Chmod :" $@ 
    367     fi 
    368     if [ $DRYRUN -le 1 ]; then 
    369         \chmod $@ 
    370         if [ $? -gt 0 ] ; then 
    371             echo "IGCM_sys_Chmod : erreur." 
    372             IGCM_debug_Exit "IGCM_sys_Chmod" 
    373         fi 
    374     else 
    375         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    376     fi 
    377     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" 
    378416} 
    379417 
     
    384422#D- 
    385423function IGCM_sys_FileSize { 
    386     IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    387  
    388     typeset sizeF 
    389     set +A sizeF -- $( ls -la ${1} ) 
    390     if [ $? -gt 0 ] ; then 
    391         IGCM_debug_Exit "IGCM_sys_FileSize" 
    392     fi 
    393     eval ${2}=${sizeF[4]} 
    394  
    395     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" 
    396434} 
    397435 
     
    402440#D- 
    403441function IGCM_sys_TestDir { 
    404     IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    405     if ( $DEBUG_sys ) ; then 
    406         echo "IGCM_sys_TestDir :" $@ 
    407     fi 
    408     typeset ExistFlag 
    409     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    410     IGCM_debug_PopStack "IGCM_sys_TestDir" 
    411  
    412     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} 
    413451} 
    414452 
     
    419457#D- 
    420458function IGCM_sys_TestDirArchive { 
    421     IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
    422     if ( $DEBUG_sys ) ; then 
    423         echo "IGCM_sys_TestDirArchive :" $@ 
    424     fi 
    425     typeset ExistFlag 
    426     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    427     IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
    428  
    429     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} 
     468} 
     469 
     470#D-#================================================== 
     471#D-function IGCM_sys_IsFileArchived 
     472#D-* Purpose: Test file that must NOT EXISTS on Archive 
     473#D-* Examples: 
     474#D- 
     475function IGCM_sys_IsFileArchived { 
     476  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ 
     477  if ( $DEBUG_sys ) ; then 
     478    echo "IGCM_sys_IsFileArchived :" $@ 
     479  fi 
     480  typeset IsArchivedFlag 
     481  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/dmnfs ) != X ] && echo 0 || echo 1 ) 
     482  IGCM_debug_PopStack "IGCM_sys_IsFileArchived" 
     483 
     484  return ${IsArchivedFlag} 
    430485} 
    431486 
     
    436491#D- 
    437492function IGCM_sys_TestFileArchive { 
    438     IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    439     typeset ExistFlag 
    440     ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    441     IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    442  
    443     return ${ExistFlag} 
     493  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
     494  if ( $DEBUG_sys ) ; then 
     495    echo "IGCM_sys_TestFileArchive :" $@ 
     496  fi 
     497  typeset ExistFlag 
     498  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     499  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
     500 
     501  return ${ExistFlag} 
     502} 
     503 
     504#D-#================================================== 
     505#D-function IGCM_sys_TestFileBuffer 
     506#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     507#D-* Examples: 
     508#D- 
     509function IGCM_sys_TestFileBuffer { 
     510  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     511  typeset ExistFlag 
     512  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     513  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     514 
     515  return ${ExistFlag} 
    444516} 
    445517 
     
    450522#D- 
    451523function IGCM_sys_CountFileArchive { 
    452     IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
    453     ls ${@} 2>/dev/null | wc -l 
    454     if [ $? -gt 0 ] ; then 
    455         echo "IGCM_sys_CountFileArchive : erreur." 
    456     fi 
    457     IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     524  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
     525  ls ${@} 2>/dev/null | wc -l 
     526  if [ $? -gt 0 ] ; then 
     527    echo "IGCM_sys_CountFileArchive : erreur." 
     528  fi 
     529  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     530} 
     531 
     532#D-#================================================== 
     533#D-function IGCM_sys_CountFileBuffer 
     534#D-* Purpose: Count files on Scratch filesystem 
     535#D-* Examples: 
     536#D- 
     537function IGCM_sys_CountFileBuffer { 
     538  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     539  ls ${@} 2>/dev/null | wc -l 
     540  if [ $? -gt 0 ] ; then 
     541    echo "IGCM_sys_CountFileBuffer : erreur." 
     542  fi 
     543  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    458544} 
    459545 
     
    464550#D- 
    465551function IGCM_sys_Tree { 
    466     IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
    467     if ( $DEBUG_sys ) ; then 
    468         echo "IGCM_sys_Tree :" $@ 
    469     fi 
    470  
    471     \ls -lR ${@} 
    472  
    473     IGCM_debug_PopStack "IGCM_sys_Tree" 
     552  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     553  if ( $DEBUG_sys ) ; then 
     554    echo "IGCM_sys_Tree :" $@ 
     555  fi 
     556 
     557  \ls -lR ${@} 
     558 
     559  IGCM_debug_PopStack "IGCM_sys_Tree" 
    474560} 
    475561 
    476562#D-#================================================== 
    477563#D-function IGCM_sys_Tar 
    478 #D-* Purpose: master un-tar command 
     564#D-* Purpose: master tar command 
    479565#D-* Examples: 
    480566#D- 
    481567function IGCM_sys_Tar { 
    482     IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    483     if ( $DEBUG_sys ) ; then 
    484         echo "IGCM_sys_Tar :" $@ 
    485     fi 
    486     \tar xvf $1 
    487     if [ $? -gt 0 ] ; then 
    488         echo "IGCM_sys_Tar : erreur." 
    489         IGCM_debug_Exit "IGCM_sys_Tar" 
    490     fi 
    491     IGCM_debug_PopStack "IGCM_sys_Tar" 
     568  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     569  if ( $DEBUG_sys ) ; then 
     570    echo "IGCM_sys_Tar :" $@ 
     571  fi 
     572  \tar cf $@ 
     573  if [ $? -gt 0 ] ; then 
     574    echo "IGCM_sys_Tar : erreur." 
     575    IGCM_debug_Exit "IGCM_sys_Tar" 
     576  fi 
     577  IGCM_debug_PopStack "IGCM_sys_Tar" 
    492578} 
    493579 
     
    498584#D- 
    499585function IGCM_sys_UnTar { 
    500     IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    501     if ( $DEBUG_sys ) ; then 
    502         echo "IGCM_sys_UnTar :" $@ 
    503     fi 
    504     \tar xvf $1 
    505     if [ $? -gt 0 ] ; then 
    506         echo "IGCM_sys_UnTar : erreur." 
    507         IGCM_debug_Exit "IGCM_sys_UnTar" 
    508     fi 
    509     IGCM_debug_PopStack "IGCM_sys_UnTar" 
     586  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     587  if ( $DEBUG_sys ) ; then 
     588    echo "IGCM_sys_UnTar :" $@ 
     589  fi 
     590  \tar xvf $1 
     591  if [ $? -gt 0 ] ; then 
     592    echo "IGCM_sys_UnTar : erreur." 
     593    IGCM_debug_Exit "IGCM_sys_UnTar" 
     594  fi 
     595  IGCM_debug_PopStack "IGCM_sys_UnTar" 
    510596} 
    511597 
     
    516602#D- 
    517603function IGCM_sys_Qsub { 
    518     IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
    519     if ( $DEBUG_sys ) ; then 
    520         echo "IGCM_sys_Qsub :" $@ 
    521     fi 
    522     /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1 
    523     if [ $? -gt 0 ] ; then 
    524         echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@." 
    525         IGCM_debug_Exit "IGCM_sys_Qsub" 
    526     fi 
    527     IGCM_debug_PopStack "IGCM_sys_Qsub" 
     604  IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
     605  if ( $DEBUG_sys ) ; then 
     606    echo "IGCM_sys_Qsub :" $@ 
     607  fi 
     608  /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1 
     609  if [ $? -gt 0 ] ; then 
     610    echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@." 
     611    IGCM_debug_Exit "IGCM_sys_Qsub" 
     612  fi 
     613  IGCM_debug_PopStack "IGCM_sys_Qsub" 
    528614} 
    529615 
     
    534620#D- 
    535621function IGCM_sys_QsubPost { 
    536     IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
    537     if ( $DEBUG_sys ) ; then 
    538         echo "IGCM_sys_QsubPost :" $@ 
    539     fi 
    540     # ============ CESIUM START ============ # 
    541     #/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 
    542     # ============ CESIUM  END  ============ # 
    543     /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv} 
    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" 
     622  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     623  if ( $DEBUG_sys ) ; then 
     624    echo "IGCM_sys_QsubPost :" $@ 
     625  fi 
     626 
     627# ============ FRONTEND START ============ # 
     628 
     629  /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv} 
     630 
     631# ============ FRONTEND  END  ============ # 
     632 
     633# ============ CESIUM START ============ # 
     634 
     635#  typeset NB_ESSAI DELAI status i 
     636#  # number of tentative 
     637#  NB_ESSAI=10 
     638#  # time delay between tentative 
     639#  DELAI=10 
     640#  (( i = 0 )) 
     641#  while [ $i -lt $NB_ESSAI ] ; do 
     642#    /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 
     643#    status=$? 
     644#    if [ ${status} -gt 0 ]; then 
     645#      sleep $DELAI 
     646#    else 
     647#      break 
     648#    fi 
     649#    (( i = i + 1 )) 
     650#  done  
     651 
     652# ============ CESIUM  END  ============ # 
     653 
     654  if [ $? -gt 0 ] ; then 
     655    echo "IGCM_sys_QsubPost : erreur " $@ 
     656    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     657  fi 
     658  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    549659} 
    550660 
     
    560670#D-  Error values and explanations can depend on your system version. 
    561671function 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      
     672  RET=$1 
     673  if [ ! $RET ] ; then 
     674    echo "rsync error !" 
     675  fi 
     676 
     677  if [ $MYLANG = "fr" ]; then 
     678    case $RET in 
     679    0)  return ;; 
     680    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     681      echo "Erreur de syntaxe ou d'utilisation." 
     682      return;; 
     683    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     684      echo "Incompatibilité de protocole." 
     685      return;; 
     686    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     687      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     688      echo "répertoires" 
     689      return;; 
     690    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     691      echo "Action demandée non supportée : une tentative de manipulation de" 
     692      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     693      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     694      echo "pas par le serveur a été spécifiée." 
     695      return;; 
     696    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     697      echo "Erreur dans le socket d'entrée sortie" 
     698      return;; 
     699    11) echo "Erreur de rsync ; RERR_FILEIO" 
     700      echo "Erreur d'entrée sortie fichier" 
     701      return;; 
     702    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     703      echo "Erreur dans flux de donnée du protocole rsync" 
     704      return;; 
     705    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     706      echo "Erreur avec les diagnostics du programme" 
     707      return;; 
     708    14) echo "Erreur de rsync ; RERR_IPC" 
     709      echo "Erreur dans le code IPC" 
     710      return;; 
     711    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     712      echo "SIGUSR1 ou SIGINT reçu" 
     713      return;; 
     714    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     715      echo "Une erreur retournée par waitpid()" 
     716      return;; 
     717    22) echo "Erreur de rsync ; RERR_MALLOC" 
     718      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     719      return;; 
     720    23) echo "" 
     721      echo "Erreur fichier inexistant" 
     722      return;; 
     723    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     724      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     725      return;; 
     726    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     727      return;; 
     728    esac 
     729  elif [ $MYLANG = "en" ] ; then 
     730    case $RET in 
     731    0)  return;;                 
     732    1)  echo "rsync error : Syntax or usage error " 
     733      return;; 
     734    2)  echo "rsync error : Protocol incompatibility " 
     735      return;; 
     736    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     737      return;; 
     738    4)  echo "rsync error : Requested action not supported: an attempt" 
     739      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     740      echo "them; or an option was specified that is supported by the client and" 
     741      echo "not by the server." 
     742      return;; 
     743    5)  echo "rsync error : Error starting client-server protocol" 
     744      return;; 
     745    10) echo "rsync error : Error in socket I/O " 
     746      return;; 
     747    11) echo "rsync error : Error in file I/O " 
     748      return;; 
     749    12) echo "rsync error : Error in rsync protocol data stream " 
     750      return;; 
     751    13) echo "rsync error : Errors with program diagnostics " 
     752      return;; 
     753    14) echo "rsync error : Error in IPC code " 
     754      return;; 
     755    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     756      return;; 
     757    21) echo "rsync error : Some error returned by waitpid() " 
     758      return;; 
     759    22) echo "rsync error : Error allocating core memory buffers " 
     760      return;; 
     761    23) echo "rsync error : Partial transfer due to error" 
     762      return;; 
     763    24) echo "rsync error : Partial transfer due to vanished source files" 
     764      return;; 
     765    30) echo "rsync error : Timeout in data send/receive " 
     766      return;; 
     767    *)  echo "rsync error : return code of rsync unknown :" $RET 
     768      return;; 
     769    esac 
     770  else 
     771    echo "unknown language $MYLANG." 
     772    return 
     773  fi 
     774} 
    666775 
    667776#D-#================================================== 
     
    671780#D- 
    672781function IGCM_sys_Mirror_libIGCM { 
    673     IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    674     if ( $DEBUG_sys ) ; then 
    675         echo "IGCM_sys_Mirror_libIGCM" 
    676     fi 
    677  
    678     typeset RET DEST 
    679  
    680     mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    681  
    682     echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
    683     ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
    684     RET=$? 
    685  
    686     if [ ${RET} -gt 0 ] ; then 
    687         echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
    688         cat out_rsync 
    689     fi 
    690     IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
     782  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
     783  if ( $DEBUG_sys ) ; then 
     784    echo "IGCM_sys_Mirror_libIGCM" 
     785  fi 
     786 
     787  typeset RET DEST 
     788 
     789  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
     790 
     791  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
     792  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
     793  RET=$? 
     794 
     795  if [ ${RET} -gt 0 ] ; then 
     796    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
     797    cat out_rsync 
     798  fi 
     799  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    691800} 
    692801 
     
    694803#- Call IGCM_sys_Mirror_libIGCM now ! 
    695804if ( $MirrorlibIGCM ) ; then 
    696     IGCM_sys_Mirror_libIGCM 
     805  IGCM_sys_Mirror_libIGCM 
    697806fi 
    698807 
     
    703812#D- 
    704813function IGCM_sys_Cp { 
    705     IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    706     if ( $DEBUG_sys ) ; then 
    707         echo "IGCM_sys_Cp :" $@ 
    708     fi 
    709  
    710     typeset RET 
    711  
    712     echo cp $@ > out_rsync 2>&1 
    713     \cp $@ >> out_rsync 2>&1 
    714     RET=$? 
    715  
    716     if [ ${RET} -gt 0 ] ; then 
    717         echo "IGCM_sys_Cp : error." 
    718         cat out_rsync 
    719         IGCM_debug_Exit "IGCM_sys_Cp" 
    720      else 
    721         \rm out_rsync 
    722     fi 
    723     IGCM_debug_PopStack "IGCM_sys_Cp" 
     814  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     815  if ( $DEBUG_sys ) ; then 
     816    echo "IGCM_sys_Cp :" $@ 
     817  fi 
     818 
     819  typeset RET 
     820 
     821  echo cp $@ > out_rsync 2>&1 
     822  \cp $@ >> out_rsync 2>&1 
     823  RET=$? 
     824 
     825  if [ ${RET} -gt 0 ] ; then 
     826    echo "IGCM_sys_Cp : error." 
     827    cat out_rsync 
     828    IGCM_debug_Exit "IGCM_sys_Cp" 
     829  else 
     830    \rm out_rsync 
     831  fi 
     832  IGCM_debug_PopStack "IGCM_sys_Cp" 
    724833} 
    725834 
     
    730839#D- 
    731840function IGCM_sys_Rm { 
    732     IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
    733     if ( $DEBUG_sys ) ; then 
    734         echo "IGCM_sys_Rm :" $@ 
    735     fi 
    736  
    737     typeset RET 
    738  
    739     echo rm $@ > out_rsync 2>&1 
    740     \rm $@ >> out_rsync 2>&1 
    741     RET=$? 
    742  
    743     if [ ${RET} -gt 0 ] ; then 
    744         echo "IGCM_sys_Rm : error." 
    745         cat out_rsync 
    746         IGCM_debug_Exit "IGCM_sys_Rm" 
    747     else 
    748         \rm out_rsync 
    749     fi 
    750     IGCM_debug_PopStack "IGCM_sys_Rm" 
     841  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     842  if ( $DEBUG_sys ) ; then 
     843    echo "IGCM_sys_Rm :" $@ 
     844  fi 
     845 
     846  typeset RET 
     847 
     848  echo rm $@ > out_rsync 2>&1 
     849  \rm $@ >> out_rsync 2>&1 
     850  RET=$? 
     851 
     852  if [ ${RET} -gt 0 ] ; then 
     853    echo "IGCM_sys_Rm : error." 
     854    cat out_rsync 
     855    IGCM_debug_Exit "IGCM_sys_Rm" 
     856  else 
     857    \rm out_rsync 
     858  fi 
     859  IGCM_debug_PopStack "IGCM_sys_Rm" 
    751860} 
    752861 
     
    757866#D- 
    758867function IGCM_sys_Mv { 
    759     IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    760     if ( $DEBUG_sys ) ; then 
    761         echo "IGCM_sys_Mv :" $@ 
    762     fi 
    763  
    764     if [ $DRYRUN = 0 ]; then 
    765  
    766         typeset RET 
    767              
    768         echo mv $@ > out_rsync 2>&1 
    769         \mv $@ >> out_rsync 2>&1 
    770         RET=$? 
     868  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     869  if ( $DEBUG_sys ) ; then 
     870    echo "IGCM_sys_Mv :" $@ 
     871  fi 
     872 
     873  if [ $DRYRUN = 0 ]; then 
     874 
     875    typeset RET 
    771876     
    772         if [ ${RET} -gt 0 ] ; then 
    773             echo "IGCM_sys_Mv : error in mv." 
    774             cat out_rsync 
    775             IGCM_debug_Exit "IGCM_sys_Mv" 
    776         else 
    777             \rm out_rsync 
    778         fi 
     877    echo mv $@ > out_rsync 2>&1 
     878    \mv $@ >> out_rsync 2>&1 
     879    RET=$? 
     880     
     881    if [ ${RET} -gt 0 ] ; then 
     882      echo "IGCM_sys_Mv : error in mv." 
     883      cat out_rsync 
     884      IGCM_debug_Exit "IGCM_sys_Mv" 
    779885    else 
    780         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    781     fi 
    782  
    783     IGCM_debug_PopStack "IGCM_sys_Mv" 
     886      \rm out_rsync 
     887    fi 
     888  else 
     889    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     890  fi 
     891 
     892  IGCM_debug_PopStack "IGCM_sys_Mv" 
    784893} 
    785894 
     
    790899#D- 
    791900function IGCM_sys_Put_Dir { 
    792     IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
    793     if ( $DEBUG_sys ) ; then 
    794         echo "IGCM_sys_Put_Dir :" $@ 
    795     fi 
    796     if [ $DRYRUN = 0 ]; then 
    797         if [ ! -d ${1} ] ; then 
    798             echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
    799             IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    800             return 
    801         fi 
    802  
    803         typeset RET 
    804  
    805         # Only if we use rsync 
    806         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    807         # 
    808         #USUAL WAY 
    809         \cp -r $1 $2 > out_rsync 2>&1 
    810         RET=$? 
    811  
    812         if [ ${RET} -gt 0 ] ; then 
    813             echo "IGCM_sys_Put_Dir : error." 
    814             cat out_rsync 
    815             IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    816         else 
    817             \rm out_rsync 
    818         fi 
     901  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     902  if ( $DEBUG_sys ) ; then 
     903    echo "IGCM_sys_Put_Dir :" $@ 
     904  fi 
     905  if [ $DRYRUN = 0 ]; then 
     906    if [ ! -d ${1} ] ; then 
     907      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     908      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     909      return 
     910    fi 
     911 
     912    typeset RET 
     913 
     914    # Only if we use rsync 
     915    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     916    # 
     917    #USUAL WAY 
     918    \cp -r $1 $2 > out_rsync 2>&1 
     919    RET=$? 
     920 
     921    if [ ${RET} -gt 0 ] ; then 
     922      echo "IGCM_sys_Put_Dir : error." 
     923      cat out_rsync 
     924      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    819925    else 
    820         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    821     fi 
    822     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     926      \rm out_rsync 
     927    fi 
     928  else 
     929    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     930  fi 
     931  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    823932} 
    824933 
    825934#D-#================================================== 
    826935#D-function IGCM_sys_Get_Dir 
    827 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     936#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    828937#D-* Examples: 
    829938#D- 
    830939function IGCM_sys_Get_Dir { 
    831     IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
    832     if ( $DEBUG_sys ) ; then 
    833         echo "IGCM_sys_Get_Dir :" $@ 
    834     fi 
    835     if [ $DRYRUN = 0 ]; then 
    836         if [ ! -d ${1} ] ; then 
    837             echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
    838             IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    839             return 
    840         fi 
    841  
    842         typeset RET 
    843  
    844         # Only if we use rsync 
    845         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    846         # 
    847         #USUAL WAY 
    848         \cp -r $1 $2 > out_rsync 2>&1 
    849         RET=$? 
    850  
    851         if [ ${RET} -gt 0 ] ; then 
    852             echo "IGCM_sys_Get_Dir : error." 
    853             cat out_rsync 
    854             IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    855         else 
    856             \rm out_rsync 
    857         fi 
     940  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     941  if ( $DEBUG_sys ) ; then 
     942    echo "IGCM_sys_Get_Dir :" $@ 
     943  fi 
     944  if [ $DRYRUN = 0 ]; then 
     945#    if [ ! -d ${1} ] ; then 
     946#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     947#      IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     948#      return 
     949#    fi 
     950 
     951    typeset RET 
     952 
     953    # Only if we use rsync 
     954    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     955    # 
     956    # USUAL WAY 
     957    # add dmfind/dmget (to demigrate all offline files) : 
     958    dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget 
     959    \cp -r $1 $2 > out_rsync 2>&1 
     960    RET=$? 
     961 
     962    if [ ${RET} -gt 0 ] ; then 
     963      echo "IGCM_sys_Get_Dir : error." 
     964      cat out_rsync 
     965      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    858966    else 
    859         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    860     fi 
    861     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     967      \rm out_rsync 
     968    fi 
     969  else 
     970    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     971  fi 
     972  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    862973} 
    863974 
    864975#D-#================================================== 
    865976#D-function IGCM_sys_Put_Rest 
    866 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     977#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    867978#D-           File and target directory must exist. 
    868979#D-* Examples: 
    869980#D- 
    870981function IGCM_sys_Put_Rest { 
    871     IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
    872     if ( $DEBUG_sys ) ; then 
    873         echo "IGCM_sys_Put_Rest :" $@ 
    874     fi 
    875     if [ $DRYRUN = 0 ]; then 
    876         if [ ! -f ${1} ] ; then 
    877             echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
    878             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    879         fi 
    880  
    881         typeset RET 
    882         # 
    883         if [ X${JobType} = XRUN ] ; then 
    884             IGCM_sys_Chmod 444 ${1} 
    885         fi 
    886         # 
    887         IGCM_sys_TestDirArchive $( dirname $2 ) 
    888         # 
    889         # USUAL WAY 
    890         putfer $1 $2 > out_rsync 2>&1 
    891         RET=$? 
     982  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     983  if ( $DEBUG_sys ) ; then 
     984    echo "IGCM_sys_Put_Rest :" $@ 
     985  fi 
     986  if [ $DRYRUN = 0 ]; then 
     987    if [ ! -f ${1} ] ; then 
     988      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     989      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     990    fi 
     991 
     992    typeset RET 
     993    # 
     994    if [ X${JobType} = XRUN ] ; then 
     995      IGCM_sys_Chmod 444 ${1} 
     996    fi 
     997 
     998    # 
     999    # USUAL WAY 
     1000    \cp $1 $2 > out_rsync 2>&1 
     1001    RET=$? 
    8921002 
    8931003#       #RSYNC WITH NETWORK SSH CALL 
    894 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    895 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     1004#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     1005#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    8961006 
    8971007#       #RSYNC WITH NFS USE 
     
    9051015#       (( RET=RET+$? )) 
    9061016 
    907         if [ ${RET} -gt 0 ] ; then 
    908             echo "IGCM_sys_Put_Rest : error." 
    909             cat out_rsync 
    910             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    911         else 
    912             \rm out_rsync 
    913         fi 
     1017    if [ ${RET} -gt 0 ] ; then 
     1018      echo "IGCM_sys_Put_Rest : error." 
     1019      cat out_rsync 
     1020      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    9141021    else 
    915         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    916     fi 
    917     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1022      \rm out_rsync 
     1023    fi 
     1024  else 
     1025    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1026  fi 
     1027  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1028} 
     1029 
     1030#D-#================================================== 
     1031#D-function IGCM_sys_PutBuffer_Rest 
     1032#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     1033#D-           File and target directory must exist. 
     1034#D-* Examples: 
     1035#D- 
     1036function IGCM_sys_PutBuffer_Rest { 
     1037  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     1038  if ( $DEBUG_sys ) ; then 
     1039    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     1040  fi 
     1041  if [ $DRYRUN = 0 ]; then 
     1042    if [ ! -f ${1} ] ; then 
     1043      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     1044      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1045    fi 
     1046 
     1047    typeset RET 
     1048    # 
     1049    if [ X${JobType} = XRUN ] ; then 
     1050      IGCM_sys_Chmod 444 ${1} 
     1051    fi 
     1052 
     1053    # 
     1054    # USUAL WAY 
     1055    \cp $1 $2 > out_rsync 2>&1 
     1056    RET=$? 
     1057 
     1058    if [ ${RET} -gt 0 ] ; then 
     1059      echo "IGCM_sys_PutBuffer_Rest : error." 
     1060      cat out_rsync 
     1061      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1062    else 
     1063      \rm out_rsync 
     1064    fi 
     1065  else 
     1066    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1067  fi 
     1068  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    9181069} 
    9191070 
    9201071#D-#================================================== 
    9211072#D-function IGCM_sys_Put_Out 
    922 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     1073#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    9231074#D-* Examples: 
    9241075#D- 
    9251076function IGCM_sys_Put_Out { 
    926     IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
    927     if ( $DEBUG_sys ) ; then 
    928         echo "IGCM_sys_Put_Out :" $@ 
    929     fi 
    930     if [ $DRYRUN = 0 ]; then 
    931         if [ ! -f ${1} ] ; then 
    932             echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
    933             IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    934             return 1 
    935         fi 
    936         # 
    937         IGCM_sys_MkdirArchive $( dirname $2 ) 
    938         # 
    939         typeset RET 
    940  
    941         #===================================================== 
    942         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    943         #===================================================== 
    944  
    945         #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
    946         #if [ $? -eq 0 ] ; then 
    947         #    typeset WORKPATH FILEPATH 
    948         #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    949         #    IGCM_sys_MkdirWork ${WORKPATH}  
    950         #    FILEPATH=${WORKPATH}/$( basename $2 ) 
    951         #    # 
    952         #    IGCM_sys_Cp ${1} ${FILEPATH} 
    953         #fi 
    954  
    955         if [ X${JobType} = XRUN ] ; then 
    956             if [ X${3} = X ] ; then 
    957                 IGCM_sys_Chmod 444 ${1} 
    958             fi 
    959         fi 
    960         # 
    961         # USUAL WAY 
    962         putfer $1 $2 > out_rsync 2>&1 
    963         RET=$? 
     1077  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     1078  if ( $DEBUG_sys ) ; then 
     1079    echo "IGCM_sys_Put_Out :" $@ 
     1080  fi 
     1081  if [ $DRYRUN = 0 ]; then 
     1082    if [ ! -f ${1} ] ; then 
     1083      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     1084      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1085      return 1 
     1086    fi 
     1087    # 
     1088    IGCM_sys_MkdirArchive $( dirname $2 ) 
     1089    # 
     1090    typeset RET 
     1091 
     1092    #===================================================== 
     1093    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1094    #===================================================== 
     1095 
     1096    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     1097    #if [ $? -eq 0 ] ; then 
     1098    #    typeset WORKPATH FILEPATH 
     1099    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     1100    #    IGCM_sys_MkdirWork ${WORKPATH}  
     1101    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     1102    #    # 
     1103    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1104    #fi 
     1105 
     1106    if [ X${JobType} = XRUN ] ; then 
     1107      if [ X${3} = X ] ; then 
     1108        IGCM_sys_Chmod 444 ${1} 
     1109      fi 
     1110    fi 
     1111    # 
     1112    # USUAL WAY 
     1113    \cp $1 $2 > out_rsync 2>&1 
     1114    RET=$? 
    9641115 
    9651116#       #RSYNC WITH NETWORK SSH CALL 
    966 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    967 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     1117#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     1118#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    9681119 
    9691120#       #RSYNC WITH NFS USE 
     
    9771128#       (( RET=RET+$? )) 
    9781129 
    979         if [ ${RET} -gt 0 ] ; then 
    980             echo "IGCM_sys_Put_Out : error." 
    981             cat out_rsync 
    982             IGCM_debug_Exit "IGCM_sys_Put_Out" 
    983         else 
    984             \rm out_rsync 
    985         fi 
     1130    if [ ${RET} -gt 0 ] ; then 
     1131      echo "IGCM_sys_Put_Out : error." 
     1132      cat out_rsync 
     1133      IGCM_debug_Exit "IGCM_sys_Put_Out" 
    9861134    else 
    987         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    988     fi 
    989     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    990     return 0 
     1135      \rm out_rsync 
     1136    fi 
     1137  else 
     1138    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1139  fi 
     1140  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1141  return 0 
     1142} 
     1143 
     1144#D-#================================================== 
     1145#D-function IGCM_sys_PutBuffer_Out 
     1146#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
     1147#D-* Examples: 
     1148#D- 
     1149function IGCM_sys_PutBuffer_Out { 
     1150  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     1151  if ( $DEBUG_sys ) ; then 
     1152    echo "IGCM_sys_PutBuffer_Out :" $@ 
     1153  fi 
     1154  if [ $DRYRUN = 0 ]; then 
     1155    if [ ! -f ${1} ] ; then 
     1156      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     1157      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1158      return 1 
     1159    fi 
     1160    # 
     1161    IGCM_sys_Mkdir $( dirname $2 ) 
     1162    # 
     1163    typeset RET 
     1164 
     1165    if [ X${JobType} = XRUN ] ; then 
     1166      if [ X${3} = X ] ; then 
     1167        IGCM_sys_Chmod 444 ${1} 
     1168      fi 
     1169    fi 
     1170    # 
     1171    # USUAL WAY 
     1172    \cp $1 $2 > out_rsync 2>&1 
     1173    RET=$? 
     1174 
     1175    if [ ${RET} -gt 0 ] ; then 
     1176      echo "IGCM_sys_PutBuffer_Out : error." 
     1177      cat out_rsync 
     1178      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
     1179    else 
     1180      \rm out_rsync 
     1181    fi 
     1182  else 
     1183    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1184  fi 
     1185  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1186  return 0 
    9911187} 
    9921188 
     
    9971193#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    9981194function IGCM_sys_Get { 
    999     IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    1000  
    1001     typeset DEST RET dm_liste ifile target file_work  
    1002  
    1003     if ( $DEBUG_sys ) ; then 
    1004         echo "IGCM_sys_Get :" $@ 
    1005     fi 
    1006     if [ $DRYRUN -le 2 ]; then 
    1007         if [ X${1} = X'/l' ] ; then 
    1008             # test if the first file is present in the old computation : 
    1009             eval set +A dm_liste \${${2}} 
    1010         else 
    1011             eval set +A dm_liste ${1} 
    1012         fi 
    1013         eval DEST=\${${#}} 
    1014  
    1015         #===================================================== 
    1016         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1017         #===================================================== 
    1018  
    1019         # Is it an R_OUT file (not R_IN) ? 
    1020         #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
    1021         #if [ $? -eq 0 ] ; then 
    1022         #    # Yes  ? then we try to get it in SCRATCHDIR 
    1023         #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    1024         #    if [ -f ${file_work[0]} ] ; then 
    1025         #       IGCM_sys_Cp ${file_work[*]} ${DEST} 
    1026         #       IGCM_debug_PopStack "IGCM_sys_Get" 
    1027         #       return 
    1028         #    fi 
    1029         #fi 
    1030  
    1031         # test if the (first) file is present in the old computation : 
    1032         IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1033         RET=$? 
    1034         if [ ${RET} -gt 0 ] ; then 
    1035             echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    1036             IGCM_debug_Exit "IGCM_sys_Get" 
    1037             IGCM_debug_PopStack "IGCM_sys_Get" 
    1038             return 
    1039         fi 
    1040  
    1041         dmget ${dm_liste[*]} > out_rsync 2>&1 
    1042         RET=$? 
    1043         if [ ${RET} -gt 0 ] ; then 
    1044             echo "IGCM_sys_Get : demigration error." 
    1045             cat out_rsync 
    1046             IGCM_debug_Exit "IGCM_sys_Get" 
    1047         fi 
    1048  
    1049         #USUAL WAY 
    1050         if [ X${1} = X'/l' ] ; then 
    1051             (( RET=0 )) 
    1052             for target in ${dm_liste[*]} ; do 
    1053                 local_file=$( basename ${target} ) 
    1054                 \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1055                 (( RET = RET + $? )) 
    1056             done 
    1057         else 
    1058             \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
    1059             RET=$? 
    1060         fi 
     1195  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1196 
     1197  typeset DEST RET dm_liste ifile target file_work  
     1198 
     1199  if ( $DEBUG_sys ) ; then 
     1200    echo "IGCM_sys_Get :" $@ 
     1201  fi 
     1202  if [ $DRYRUN -le 2 ]; then 
     1203    if [ X${1} = X'/l' ] ; then 
     1204      # test if the first file is present in the old computation : 
     1205      eval set +A dm_liste \${${2}} 
     1206    else 
     1207      eval set +A dm_liste ${1} 
     1208    fi 
     1209    eval DEST=\${${#}} 
     1210 
     1211    #===================================================== 
     1212    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1213    #===================================================== 
     1214 
     1215    # Is it an R_OUT file (not R_IN) ? 
     1216    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1217    #if [ $? -eq 0 ] ; then 
     1218    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1219    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1220    #    if [ -f ${file_work[0]} ] ; then 
     1221    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1222    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1223    #   return 
     1224    #    fi 
     1225    #fi 
     1226 
     1227    # test if the (first) file is present in the old computation : 
     1228    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1229    RET=$? 
     1230    if [ ${RET} -gt 0 ] ; then 
     1231      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1232      IGCM_debug_Exit "IGCM_sys_Get" 
     1233    fi 
     1234 
     1235    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1236    RET=$? 
     1237    if [ ${RET} -gt 0 ] ; then 
     1238      echo "WARNING IGCM_sys_Get : demigration error." 
     1239      cat out_rsync 
     1240      echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
     1241    fi 
     1242 
     1243    #if [ ${RET} -gt 0 ] ; then 
     1244    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1245    #   cat out_rsync 
     1246    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1247    #   sleep 30 
     1248    #   echo "We try another time" 
     1249    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1250    #   RET=$? 
     1251    #   if [ ${RET} -gt 0 ] ; then 
     1252    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1253    #       cat out_rsync 
     1254    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1255    #   fi 
     1256    #    else 
     1257    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1258    #   cat out_rsync 
     1259    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1260    #    fi 
     1261    #fi 
     1262 
     1263    #USUAL WAY 
     1264    if [ X${1} = X'/l' ] ; then 
     1265      (( RET=0 )) 
     1266      for target in ${dm_liste[*]} ; do 
     1267        local_file=$( basename ${target} ) 
     1268        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1269        (( RET = RET + $? )) 
     1270      done 
     1271    else 
     1272      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1273      RET=$? 
     1274    fi 
    10611275 
    10621276#       #RSYNC WITH NETWORK SSH CALL 
    1063 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
    1064 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
     1277#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
     1278#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
    10651279 
    10661280#       #RSYNC WITH NFS USE 
     
    10741288#       (( RET=RET+$? )) 
    10751289 
    1076         if [ ${RET} -gt 0 ] ; then 
    1077             echo "IGCM_sys_Get : copy error." 
    1078             cat out_rsync 
    1079             IGCM_debug_Exit "IGCM_sys_Get" 
    1080         else 
    1081             \rm out_rsync 
    1082         fi 
     1290    if [ ${RET} -gt 0 ] ; then 
     1291      echo "IGCM_sys_Get : copy error." 
     1292      cat out_rsync 
     1293      IGCM_debug_Exit "IGCM_sys_Get" 
    10831294    else 
    1084         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1085     fi 
    1086     IGCM_debug_PopStack "IGCM_sys_Get" 
    1087 } 
    1088  
    1089 ############################################################## A FINIR !! 
     1295      \rm out_rsync 
     1296    fi 
     1297  else 
     1298    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1299  fi 
     1300  IGCM_debug_PopStack "IGCM_sys_Get" 
     1301} 
     1302 
     1303#D-#================================================== 
     1304#D-function IGCM_sys_GetBuffer 
     1305#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1306#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1307#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1308function IGCM_sys_GetBuffer { 
     1309  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1310 
     1311  typeset DEST RET buf_liste ifile target file_work  
     1312 
     1313  if ( $DEBUG_sys ) ; then 
     1314    echo "IGCM_sys_GetBuffer :" $@ 
     1315  fi 
     1316  if [ $DRYRUN -le 2 ]; then 
     1317    if [ X${1} = X'/l' ] ; then 
     1318      # test if the first file is present in the old computation : 
     1319      eval set +A buf_liste \${${2}} 
     1320    else 
     1321      eval set +A buf_liste ${1} 
     1322    fi 
     1323    eval DEST=\${${#}} 
     1324 
     1325    #USUAL WAY 
     1326    if [ X${1} = X'/l' ] ; then 
     1327      (( RET=0 )) 
     1328      for target in ${buf_liste[*]} ; do 
     1329        local_file=$( basename ${target} ) 
     1330        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1331        (( RET = RET + $? )) 
     1332      done 
     1333    else 
     1334      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1335      RET=$? 
     1336    fi 
     1337 
     1338    if [ ${RET} -gt 0 ] ; then 
     1339      echo "IGCM_sys_GetBuffer : copy error." 
     1340      cat out_rsync 
     1341      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1342    else 
     1343      \rm out_rsync 
     1344    fi 
     1345  else 
     1346    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1347  fi 
     1348  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
     1349} 
    10901350 
    10911351#D-#================================================== 
     
    10951355#D- 
    10961356function IGCM_sys_GetDate_FichWork { 
    1097     IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1098     if ( $DEBUG_sys ) ; then 
    1099         echo "IGCM_sys_GetDate_FichWork :" $@ 
    1100     fi 
     1357  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1358  if ( $DEBUG_sys ) ; then 
     1359    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1360  fi 
     1361  typeset dateF 
     1362  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1363  eval ${2}=${dateF[5]} 
     1364 
    11011365    # donne la date filesys d'un fichier sur la machine work 
    1102     IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1366  IGCM_debug_PopStack "IGCM_sys_FichWork" 
    11031367} 
    11041368 
     
    11091373#D- 
    11101374function IGCM_sys_GetDate_FichArchive { 
    1111     IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1112     if ( $DEBUG_sys ) ; then 
    1113         echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1114     fi 
    1115     IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1375  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1376  if ( $DEBUG_sys ) ; then 
     1377    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1378  fi 
     1379  typeset dateF 
     1380  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1381  eval ${2}=${dateF[5]} 
     1382 
     1383  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    11161384} 
    11171385 
     
    11201388 
    11211389function IGCM_sys_rebuild { 
    1122     IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
    1123     if ( $DEBUG_sys ) ; then 
    1124         echo "IGCM_sys_rebuild :" $@ 
    1125     fi 
    1126     /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@ 
    1127     if [ $? -gt 0 ] ; then 
    1128        echo "IGCM_sys_rebuild : erreur ${@}." 
    1129        IGCM_debug_Exit "rebuild" 
    1130     fi 
    1131  
    1132     IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1390  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1391  if ( $DEBUG_sys ) ; then 
     1392    echo "IGCM_sys_rebuild :" $@ 
     1393  fi 
     1394  /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@ 
     1395  if [ $? -gt 0 ] ; then 
     1396    echo "IGCM_sys_rebuild : erreur ${@}." 
     1397    IGCM_debug_Exit "rebuild" 
     1398  fi 
     1399 
     1400  IGCM_debug_PopStack "IGCM_sys_rebuild" 
    11331401} 
    11341402 
     
    11371405 
    11381406function IGCM_sys_activ_variables { 
    1139     IGCM_debug_PushStack "IGCM_sys_activ_variables" 
    1140     if ( $DEBUG_sys ) ; then 
    1141         echo "IGCM_sys_activ_variables" 
    1142     fi 
     1407  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1408  if ( $DEBUG_sys ) ; then 
     1409    echo "IGCM_sys_activ_variables" 
     1410  fi 
    11431411 
    11441412# -------------------------------------------------------------------- 
     
    11471415 
    11481416#D-- MPISUSPEND 
    1149     export MPISUSPEND=${MPISUSPEND:=OFF} 
     1417  export MPISUSPEND=${MPISUSPEND:=OFF} 
    11501418 
    11511419#D-- MPIPROGINF #other choices : ALL_DETAIL2 
    1152     export MPIPROGINF=ALL 
     1420  export MPIPROGINF=ALL 
    11531421#D- activate ftrace (with -ftrace) 
    1154     export F_FTRACE=YES 
     1422  export F_FTRACE=YES 
    11551423#D- communication information (with -ftrace) 
    1156     export MPICOMMINF=DETAIL 
     1424  export MPICOMMINF=DETAIL 
    11571425 
    11581426# -------------------------------------------------------------------- 
     
    11611429 
    11621430#D- max number of character/line in output job 
    1163     export F_SYSLEN=5000 
     1431  export F_SYSLEN=5000 
    11641432#D- number of error that can be admitted on the NEC 
    1165     export F_ERRCNT=0 
     1433  export F_ERRCNT=0 
    11661434#D- global performance 
    1167     export F_PROGINF=DETAIL 
     1435  export F_PROGINF=DETAIL 
    11681436 
    11691437#D- I/O performance (FORTRAN I/O only not netCDF) 
    1170     export F_FILEINF=${F_FILEINF:=NO} 
     1438  export F_FILEINF=${F_FILEINF:=NO} 
    11711439#D- netCDF I/O performance 
    1172     export NC_FILEINF=${NC_FILEINF:=NO} 
    1173  
    1174     IGCM_debug_PopStack "IGCM_sys_activ_variables" 
     1440  export NC_FILEINF=${NC_FILEINF:=NO} 
     1441 
     1442  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    11751443} 
    11761444 
     
    11791447 
    11801448function IGCM_sys_desactiv_variables { 
    1181     IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
    1182     if ( $DEBUG_sys ) ; then 
    1183         echo "IGCM_sys_desactiv_variables" 
    1184     fi 
     1449  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1450  if ( $DEBUG_sys ) ; then 
     1451    echo "IGCM_sys_desactiv_variables" 
     1452  fi 
    11851453# -------------------------------------------------------------------- 
    11861454#D- MPI specifications 
     
    11881456 
    11891457#D-- MPIPROGINF 
    1190     export MPIPROGINF=NO 
     1458  export MPIPROGINF=NO 
    11911459 
    11921460# -------------------------------------------------------------------- 
     
    11951463 
    11961464#D- global performance 
    1197     export F_PROGINF=NO   
    1198  
    1199     IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
     1465  export F_PROGINF=NO   
     1466 
     1467  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
    12001468} 
    12011469 
     
    12041472 
    12051473function IGCM_sys_build_run_file { 
    1206     IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
    1207     if ( $DEBUG_sys ) ; then 
    1208         echo "IGCM_sys_build_run_file " $@ 
    1209     fi 
    1210     (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 )) 
    1211     (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
    1212     (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
    1213      
    1214     if [ $1 = MPI2 ]; then 
    1215         cat <<EOF > run_file 
     1474  IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 
     1475  if ( $DEBUG_sys ) ; then 
     1476    echo "IGCM_sys_build_run_file " $@ 
     1477  fi 
     1478  (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 )) 
     1479  (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
     1480  (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM )) 
     1481   
     1482  if [ $1 = MPI2 ]; then 
     1483    cat <<EOF > run_file 
    12161484-p 1 -np 1 -e ./oasis 
    12171485EOF 
    1218         (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 )) 
    1219         config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"' 
    1220  
    1221     elif [ $1 = MPI1 ]; then 
    1222         cat <<EOF > run_file 
     1486    (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 )) 
     1487    config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"' 
     1488 
     1489  elif [ $1 = MPI1 ]; then 
     1490    cat <<EOF > run_file 
    12231491-p $NUM_PROC_OASIS -e ./oasis 
    12241492-p $NUM_PROC_ATM -e ./lmdz.x 
    12251493-p $NUM_PROC_OCE -e ./opa.xx 
    12261494EOF 
    1227   
    1228     fi 
    1229  
    1230     IGCM_debug_PopStack "IGCM_sys_build_run_file" 
    1231    
    1232 } 
     1495  fi 
     1496  IGCM_debug_PopStack "IGCM_sys_build_run_file" 
     1497} 
  • branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_mercurex9.ksh

    r560 r571  
    99# IPSL (2006) 
    1010#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC 
    11 # History: 
    12 # Modification: 
    1311# 
    1412#************************************************************** 
     
    8583typeset -r RSYNC_opt="-va" 
    8684# ie storage filesystem 
    87 typeset -r RHOST=mercure 
     85typeset -r STOREHOST=${MASTER} 
    8886 
    8987#==================================================== 
     
    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 
     
    135133#==================================================== 
    136134#- IN 
    137 typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM} 
     135typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM} 
    138136typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data} 
    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#==================================================== 
     
    149155#- RUN_DIR_PATH : Temporary working directory (=> TMP) 
    150156typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${LOCALTMPDIR}} 
    151  
    152 #==================================================== 
    153 #- BIG_DIR : BIG_DIR to store files waiting for rebuild 
    154 typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    155157 
    156158#==================================================== 
     
    172174 
    173175#D-#================================================== 
     176#D-function IGCM_sys_RshMaster 
     177#D-* Purpose: Connection to frontend machine. 
     178#D-* Examples: 
     179#D- 
     180function IGCM_sys_RshMaster { 
     181  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
     182  ssh -t ${MASTER} /bin/ksh <<-EOF 
     183  export libIGCM=${libIGCM} 
     184  export DEBUG_debug=${DEBUG_debug} 
     185  . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
     186  . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
     187  ${@} 
     188EOF 
     189  if [ $? -gt 0 ] ; then 
     190    echo "IGCM_sys_RshMaster : erreur." 
     191    IGCM_debug_Exit "IGCM_sys_RshMaster" 
     192  fi 
     193  IGCM_debug_PopStack "IGCM_sys_RshMaster" 
     194} 
     195 
     196#D-#================================================== 
    174197#D-function IGCM_sys_RshArchive 
    175198#D-* Purpose: Archive rsh command 
     
    177200#D- 
    178201function IGCM_sys_RshArchive { 
    179     IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    180     /bin/ksh <<-EOF 
    181 ${@} 
     202  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
     203  /bin/ksh <<-EOF 
     204    ${@} 
    182205EOF 
    183     if [ $? -gt 0 ] ; then 
    184         echo "IGCM_sys_RshArchive : erreur." 
    185         IGCM_debug_Exit "IGCM_sys_RshArchive" 
    186     fi 
    187     IGCM_debug_PopStack "IGCM_sys_RshArchive" 
     206  if [ $? -gt 0 ] ; then 
     207    echo "IGCM_sys_RshArchive : erreur." 
     208    IGCM_debug_Exit "IGCM_sys_RshArchive" 
     209  fi 
     210  IGCM_debug_PopStack "IGCM_sys_RshArchive" 
    188211} 
    189212 
     
    194217#D- 
    195218function IGCM_sys_RshPost { 
    196     IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    197     if ( $DEBUG_sys ) ; then 
    198         echo "IGCM_sys_RshPost :" $@ 
    199     fi 
     219  IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
     220  if ( $DEBUG_sys ) ; then 
     221    echo "IGCM_sys_RshPost :" $@ 
     222  fi 
     223 
     224  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL 
     225  #cat tmp_IGCM_sys_RshPost_$$ 
     226  # keep standard input (stdin) for the loop onto temporary file 
     227  cat >tmp_IGCM_sys_RshPost_$$ 
     228 
     229# ============ FRONTEND START ============ # 
     230 
     231#  /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     232#  if [ $? -gt 0 ] ; then 
     233#    echo "IGCM_sys_RshPost : erreur." 
     234#    IGCM_debug_Exit "IGCM_sys_RshPost" 
     235#  fi 
     236#  \rm tmp_IGCM_sys_RshPost_$$ 
     237 
     238# ============ FRONTEND  END  ============ # 
    200239 
    201240# ============ CESIUM START ============ # 
    202     typeset NB_ESSAI DELAI status i 
    203     # keep standard input for the loop onto temporary file 
    204     cat >tmp_IGCM_sys_RshPost_$$ 
    205     # number of tentative 
    206     NB_ESSAI=10 
    207     # time delay between tentative 
    208     DELAI=10 
    209     (( i = 0 )) 
    210     while [ $i -lt $NB_ESSAI ] ; do 
    211         ssh -t mercure01 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
    212         status=$? 
    213         if [ ${status} -gt 0 ]; then 
    214             IGCM_debug_Print 2 "IGCM_sys_RshPost : ssh failed ${i}/${NB_ESSAI}" 
    215             IGCM_debug_Print 2 "IGCM_sys_RshPost : sleep ${DELAI} seconds and try again." 
    216             sleep $DELAI 
    217         else 
    218             break 
    219         fi 
    220         (( i = i + 1 )) 
    221     done  
    222     # delete temporary file 
    223     /bin/rm tmp_IGCM_sys_RshPost_$$ 
     241  typeset NB_ESSAI DELAI status i 
     242  # number of tentative 
     243  NB_ESSAI=10 
     244  # time delay between tentative 
     245  DELAI=10 
     246  (( i = 0 )) 
     247  while [ $i -lt $NB_ESSAI ] ; do 
     248    ssh -t mercure01 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     249    status=$? 
     250    if [ ${status} -gt 0 ]; then 
     251      IGCM_debug_Print 2 "IGCM_sys_RshPost : ssh failed ${i}/${NB_ESSAI}" 
     252      IGCM_debug_Print 2 "IGCM_sys_RshPost : sleep ${DELAI} seconds and try again." 
     253      sleep $DELAI 
     254    else 
     255      break 
     256    fi 
     257    (( i = i + 1 )) 
     258  done  
     259  # delete temporary file 
     260  /bin/rm tmp_IGCM_sys_RshPost_$$ 
    224261# ============ CESIUM  END  ============ # 
    225262 
    226 # Uncomment for frontend  
    227 #    /bin/ksh ${@} 
    228 #    if [ $? -gt 0 ] ; then 
    229 #       echo "IGCM_sys_RshPost : erreur." 
    230 #       IGCM_debug_Exit "IGCM_sys_RshPost" 
    231 #    fi 
    232  
    233     IGCM_debug_PopStack "IGCM_sys_RshPost" 
     263  IGCM_debug_PopStack "IGCM_sys_RshPost" 
    234264} 
    235265 
     
    240270#D- 
    241271function IGCM_sys_SendMail { 
    242     IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    243     if ( $DEBUG_sys ) ; then 
    244         echo "IGCM_sys_SendMail :" $@ 
    245     fi 
    246  
    247     if ( ${ExitFlag} ) ; then 
    248         status=failed 
    249     else 
    250         status=completed 
    251     fi 
    252     cat  << END_MAIL > job_end.mail 
    253 Dear ${LOGIN}, 
     272  IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
     273  if ( $DEBUG_sys ) ; then 
     274    echo "IGCM_sys_SendMail :" $@ 
     275  fi 
     276 
     277  if ( ${ExitFlag} ) ; then 
     278    status=failed 
     279  else 
     280    status=completed 
     281  fi 
     282  cat  << END_MAIL > job_end.mail 
     283  Dear ${LOGIN}, 
    254284 
    255285  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`. 
     
    260290END_MAIL 
    261291 
    262     if  [ X"${config_UserChoices_MailName}" != X ] ; then 
    263        mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail 
    264     elif [ -f ~/.forward ] ; then 
    265        mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
    266     else 
    267        mailx -s "${config_UserChoices_JobName} ${status}" ${LOGIN} < job_end.mail 
    268     fi 
    269  
    270     if [ $? -gt 0 ] ; then 
    271         echo "IGCM_sys_SendMail : erreur." 
    272         IGCM_debug_Exit "IGCM_sys_SendMail" 
    273     fi 
    274     IGCM_debug_PopStack "IGCM_sys_SendMail" 
     292  if  [ X"${config_UserChoices_MailName}" != X ] ; then 
     293    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail 
     294  elif [ -f ~/.forward ] ; then 
     295    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
     296  else 
     297    mailx -s "${config_UserChoices_JobName} ${status}" ${LOGIN} < job_end.mail 
     298  fi 
     299 
     300  if [ $? -gt 0 ] ; then 
     301    echo "IGCM_sys_SendMail : erreur." 
     302    IGCM_debug_Exit "IGCM_sys_SendMail" 
     303  fi 
     304  IGCM_debug_PopStack "IGCM_sys_SendMail" 
    275305} 
    276306 
     
    281311#D- 
    282312function IGCM_sys_Mkdir { 
    283     IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    284     if ( $DEBUG_sys ) ; then 
    285         echo "IGCM_sys_Mkdir :" $@ 
    286     fi 
    287     if [ ! -d ${1} ]; then 
    288         \mkdir -p $1 
    289         if [ $? -gt 0 ] ; then 
    290             echo "IGCM_sys_Mkdir : erreur." 
    291             IGCM_debug_Exit "IGCM_sys_Mkdir" 
    292         fi 
    293     fi 
    294     # vérification : 
    295     if [ ! -d ${1} ] ; then 
    296         echo "IGCM_sys_Mkdir : erreur." 
    297         IGCM_debug_Exit "IGCM_sys_Mkdir" 
    298     fi 
    299     IGCM_debug_PopStack "IGCM_sys_Mkdir" 
     313  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
     314  if ( $DEBUG_sys ) ; then 
     315    echo "IGCM_sys_Mkdir :" $@ 
     316  fi 
     317  if [ ! -d ${1} ]; then 
     318    \mkdir -p $1 
     319    if [ $? -gt 0 ] ; then 
     320      echo "IGCM_sys_Mkdir : erreur." 
     321      IGCM_debug_Exit "IGCM_sys_Mkdir" 
     322    fi 
     323  fi 
     324  # vérification : 
     325  if [ ! -d ${1} ] ; then 
     326    echo "IGCM_sys_Mkdir : erreur." 
     327    IGCM_debug_Exit "IGCM_sys_Mkdir" 
     328  fi 
     329  IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    300330} 
    301331 
     
    306336#D- 
    307337function IGCM_sys_MkdirArchive { 
    308     IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
    309     if ( $DEBUG_sys ) ; then 
    310         echo "IGCM_sys_MkdirArchive :" $@ 
    311     fi 
    312     #- creation de repertoire sur le serveur fichier 
    313     if [ ! -d ${1} ]; then  
    314         \mkdir -p $1 
    315         if [ $? -gt 0 ] ; then 
    316             echo "IGCM_sys_MkdirArchive : erreur." 
    317             IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
    318         fi 
    319     fi 
    320     IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
     338  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
     339  if ( $DEBUG_sys ) ; then 
     340    echo "IGCM_sys_MkdirArchive :" $@ 
     341  fi 
     342  #- creation de repertoire sur le serveur fichier 
     343  if [ ! -d ${1} ]; then  
     344    \mkdir -p $1 
     345    if [ $? -gt 0 ] ; then 
     346      echo "IGCM_sys_MkdirArchive : erreur." 
     347      IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
     348    fi 
     349  fi 
     350  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    321351} 
    322352 
     
    327357#D- 
    328358function IGCM_sys_MkdirWork { 
    329     IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    330     if ( $DEBUG_sys ) ; then 
    331         echo "IGCM_sys_MkdirWork :" $@ 
    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_MkdirWork : erreur." 
    338             IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    339         fi 
    340     fi 
    341     IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
     359  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
     360  if ( $DEBUG_sys ) ; then 
     361    echo "IGCM_sys_MkdirWork :" $@ 
     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_MkdirWork : erreur." 
     368      IGCM_debug_Exit "IGCM_sys_MkdirWork" 
     369    fi 
     370  fi 
     371  IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    342372} 
    343373 
     
    348378#D- 
    349379function IGCM_sys_Cd { 
    350     IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    351     if ( $DEBUG_sys ) ; then 
    352         echo "IGCM_sys_Cd :" $@ 
    353     fi 
    354     \cd $1 
    355     if [ $? -gt 0 ] ; then 
    356         echo "IGCM_sys_Cd : erreur." 
    357         IGCM_debug_Exit "IGCM_sys_Cd" 
    358     fi 
    359     IGCM_debug_PopStack "IGCM_sys_Cd" 
     380  IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
     381  if ( $DEBUG_sys ) ; then 
     382    echo "IGCM_sys_Cd :" $@ 
     383  fi 
     384  \cd $1 
     385  if [ $? -gt 0 ] ; then 
     386    echo "IGCM_sys_Cd : erreur." 
     387    IGCM_debug_Exit "IGCM_sys_Cd" 
     388  fi 
     389  IGCM_debug_PopStack "IGCM_sys_Cd" 
    360390} 
    361391 
     
    366396#D- 
    367397function IGCM_sys_Chmod { 
    368     IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
    369     if ( $DEBUG_sys ) ; then 
    370         echo "IGCM_sys_Chmod :" $@ 
    371     fi 
    372     if [ $DRYRUN -le 1 ]; then 
    373         \chmod $@ 
    374         if [ $? -gt 0 ] ; then 
    375             echo "IGCM_sys_Chmod : erreur." 
    376             IGCM_debug_Exit "IGCM_sys_Chmod" 
    377         fi 
    378     else 
    379         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    380     fi 
    381     IGCM_debug_PopStack "IGCM_sys_Chmod" 
     398  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
     399  if ( $DEBUG_sys ) ; then 
     400    echo "IGCM_sys_Chmod :" $@ 
     401  fi 
     402  if [ $DRYRUN -le 1 ]; then 
     403    \chmod $@ 
     404    if [ $? -gt 0 ] ; then 
     405      echo "IGCM_sys_Chmod : erreur." 
     406      IGCM_debug_Exit "IGCM_sys_Chmod" 
     407    fi 
     408  else 
     409    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     410  fi 
     411  IGCM_debug_PopStack "IGCM_sys_Chmod" 
    382412} 
    383413 
     
    388418#D- 
    389419function IGCM_sys_FileSize { 
    390     IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    391  
    392     typeset sizeF 
    393     set +A sizeF -- $( ls -la ${1} ) 
    394     if [ $? -gt 0 ] ; then 
    395         IGCM_debug_Exit "IGCM_sys_FileSize" 
    396     fi 
    397     eval ${2}=${sizeF[4]} 
    398  
    399     IGCM_debug_PopStack "IGCM_sys_FileSize" 
     420  IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
     421 
     422  typeset sizeF 
     423  set +A sizeF -- $( ls -la ${1} ) 
     424  if [ $? -gt 0 ] ; then 
     425    IGCM_debug_Exit "IGCM_sys_FileSize" 
     426  fi 
     427  eval ${2}=${sizeF[4]} 
     428 
     429  IGCM_debug_PopStack "IGCM_sys_FileSize" 
    400430} 
    401431 
     
    406436#D- 
    407437function IGCM_sys_TestDir { 
    408     IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    409     if ( $DEBUG_sys ) ; then 
    410         echo "IGCM_sys_TestDir :" $@ 
    411     fi 
    412     typeset ExistFlag 
    413     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    414     IGCM_debug_PopStack "IGCM_sys_TestDir" 
    415  
    416     return ${ExistFlag} 
     438  IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
     439  if ( $DEBUG_sys ) ; then 
     440    echo "IGCM_sys_TestDir :" $@ 
     441  fi 
     442  typeset ExistFlag 
     443  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     444  IGCM_debug_PopStack "IGCM_sys_TestDir" 
     445 
     446  return ${ExistFlag} 
    417447} 
    418448 
     
    423453#D- 
    424454function IGCM_sys_TestDirArchive { 
    425     IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
    426     if ( $DEBUG_sys ) ; then 
    427         echo "IGCM_sys_TestDirArchive :" $@ 
    428     fi 
    429     typeset ExistFlag 
    430     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    431     IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
    432  
    433     return ${ExistFlag} 
     455  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
     456  if ( $DEBUG_sys ) ; then 
     457    echo "IGCM_sys_TestDirArchive :" $@ 
     458  fi 
     459  typeset ExistFlag 
     460  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     461  IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
     462 
     463  return ${ExistFlag} 
     464} 
     465 
     466#D-#================================================== 
     467#D-function IGCM_sys_IsFileArchived 
     468#D-* Purpose: Test file that must NOT EXISTS on Archive 
     469#D-* Examples: 
     470#D- 
     471function IGCM_sys_IsFileArchived { 
     472  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ 
     473  if ( $DEBUG_sys ) ; then 
     474    echo "IGCM_sys_IsFileArchived :" $@ 
     475  fi 
     476  typeset IsArchivedFlag 
     477  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/dmnfs ) != X ] && echo 0 || echo 1 ) 
     478  IGCM_debug_PopStack "IGCM_sys_IsFileArchived" 
     479 
     480  return ${IsArchivedFlag} 
    434481} 
    435482 
     
    440487#D- 
    441488function IGCM_sys_TestFileArchive { 
    442     IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    443     typeset ExistFlag 
    444     ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    445     IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    446  
    447     return ${ExistFlag} 
     489  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
     490  if ( $DEBUG_sys ) ; then 
     491    echo "IGCM_sys_TestFileArchive :" $@ 
     492  fi 
     493  typeset ExistFlag 
     494  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     495  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
     496 
     497  return ${ExistFlag} 
     498} 
     499 
     500#D-#================================================== 
     501#D-function IGCM_sys_TestFileBuffer 
     502#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     503#D-* Examples: 
     504#D- 
     505function IGCM_sys_TestFileBuffer { 
     506  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     507  typeset ExistFlag 
     508  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     509  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     510 
     511  return ${ExistFlag} 
    448512} 
    449513 
     
    454518#D- 
    455519function IGCM_sys_CountFileArchive { 
    456     IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
    457     ls ${@} 2>/dev/null | wc -l 
    458     if [ $? -gt 0 ] ; then 
    459         echo "IGCM_sys_CountFileArchive : erreur." 
    460     fi 
    461     IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     520  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
     521  ls ${@} 2>/dev/null | wc -l 
     522  if [ $? -gt 0 ] ; then 
     523    echo "IGCM_sys_CountFileArchive : erreur." 
     524  fi 
     525  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     526} 
     527 
     528#D-#================================================== 
     529#D-function IGCM_sys_CountFileBuffer 
     530#D-* Purpose: Count files on Scratch filesystem 
     531#D-* Examples: 
     532#D- 
     533function IGCM_sys_CountFileBuffer { 
     534  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     535  ls ${@} 2>/dev/null | wc -l 
     536  if [ $? -gt 0 ] ; then 
     537    echo "IGCM_sys_CountFileBuffer : erreur." 
     538  fi 
     539  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    462540} 
    463541 
     
    468546#D- 
    469547function IGCM_sys_Tree { 
    470     IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
    471     if ( $DEBUG_sys ) ; then 
    472         echo "IGCM_sys_Tree :" $@ 
    473     fi 
    474  
    475     \ls -lR ${@} 
    476  
    477     IGCM_debug_PopStack "IGCM_sys_Tree" 
     548  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     549  if ( $DEBUG_sys ) ; then 
     550    echo "IGCM_sys_Tree :" $@ 
     551  fi 
     552 
     553  \ls -lR ${@} 
     554 
     555  IGCM_debug_PopStack "IGCM_sys_Tree" 
    478556} 
    479557 
    480558#D-#================================================== 
    481559#D-function IGCM_sys_Tar 
    482 #D-* Purpose: master un-tar command 
     560#D-* Purpose: master tar command 
    483561#D-* Examples: 
    484562#D- 
    485563function IGCM_sys_Tar { 
    486     IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    487     if ( $DEBUG_sys ) ; then 
    488         echo "IGCM_sys_Tar :" $@ 
    489     fi 
    490     \tar xvf $1 
    491     if [ $? -gt 0 ] ; then 
    492         echo "IGCM_sys_Tar : erreur." 
    493         IGCM_debug_Exit "IGCM_sys_Tar" 
    494     fi 
    495     IGCM_debug_PopStack "IGCM_sys_Tar" 
     564  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     565  if ( $DEBUG_sys ) ; then 
     566    echo "IGCM_sys_Tar :" $@ 
     567  fi 
     568  \tar cf $@ 
     569  if [ $? -gt 0 ] ; then 
     570    echo "IGCM_sys_Tar : erreur." 
     571    IGCM_debug_Exit "IGCM_sys_Tar" 
     572  fi 
     573  IGCM_debug_PopStack "IGCM_sys_Tar" 
    496574} 
    497575 
     
    502580#D- 
    503581function IGCM_sys_UnTar { 
    504     IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    505     if ( $DEBUG_sys ) ; then 
    506         echo "IGCM_sys_UnTar :" $@ 
    507     fi 
    508     \tar xvf $1 
    509     if [ $? -gt 0 ] ; then 
    510         echo "IGCM_sys_UnTar : erreur." 
    511         IGCM_debug_Exit "IGCM_sys_UnTar" 
    512     fi 
    513     IGCM_debug_PopStack "IGCM_sys_UnTar" 
     582  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     583  if ( $DEBUG_sys ) ; then 
     584    echo "IGCM_sys_UnTar :" $@ 
     585  fi 
     586  \tar xvf $1 
     587  if [ $? -gt 0 ] ; then 
     588    echo "IGCM_sys_UnTar : erreur." 
     589    IGCM_debug_Exit "IGCM_sys_UnTar" 
     590  fi 
     591  IGCM_debug_PopStack "IGCM_sys_UnTar" 
    514592} 
    515593 
     
    520598#D- 
    521599function IGCM_sys_Qsub { 
    522     IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
    523     if ( $DEBUG_sys ) ; then 
    524         echo "IGCM_sys_Qsub :" $@ 
    525     fi 
    526     /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1 
    527     if [ $? -gt 0 ] ; then 
    528         echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@." 
    529         IGCM_debug_Exit "IGCM_sys_Qsub" 
    530     fi 
    531     IGCM_debug_PopStack "IGCM_sys_Qsub" 
     600  IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
     601  if ( $DEBUG_sys ) ; then 
     602    echo "IGCM_sys_Qsub :" $@ 
     603  fi 
     604  /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1 
     605  if [ $? -gt 0 ] ; then 
     606    echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@." 
     607    IGCM_debug_Exit "IGCM_sys_Qsub" 
     608  fi 
     609  IGCM_debug_PopStack "IGCM_sys_Qsub" 
    532610} 
    533611 
     
    538616#D- 
    539617function IGCM_sys_QsubPost { 
    540     IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
    541     if ( $DEBUG_sys ) ; then 
    542         echo "IGCM_sys_QsubPost :" $@ 
    543     fi 
    544     # ============ CESIUM START ============ # 
    545     typeset NB_ESSAI DELAI status i 
    546     # number of tentative 
    547     NB_ESSAI=10 
    548     # time delay between tentative 
    549     DELAI=10 
    550     (( i = 0 )) 
    551     while [ $i -lt $NB_ESSAI ] ; do 
    552         /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 
    553         status=$? 
    554         if [ ${status} -gt 0 ]; 
    555         then 
    556             sleep $DELAI 
    557         else 
    558             break 
    559         fi 
    560         (( i = i + 1 )) 
    561     done  
    562     # ============ CESIUM  END  ============ # 
    563     #/usr/bin/nqsII/qsub -o ${POST_DIR}/$1.${PeriodDateEnd}.out ${libIGCM}/$1.job -v ${listVarEnv} 
    564     if [ $? -gt 0 ] ; then 
    565         echo "IGCM_sys_QsubPost : erreur " $@ 
    566         IGCM_debug_Exit "IGCM_sys_QsubPost" 
    567     fi 
    568     IGCM_debug_PopStack "IGCM_sys_QsubPost" 
     618  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     619  if ( $DEBUG_sys ) ; then 
     620    echo "IGCM_sys_QsubPost :" $@ 
     621  fi 
     622 
     623# ============ FRONTEND START ============ # 
     624 
     625#  /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv} 
     626 
     627# ============ FRONTEND  END  ============ # 
     628 
     629# ============ CESIUM START ============ # 
     630  typeset NB_ESSAI DELAI status i 
     631  # number of tentative 
     632  NB_ESSAI=10 
     633  # time delay between tentative 
     634  DELAI=10 
     635  (( i = 0 )) 
     636  while [ $i -lt $NB_ESSAI ] ; do 
     637    /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 
     638    status=$? 
     639    if [ ${status} -gt 0 ]; then 
     640      sleep $DELAI 
     641    else 
     642      break 
     643    fi 
     644    (( i = i + 1 )) 
     645  done  
     646# ============ CESIUM  END  ============ # 
     647 
     648  if [ $? -gt 0 ] ; then 
     649    echo "IGCM_sys_QsubPost : erreur " $@ 
     650    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     651  fi 
     652  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    569653} 
    570654 
     
    580664#D-  Error values and explanations can depend on your system version. 
    581665function IGCM_sys_Rsync_out { 
    582     RET=$1 
    583     if [ ! $RET ] ; then 
    584         echo "rsync error !" 
    585     fi 
    586  
    587     if [ $MYLANG = "fr" ]; then 
    588         case $RET in 
    589             0)  return ;; 
    590             1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    591                 echo "Erreur de syntaxe ou d'utilisation." 
    592                 return;; 
    593             2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    594                 echo "Incompatibilité de protocole." 
    595                 return;; 
    596             3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    597                 echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    598                 echo "répertoires" 
    599                 return;; 
    600             4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    601                 echo "Action demandée non supportée : une tentative de manipulation de" 
    602                 echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    603                 echo "été faite ; ou une option qui est supportée par le  client  mais" 
    604                 echo "pas par le serveur a été spécifiée." 
    605                 return;; 
    606             10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    607                 echo "Erreur dans le socket d'entrée sortie" 
    608                 return;; 
    609             11) echo "Erreur de rsync ; RERR_FILEIO" 
    610                 echo "Erreur d'entrée sortie fichier" 
    611                 return;; 
    612             12) echo "Erreur de rsync ; RERR_STREAMIO" 
    613                 echo "Erreur dans flux de donnée du protocole rsync" 
    614                 return;; 
    615             13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    616                 echo "Erreur avec les diagnostics du programme" 
    617                 return;; 
    618             14) echo "Erreur de rsync ; RERR_IPC" 
    619                 echo "Erreur dans le code IPC" 
    620                 return;; 
    621             20) echo "Erreur de rsync ; RERR_SIGNAL" 
    622                 echo "SIGUSR1 ou SIGINT reçu" 
    623                 return;; 
    624             21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    625                 echo "Une erreur retournée par waitpid()" 
    626                 return;; 
    627             22) echo "Erreur de rsync ; RERR_MALLOC" 
    628                 echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    629                 return;; 
    630             23) echo "" 
    631                 echo "Erreur fichier inexistant" 
    632                 return;; 
    633             30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    634                 echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    635                 return;; 
    636             *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
    637                 return;; 
    638         esac 
    639     elif [ $MYLANG = "en" ] ; then 
    640         case $RET in 
    641             0)  return;;                 
    642             1)  echo "rsync error : Syntax or usage error " 
    643                 return;; 
    644             2)  echo "rsync error : Protocol incompatibility " 
    645                 return;; 
    646             3)  echo "rsync error : Errors selecting input/output files, dirs" 
    647                 return;; 
    648             4)  echo "rsync error : Requested action not supported: an attempt" 
    649                 echo "was made to manipulate 64-bit files on a platform that cannot support" 
    650                 echo "them; or an option was specified that is supported by the client and" 
    651                 echo "not by the server." 
    652                 return;; 
    653             5)  echo "rsync error : Error starting client-server protocol" 
    654                 return;; 
    655             10) echo "rsync error : Error in socket I/O " 
    656                 return;; 
    657             11) echo "rsync error : Error in file I/O " 
    658                 return;; 
    659             12) echo "rsync error : Error in rsync protocol data stream " 
    660                 return;; 
    661             13) echo "rsync error : Errors with program diagnostics " 
    662                 return;; 
    663             14) echo "rsync error : Error in IPC code " 
    664                 return;; 
    665             20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    666                 return;; 
    667             21) echo "rsync error : Some error returned by waitpid() " 
    668                 return;; 
    669             22) echo "rsync error : Error allocating core memory buffers " 
    670                 return;; 
    671             23) echo "rsync error : Partial transfer due to error" 
    672                 return;; 
    673             24) echo "rsync error : Partial transfer due to vanished source files" 
    674                 return;; 
    675             30) echo "rsync error : Timeout in data send/receive " 
    676                 return;; 
    677             *)  echo "rsync error : return code of rsync unknown :" $RET 
    678                 return;; 
    679         esac 
    680     else 
    681         echo "unknown language $MYLANG." 
    682         return 
    683     fi 
    684 } 
    685      
     666  RET=$1 
     667  if [ ! $RET ] ; then 
     668    echo "rsync error !" 
     669  fi 
     670 
     671  if [ $MYLANG = "fr" ]; then 
     672    case $RET in 
     673    0)  return ;; 
     674    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     675      echo "Erreur de syntaxe ou d'utilisation." 
     676      return;; 
     677    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     678      echo "Incompatibilité de protocole." 
     679      return;; 
     680    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     681      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     682      echo "répertoires" 
     683      return;; 
     684    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     685      echo "Action demandée non supportée : une tentative de manipulation de" 
     686      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     687      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     688      echo "pas par le serveur a été spécifiée." 
     689      return;; 
     690    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     691      echo "Erreur dans le socket d'entrée sortie" 
     692      return;; 
     693    11) echo "Erreur de rsync ; RERR_FILEIO" 
     694      echo "Erreur d'entrée sortie fichier" 
     695      return;; 
     696    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     697      echo "Erreur dans flux de donnée du protocole rsync" 
     698      return;; 
     699    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     700      echo "Erreur avec les diagnostics du programme" 
     701      return;; 
     702    14) echo "Erreur de rsync ; RERR_IPC" 
     703      echo "Erreur dans le code IPC" 
     704      return;; 
     705    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     706      echo "SIGUSR1 ou SIGINT reçu" 
     707      return;; 
     708    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     709      echo "Une erreur retournée par waitpid()" 
     710      return;; 
     711    22) echo "Erreur de rsync ; RERR_MALLOC" 
     712      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     713      return;; 
     714    23) echo "" 
     715      echo "Erreur fichier inexistant" 
     716      return;; 
     717    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     718      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     719      return;; 
     720    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     721      return;; 
     722    esac 
     723  elif [ $MYLANG = "en" ] ; then 
     724    case $RET in 
     725    0)  return;;                 
     726    1)  echo "rsync error : Syntax or usage error " 
     727      return;; 
     728    2)  echo "rsync error : Protocol incompatibility " 
     729      return;; 
     730    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     731      return;; 
     732    4)  echo "rsync error : Requested action not supported: an attempt" 
     733      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     734      echo "them; or an option was specified that is supported by the client and" 
     735      echo "not by the server." 
     736      return;; 
     737    5)  echo "rsync error : Error starting client-server protocol" 
     738      return;; 
     739    10) echo "rsync error : Error in socket I/O " 
     740      return;; 
     741    11) echo "rsync error : Error in file I/O " 
     742      return;; 
     743    12) echo "rsync error : Error in rsync protocol data stream " 
     744      return;; 
     745    13) echo "rsync error : Errors with program diagnostics " 
     746      return;; 
     747    14) echo "rsync error : Error in IPC code " 
     748      return;; 
     749    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     750      return;; 
     751    21) echo "rsync error : Some error returned by waitpid() " 
     752      return;; 
     753    22) echo "rsync error : Error allocating core memory buffers " 
     754      return;; 
     755    23) echo "rsync error : Partial transfer due to error" 
     756      return;; 
     757    24) echo "rsync error : Partial transfer due to vanished source files" 
     758      return;; 
     759    30) echo "rsync error : Timeout in data send/receive " 
     760      return;; 
     761    *)  echo "rsync error : return code of rsync unknown :" $RET 
     762      return;; 
     763    esac 
     764  else 
     765    echo "unknown language $MYLANG." 
     766    return 
     767  fi 
     768} 
    686769 
    687770#D-#================================================== 
     
    691774#D- 
    692775function IGCM_sys_Mirror_libIGCM { 
    693     IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    694     if ( $DEBUG_sys ) ; then 
    695         echo "IGCM_sys_Mirror_libIGCM" 
    696     fi 
    697  
    698     typeset RET DEST 
    699  
    700     mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    701  
    702     echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
    703     ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
    704     RET=$? 
    705  
    706     if [ ${RET} -gt 0 ] ; then 
    707         echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
    708         cat out_rsync 
    709     fi 
    710     IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
     776  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
     777  if ( $DEBUG_sys ) ; then 
     778    echo "IGCM_sys_Mirror_libIGCM" 
     779  fi 
     780 
     781  typeset RET DEST 
     782 
     783  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
     784 
     785  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
     786  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
     787  RET=$? 
     788 
     789  if [ ${RET} -gt 0 ] ; then 
     790    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
     791    cat out_rsync 
     792  fi 
     793  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    711794} 
    712795 
     
    714797#- Call IGCM_sys_Mirror_libIGCM now ! 
    715798if ( $MirrorlibIGCM ) ; then 
    716     IGCM_sys_Mirror_libIGCM 
     799  IGCM_sys_Mirror_libIGCM 
    717800fi 
    718801 
     
    723806#D- 
    724807function IGCM_sys_Cp { 
    725     IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    726     if ( $DEBUG_sys ) ; then 
    727         echo "IGCM_sys_Cp :" $@ 
    728     fi 
    729  
    730     typeset RET 
    731  
    732     echo cp $@ > out_rsync 2>&1 
    733     \cp $@ >> out_rsync 2>&1 
    734     RET=$? 
    735  
    736     if [ ${RET} -gt 0 ] ; then 
    737         echo "IGCM_sys_Cp : error." 
    738         cat out_rsync 
    739         IGCM_debug_Exit "IGCM_sys_Cp" 
    740      else 
    741         \rm out_rsync 
    742     fi 
    743     IGCM_debug_PopStack "IGCM_sys_Cp" 
     808  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     809  if ( $DEBUG_sys ) ; then 
     810    echo "IGCM_sys_Cp :" $@ 
     811  fi 
     812 
     813  typeset RET 
     814 
     815  echo cp $@ > out_rsync 2>&1 
     816  \cp $@ >> out_rsync 2>&1 
     817  RET=$? 
     818 
     819  if [ ${RET} -gt 0 ] ; then 
     820    echo "IGCM_sys_Cp : error." 
     821    cat out_rsync 
     822    IGCM_debug_Exit "IGCM_sys_Cp" 
     823  else 
     824    \rm out_rsync 
     825  fi 
     826  IGCM_debug_PopStack "IGCM_sys_Cp" 
    744827} 
    745828 
     
    750833#D- 
    751834function IGCM_sys_Rm { 
    752     IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
    753     if ( $DEBUG_sys ) ; then 
    754         echo "IGCM_sys_Rm :" $@ 
    755     fi 
    756  
    757     typeset RET 
    758  
    759     echo rm $@ > out_rsync 2>&1 
    760     \rm $@ >> out_rsync 2>&1 
    761     RET=$? 
    762  
    763     if [ ${RET} -gt 0 ] ; then 
    764         echo "IGCM_sys_Rm : error." 
    765         cat out_rsync 
    766         IGCM_debug_Exit "IGCM_sys_Rm" 
    767     else 
    768         \rm out_rsync 
    769     fi 
    770     IGCM_debug_PopStack "IGCM_sys_Rm" 
     835  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     836  if ( $DEBUG_sys ) ; then 
     837    echo "IGCM_sys_Rm :" $@ 
     838  fi 
     839 
     840  typeset RET 
     841 
     842  echo rm $@ > out_rsync 2>&1 
     843  \rm $@ >> out_rsync 2>&1 
     844  RET=$? 
     845 
     846  if [ ${RET} -gt 0 ] ; then 
     847    echo "IGCM_sys_Rm : error." 
     848    cat out_rsync 
     849    IGCM_debug_Exit "IGCM_sys_Rm" 
     850  else 
     851    \rm out_rsync 
     852  fi 
     853  IGCM_debug_PopStack "IGCM_sys_Rm" 
    771854} 
    772855 
     
    777860#D- 
    778861function IGCM_sys_Mv { 
    779     IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    780     if ( $DEBUG_sys ) ; then 
    781         echo "IGCM_sys_Mv :" $@ 
    782     fi 
    783  
    784     if [ $DRYRUN = 0 ]; then 
    785  
    786         typeset RET 
    787              
    788         echo mv $@ > out_rsync 2>&1 
    789         \mv $@ >> out_rsync 2>&1 
    790         RET=$? 
     862  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     863  if ( $DEBUG_sys ) ; then 
     864    echo "IGCM_sys_Mv :" $@ 
     865  fi 
     866 
     867  if [ $DRYRUN = 0 ]; then 
     868 
     869    typeset RET 
    791870     
    792         if [ ${RET} -gt 0 ] ; then 
    793             echo "IGCM_sys_Mv : error in mv." 
    794             cat out_rsync 
    795             IGCM_debug_Exit "IGCM_sys_Mv" 
    796         else 
    797             \rm out_rsync 
    798         fi 
     871    echo mv $@ > out_rsync 2>&1 
     872    \mv $@ >> out_rsync 2>&1 
     873    RET=$? 
     874     
     875    if [ ${RET} -gt 0 ] ; then 
     876      echo "IGCM_sys_Mv : error in mv." 
     877      cat out_rsync 
     878      IGCM_debug_Exit "IGCM_sys_Mv" 
    799879    else 
    800         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    801     fi 
    802  
    803     IGCM_debug_PopStack "IGCM_sys_Mv" 
     880      \rm out_rsync 
     881    fi 
     882  else 
     883    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     884  fi 
     885 
     886  IGCM_debug_PopStack "IGCM_sys_Mv" 
    804887} 
    805888 
     
    810893#D- 
    811894function IGCM_sys_Put_Dir { 
    812     IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
    813     if ( $DEBUG_sys ) ; then 
    814         echo "IGCM_sys_Put_Dir :" $@ 
    815     fi 
    816     if [ $DRYRUN = 0 ]; then 
    817         if [ ! -d ${1} ] ; then 
    818             echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
    819             IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    820             return 
    821         fi 
    822  
    823         typeset RET 
    824  
    825         # Only if we use rsync 
    826         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    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_Put_Dir : error." 
    834             cat out_rsync 
    835             IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    836         else 
    837             \rm out_rsync 
    838         fi 
     895  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     896  if ( $DEBUG_sys ) ; then 
     897    echo "IGCM_sys_Put_Dir :" $@ 
     898  fi 
     899  if [ $DRYRUN = 0 ]; then 
     900    if [ ! -d ${1} ] ; then 
     901      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     902      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     903      return 
     904    fi 
     905 
     906    typeset RET 
     907 
     908    # Only if we use rsync 
     909    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     910    # 
     911    #USUAL WAY 
     912    \cp -r $1 $2 > out_rsync 2>&1 
     913    RET=$? 
     914 
     915    if [ ${RET} -gt 0 ] ; then 
     916      echo "IGCM_sys_Put_Dir : error." 
     917      cat out_rsync 
     918      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    839919    else 
    840         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    841     fi 
    842     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     920      \rm out_rsync 
     921    fi 
     922  else 
     923    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     924  fi 
     925  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    843926} 
    844927 
    845928#D-#================================================== 
    846929#D-function IGCM_sys_Get_Dir 
    847 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     930#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    848931#D-* Examples: 
    849932#D- 
    850933function IGCM_sys_Get_Dir { 
    851     IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
    852     if ( $DEBUG_sys ) ; then 
    853         echo "IGCM_sys_Get_Dir :" $@ 
    854     fi 
    855     if [ $DRYRUN = 0 ]; then 
    856         if [ ! -d ${1} ] ; then 
    857             echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
    858             IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    859             return 
    860         fi 
    861  
    862         typeset RET 
    863  
    864         # Only if we use rsync 
    865         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    866         # 
    867         #USUAL WAY 
    868         \cp -r $1 $2 > out_rsync 2>&1 
    869         RET=$? 
    870  
    871         if [ ${RET} -gt 0 ] ; then 
    872             echo "IGCM_sys_Get_Dir : error." 
    873             cat out_rsync 
    874             IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    875         else 
    876             \rm out_rsync 
    877         fi 
     934  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     935  if ( $DEBUG_sys ) ; then 
     936    echo "IGCM_sys_Get_Dir :" $@ 
     937  fi 
     938  if [ $DRYRUN = 0 ]; then 
     939#    if [ ! -d ${1} ] ; then 
     940#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     941#      IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     942#      return 
     943#    fi 
     944 
     945    typeset RET 
     946 
     947    # Only if we use rsync 
     948    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     949    # 
     950    # USUAL WAY 
     951    # add dmfind/dmget (to demigrate all offline files) : 
     952    dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget 
     953    \cp -r $1 $2 > out_rsync 2>&1 
     954    RET=$? 
     955 
     956    if [ ${RET} -gt 0 ] ; then 
     957      echo "IGCM_sys_Get_Dir : error." 
     958      cat out_rsync 
     959      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    878960    else 
    879         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    880     fi 
    881     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     961      \rm out_rsync 
     962    fi 
     963  else 
     964    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     965  fi 
     966  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    882967} 
    883968 
    884969#D-#================================================== 
    885970#D-function IGCM_sys_Put_Rest 
    886 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     971#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    887972#D-           File and target directory must exist. 
    888973#D-* Examples: 
    889974#D- 
    890975function IGCM_sys_Put_Rest { 
    891     IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
    892     if ( $DEBUG_sys ) ; then 
    893         echo "IGCM_sys_Put_Rest :" $@ 
    894     fi 
    895     if [ $DRYRUN = 0 ]; then 
    896         if [ ! -f ${1} ] ; then 
    897             echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
    898             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    899         fi 
    900  
    901         typeset RET 
    902         # 
    903         if [ X${JobType} = XRUN ] ; then 
    904             IGCM_sys_Chmod 444 ${1} 
    905         fi 
    906         # 
    907         IGCM_sys_TestDirArchive $( dirname $2 ) 
    908         # 
    909         # USUAL WAY 
    910         putfer $1 $2 > out_rsync 2>&1 
    911         RET=$? 
     976  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     977  if ( $DEBUG_sys ) ; then 
     978    echo "IGCM_sys_Put_Rest :" $@ 
     979  fi 
     980  if [ $DRYRUN = 0 ]; then 
     981    if [ ! -f ${1} ] ; then 
     982      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     983      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     984    fi 
     985 
     986    typeset RET 
     987    # 
     988    if [ X${JobType} = XRUN ] ; then 
     989      IGCM_sys_Chmod 444 ${1} 
     990    fi 
     991 
     992    # 
     993    # USUAL WAY 
     994    \cp $1 $2 > out_rsync 2>&1 
     995    RET=$? 
    912996 
    913997#       #RSYNC WITH NETWORK SSH CALL 
    914 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    915 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     998#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     999#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    9161000 
    9171001#       #RSYNC WITH NFS USE 
     
    9251009#       (( RET=RET+$? )) 
    9261010 
    927         if [ ${RET} -gt 0 ] ; then 
    928             echo "IGCM_sys_Put_Rest : error." 
    929             cat out_rsync 
    930             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    931         else 
    932             \rm out_rsync 
    933         fi 
     1011    if [ ${RET} -gt 0 ] ; then 
     1012      echo "IGCM_sys_Put_Rest : error." 
     1013      cat out_rsync 
     1014      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    9341015    else 
    935         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    936     fi 
    937     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1016      \rm out_rsync 
     1017    fi 
     1018  else 
     1019    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1020  fi 
     1021  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1022} 
     1023 
     1024#D-#================================================== 
     1025#D-function IGCM_sys_PutBuffer_Rest 
     1026#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     1027#D-           File and target directory must exist. 
     1028#D-* Examples: 
     1029#D- 
     1030function IGCM_sys_PutBuffer_Rest { 
     1031  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     1032  if ( $DEBUG_sys ) ; then 
     1033    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     1034  fi 
     1035  if [ $DRYRUN = 0 ]; then 
     1036    if [ ! -f ${1} ] ; then 
     1037      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     1038      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1039    fi 
     1040 
     1041    typeset RET 
     1042    # 
     1043    if [ X${JobType} = XRUN ] ; then 
     1044      IGCM_sys_Chmod 444 ${1} 
     1045    fi 
     1046 
     1047    # 
     1048    # USUAL WAY 
     1049    \cp $1 $2 > out_rsync 2>&1 
     1050    RET=$? 
     1051 
     1052    if [ ${RET} -gt 0 ] ; then 
     1053      echo "IGCM_sys_PutBuffer_Rest : error." 
     1054      cat out_rsync 
     1055      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1056    else 
     1057      \rm out_rsync 
     1058    fi 
     1059  else 
     1060    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1061  fi 
     1062  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    9381063} 
    9391064 
    9401065#D-#================================================== 
    9411066#D-function IGCM_sys_Put_Out 
    942 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     1067#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    9431068#D-* Examples: 
    9441069#D- 
    9451070function IGCM_sys_Put_Out { 
    946     IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
    947     if ( $DEBUG_sys ) ; then 
    948         echo "IGCM_sys_Put_Out :" $@ 
    949     fi 
    950     if [ $DRYRUN = 0 ]; then 
    951         if [ ! -f ${1} ] ; then 
    952             echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
    953             IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    954             return 1 
    955         fi 
    956         # 
    957         IGCM_sys_MkdirArchive $( dirname $2 ) 
    958         # 
    959         typeset RET 
    960  
    961         #===================================================== 
    962         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    963         #===================================================== 
    964  
    965         #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
    966         #if [ $? -eq 0 ] ; then 
    967         #    typeset WORKPATH FILEPATH 
    968         #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    969         #    IGCM_sys_MkdirWork ${WORKPATH}  
    970         #    FILEPATH=${WORKPATH}/$( basename $2 ) 
    971         #    # 
    972         #    IGCM_sys_Cp ${1} ${FILEPATH} 
    973         #fi 
    974  
    975         if [ X${JobType} = XRUN ] ; then 
    976             if [ X${3} = X ] ; then 
    977                 IGCM_sys_Chmod 444 ${1} 
    978             fi 
    979         fi 
    980         # 
    981         # USUAL WAY 
    982         putfer $1 $2 > out_rsync 2>&1 
    983         RET=$? 
     1071  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     1072  if ( $DEBUG_sys ) ; then 
     1073    echo "IGCM_sys_Put_Out :" $@ 
     1074  fi 
     1075  if [ $DRYRUN = 0 ]; then 
     1076    if [ ! -f ${1} ] ; then 
     1077      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     1078      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1079      return 1 
     1080    fi 
     1081    # 
     1082    IGCM_sys_MkdirArchive $( dirname $2 ) 
     1083    # 
     1084    typeset RET 
     1085 
     1086    #===================================================== 
     1087    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1088    #===================================================== 
     1089 
     1090    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     1091    #if [ $? -eq 0 ] ; then 
     1092    #    typeset WORKPATH FILEPATH 
     1093    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     1094    #    IGCM_sys_MkdirWork ${WORKPATH}  
     1095    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     1096    #    # 
     1097    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1098    #fi 
     1099 
     1100    if [ X${JobType} = XRUN ] ; then 
     1101      if [ X${3} = X ] ; then 
     1102        IGCM_sys_Chmod 444 ${1} 
     1103      fi 
     1104    fi 
     1105    # 
     1106    # USUAL WAY 
     1107    \cp $1 $2 > out_rsync 2>&1 
     1108    RET=$? 
    9841109 
    9851110#       #RSYNC WITH NETWORK SSH CALL 
    986 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    987 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     1111#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     1112#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    9881113 
    9891114#       #RSYNC WITH NFS USE 
     
    9971122#       (( RET=RET+$? )) 
    9981123 
    999         if [ ${RET} -gt 0 ] ; then 
    1000             echo "IGCM_sys_Put_Out : error." 
    1001             cat out_rsync 
    1002             IGCM_debug_Exit "IGCM_sys_Put_Out" 
    1003         else 
    1004             \rm out_rsync 
    1005         fi 
     1124    if [ ${RET} -gt 0 ] ; then 
     1125      echo "IGCM_sys_Put_Out : error." 
     1126      cat out_rsync 
     1127      IGCM_debug_Exit "IGCM_sys_Put_Out" 
    10061128    else 
    1007         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1008     fi 
    1009     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1010     return 0 
     1129      \rm out_rsync 
     1130    fi 
     1131  else 
     1132    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1133  fi 
     1134  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1135  return 0 
     1136} 
     1137 
     1138#D-#================================================== 
     1139#D-function IGCM_sys_PutBuffer_Out 
     1140#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
     1141#D-* Examples: 
     1142#D- 
     1143function IGCM_sys_PutBuffer_Out { 
     1144  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     1145  if ( $DEBUG_sys ) ; then 
     1146    echo "IGCM_sys_PutBuffer_Out :" $@ 
     1147  fi 
     1148  if [ $DRYRUN = 0 ]; then 
     1149    if [ ! -f ${1} ] ; then 
     1150      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     1151      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1152      return 1 
     1153    fi 
     1154    # 
     1155    IGCM_sys_Mkdir $( dirname $2 ) 
     1156    # 
     1157    typeset RET 
     1158 
     1159    if [ X${JobType} = XRUN ] ; then 
     1160      if [ X${3} = X ] ; then 
     1161        IGCM_sys_Chmod 444 ${1} 
     1162      fi 
     1163    fi 
     1164    # 
     1165    # USUAL WAY 
     1166    \cp $1 $2 > out_rsync 2>&1 
     1167    RET=$? 
     1168 
     1169    if [ ${RET} -gt 0 ] ; then 
     1170      echo "IGCM_sys_PutBuffer_Out : error." 
     1171      cat out_rsync 
     1172      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
     1173    else 
     1174      \rm out_rsync 
     1175    fi 
     1176  else 
     1177    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1178  fi 
     1179  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1180  return 0 
    10111181} 
    10121182 
     
    10171187#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    10181188function IGCM_sys_Get { 
    1019     IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    1020  
    1021     typeset DEST RET dm_liste ifile target file_work  
    1022  
    1023     if ( $DEBUG_sys ) ; then 
    1024         echo "IGCM_sys_Get :" $@ 
    1025     fi 
    1026     if [ $DRYRUN -le 2 ]; then 
    1027         if [ X${1} = X'/l' ] ; then 
    1028             # test if the first file is present in the old computation : 
    1029             eval set +A dm_liste \${${2}} 
    1030         else 
    1031             eval set +A dm_liste ${1} 
    1032         fi 
    1033         eval DEST=\${${#}} 
    1034  
    1035         #===================================================== 
    1036         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1037         #===================================================== 
    1038  
    1039         # Is it an R_OUT file (not R_IN) ? 
    1040         #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
    1041         #if [ $? -eq 0 ] ; then 
    1042         #    # Yes  ? then we try to get it in SCRATCHDIR 
    1043         #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    1044         #    if [ -f ${file_work[0]} ] ; then 
    1045         #       IGCM_sys_Cp ${file_work[*]} ${DEST} 
    1046         #       IGCM_debug_PopStack "IGCM_sys_Get" 
    1047         #       return 
    1048         #    fi 
    1049         #fi 
    1050  
    1051         # test if the (first) file is present in the old computation : 
    1052         IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1053         RET=$? 
    1054         if [ ${RET} -gt 0 ] ; then 
    1055             echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    1056             IGCM_debug_Exit "IGCM_sys_Get" 
    1057             IGCM_debug_PopStack "IGCM_sys_Get" 
    1058             return 
    1059         fi 
    1060  
    1061         dmget ${dm_liste[*]} > out_rsync 2>&1 
    1062         RET=$? 
    1063         if [ ${RET} -gt 0 ] ; then 
    1064             echo "IGCM_sys_Get : demigration error." 
    1065             cat out_rsync 
    1066             IGCM_debug_Exit "IGCM_sys_Get" 
    1067         fi 
    1068  
    1069         #USUAL WAY 
    1070         if [ X${1} = X'/l' ] ; then 
    1071             (( RET=0 )) 
    1072             for target in ${dm_liste[*]} ; do 
    1073                 local_file=$( basename ${target} ) 
    1074                 \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1075                 (( RET = RET + $? )) 
    1076             done 
    1077         else 
    1078             \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
    1079             RET=$? 
    1080         fi 
     1189  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1190 
     1191  typeset DEST RET dm_liste ifile target file_work  
     1192 
     1193  if ( $DEBUG_sys ) ; then 
     1194    echo "IGCM_sys_Get :" $@ 
     1195  fi 
     1196  if [ $DRYRUN -le 2 ]; then 
     1197    if [ X${1} = X'/l' ] ; then 
     1198      # test if the first file is present in the old computation : 
     1199      eval set +A dm_liste \${${2}} 
     1200    else 
     1201      eval set +A dm_liste ${1} 
     1202    fi 
     1203    eval DEST=\${${#}} 
     1204 
     1205    #===================================================== 
     1206    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1207    #===================================================== 
     1208 
     1209    # Is it an R_OUT file (not R_IN) ? 
     1210    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1211    #if [ $? -eq 0 ] ; then 
     1212    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1213    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1214    #    if [ -f ${file_work[0]} ] ; then 
     1215    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1216    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1217    #   return 
     1218    #    fi 
     1219    #fi 
     1220 
     1221    # test if the (first) file is present in the old computation : 
     1222    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1223    RET=$? 
     1224    if [ ${RET} -gt 0 ] ; then 
     1225      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1226      IGCM_debug_Exit "IGCM_sys_Get" 
     1227    fi 
     1228 
     1229    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1230    RET=$? 
     1231    if [ ${RET} -gt 0 ] ; then 
     1232      echo "WARNING IGCM_sys_Get : demigration error." 
     1233      cat out_rsync 
     1234      echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
     1235    fi 
     1236 
     1237    #if [ ${RET} -gt 0 ] ; then 
     1238    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1239    #   cat out_rsync 
     1240    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1241    #   sleep 30 
     1242    #   echo "We try another time" 
     1243    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1244    #   RET=$? 
     1245    #   if [ ${RET} -gt 0 ] ; then 
     1246    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1247    #       cat out_rsync 
     1248    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1249    #   fi 
     1250    #    else 
     1251    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1252    #   cat out_rsync 
     1253    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1254    #    fi 
     1255    #fi 
     1256 
     1257    #USUAL WAY 
     1258    if [ X${1} = X'/l' ] ; then 
     1259      (( RET=0 )) 
     1260      for target in ${dm_liste[*]} ; do 
     1261        local_file=$( basename ${target} ) 
     1262        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1263        (( RET = RET + $? )) 
     1264      done 
     1265    else 
     1266      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1267      RET=$? 
     1268    fi 
    10811269 
    10821270#       #RSYNC WITH NETWORK SSH CALL 
    1083 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
    1084 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
     1271#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
     1272#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
    10851273 
    10861274#       #RSYNC WITH NFS USE 
     
    10941282#       (( RET=RET+$? )) 
    10951283 
    1096         if [ ${RET} -gt 0 ] ; then 
    1097             echo "IGCM_sys_Get : copy error." 
    1098             cat out_rsync 
    1099             IGCM_debug_Exit "IGCM_sys_Get" 
    1100         else 
    1101             \rm out_rsync 
    1102         fi 
     1284    if [ ${RET} -gt 0 ] ; then 
     1285      echo "IGCM_sys_Get : copy error." 
     1286      cat out_rsync 
     1287      IGCM_debug_Exit "IGCM_sys_Get" 
    11031288    else 
    1104         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1105     fi 
    1106     IGCM_debug_PopStack "IGCM_sys_Get" 
    1107 } 
    1108  
    1109 ############################################################## A FINIR !! 
     1289      \rm out_rsync 
     1290    fi 
     1291  else 
     1292    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1293  fi 
     1294  IGCM_debug_PopStack "IGCM_sys_Get" 
     1295} 
     1296 
     1297#D-#================================================== 
     1298#D-function IGCM_sys_GetBuffer 
     1299#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1300#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1301#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1302function IGCM_sys_GetBuffer { 
     1303  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1304 
     1305  typeset DEST RET buf_liste ifile target file_work  
     1306 
     1307  if ( $DEBUG_sys ) ; then 
     1308    echo "IGCM_sys_GetBuffer :" $@ 
     1309  fi 
     1310  if [ $DRYRUN -le 2 ]; then 
     1311    if [ X${1} = X'/l' ] ; then 
     1312      # test if the first file is present in the old computation : 
     1313      eval set +A buf_liste \${${2}} 
     1314    else 
     1315      eval set +A buf_liste ${1} 
     1316    fi 
     1317    eval DEST=\${${#}} 
     1318 
     1319    #USUAL WAY 
     1320    if [ X${1} = X'/l' ] ; then 
     1321      (( RET=0 )) 
     1322      for target in ${buf_liste[*]} ; do 
     1323        local_file=$( basename ${target} ) 
     1324        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1325        (( RET = RET + $? )) 
     1326      done 
     1327    else 
     1328      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1329      RET=$? 
     1330    fi 
     1331 
     1332    if [ ${RET} -gt 0 ] ; then 
     1333      echo "IGCM_sys_GetBuffer : copy error." 
     1334      cat out_rsync 
     1335      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1336    else 
     1337      \rm out_rsync 
     1338    fi 
     1339  else 
     1340    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1341  fi 
     1342  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
     1343} 
    11101344 
    11111345#D-#================================================== 
     
    11151349#D- 
    11161350function IGCM_sys_GetDate_FichWork { 
    1117     IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1118     if ( $DEBUG_sys ) ; then 
    1119         echo "IGCM_sys_GetDate_FichWork :" $@ 
    1120     fi 
     1351  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1352  if ( $DEBUG_sys ) ; then 
     1353    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1354  fi 
     1355  typeset dateF 
     1356  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1357  eval ${2}=${dateF[5]} 
     1358 
    11211359    # donne la date filesys d'un fichier sur la machine work 
    1122     IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1360  IGCM_debug_PopStack "IGCM_sys_FichWork" 
    11231361} 
    11241362 
     
    11291367#D- 
    11301368function IGCM_sys_GetDate_FichArchive { 
    1131     IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1132     if ( $DEBUG_sys ) ; then 
    1133         echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1134     fi 
    1135     IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1369  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1370  if ( $DEBUG_sys ) ; then 
     1371    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1372  fi 
     1373  typeset dateF 
     1374  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1375  eval ${2}=${dateF[5]} 
     1376 
     1377  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    11361378} 
    11371379 
     
    11401382 
    11411383function IGCM_sys_rebuild { 
    1142     IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
    1143     if ( $DEBUG_sys ) ; then 
    1144         echo "IGCM_sys_rebuild :" $@ 
    1145     fi 
    1146     /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@ 
    1147     if [ $? -gt 0 ] ; then 
    1148        echo "IGCM_sys_rebuild : erreur ${@}." 
    1149        IGCM_debug_Exit "rebuild" 
    1150     fi 
    1151  
    1152     IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1384  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1385  if ( $DEBUG_sys ) ; then 
     1386    echo "IGCM_sys_rebuild :" $@ 
     1387  fi 
     1388  /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@ 
     1389  if [ $? -gt 0 ] ; then 
     1390    echo "IGCM_sys_rebuild : erreur ${@}." 
     1391    IGCM_debug_Exit "rebuild" 
     1392  fi 
     1393 
     1394  IGCM_debug_PopStack "IGCM_sys_rebuild" 
    11531395} 
    11541396 
     
    11571399 
    11581400function IGCM_sys_activ_variables { 
    1159     IGCM_debug_PushStack "IGCM_sys_activ_variables" 
    1160     if ( $DEBUG_sys ) ; then 
    1161         echo "IGCM_sys_activ_variables" 
    1162     fi 
     1401  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1402  if ( $DEBUG_sys ) ; then 
     1403    echo "IGCM_sys_activ_variables" 
     1404  fi 
    11631405 
    11641406# -------------------------------------------------------------------- 
     
    11671409 
    11681410#D-- MPISUSPEND 
    1169     export MPISUSPEND=${MPISUSPEND:=OFF} 
     1411  export MPISUSPEND=${MPISUSPEND:=OFF} 
    11701412 
    11711413#D-- MPIPROGINF #other choices : ALL_DETAIL2 
    1172     export MPIPROGINF=ALL 
     1414  export MPIPROGINF=ALL 
    11731415#D- activate ftrace (with -ftrace) 
    1174     export F_FTRACE=YES 
     1416  export F_FTRACE=YES 
    11751417#D- communication information (with -ftrace) 
    1176     export MPICOMMINF=DETAIL 
     1418  export MPICOMMINF=DETAIL 
    11771419 
    11781420# -------------------------------------------------------------------- 
     
    11811423 
    11821424#D- max number of character/line in output job 
    1183     export F_SYSLEN=5000 
     1425  export F_SYSLEN=5000 
    11841426#D- number of error that can be admitted on the NEC 
    1185     export F_ERRCNT=0 
     1427  export F_ERRCNT=0 
    11861428#D- global performance 
    1187     export F_PROGINF=DETAIL 
     1429  export F_PROGINF=DETAIL 
    11881430 
    11891431#D- I/O performance (FORTRAN I/O only not netCDF) 
    1190     export F_FILEINF=${F_FILEINF:=NO} 
     1432  export F_FILEINF=${F_FILEINF:=NO} 
    11911433#D- netCDF I/O performance 
    1192     export NC_FILEINF=${NC_FILEINF:=NO} 
    1193  
    1194     IGCM_debug_PopStack "IGCM_sys_activ_variables" 
     1434  export NC_FILEINF=${NC_FILEINF:=NO} 
     1435 
     1436  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    11951437} 
    11961438 
     
    11991441 
    12001442function IGCM_sys_desactiv_variables { 
    1201     IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
    1202     if ( $DEBUG_sys ) ; then 
    1203         echo "IGCM_sys_desactiv_variables" 
    1204     fi 
     1443  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1444  if ( $DEBUG_sys ) ; then 
     1445    echo "IGCM_sys_desactiv_variables" 
     1446  fi 
    12051447# -------------------------------------------------------------------- 
    12061448#D- MPI specifications 
     
    12081450 
    12091451#D-- MPIPROGINF 
    1210     export MPIPROGINF=NO 
     1452  export MPIPROGINF=NO 
    12111453 
    12121454# -------------------------------------------------------------------- 
     
    12151457 
    12161458#D- global performance 
    1217     export F_PROGINF=NO   
    1218  
    1219     IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
     1459  export F_PROGINF=NO   
     1460 
     1461  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
    12201462} 
    12211463 
     
    13251567 
    13261568    IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" 
     1569 
    13271570} 
    13281571 
  • branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_obelix.ksh

    r463 r571  
    6464# Host and user names  
    6565# $hostname ou hostname 
    66 typeset  HOST=${HOST:=$( hostname )} 
     66typeset  MASTER=${MASTER:=$( hostname )} 
    6767# $username ou whoami 
    6868typeset  LOGIN=${LOGIN:=$( whoami )} 
     
    168168    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    169169 
    170     ssh ${HOST} exec /bin/ksh  <<-EOF 
     170    ssh obelix3 exec /bin/ksh  <<-EOF 
    171171    export libIGCM=${libIGCM} 
    172172    export DEBUG_debug=${DEBUG_debug} 
     
    474474        echo "IGCM_sys_Tar :" $@ 
    475475    fi 
    476     \tar cvf $@ 
     476    \tar cf $@ 
    477477    if [ $? -gt 0 ] ; then 
    478478        echo "IGCM_sys_Tar : erreur." 
    479479        IGCM_debug_Exit "IGCM_sys_Tar" 
    480480    fi 
    481     \tar tvf $1 
    482481 
    483482    IGCM_debug_PopStack "IGCM_sys_Tar" 
     
    10441043        echo "IGCM_sys_Dods_Rm :" $@ 
    10451044    fi 
    1046     typeset RET 
    1047     RET=0 
    1048     if [ $DRYRUN = 0 ]; then 
    1049         if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then 
    1050             echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." 
    1051             echo "Nothing has been done." 
    1052             return 
    1053         fi 
    1054         IGCM_sys_Rm -Rf /tmp/DODS/${config_UserChoices_TagName}/${config_UserChoices_JobName}/${1} 
    1055         RET=$? 
    1056          
    1057         if [ ${RET} -gt 0 ] ; then 
    1058             echo "IGCM_sys_Put_Dods : error." 
    1059             cat out_dods_rm 
    1060             IGCM_debug_Exit "IGCM_sys_Dods_Rm" 
    1061         else 
    1062             rm out_dods_rm 
    1063         fi 
    1064     else 
    1065         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1066     fi 
    1067     return $RET 
     1045    return 0 
    10681046} 
    10691047 
     
    10781056        echo "IGCM_sys_Dods_Cp :" $@ 
    10791057    fi 
    1080     typeset RET 
    1081     RET=0 
    1082     if [ $DRYRUN = 0 ]; then 
    1083         if [ ! -d ${R_SAVE}/${1} ] ; then 
    1084             echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." 
    1085             echo "Nothing has been done." 
    1086             return 
    1087         fi 
    1088         # 
    1089         IGCM_sys_Mkdir /tmp/DODS/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    1090         IGCM_sys_Cp -Rp --parents ${1} /tmp/DODS/${config_UserChoices_TagName}/${config_UserChoices_JobName} 
    1091         RET=$? 
    1092          
    1093         if [ ${RET} -gt 0 ] ; then 
    1094             echo "IGCM_sys_Dods_Cp : error." 
    1095             cat out_dods_cp 
    1096             IGCM_debug_Exit "IGCM_sys_Dods_Cp" 
    1097         else 
    1098             rm out_dods_cp 
    1099         fi 
    1100     else 
    1101         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1102     fi 
    1103     return $RET 
     1058    return 0 
    11041059} 
    11051060 
     
    11151070    fi 
    11161071    if [ $DRYRUN = 0 ]; then 
    1117         if [ ! -d ${R_SAVE}/${1} ] ; then 
    1118             echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." 
    1119             IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    1120             return 
    1121         fi 
    1122  
    1123         typeset RET 
    1124         # 
    1125         cd ${R_SAVE} 
    1126         IGCM_sys_Dods_Rm ${1} 
    1127         IGCM_sys_Dods_Cp ${1} 
    11281072        RET=0 
    11291073         
     
    11381082} 
    11391083 
    1140 ############################################################## A FINIR !! 
    1141  
    11421084#D-#================================================== 
    11431085#D-function IGCM_sys_GetDate_FichWork 
     
    11501092        echo "IGCM_sys_GetDate_FichWork :" $@ 
    11511093    fi 
     1094    typeset dateF 
     1095    set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1096    eval ${2}=${dateF[5]} 
     1097 
    11521098    # donne la date filesys d'un fichier sur la machine work 
    11531099    IGCM_debug_PopStack "IGCM_sys_FichWork" 
     
    11641110        echo "IGCM_sys_GetDate_FichArchive :" $@ 
    11651111    fi 
     1112    typeset dateF 
     1113    set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1114    eval ${2}=${dateF[5]} 
     1115 
    11661116    IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    11671117} 
  • branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_titane.ksh

    r570 r571  
    8080typeset -r RSYNC_opt="-va" 
    8181# ie storage filesystem 
    82 typeset -r RHOST=titane 
     82typeset -r STOREHOST=${MASTER} 
    8383 
    8484#==================================================== 
     
    9191#==================================================== 
    9292. /home/cont003/p86ipsl/.atlas_env_titane_ksh 
     93 
     94module switch nco/4.0.8 nco/3.9.4_netcdf4 
    9395 
    9496#==================================================== 
     
    113115typeset -r ARCHIVE=${DMFDIR} 
    114116 
     117# ============ CESIUM START ============ # 
     118 
    115119#==================================================== 
    116120#- 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 
     121#ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $3}' ) 
     122#if [ ! ${ROOTSYS} = "home" ] ; then 
     123#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true} 
     124#else 
     125#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} 
     126#fi 
    123127 
    124128#==================================================== 
    125129#- 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 
     130#if ( ${MirrorlibIGCM} ) ; then 
     131#  PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" ) 
     132#  typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM 
     133#else 
     134#  typeset -r libIGCM_POST=${libIGCM} 
     135#fi 
     136 
     137# ============ CESIUM  END  ============ # 
     138 
     139#==================================================== 
     140#- MirrorlibIGCM for frontend 
     141typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} 
     142 
     143#==================================================== 
     144#- libIGCM_POST for frontend 
     145typeset -r libIGCM_POST=${libIGCM} 
    132146 
    133147#==================================================== 
    134148#- IN 
    135 typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM} 
     149typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM} 
    136150typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data} 
    137151 
    138152#==================================================== 
    139 #- OUT 
     153#- R_OUT 
    140154typeset -r R_OUT=${ARCHIVE}/IGCM_OUT 
    141155 
    142156#==================================================== 
    143 #- OUT_SCR (ONLY FOR double copy an scratch) 
    144 typeset -r R_OUT_SCR=${SCRATCHDIR}/IGCM_OUT 
     157#- R_BUF (ONLY FOR double copy an scratch) 
     158typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT 
     159 
     160#==================================================== 
     161#- BIG_DIR : BIG_DIR to store files waiting for rebuild 
     162typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    145163 
    146164#==================================================== 
     
    151169#- RUN_DIR_PATH : Temporary working directory (=> TMP) 
    152170if [ ! X${LSB_QUEUE} = Xmono ] ; then 
    153     typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${LSB_JOBID}} 
     171  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${LSB_JOBID}} 
    154172else 
    155     typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/TMPDIR_IGCM/${LSB_JOBID}} 
     173  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/TMPDIR_IGCM/${LSB_JOBID}} 
    156174fi 
    157  
    158 #==================================================== 
    159 #- BIG_DIR : BIG_DIR to store files waiting for rebuild 
    160 typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD} 
    161175 
    162176#==================================================== 
     
    181195#D-#================================================== 
    182196#D-function IGCM_sys_RshMaster 
    183 #D-* Purpose: Just a fake command to wrapp 
    184 #D-           IGCM_card call in post-treatment 
    185 #D-           Ulam do not see brodie filesystem 
    186 #D-           Cesium do not see all mercure filesystem 
    187 #D-           That's why we need this hack. 
     197#D-* Purpose: Connection to frontend machine. 
    188198#D-* Examples: 
    189199#D- 
    190200function IGCM_sys_RshMaster { 
    191     IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    192     /bin/ksh <<-EOF 
     201  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
     202  /bin/ksh <<-EOF 
    193203    export libIGCM=${libIGCM} 
    194204    export DEBUG_debug=${DEBUG_debug} 
     
    197207    ${@} 
    198208EOF 
    199     if [ $? -gt 0 ] ; then 
    200         echo "IGCM_sys_RshMaster : erreur." 
    201         IGCM_debug_Exit "IGCM_sys_RshMaster" 
    202     fi 
    203     IGCM_debug_PopStack "IGCM_sys_RshMaster" 
     209  if [ $? -gt 0 ] ; then 
     210    echo "IGCM_sys_RshMaster : erreur." 
     211    IGCM_debug_Exit "IGCM_sys_RshMaster" 
     212  fi 
     213  IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    204214} 
    205215 
     
    210220#D- 
    211221function IGCM_sys_RshArchive { 
    212     IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    213     /bin/ksh <<-EOF 
     222  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
     223  /bin/ksh <<-EOF 
    214224    ${@} 
    215225EOF 
    216     if [ $? -gt 0 ] ; then 
    217         echo "IGCM_sys_RshArchive : erreur." 
    218         IGCM_debug_Exit "IGCM_sys_RshArchive" 
    219     fi 
    220     IGCM_debug_PopStack "IGCM_sys_RshArchive" 
     226  if [ $? -gt 0 ] ; then 
     227    echo "IGCM_sys_RshArchive : erreur." 
     228    IGCM_debug_Exit "IGCM_sys_RshArchive" 
     229  fi 
     230  IGCM_debug_PopStack "IGCM_sys_RshArchive" 
    221231} 
    222232 
     
    227237#D- 
    228238function IGCM_sys_RshPost { 
    229     IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    230     if ( $DEBUG_sys ) ; then 
    231         echo "IGCM_sys_RshPost :" $@ 
    232     fi 
    233  
    234     typeset NB_ESSAI DELAI status i 
    235     # keep standard input for the loop onto temporary file 
    236     cat >tmp_IGCM_sys_RshPost_$$ 
    237  
    238     #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL 
    239     #cat tmp_IGCM_sys_RshPost_$$ 
    240  
    241     if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then 
    242         # little hack so that rebuild submission is done on titane not an cesium 
    243         # 
    244         libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' ) 
    245         POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' ) 
    246         sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
    247         sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
    248         sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
    249         sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
    250         #\mv tmp.txt tmp_IGCM_sys_RshPost_$$ 
    251         # 
    252         #echo cat tmp_IGCM_sys_RshPost_$$ AFTER 
    253         #cat tmp_IGCM_sys_RshPost_$$ 
    254         /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
    255         if [ $? -gt 0 ] ; then 
    256             echo "IGCM_sys_RshPost : erreur." 
    257             IGCM_debug_Exit "IGCM_sys_RshPost" 
    258         fi 
    259         # delete temporary file 
    260         \rm tmp_IGCM_sys_RshPost_$$ 
    261     else 
    262         # number of tentative 
    263         NB_ESSAI=10 
    264         # time delay between tentative 
    265         DELAI=10 
    266         i=0 
    267         while [ $i -ne $NB_ESSAI ] ; do 
    268             ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
    269             status=$? 
    270             if [ ${status} -ne 0 ]; 
    271             then 
    272                 sleep $DELAI 
    273             else 
    274                 break 
    275             fi 
    276             let i=$i+1 
    277         done 
    278         # delete temporary file 
    279         \rm tmp_IGCM_sys_RshPost_$$ 
    280  
    281         if [ ${status} -gt 0 ] ; then 
    282             echo "IGCM_sys_RshPost : erreur." 
    283             IGCM_debug_Exit "IGCM_sys_RshPost" 
    284         fi 
    285     fi 
    286     IGCM_debug_PopStack "IGCM_sys_RshPost" 
     239  IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
     240  if ( $DEBUG_sys ) ; then 
     241    echo "IGCM_sys_RshPost :" $@ 
     242  fi 
     243 
     244  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL 
     245  #cat tmp_IGCM_sys_RshPost_$$ 
     246  # keep standard input (stdin) for the loop onto temporary file 
     247  cat >tmp_IGCM_sys_RshPost_$$ 
     248 
     249# ============ FRONTEND START ============ # 
     250 
     251  /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     252  if [ $? -gt 0 ] ; then 
     253    echo "IGCM_sys_RshPost : erreur." 
     254    IGCM_debug_Exit "IGCM_sys_RshPost" 
     255  fi 
     256  # delete temporary file 
     257  \rm tmp_IGCM_sys_RshPost_$$ 
     258 
     259# ============ FRONTEND  END  ============ # 
     260 
     261# ============ CESIUM START ============ # 
     262#  typeset NB_ESSAI DELAI status i 
     263#  if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then 
     264#    #little hack so that rebuild submission is done on titane not an cesium 
     265#     
     266#    libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' ) 
     267#    POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' ) 
     268#    sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
     269#    sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
     270#    sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
     271#    sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
     272#    \mv tmp.txt tmp_IGCM_sys_RshPost_$$ 
     273#     
     274#    echo cat tmp_IGCM_sys_RshPost_$$ AFTER 
     275#    cat tmp_IGCM_sys_RshPost_$$ 
     276# 
     277#    /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     278#    if [ $? -gt 0 ] ; then 
     279#      echo "IGCM_sys_RshPost : erreur." 
     280#      IGCM_debug_Exit "IGCM_sys_RshPost" 
     281#    fi 
     282#    # delete temporary file 
     283#    \rm tmp_IGCM_sys_RshPost_$$ 
     284# 
     285#  else 
     286#    # number of tentative 
     287#    NB_ESSAI=10 
     288#    # time delay between tentative 
     289#    DELAI=10 
     290#    i=0 
     291#    while [ $i -ne $NB_ESSAI ] ; do 
     292#      ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     293#      status=$? 
     294#      if [ ${status} -ne 0 ]; 
     295#      then 
     296#       sleep $DELAI 
     297#      else 
     298#       break 
     299#      fi 
     300#      let i=$i+1 
     301#    done 
     302#    # delete temporary file 
     303#    \rm tmp_IGCM_sys_RshPost_$$ 
     304# 
     305#    if [ ${status} -gt 0 ] ; then 
     306#      echo "IGCM_sys_RshPost : erreur." 
     307#      IGCM_debug_Exit "IGCM_sys_RshPost" 
     308#    fi 
     309#  fi 
     310 
     311# ============ CESIUM  END  ============ # 
     312 
     313  IGCM_debug_PopStack "IGCM_sys_RshPost" 
    287314} 
    288315 
     
    293320#D- 
    294321function IGCM_sys_SendMail { 
    295     IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    296     if ( $DEBUG_sys ) ; then 
    297        echo "IGCM_sys_SendMail :" $@ 
    298     fi 
    299  
    300     if ( ${ExitFlag} ) ; then 
    301         status=failed 
    302     else 
    303         status=completed 
    304     fi 
    305  
    306     ssh -t titane996 ssh platine /bin/ksh <<-EOF 
    307     export LOGIN=${LOGIN} 
    308     export config_UserChoices_JobName=${config_UserChoices_JobName} 
    309     export config_UserChoices_MailName=${config_UserChoices_MailName} 
    310     export DateBegin=${DateBegin} 
    311     export DateEnd=${DateEnd} 
    312     export R_SAVE=${R_SAVE} 
    313     export SUBMIT_DIR=${SUBMIT_DIR} 
    314     export status=${status} 
     322  IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
     323  if ( $DEBUG_sys ) ; then 
     324    echo "IGCM_sys_SendMail :" $@ 
     325  fi 
     326 
     327  if ( ${ExitFlag} ) ; then 
     328    status=failed 
     329  else 
     330    status=completed 
     331  fi 
    315332 
    316333    cat  << END_MAIL > job_end.mail 
     
    325342 
    326343    if [ ! -z ${config_UserChoices_MailName} ] ; then 
    327         mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail 
     344        mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail 
    328345    elif [ -f ~/.forward ] ; then 
    329         mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
    330     fi 
    331  
     346        mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 
     347    fi 
    332348    sleep 10 
    333349    rm -f job_end.mail 
    334 EOF 
    335  
    336     if [ $? -gt 0 ] ; then 
    337         echo "IGCM_sys_SendMail : erreur." 
    338         IGCM_debug_Exit "IGCM_sys_SendMail" 
    339     fi 
    340     IGCM_debug_PopStack "IGCM_sys_SendMail" 
     350 
     351  if [ $? -gt 0 ] ; then 
     352    echo "IGCM_sys_SendMail : erreur." 
     353    IGCM_debug_Exit "IGCM_sys_SendMail" 
     354  fi 
     355  IGCM_debug_PopStack "IGCM_sys_SendMail" 
    341356} 
    342357 
     
    347362#D- 
    348363function IGCM_sys_Mkdir { 
    349     IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    350     if ( $DEBUG_sys ) ; then 
    351         echo "IGCM_sys_Mkdir :" $@ 
    352     fi 
    353     if [ ! -d ${1} ]; then 
    354         \mkdir -p $1 
    355         if [ $? -gt 0 ] ; then 
    356             echo "IGCM_sys_Mkdir : erreur." 
    357             IGCM_debug_Exit "IGCM_sys_Mkdir" 
    358         fi 
    359     fi 
    360     # vérification : 
    361     if [ ! -d ${1} ] ; then 
    362         echo "IGCM_sys_Mkdir : erreur." 
    363         IGCM_debug_Exit "IGCM_sys_Mkdir" 
    364     fi 
    365     IGCM_debug_PopStack "IGCM_sys_Mkdir" 
     364  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
     365  if ( $DEBUG_sys ) ; then 
     366    echo "IGCM_sys_Mkdir :" $@ 
     367  fi 
     368  if [ ! -d ${1} ]; then 
     369    \mkdir -p $1 
     370    if [ $? -gt 0 ] ; then 
     371      echo "IGCM_sys_Mkdir : erreur." 
     372      IGCM_debug_Exit "IGCM_sys_Mkdir" 
     373    fi 
     374  fi 
     375  # vérification : 
     376  if [ ! -d ${1} ] ; then 
     377    echo "IGCM_sys_Mkdir : erreur." 
     378    IGCM_debug_Exit "IGCM_sys_Mkdir" 
     379  fi 
     380  IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    366381} 
    367382 
     
    372387#D- 
    373388function IGCM_sys_MkdirArchive { 
    374     IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
    375     if ( $DEBUG_sys ) ; then 
    376         echo "IGCM_sys_MkdirArchive :" $@ 
    377     fi 
    378     #- creation de repertoire sur le serveur fichier 
    379     if [ ! -d ${1} ]; then  
    380         \mkdir -p $1 
    381         if [ $? -gt 0 ] ; then 
    382             echo "IGCM_sys_MkdirArchive : erreur." 
    383             IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
    384         fi 
    385     fi 
    386     IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
     389  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 
     390  if ( $DEBUG_sys ) ; then 
     391    echo "IGCM_sys_MkdirArchive :" $@ 
     392  fi 
     393  #- creation de repertoire sur le serveur fichier 
     394  if [ ! -d ${1} ]; then  
     395    \mkdir -p $1 
     396    if [ $? -gt 0 ] ; then 
     397      echo "IGCM_sys_MkdirArchive : erreur." 
     398      IGCM_debug_Exit "IGCM_sys_MkdirArchive" 
     399    fi 
     400  fi 
     401  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    387402} 
    388403 
     
    393408#D- 
    394409function IGCM_sys_MkdirWork { 
    395     IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    396     if ( $DEBUG_sys ) ; then 
    397         echo "IGCM_sys_MkdirWork :" $@ 
    398     fi 
    399     #- creation de repertoire sur le serveur fichier 
    400     if [ ! -d ${1} ]; then  
    401         \mkdir -p $1 
    402         if [ $? -gt 0 ] ; then 
    403             echo "IGCM_sys_MkdirWork : erreur." 
    404             IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    405         fi 
    406     fi 
    407     IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
     410  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
     411  if ( $DEBUG_sys ) ; then 
     412    echo "IGCM_sys_MkdirWork :" $@ 
     413  fi 
     414  #- creation de repertoire sur le serveur fichier 
     415  if [ ! -d ${1} ]; then  
     416    \mkdir -p $1 
     417    if [ $? -gt 0 ] ; then 
     418      echo "IGCM_sys_MkdirWork : erreur." 
     419      IGCM_debug_Exit "IGCM_sys_MkdirWork" 
     420    fi 
     421  fi 
     422  IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    408423} 
    409424 
     
    414429#D- 
    415430function IGCM_sys_Cd { 
    416     IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    417     if ( $DEBUG_sys ) ; then 
    418         echo "IGCM_sys_Cd :" $@ 
    419     fi 
    420     \cd $1 
    421     if [ $? -gt 0 ] ; then 
    422         echo "IGCM_sys_Cd : erreur." 
    423         IGCM_debug_Exit "IGCM_sys_Cd" 
    424     fi 
    425     IGCM_debug_PopStack "IGCM_sys_Cd" 
     431  IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
     432  if ( $DEBUG_sys ) ; then 
     433    echo "IGCM_sys_Cd :" $@ 
     434  fi 
     435  \cd $1 
     436  if [ $? -gt 0 ] ; then 
     437    echo "IGCM_sys_Cd : erreur." 
     438    IGCM_debug_Exit "IGCM_sys_Cd" 
     439  fi 
     440  IGCM_debug_PopStack "IGCM_sys_Cd" 
    426441} 
    427442 
     
    432447#D- 
    433448function IGCM_sys_Chmod { 
    434     IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
    435     if ( $DEBUG_sys ) ; then 
    436         echo "IGCM_sys_Chmod :" $@ 
    437     fi 
    438     if [ $DRYRUN -le 1 ]; then 
    439         \chmod $@ 
    440         if [ $? -gt 0 ] ; then 
    441             echo "IGCM_sys_Chmod : erreur." 
    442             IGCM_debug_Exit "IGCM_sys_Chmod" 
    443         fi 
    444     else 
    445         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    446     fi 
    447     IGCM_debug_PopStack "IGCM_sys_Chmod" 
     449  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 
     450  if ( $DEBUG_sys ) ; then 
     451    echo "IGCM_sys_Chmod :" $@ 
     452  fi 
     453  if [ $DRYRUN -le 1 ]; then 
     454    \chmod $@ 
     455    if [ $? -gt 0 ] ; then 
     456      echo "IGCM_sys_Chmod : erreur." 
     457      IGCM_debug_Exit "IGCM_sys_Chmod" 
     458    fi 
     459  else 
     460    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     461  fi 
     462  IGCM_debug_PopStack "IGCM_sys_Chmod" 
    448463} 
    449464 
     
    454469#D- 
    455470function IGCM_sys_FileSize { 
    456     IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    457  
    458     typeset sizeF 
    459     set +A sizeF -- $( ls -la ${1} ) 
    460     if [ $? -gt 0 ] ; then 
    461         IGCM_debug_Exit "IGCM_sys_FileSize" 
    462     fi 
    463     eval ${2}=${sizeF[4]} 
    464  
    465     IGCM_debug_PopStack "IGCM_sys_FileSize" 
     471  IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
     472 
     473  typeset sizeF 
     474  set +A sizeF -- $( ls -la ${1} ) 
     475  if [ $? -gt 0 ] ; then 
     476    IGCM_debug_Exit "IGCM_sys_FileSize" 
     477  fi 
     478  eval ${2}=${sizeF[4]} 
     479 
     480  IGCM_debug_PopStack "IGCM_sys_FileSize" 
    466481} 
    467482 
     
    472487#D- 
    473488function IGCM_sys_TestDir { 
    474     IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    475     if ( $DEBUG_sys ) ; then 
    476         echo "IGCM_sys_TestDir :" $@ 
    477     fi 
    478     typeset ExistFlag 
    479     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    480     IGCM_debug_PopStack "IGCM_sys_TestDir" 
    481  
    482     return ${ExistFlag} 
     489  IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
     490  if ( $DEBUG_sys ) ; then 
     491    echo "IGCM_sys_TestDir :" $@ 
     492  fi 
     493  typeset ExistFlag 
     494  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     495  IGCM_debug_PopStack "IGCM_sys_TestDir" 
     496 
     497  return ${ExistFlag} 
    483498} 
    484499 
     
    489504#D- 
    490505function IGCM_sys_TestDirArchive { 
    491     IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
    492     if ( $DEBUG_sys ) ; then 
    493         echo "IGCM_sys_TestDirArchive :" $@ 
    494     fi 
    495     typeset ExistFlag 
    496     ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    497     IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
    498  
    499     return ${ExistFlag} 
     506  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 
     507  if ( $DEBUG_sys ) ; then 
     508    echo "IGCM_sys_TestDirArchive :" $@ 
     509  fi 
     510  typeset ExistFlag 
     511  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     512  IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
     513 
     514  return ${ExistFlag} 
     515} 
     516 
     517#D-#================================================== 
     518#D-function IGCM_sys_IsFileArchived 
     519#D-* Purpose: Test file that must NOT EXISTS on Archive 
     520#D-* Examples: 
     521#D- 
     522function IGCM_sys_IsFileArchived { 
     523  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ 
     524  if ( $DEBUG_sys ) ; then 
     525    echo "IGCM_sys_IsFileArchived :" $@ 
     526  fi 
     527  typeset IsArchivedFlag 
     528  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/dmnfs ) != X ] && echo 0 || echo 1 ) 
     529  IGCM_debug_PopStack "IGCM_sys_IsFileArchived" 
     530 
     531  return ${IsArchivedFlag} 
    500532} 
    501533 
     
    506538#D- 
    507539function IGCM_sys_TestFileArchive { 
    508     IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
    509     typeset ExistFlag 
    510     ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    511     IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    512  
    513     return ${ExistFlag} 
     540  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 
     541  if ( $DEBUG_sys ) ; then 
     542    echo "IGCM_sys_TestFileArchive :" $@ 
     543  fi 
     544  typeset ExistFlag 
     545  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     546  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
     547 
     548  return ${ExistFlag} 
     549} 
     550 
     551#D-#================================================== 
     552#D-function IGCM_sys_TestFileBuffer 
     553#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     554#D-* Examples: 
     555#D- 
     556function IGCM_sys_TestFileBuffer { 
     557  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     558  typeset ExistFlag 
     559  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     560  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     561 
     562  return ${ExistFlag} 
    514563} 
    515564 
     
    520569#D- 
    521570function IGCM_sys_CountFileArchive { 
    522     IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
    523     ls ${@} 2>/dev/null | wc -l 
    524     if [ $? -gt 0 ] ; then 
    525         echo "IGCM_sys_CountFileArchive : erreur." 
    526     fi 
    527     IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     571  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 
     572  ls ${@} 2>/dev/null | wc -l 
     573  if [ $? -gt 0 ] ; then 
     574    echo "IGCM_sys_CountFileArchive : erreur." 
     575  fi 
     576  IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 
     577} 
     578 
     579#D-#================================================== 
     580#D-function IGCM_sys_CountFileBuffer 
     581#D-* Purpose: Count files on Scratch filesystem 
     582#D-* Examples: 
     583#D- 
     584function IGCM_sys_CountFileBuffer { 
     585  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     586  ls ${@} 2>/dev/null | wc -l 
     587  if [ $? -gt 0 ] ; then 
     588    echo "IGCM_sys_CountFileBuffer : erreur." 
     589  fi 
     590  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    528591} 
    529592 
     
    534597#D- 
    535598function IGCM_sys_Tree { 
    536     IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
    537     if ( $DEBUG_sys ) ; then 
    538         echo "IGCM_sys_Tree :" $@ 
    539     fi 
    540  
    541     \ls -lR ${@} 
    542  
    543     IGCM_debug_PopStack "IGCM_sys_Tree" 
     599  IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
     600  if ( $DEBUG_sys ) ; then 
     601    echo "IGCM_sys_Tree :" $@ 
     602  fi 
     603 
     604  \ls -lR ${@} 
     605 
     606  IGCM_debug_PopStack "IGCM_sys_Tree" 
    544607} 
    545608 
    546609#D-#================================================== 
    547610#D-function IGCM_sys_Tar 
    548 #D-* Purpose: master un-tar command 
     611#D-* Purpose: master tar command 
    549612#D-* Examples: 
    550613#D- 
    551614function IGCM_sys_Tar { 
    552     IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    553     if ( $DEBUG_sys ) ; then 
    554         echo "IGCM_sys_Tar :" $@ 
    555     fi 
    556     \tar xvf $1 
    557     if [ $? -gt 0 ] ; then 
    558         echo "IGCM_sys_Tar : erreur." 
    559         IGCM_debug_Exit "IGCM_sys_Tar" 
    560     fi 
    561     IGCM_debug_PopStack "IGCM_sys_Tar" 
     615  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     616  if ( $DEBUG_sys ) ; then 
     617    echo "IGCM_sys_Tar :" $@ 
     618  fi 
     619  \tar cf $@ 
     620  if [ $? -gt 0 ] ; then 
     621    echo "IGCM_sys_Tar : erreur." 
     622    IGCM_debug_Exit "IGCM_sys_Tar" 
     623  fi 
     624  IGCM_debug_PopStack "IGCM_sys_Tar" 
    562625} 
    563626 
     
    568631#D- 
    569632function IGCM_sys_UnTar { 
    570     IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    571     if ( $DEBUG_sys ) ; then 
    572         echo "IGCM_sys_UnTar :" $@ 
    573     fi 
    574     \tar xvf $1 
    575     if [ $? -gt 0 ] ; then 
    576         echo "IGCM_sys_UnTar : erreur." 
    577         IGCM_debug_Exit "IGCM_sys_UnTar" 
    578     fi 
    579     IGCM_debug_PopStack "IGCM_sys_UnTar" 
     633  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     634  if ( $DEBUG_sys ) ; then 
     635    echo "IGCM_sys_UnTar :" $@ 
     636  fi 
     637  \tar xvf $1 
     638  if [ $? -gt 0 ] ; then 
     639    echo "IGCM_sys_UnTar : erreur." 
     640    IGCM_debug_Exit "IGCM_sys_UnTar" 
     641  fi 
     642  IGCM_debug_PopStack "IGCM_sys_UnTar" 
    580643} 
    581644 
     
    586649#D- 
    587650function IGCM_sys_Qsub { 
    588     IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
    589     if ( $DEBUG_sys ) ; then 
    590         echo "IGCM_sys_Qsub :" $@ 
    591     fi 
    592  
    593     if [ ${config_UserChoices_JobName}.${CumulPeriod} = "." ] ; then 
    594         /usr/local/bin/ccc_msub -o ${Script_Output} -e ${Script_Output} < $1 
    595     else 
    596         /usr/local/bin/ccc_msub -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod} < $1 
    597     fi 
    598  
    599     if [ $? -gt 0 ] ; then 
    600         echo "IGCM_sys_Qsub : erreur " $@ 
    601         IGCM_debug_Exit "IGCM_sys_Qsub" 
    602     fi 
    603     IGCM_debug_PopStack "IGCM_sys_Qsub" 
     651  IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 
     652  if ( $DEBUG_sys ) ; then 
     653    echo "IGCM_sys_Qsub :" $@ 
     654  fi 
     655  typeset options 
     656  if [ ${config_UserChoices_JobName}.${CumulPeriod} = "." ] ; then 
     657    options=" -o ${Script_Output} -e ${Script_Output}" 
     658  else 
     659    options=" -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod}" 
     660  fi 
     661 
     662  /usr/local/bin/ccc_msub ${options} < $1 
     663  if [ $? -gt 0 ] ; then 
     664    echo "IGCM_sys_Qsub : erreur ${options} $1" 
     665    IGCM_debug_Exit "IGCM_sys_Qsub" 
     666  fi 
     667  IGCM_debug_PopStack "IGCM_sys_Qsub" 
    604668} 
    605669 
     
    610674#D- 
    611675function IGCM_sys_QsubPost { 
    612     IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
    613     if ( $DEBUG_sys ) ; then 
    614         echo "IGCM_sys_QsubPost :" $@ 
    615     fi 
    616     /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 
    617     if [ $? -gt 0 ] ; then 
    618         echo "IGCM_sys_QsubPost : erreur " $@ 
    619         IGCM_debug_Exit "IGCM_sys_QsubPost" 
    620     fi 
    621     IGCM_debug_PopStack "IGCM_sys_QsubPost" 
     676  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 
     677  if ( $DEBUG_sys ) ; then 
     678    echo "IGCM_sys_QsubPost :" $@ 
     679  fi 
     680 
     681  # Need to export listVarEnv for cesium 
     682  # NO Need to export listVarEnv for titane 
     683# ============ FRONTEND START ============ # 
     684 
     685  /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 
     686 
     687# ============ FRONTEND  END  ============ # 
     688 
     689# ============ CESIUM START ============ # 
     690#  typeset NB_ESSAI DELAI status i 
     691#  # number of tentative 
     692#  NB_ESSAI=10 
     693#  # time delay between tentative 
     694#  DELAI=10 
     695#  (( i = 0 )) 
     696#  while [ $i -lt $NB_ESSAI ] ; do 
     697#    /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 
     698#    status=$? 
     699#    if [ ${status} -gt 0 ]; then 
     700#      sleep $DELAI 
     701#    else 
     702#      break 
     703#    fi 
     704#    (( i = i + 1 )) 
     705#  done  
     706# ============ CESIUM  END  ============ # 
     707 
     708  if [ $? -gt 0 ] ; then 
     709    echo "IGCM_sys_QsubPost : erreur " $@ 
     710    IGCM_debug_Exit "IGCM_sys_QsubPost" 
     711  fi 
     712  IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    622713} 
    623714 
     
    633724#D-  Error values and explanations can depend on your system version. 
    634725function IGCM_sys_Rsync_out { 
    635     RET=$1 
    636     if [ ! $RET ] ; then 
    637         echo "rsync error !" 
    638     fi 
    639  
    640     if [ $MYLANG = "fr" ]; then 
    641         case $RET in 
    642             0)  return ;; 
    643             1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    644                 echo "Erreur de syntaxe ou d'utilisation." 
    645                 return;; 
    646             2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    647                 echo "Incompatibilité de protocole." 
    648                 return;; 
    649             3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    650                 echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    651                 echo "répertoires" 
    652                 return;; 
    653             4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    654                 echo "Action demandée non supportée : une tentative de manipulation de" 
    655                 echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    656                 echo "été faite ; ou une option qui est supportée par le  client  mais" 
    657                 echo "pas par le serveur a été spécifiée." 
    658                 return;; 
    659             10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    660                 echo "Erreur dans le socket d'entrée sortie" 
    661                 return;; 
    662             11) echo "Erreur de rsync ; RERR_FILEIO" 
    663                 echo "Erreur d'entrée sortie fichier" 
    664                 return;; 
    665             12) echo "Erreur de rsync ; RERR_STREAMIO" 
    666                 echo "Erreur dans flux de donnée du protocole rsync" 
    667                 return;; 
    668             13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    669                 echo "Erreur avec les diagnostics du programme" 
    670                 return;; 
    671             14) echo "Erreur de rsync ; RERR_IPC" 
    672                 echo "Erreur dans le code IPC" 
    673                 return;; 
    674             20) echo "Erreur de rsync ; RERR_SIGNAL" 
    675                 echo "SIGUSR1 ou SIGINT reçu" 
    676                 return;; 
    677             21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    678                 echo "Une erreur retournée par waitpid()" 
    679                 return;; 
    680             22) echo "Erreur de rsync ; RERR_MALLOC" 
    681                 echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    682                 return;; 
    683             23) echo "" 
    684                 echo "Erreur fichier inexistant" 
    685                 return;; 
    686             30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    687                 echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    688                 return;; 
    689             *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
    690                 return;; 
    691         esac 
    692     elif [ $MYLANG = "en" ] ; then 
    693         case $RET in 
    694             0)  return;;                 
    695             1)  echo "rsync error : Syntax or usage error " 
    696                 return;; 
    697             2)  echo "rsync error : Protocol incompatibility " 
    698                 return;; 
    699             3)  echo "rsync error : Errors selecting input/output files, dirs" 
    700                 return;; 
    701             4)  echo "rsync error : Requested action not supported: an attempt" 
    702                 echo "was made to manipulate 64-bit files on a platform that cannot support" 
    703                 echo "them; or an option was specified that is supported by the client and" 
    704                 echo "not by the server." 
    705                 return;; 
    706             5)  echo "rsync error : Error starting client-server protocol" 
    707                 return;; 
    708             10) echo "rsync error : Error in socket I/O " 
    709                 return;; 
    710             11) echo "rsync error : Error in file I/O " 
    711                 return;; 
    712             12) echo "rsync error : Error in rsync protocol data stream " 
    713                 return;; 
    714             13) echo "rsync error : Errors with program diagnostics " 
    715                 return;; 
    716             14) echo "rsync error : Error in IPC code " 
    717                 return;; 
    718             20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    719                 return;; 
    720             21) echo "rsync error : Some error returned by waitpid() " 
    721                 return;; 
    722             22) echo "rsync error : Error allocating core memory buffers " 
    723                 return;; 
    724             23) echo "rsync error : Partial transfer due to error" 
    725                 return;; 
    726             24) echo "rsync error : Partial transfer due to vanished source files" 
    727                 return;; 
    728             30) echo "rsync error : Timeout in data send/receive " 
    729                 return;; 
    730             *)  echo "rsync error : return code of rsync unknown :" $RET 
    731                 return;; 
    732         esac 
    733     else 
    734         echo "unknown language $MYLANG." 
    735         return 
    736     fi 
    737 } 
    738      
     726  RET=$1 
     727  if [ ! $RET ] ; then 
     728    echo "rsync error !" 
     729  fi 
     730 
     731  if [ $MYLANG = "fr" ]; then 
     732    case $RET in 
     733    0)  return ;; 
     734    1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
     735      echo "Erreur de syntaxe ou d'utilisation." 
     736      return;; 
     737    2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
     738      echo "Incompatibilité de protocole." 
     739      return;; 
     740    3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
     741      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
     742      echo "répertoires" 
     743      return;; 
     744    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
     745      echo "Action demandée non supportée : une tentative de manipulation de" 
     746      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
     747      echo "été faite ; ou une option qui est supportée par le  client  mais" 
     748      echo "pas par le serveur a été spécifiée." 
     749      return;; 
     750    10) echo "Erreur de rsync ; RERR_SOCKETIO" 
     751      echo "Erreur dans le socket d'entrée sortie" 
     752      return;; 
     753    11) echo "Erreur de rsync ; RERR_FILEIO" 
     754      echo "Erreur d'entrée sortie fichier" 
     755      return;; 
     756    12) echo "Erreur de rsync ; RERR_STREAMIO" 
     757      echo "Erreur dans flux de donnée du protocole rsync" 
     758      return;; 
     759    13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
     760      echo "Erreur avec les diagnostics du programme" 
     761      return;; 
     762    14) echo "Erreur de rsync ; RERR_IPC" 
     763      echo "Erreur dans le code IPC" 
     764      return;; 
     765    20) echo "Erreur de rsync ; RERR_SIGNAL" 
     766      echo "SIGUSR1 ou SIGINT reçu" 
     767      return;; 
     768    21) echo "Erreur de rsync ; RERR_WAITCHILD" 
     769      echo "Une erreur retournée par waitpid()" 
     770      return;; 
     771    22) echo "Erreur de rsync ; RERR_MALLOC" 
     772      echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
     773      return;; 
     774    23) echo "" 
     775      echo "Erreur fichier inexistant" 
     776      return;; 
     777    30) echo "Erreur de rsync ; RERR_TIMEOUT" 
     778      echo "Temps d'attente écoulé dans l'envoi/réception de données" 
     779      return;; 
     780    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 
     781      return;; 
     782    esac 
     783  elif [ $MYLANG = "en" ] ; then 
     784    case $RET in 
     785    0)  return;;                 
     786    1)  echo "rsync error : Syntax or usage error " 
     787      return;; 
     788    2)  echo "rsync error : Protocol incompatibility " 
     789      return;; 
     790    3)  echo "rsync error : Errors selecting input/output files, dirs" 
     791      return;; 
     792    4)  echo "rsync error : Requested action not supported: an attempt" 
     793      echo "was made to manipulate 64-bit files on a platform that cannot support" 
     794      echo "them; or an option was specified that is supported by the client and" 
     795      echo "not by the server." 
     796      return;; 
     797    5)  echo "rsync error : Error starting client-server protocol" 
     798      return;; 
     799    10) echo "rsync error : Error in socket I/O " 
     800      return;; 
     801    11) echo "rsync error : Error in file I/O " 
     802      return;; 
     803    12) echo "rsync error : Error in rsync protocol data stream " 
     804      return;; 
     805    13) echo "rsync error : Errors with program diagnostics " 
     806      return;; 
     807    14) echo "rsync error : Error in IPC code " 
     808      return;; 
     809    20) echo "rsync error : Received SIGUSR1 or SIGINT " 
     810      return;; 
     811    21) echo "rsync error : Some error returned by waitpid() " 
     812      return;; 
     813    22) echo "rsync error : Error allocating core memory buffers " 
     814      return;; 
     815    23) echo "rsync error : Partial transfer due to error" 
     816      return;; 
     817    24) echo "rsync error : Partial transfer due to vanished source files" 
     818      return;; 
     819    30) echo "rsync error : Timeout in data send/receive " 
     820      return;; 
     821    *)  echo "rsync error : return code of rsync unknown :" $RET 
     822      return;; 
     823    esac 
     824  else 
     825    echo "unknown language $MYLANG." 
     826    return 
     827  fi 
     828} 
    739829 
    740830#D-#================================================== 
     
    744834#D- 
    745835function IGCM_sys_Mirror_libIGCM { 
    746     IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    747     if ( $DEBUG_sys ) ; then 
    748         echo "IGCM_sys_Mirror_libIGCM" 
    749     fi 
    750  
    751     typeset RET DEST 
    752  
    753     mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    754  
    755     echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
    756     ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
    757     RET=$? 
    758  
    759     if [ ${RET} -gt 0 ] ; then 
    760         echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
    761         cat out_rsync 
    762     fi 
    763     IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
     836  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
     837  if ( $DEBUG_sys ) ; then 
     838    echo "IGCM_sys_Mirror_libIGCM" 
     839  fi 
     840 
     841  typeset RET DEST 
     842 
     843  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
     844 
     845  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 
     846  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 
     847  RET=$? 
     848 
     849  if [ ${RET} -gt 0 ] ; then 
     850    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium." 
     851    cat out_rsync 
     852  fi 
     853  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    764854} 
    765855 
     
    767857#- Call IGCM_sys_Mirror_libIGCM now ! 
    768858if ( $MirrorlibIGCM ) ; then 
    769     IGCM_sys_Mirror_libIGCM 
     859  IGCM_sys_Mirror_libIGCM 
    770860fi 
    771861 
     
    776866#D- 
    777867function IGCM_sys_Cp { 
    778     IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    779     if ( $DEBUG_sys ) ; then 
    780         echo "IGCM_sys_Cp :" $@ 
    781     fi 
    782  
    783     typeset RET 
    784  
    785     echo cp $@ > out_rsync 2>&1 
    786     \cp $@ >> out_rsync 2>&1 
    787     RET=$? 
    788  
    789     if [ ${RET} -gt 0 ] ; then 
    790         echo "IGCM_sys_Cp : error." 
    791         cat out_rsync 
    792         IGCM_debug_Exit "IGCM_sys_Cp" 
    793      else 
    794         \rm out_rsync 
    795     fi 
    796     IGCM_debug_PopStack "IGCM_sys_Cp" 
     868  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     869  if ( $DEBUG_sys ) ; then 
     870    echo "IGCM_sys_Cp :" $@ 
     871  fi 
     872 
     873  typeset RET 
     874 
     875  echo cp $@ > out_rsync 2>&1 
     876  \cp $@ >> out_rsync 2>&1 
     877  RET=$? 
     878 
     879  if [ ${RET} -gt 0 ] ; then 
     880    echo "IGCM_sys_Cp : error." 
     881    cat out_rsync 
     882    IGCM_debug_Exit "IGCM_sys_Cp" 
     883  else 
     884    \rm out_rsync 
     885  fi 
     886  IGCM_debug_PopStack "IGCM_sys_Cp" 
    797887} 
    798888 
     
    803893#D- 
    804894function IGCM_sys_Rm { 
    805     IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
    806     if ( $DEBUG_sys ) ; then 
    807         echo "IGCM_sys_Rm :" $@ 
    808     fi 
    809  
    810     typeset RET 
    811  
    812     echo rm $@ > out_rsync 2>&1 
    813     \rm $@ >> out_rsync 2>&1 
    814     RET=$? 
    815  
    816     if [ ${RET} -gt 0 ] ; then 
    817         echo "IGCM_sys_Rm : error." 
    818         cat out_rsync 
    819         IGCM_debug_Exit "IGCM_sys_Rm" 
    820     else 
    821         \rm out_rsync 
    822     fi 
    823     IGCM_debug_PopStack "IGCM_sys_Rm" 
     895  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 
     896  if ( $DEBUG_sys ) ; then 
     897    echo "IGCM_sys_Rm :" $@ 
     898  fi 
     899 
     900  typeset RET 
     901 
     902  echo rm $@ > out_rsync 2>&1 
     903  \rm $@ >> out_rsync 2>&1 
     904  RET=$? 
     905 
     906  if [ ${RET} -gt 0 ] ; then 
     907    echo "IGCM_sys_Rm : error." 
     908    cat out_rsync 
     909    IGCM_debug_Exit "IGCM_sys_Rm" 
     910  else 
     911    \rm out_rsync 
     912  fi 
     913  IGCM_debug_PopStack "IGCM_sys_Rm" 
    824914} 
    825915 
     
    831921#D- 
    832922function IGCM_sys_RmRunDir { 
    833     IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
    834     if ( $DEBUG_sys ) ; then 
    835         echo "IGCM_sys_RmRunDir :" $@ 
    836     fi 
    837  
    838     typeset RET 
    839  
    840     echo rm $@ > out_rsync 2>&1 
    841     \rm $@ >> out_rsync 2>&1 
    842     RET=$? 
    843  
    844     if [ ${RET} -gt 0 ] ; then 
    845         echo "IGCM_sys_RmRunDir : error." 
    846         cat out_rsync 
    847         IGCM_debug_Exit "IGCM_sys_RmRunDir" 
    848     else 
    849         \rm out_rsync 
    850     fi 
    851  
    852     IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
     923  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 
     924  if ( $DEBUG_sys ) ; then 
     925    echo "IGCM_sys_RmRunDir :" $@ 
     926  fi 
     927 
     928  typeset RET 
     929 
     930  echo rm $@ > out_rsync 2>&1 
     931  \rm $@ >> out_rsync 2>&1 
     932  RET=$? 
     933 
     934  if [ ${RET} -gt 0 ] ; then 
     935    echo "IGCM_sys_RmRunDir : error." 
     936    cat out_rsync 
     937    IGCM_debug_Exit "IGCM_sys_RmRunDir" 
     938  else 
     939    \rm out_rsync 
     940  fi 
     941  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    853942} 
    854943 
     
    859948#D- 
    860949function IGCM_sys_Mv { 
    861     IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    862     if ( $DEBUG_sys ) ; then 
    863         echo "IGCM_sys_Mv :" $@ 
    864     fi 
    865  
    866     if [ $DRYRUN = 0 ]; then 
    867  
    868         typeset RET 
    869              
    870         echo mv $@ > out_rsync 2>&1 
    871         \mv $@ >> out_rsync 2>&1 
    872         RET=$? 
     950  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     951  if ( $DEBUG_sys ) ; then 
     952    echo "IGCM_sys_Mv :" $@ 
     953  fi 
     954 
     955  if [ $DRYRUN = 0 ]; then 
     956 
     957    typeset RET 
    873958     
    874         if [ ${RET} -gt 0 ] ; then 
    875             echo "IGCM_sys_Mv : error in mv." 
    876             cat out_rsync 
    877             IGCM_debug_Exit "IGCM_sys_Mv" 
    878         else 
    879             \rm out_rsync 
    880         fi 
     959    echo mv $@ > out_rsync 2>&1 
     960    \mv $@ >> out_rsync 2>&1 
     961    RET=$? 
     962     
     963    if [ ${RET} -gt 0 ] ; then 
     964      echo "IGCM_sys_Mv : error in mv." 
     965      cat out_rsync 
     966      IGCM_debug_Exit "IGCM_sys_Mv" 
    881967    else 
    882         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    883     fi 
    884  
    885     IGCM_debug_PopStack "IGCM_sys_Mv" 
     968      \rm out_rsync 
     969    fi 
     970  else 
     971    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     972  fi 
     973 
     974  IGCM_debug_PopStack "IGCM_sys_Mv" 
    886975} 
    887976 
     
    892981#D- 
    893982function IGCM_sys_Put_Dir { 
    894     IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
    895     if ( $DEBUG_sys ) ; then 
    896         echo "IGCM_sys_Put_Dir :" $@ 
    897     fi 
    898     if [ $DRYRUN = 0 ]; then 
    899         if [ ! -d ${1} ] ; then 
    900             echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
    901             IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    902             return 
    903         fi 
    904  
    905         typeset RET 
    906  
    907         # Only if we use rsync 
    908         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    909         # 
    910         #USUAL WAY 
    911         \cp -r $1 $2 > out_rsync 2>&1 
    912         RET=$? 
    913  
    914         if [ ${RET} -gt 0 ] ; then 
    915             echo "IGCM_sys_Put_Dir : error." 
    916             cat out_rsync 
    917             IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    918         else 
    919             \rm out_rsync 
    920         fi 
     983  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 
     984  if ( $DEBUG_sys ) ; then 
     985    echo "IGCM_sys_Put_Dir :" $@ 
     986  fi 
     987  if [ $DRYRUN = 0 ]; then 
     988    if [ ! -d ${1} ] ; then 
     989      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 
     990      IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     991      return 
     992    fi 
     993 
     994    typeset RET 
     995 
     996    # Only if we use rsync 
     997    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     998    # 
     999    #USUAL WAY 
     1000    \cp -r $1 $2 > out_rsync 2>&1 
     1001    RET=$? 
     1002 
     1003    if [ ${RET} -gt 0 ] ; then 
     1004      echo "IGCM_sys_Put_Dir : error." 
     1005      cat out_rsync 
     1006      IGCM_debug_Exit "IGCM_sys_Put_Dir" 
    9211007    else 
    922         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    923     fi 
    924     IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
     1008      \rm out_rsync 
     1009    fi 
     1010  else 
     1011    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1012  fi 
     1013  IGCM_debug_PopStack "IGCM_sys_Put_Dir" 
    9251014} 
    9261015 
    9271016#D-#================================================== 
    9281017#D-function IGCM_sys_Get_Dir 
    929 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     1018#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    9301019#D-* Examples: 
    9311020#D- 
    9321021function IGCM_sys_Get_Dir { 
    933     IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
    934     if ( $DEBUG_sys ) ; then 
    935         echo "IGCM_sys_Get_Dir :" $@ 
    936     fi 
    937     if [ $DRYRUN = 0 ]; then 
    938 #       if [ ! -d ${1} ] ; then 
    939 #           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
    940 #           IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    941 #           return 
    942 #       fi 
    943  
    944         typeset RET 
    945  
    946         # Only if we use rsync 
    947         #IGCM_sys_TestDirArchive $( dirname $2 ) 
    948         # 
    949         #USUAL WAY 
    950         # add dmget (to demigrate all offline files) to reduce time of this command : 
    951         dmget $1/* 
    952         \cp -r $1 $2 > out_rsync 2>&1 
    953         RET=$? 
    954  
    955         if [ ${RET} -gt 0 ] ; then 
    956             echo "IGCM_sys_Get_Dir : error." 
    957             cat out_rsync 
    958             IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    959         else 
    960             \rm out_rsync 
    961         fi 
     1022  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 
     1023  if ( $DEBUG_sys ) ; then 
     1024    echo "IGCM_sys_Get_Dir :" $@ 
     1025  fi 
     1026  if [ $DRYRUN = 0 ]; then 
     1027#    if [ ! -d ${1} ] ; then 
     1028#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     1029#      IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     1030#      return 
     1031#    fi 
     1032 
     1033    typeset RET 
     1034 
     1035    # Only if we use rsync 
     1036    #IGCM_sys_TestDirArchive $( dirname $2 ) 
     1037    # 
     1038    # USUAL WAY 
     1039    # add dmfind/dmget (to demigrate all offline files) : 
     1040    dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget 
     1041    \cp -r $1 $2 > out_rsync 2>&1 
     1042    RET=$? 
     1043 
     1044    if [ ${RET} -gt 0 ] ; then 
     1045      echo "IGCM_sys_Get_Dir : error." 
     1046      cat out_rsync 
     1047      IGCM_debug_Exit "IGCM_sys_Get_Dir" 
    9621048    else 
    963         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    964     fi 
    965     IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     1049      \rm out_rsync 
     1050    fi 
     1051  else 
     1052    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1053  fi 
     1054  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    9661055} 
    9671056 
     
    9721061#D- 
    9731062function IGCM_sys_Get_Master { 
    974     IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
    975     if ( $DEBUG_sys ) ; then 
    976         echo "IGCM_sys_Get_Master :" $@ 
    977     fi 
    978     if [ $DRYRUN = 0 ]; then 
    979         if [ ! -d ${1} ] ; then 
    980             echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
    981             IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    982             return 
    983         fi 
    984  
    985         typeset RET 
    986  
    987         #USUAL WAY 
    988         \cp -r $1 $2 > out_rsync 2>&1 
    989         RET=$? 
    990  
    991         if [ ${RET} -gt 0 ] ; then 
    992             echo "IGCM_sys_Get_Master : error." 
    993             cat out_rsync 
    994             IGCM_debug_Exit "IGCM_sys_Get_Master" 
    995         fi 
     1063  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
     1064  if ( $DEBUG_sys ) ; then 
     1065    echo "IGCM_sys_Get_Master :" $@ 
     1066  fi 
     1067  if [ $DRYRUN = 0 ]; then 
     1068    if [ ! -d ${1} ] ; then 
     1069      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
     1070      IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     1071      return 
     1072    fi 
     1073 
     1074    typeset RET 
     1075 
     1076    #USUAL WAY 
     1077    \cp -r $1 $2 > out_rsync 2>&1 
     1078    RET=$? 
     1079 
     1080    if [ ${RET} -gt 0 ] ; then 
     1081      echo "IGCM_sys_Get_Master : error." 
     1082      cat out_rsync 
     1083      IGCM_debug_Exit "IGCM_sys_Get_Master" 
    9961084    else 
    997         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    998     fi 
    999     IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     1085      \rm out_rsync 
     1086    fi 
     1087  else 
     1088    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1089  fi 
     1090  IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    10001091} 
    10011092 
    10021093#D-#================================================== 
    10031094#D-function IGCM_sys_Put_Rest 
    1004 #D-* Purpose: Put computied restarts on $(ARCHIVE). 
     1095#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
    10051096#D-           File and target directory must exist. 
    10061097#D-* Examples: 
    10071098#D- 
    10081099function IGCM_sys_Put_Rest { 
    1009     IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
    1010     if ( $DEBUG_sys ) ; then 
    1011         echo "IGCM_sys_Put_Rest :" $@ 
    1012     fi 
    1013     if [ $DRYRUN = 0 ]; then 
    1014         if [ ! -f ${1} ] ; then 
    1015             echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
    1016             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    1017         fi 
    1018  
    1019         typeset RET 
    1020         # 
    1021         if [ X${JobType} = XRUN ] ; then 
    1022             IGCM_sys_Chmod 444 ${1} 
    1023         fi 
    1024         # 
    1025         IGCM_sys_TestDirArchive $( dirname $2 ) 
    1026         # 
    1027         # USUAL WAY 
    1028         \cp $1 $2 > out_rsync 2>&1 
    1029         RET=$? 
     1100  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 
     1101  if ( $DEBUG_sys ) ; then 
     1102    echo "IGCM_sys_Put_Rest :" $@ 
     1103  fi 
     1104  if [ $DRYRUN = 0 ]; then 
     1105    if [ ! -f ${1} ] ; then 
     1106      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 
     1107      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     1108    fi 
     1109 
     1110    typeset RET 
     1111    # 
     1112    if [ X${JobType} = XRUN ] ; then 
     1113      IGCM_sys_Chmod 444 ${1} 
     1114    fi 
     1115 
     1116    # 
     1117    # USUAL WAY 
     1118    \cp $1 $2 > out_rsync 2>&1 
     1119    RET=$? 
    10301120 
    10311121#       #RSYNC WITH NETWORK SSH CALL 
    1032 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    1033 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     1122#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     1123#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    10341124 
    10351125#       #RSYNC WITH NFS USE 
     
    10431133#       (( RET=RET+$? )) 
    10441134 
    1045         if [ ${RET} -gt 0 ] ; then 
    1046             echo "IGCM_sys_Put_Rest : error." 
    1047             cat out_rsync 
    1048             IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    1049         else 
    1050             \rm out_rsync 
    1051         fi 
     1135    if [ ${RET} -gt 0 ] ; then 
     1136      echo "IGCM_sys_Put_Rest : error." 
     1137      cat out_rsync 
     1138      IGCM_debug_Exit "IGCM_sys_Put_Rest" 
    10521139    else 
    1053         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1054     fi 
    1055     IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1140      \rm out_rsync 
     1141    fi 
     1142  else 
     1143    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1144  fi 
     1145  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1146} 
     1147 
     1148#D-#================================================== 
     1149#D-function IGCM_sys_PutBuffer_Rest 
     1150#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     1151#D-           File and target directory must exist. 
     1152#D-* Examples: 
     1153#D- 
     1154function IGCM_sys_PutBuffer_Rest { 
     1155  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     1156  if ( $DEBUG_sys ) ; then 
     1157    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     1158  fi 
     1159  if [ $DRYRUN = 0 ]; then 
     1160    if [ ! -f ${1} ] ; then 
     1161      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     1162      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1163    fi 
     1164 
     1165    typeset RET 
     1166    # 
     1167    if [ X${JobType} = XRUN ] ; then 
     1168      IGCM_sys_Chmod 444 ${1} 
     1169    fi 
     1170 
     1171    # 
     1172    # USUAL WAY 
     1173    \cp $1 $2 > out_rsync 2>&1 
     1174    RET=$? 
     1175 
     1176    if [ ${RET} -gt 0 ] ; then 
     1177      echo "IGCM_sys_PutBuffer_Rest : error." 
     1178      cat out_rsync 
     1179      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1180    else 
     1181      \rm out_rsync 
     1182    fi 
     1183  else 
     1184    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1185  fi 
     1186  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    10561187} 
    10571188 
    10581189#D-#================================================== 
    10591190#D-function IGCM_sys_Put_Out 
    1060 #D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly 
     1191#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
    10611192#D-* Examples: 
    10621193#D- 
    10631194function IGCM_sys_Put_Out { 
    1064     IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
    1065     if ( $DEBUG_sys ) ; then 
    1066         echo "IGCM_sys_Put_Out :" $@ 
    1067     fi 
    1068     if [ $DRYRUN = 0 ]; then 
    1069         if [ ! -f ${1} ] ; then 
    1070             echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
    1071             IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1072             return 1 
    1073         fi 
    1074         # 
    1075         IGCM_sys_MkdirArchive $( dirname $2 ) 
    1076         # 
    1077         typeset RET 
    1078  
    1079         #===================================================== 
    1080         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1081         #===================================================== 
    1082  
    1083         #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
    1084         #if [ $? -eq 0 ] ; then 
    1085         #    typeset WORKPATH FILEPATH 
    1086         #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" ) 
    1087         #    IGCM_sys_MkdirWork ${WORKPATH}  
    1088         #    FILEPATH=${WORKPATH}/$( basename $2 ) 
    1089         #    # 
    1090         #    IGCM_sys_Cp ${1} ${FILEPATH} 
    1091         #fi 
    1092  
    1093         if [ X${JobType} = XRUN ] ; then 
    1094             if [ X${3} = X ] ; then 
    1095                 IGCM_sys_Chmod 444 ${1} 
    1096             fi 
    1097         fi 
    1098         # 
    1099         # USUAL WAY 
    1100         \cp $1 $2 > out_rsync 2>&1 
    1101         RET=$? 
     1195  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 
     1196  if ( $DEBUG_sys ) ; then 
     1197    echo "IGCM_sys_Put_Out :" $@ 
     1198  fi 
     1199  if [ $DRYRUN = 0 ]; then 
     1200    if [ ! -f ${1} ] ; then 
     1201      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 
     1202      IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1203      return 1 
     1204    fi 
     1205    # 
     1206    IGCM_sys_MkdirArchive $( dirname $2 ) 
     1207    # 
     1208    typeset RET 
     1209 
     1210    #===================================================== 
     1211    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1212    #===================================================== 
     1213 
     1214    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1 
     1215    #if [ $? -eq 0 ] ; then 
     1216    #    typeset WORKPATH FILEPATH 
     1217    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
     1218    #    IGCM_sys_MkdirWork ${WORKPATH}  
     1219    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
     1220    #    # 
     1221    #    IGCM_sys_Cp ${1} ${FILEPATH} 
     1222    #fi 
     1223 
     1224    if [ X${JobType} = XRUN ] ; then 
     1225      if [ X${3} = X ] ; then 
     1226        IGCM_sys_Chmod 444 ${1} 
     1227      fi 
     1228    fi 
     1229    # 
     1230    # USUAL WAY 
     1231    \cp $1 $2 > out_rsync 2>&1 
     1232    RET=$? 
    11021233 
    11031234#       #RSYNC WITH NETWORK SSH CALL 
    1104 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    1105 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     1235#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     1236#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    11061237 
    11071238#       #RSYNC WITH NFS USE 
     
    11151246#       (( RET=RET+$? )) 
    11161247 
    1117         if [ ${RET} -gt 0 ] ; then 
    1118             echo "IGCM_sys_Put_Out : error." 
    1119             cat out_rsync 
    1120             IGCM_debug_Exit "IGCM_sys_Put_Out" 
    1121         else 
    1122             \rm out_rsync 
    1123         fi 
     1248    if [ ${RET} -gt 0 ] ; then 
     1249      echo "IGCM_sys_Put_Out : error." 
     1250      cat out_rsync 
     1251      IGCM_debug_Exit "IGCM_sys_Put_Out" 
    11241252    else 
    1125         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1126     fi 
    1127     IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1128     return 0 
     1253      \rm out_rsync 
     1254    fi 
     1255  else 
     1256    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1257  fi 
     1258  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
     1259  return 0 
     1260} 
     1261 
     1262#D-#================================================== 
     1263#D-function IGCM_sys_PutBuffer_Out 
     1264#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
     1265#D-* Examples: 
     1266#D- 
     1267function IGCM_sys_PutBuffer_Out { 
     1268  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     1269  if ( $DEBUG_sys ) ; then 
     1270    echo "IGCM_sys_PutBuffer_Out :" $@ 
     1271  fi 
     1272  if [ $DRYRUN = 0 ]; then 
     1273    if [ ! -f ${1} ] ; then 
     1274      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     1275      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1276      return 1 
     1277    fi 
     1278    # 
     1279    IGCM_sys_Mkdir $( dirname $2 ) 
     1280    # 
     1281    typeset RET 
     1282 
     1283    if [ X${JobType} = XRUN ] ; then 
     1284      if [ X${3} = X ] ; then 
     1285        IGCM_sys_Chmod 444 ${1} 
     1286      fi 
     1287    fi 
     1288    # 
     1289    # USUAL WAY 
     1290    \cp $1 $2 > out_rsync 2>&1 
     1291    RET=$? 
     1292 
     1293    if [ ${RET} -gt 0 ] ; then 
     1294      echo "IGCM_sys_PutBuffer_Out : error." 
     1295      cat out_rsync 
     1296      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
     1297    else 
     1298      \rm out_rsync 
     1299    fi 
     1300  else 
     1301    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1302  fi 
     1303  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1304  return 0 
    11291305} 
    11301306 
     
    11351311#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/ 
    11361312function IGCM_sys_Get { 
    1137     IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    1138  
    1139     typeset DEST RET dm_liste ifile target file_work  
    1140  
    1141     if ( $DEBUG_sys ) ; then 
    1142         echo "IGCM_sys_Get :" $@ 
    1143     fi 
    1144     if [ $DRYRUN -le 2 ]; then 
    1145         if [ X${1} = X'/l' ] ; then 
    1146             # test if the first file is present in the old computation : 
    1147             eval set +A dm_liste \${${2}} 
    1148         else 
    1149             eval set +A dm_liste ${1} 
    1150         fi 
    1151         eval DEST=\${${#}} 
    1152  
    1153         #===================================================== 
    1154         #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
    1155         #===================================================== 
    1156  
    1157         # Is it an R_OUT file (not R_IN) ? 
    1158         #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
    1159         #if [ $? -eq 0 ] ; then 
    1160         #    # Yes  ? then we try to get it in SCRATCHDIR 
    1161         #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" ) 
    1162         #    if [ -f ${file_work[0]} ] ; then 
    1163         #       IGCM_sys_Cp ${file_work[*]} ${DEST} 
    1164         #       IGCM_debug_PopStack "IGCM_sys_Get" 
    1165         #       return 
    1166         #    fi 
    1167         #fi 
    1168  
    1169         # test if the (first) file is present in the old computation : 
    1170         IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1171         RET=$? 
    1172         if [ ${RET} -gt 0 ] ; then 
    1173             echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    1174             IGCM_debug_Exit "IGCM_sys_Get" 
    1175         fi 
    1176  
    1177         dmget ${dm_liste[*]} > out_rsync 2>&1 
    1178         RET=$? 
    1179  
    1180         if [ ${RET} -gt 0 ] ; then 
    1181             echo "WARNING IGCM_sys_Get : demigration error." 
    1182             cat out_rsync 
    1183             echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
    1184         fi 
    1185  
    1186         #if [ ${RET} -gt 0 ] ; then 
    1187         #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
    1188         #       cat out_rsync 
    1189         #       echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
    1190         #       sleep 30 
    1191         #       echo "We try another time" 
    1192         #       dmget ${dm_liste[*]} > out_rsync 2>&1 
    1193         #       RET=$? 
    1194         #       if [ ${RET} -gt 0 ] ; then 
    1195         #           echo "ERROR IGCM_sys_Get : again demigration error :" 
    1196         #           cat out_rsync 
    1197         #           IGCM_debug_Exit "IGCM_sys_Get" 
    1198         #       fi 
    1199         #    else 
    1200         #       echo "ERROR IGCM_sys_Get : demigration error :" 
    1201         #       cat out_rsync 
    1202         #       IGCM_debug_Exit "IGCM_sys_Get" 
    1203         #    fi 
    1204         #fi 
    1205  
    1206         #USUAL WAY 
    1207         if [ X${1} = X'/l' ] ; then 
    1208             (( RET=0 )) 
    1209             for target in ${dm_liste[*]} ; do 
    1210                 local_file=$( basename ${target} ) 
    1211                 \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1212                 (( RET = RET + $? )) 
    1213             done 
    1214         else 
    1215             \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
    1216             RET=$? 
    1217         fi 
     1313  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
     1314 
     1315  typeset DEST RET dm_liste ifile target file_work  
     1316 
     1317  if ( $DEBUG_sys ) ; then 
     1318    echo "IGCM_sys_Get :" $@ 
     1319  fi 
     1320  if [ $DRYRUN -le 2 ]; then 
     1321    if [ X${1} = X'/l' ] ; then 
     1322      # test if the first file is present in the old computation : 
     1323      eval set +A dm_liste \${${2}} 
     1324    else 
     1325      eval set +A dm_liste ${1} 
     1326    fi 
     1327    eval DEST=\${${#}} 
     1328 
     1329    #===================================================== 
     1330    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR 
     1331    #===================================================== 
     1332 
     1333    # Is it an R_OUT file (not R_IN) ? 
     1334    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1 
     1335    #if [ $? -eq 0 ] ; then 
     1336    #    # Yes  ? then we try to get it in SCRATCHDIR 
     1337    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" ) 
     1338    #    if [ -f ${file_work[0]} ] ; then 
     1339    #   IGCM_sys_Cp ${file_work[*]} ${DEST} 
     1340    #   IGCM_debug_PopStack "IGCM_sys_Get" 
     1341    #   return 
     1342    #    fi 
     1343    #fi 
     1344 
     1345    # test if the (first) file is present in the old computation : 
     1346    IGCM_sys_TestFileArchive ${dm_liste[0]} 
     1347    RET=$? 
     1348    if [ ${RET} -gt 0 ] ; then 
     1349      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1350      IGCM_debug_Exit "IGCM_sys_Get" 
     1351    fi 
     1352 
     1353    dmget ${dm_liste[*]} > out_rsync 2>&1 
     1354    RET=$? 
     1355    if [ ${RET} -gt 0 ] ; then 
     1356      echo "WARNING IGCM_sys_Get : demigration error." 
     1357      cat out_rsync 
     1358      echo "WARNING IGCM_sys_Get : will stop later if the cp fails." 
     1359    fi 
     1360 
     1361    #if [ ${RET} -gt 0 ] ; then 
     1362    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then 
     1363    #   cat out_rsync 
     1364    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : " 
     1365    #   sleep 30 
     1366    #   echo "We try another time" 
     1367    #   dmget ${dm_liste[*]} > out_rsync 2>&1 
     1368    #   RET=$? 
     1369    #   if [ ${RET} -gt 0 ] ; then 
     1370    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1371    #       cat out_rsync 
     1372    #       IGCM_debug_Exit "IGCM_sys_Get" 
     1373    #   fi 
     1374    #    else 
     1375    #   echo "ERROR IGCM_sys_Get : demigration error :" 
     1376    #   cat out_rsync 
     1377    #   IGCM_debug_Exit "IGCM_sys_Get" 
     1378    #    fi 
     1379    #fi 
     1380 
     1381    #USUAL WAY 
     1382    if [ X${1} = X'/l' ] ; then 
     1383      (( RET=0 )) 
     1384      for target in ${dm_liste[*]} ; do 
     1385        local_file=$( basename ${target} ) 
     1386        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1387        (( RET = RET + $? )) 
     1388      done 
     1389    else 
     1390      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1 
     1391      RET=$? 
     1392    fi 
    12181393 
    12191394#       #RSYNC WITH NETWORK SSH CALL 
    1220 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
    1221 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
     1395#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
     1396#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
    12221397 
    12231398#       #RSYNC WITH NFS USE 
     
    12311406#       (( RET=RET+$? )) 
    12321407 
    1233         if [ ${RET} -gt 0 ] ; then 
    1234             echo "IGCM_sys_Get : copy error." 
    1235             cat out_rsync 
    1236             IGCM_debug_Exit "IGCM_sys_Get" 
    1237         else 
    1238             \rm out_rsync 
    1239         fi 
     1408    if [ ${RET} -gt 0 ] ; then 
     1409      echo "IGCM_sys_Get : copy error." 
     1410      cat out_rsync 
     1411      IGCM_debug_Exit "IGCM_sys_Get" 
    12401412    else 
    1241         ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
    1242     fi 
    1243     IGCM_debug_PopStack "IGCM_sys_Get" 
    1244 } 
    1245  
    1246 ############################################################## A FINIR !! 
     1413      \rm out_rsync 
     1414    fi 
     1415  else 
     1416    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1417  fi 
     1418  IGCM_debug_PopStack "IGCM_sys_Get" 
     1419} 
     1420 
     1421#D-#================================================== 
     1422#D-function IGCM_sys_GetBuffer 
     1423#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1424#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1425#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1426function IGCM_sys_GetBuffer { 
     1427  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1428 
     1429  typeset DEST RET buf_liste ifile target file_work  
     1430 
     1431  if ( $DEBUG_sys ) ; then 
     1432    echo "IGCM_sys_GetBuffer :" $@ 
     1433  fi 
     1434  if [ $DRYRUN -le 2 ]; then 
     1435    if [ X${1} = X'/l' ] ; then 
     1436      # test if the first file is present in the old computation : 
     1437      eval set +A buf_liste \${${2}} 
     1438    else 
     1439      eval set +A buf_liste ${1} 
     1440    fi 
     1441    eval DEST=\${${#}} 
     1442 
     1443    #USUAL WAY 
     1444    if [ X${1} = X'/l' ] ; then 
     1445      (( RET=0 )) 
     1446      for target in ${buf_liste[*]} ; do 
     1447        local_file=$( basename ${target} ) 
     1448        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1449        (( RET = RET + $? )) 
     1450      done 
     1451    else 
     1452      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1453      RET=$? 
     1454    fi 
     1455 
     1456    if [ ${RET} -gt 0 ] ; then 
     1457      echo "IGCM_sys_GetBuffer : copy error." 
     1458      cat out_rsync 
     1459      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     1460    else 
     1461      \rm out_rsync 
     1462    fi 
     1463  else 
     1464    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1465  fi 
     1466  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
     1467} 
    12471468 
    12481469#D-#================================================== 
     
    12521473#D- 
    12531474function IGCM_sys_GetDate_FichWork { 
    1254     IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1255     if ( $DEBUG_sys ) ; then 
    1256         echo "IGCM_sys_GetDate_FichWork :" $@ 
    1257     fi 
     1475  IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
     1476  if ( $DEBUG_sys ) ; then 
     1477    echo "IGCM_sys_GetDate_FichWork :" $@ 
     1478  fi 
     1479  typeset dateF 
     1480  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1481  eval ${2}=${dateF[5]} 
     1482 
    12581483    # donne la date filesys d'un fichier sur la machine work 
    1259     IGCM_debug_PopStack "IGCM_sys_FichWork" 
     1484  IGCM_debug_PopStack "IGCM_sys_FichWork" 
    12601485} 
    12611486 
     
    12661491#D- 
    12671492function IGCM_sys_GetDate_FichArchive { 
    1268     IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1269     if ( $DEBUG_sys ) ; then 
    1270         echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1271     fi 
    1272     IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1493  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
     1494  if ( $DEBUG_sys ) ; then 
     1495    echo "IGCM_sys_GetDate_FichArchive :" $@ 
     1496  fi 
     1497  typeset dateF 
     1498  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1499  eval ${2}=${dateF[5]} 
     1500 
     1501  IGCM_debug_PopStack "IGCM_sys_FichArchive" 
     1502} 
     1503 
     1504#D-#================================================== 
     1505#D-function IGCM_sys_Dods_Rm 
     1506#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. 
     1507#D-* Examples: 
     1508#D- 
     1509function IGCM_sys_Dods_Rm { 
     1510  if ( $DEBUG_sys ) ; then 
     1511    echo "IGCM_sys_Dods_Rm :" $@ 
     1512  fi 
     1513  typeset RET 
     1514  RET=0 
     1515  if [ $DRYRUN = 0 ]; then 
     1516    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then 
     1517      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ." 
     1518      echo "Nothing has been done." 
     1519      return 
     1520    fi 
     1521    dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 
     1522    RET=$? 
     1523     
     1524#       if [ ${RET} -gt 0 ] ; then 
     1525#           echo "IGCM_sys_Dods_Rm : error." 
     1526#           cat out_dods_rm 
     1527#           IGCM_debug_Exit "IGCM_sys_Dods_Rm" 
     1528#       else 
     1529#           rm out_dods_rm 
     1530#       fi 
     1531 
     1532  else 
     1533    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1534  fi 
     1535  return $RET 
     1536} 
     1537 
     1538#D-#================================================== 
     1539#D-function IGCM_sys_Dods_Cp 
     1540#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole. 
     1541#D-* Examples: 
     1542#D- 
     1543function IGCM_sys_Dods_Cp { 
     1544  if ( $DEBUG_sys ) ; then 
     1545    echo "IGCM_sys_Dods_Cp :" $@ 
     1546  fi 
     1547  typeset RET 
     1548  RET=0 
     1549  if [ $DRYRUN = 0 ]; then 
     1550    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1551      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ." 
     1552      echo "Nothing has been done." 
     1553      return 
     1554    fi 
     1555    # 
     1556    dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1 
     1557    RET=$? 
     1558 
     1559#       if [ ${RET} -gt 0 ] ; then 
     1560#           echo "IGCM_sys_Dods_Cp : error." 
     1561#           cat out_dods_cp 
     1562#           IGCM_debug_Exit "IGCM_sys_Dods_Cp" 
     1563#       else 
     1564#           rm out_dods_cp 
     1565#       fi 
     1566 
     1567  else 
     1568    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1569  fi 
     1570  return $RET 
     1571} 
     1572 
     1573#D-#================================================== 
     1574#D-function IGCM_sys_Put_Dods 
     1575#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole. 
     1576#D-* Examples: 
     1577#D- 
     1578function IGCM_sys_Put_Dods { 
     1579  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ 
     1580  if ( $DEBUG_sys ) ; then 
     1581    echo "IGCM_sys_Put_Dods :" $@ 
     1582  fi 
     1583  if [ $DRYRUN = 0 ]; then 
     1584    if [ ! -d ${R_SAVE}/${1} ] ; then 
     1585      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ." 
     1586      IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
     1587      return 
     1588    fi 
     1589 
     1590    typeset RET 
     1591        # 
     1592    cd ${R_SAVE} 
     1593    IGCM_sys_Dods_Rm ${1} 
     1594    IGCM_sys_Dods_Cp ${1} 
     1595    RET=0 
     1596     
     1597    if [ ${RET} -gt 0 ] ; then 
     1598      echo "IGCM_sys_Put_Dods : error." 
     1599      IGCM_debug_Exit "IGCM_sys_Put_Dods" 
     1600    fi 
     1601  else 
     1602    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1603  fi 
     1604  IGCM_debug_PopStack "IGCM_sys_Put_Dods" 
    12731605} 
    12741606 
     
    12771609 
    12781610function IGCM_sys_rebuild { 
    1279     IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
    1280     if ( $DEBUG_sys ) ; then 
    1281         echo "IGCM_sys_rebuild :" $@ 
    1282     fi 
    1283     /home/cont003/p86ipsl/X64/bin/rebuild -f -o $@ 
    1284     if [ $? -gt 0 ] ; then 
    1285        echo "IGCM_sys_rebuild : erreur ${@}." 
    1286        IGCM_debug_Exit "rebuild" 
    1287     fi 
    1288  
    1289     IGCM_debug_PopStack "IGCM_sys_rebuild" 
     1611  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 
     1612  if ( $DEBUG_sys ) ; then 
     1613    echo "IGCM_sys_rebuild :" $@ 
     1614  fi 
     1615  /home/cont003/p86ipsl/X64/bin/rebuild -f -o $@ 
     1616  if [ $? -gt 0 ] ; then 
     1617    echo "IGCM_sys_rebuild : erreur ${@}." 
     1618    IGCM_debug_Exit "rebuild" 
     1619  fi 
     1620 
     1621  IGCM_debug_PopStack "IGCM_sys_rebuild" 
    12901622} 
    12911623 
     
    12941626 
    12951627function IGCM_sys_activ_variables { 
    1296     IGCM_debug_PushStack "IGCM_sys_activ_variables" 
    1297     if ( $DEBUG_sys ) ; then 
    1298         echo "IGCM_sys_activ_variables" 
    1299     fi 
    1300 #    ulimit -s 2097152 
    1301  
    1302     typeset max_omp 
    1303  
    1304     ulimit -s unlimited 
    1305  
    1306     (( max_omp = 0 )) 
    1307     for comp in ${config_ListOfComponents[*]} ; do 
     1628  IGCM_debug_PushStack "IGCM_sys_activ_variables" 
     1629  if ( $DEBUG_sys ) ; then 
     1630    echo "IGCM_sys_activ_variables" 
     1631  fi 
     1632 
     1633  typeset max_omp 
     1634 
     1635  ulimit -s unlimited 
     1636 
     1637  (( max_omp = 0 )) 
     1638  for comp in ${config_ListOfComponents[*]} ; do 
    13081639         
    1309         eval ExeNameIn=\${config_Executable_${comp}[0]} 
    1310         eval ExeNameOut=\${config_Executable_${comp}[1]} 
    1311          
     1640    eval ExeNameIn=\${config_Executable_${comp}[0]} 
     1641    eval ExeNameOut=\${config_Executable_${comp}[1]} 
    13121642     
    1313         # Only if we really have an executable for the component : 
    1314         if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then 
    1315             eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
    1316  
    1317             if [ ${comp_proc_omp_loc} -gt ${max_omp} ] ; then 
    1318  
    1319                 (( max_omp = comp_proc_omp_loc )) 
    1320             fi 
    1321         fi 
    1322     done 
    1323     if [ ${max_omp} -gt 1 ] ; then 
    1324         module load openmp/${max_omp}thds 
    1325     fi 
    1326  
    1327     IGCM_debug_PopStack "IGCM_sys_activ_variables" 
     1643    # Only if we really have an executable for the component : 
     1644    if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then 
     1645      eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
     1646      if [ ${comp_proc_omp_loc} -gt ${max_omp} ] ; then 
     1647        (( max_omp = comp_proc_omp_loc )) 
     1648      fi 
     1649    fi 
     1650  done 
     1651  if [ ${max_omp} -gt 1 ] ; then 
     1652    module load openmp/${max_omp}thds 
     1653  fi 
     1654 
     1655  IGCM_debug_PopStack "IGCM_sys_activ_variables" 
    13281656} 
    13291657 
     
    13321660 
    13331661function IGCM_sys_desactiv_variables { 
    1334     IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
    1335     if ( $DEBUG_sys ) ; then 
    1336         echo "IGCM_sys_desactiv_variables" 
    1337     fi 
    1338     IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
     1662  IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 
     1663  if ( $DEBUG_sys ) ; then 
     1664    echo "IGCM_sys_desactiv_variables" 
     1665  fi 
     1666  IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 
    13391667} 
    13401668 
     
    13501678############################################################ 
    13511679# Build MPI/OMP scripts 
    1352  
    13531680function IGCM_sys_build_execution_scripts  
    13541681{ 
    1355     IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ 
    1356     if ( $DEBUG_sys ) ; then 
    1357         echo "IGCM_sys_build_execution_scripts " $@ 
    1358     fi 
    1359     typeset nodes listnodes init_node start_num init_exec comp ExeNameIn ExeNameOut  
    1360     typeset node_num_current node_current comp_proc_mpi_loc comp_proc_omp_loc  
    1361     typeset num_corempi nombre_restant_node nombre_restant_comp 
    1362  
    1363     if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then 
    1364         IGCM_debug_Exit "IGCM_sys_titane build_execution_scripts : Job_${config_UserChoices_JobName} doesn't exist in SUBMIT_DIR : ${SUBMIT_DIR} " 
    1365     fi 
    1366  
    1367     if ( ${OK_PARA_MPMD} ) ; then 
    1368  
    1369         if [ -f run_file ] ; then 
    1370             IGCM_sys_Rm -f run_file 
     1682  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ 
     1683  if ( $DEBUG_sys ) ; then 
     1684    echo "IGCM_sys_build_execution_scripts " $@ 
     1685  fi 
     1686  typeset nodes listnodes init_node start_num init_exec comp ExeNameIn ExeNameOut  
     1687  typeset node_num_current node_current comp_proc_mpi_loc comp_proc_omp_loc  
     1688  typeset num_corempi nombre_restant_node nombre_restant_comp 
     1689 
     1690  if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then 
     1691    IGCM_debug_Exit "IGCM_sys_titane build_execution_scripts : Job_${config_UserChoices_JobName} doesn't exist in SUBMIT_DIR : ${SUBMIT_DIR} " 
     1692  fi 
     1693 
     1694  if ( ${OK_PARA_MPMD} ) ; then 
     1695 
     1696    if [ -f run_file ] ; then 
     1697      IGCM_sys_Rm -f run_file 
     1698    fi 
     1699    touch run_file 
     1700 
     1701    if ( ${OK_PARA_OMP} ) ; then 
     1702 
     1703      #  Hosts treatment 
     1704 
     1705      ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp 
     1706         
     1707      i=0 
     1708      rm -f hosts 
     1709      IGCM_debug_Print 1 "sys Titane, Hosts avaible :" 
     1710      for nodes in `cat hosts.tmp` ; do 
     1711        host[$i]=$nodes 
     1712        echo "${host[$i]} slots=8 max_slots=8" >> hosts 
     1713        IGCM_debug_Print 1 ${host[$i]} 
     1714        i=$((i+1)) 
     1715      done 
     1716      rm -f hosts.tmp 
     1717             
     1718      listnodes=${host[*]} 
     1719             
     1720      EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts"  
     1721         
     1722      # Initialisation 
     1723 
     1724      init_node=y 
     1725      node_num_current=0 
     1726      start_num=0 
     1727      init_exec=n 
     1728 
     1729      # Test : if oasis is there, we put it at the first position 
     1730             
     1731      for comp in ${config_ListOfComponents[*]} ; do 
     1732                 
     1733        if [ "X${comp}" = "XCPL" ]  ; then 
     1734                     
     1735          eval ExeNameIn=\${config_Executable_${comp}[0]} 
     1736          eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1737                     
     1738          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh 
     1739          echo ""  >> script_${ExeNameOut}.ksh 
     1740          echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh 
     1741          echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh 
     1742          echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh 
     1743          echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err"  >> script_${ExeNameOut}.ksh 
     1744          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh 
     1745                     
     1746          init_node=n 
     1747                     
     1748          (( nombre_restant_node = NUM_COREPERNODE - 1 )) 
     1749          node_num_current=0 
     1750          node_current=${host[${node_num_current}]} 
     1751                     
     1752          EXECUTION="${EXECUTION} -H ${node_current} -np 1 ./script_${ExeNameOut}.ksh"  
     1753                     
     1754          init_exec=y 
     1755          start_num=1 
     1756                     
    13711757        fi 
    1372         touch run_file 
    1373  
    1374         if ( ${OK_PARA_OMP} ) ; then 
    1375  
    1376     #  Hosts treatment 
    1377  
    1378             ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp 
    1379          
    1380             i=0 
    1381             rm -f hosts 
    1382             IGCM_debug_Print 1 "sys Titane, Hosts avaible :" 
    1383             for nodes in `cat hosts.tmp` 
    1384             do 
    1385                 host[$i]=$nodes 
    1386                 echo "${host[$i]} slots=8 max_slots=8" >> hosts 
    1387                 IGCM_debug_Print 1 ${host[$i]} 
    1388                 i=$((i+1)) 
    1389             done 
    1390             rm -f hosts.tmp 
     1758                 
     1759      done 
    13911760             
    1392             listnodes=${host[*]} 
     1761      # Then loop on the components (except for oasis) 
     1762 
     1763      for comp in ${config_ListOfComponents[*]} ; do 
     1764                 
     1765        eval ExeNameIn=\${config_Executable_${comp}[0]} 
     1766        eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1767                 
     1768        # Only if we really have an executable for the component : 
     1769        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then 
     1770 
     1771          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
     1772          eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
     1773                     
     1774          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh 
     1775          # echo "set -vx" >> script_${ExeNameOut}.ksh 
     1776          echo ""  >> script_${ExeNameOut}.ksh 
     1777          echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh 
     1778          echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh 
     1779          echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh 
     1780          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh 
     1781          echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh 
     1782          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh 
     1783          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh 
     1784                     
     1785          node_num=0 
     1786                     
     1787          # We define the number of MPI process to be assigned for the component  
     1788 
     1789          nombre_restant_comp=${comp_proc_mpi_loc} 
     1790                     
     1791          # Loop on the allocated nodes 
     1792 
     1793          for node in ${listnodes} ; do 
     1794 
     1795            # We go to the current node 
     1796            if [ ${node_num} = ${node_num_current} ] ; then 
     1797 
     1798              node_current=${host[${node_num_current}]} 
     1799 
     1800              # If first time on the node : initialisation  
     1801 
     1802              if [ ${init_node} = y ] ; then 
     1803                nombre_restant_node=${NUM_COREPERNODE} 
     1804              fi 
     1805                             
     1806              # Test on the number of OMP threads 
     1807 
     1808              if [ ${comp_proc_omp_loc} -gt ${nombre_restant_node} ] ; then 
     1809                (( node_num = node_num + 1 )) 
     1810                node_num_current=${node_num} 
     1811                init_node=y 
     1812                continue 
     1813              fi 
     1814 
     1815              # Number of MPI process to assign 
     1816 
     1817              (( num_corempi = nombre_restant_node / comp_proc_omp_loc )) 
     1818                             
     1819              if [ ${num_corempi} -gt ${nombre_restant_comp} ] ; then 
     1820                num_corempi=${nombre_restant_comp} 
     1821              fi 
     1822 
     1823              (( nombre_restant_node = nombre_restant_node - num_corempi * comp_proc_omp_loc )) 
     1824              (( nombre_restant_comp = nombre_restant_comp - num_corempi )) 
     1825                             
     1826              if [ ${init_exec} = y ] ; then 
     1827                EXECUTION="${EXECUTION} : -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh" 
     1828              else       
     1829                EXECUTION="${EXECUTION} -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh" 
     1830                init_exec=y 
     1831              fi 
     1832 
     1833              ((  start_num = num_corempi + start_num )) 
     1834                             
     1835            else 
     1836                             
     1837              (( node_num = node_num + 1 ))  
     1838              continue 
     1839            fi 
     1840                         
     1841            # Test on the number of core/process remaining on the node/component  
     1842                         
     1843            if [ ${nombre_restant_node} = 0 ] ; then 
     1844              (( node_num = node_num + 1 )) 
     1845              node_num_current=${node_num} 
     1846              init_node=y 
     1847 
     1848              if [ ${nombre_restant_comp} = 0 ] ; then 
     1849                break 1 
     1850              fi 
     1851            else 
     1852 
     1853              node_num_current=${node_num} 
     1854              init_node=n 
     1855                             
     1856              if [ ${nombre_restant_comp} = 0 ] ; then 
     1857                break 1 
     1858              fi 
     1859            fi 
     1860          done 
     1861        fi 
     1862      done 
    13931863             
    1394             EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts"  
    1395 #       fi 
    1396          
    1397 # Initialisation 
    1398  
    1399             init_node=y 
    1400             node_num_current=0 
    1401             start_num=0 
    1402             init_exec=n 
    1403  
    1404  
    1405 # Test : if oasis is there, we put it at the first position 
    1406              
    1407             for comp in ${config_ListOfComponents[*]} ; do 
     1864    else 
     1865 
     1866      # Then first loop on the components for the coupler ie oasis 
     1867 
     1868      ### the coupler ie oasis must be the first one 
     1869      for comp in ${config_ListOfComponents[*]} ; do 
    14081870                 
    1409                 if [ "X${comp}" = "XCPL" ]  ; then 
     1871        eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1872                 
     1873        # for CPL component only 
     1874        if [ "X${comp}" = "XCPL" ] ; then 
     1875 
     1876          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
    14101877                     
    1411                     eval ExeNameIn=\${config_Executable_${comp}[0]} 
    1412                     eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1878          if ( ${OK_PARA_MPI} ) ; then  
     1879            (( mpi_count = 1 )) 
     1880            until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do 
     1881              echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file  
     1882              (( mpi_count = mpi_count + 1 )) 
     1883            done 
     1884          else 
     1885            echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file  
     1886          fi 
     1887        fi 
     1888      done 
     1889 
     1890      # Then second loop on the components 
     1891 
     1892      for comp in ${config_ListOfComponents[*]} ; do 
     1893                 
     1894        eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1895                 
     1896        # Only if we really have an executable for the component and not the coupler ie oasis: 
     1897        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then 
     1898 
     1899          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
    14131900                     
    1414                     echo "#!/bin/ksh" > script_${ExeNameOut}.ksh 
    1415                     echo ""  >> script_${ExeNameOut}.ksh 
    1416                     echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh 
    1417                     echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh 
    1418                     echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh 
    1419                     echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err"  >> script_${ExeNameOut}.ksh 
    1420                     IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh 
    1421                      
    1422                     init_node=n 
    1423                      
    1424                     (( nombre_restant_node = NUM_COREPERNODE - 1 )) 
    1425                     node_num_current=0 
    1426                     node_current=${host[${node_num_current}]} 
    1427                      
    1428                     EXECUTION="${EXECUTION} -H ${node_current} -np 1 ./script_${ExeNameOut}.ksh"  
    1429                      
    1430                     init_exec=y 
    1431                     start_num=1 
    1432                      
    1433                 fi 
     1901          if ( ${OK_PARA_MPI} ) ; then  
     1902 
     1903            (( mpi_count = 1 )) 
     1904            until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do 
     1905              echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file  
     1906              (( mpi_count = mpi_count + 1 )) 
     1907            done 
     1908          else 
     1909            echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file  
     1910          fi 
     1911        fi 
     1912      done 
     1913      IGCM_sys_Chmod u+x run_file 
     1914 
     1915      EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file" 
     1916           
     1917    fi 
     1918 
     1919  else # Only one executable. launch it. 
     1920 
     1921    for comp in ${config_ListOfComponents[*]} ; do 
     1922 
     1923      # Only if we really have an executable for the component : 
     1924      eval ExeNameOut=\${config_Executable_${comp}[1]} 
     1925      if ( [ "X${ExeNameOut}" != X\"\" ] ) ; then        
    14341926                 
    1435             done 
    1436              
    1437 # Then loop on the components (except for oasis) 
    1438  
    1439             for comp in ${config_ListOfComponents[*]} ; do 
    1440                  
    1441                 eval ExeNameIn=\${config_Executable_${comp}[0]} 
    1442                 eval ExeNameOut=\${config_Executable_${comp}[1]} 
    1443                  
    1444                  
    1445         # Only if we really have an executable for the component : 
    1446                 if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then 
    1447  
    1448                     eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
    1449                     eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 
    1450                      
    1451                     echo "#!/bin/ksh" > script_${ExeNameOut}.ksh 
    1452 #               echo "set -vx" >> script_${ExeNameOut}.ksh 
    1453                     echo ""  >> script_${ExeNameOut}.ksh 
    1454                     echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh 
    1455                     echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh 
    1456                     echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh 
    1457                     echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh 
    1458                     echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh 
    1459                     echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh 
    1460                     IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh 
    1461                      
    1462                     node_num=0 
    1463                      
    1464 # We define the number of MPI process to be assigned for the component  
    1465  
    1466                     nombre_restant_comp=${comp_proc_mpi_loc} 
    1467                      
    1468 # Loop on the allocated nodes 
    1469  
    1470                     for node in ${listnodes} ; do 
    1471  
    1472 # We go to the current node 
    1473  
    1474                         if [ ${node_num} = ${node_num_current} ] ; then 
    1475  
    1476                             node_current=${host[${node_num_current}]} 
    1477  
    1478 # If first time on the node : initialisation  
    1479  
    1480                             if [ ${init_node} = y ] ; then 
    1481                                 nombre_restant_node=${NUM_COREPERNODE} 
    1482                             fi 
    1483                              
    1484 # Test on the number of OMP threads 
    1485  
    1486                             if [ ${comp_proc_omp_loc} -gt ${nombre_restant_node} ] ; then 
    1487                                 (( node_num = node_num + 1 )) 
    1488                                 node_num_current=${node_num} 
    1489                                 init_node=y 
    1490                                 continue 
    1491                             fi 
    1492  
    1493 # Number of MPI process to assign 
    1494  
    1495                             (( num_corempi = nombre_restant_node / comp_proc_omp_loc )) 
    1496                              
    1497                             if [ ${num_corempi} -gt ${nombre_restant_comp} ] ; then 
    1498                                 num_corempi=${nombre_restant_comp} 
    1499                             fi 
    1500  
    1501                             (( nombre_restant_node = nombre_restant_node - num_corempi * comp_proc_omp_loc )) 
    1502                             (( nombre_restant_comp = nombre_restant_comp - num_corempi )) 
    1503                              
    1504                             if [ ${init_exec} = y ] ; then 
    1505                                 EXECUTION="${EXECUTION} : -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh" 
    1506                             else         
    1507                                 EXECUTION="${EXECUTION} -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh" 
    1508                                 init_exec=y 
    1509                             fi 
    1510  
    1511                             ((  start_num = num_corempi + start_num )) 
    1512                              
    1513                         else 
    1514                              
    1515                             (( node_num = node_num + 1 ))  
    1516                             continue 
    1517                         fi 
    1518                          
    1519 # Test on the number of core/process remaining on the node/component  
    1520                          
    1521                         if [ ${nombre_restant_node} = 0 ] ; then 
    1522                             (( node_num = node_num + 1 )) 
    1523                             node_num_current=${node_num} 
    1524                             init_node=y 
    1525  
    1526                             if [ ${nombre_restant_comp} = 0 ] ; then 
    1527                                 break 1 
    1528                             fi 
    1529                         else 
    1530  
    1531                             node_num_current=${node_num} 
    1532                             init_node=n 
    1533                              
    1534                             if [ ${nombre_restant_comp} = 0 ] ; then 
    1535                                 break 1 
    1536                             fi 
    1537                         fi 
    1538                     done 
    1539                 fi 
    1540             done 
    1541              
     1927        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh 
     1928        echo ""  >> script_${ExeNameOut}.ksh 
     1929        if ( ${OK_PARA_OMP} ) ; then  
     1930          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh        
     1931        fi 
     1932        if  ( ${OK_PARA_MPI} ) ; then  
     1933          # Attention : a voir si sur 1 proc mais non // 
     1934          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}"  >> script_${ExeNameOut}.ksh 
     1935          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh 
     1936          EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh" 
    15421937        else 
    1543  
    1544  # Then first loop on the components for the coupler ie oasis 
    1545  
    1546 ### the coupler ie oasis must be the first one 
    1547             for comp in ${config_ListOfComponents[*]} ; do 
    1548                  
    1549                 eval ExeNameOut=\${config_Executable_${comp}[1]} 
    1550                  
    1551         # for CPL component only 
    1552                 if [ "X${comp}" = "XCPL" ] ; then 
    1553  
    1554                     eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
    1555                      
    1556                     if ( ${OK_PARA_MPI} ) ; then  
    1557                         (( mpi_count = 1 )) 
    1558                         until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do 
    1559                             echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file  
    1560                             (( mpi_count = mpi_count + 1 )) 
    1561                         done 
    1562                     else 
    1563                         echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file  
    1564                     fi 
    1565                 fi 
    1566             done 
    1567  
    1568 # Then second loop on the components 
    1569  
    1570             for comp in ${config_ListOfComponents[*]} ; do 
    1571                  
    1572                 eval ExeNameOut=\${config_Executable_${comp}[1]} 
    1573                  
    1574         # Only if we really have an executable for the component and not the coupler ie oasis: 
    1575                 if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then 
    1576  
    1577                     eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 
    1578                      
    1579                     if ( ${OK_PARA_MPI} ) ; then  
    1580  
    1581                         (( mpi_count = 1 )) 
    1582                         until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do 
    1583                             echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file  
    1584                             (( mpi_count = mpi_count + 1 )) 
    1585                         done 
    1586                     else 
    1587                         echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file  
    1588                     fi 
    1589                 fi 
    1590             done 
    1591             IGCM_sys_Chmod u+x run_file 
    1592  
    1593             EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file" 
    1594            
    1595         fi 
    1596  
    1597     else # Only one executable. launch it. 
    1598  
    1599         for comp in ${config_ListOfComponents[*]} ; do 
    1600  
    1601         # Only if we really have an executable for the component : 
    1602             eval ExeNameOut=\${config_Executable_${comp}[1]} 
    1603             if ( [ "X${ExeNameOut}" != X\"\" ] ) ; then  
    1604                  
    1605                 echo "#!/bin/ksh" > script_${ExeNameOut}.ksh 
    1606                 echo ""  >> script_${ExeNameOut}.ksh 
    1607                 if ( ${OK_PARA_OMP} ) ; then  
    1608                     echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh      
    1609                 fi 
    1610                 if  ( ${OK_PARA_MPI} ) ; then  
    1611 # Attention : a voir si sur 1 proc mais non // 
    1612                     echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}"  >> script_${ExeNameOut}.ksh 
    1613                     IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh 
    1614                     EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh" 
    1615                 else 
    1616                     EXECUTION="time ./${ExeNameOut}" 
    1617                 fi 
    1618             fi 
    1619         done 
    1620  
    1621     fi 
     1938          EXECUTION="time ./${ExeNameOut}" 
     1939        fi 
     1940      fi 
     1941    done 
     1942 
     1943  fi 
    16221944 
    16231945  IGCM_debug_Print 1 "sys Titane : La commande d execution est " 
     
    16321954# NCO OPERATOR 
    16331955 
     1956function IGCM_sys_ncap2 { 
     1957  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ 
     1958  if ( $DEBUG_sys ) ; then 
     1959    echo "IGCM_sys_ncap2 :" $@ 
     1960  fi 
     1961  ncap2 "$@" 
     1962  if [ $? -gt 0 ] ; then 
     1963    echo "IGCM_sys_ncap2 : erreur ${@}." 
     1964    IGCM_debug_Exit "ncap2" 
     1965  fi 
     1966 
     1967  IGCM_debug_PopStack "IGCM_sys_ncap2" 
     1968} 
     1969 
    16341970function IGCM_sys_ncatted { 
    1635     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
    1636     if ( $DEBUG_sys ) ; then 
    1637         echo "IGCM_sys_ncatted :" $@ 
    1638     fi 
    1639     ncatted "$@" 
    1640     if [ $? -gt 0 ] ; then 
    1641        echo "IGCM_sys_ncatted : erreur ${@}." 
    1642        IGCM_debug_Exit "ncatted" 
    1643     fi 
    1644  
    1645     IGCM_debug_PopStack "IGCM_sys_ncatted" 
     1971  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 
     1972  if ( $DEBUG_sys ) ; then 
     1973    echo "IGCM_sys_ncatted :" $@ 
     1974  fi 
     1975  ncatted "$@" 
     1976  if [ $? -gt 0 ] ; then 
     1977    echo "IGCM_sys_ncatted : erreur ${@}." 
     1978    IGCM_debug_Exit "ncatted" 
     1979  fi 
     1980 
     1981  IGCM_debug_PopStack "IGCM_sys_ncatted" 
    16461982} 
    16471983 
    16481984function IGCM_sys_ncbo { 
    1649     IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
    1650     if ( $DEBUG_sys ) ; then 
    1651         echo "IGCM_sys_ncbo :" $@ 
    1652     fi 
    1653     ncbo $@ 
    1654     if [ $? -gt 0 ] ; then 
    1655        echo "IGCM_sys_ncbo : erreur ${@}." 
    1656        IGCM_debug_Exit "ncbo" 
    1657     fi 
    1658  
    1659     IGCM_debug_PopStack "IGCM_sys_ncbo" 
     1985  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 
     1986  if ( $DEBUG_sys ) ; then 
     1987    echo "IGCM_sys_ncbo :" $@ 
     1988  fi 
     1989  ncbo $@ 
     1990  if [ $? -gt 0 ] ; then 
     1991    echo "IGCM_sys_ncbo : erreur ${@}." 
     1992    IGCM_debug_Exit "ncbo" 
     1993  fi 
     1994 
     1995  IGCM_debug_PopStack "IGCM_sys_ncbo" 
    16601996} 
    16611997 
    16621998function IGCM_sys_ncdiff { 
    1663     IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
    1664     if ( $DEBUG_sys ) ; then 
    1665         echo "IGCM_sys_ncdiff :" $@ 
    1666     fi 
    1667     ncdiff $@ 
    1668     if [ $? -gt 0 ] ; then 
    1669        echo "IGCM_sys_ncdiff : erreur ${@}." 
    1670        IGCM_debug_Exit "ncdiff" 
    1671     fi 
    1672  
    1673     IGCM_debug_PopStack "IGCM_sys_ncdiff" 
     1999  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 
     2000  if ( $DEBUG_sys ) ; then 
     2001    echo "IGCM_sys_ncdiff :" $@ 
     2002  fi 
     2003  ncdiff $@ 
     2004  if [ $? -gt 0 ] ; then 
     2005    echo "IGCM_sys_ncdiff : erreur ${@}." 
     2006    IGCM_debug_Exit "ncdiff" 
     2007  fi 
     2008 
     2009  IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    16742010} 
    16752011 
    16762012function IGCM_sys_ncea { 
    1677     IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
    1678     if ( $DEBUG_sys ) ; then 
    1679         echo "IGCM_sys_ncea :" $@ 
    1680     fi 
    1681     ncea $@ 
    1682     if [ $? -gt 0 ] ; then 
    1683        echo "IGCM_sys_ncea : erreur ${@}." 
    1684        IGCM_debug_Exit "ncea" 
    1685     fi 
    1686  
    1687     IGCM_debug_PopStack "IGCM_sys_ncea" 
     2013  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 
     2014  if ( $DEBUG_sys ) ; then 
     2015    echo "IGCM_sys_ncea :" $@ 
     2016  fi 
     2017  ncea $@ 
     2018  if [ $? -gt 0 ] ; then 
     2019    echo "IGCM_sys_ncea : erreur ${@}." 
     2020    IGCM_debug_Exit "ncea" 
     2021  fi 
     2022 
     2023  IGCM_debug_PopStack "IGCM_sys_ncea" 
    16882024} 
    16892025 
    16902026function IGCM_sys_ncecat { 
    1691     IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
    1692     if ( $DEBUG_sys ) ; then 
    1693         echo "IGCM_sys_ncecat :" $@ 
    1694     fi 
    1695     ncecat $@ 
    1696     if [ $? -gt 0 ] ; then 
    1697        echo "IGCM_sys_ncecat : erreur ${@}." 
    1698        IGCM_debug_Exit "ncecat" 
    1699     fi 
    1700  
    1701     IGCM_debug_PopStack "IGCM_sys_ncecat" 
     2027  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 
     2028  if ( $DEBUG_sys ) ; then 
     2029    echo "IGCM_sys_ncecat :" $@ 
     2030  fi 
     2031  ncecat $@ 
     2032  if [ $? -gt 0 ] ; then 
     2033    echo "IGCM_sys_ncecat : erreur ${@}." 
     2034    IGCM_debug_Exit "ncecat" 
     2035  fi 
     2036 
     2037  IGCM_debug_PopStack "IGCM_sys_ncecat" 
    17022038} 
    17032039 
    17042040function IGCM_sys_ncflint { 
    1705     IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
    1706     if ( $DEBUG_sys ) ; then 
    1707         echo "IGCM_sys_ncflint :" $@ 
    1708     fi 
    1709     ncflint $@ 
    1710     if [ $? -gt 0 ] ; then 
    1711        echo "IGCM_sys_ncflint : erreur ${@}." 
    1712        IGCM_debug_Exit "ncflint" 
    1713     fi 
    1714  
    1715     IGCM_debug_PopStack "IGCM_sys_ncflint" 
     2041  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 
     2042  if ( $DEBUG_sys ) ; then 
     2043    echo "IGCM_sys_ncflint :" $@ 
     2044  fi 
     2045  ncflint $@ 
     2046  if [ $? -gt 0 ] ; then 
     2047    echo "IGCM_sys_ncflint : erreur ${@}." 
     2048    IGCM_debug_Exit "ncflint" 
     2049  fi 
     2050 
     2051  IGCM_debug_PopStack "IGCM_sys_ncflint" 
    17162052} 
    17172053 
    17182054function IGCM_sys_ncks { 
    1719     IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
    1720     if ( $DEBUG_sys ) ; then 
    1721         echo "IGCM_sys_ncks :" $@ 
    1722     fi 
    1723     ncks $@ 
    1724     if [ $? -gt 0 ] ; then 
    1725        echo "IGCM_sys_ncks : erreur ${@}." 
    1726        IGCM_debug_Exit "ncks" 
    1727     fi 
    1728  
    1729     IGCM_debug_PopStack "IGCM_sys_ncks" 
     2055  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 
     2056  if ( $DEBUG_sys ) ; then 
     2057    echo "IGCM_sys_ncks :" $@ 
     2058  fi 
     2059  ncks $@ 
     2060  if [ $? -gt 0 ] ; then 
     2061    echo "IGCM_sys_ncks : erreur ${@}." 
     2062    IGCM_debug_Exit "ncks" 
     2063  fi 
     2064 
     2065  IGCM_debug_PopStack "IGCM_sys_ncks" 
    17302066} 
    17312067 
    17322068function IGCM_sys_ncpdq { 
    1733     IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
    1734     if ( $DEBUG_sys ) ; then 
    1735         echo "IGCM_sys_ncpdq :" $@ 
    1736     fi 
    1737     ncpdq $@ 
    1738     if [ $? -gt 0 ] ; then 
    1739        echo "IGCM_sys_ncpdq : erreur ${@}." 
    1740        IGCM_debug_Exit "ncpdq" 
    1741     fi 
    1742  
    1743     IGCM_debug_PopStack "IGCM_sys_ncpdq" 
     2069  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 
     2070  if ( $DEBUG_sys ) ; then 
     2071    echo "IGCM_sys_ncpdq :" $@ 
     2072  fi 
     2073  ncpdq $@ 
     2074  if [ $? -gt 0 ] ; then 
     2075    echo "IGCM_sys_ncpdq : erreur ${@}." 
     2076    IGCM_debug_Exit "ncpdq" 
     2077  fi 
     2078 
     2079  IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    17442080} 
    17452081 
    17462082function IGCM_sys_ncra { 
    1747     IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
    1748     if ( $DEBUG_sys ) ; then 
    1749         echo "IGCM_sys_ncra :" $@ 
    1750     fi 
    1751     ncra $@ 
    1752     if [ $? -gt 0 ] ; then 
    1753        echo "IGCM_sys_ncra : erreur ${@}." 
    1754        IGCM_debug_Exit "ncra" 
    1755     fi 
    1756  
    1757     IGCM_debug_PopStack "IGCM_sys_ncra" 
     2083  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 
     2084  if ( $DEBUG_sys ) ; then 
     2085    echo "IGCM_sys_ncra :" $@ 
     2086  fi 
     2087  ncra $@ 
     2088  if [ $? -gt 0 ] ; then 
     2089    echo "IGCM_sys_ncra : erreur ${@}." 
     2090    IGCM_debug_Exit "ncra" 
     2091  fi 
     2092 
     2093  IGCM_debug_PopStack "IGCM_sys_ncra" 
    17582094} 
    17592095 
    17602096function IGCM_sys_ncrcat { 
    1761     IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
    1762     if ( $DEBUG_sys ) ; then 
    1763         echo "IGCM_sys_ncrcat :" $@ 
    1764     fi 
    1765     ncrcat $@ 
    1766     if [ $? -gt 0 ] ; then 
    1767        echo "IGCM_sys_ncrcat : erreur ${@}." 
     2097  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 
     2098  if ( $DEBUG_sys ) ; then 
     2099    echo "IGCM_sys_ncrcat :" $@ 
     2100  fi 
     2101  ncrcat $@ 
     2102  if [ $? -gt 0 ] ; then 
     2103    echo "IGCM_sys_ncrcat : erreur ${@}." 
    17682104#       IGCM_debug_Exit "ncrcat" 
    1769     fi 
    1770  
    1771     IGCM_debug_PopStack "IGCM_sys_ncrcat" 
     2105  fi 
     2106 
     2107  IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    17722108} 
    17732109 
    17742110function IGCM_sys_ncrename { 
    1775     IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
    1776     if ( $DEBUG_sys ) ; then 
    1777         echo "IGCM_sys_ncrename :" $@ 
    1778     fi 
    1779     ncrename $@ 
    1780     if [ $? -gt 0 ] ; then 
    1781        echo "IGCM_sys_ncrename : erreur ${@}." 
    1782        IGCM_debug_Exit "ncrename" 
    1783     fi 
    1784  
    1785     IGCM_debug_PopStack "IGCM_sys_ncrename" 
     2111  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 
     2112  if ( $DEBUG_sys ) ; then 
     2113    echo "IGCM_sys_ncrename :" $@ 
     2114  fi 
     2115  ncrename $@ 
     2116  if [ $? -gt 0 ] ; then 
     2117    echo "IGCM_sys_ncrename : erreur ${@}." 
     2118    IGCM_debug_Exit "ncrename" 
     2119  fi 
     2120 
     2121  IGCM_debug_PopStack "IGCM_sys_ncrename" 
    17862122} 
    17872123 
    17882124function IGCM_sys_ncwa { 
    1789     IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
    1790     if ( $DEBUG_sys ) ; then 
    1791         echo "IGCM_sys_ncwa :" $@ 
    1792     fi 
    1793     ncwa $@ 
    1794     if [ $? -gt 0 ] ; then 
    1795        echo "IGCM_sys_ncwa : erreur ${@}." 
    1796        IGCM_debug_Exit "ncwa" 
    1797     fi 
    1798  
    1799     IGCM_debug_PopStack "IGCM_sys_ncwa" 
    1800 } 
     2125  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 
     2126  if ( $DEBUG_sys ) ; then 
     2127    echo "IGCM_sys_ncwa :" $@ 
     2128  fi 
     2129  ncwa $@ 
     2130  if [ $? -gt 0 ] ; then 
     2131    echo "IGCM_sys_ncwa : erreur ${@}." 
     2132    IGCM_debug_Exit "ncwa" 
     2133  fi 
     2134 
     2135  IGCM_debug_PopStack "IGCM_sys_ncwa" 
     2136} 
     2137 
     2138############################################################## 
     2139# CDO OPERATOR 
     2140 
     2141function IGCM_sys_cdo { 
     2142  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ 
     2143  if ( $DEBUG_sys ) ; then 
     2144    echo "IGCM_sys_cdo :" $@ 
     2145  fi 
     2146  \cdo $@ 
     2147  if [ $? -gt 0 ] ; then 
     2148    echo "IGCM_sys_cdo : erreur ${@}." 
     2149    IGCM_debug_PopStack "IGCM_sys_cdo" 
     2150    return 1 
     2151  else 
     2152    IGCM_debug_PopStack "IGCM_sys_cdo" 
     2153    return 0 
     2154  fi 
     2155 
     2156  IGCM_debug_PopStack "IGCM_sys_cdo" 
     2157} 
  • branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_ulam.ksh

    r505 r571  
    101101#==================================================== 
    102102#- ARCHIVE 
    103 # modified 17/10/2011 /u to be used for file stored on gaya 
    104 if (tty -s ) then  
    105 typeset -r ARCHIVE=${HOMEGAYA} 
    106 else 
    107 typeset -r ARCHIVE=$(echo ${HOMEGAYA}|sed 's,/homegaya/,/u/',) 
     103# modified 17/10/2011 /u to be used for file stored on gaya  
     104if (tty -s ) then   
     105    typeset -r ARCHIVE=${HOMEGAYA}  
     106else  
     107    typeset -r ARCHIVE=$(echo ${HOMEGAYA}|sed 's,/homegaya/,/u/',)  
    108108fi 
    109  
    110109 
    111110#==================================================== 
     
    119118 
    120119#==================================================== 
     120#- R_BUF  Buffer to pack files stored on Master 
     121typeset -r R_BUF=${WORKDIR}/BUFFER_IGCM 
     122 
     123#==================================================== 
    121124#- OUT_POST 
    122125typeset -r R_OUT_POST=${WORKDIR}/IGCM_OUT 
     
    128131#==================================================== 
    129132#- Max number of arguments passed to nco operator or demigration command 
    130 UNIX_MAX_LIMIT=12 
     133UNIX_MAX_LIMIT=120 
    131134 
    132135#D-#================================================== 
     
    378381        echo "IGCM_sys_TestDirArchive :" $@ 
    379382    fi 
    380     typeset ExistFlag DirNameToTest 
    381     # modified 17/10/2011 /u is not known on ulam, use /homegaya instead to test dir locally on ulam 
    382     DirNameToTest=$(echo $1 | sed 's,/u/,/homegaya/,') 
     383    typeset ExistFlag DirNameToTest  
     384    # modified 17/10/2011 /u is not known on ulam, use /homegaya instead to test dir locally on ulam  
     385    DirNameToTest=$(echo $1 | sed 's,/u/,/homegaya/,')  
    383386    ExistFlag=$( [ -d ${DirNameToTest} ] && echo 0 || echo 1 ) 
    384387    IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 
     
    397400        echo "IGCM_sys_TestFileArchive :" $@ 
    398401    fi 
    399     typeset ExistFlag FileNameToTest 
    400     # modified 17/10/2011 /u is not known on ulam, use /homegaya instead to test dir locally on ulam 
    401     FileNameToTest=$(echo $1 | sed 's,/u/,/homegaya/,') 
    402     ExistFlag=$( IGCM_sys_RshArchive "[ -f ${FileNameToTest} ] && echo 0 || echo 1" ) 
     402    typeset ExistFlag FileNameToTest  
     403    # modified 17/10/2011 /u is not known on ulam, use /homegaya instead to test dir locally on ulam  
     404    FileNameToTest=$(echo $1 | sed 's,/u/,/homegaya/,')  
     405    ExistFlag=$( IGCM_sys_RshArchive "[ -f ${FileNameToTest} ] && echo 0 || echo 1" )  
    403406    IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    404407 
     
    491494        IGCM_debug_Exit "IGCM_sys_QsubPost" 
    492495    fi 
     496 
    493497    IGCM_debug_PopStack "IGCM_sys_QsubPost" 
    494498} 
  • branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_vargas.ksh

    r558 r571  
    8181typeset -r RSYNC_opt="-va" 
    8282# ie storage filesystem 
    83 typeset -r RHOST=gaya.idris.fr 
     83typeset -r STOREHOST=gaya.idris.fr 
    8484typeset -r REMOTE_RSYNC=/u/rech/ces/rces452/RSYNC/bin/rsync 
    8585 
     
    118118#- OUT 
    119119typeset -r R_OUT=${ARCHIVE}/IGCM_OUT 
     120 
     121#==================================================== 
     122#- R_BUF  Buffer to pack files 
     123typeset -r R_BUF=${WORKDIR}/BUFFER_IGCM 
    120124 
    121125#==================================================== 
     
    149153 
    150154#D-#================================================== 
     155#D-function IGCM_sys_RshMaster 
     156#D-* Purpose: Connection to frontend machine. 
     157#D-* Examples: 
     158#D- 
     159(( RshMNum = 0 )) 
     160function IGCM_sys_RshMaster { 
     161    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
     162 
     163    typeset THEFILE OUTFILE ERR 
     164 
     165    RshDIR=${WORKDIR}/RUN_DIR/${config_UserChoices_TagName}/${config_UserChoices_JobName}.${$} 
     166    if [ ! -d ${RshDIR} ] ; then 
     167        IGCM_sys_Mkdir ${RshDIR} 
     168    fi 
     169    THEFILE=${RshDIR}/file_sys_RshMaster_$$_${RshMNum} 
     170    echo '#!/bin/ksh' > ${THEFILE} 
     171    echo "export libIGCM=${libIGCM} > /dev/null 2>&1" >> ${THEFILE} 
     172    echo "export DEBUG_debug=${DEBUG_debug} > /dev/null 2>&1" >> ${THEFILE} 
     173    echo ". ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh > /dev/null 2>&1" >> ${THEFILE} 
     174    echo ". ${libIGCM}/libIGCM_card/libIGCM_card.ksh > /dev/null 2>&1" >> ${THEFILE} 
     175    echo "${@} " >> ${THEFILE} 
     176 
     177    # No frontend queue on brodie : just rsh the job on the frontend with submission. 
     178    sed -e "s@IGCM_sys_Qsub\(.*\)@\1@" ${THEFILE} > ${THEFILE}_ 
     179 
     180    chmod u+x  ${THEFILE}_ 
     181 
     182    OUTFILE=${RshDIR}/out_RshMaster.$$.${RshMNum} 
     183    (( RshMNum = RshMNum + 1 )) 
     184 
     185    rsh ${MASTER} 'bash -c "nohup '${THEFILE}'_ > '${OUTFILE}' 2>&1 &"' 
     186    if [ $? -gt 0 ] ; then 
     187        echo "IGCM_sys_RshMaster : erreur." 
     188        IGCM_debug_Exit "IGCM_sys_RshMaster" 
     189    fi 
     190    IGCM_debug_PopStack "IGCM_sys_RshMaster" 
     191} 
     192 
     193#D-#================================================== 
    151194#D-function IGCM_sys_RshArchive 
    152195#D-* Purpose: Archive rsh command 
     
    155198function IGCM_sys_RshArchive { 
    156199    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 
    157     rsh gaya exec /bin/ksh <<-EOF 
     200    rsh ${STOREHOST} exec /bin/ksh <<-EOF 
    158201    ${@} 
    159202EOF 
     
    177220 
    178221    # keep standard input to keep it for postpone if ulam don't answer 
    179     cat >/tmp/tmp_IGCM_sys_RshPost_$$ 
     222    cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    180223 
    181224    ## Add submission for old postponed files only if command is a Qsub 
    182225    ## 
    183226    ISITQSUB=0 
    184     grep Qsub /tmp/tmp_IGCM_sys_RshPost_$$ >/dev/null 2>&1 && ISITQSUB=1 
     227    grep Qsub /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} >/dev/null 2>&1 && ISITQSUB=1 
    185228    if  ( [ ${ISITQSUB} -gt 0 ] ) ; then  
    186229      if [ -d ${SUBMIT_DIR}/POSTPONE ] ; then 
     
    201244    RETURN=0 
    202245    # rsh ulam command 
    203     rsh ulam exec /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$ 
     246    rsh ulam exec /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    204247    RETURN=$? 
    205248 
    206249    # keep standard input for postpone if ulam don't answer 
    207250    if ( [ ${RETURN} -gt 0 ] ) ; then 
    208         IGCM_debug_Print 2 "Postpone tmp_IGCM_sys_RshPost_$$" 
     251        IGCM_debug_Print 2 "Postpone tmp_IGCM_sys_RshPost_$$_${LOGNAME}" 
    209252        [ -d ${SUBMIT_DIR}/POSTPONE ] || mkdir ${SUBMIT_DIR}/POSTPONE 
    210         mv /tmp/tmp_IGCM_sys_RshPost_$$ ${SUBMIT_DIR}/POSTPONE 
     253        mv /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} ${SUBMIT_DIR}/POSTPONE 
     254    else 
     255        IGCM_sys_Rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    211256    fi 
    212257    IGCM_debug_PopStack "IGCM_sys_RshPost" 
     
    290335    fi 
    291336    #- creation de repertoire sur le serveur fichier 
    292     rsh gaya -n mkdir -p $1 
     337    rsh ${STOREHOST} -n mkdir -p $1 
    293338 
    294339    if [ $? -gt 0 ] ; then 
     
    413458 
    414459#D-#================================================== 
     460#D-function IGCM_sys_IsFileArchived 
     461#D-* Purpose: Test file that must NOT EXISTS on Archive 
     462#D-* always true on vargas. 
     463#D-* Examples: 
     464#D- 
     465function IGCM_sys_IsFileArchived { 
     466  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ 
     467  if ( $DEBUG_sys ) ; then 
     468    echo "IGCM_sys_IsFileArchived :" $@ 
     469  fi 
     470  typeset IsArchivedFlag 
     471  IsArchivedFlag=$( echo 0 ) 
     472  IGCM_debug_PopStack "IGCM_sys_IsFileArchived" 
     473 
     474  return ${IsArchivedFlag} 
     475} 
     476 
     477#D-#================================================== 
    415478#D-function IGCM_sys_TestFileArchive 
    416479#D-* Purpose: Test file that must NOT EXISTS on Archive 
     
    427490 
    428491#D-#================================================== 
     492#D-function IGCM_sys_TestFileBuffer 
     493#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     494#D-* Examples: 
     495#D- 
     496function IGCM_sys_TestFileBuffer { 
     497  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     498  typeset ExistFlag 
     499  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     500  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     501 
     502  return ${ExistFlag} 
     503} 
     504 
     505#D-#================================================== 
    429506#D-function IGCM_sys_CountFileArchive 
    430507#D-* Purpose: Count files on Archive filesystem 
     
    441518 
    442519#D-#================================================== 
     520#D-function IGCM_sys_CountFileBuffer 
     521#D-* Purpose: Count files on Scratch filesystem 
     522#D-* Examples: 
     523#D- 
     524function IGCM_sys_CountFileBuffer { 
     525  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     526  ls ${@} 2>/dev/null | wc -l 
     527  if [ $? -gt 0 ] ; then 
     528    echo "IGCM_sys_CountFileBuffer : erreur." 
     529  fi 
     530  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
     531} 
     532 
     533#D-#================================================== 
    443534#D-function IGCM_sys_Tree 
    444535#D-* Purpose: Tree directories with files on ${ARCHIVE} 
     
    466557        echo "IGCM_sys_Tar :" $@ 
    467558    fi 
    468     \tar cvf $@ 
     559    \tar cf $@ 
    469560    if [ $? -gt 0 ] ; then 
    470561        echo "IGCM_sys_Tar : erreur." 
    471562        IGCM_debug_Exit "IGCM_sys_Tar" 
    472563    fi 
    473     \tar tvf $1 
    474  
    475564    IGCM_debug_PopStack "IGCM_sys_Tar" 
    476565} 
     
    532621    fi 
    533622    cd ${POST_DIR} 
     623    echo MAF QsubPost vargas 
    534624    /opt/ibmll/LoadL/full/bin/llsubmit ${libIGCM_POST}/$1.job 
    535625    cd - 
     
    742832        cat out_rsync 
    743833        IGCM_debug_Exit "IGCM_sys_Cp" 
     834     else 
     835         \rm out_rsync 
    744836    fi 
    745837    IGCM_debug_PopStack "IGCM_sys_Cp" 
     
    784876            cat out_rsync 
    785877            IGCM_debug_Exit "IGCM_sys_Mv" 
     878        else 
     879            \rm out_rsync 
    786880        fi 
    787881    else 
     
    815909        # 
    816910        #USUAL WAY 
    817         rcp -r $1 gaya:$2 > out_rsync 2>&1 
     911        rcp -r $1 ${STOREHOST}:$2 > out_rsync 2>&1 
    818912        RET=$? 
    819913 
     
    822916            cat out_rsync 
    823917            IGCM_debug_Exit "IGCM_sys_Put_Dir" 
     918        else 
     919            \rm out_rsync 
    824920        fi 
    825921    else 
     
    849945 
    850946        #USUAL WAY 
    851         rcp -rp gaya:$1 $2 > out_rsync 2>&1 
     947        rcp -rp ${STOREHOST}:$1 $2 > out_rsync 2>&1 
    852948        RET=$? 
    853949 
     
    894990 
    895991#       #RSYNC WITH NETWORK RSH CALL 
    896 #       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    897 #       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     992#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     993#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    898994 
    899995#       #RSYNC WITH NFS USE 
     
    9111007            cat out_rsync 
    9121008            IGCM_debug_Exit "IGCM_sys_Put_Rest" 
     1009        else 
     1010            \rm out_rsync 
    9131011        fi 
    9141012    else 
     
    9161014    fi 
    9171015    IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
     1016} 
     1017 
     1018#D-#================================================== 
     1019#D-function IGCM_sys_PutBuffer_Rest 
     1020#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     1021#D-           File and target directory must exist. 
     1022#D-* Examples: 
     1023#D- 
     1024function IGCM_sys_PutBuffer_Rest { 
     1025  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     1026  if ( $DEBUG_sys ) ; then 
     1027    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     1028  fi 
     1029  if [ $DRYRUN = 0 ]; then 
     1030    if [ ! -f ${1} ] ; then 
     1031      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     1032      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1033    fi 
     1034 
     1035    typeset RET 
     1036    # 
     1037    if [ X${JobType} = XRUN ] ; then 
     1038      IGCM_sys_Chmod 444 ${1} 
     1039    fi 
     1040 
     1041    # 
     1042    # USUAL WAY 
     1043    \cp $1 $2 > out_rsync 2>&1 
     1044    RET=$? 
     1045 
     1046    if [ ${RET} -gt 0 ] ; then 
     1047      echo "IGCM_sys_PutBuffer_Rest : error." 
     1048      cat out_rsync 
     1049      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     1050    else 
     1051      \rm out_rsync 
     1052    fi 
     1053  else 
     1054    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1055  fi 
     1056  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    9181057} 
    9191058 
     
    9511090 
    9521091#       #RSYNC WITH NETWORK RSH CALL 
    953 #       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1 
    954 #       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1 
     1092#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     1093#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    9551094 
    9561095#       #RSYNC WITH NFS USE 
     
    9681107            cat out_rsync 
    9691108            IGCM_debug_Exit "IGCM_sys_Put_Out" 
     1109        else 
     1110            \rm out_rsync 
    9701111        fi 
    9711112        IGCM_sys_Rm out_rsync 
     
    9751116    IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    9761117    return 0 
     1118} 
     1119 
     1120#D-#================================================== 
     1121#D-function IGCM_sys_PutBuffer_Out 
     1122#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
     1123#D-* Examples: 
     1124#D- 
     1125function IGCM_sys_PutBuffer_Out { 
     1126  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     1127  if ( $DEBUG_sys ) ; then 
     1128    echo "IGCM_sys_PutBuffer_Out :" $@ 
     1129  fi 
     1130  if [ $DRYRUN = 0 ]; then 
     1131    if [ ! -f ${1} ] ; then 
     1132      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     1133      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1134      return 1 
     1135    fi 
     1136    # 
     1137    IGCM_sys_Mkdir $( dirname $2 ) 
     1138    # 
     1139    typeset RET 
     1140 
     1141    if [ X${JobType} = XRUN ] ; then 
     1142      if [ X${3} = X ] ; then 
     1143        IGCM_sys_Chmod 444 ${1} 
     1144      fi 
     1145    fi 
     1146    # 
     1147    # USUAL WAY 
     1148    \cp $1 $2 > out_rsync 2>&1 
     1149    RET=$? 
     1150 
     1151    if [ ${RET} -gt 0 ] ; then 
     1152      echo "IGCM_sys_PutBuffer_Out : error." 
     1153      cat out_rsync 
     1154      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
     1155    else 
     1156      \rm out_rsync 
     1157    fi 
     1158  else 
     1159    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     1160  fi 
     1161  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     1162  return 0 
    9771163} 
    9781164 
     
    10251211 
    10261212#       #RSYNC WITH NETWORK RSH CALL 
    1027 #       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
    1028 #       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
     1213#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
     1214#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
    10291215 
    10301216#       #RSYNC WITH NFS USE 
     
    10421228            cat out_rsync 
    10431229            IGCM_debug_Exit "IGCM_sys_Get" 
     1230        else 
     1231            \rm out_rsync 
    10441232        fi 
    10451233    else 
     
    10471235    fi 
    10481236    IGCM_debug_PopStack "IGCM_sys_Get" 
     1237} 
     1238 
     1239#D-#================================================== 
     1240#D-function IGCM_sys_GetBuffer 
     1241#D-* Purpose: Get a file from ${SCRATCHDIR} 
     1242#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     1243#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     1244function IGCM_sys_GetBuffer { 
     1245  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     1246 
     1247  typeset DEST RET buf_liste ifile target file_work 
     1248 
     1249  if ( $DEBUG_sys ) ; then 
     1250    echo "IGCM_sys_GetBuffer :" $@ 
     1251  fi 
     1252  if [ $DRYRUN -le 2 ]; then 
     1253    if [ X${1} = X'/l' ] ; then 
     1254      # test if the first file is present in the old computation : 
     1255      eval set +A buf_liste \${${2}} 
     1256    else 
     1257      eval set +A buf_liste ${1} 
     1258    fi 
     1259    eval DEST=\${${#}} 
     1260 
     1261    #USUAL WAY 
     1262    if [ X${1} = X'/l' ] ; then 
     1263      (( RET=0 )) 
     1264      for target in ${buf_liste[*]} ; do 
     1265        local_file=$( basename ${target} ) 
     1266        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1267        (( RET = RET + $? )) 
     1268      done 
     1269    else 
     1270      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 
     1271      RET=$? 
     1272    fi 
     1273 
     1274    if [ ${RET} -gt 0 ] ; then 
     1275      echo "IGCM_sys_GetBuffer : copy error." 
     1276      cat out_rsync 
     1277      IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     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_GetBuffer" 
    10491285} 
    10501286 
     
    10611297        echo "IGCM_sys_GetDate_FichWork :" $@ 
    10621298    fi 
     1299    typeset dateF 
     1300    set +A dateF -- $( rsh ${MASTER} -n /opt/freeware/bin/ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1301    eval ${2}=${dateF[5]} 
     1302 
    10631303    # donne la date filesys d'un fichier sur la machine work 
    10641304    IGCM_debug_PopStack "IGCM_sys_FichWork" 
     
    10751315        echo "IGCM_sys_GetDate_FichArchive :" $@ 
    10761316    fi 
     1317    typeset dateF 
     1318    set +A dateF -- $( rsh ${STOREHOST} -n ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
     1319    eval ${2}=${dateF[5]} 
     1320 
    10771321    IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    10781322} 
Note: See TracChangeset for help on using the changeset viewer.