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_iitm.ksh

    r1180 r1181  
    205205 
    206206#D-#================================================== 
    207 #D-function IGCM_sys_RshMaster 
    208 #D-* Purpose: Connection to frontend machine. 
    209 #D-* Examples: 
    210 #D- 
    211 function IGCM_sys_RshMaster { 
    212   IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    213   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF 
    214     export libIGCM=${libIGCM} 
    215     export DEBUG_debug=${DEBUG_debug} 
    216     . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
    217     . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
    218     ${@} 
    219 EOF 
    220   if [ $? -gt 0 ] ; then 
    221     echo "IGCM_sys_RshMaster : erreur." 
    222     IGCM_debug_Exit "IGCM_sys_RshMaster" 
    223   fi 
    224   IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    225 } 
    226  
    227 #D-#================================================== 
    228207#D-function IGCM_sys_RshArchive 
    229208#D-* Purpose: Archive rsh command 
     
    258237 
    259238#D-#================================================== 
    260 #D-function IGCM_sys_RshPost 
    261 #D-* Purpose: Post-process rsh command 
    262 #D-* Examples: 
    263 #D- 
    264 function IGCM_sys_RshPost { 
    265   IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    266   if ( $DEBUG_sys ) ; then 
    267     echo "IGCM_sys_RshPost :" $@ 
    268   fi 
    269   # keep standard input (stdin) for the loop onto temporary file 
    270   cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    271  
    272   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    273   if [ $? -gt 0 ] ; then 
    274     echo "IGCM_sys_RshPost : erreur." 
    275     IGCM_debug_Exit "IGCM_sys_RshPost" 
    276   fi 
    277   # delete temporary file 
    278   \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    279  
    280   IGCM_debug_PopStack "IGCM_sys_RshPost" 
    281 } 
    282  
    283 #D-#================================================== 
    284 #D-function IGCM_sys_SendMail 
    285 #D-* Purpose: Send mail when simulation is over 
    286 #D-* Examples: 
    287 #D- 
    288 function IGCM_sys_SendMail { 
    289   IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    290   if ( $DEBUG_sys ) ; then 
    291     echo "IGCM_sys_SendMail :" $@ 
    292   fi 
    293  
    294   if [ X${1} = XAccounting ] ; then 
    295     status=Accounting 
    296     mailText=jobAccounting.mail 
    297   elif ( ${ExitFlag} ) ; then 
    298     status=failed 
    299     mailText=jobEnd.mail 
    300   else 
    301     status=completed 
    302     mailText=jobEnd.mail 
    303   fi 
    304  
    305   # Update selected mail template 
    306   while read -r line; do 
    307     eval echo $line >> mail.txt ; 
    308   done < ${libIGCM}/libIGCM_sys/${mailText} 
    309  
    310   if [ ! -z ${config_UserChoices_MailName} ] ; then 
    311     mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt 
    312   elif [ -f ~/.forward ] ; then 
    313     mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt 
    314   else 
    315     mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt 
    316   fi 
    317  
    318   sleep 10 
    319   rm -f mail.txt 
    320  
    321   IGCM_debug_PopStack "IGCM_sys_SendMail" 
    322 } 
    323  
    324 #D-#================================================== 
    325 #D-function IGCM_sys_Mkdir 
    326 #D-* Purpose: Master locale mkdir command 
    327 #D-* Examples: 
    328 #D- 
    329 function IGCM_sys_Mkdir { 
    330   IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    331   if ( $DEBUG_sys ) ; then 
    332     echo "IGCM_sys_Mkdir :" $@ 
    333   fi 
    334   if [ ! -d ${1} ]; then 
    335     \mkdir -p $1 
    336     if [ $? -gt 0 ] ; then 
    337       echo "IGCM_sys_Mkdir : erreur." 
    338       IGCM_debug_Exit "IGCM_sys_Mkdir" 
    339     fi 
    340   fi 
    341   # vérification : 
    342   if [ ! -d ${1} ] ; then 
    343     echo "IGCM_sys_Mkdir : erreur." 
    344     IGCM_debug_Exit "IGCM_sys_Mkdir" 
    345   fi 
    346   IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    347 } 
    348  
    349 #D-#================================================== 
    350239#D-function IGCM_sys_MkdirArchive 
    351240#D-* Purpose: Mkdir on Archive 
     
    368257  fi 
    369258  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    370 } 
    371  
    372 #D-#================================================== 
    373 #D-function IGCM_sys_MkdirWork 
    374 #D-* Purpose: Mkdir on Work 
    375 #D-* Examples: 
    376 #D- 
    377 function IGCM_sys_MkdirWork { 
    378   IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    379   if ( $DEBUG_sys ) ; then 
    380     echo "IGCM_sys_MkdirWork :" $@ 
    381   fi 
    382   #- creation de repertoire sur le serveur fichier 
    383   if [ ! -d ${1} ]; then 
    384     \mkdir -p $1 
    385     if [ $? -gt 0 ] ; then 
    386       echo "IGCM_sys_MkdirWork : erreur." 
    387       IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    388     fi 
    389   fi 
    390   IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    391 } 
    392  
    393 #D-#================================================== 
    394 #D-function IGCM_sys_Cd 
    395 #D-* Purpose: master cd command 
    396 #D-* Examples: 
    397 #D- 
    398 function IGCM_sys_Cd { 
    399   IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    400   if ( $DEBUG_sys ) ; then 
    401     echo "IGCM_sys_Cd :" $@ 
    402   fi 
    403   \cd $1 
    404   if [ $? -gt 0 ] ; then 
    405     echo "IGCM_sys_Cd : erreur." 
    406     IGCM_debug_Exit "IGCM_sys_Cd" 
    407   fi 
    408   IGCM_debug_PopStack "IGCM_sys_Cd" 
    409 } 
    410  
    411 #D-#================================================== 
    412 #D-function IGCM_sys_Chmod 
    413 #D-* Purpose: Chmod 
    414 #D-* Examples: 
    415 #D- 
    416 function IGCM_sys_Chmod { 
    417   IGCM_debug_PushStack "IGCM_sys_Chmod" $@ 
    418   if ( $DEBUG_sys ) ; then 
    419     echo "IGCM_sys_Chmod :" $@ 
    420   fi 
    421   \chmod $@ 
    422   if [ $? -gt 0 ] ; then 
    423     echo "IGCM_sys_Chmod : erreur." 
    424     IGCM_debug_Exit "IGCM_sys_Chmod" 
    425   fi 
    426   IGCM_debug_PopStack "IGCM_sys_Chmod" 
    427 } 
    428  
    429 #D-#================================================== 
    430 #D-function IGCM_sys_FileSize 
    431 #D-* Purpose: Filesize 
    432 #D-* Examples: 
    433 #D- 
    434 function IGCM_sys_FileSize { 
    435   IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    436  
    437   typeset sizeF 
    438   set +A sizeF -- $( ls -la ${1} ) 
    439   if [ $? -gt 0 ] ; then 
    440     IGCM_debug_Exit "IGCM_sys_FileSize" 
    441   fi 
    442   eval ${2}=${sizeF[4]} 
    443  
    444   IGCM_debug_PopStack "IGCM_sys_FileSize" 
    445 } 
    446  
    447 #D-#================================================== 
    448 #D-function IGCM_sys_TestDir 
    449 #D-* Purpose: Test Directory that must exists 
    450 #D-* Examples: 
    451 #D- 
    452 function IGCM_sys_TestDir { 
    453   IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    454   if ( $DEBUG_sys ) ; then 
    455     echo "IGCM_sys_TestDir :" $@ 
    456   fi 
    457   typeset ExistFlag 
    458   ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    459   IGCM_debug_PopStack "IGCM_sys_TestDir" 
    460  
    461   return ${ExistFlag} 
    462259} 
    463260 
     
    505302  ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) 
    506303  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    507  
    508   return ${ExistFlag} 
    509 } 
    510  
    511 #D-#================================================== 
    512 #D-function IGCM_sys_TestFileBuffer 
    513 #D-* Purpose: Test file that must NOT EXISTS on Buffer 
    514 #D-* Examples: 
    515 #D- 
    516 function IGCM_sys_TestFileBuffer { 
    517   IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
    518   typeset ExistFlag 
    519   ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    520   IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
    521304 
    522305  return ${ExistFlag} 
     
    546329 
    547330#D-#================================================== 
    548 #D-function IGCM_sys_CountFileBuffer 
    549 #D-* Purpose: Count files on Scratch filesystem 
    550 #D-* Examples: 
    551 #D- 
    552 function IGCM_sys_CountFileBuffer { 
    553   IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
    554   ls ${@} 2>/dev/null | wc -l 
    555   if [ $? -gt 0 ] ; then 
    556     echo "IGCM_sys_CountFileBuffer : erreur." 
    557   fi 
    558   IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    559 } 
    560  
    561 #D-#================================================== 
    562 #D-function IGCM_sys_Tree 
    563 #D-* Purpose: Tree directories with files on ${ARCHIVE} 
    564 #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT} 
    565 #D- 
    566 function IGCM_sys_Tree { 
    567   IGCM_debug_PushStack "IGCM_sys_Tree" $@ 
    568   if ( $DEBUG_sys ) ; then 
    569     echo "IGCM_sys_Tree :" $@ 
    570   fi 
    571  
    572   \tree -f $@ 
    573  
    574   IGCM_debug_PopStack "IGCM_sys_Tree" 
    575 } 
    576  
    577 #D-#================================================== 
    578 #D-function IGCM_sys_Tar 
    579 #D-* Purpose: master tar command 
    580 #D-* Examples: 
    581 #D- 
    582 function IGCM_sys_Tar { 
    583   IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    584   if ( $DEBUG_sys ) ; then 
    585     echo "IGCM_sys_Tar :" $@ 
    586   fi 
    587   \tar cf $@ 
    588   if [ $? -gt 0 ] ; then 
    589     echo "IGCM_sys_Tar : erreur." 
    590     IGCM_debug_Exit "IGCM_sys_Tar" 
    591   fi 
    592   IGCM_debug_PopStack "IGCM_sys_Tar" 
    593 } 
    594  
    595 #D-#================================================== 
    596 #D-function IGCM_sys_UnTar 
    597 #D-* Purpose: master un-tar command 
    598 #D-* Examples: 
    599 #D- 
    600 function IGCM_sys_UnTar { 
    601   IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    602   if ( $DEBUG_sys ) ; then 
    603     echo "IGCM_sys_UnTar :" $@ 
    604   fi 
    605   \tar xvf $1 
    606   if [ $? -gt 0 ] ; then 
    607     echo "IGCM_sys_UnTar : erreur." 
    608     IGCM_debug_Exit "IGCM_sys_UnTar" 
    609   fi 
    610   IGCM_debug_PopStack "IGCM_sys_UnTar" 
    611 } 
    612  
    613 #D-#================================================== 
    614331#D-function IGCM_sys_Qsub 
    615332#D-* Purpose: Qsub new job 
     
    683400 
    684401#D-#================================================== 
    685 #D-function IGCM_sys_Rsync_out 
    686 #D-* Purpose: treat return val of rsync 
    687 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync 
    688 #D-  Error values and explanations can depend on your system version. 
    689 function IGCM_sys_Rsync_out { 
    690   status=$1 
    691   if [ ! $status ] ; then 
    692     echo "rsync error !" 
    693   fi 
    694  
    695   if [ $MYLANG = "fr" ]; then 
    696     case $status in 
    697     0)  return ;; 
    698     1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    699       echo "Erreur de syntaxe ou d'utilisation." 
    700       return;; 
    701     2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    702       echo "Incompatibilité de protocole." 
    703       return;; 
    704     3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    705       echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    706       echo "répertoires" 
    707       return;; 
    708     4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    709       echo "Action demandée non supportée : une tentative de manipulation de" 
    710       echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    711       echo "été faite ; ou une option qui est supportée par le  client  mais" 
    712       echo "pas par le serveur a été spécifiée." 
    713       return;; 
    714     10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    715       echo "Erreur dans le socket d'entrée sortie" 
    716       return;; 
    717     11) echo "Erreur de rsync ; RERR_FILEIO" 
    718       echo "Erreur d'entrée sortie fichier" 
    719       return;; 
    720     12) echo "Erreur de rsync ; RERR_STREAMIO" 
    721       echo "Erreur dans flux de donnée du protocole rsync" 
    722       return;; 
    723     13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    724       echo "Erreur avec les diagnostics du programme" 
    725       return;; 
    726     14) echo "Erreur de rsync ; RERR_IPC" 
    727       echo "Erreur dans le code IPC" 
    728       return;; 
    729     20) echo "Erreur de rsync ; RERR_SIGNAL" 
    730       echo "SIGUSR1 ou SIGINT reçu" 
    731       return;; 
    732     21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    733       echo "Une erreur retournée par waitpid()" 
    734       return;; 
    735     22) echo "Erreur de rsync ; RERR_MALLOC" 
    736       echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    737       return;; 
    738     23) echo "" 
    739       echo "Erreur fichier inexistant" 
    740       return;; 
    741     30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    742       echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    743       return;; 
    744     *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status 
    745       return;; 
    746     esac 
    747   elif [ $MYLANG = "en" ] ; then 
    748     case $status in 
    749     0)  return;; 
    750     1)  echo "rsync error : Syntax or usage error " 
    751       return;; 
    752     2)  echo "rsync error : Protocol incompatibility " 
    753       return;; 
    754     3)  echo "rsync error : Errors selecting input/output files, dirs" 
    755       return;; 
    756     4)  echo "rsync error : Requested action not supported: an attempt" 
    757       echo "was made to manipulate 64-bit files on a platform that cannot support" 
    758       echo "them; or an option was specified that is supported by the client and" 
    759       echo "not by the server." 
    760       return;; 
    761     5)  echo "rsync error : Error starting client-server protocol" 
    762       return;; 
    763     10) echo "rsync error : Error in socket I/O " 
    764       return;; 
    765     11) echo "rsync error : Error in file I/O " 
    766       return;; 
    767     12) echo "rsync error : Error in rsync protocol data stream " 
    768       return;; 
    769     13) echo "rsync error : Errors with program diagnostics " 
    770       return;; 
    771     14) echo "rsync error : Error in IPC code " 
    772       return;; 
    773     20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    774       return;; 
    775     21) echo "rsync error : Some error returned by waitpid() " 
    776       return;; 
    777     22) echo "rsync error : Error allocating core memory buffers " 
    778       return;; 
    779     23) echo "rsync error : Partial transfer due to error" 
    780       return;; 
    781     24) echo "rsync error : Partial transfer due to vanished source files" 
    782       return;; 
    783     30) echo "rsync error : Timeout in data send/receive " 
    784       return;; 
    785     *)  echo "rsync error : return code of rsync unknown :" $status 
    786       return;; 
    787     esac 
    788   else 
    789     echo "unknown language $MYLANG." 
    790     return 
    791   fi 
    792 } 
    793  
    794 #D-#================================================== 
    795 #D-function IGCM_sys_Miror_libIGCM 
    796 #D-* Purpose: Mirror libIGCM PATH and lib to frontend 
    797 #D-* Examples: 
    798 #D- 
    799 function IGCM_sys_Mirror_libIGCM { 
    800   IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    801   if ( $DEBUG_sys ) ; then 
    802     echo "IGCM_sys_Mirror_libIGCM" 
    803   fi 
    804  
    805   typeset status 
    806  
    807   mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    808  
    809   echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    810   ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    811   status=$? 
    812  
    813   if [ ${status} -gt 0 ] ; then 
    814     echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." 
    815     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    816   fi 
    817   IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    818 } 
    819  
    820 #D-#================================================== 
    821 #D-function IGCM_sys_Cp 
    822 #D-* Purpose: generic cp 
    823 #D-* Examples: 
    824 #D- 
    825 function IGCM_sys_Cp { 
    826   IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    827   if ( $DEBUG_sys ) ; then 
    828     echo "IGCM_sys_Cp :" $@ 
    829   fi 
    830  
    831   typeset status 
    832  
    833   echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    834   \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    835   status=$? 
    836  
    837   if [ ${status} -gt 0 ] ; then 
    838     echo "IGCM_sys_Cp : error code ${status}" 
    839     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    840     IGCM_debug_Exit "IGCM_sys_Cp" 
    841   else 
    842     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    843   fi 
    844   IGCM_debug_PopStack "IGCM_sys_Cp" 
    845 } 
    846  
    847 #D-#================================================== 
    848 #D-function IGCM_sys_Rm 
    849 #D-* Purpose: generic rm 
    850 #D-* Examples: 
    851 #D- 
    852 function IGCM_sys_Rm { 
    853   IGCM_debug_PushStack "IGCM_sys_Rm" $@ 
    854   if ( $DEBUG_sys ) ; then 
    855     echo "IGCM_sys_Rm :" $@ 
    856   fi 
    857  
    858   typeset status 
    859  
    860   echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    861   \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    862   status=$? 
    863  
    864   if [ ${status} -gt 0 ] ; then 
    865     echo "IGCM_sys_Rm : error code ${status}" 
    866     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    867     IGCM_debug_Exit "IGCM_sys_Rm" 
    868   else 
    869     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    870   fi 
    871   IGCM_debug_PopStack "IGCM_sys_Rm" 
    872 } 
    873  
    874 #D-#================================================== 
    875402#D-function IGCM_sys_RmRunDir 
    876403#D-* Purpose: rm tmpdir (dummy function most of the time batch 
     
    901428 
    902429#D-#================================================== 
    903 #D-function IGCM_sys_Mv 
    904 #D-* Purpose: generic move 
    905 #D-* Examples: 
    906 #D- 
    907 function IGCM_sys_Mv { 
    908   IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    909   if ( $DEBUG_sys ) ; then 
    910     echo "IGCM_sys_Mv :" $@ 
    911   fi 
    912  
    913   if [ $DRYRUN = 0 ]; then 
    914  
    915     typeset status 
    916  
    917     echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    918     \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    919     status=$? 
    920  
    921     if [ ${status} -gt 0 ] ; then 
    922       echo "IGCM_sys_Mv : error code ${status}" 
    923       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    924       IGCM_debug_Exit "IGCM_sys_Mv" 
    925     else 
    926       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    927     fi 
    928   fi 
    929   IGCM_debug_PopStack "IGCM_sys_Mv" 
    930 } 
    931  
    932 #D-#================================================== 
    933430#D-function IGCM_sys_Put_Dir 
    934431#D-* Purpose: Copy a complete directory on $(ARCHIVE) 
     
    1000497  IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    1001498} 
    1002  
    1003 #D-#================================================== 
    1004 #D-function IGCM_sys_Get_Master 
    1005 #D-* Purpose: Copy a complete directory from MASTER filesystem 
    1006 #D-* Examples: 
    1007 #D- 
    1008 function IGCM_sys_Get_Master { 
    1009   IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
    1010   if ( $DEBUG_sys ) ; then 
    1011     echo "IGCM_sys_Get_Master :" $@ 
    1012   fi 
    1013   if [ $DRYRUN = 0 ]; then 
    1014     if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then 
    1015       echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
    1016       IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    1017       return 
    1018     fi 
    1019  
    1020     typeset NB_ESSAI DELAI status i 
    1021     # number of tentative 
    1022     NB_ESSAI=3 
    1023     # time delay between tentative 
    1024     DELAI=2 
    1025  
    1026     i=0 
    1027     while [ $i -lt $NB_ESSAI ] ; do 
    1028       \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1029       status=$? 
    1030       if [ ${status} -gt 0 ]; then 
    1031         IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1032         IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 
    1033         sleep $DELAI 
    1034       else 
    1035         break 
    1036       fi 
    1037       (( i = i + 1 )) 
    1038     done 
    1039  
    1040     if [ ${status} -gt 0 ] ; then 
    1041       echo "IGCM_sys_Get_Master : error." 
    1042       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1043       IGCM_debug_Exit "IGCM_sys_Get_Master" 
    1044     else 
    1045       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1046     fi 
    1047   fi 
    1048   IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    1049 } 
    1050  
    1051 #==================================================== 
    1052 #- Call IGCM_sys_Mirror_libIGCM now ! 
    1053 if ( $MirrorlibIGCM ) ; then 
    1054   IGCM_sys_Mirror_libIGCM 
    1055 fi 
    1056499 
    1057500#D-#================================================== 
     
    1097540 
    1098541#D-#================================================== 
    1099 #D-function IGCM_sys_PutBuffer_Rest 
    1100 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
    1101 #D-           File and target directory must exist. 
    1102 #D-* Examples: 
    1103 #D- 
    1104 function IGCM_sys_PutBuffer_Rest { 
    1105   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
    1106   if ( $DEBUG_sys ) ; then 
    1107     echo "IGCM_sys_PutBuffer_Rest :" $@ 
    1108   fi 
    1109   if [ $DRYRUN = 0 ]; then 
    1110     if [ ! -f ${1} ] ; then 
    1111       echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
    1112       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1113     fi 
    1114  
    1115     typeset status 
    1116     # 
    1117     if [ X${JobType} = XRUN ] ; then 
    1118       IGCM_sys_Chmod 444 ${1} 
    1119     fi 
    1120  
    1121     # 
    1122     # USUAL WAY 
    1123     \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1124     status=$? 
    1125  
    1126     if [ ${status} -gt 0 ] ; then 
    1127       echo "IGCM_sys_PutBuffer_Rest : error code ${status}" 
    1128       [ -f ${2} ] && ls -l ${2} 
    1129       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1130       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1131       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1132     else 
    1133       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1134     fi 
    1135   fi 
    1136   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    1137 } 
    1138  
    1139 #D-#================================================== 
    1140 #D-function IGCM_sys_PrepareTaredRestart 
    1141 #D-* Purpose: Prepare tared restart to be access by computing job. Identity here. 
    1142 #D-* Examples: 
    1143 #D- 
    1144 function IGCM_sys_PrepareTaredRestart { 
    1145   IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ 
    1146  
    1147   IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" 
    1148 } 
    1149  
    1150 #D-#================================================== 
    1151542#D-function IGCM_sys_Put_Out 
    1152543#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
     
    1189580  fi 
    1190581  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1191   return 0 
    1192 } 
    1193  
    1194 #D-#================================================== 
    1195 #D-function IGCM_sys_PutBuffer_Out 
    1196 #D-* Purpose: Copy a file on ${WORKDIR} after having chmod it in readonly 
    1197 #D-* Examples: 
    1198 #D- 
    1199 function IGCM_sys_PutBuffer_Out { 
    1200   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
    1201   if ( $DEBUG_sys ) ; then 
    1202     echo "IGCM_sys_PutBuffer_Out :" $@ 
    1203   fi 
    1204  
    1205   typeset NB_ESSAI DELAI status i exist skip 
    1206  
    1207   # number of tentative 
    1208   NB_ESSAI=3 
    1209   # time delay between tentative 
    1210   DELAI=2 
    1211  
    1212   if [ $DRYRUN = 0 ]; then 
    1213     if [ ! -f ${1} ] ; then 
    1214       echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
    1215       IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1216       return 1 
    1217     fi 
    1218     # 
    1219     IGCM_sys_Mkdir $( dirname $2 ) 
    1220     # 
    1221  
    1222     exist=false 
    1223     skip=false 
    1224     if [ -f $2 ] ; then 
    1225       IGCM_debug_Print 1 "$2 already exist" 
    1226       exist=true 
    1227       if [ "X$( diff $1 $2 )" = X ] ; then 
    1228         IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
    1229         status=0 
    1230         skip=true 
    1231       else 
    1232         IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    1233         skip=false 
    1234       fi 
    1235     fi 
    1236     # 
    1237     if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
    1238       IGCM_sys_Chmod u+w $2 
    1239     fi 
    1240  
    1241     if [ X${skip} = Xfalse ] ; then 
    1242       i=0 
    1243       while [ $i -lt $NB_ESSAI ] ; do 
    1244         if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then 
    1245           # USUAL WAY 
    1246           \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1247           status=$? 
    1248         else 
    1249           # NOT SO USUAL WAY 
    1250           \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1251           status=$? 
    1252         fi 
    1253         if [ ${status} -gt 0 ]; then 
    1254           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1255           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 
    1256           [ -f ${2} ] && ls -l ${2} 
    1257           [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1258           sleep $DELAI 
    1259         else 
    1260           break 
    1261         fi 
    1262         (( i = i + 1 )) 
    1263       done 
    1264     fi 
    1265  
    1266     if [ ${status} -gt 0 ] ; then 
    1267       echo "IGCM_sys_PutBuffer_Out : error." 
    1268       [ -f ${2} ] && ls -l ${2} 
    1269       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1270       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1271       IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
    1272     else 
    1273  
    1274       if [ X${JobType} = XRUN ] ; then 
    1275         if [ X${3} = X ] ; then 
    1276           [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
    1277           [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
    1278         fi 
    1279       fi 
    1280  
    1281       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1282     fi 
    1283   fi 
    1284   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1285582  return 0 
    1286583} 
     
    1339636 
    1340637#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   # donne la date filesys d'un fichier sur la machine work 
    1432   IGCM_debug_PopStack "IGCM_sys_FichWork" 
    1433 } 
    1434  
    1435 #D-#================================================== 
    1436 #D-function IGCM_sys_GetDate_FichArchive 
    1437 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE 
    1438 #D-* Examples: 
    1439 #D- 
    1440 function IGCM_sys_GetDate_FichArchive { 
    1441   IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1442   if ( $DEBUG_sys ) ; then 
    1443     echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1444   fi 
    1445   IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    1446 } 
    1447  
    1448 #D-#================================================== 
    1449638#D-function IGCM_sys_Dods_Rm 
    1450639#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. 
     
    1498687  fi 
    1499688  IGCM_debug_PopStack "IGCM_sys_sync" 
    1500 } 
    1501  
    1502 #D-#================================================== 
    1503 #D-function IGCM_sys_rebuild 
    1504 #D-* Purpose: rebuild parallel files 
    1505 #D-* Examples: 
    1506 #D- 
    1507 function IGCM_sys_rebuild { 
    1508   IGCM_debug_PushStack "IGCM_sys_rebuild" $@ 
    1509   if ( $DEBUG_sys ) ; then 
    1510     echo "IGCM_sys_rebuild :" $@ 
    1511   fi 
    1512  
    1513   typeset NB_ESSAI DELAI status i firstArg 
    1514   # number of tentative 
    1515   NB_ESSAI=3 
    1516   # time delay between tentative 
    1517   DELAI=2 
    1518  
    1519   i=0 
    1520   while [ $i -lt $NB_ESSAI ] ; do 
    1521     rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1522     status=$? 
    1523     if [ ${status} -gt 0 ] ; then 
    1524       IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" 
    1525       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1526       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1527       IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    1528       firstArg=${1} 
    1529       \rm ${firstArg} 
    1530       sleep $DELAI 
    1531     else 
    1532       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1533       break 
    1534     fi 
    1535     (( i = i + 1 )) 
    1536   done 
    1537  
    1538   if [ ${status} -gt 0 ] ; then 
    1539     echo "IGCM_sys_rebuild : rebuild error code is ${status}" 
    1540     IGCM_debug_Exit "rebuild" 
    1541   fi 
    1542  
    1543   IGCM_debug_PopStack "IGCM_sys_rebuild" 
    1544 } 
    1545  
    1546 #D-#================================================== 
    1547 #D-function IGCM_sys_rebuild_station 
    1548 #D-* Purpose: rebuild parallel files describing station 
    1549 #D-* Examples: 
    1550 #D- 
    1551 function IGCM_sys_rebuild_station { 
    1552   IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@ 
    1553   typeset i list_opt file_in file_out prefix_invert list_invert 
    1554   if ( $DEBUG_sys ) ; then 
    1555     echo "IGCM_sys_rebuild_station :" $@ 
    1556   fi 
    1557   list_opt=$@ 
    1558  
    1559   # Invert Axis : t,x -> x,t 
    1560   #               t,pres,x -> x,t,pres 
    1561   # So that we can concatenate along x 
    1562   i=0 
    1563   for file_in in ${list_opt} ; do 
    1564     (( i = i + 1)) 
    1565     [ ${i} = 1 ] && file_out=${file_in} && continue 
    1566     # detect time counter and do the job only if present 
    1567     var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') 
    1568     if [ X${var_unlim} = Xtime_counter ] ; then 
    1569       prefix_invert=$( basename ${file_in} .nc ) 
    1570       IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc 
    1571       list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc 
    1572     fi 
    1573   done 
    1574  
    1575   # Concatenate 
    1576   IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc 
    1577  
    1578   # Re-ivert file 
    1579   IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} 
    1580  
    1581   # Station re-ordering is too expansive to be run within libIGCM 
    1582   # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. 
    1583   # This re-ordering must be done "in memory" by the cmorization process 
    1584   # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) 
    1585   # BEGIN reordering 
    1586  
    1587   # Only LMDZ text output contains the exact ordering of the station. 
    1588   # We isolate this in the code below: 
    1589   #  0  38  -157.5000000000000  70.98591549295774 
    1590   #  0  54  27.49999999999999   67.18309859154928 
    1591   #  0  56  -62.50000000000001  82.39436619718309 
    1592   #  0  79  12.49999999999999   78.59154929577466 
    1593   #  0  116 -165.0000000000000  76.05633802816901 
    1594   #  0  117 130.0000000000000   70.98591549295774 
    1595   #  0  118 110.0000000000000   87.46478873239437 
    1596   #  1  40  4.999999999999995   51.97183098591550 
    1597  
    1598 #  typeset iStation iProc list_opt file_in file_out prefix_invert 
    1599 #  typeset -Z4 j4 
    1600 #  typeset -Z3 j3 
    1601  
    1602 #  unset list_opt 
    1603 #  set +A list_opt $@ 
    1604  
    1605   # Filename after rebuild 
    1606 #  file_out=${list_opt[0]} 
    1607   # Prefix of output files 
    1608 #  prefix_invert=$( basename ${file_out} .nc ) 
    1609   # Number of procs 
    1610 #  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) 
    1611  
    1612 #  iProc=0 
    1613 #  while [ ${iProc} -lt ${num_proc} ] ; do 
    1614     # Array containing Station as a number 
    1615 #    unset proc_stn 
    1616 #    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}' ) 
    1617     # Number of stations produced by processor proc 
    1618 #    stationLast=${#proc_stn[*]} 
    1619     # Proc number on 4 digits 
    1620 #    j4=${iProc} 
    1621     # Init 
    1622 #    iStation=0 
    1623 #    while [ ${iStation} -lt ${stationLast} ] ; do 
    1624       # Station number on 3 digits 
    1625 #      j3=${proc_stn[${iStation}]} 
    1626       # Extract station 
    1627       # Invert Axis : t,x -> x,t 
    1628       #               t,pres,x -> x,t,pres 
    1629       # So that we can concatenate along x 
    1630 #      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 
    1631 #      (( iStation = iStation + 1 )) 
    1632 #    done 
    1633 #    (( iProc = iProc + 1 )) 
    1634 #  done 
    1635  
    1636   # Concatenate all station along x 
    1637 #  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc 
    1638  
    1639   # Re-invert file 
    1640 #  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} 
    1641  
    1642   # END reordering 
    1643  
    1644   IGCM_debug_PopStack "IGCM_sys_rebuild_station" 
    1645689} 
    1646690 
     
    1925969  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" 
    1926970} 
    1927  
    1928 ############################################################## 
    1929 # NCO OPERATOR 
    1930  
    1931 #D-#================================================== 
    1932 #D-function IGCM_sys_ncap2 
    1933 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry 
    1934 #D-* Examples: 
    1935 #D- 
    1936 function IGCM_sys_ncap2 { 
    1937   IGCM_debug_PushStack "IGCM_sys_ncap2" $@ 
    1938   if ( $DEBUG_sys ) ; then 
    1939     echo "IGCM_sys_ncap2 :" $@ 
    1940   fi 
    1941  
    1942   typeset NB_ESSAI DELAI status i 
    1943   # number of tentative 
    1944   NB_ESSAI=3 
    1945   # time delay between tentative 
    1946   DELAI=2 
    1947  
    1948   i=0 
    1949   while [ $i -lt $NB_ESSAI ] ; do 
    1950     ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1951     status=$? 
    1952     if [ ${status} -gt 0 ] ; then 
    1953       IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" 
    1954       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1955       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1956       IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    1957       sleep $DELAI 
    1958     else 
    1959       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1960       break 
    1961     fi 
    1962     (( i = i + 1 )) 
    1963   done 
    1964  
    1965   if [ ${status} -gt 0 ] ; then 
    1966     echo "IGCM_sys_ncap2 : ncap2 error" 
    1967     IGCM_debug_Exit "ncap2" 
    1968   fi 
    1969  
    1970   IGCM_debug_PopStack "IGCM_sys_ncap2" 
    1971 } 
    1972  
    1973 #D-#================================================== 
    1974 #D-function IGCM_sys_ncatted 
    1975 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry 
    1976 #D-* Examples: 
    1977 #D- 
    1978 function IGCM_sys_ncatted { 
    1979   IGCM_debug_PushStack "IGCM_sys_ncatted" $@ 
    1980   if ( $DEBUG_sys ) ; then 
    1981     echo "IGCM_sys_ncatted :" $@ 
    1982   fi 
    1983  
    1984   typeset NB_ESSAI DELAI status i 
    1985   # number of tentative 
    1986   NB_ESSAI=3 
    1987   # time delay between tentative 
    1988   DELAI=2 
    1989  
    1990   i=0 
    1991   while [ $i -lt $NB_ESSAI ] ; do 
    1992     ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1993     status=$? 
    1994     if [ ${status} -gt 0 ] ; then 
    1995       IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" 
    1996       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1997       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1998       IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    1999       sleep $DELAI 
    2000     else 
    2001       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2002       break 
    2003     fi 
    2004     (( i = i + 1 )) 
    2005   done 
    2006  
    2007   if [ ${status} -gt 0 ] ; then 
    2008     echo "IGCM_sys_ncatted : ncatted error" 
    2009     IGCM_debug_Exit "ncatted" 
    2010   fi 
    2011  
    2012   IGCM_debug_PopStack "IGCM_sys_ncatted" 
    2013 } 
    2014  
    2015 #D-#================================================== 
    2016 #D-function IGCM_sys_ncbo 
    2017 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry 
    2018 #D-* Examples: 
    2019 #D- 
    2020 function IGCM_sys_ncbo { 
    2021   IGCM_debug_PushStack "IGCM_sys_ncbo" $@ 
    2022   if ( $DEBUG_sys ) ; then 
    2023     echo "IGCM_sys_ncbo :" $@ 
    2024   fi 
    2025  
    2026   typeset NB_ESSAI DELAI status i 
    2027   # number of tentative 
    2028   NB_ESSAI=3 
    2029   # time delay between tentative 
    2030   DELAI=2 
    2031  
    2032   i=0 
    2033   while [ $i -lt $NB_ESSAI ] ; do 
    2034     ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2035     status=$? 
    2036     if [ ${status} -gt 0 ] ; then 
    2037       IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" 
    2038       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2039       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2040       IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2041       sleep $DELAI 
    2042     else 
    2043       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2044       break 
    2045     fi 
    2046     (( i = i + 1 )) 
    2047   done 
    2048  
    2049   if [ ${status} -gt 0 ] ; then 
    2050     echo "IGCM_sys_ncbo : ncbo error" 
    2051     IGCM_debug_Exit "ncbo" 
    2052   fi 
    2053  
    2054   IGCM_debug_PopStack "IGCM_sys_ncbo" 
    2055 } 
    2056  
    2057 #D-#================================================== 
    2058 #D-function IGCM_sys_ncdif 
    2059 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry 
    2060 #D-* Examples: 
    2061 #D- 
    2062 function IGCM_sys_ncdiff { 
    2063   IGCM_debug_PushStack "IGCM_sys_ncdiff" $@ 
    2064   if ( $DEBUG_sys ) ; then 
    2065     echo "IGCM_sys_ncdiff :" $@ 
    2066   fi 
    2067  
    2068   typeset NB_ESSAI DELAI status i 
    2069   # number of tentative 
    2070   NB_ESSAI=3 
    2071   # time delay between tentative 
    2072   DELAI=2 
    2073  
    2074   i=0 
    2075   while [ $i -lt $NB_ESSAI ] ; do 
    2076     ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2077     status=$? 
    2078     if [ ${status} -gt 0 ] ; then 
    2079       IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" 
    2080       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2081       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2082       IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2083       sleep $DELAI 
    2084     else 
    2085       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2086       break 
    2087     fi 
    2088     (( i = i + 1 )) 
    2089   done 
    2090  
    2091   if [ ${status} -gt 0 ] ; then 
    2092     echo "IGCM_sys_ncdiff : ncdiff error" 
    2093     IGCM_debug_Exit "ncdiff" 
    2094   fi 
    2095  
    2096   IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    2097 } 
    2098  
    2099 #D-#================================================== 
    2100 #D-function IGCM_sys_ncea 
    2101 #D-* Purpose: encapsulate ncea call so as to manage error code and retry 
    2102 #D-* Examples: 
    2103 #D- 
    2104 function IGCM_sys_ncea { 
    2105   IGCM_debug_PushStack "IGCM_sys_ncea" $@ 
    2106   if ( $DEBUG_sys ) ; then 
    2107     echo "IGCM_sys_ncea :" $@ 
    2108   fi 
    2109  
    2110   typeset NB_ESSAI DELAI status i 
    2111   # number of tentative 
    2112   NB_ESSAI=3 
    2113   # time delay between tentative 
    2114   DELAI=2 
    2115  
    2116   i=0 
    2117   while [ $i -lt $NB_ESSAI ] ; do 
    2118     ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2119     status=$? 
    2120     if [ ${status} -gt 0 ] ; then 
    2121       IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" 
    2122       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2123       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2124       IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2125       sleep $DELAI 
    2126     else 
    2127       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2128       break 
    2129     fi 
    2130     (( i = i + 1 )) 
    2131   done 
    2132  
    2133   if [ ${status} -gt 0 ] ; then 
    2134     echo "IGCM_sys_ncea : ncea error" 
    2135     IGCM_debug_Exit "ncea" 
    2136   fi 
    2137  
    2138   IGCM_debug_PopStack "IGCM_sys_ncea" 
    2139 } 
    2140  
    2141 #D-#================================================== 
    2142 #D-function IGCM_sys_ncecat 
    2143 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry 
    2144 #D-* Examples: 
    2145 #D- 
    2146 function IGCM_sys_ncecat { 
    2147   IGCM_debug_PushStack "IGCM_sys_ncecat" $@ 
    2148   if ( $DEBUG_sys ) ; then 
    2149     echo "IGCM_sys_ncecat :" $@ 
    2150   fi 
    2151  
    2152   typeset NB_ESSAI DELAI status i 
    2153   # number of tentative 
    2154   NB_ESSAI=3 
    2155   # time delay between tentative 
    2156   DELAI=2 
    2157  
    2158   i=0 
    2159   while [ $i -lt $NB_ESSAI ] ; do 
    2160     ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2161     status=$? 
    2162     if [ ${status} -gt 0 ] ; then 
    2163       IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" 
    2164       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2165       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2166       IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2167       sleep $DELAI 
    2168     else 
    2169       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2170       break 
    2171     fi 
    2172     (( i = i + 1 )) 
    2173   done 
    2174  
    2175   if [ ${status} -gt 0 ] ; then 
    2176     echo "IGCM_sys_ncecat : ncecat error" 
    2177     IGCM_debug_Exit "ncecat" 
    2178   fi 
    2179  
    2180   IGCM_debug_PopStack "IGCM_sys_ncecat" 
    2181 } 
    2182  
    2183 #D-#================================================== 
    2184 #D-function IGCM_sys_ncflint 
    2185 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry 
    2186 #D-* Examples: 
    2187 #D- 
    2188 function IGCM_sys_ncflint { 
    2189   IGCM_debug_PushStack "IGCM_sys_ncflint" $@ 
    2190   if ( $DEBUG_sys ) ; then 
    2191     echo "IGCM_sys_ncflint :" $@ 
    2192   fi 
    2193  
    2194   typeset NB_ESSAI DELAI status i 
    2195   # number of tentative 
    2196   NB_ESSAI=3 
    2197   # time delay between tentative 
    2198   DELAI=2 
    2199  
    2200   i=0 
    2201   while [ $i -lt $NB_ESSAI ] ; do 
    2202     ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2203     status=$? 
    2204     if [ ${status} -gt 0 ] ; then 
    2205       IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" 
    2206       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2207       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2208       IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2209       sleep $DELAI 
    2210     else 
    2211       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2212       break 
    2213     fi 
    2214     (( i = i + 1 )) 
    2215   done 
    2216  
    2217   if [ ${status} -gt 0 ] ; then 
    2218     echo "IGCM_sys_ncflint : ncflint error" 
    2219     IGCM_debug_Exit "ncflint" 
    2220   fi 
    2221  
    2222   IGCM_debug_PopStack "IGCM_sys_ncflint" 
    2223 } 
    2224  
    2225 #D-#================================================== 
    2226 #D-function IGCM_sys_ncks 
    2227 #D-* Purpose: encapsulate ncks call so as to manage error code and retry 
    2228 #D-* Examples: 
    2229 #D- 
    2230 function IGCM_sys_ncks { 
    2231   IGCM_debug_PushStack "IGCM_sys_ncks" $@ 
    2232   if ( $DEBUG_sys ) ; then 
    2233     echo "IGCM_sys_ncks :" $@ 
    2234   fi 
    2235  
    2236   typeset NB_ESSAI DELAI status i 
    2237   # number of tentative 
    2238   NB_ESSAI=3 
    2239   # time delay between tentative 
    2240   DELAI=2 
    2241  
    2242   i=0 
    2243   while [ $i -lt $NB_ESSAI ] ; do 
    2244     ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2245     status=$? 
    2246     if [ ${status} -gt 0 ] ; then 
    2247       IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" 
    2248       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2249       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2250       IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2251       sleep $DELAI 
    2252     else 
    2253       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2254       break 
    2255     fi 
    2256     (( i = i + 1 )) 
    2257   done 
    2258  
    2259   if [ ${status} -gt 0 ] ; then 
    2260     echo "IGCM_sys_ncks : ncks error" 
    2261     IGCM_debug_Exit "ncks" 
    2262   fi 
    2263  
    2264   IGCM_debug_PopStack "IGCM_sys_ncks" 
    2265 } 
    2266  
    2267 #D-#================================================== 
    2268 #D-function IGCM_sys_ncpdq 
    2269 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry 
    2270 #D-* Examples: 
    2271 #D- 
    2272 function IGCM_sys_ncpdq { 
    2273   IGCM_debug_PushStack "IGCM_sys_ncpdq" $@ 
    2274   if ( $DEBUG_sys ) ; then 
    2275     echo "IGCM_sys_ncpdq :" $@ 
    2276   fi 
    2277  
    2278   typeset NB_ESSAI DELAI status i 
    2279   # number of tentative 
    2280   NB_ESSAI=3 
    2281   # time delay between tentative 
    2282   DELAI=2 
    2283  
    2284   i=0 
    2285   while [ $i -lt $NB_ESSAI ] ; do 
    2286     ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2287     status=$? 
    2288     if [ ${status} -gt 0 ] ; then 
    2289       IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" 
    2290       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2291       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2292       IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2293       sleep $DELAI 
    2294     else 
    2295       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2296       break 
    2297     fi 
    2298     (( i = i + 1 )) 
    2299   done 
    2300  
    2301   if [ ${status} -gt 0 ] ; then 
    2302     echo "IGCM_sys_ncpdq : ncpdq error" 
    2303     IGCM_debug_Exit "ncpdq" 
    2304   fi 
    2305  
    2306   IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    2307 } 
    2308  
    2309 #D-#================================================== 
    2310 #D-function IGCM_sys_ncra 
    2311 #D-* Purpose: encapsulate ncra call so as to manage error code and retry 
    2312 #D-* Examples: 
    2313 #D- 
    2314 function IGCM_sys_ncra { 
    2315   IGCM_debug_PushStack "IGCM_sys_ncra" $@ 
    2316   if ( $DEBUG_sys ) ; then 
    2317     echo "IGCM_sys_ncra :" $@ 
    2318   fi 
    2319  
    2320   typeset NB_ESSAI DELAI status i 
    2321   # number of tentative 
    2322   NB_ESSAI=3 
    2323   # time delay between tentative 
    2324   DELAI=2 
    2325  
    2326   i=0 
    2327   while [ $i -lt $NB_ESSAI ] ; do 
    2328     ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2329     status=$? 
    2330     if [ ${status} -gt 0 ] ; then 
    2331       IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" 
    2332       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2333       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2334       IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2335       sleep $DELAI 
    2336     else 
    2337       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2338       break 
    2339     fi 
    2340     (( i = i + 1 )) 
    2341   done 
    2342  
    2343   if [ ${status} -gt 0 ] ; then 
    2344     echo "IGCM_sys_ncra : ncra error" 
    2345     IGCM_debug_Exit "ncra" 
    2346   fi 
    2347  
    2348   IGCM_debug_PopStack "IGCM_sys_ncra" 
    2349 } 
    2350  
    2351 #D-#================================================== 
    2352 #D-function IGCM_sys_ncrcat 
    2353 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry 
    2354 #D-* Examples: 
    2355 #D- 
    2356 function IGCM_sys_ncrcat { 
    2357   IGCM_debug_PushStack "IGCM_sys_ncrcat" $@ 
    2358   if ( $DEBUG_sys ) ; then 
    2359     echo "IGCM_sys_ncrcat :" $@ 
    2360   fi 
    2361  
    2362   typeset NB_ESSAI DELAI status i lastArg 
    2363   # number of tentative 
    2364   NB_ESSAI=3 
    2365   # time delay between tentative 
    2366   DELAI=2 
    2367  
    2368   i=0 
    2369   while [ $i -lt $NB_ESSAI ] ; do 
    2370     ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2371     status=$? 
    2372     if [ ${status} -gt 0 ] ; then 
    2373       IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" 
    2374       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2375       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2376       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2377       sleep $DELAI 
    2378     elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then 
    2379       IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" 
    2380       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2381       # remove files having corrupted time axis 
    2382       eval lastArg=\${$#} 
    2383       IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" 
    2384       \rm ${lastArg} 
    2385       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2386       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2387       sleep $DELAI 
    2388     else 
    2389       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2390       break 
    2391     fi 
    2392     (( i = i + 1 )) 
    2393   done 
    2394  
    2395   if [ ${status} -gt 0 ] ; then 
    2396     echo "IGCM_sys_ncrcat : ncrcat error" 
    2397     #IGCM_debug_Exit "ncrcat" 
    2398   fi 
    2399  
    2400   IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    2401 } 
    2402  
    2403 #D-#================================================== 
    2404 #D-function IGCM_sys_ncrename 
    2405 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry 
    2406 #D-* Examples: 
    2407 #D- 
    2408 function IGCM_sys_ncrename { 
    2409   IGCM_debug_PushStack "IGCM_sys_ncrename" $@ 
    2410   if ( $DEBUG_sys ) ; then 
    2411     echo "IGCM_sys_ncrename :" $@ 
    2412   fi 
    2413  
    2414   typeset NB_ESSAI DELAI status i 
    2415   # number of tentative 
    2416   NB_ESSAI=3 
    2417   # time delay between tentative 
    2418   DELAI=2 
    2419  
    2420   i=0 
    2421   while [ $i -lt $NB_ESSAI ] ; do 
    2422     ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2423     status=$? 
    2424     if [ ${status} -gt 0 ] ; then 
    2425       IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" 
    2426       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2427       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2428       IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2429       sleep $DELAI 
    2430     else 
    2431       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2432       break 
    2433     fi 
    2434     (( i = i + 1 )) 
    2435   done 
    2436  
    2437   if [ ${status} -gt 0 ] ; then 
    2438     echo "IGCM_sys_ncrename : ncrename error" 
    2439     IGCM_debug_Exit "ncrename" 
    2440   fi 
    2441  
    2442   IGCM_debug_PopStack "IGCM_sys_ncrename" 
    2443 } 
    2444  
    2445 #D-#================================================== 
    2446 #D-function IGCM_sys_ncwa 
    2447 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry 
    2448 #D-* Examples: 
    2449 #D- 
    2450 function IGCM_sys_ncwa { 
    2451   IGCM_debug_PushStack "IGCM_sys_ncwa" $@ 
    2452   if ( $DEBUG_sys ) ; then 
    2453     echo "IGCM_sys_ncwa :" $@ 
    2454   fi 
    2455  
    2456   typeset NB_ESSAI DELAI status i 
    2457   # number of tentative 
    2458   NB_ESSAI=3 
    2459   # time delay between tentative 
    2460   DELAI=2 
    2461  
    2462   i=0 
    2463   while [ $i -lt $NB_ESSAI ] ; do 
    2464     ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2465     status=$? 
    2466     if [ ${status} -gt 0 ] ; then 
    2467       IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" 
    2468       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2469       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2470       IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2471       sleep $DELAI 
    2472     else 
    2473       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2474       break 
    2475     fi 
    2476     (( i = i + 1 )) 
    2477   done 
    2478  
    2479   if [ ${status} -gt 0 ] ; then 
    2480     echo "IGCM_sys_ncwa : ncwa error" 
    2481     IGCM_debug_Exit "ncwa" 
    2482   fi 
    2483  
    2484   IGCM_debug_PopStack "IGCM_sys_ncwa" 
    2485 } 
    2486  
    2487 ############################################################## 
    2488 # CDO OPERATOR 
    2489  
    2490 #D-#================================================== 
    2491 #D-function IGCM_sys_cdo 
    2492 #D-* Purpose: encapsulate cdo call so as to manage error code and retry 
    2493 #D-* Examples: 
    2494 #D- 
    2495 function IGCM_sys_cdo { 
    2496   IGCM_debug_PushStack "IGCM_sys_cdo" $@ 
    2497   if ( $DEBUG_sys ) ; then 
    2498     echo "IGCM_sys_cdo :" $@ 
    2499   fi 
    2500  
    2501   typeset status 
    2502  
    2503   \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2504   status=$? 
    2505   if [ ${status} -gt 0 ] ; then 
    2506     echo "IGCM_sys_cdo : error code ${status}" 
    2507     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2508     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2509     IGCM_debug_PopStack "IGCM_sys_cdo" 
    2510     return 1 
    2511   else 
    2512     IGCM_debug_PopStack "IGCM_sys_cdo" 
    2513     return 0 
    2514   fi 
    2515  
    2516   IGCM_debug_PopStack "IGCM_sys_cdo" 
    2517 } 
Note: See TracChangeset for help on using the changeset viewer.