Ignore:
Timestamp:
04/01/15 14:54:34 (9 years ago)
Author:
sdipsl
Message:

house keeping in libIGCM_sys (fourth pass). Will ease #248 and #251

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh

    r1180 r1181  
    217217 
    218218#D-#================================================== 
    219 #D-function IGCM_sys_RshMaster 
    220 #D-* Purpose: Connection to frontend machine. 
    221 #D-* Examples: 
    222 #D- 
    223 function IGCM_sys_RshMaster { 
    224   IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    225   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF 
    226     export libIGCM=${libIGCM} 
    227     export DEBUG_debug=${DEBUG_debug} 
    228     . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
    229     . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
    230     ${@} 
    231 EOF 
    232   if [ $? -gt 0 ] ; then 
    233     echo "IGCM_sys_RshMaster : erreur." 
    234     IGCM_debug_Exit "IGCM_sys_RshMaster" 
    235   fi 
    236   IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    237 } 
    238  
    239 #D-#================================================== 
    240219#D-function IGCM_sys_RshArchive 
    241220#D-* Purpose: Archive rsh command 
     
    264243  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ 
    265244  /bin/ksh <<-EOF 
    266     ${@} 2> \dev\null 
     245    ${@} 2> /dev/null 
    267246EOF 
    268247  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" 
    269 } 
    270  
    271 #D-#================================================== 
    272 #D-function IGCM_sys_RshPost 
    273 #D-* Purpose: Post-process rsh command 
    274 #D-* Examples: 
    275 #D- 
    276 function IGCM_sys_RshPost { 
    277   IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    278   if ( $DEBUG_sys ) ; then 
    279     echo "IGCM_sys_RshPost :" $@ 
    280   fi 
    281   # keep standard input (stdin) for the loop onto temporary file 
    282   cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    283  
    284   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    285   if [ $? -gt 0 ] ; then 
    286     echo "IGCM_sys_RshPost : erreur." 
    287     IGCM_debug_Exit "IGCM_sys_RshPost" 
    288   fi 
    289   # delete temporary file 
    290   \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    291   IGCM_debug_PopStack "IGCM_sys_RshPost" 
    292 } 
    293  
    294 #D-#================================================== 
    295 #D-function IGCM_sys_SendMail 
    296 #D-* Purpose: Send mail when simulation is over 
    297 #D-* Examples: 
    298 #D- 
    299 function IGCM_sys_SendMail { 
    300   IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    301   if ( $DEBUG_sys ) ; then 
    302     echo "IGCM_sys_SendMail :" $@ 
    303   fi 
    304  
    305   if [ X${1} = XAccounting ] ; then 
    306     status=Accounting 
    307     mailText=jobAccounting.mail 
    308   elif ( ${ExitFlag} ) ; then 
    309     status=failed 
    310     mailText=jobEnd.mail 
    311   else 
    312     status=completed 
    313     mailText=jobEnd.mail 
    314   fi 
    315  
    316   # Update selected mail template 
    317   while read -r line; do 
    318     eval echo $line >> mail.txt ; 
    319   done < ${libIGCM}/libIGCM_sys/${mailText} 
    320  
    321   if [ ! -z ${config_UserChoices_MailName} ] ; then 
    322     mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt 
    323   elif [ -f ~/.forward ] ; then 
    324     mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt 
    325   else 
    326     mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt 
    327   fi 
    328  
    329   sleep 10 
    330   rm -f mail.txt 
    331  
    332   IGCM_debug_PopStack "IGCM_sys_SendMail" 
    333 } 
    334  
    335 #D-#================================================== 
    336 #D-function IGCM_sys_Mkdir 
    337 #D-* Purpose: Master locale mkdir command 
    338 #D-* Examples: 
    339 #D- 
    340 function IGCM_sys_Mkdir { 
    341   IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    342   if ( $DEBUG_sys ) ; then 
    343     echo "IGCM_sys_Mkdir :" $@ 
    344   fi 
    345   if [ ! -d ${1} ]; then 
    346     \mkdir -p $1 
    347     if [ $? -gt 0 ] ; then 
    348       echo "IGCM_sys_Mkdir : erreur." 
    349       IGCM_debug_Exit "IGCM_sys_Mkdir" 
    350     fi 
    351   fi 
    352   # vérification : 
    353   if [ ! -d ${1} ] ; then 
    354     echo "IGCM_sys_Mkdir : erreur." 
    355     IGCM_debug_Exit "IGCM_sys_Mkdir" 
    356   fi 
    357   IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    358248} 
    359249 
     
    379269  fi 
    380270  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    381 } 
    382  
    383 #D-#================================================== 
    384 #D-function IGCM_sys_MkdirWork 
    385 #D-* Purpose: Mkdir on Work 
    386 #D-* Examples: 
    387 #D- 
    388 function IGCM_sys_MkdirWork { 
    389   IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    390   if ( $DEBUG_sys ) ; then 
    391     echo "IGCM_sys_MkdirWork :" $@ 
    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_MkdirWork : erreur." 
    398       IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    399     fi 
    400   fi 
    401   IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    402 } 
    403  
    404 #D-#================================================== 
    405 #D-function IGCM_sys_Cd 
    406 #D-* Purpose: master cd command 
    407 #D-* Examples: 
    408 #D- 
    409 function IGCM_sys_Cd { 
    410   IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    411   if ( $DEBUG_sys ) ; then 
    412     echo "IGCM_sys_Cd :" $@ 
    413   fi 
    414   \cd $1 
    415   if [ $? -gt 0 ] ; then 
    416     echo "IGCM_sys_Cd : erreur." 
    417     IGCM_debug_Exit "IGCM_sys_Cd" 
    418   fi 
    419   IGCM_debug_PopStack "IGCM_sys_Cd" 
    420 } 
    421  
    422 #D-#================================================== 
    423 #D-function IGCM_sys_Chmod 
    424 #D-* Purpose: Chmod 
    425 #D-* Examples: 
    426 #D- 
    427 function IGCM_sys_Chmod { 
    428   IGCM_debug_PushStack "IGCM_sys_Chmod" $@ 
    429   if ( $DEBUG_sys ) ; then 
    430     echo "IGCM_sys_Chmod :" $@ 
    431   fi 
    432   \chmod $@ 
    433   if [ $? -gt 0 ] ; then 
    434     echo "IGCM_sys_Chmod : erreur." 
    435     IGCM_debug_Exit "IGCM_sys_Chmod" 
    436   fi 
    437   IGCM_debug_PopStack "IGCM_sys_Chmod" 
    438 } 
    439  
    440 #D-#================================================== 
    441 #D-function IGCM_sys_FileSize 
    442 #D-* Purpose: Filesize 
    443 #D-* Examples: 
    444 #D- 
    445 function IGCM_sys_FileSize { 
    446   IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    447  
    448   typeset sizeF 
    449   set +A sizeF -- $( ls -la ${1} ) 
    450   if [ $? -gt 0 ] ; then 
    451     IGCM_debug_Exit "IGCM_sys_FileSize" 
    452   fi 
    453   eval ${2}=${sizeF[4]} 
    454  
    455   IGCM_debug_PopStack "IGCM_sys_FileSize" 
    456 } 
    457  
    458 #D-#================================================== 
    459 #D-function IGCM_sys_TestDir 
    460 #D-* Purpose: Test Directory that must exists 
    461 #D-* Examples: 
    462 #D- 
    463 function IGCM_sys_TestDir { 
    464   IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    465   if ( $DEBUG_sys ) ; then 
    466     echo "IGCM_sys_TestDir :" $@ 
    467   fi 
    468   typeset ExistFlag 
    469   ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    470   IGCM_debug_PopStack "IGCM_sys_TestDir" 
    471  
    472   return ${ExistFlag} 
    473271} 
    474272 
     
    522320 
    523321#D-#================================================== 
    524 #D-function IGCM_sys_TestFileBuffer 
    525 #D-* Purpose: Test file that must NOT EXISTS on Buffer 
    526 #D-* Examples: 
    527 #D- 
    528 function IGCM_sys_TestFileBuffer { 
    529   IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
    530   typeset ExistFlag 
    531   ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    532   IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
    533  
    534   return ${ExistFlag} 
    535 } 
    536  
    537 #D-#================================================== 
    538322#D-function IGCM_sys_CountFileArchive 
    539323#D-* Purpose: Count files on Archive filesystem 
     
    550334 
    551335#D-#================================================== 
    552 #D-function IGCM_sys_CountFileBuffer 
    553 #D-* Purpose: Count files on Scratch filesystem 
    554 #D-* Examples: 
    555 #D- 
    556 function IGCM_sys_CountFileBuffer { 
    557   IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
    558   ls ${@} 2>/dev/null | wc -l 
    559   if [ $? -gt 0 ] ; then 
    560     echo "IGCM_sys_CountFileBuffer : erreur." 
    561   fi 
    562   IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    563 } 
    564  
    565 #D-#================================================== 
    566336#D-function IGCM_sys_Tree 
    567337#D-* Purpose: Tree directories with files on ${ARCHIVE} 
     
    577347 
    578348  IGCM_debug_PopStack "IGCM_sys_Tree" 
    579 } 
    580  
    581 #D-#================================================== 
    582 #D-function IGCM_sys_Tar 
    583 #D-* Purpose: master tar command 
    584 #D-* Examples: 
    585 #D- 
    586 function IGCM_sys_Tar { 
    587   IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    588   if ( $DEBUG_sys ) ; then 
    589     echo "IGCM_sys_Tar :" $@ 
    590   fi 
    591   \tar cf $@ 
    592   if [ $? -gt 0 ] ; then 
    593     echo "IGCM_sys_Tar : erreur." 
    594     IGCM_debug_Exit "IGCM_sys_Tar" 
    595   fi 
    596   IGCM_debug_PopStack "IGCM_sys_Tar" 
    597 } 
    598  
    599 #D-#================================================== 
    600 #D-function IGCM_sys_UnTar 
    601 #D-* Purpose: master un-tar command 
    602 #D-* Examples: 
    603 #D- 
    604 function IGCM_sys_UnTar { 
    605   IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    606   if ( $DEBUG_sys ) ; then 
    607     echo "IGCM_sys_UnTar :" $@ 
    608   fi 
    609   \tar xvf $1 
    610   if [ $? -gt 0 ] ; then 
    611     echo "IGCM_sys_UnTar : erreur." 
    612     IGCM_debug_Exit "IGCM_sys_UnTar" 
    613   fi 
    614   IGCM_debug_PopStack "IGCM_sys_UnTar" 
    615349} 
    616350 
     
    671405 
    672406#D-#================================================== 
    673 #D-function IGCM_sys_Rsync_out 
    674 #D-* Purpose: treat return val of rsync 
    675 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync 
    676 #D-  Error values and explanations can depend on your system version. 
    677 function IGCM_sys_Rsync_out { 
    678   status=$1 
    679   if [ ! $status ] ; then 
    680     echo "rsync error !" 
    681   fi 
    682  
    683   if [ $MYLANG = "fr" ]; then 
    684     case $status in 
    685     0)  return ;; 
    686     1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    687       echo "Erreur de syntaxe ou d'utilisation." 
    688       return;; 
    689     2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    690       echo "Incompatibilité de protocole." 
    691       return;; 
    692     3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    693       echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    694       echo "répertoires" 
    695       return;; 
    696     4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    697       echo "Action demandée non supportée : une tentative de manipulation de" 
    698       echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    699       echo "été faite ; ou une option qui est supportée par le  client  mais" 
    700       echo "pas par le serveur a été spécifiée." 
    701       return;; 
    702     10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    703       echo "Erreur dans le socket d'entrée sortie" 
    704       return;; 
    705     11) echo "Erreur de rsync ; RERR_FILEIO" 
    706       echo "Erreur d'entrée sortie fichier" 
    707       return;; 
    708     12) echo "Erreur de rsync ; RERR_STREAMIO" 
    709       echo "Erreur dans flux de donnée du protocole rsync" 
    710       return;; 
    711     13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    712       echo "Erreur avec les diagnostics du programme" 
    713       return;; 
    714     14) echo "Erreur de rsync ; RERR_IPC" 
    715       echo "Erreur dans le code IPC" 
    716       return;; 
    717     20) echo "Erreur de rsync ; RERR_SIGNAL" 
    718       echo "SIGUSR1 ou SIGINT reçu" 
    719       return;; 
    720     21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    721       echo "Une erreur retournée par waitpid()" 
    722       return;; 
    723     22) echo "Erreur de rsync ; RERR_MALLOC" 
    724       echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    725       return;; 
    726     23) echo "" 
    727       echo "Erreur fichier inexistant" 
    728       return;; 
    729     30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    730       echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    731       return;; 
    732     *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status 
    733       return;; 
    734     esac 
    735   elif [ $MYLANG = "en" ] ; then 
    736     case $status in 
    737     0)  return;; 
    738     1)  echo "rsync error : Syntax or usage error " 
    739       return;; 
    740     2)  echo "rsync error : Protocol incompatibility " 
    741       return;; 
    742     3)  echo "rsync error : Errors selecting input/output files, dirs" 
    743       return;; 
    744     4)  echo "rsync error : Requested action not supported: an attempt" 
    745       echo "was made to manipulate 64-bit files on a platform that cannot support" 
    746       echo "them; or an option was specified that is supported by the client and" 
    747       echo "not by the server." 
    748       return;; 
    749     5)  echo "rsync error : Error starting client-server protocol" 
    750       return;; 
    751     10) echo "rsync error : Error in socket I/O " 
    752       return;; 
    753     11) echo "rsync error : Error in file I/O " 
    754       return;; 
    755     12) echo "rsync error : Error in rsync protocol data stream " 
    756       return;; 
    757     13) echo "rsync error : Errors with program diagnostics " 
    758       return;; 
    759     14) echo "rsync error : Error in IPC code " 
    760       return;; 
    761     20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    762       return;; 
    763     21) echo "rsync error : Some error returned by waitpid() " 
    764       return;; 
    765     22) echo "rsync error : Error allocating core memory buffers " 
    766       return;; 
    767     23) echo "rsync error : Partial transfer due to error" 
    768       return;; 
    769     24) echo "rsync error : Partial transfer due to vanished source files" 
    770       return;; 
    771     30) echo "rsync error : Timeout in data send/receive " 
    772       return;; 
    773     *)  echo "rsync error : return code of rsync unknown :" $status 
    774       return;; 
    775     esac 
    776   else 
    777     echo "unknown language $MYLANG." 
    778     return 
    779   fi 
    780 } 
    781  
    782 #D-#================================================== 
    783 #D-function IGCM_sys_Miror_libIGCM 
    784 #D-* Purpose: Mirror libIGCM PATH and lib to frontend 
    785 #D-* Examples: 
    786 #D- 
    787 function IGCM_sys_Mirror_libIGCM { 
    788   IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    789   if ( $DEBUG_sys ) ; then 
    790     echo "IGCM_sys_Mirror_libIGCM" 
    791   fi 
    792  
    793   typeset status 
    794  
    795   mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    796  
    797   echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    798   ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    799   status=$? 
    800  
    801   if [ ${status} -gt 0 ] ; then 
    802     echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." 
    803     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    804   fi 
    805   IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    806 } 
    807  
    808 #D-#================================================== 
    809 #D-function IGCM_sys_Cp 
    810 #D-* Purpose: generic cp 
    811 #D-* Examples: 
    812 #D- 
    813 function 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 status 
    820  
    821   echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    822   \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    823   status=$? 
    824  
    825   if [ ${status} -gt 0 ] ; then 
    826     echo "IGCM_sys_Cp : error code ${status}" 
    827     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    828     IGCM_debug_Exit "IGCM_sys_Cp" 
    829   else 
    830     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    831   fi 
    832   IGCM_debug_PopStack "IGCM_sys_Cp" 
    833 } 
    834  
    835 #D-#================================================== 
    836 #D-function IGCM_sys_Rm 
    837 #D-* Purpose: generic rm 
    838 #D-* Examples: 
    839 #D- 
    840 function 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 status 
    847  
    848   echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    849   \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    850   status=$? 
    851  
    852   if [ ${status} -gt 0 ] ; then 
    853     echo "IGCM_sys_Rm : error code ${status}" 
    854     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    855     IGCM_debug_Exit "IGCM_sys_Rm" 
    856   else 
    857     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    858   fi 
    859   IGCM_debug_PopStack "IGCM_sys_Rm" 
    860 } 
    861  
    862 #D-#================================================== 
    863407#D-function IGCM_sys_RmRunDir 
    864408#D-* Purpose: rm tmpdir (dummy function most of the time batch 
     
    873417  fi 
    874418  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    875 } 
    876  
    877 #D-#================================================== 
    878 #D-function IGCM_sys_Mv 
    879 #D-* Purpose: generic move 
    880 #D-* Examples: 
    881 #D- 
    882 function IGCM_sys_Mv { 
    883   IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    884   if ( $DEBUG_sys ) ; then 
    885     echo "IGCM_sys_Mv :" $@ 
    886   fi 
    887  
    888   if [ $DRYRUN = 0 ]; then 
    889  
    890     typeset status 
    891  
    892     echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    893     \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    894     status=$? 
    895  
    896     if [ ${status} -gt 0 ] ; then 
    897       echo "IGCM_sys_Mv : error code ${status}" 
    898       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    899       IGCM_debug_Exit "IGCM_sys_Mv" 
    900     else 
    901       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    902     fi 
    903   fi 
    904   IGCM_debug_PopStack "IGCM_sys_Mv" 
    905419} 
    906420 
     
    987501 
    988502#D-#================================================== 
    989 #D-function IGCM_sys_Get_Master 
    990 #D-* Purpose: Copy a complete directory from MASTER filesystem 
    991 #D-* Examples: 
    992 #D- 
    993 function IGCM_sys_Get_Master { 
    994   IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
    995   if ( $DEBUG_sys ) ; then 
    996     echo "IGCM_sys_Get_Master :" $@ 
    997   fi 
    998   if [ $DRYRUN = 0 ]; then 
    999     if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then 
    1000       echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
    1001       IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    1002       return 
    1003     fi 
    1004  
    1005     typeset NB_ESSAI DELAI status i 
    1006     # number of tentative 
    1007     NB_ESSAI=3 
    1008     # time delay between tentative 
    1009     DELAI=2 
    1010  
    1011     i=0 
    1012     while [ $i -lt $NB_ESSAI ] ; do 
    1013       \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1014       status=$? 
    1015       if [ ${status} -gt 0 ]; then 
    1016         IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1017         IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 
    1018         sleep $DELAI 
    1019       else 
    1020         break 
    1021       fi 
    1022       (( i = i + 1 )) 
    1023     done 
    1024  
    1025     if [ ${status} -gt 0 ] ; then 
    1026       echo "IGCM_sys_Get_Master : error." 
    1027       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1028       IGCM_debug_Exit "IGCM_sys_Get_Master" 
    1029     else 
    1030       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1031     fi 
    1032   fi 
    1033   IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    1034 } 
    1035  
    1036 #==================================================== 
    1037 #- Call IGCM_sys_Mirror_libIGCM now ! 
    1038 if ( $MirrorlibIGCM ) ; then 
    1039   IGCM_sys_Mirror_libIGCM 
    1040 fi 
    1041  
    1042 #D-#================================================== 
    1043503#D-function IGCM_sys_Put_Rest 
    1044504#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
     
    1098558 
    1099559#D-#================================================== 
    1100 #D-function IGCM_sys_PutBuffer_Rest 
    1101 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
    1102 #D-           File and target directory must exist. 
    1103 #D-* Examples: 
    1104 #D- 
    1105 function IGCM_sys_PutBuffer_Rest { 
    1106   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
    1107   if ( $DEBUG_sys ) ; then 
    1108     echo "IGCM_sys_PutBuffer_Rest :" $@ 
    1109   fi 
    1110   if [ $DRYRUN = 0 ]; then 
    1111     if [ ! -f ${1} ] ; then 
    1112       echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
    1113       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1114     fi 
    1115  
    1116     typeset status 
    1117     # 
    1118     # USUAL WAY 
    1119     \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1120     status=$? 
    1121  
    1122     if [ ${status} -gt 0 ] ; then 
    1123       echo "IGCM_sys_PutBuffer_Rest : error code ${status}" 
    1124       [ -f ${2} ] && ls -l ${2} 
    1125       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1126       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1127       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1128     else 
    1129  
    1130       if [ X${JobType} = XRUN ] ; then 
    1131         [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
    1132         [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
    1133       fi 
    1134  
    1135       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1136     fi 
    1137   fi 
    1138   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    1139 } 
    1140  
    1141 #D-#================================================== 
    1142 #D-function IGCM_sys_PrepareTaredRestart 
    1143 #D-* Purpose: Prepare tared restart to be access by computing job. Identity here. 
    1144 #D-* Examples: 
    1145 #D- 
    1146 function IGCM_sys_PrepareTaredRestart { 
    1147   IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ 
    1148  
    1149   IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" 
    1150 } 
    1151  
    1152 #D-#================================================== 
    1153560#D-function IGCM_sys_Put_Out 
    1154561#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
     
    1200607 
    1201608#D-#================================================== 
    1202 #D-function IGCM_sys_PutBuffer_Out 
    1203 #D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
    1204 #D-* Examples: 
    1205 #D- 
    1206 function IGCM_sys_PutBuffer_Out { 
    1207   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
    1208   if ( $DEBUG_sys ) ; then 
    1209     echo "IGCM_sys_PutBuffer_Out :" $@ 
    1210   fi 
    1211  
    1212   typeset NB_ESSAI DELAI status i exist skip 
    1213  
    1214   # number of tentative 
    1215   NB_ESSAI=3 
    1216   # time delay between tentative 
    1217   DELAI=2 
    1218  
    1219   if [ $DRYRUN = 0 ]; then 
    1220     if [ ! -f ${1} ] ; then 
    1221       echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
    1222       IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1223       return 1 
    1224     fi 
    1225     # 
    1226     IGCM_sys_Mkdir $( dirname $2 ) 
    1227     # 
    1228  
    1229     exist=false 
    1230     skip=false 
    1231     if [ -f $2 ] ; then 
    1232       IGCM_debug_Print 1 "$2 already exist" 
    1233       exist=true 
    1234       if [ "X$( diff $1 $2 )" = X ] ; then 
    1235         IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
    1236         status=0 
    1237         skip=true 
    1238       else 
    1239         IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    1240         skip=false 
    1241       fi 
    1242     fi 
    1243     # 
    1244     if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
    1245       IGCM_sys_Chmod u+w $2 
    1246     fi 
    1247  
    1248     if [ X${skip} = Xfalse ] ; then 
    1249       i=0 
    1250       while [ $i -lt $NB_ESSAI ] ; do 
    1251         if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then 
    1252           # USUAL WAY 
    1253           \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1254           status=$? 
    1255         else 
    1256           # NOT SO USUAL WAY 
    1257           \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1258           status=$? 
    1259         fi 
    1260         if [ ${status} -gt 0 ]; then 
    1261           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1262           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 
    1263           [ -f ${2} ] && ls -l ${2} 
    1264           [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1265           sleep $DELAI 
    1266         else 
    1267           break 
    1268         fi 
    1269         (( i = i + 1 )) 
    1270       done 
    1271     fi 
    1272  
    1273     if [ ${status} -gt 0 ] ; then 
    1274       echo "IGCM_sys_PutBuffer_Out : error." 
    1275       [ -f ${2} ] && ls -l ${2} 
    1276       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1277       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1278       IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
    1279     else 
    1280  
    1281       if [ X${JobType} = XRUN ] ; then 
    1282         if [ X${3} = X ] ; then 
    1283           [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
    1284           [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
    1285         fi 
    1286       fi 
    1287  
    1288       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1289     fi 
    1290   fi 
    1291   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1292   return 0 
    1293 } 
    1294  
    1295 #D-#================================================== 
    1296609#D-function IGCM_sys_Get 
    1297610#D-* Purpose: Get a file from ${ARCHIVE} 
     
    1339652 
    1340653#D-#================================================== 
    1341 #D-function IGCM_sys_GetBuffer 
    1342 #D-* Purpose: Get a file from ${SCRATCHDIR} 
    1343 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
    1344 #D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
    1345 function IGCM_sys_GetBuffer { 
    1346   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
    1347  
    1348   typeset DEST buf_liste target file_work 
    1349   typeset NB_ESSAI DELAI status i 
    1350  
    1351   if ( $DEBUG_sys ) ; then 
    1352     echo "IGCM_sys_GetBuffer :" $@ 
    1353   fi 
    1354  
    1355   # number of tentative 
    1356   NB_ESSAI=3 
    1357   # time delay between tentative 
    1358   DELAI=2 
    1359  
    1360   if [ $DRYRUN -le 2 ]; then 
    1361     if [ X${1} = X'/l' ] ; then 
    1362       eval set +A buf_liste \${${2}} 
    1363     else 
    1364       eval set +A buf_liste ${1} 
    1365     fi 
    1366     eval DEST=\${${#}} 
    1367  
    1368     #USUAL WAY 
    1369     if [ X${1} = X'/l' ] ; then 
    1370       for target in ${buf_liste[*]} ; do 
    1371         local_file=$( basename ${target} ) 
    1372         i=0 
    1373         while [ $i -lt $NB_ESSAI ] ; do 
    1374           \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1375           status=$? 
    1376           if [ ${status} -gt 0 ]; then 
    1377             IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1378             IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
    1379             sleep $DELAI 
    1380           else 
    1381             break 
    1382           fi 
    1383           (( i = i + 1 )) 
    1384         done 
    1385         if [ ${status} -gt 0 ] ; then 
    1386           echo "IGCM_sys_Get : error" 
    1387           cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1388           \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1389           IGCM_debug_Exit "IGCM_sys_GetBuffer" 
    1390         else 
    1391           \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1392         fi 
    1393       done 
    1394     else 
    1395       i=0 
    1396       while [ $i -lt $NB_ESSAI ] ; do 
    1397         \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1398         status=$? 
    1399         if [ ${status} -gt 0 ]; then 
    1400           IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1401           IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
    1402           sleep $DELAI 
    1403         else 
    1404           break 
    1405         fi 
    1406         (( i = i + 1 )) 
    1407       done 
    1408       if [ ${status} -gt 0 ] ; then 
    1409         echo "IGCM_sys_Get : error" 
    1410         cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1411         \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1412         IGCM_debug_Exit "IGCM_sys_GetBuffer" 
    1413       else 
    1414         \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1415       fi 
    1416     fi 
    1417   fi 
    1418   IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
    1419 } 
    1420  
    1421 #D-#================================================== 
    1422 #D-function IGCM_sys_GetDate_FichWork 
    1423 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
    1424 #D-* Examples: 
    1425 #D- 
    1426 function IGCM_sys_GetDate_FichWork { 
    1427   IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1428   if ( $DEBUG_sys ) ; then 
    1429     echo "IGCM_sys_GetDate_FichWork :" $@ 
    1430   fi 
    1431  
    1432   if [ $# -ge 3 ] ; then 
    1433     mode=$3 
    1434     TimeStyle=$4 
    1435   else 
    1436     mode="default" 
    1437     TimeStyle="%Y%m%d%H%M%S" 
    1438   fi 
    1439  
    1440   typeset dateF 
    1441   set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} ) 
    1442  
    1443   case $mode in 
    1444     "default") 
    1445       eval ${2}=${dateF[5]} 
    1446       ;; 
    1447     "SplitFields") 
    1448       eval ${2}="${dateF[5]}\ ${dateF[6]}" 
    1449       ;; 
    1450   esac 
    1451  
    1452  
    1453   # donne la date filesys d'un fichier sur la machine work 
    1454   IGCM_debug_PopStack "IGCM_sys_FichWork" 
    1455 } 
    1456  
    1457 #D-#================================================== 
    1458 #D-function IGCM_sys_GetDate_FichArchive 
    1459 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE 
    1460 #D-* Examples: 
    1461 #D- 
    1462 function IGCM_sys_GetDate_FichArchive { 
    1463   IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1464   if ( $DEBUG_sys ) ; then 
    1465     echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1466   fi 
    1467   typeset dateF 
    1468   set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1469   eval ${2}=${dateF[5]} 
    1470  
    1471   IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    1472 } 
    1473  
    1474 #D-#================================================== 
    1475654#D-function IGCM_sys_GetDate_Monitoring 
    1476655#D-* Purpose: get the last year for which the monitoring has been computed 
     
    1540719  fi 
    1541720  IGCM_debug_PopStack "IGCM_sys_sync" 
    1542 } 
    1543  
    1544 #D-#================================================== 
    1545 #D-function IGCM_sys_rebuild 
    1546 #D-* Purpose: rebuild parallel files 
    1547 #D-* Examples: 
    1548 #D- 
    1549 function IGCM_sys_rebuild { 
    1550   IGCM_debug_PushStack "IGCM_sys_rebuild" $@ 
    1551   if ( $DEBUG_sys ) ; then 
    1552     echo "IGCM_sys_rebuild :" $@ 
    1553   fi 
    1554  
    1555   typeset NB_ESSAI DELAI status i firstArg 
    1556   # number of tentative 
    1557   NB_ESSAI=3 
    1558   # time delay between tentative 
    1559   DELAI=2 
    1560  
    1561   i=0 
    1562   while [ $i -lt $NB_ESSAI ] ; do 
    1563     rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1564     status=$? 
    1565     if [ ${status} -gt 0 ] ; then 
    1566       IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" 
    1567       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1568       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1569       IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    1570       firstArg=${1} 
    1571       \rm ${firstArg} 
    1572       sleep $DELAI 
    1573     else 
    1574       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1575       break 
    1576     fi 
    1577     (( i = i + 1 )) 
    1578   done 
    1579  
    1580   if [ ${status} -gt 0 ] ; then 
    1581     echo "IGCM_sys_rebuild : rebuild error code is ${status}" 
    1582     IGCM_debug_Exit "rebuild" 
    1583   fi 
    1584  
    1585   IGCM_debug_PopStack "IGCM_sys_rebuild" 
    1586 } 
    1587  
    1588 #D-#================================================== 
    1589 #D-function IGCM_sys_rebuild_station 
    1590 #D-* Purpose: rebuild parallel files describing station 
    1591 #D-* Examples: 
    1592 #D- 
    1593 function IGCM_sys_rebuild_station { 
    1594   IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@ 
    1595   typeset i list_opt file_in file_out prefix_invert list_invert 
    1596   if ( $DEBUG_sys ) ; then 
    1597     echo "IGCM_sys_rebuild_station :" $@ 
    1598   fi 
    1599   list_opt=$@ 
    1600  
    1601   # Invert Axis : t,x -> x,t 
    1602   #               t,pres,x -> x,t,pres 
    1603   # So that we can concatenate along x 
    1604   i=0 
    1605   for file_in in ${list_opt} ; do 
    1606     (( i = i + 1)) 
    1607     [ ${i} = 1 ] && file_out=${file_in} && continue 
    1608     # detect time counter and do the job only if present 
    1609     var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') 
    1610     if [ X${var_unlim} = Xtime_counter ] ; then 
    1611       prefix_invert=$( basename ${file_in} .nc ) 
    1612       IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc 
    1613       list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc 
    1614     fi 
    1615   done 
    1616  
    1617   # Concatenate 
    1618   IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc 
    1619  
    1620   # Re-ivert file 
    1621   IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} 
    1622  
    1623   # Station re-ordering is too expansive to be run within libIGCM 
    1624   # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. 
    1625   # This re-ordering must be done "in memory" by the cmorization process 
    1626   # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) 
    1627   # BEGIN reordering 
    1628  
    1629   # Only LMDZ text output contains the exact ordering of the station. 
    1630   # We isolate this in the code below: 
    1631   #  0  38  -157.5000000000000  70.98591549295774 
    1632   #  0  54  27.49999999999999   67.18309859154928 
    1633   #  0  56  -62.50000000000001  82.39436619718309 
    1634   #  0  79  12.49999999999999   78.59154929577466 
    1635   #  0  116 -165.0000000000000  76.05633802816901 
    1636   #  0  117 130.0000000000000   70.98591549295774 
    1637   #  0  118 110.0000000000000   87.46478873239437 
    1638   #  1  40  4.999999999999995   51.97183098591550 
    1639  
    1640 #  typeset iStation iProc list_opt file_in file_out prefix_invert 
    1641 #  typeset -Z4 j4 
    1642 #  typeset -Z3 j3 
    1643  
    1644 #  unset list_opt 
    1645 #  set +A list_opt $@ 
    1646  
    1647   # Filename after rebuild 
    1648 #  file_out=${list_opt[0]} 
    1649   # Prefix of output files 
    1650 #  prefix_invert=$( basename ${file_out} .nc ) 
    1651   # Number of procs 
    1652 #  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) 
    1653  
    1654 #  iProc=0 
    1655 #  while [ ${iProc} -lt ${num_proc} ] ; do 
    1656     # Array containing Station as a number 
    1657 #    unset proc_stn 
    1658 #    set +A proc_stn $( grep "iophy_mpi rank ip lon lat  $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' ) 
    1659     # Number of stations produced by processor proc 
    1660 #    stationLast=${#proc_stn[*]} 
    1661     # Proc number on 4 digits 
    1662 #    j4=${iProc} 
    1663     # Init 
    1664 #    iStation=0 
    1665 #    while [ ${iStation} -lt ${stationLast} ] ; do 
    1666       # Station number on 3 digits 
    1667 #      j3=${proc_stn[${iStation}]} 
    1668       # Extract station 
    1669       # Invert Axis : t,x -> x,t 
    1670       #               t,pres,x -> x,t,pres 
    1671       # So that we can concatenate along x 
    1672 #      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc 
    1673 #      (( iStation = iStation + 1 )) 
    1674 #    done 
    1675 #    (( iProc = iProc + 1 )) 
    1676 #  done 
    1677  
    1678   # Concatenate all station along x 
    1679 #  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc 
    1680  
    1681   # Re-invert file 
    1682 #  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} 
    1683  
    1684   # END reordering 
    1685  
    1686   IGCM_debug_PopStack "IGCM_sys_rebuild_station" 
    1687721} 
    1688722 
     
    20851119  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" 
    20861120} 
    2087  
    2088 ############################################################## 
    2089 # NCO OPERATOR 
    2090  
    2091 #D-#================================================== 
    2092 #D-function IGCM_sys_ncap2 
    2093 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry 
    2094 #D-* Examples: 
    2095 #D- 
    2096 function IGCM_sys_ncap2 { 
    2097   IGCM_debug_PushStack "IGCM_sys_ncap2" $@ 
    2098   if ( $DEBUG_sys ) ; then 
    2099     echo "IGCM_sys_ncap2 :" $@ 
    2100   fi 
    2101  
    2102   typeset NB_ESSAI DELAI status i 
    2103   # number of tentative 
    2104   NB_ESSAI=3 
    2105   # time delay between tentative 
    2106   DELAI=2 
    2107  
    2108   i=0 
    2109   while [ $i -lt $NB_ESSAI ] ; do 
    2110     ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2111     status=$? 
    2112     if [ ${status} -gt 0 ] ; then 
    2113       IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" 
    2114       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2115       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2116       IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2117       sleep $DELAI 
    2118     else 
    2119       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2120       break 
    2121     fi 
    2122     (( i = i + 1 )) 
    2123   done 
    2124  
    2125   if [ ${status} -gt 0 ] ; then 
    2126     echo "IGCM_sys_ncap2 : ncap2 error" 
    2127     IGCM_debug_Exit "ncap2" 
    2128   fi 
    2129  
    2130   IGCM_debug_PopStack "IGCM_sys_ncap2" 
    2131 } 
    2132  
    2133 #D-#================================================== 
    2134 #D-function IGCM_sys_ncatted 
    2135 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry 
    2136 #D-* Examples: 
    2137 #D- 
    2138 function IGCM_sys_ncatted { 
    2139   IGCM_debug_PushStack "IGCM_sys_ncatted" $@ 
    2140   if ( $DEBUG_sys ) ; then 
    2141     echo "IGCM_sys_ncatted :" $@ 
    2142   fi 
    2143  
    2144   typeset NB_ESSAI DELAI status i 
    2145   # number of tentative 
    2146   NB_ESSAI=3 
    2147   # time delay between tentative 
    2148   DELAI=2 
    2149  
    2150   i=0 
    2151   while [ $i -lt $NB_ESSAI ] ; do 
    2152     ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2153     status=$? 
    2154     if [ ${status} -gt 0 ] ; then 
    2155       IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" 
    2156       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2157       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2158       IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2159       sleep $DELAI 
    2160     else 
    2161       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2162       break 
    2163     fi 
    2164     (( i = i + 1 )) 
    2165   done 
    2166  
    2167   if [ ${status} -gt 0 ] ; then 
    2168     echo "IGCM_sys_ncatted : ncatted error" 
    2169     IGCM_debug_Exit "ncatted" 
    2170   fi 
    2171  
    2172   IGCM_debug_PopStack "IGCM_sys_ncatted" 
    2173 } 
    2174  
    2175 #D-#================================================== 
    2176 #D-function IGCM_sys_ncbo 
    2177 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry 
    2178 #D-* Examples: 
    2179 #D- 
    2180 function IGCM_sys_ncbo { 
    2181   IGCM_debug_PushStack "IGCM_sys_ncbo" $@ 
    2182   if ( $DEBUG_sys ) ; then 
    2183     echo "IGCM_sys_ncbo :" $@ 
    2184   fi 
    2185  
    2186   typeset NB_ESSAI DELAI status i 
    2187   # number of tentative 
    2188   NB_ESSAI=3 
    2189   # time delay between tentative 
    2190   DELAI=2 
    2191  
    2192   i=0 
    2193   while [ $i -lt $NB_ESSAI ] ; do 
    2194     ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2195     status=$? 
    2196     if [ ${status} -gt 0 ] ; then 
    2197       IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" 
    2198       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2199       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2200       IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2201       sleep $DELAI 
    2202     else 
    2203       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2204       break 
    2205     fi 
    2206     (( i = i + 1 )) 
    2207   done 
    2208  
    2209   if [ ${status} -gt 0 ] ; then 
    2210     echo "IGCM_sys_ncbo : ncbo error" 
    2211     IGCM_debug_Exit "ncbo" 
    2212   fi 
    2213  
    2214   IGCM_debug_PopStack "IGCM_sys_ncbo" 
    2215 } 
    2216  
    2217 #D-#================================================== 
    2218 #D-function IGCM_sys_ncdif 
    2219 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry 
    2220 #D-* Examples: 
    2221 #D- 
    2222 function IGCM_sys_ncdiff { 
    2223   IGCM_debug_PushStack "IGCM_sys_ncdiff" $@ 
    2224   if ( $DEBUG_sys ) ; then 
    2225     echo "IGCM_sys_ncdiff :" $@ 
    2226   fi 
    2227  
    2228   typeset NB_ESSAI DELAI status i 
    2229   # number of tentative 
    2230   NB_ESSAI=3 
    2231   # time delay between tentative 
    2232   DELAI=2 
    2233  
    2234   i=0 
    2235   while [ $i -lt $NB_ESSAI ] ; do 
    2236     ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2237     status=$? 
    2238     if [ ${status} -gt 0 ] ; then 
    2239       IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" 
    2240       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2241       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2242       IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2243       sleep $DELAI 
    2244     else 
    2245       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2246       break 
    2247     fi 
    2248     (( i = i + 1 )) 
    2249   done 
    2250  
    2251   if [ ${status} -gt 0 ] ; then 
    2252     echo "IGCM_sys_ncdiff : ncdiff error" 
    2253     IGCM_debug_Exit "ncdiff" 
    2254   fi 
    2255  
    2256   IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    2257 } 
    2258  
    2259 #D-#================================================== 
    2260 #D-function IGCM_sys_ncea 
    2261 #D-* Purpose: encapsulate ncea call so as to manage error code and retry 
    2262 #D-* Examples: 
    2263 #D- 
    2264 function IGCM_sys_ncea { 
    2265   IGCM_debug_PushStack "IGCM_sys_ncea" $@ 
    2266   if ( $DEBUG_sys ) ; then 
    2267     echo "IGCM_sys_ncea :" $@ 
    2268   fi 
    2269  
    2270   typeset NB_ESSAI DELAI status i 
    2271   # number of tentative 
    2272   NB_ESSAI=3 
    2273   # time delay between tentative 
    2274   DELAI=2 
    2275  
    2276   i=0 
    2277   while [ $i -lt $NB_ESSAI ] ; do 
    2278     ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2279     status=$? 
    2280     if [ ${status} -gt 0 ] ; then 
    2281       IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" 
    2282       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2283       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2284       IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2285       sleep $DELAI 
    2286     else 
    2287       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2288       break 
    2289     fi 
    2290     (( i = i + 1 )) 
    2291   done 
    2292  
    2293   if [ ${status} -gt 0 ] ; then 
    2294     echo "IGCM_sys_ncea : ncea error" 
    2295     IGCM_debug_Exit "ncea" 
    2296   fi 
    2297  
    2298   IGCM_debug_PopStack "IGCM_sys_ncea" 
    2299 } 
    2300  
    2301 #D-#================================================== 
    2302 #D-function IGCM_sys_ncecat 
    2303 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry 
    2304 #D-* Examples: 
    2305 #D- 
    2306 function IGCM_sys_ncecat { 
    2307   IGCM_debug_PushStack "IGCM_sys_ncecat" $@ 
    2308   if ( $DEBUG_sys ) ; then 
    2309     echo "IGCM_sys_ncecat :" $@ 
    2310   fi 
    2311  
    2312   typeset NB_ESSAI DELAI status i 
    2313   # number of tentative 
    2314   NB_ESSAI=3 
    2315   # time delay between tentative 
    2316   DELAI=2 
    2317  
    2318   i=0 
    2319   while [ $i -lt $NB_ESSAI ] ; do 
    2320     ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2321     status=$? 
    2322     if [ ${status} -gt 0 ] ; then 
    2323       IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" 
    2324       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2325       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2326       IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2327       sleep $DELAI 
    2328     else 
    2329       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2330       break 
    2331     fi 
    2332     (( i = i + 1 )) 
    2333   done 
    2334  
    2335   if [ ${status} -gt 0 ] ; then 
    2336     echo "IGCM_sys_ncecat : ncecat error" 
    2337     IGCM_debug_Exit "ncecat" 
    2338   fi 
    2339  
    2340   IGCM_debug_PopStack "IGCM_sys_ncecat" 
    2341 } 
    2342  
    2343 #D-#================================================== 
    2344 #D-function IGCM_sys_ncflint 
    2345 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry 
    2346 #D-* Examples: 
    2347 #D- 
    2348 function IGCM_sys_ncflint { 
    2349   IGCM_debug_PushStack "IGCM_sys_ncflint" $@ 
    2350   if ( $DEBUG_sys ) ; then 
    2351     echo "IGCM_sys_ncflint :" $@ 
    2352   fi 
    2353  
    2354   typeset NB_ESSAI DELAI status i 
    2355   # number of tentative 
    2356   NB_ESSAI=3 
    2357   # time delay between tentative 
    2358   DELAI=2 
    2359  
    2360   i=0 
    2361   while [ $i -lt $NB_ESSAI ] ; do 
    2362     ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2363     status=$? 
    2364     if [ ${status} -gt 0 ] ; then 
    2365       IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" 
    2366       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2367       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2368       IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2369       sleep $DELAI 
    2370     else 
    2371       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2372       break 
    2373     fi 
    2374     (( i = i + 1 )) 
    2375   done 
    2376  
    2377   if [ ${status} -gt 0 ] ; then 
    2378     echo "IGCM_sys_ncflint : ncflint error" 
    2379     IGCM_debug_Exit "ncflint" 
    2380   fi 
    2381  
    2382   IGCM_debug_PopStack "IGCM_sys_ncflint" 
    2383 } 
    2384  
    2385 #D-#================================================== 
    2386 #D-function IGCM_sys_ncks 
    2387 #D-* Purpose: encapsulate ncks call so as to manage error code and retry 
    2388 #D-* Examples: 
    2389 #D- 
    2390 function IGCM_sys_ncks { 
    2391   IGCM_debug_PushStack "IGCM_sys_ncks" $@ 
    2392   if ( $DEBUG_sys ) ; then 
    2393     echo "IGCM_sys_ncks :" $@ 
    2394   fi 
    2395  
    2396   typeset NB_ESSAI DELAI status i 
    2397   # number of tentative 
    2398   NB_ESSAI=3 
    2399   # time delay between tentative 
    2400   DELAI=2 
    2401  
    2402   i=0 
    2403   while [ $i -lt $NB_ESSAI ] ; do 
    2404     ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2405     status=$? 
    2406     if [ ${status} -gt 0 ] ; then 
    2407       IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" 
    2408       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2409       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2410       IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2411       sleep $DELAI 
    2412     else 
    2413       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2414       break 
    2415     fi 
    2416     (( i = i + 1 )) 
    2417   done 
    2418  
    2419   if [ ${status} -gt 0 ] ; then 
    2420     echo "IGCM_sys_ncks : ncks error" 
    2421     IGCM_debug_Exit "ncks" 
    2422   fi 
    2423  
    2424   IGCM_debug_PopStack "IGCM_sys_ncks" 
    2425 } 
    2426  
    2427 #D-#================================================== 
    2428 #D-function IGCM_sys_ncpdq 
    2429 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry 
    2430 #D-* Examples: 
    2431 #D- 
    2432 function IGCM_sys_ncpdq { 
    2433   IGCM_debug_PushStack "IGCM_sys_ncpdq" $@ 
    2434   if ( $DEBUG_sys ) ; then 
    2435     echo "IGCM_sys_ncpdq :" $@ 
    2436   fi 
    2437  
    2438   typeset NB_ESSAI DELAI status i 
    2439   # number of tentative 
    2440   NB_ESSAI=3 
    2441   # time delay between tentative 
    2442   DELAI=2 
    2443  
    2444   i=0 
    2445   while [ $i -lt $NB_ESSAI ] ; do 
    2446     ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2447     status=$? 
    2448     if [ ${status} -gt 0 ] ; then 
    2449       IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" 
    2450       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2451       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2452       IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2453       sleep $DELAI 
    2454     else 
    2455       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2456       break 
    2457     fi 
    2458     (( i = i + 1 )) 
    2459   done 
    2460  
    2461   if [ ${status} -gt 0 ] ; then 
    2462     echo "IGCM_sys_ncpdq : ncpdq error" 
    2463     IGCM_debug_Exit "ncpdq" 
    2464   fi 
    2465  
    2466   IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    2467 } 
    2468  
    2469 #D-#================================================== 
    2470 #D-function IGCM_sys_ncra 
    2471 #D-* Purpose: encapsulate ncra call so as to manage error code and retry 
    2472 #D-* Examples: 
    2473 #D- 
    2474 function IGCM_sys_ncra { 
    2475   IGCM_debug_PushStack "IGCM_sys_ncra" $@ 
    2476   if ( $DEBUG_sys ) ; then 
    2477     echo "IGCM_sys_ncra :" $@ 
    2478   fi 
    2479  
    2480   typeset NB_ESSAI DELAI status i 
    2481   # number of tentative 
    2482   NB_ESSAI=3 
    2483   # time delay between tentative 
    2484   DELAI=2 
    2485  
    2486   i=0 
    2487   while [ $i -lt $NB_ESSAI ] ; do 
    2488     ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2489     status=$? 
    2490     if [ ${status} -gt 0 ] ; then 
    2491       IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" 
    2492       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2493       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2494       IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2495       sleep $DELAI 
    2496     else 
    2497       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2498       break 
    2499     fi 
    2500     (( i = i + 1 )) 
    2501   done 
    2502  
    2503   if [ ${status} -gt 0 ] ; then 
    2504     echo "IGCM_sys_ncra : ncra error" 
    2505     IGCM_debug_Exit "ncra" 
    2506   fi 
    2507  
    2508   IGCM_debug_PopStack "IGCM_sys_ncra" 
    2509 } 
    2510  
    2511 #D-#================================================== 
    2512 #D-function IGCM_sys_ncrcat 
    2513 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry 
    2514 #D-* Examples: 
    2515 #D- 
    2516 function IGCM_sys_ncrcat { 
    2517   IGCM_debug_PushStack "IGCM_sys_ncrcat" $@ 
    2518   if ( $DEBUG_sys ) ; then 
    2519     echo "IGCM_sys_ncrcat :" $@ 
    2520   fi 
    2521  
    2522   typeset NB_ESSAI DELAI status i lastArg 
    2523   # number of tentative 
    2524   NB_ESSAI=3 
    2525   # time delay between tentative 
    2526   DELAI=2 
    2527  
    2528   i=0 
    2529   while [ $i -lt $NB_ESSAI ] ; do 
    2530     ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2531     status=$? 
    2532     if [ ${status} -gt 0 ] ; then 
    2533       IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" 
    2534       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2535       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2536       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2537       sleep $DELAI 
    2538     elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then 
    2539       IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" 
    2540       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2541       # remove files having corrupted time axis 
    2542       eval lastArg=\${$#} 
    2543       IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" 
    2544       \rm ${lastArg} 
    2545       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2546       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2547       sleep $DELAI 
    2548     else 
    2549       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2550       break 
    2551     fi 
    2552     (( i = i + 1 )) 
    2553   done 
    2554  
    2555   if [ ${status} -gt 0 ] ; then 
    2556     echo "IGCM_sys_ncrcat : ncrcat error" 
    2557     #IGCM_debug_Exit "ncrcat" 
    2558   fi 
    2559  
    2560   IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    2561 } 
    2562  
    2563 #D-#================================================== 
    2564 #D-function IGCM_sys_ncrename 
    2565 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry 
    2566 #D-* Examples: 
    2567 #D- 
    2568 function IGCM_sys_ncrename { 
    2569   IGCM_debug_PushStack "IGCM_sys_ncrename" $@ 
    2570   if ( $DEBUG_sys ) ; then 
    2571     echo "IGCM_sys_ncrename :" $@ 
    2572   fi 
    2573  
    2574   typeset NB_ESSAI DELAI status i 
    2575   # number of tentative 
    2576   NB_ESSAI=3 
    2577   # time delay between tentative 
    2578   DELAI=2 
    2579  
    2580   i=0 
    2581   while [ $i -lt $NB_ESSAI ] ; do 
    2582     ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2583     status=$? 
    2584     if [ ${status} -gt 0 ] ; then 
    2585       IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" 
    2586       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2587       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2588       IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2589       sleep $DELAI 
    2590     else 
    2591       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2592       break 
    2593     fi 
    2594     (( i = i + 1 )) 
    2595   done 
    2596  
    2597   if [ ${status} -gt 0 ] ; then 
    2598     echo "IGCM_sys_ncrename : ncrename error" 
    2599     IGCM_debug_Exit "ncrename" 
    2600   fi 
    2601  
    2602   IGCM_debug_PopStack "IGCM_sys_ncrename" 
    2603 } 
    2604  
    2605 #D-#================================================== 
    2606 #D-function IGCM_sys_ncwa 
    2607 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry 
    2608 #D-* Examples: 
    2609 #D- 
    2610 function IGCM_sys_ncwa { 
    2611   IGCM_debug_PushStack "IGCM_sys_ncwa" $@ 
    2612   if ( $DEBUG_sys ) ; then 
    2613     echo "IGCM_sys_ncwa :" $@ 
    2614   fi 
    2615  
    2616   typeset NB_ESSAI DELAI status i 
    2617   # number of tentative 
    2618   NB_ESSAI=3 
    2619   # time delay between tentative 
    2620   DELAI=2 
    2621  
    2622   i=0 
    2623   while [ $i -lt $NB_ESSAI ] ; do 
    2624     ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2625     status=$? 
    2626     if [ ${status} -gt 0 ] ; then 
    2627       IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" 
    2628       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2629       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2630       IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2631       sleep $DELAI 
    2632     else 
    2633       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2634       break 
    2635     fi 
    2636     (( i = i + 1 )) 
    2637   done 
    2638  
    2639   if [ ${status} -gt 0 ] ; then 
    2640     echo "IGCM_sys_ncwa : ncwa error" 
    2641     IGCM_debug_Exit "ncwa" 
    2642   fi 
    2643  
    2644   IGCM_debug_PopStack "IGCM_sys_ncwa" 
    2645 } 
    2646  
    2647 ############################################################## 
    2648 # CDO OPERATOR 
    2649  
    2650 #D-#================================================== 
    2651 #D-function IGCM_sys_cdo 
    2652 #D-* Purpose: encapsulate cdo call so as to manage error code and retry 
    2653 #D-* Examples: 
    2654 #D- 
    2655 function IGCM_sys_cdo { 
    2656   IGCM_debug_PushStack "IGCM_sys_cdo" $@ 
    2657   if ( $DEBUG_sys ) ; then 
    2658     echo "IGCM_sys_cdo :" $@ 
    2659   fi 
    2660  
    2661   typeset status 
    2662  
    2663   \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2664   status=$? 
    2665   if [ ${status} -gt 0 ] ; then 
    2666     echo "IGCM_sys_cdo : error code ${status}" 
    2667     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2668     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2669     IGCM_debug_PopStack "IGCM_sys_cdo" 
    2670     return 1 
    2671   else 
    2672     IGCM_debug_PopStack "IGCM_sys_cdo" 
    2673     return 0 
    2674   fi 
    2675  
    2676   IGCM_debug_PopStack "IGCM_sys_cdo" 
    2677 } 
Note: See TracChangeset for help on using the changeset viewer.