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

    r1180 r1181  
    204204 
    205205#D-#================================================== 
    206 #D-function IGCM_sys_RshMaster 
    207 #D-* Purpose: Connection to frontend machine. 
    208 #D-* Examples: 
    209 #D- 
    210 function IGCM_sys_RshMaster { 
    211   IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    212   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF 
    213     export libIGCM=${libIGCM} 
    214     export DEBUG_debug=${DEBUG_debug} 
    215     . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
    216     . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
    217     ${@} 
    218 EOF 
    219   if [ $? -gt 0 ] ; then 
    220     echo "IGCM_sys_RshMaster : erreur." 
    221     IGCM_debug_Exit "IGCM_sys_RshMaster" 
    222   fi 
    223   IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    224 } 
    225  
    226 #D-#================================================== 
    227206#D-function IGCM_sys_RshArchive 
    228207#D-* Purpose: Archive rsh command 
     
    251230  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ 
    252231  /bin/ksh <<-EOF 
    253     ${@} 2> \dev\null 
     232    ${@} 2> /dev/null 
    254233EOF 
    255234  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" 
    256 } 
    257  
    258 #D-#================================================== 
    259 #D-function IGCM_sys_RshPost 
    260 #D-* Purpose: Post-process rsh command 
    261 #D-* Examples: 
    262 #D- 
    263 function IGCM_sys_RshPost { 
    264   IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    265   if ( $DEBUG_sys ) ; then 
    266     echo "IGCM_sys_RshPost :" $@ 
    267   fi 
    268   # keep standard input (stdin) for the loop onto temporary file 
    269   cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    270  
    271   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    272   if [ $? -gt 0 ] ; then 
    273     echo "IGCM_sys_RshPost : erreur." 
    274     IGCM_debug_Exit "IGCM_sys_RshPost" 
    275   fi 
    276   # delete temporary file 
    277   \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    278   IGCM_debug_PopStack "IGCM_sys_RshPost" 
    279 } 
    280  
    281 #D-#================================================== 
    282 #D-function IGCM_sys_SendMail 
    283 #D-* Purpose: Send mail when simulation is over 
    284 #D-* Examples: 
    285 #D- 
    286 function IGCM_sys_SendMail { 
    287   IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    288   if ( $DEBUG_sys ) ; then 
    289     echo "IGCM_sys_SendMail :" $@ 
    290   fi 
    291  
    292   if [ X${1} = XAccounting ] ; then 
    293     status=Accounting 
    294     mailText=jobAccounting.mail 
    295   elif ( ${ExitFlag} ) ; then 
    296     status=failed 
    297     mailText=jobEnd.mail 
    298   else 
    299     status=completed 
    300     mailText=jobEnd.mail 
    301   fi 
    302  
    303   # Update selected mail template 
    304   while read -r line; do 
    305     eval echo $line >> mail.txt ; 
    306   done < ${libIGCM}/libIGCM_sys/${mailText} 
    307  
    308   if [ ! -z ${config_UserChoices_MailName} ] ; then 
    309     mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt 
    310   elif [ -f ~/.forward ] ; then 
    311     mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt 
    312   else 
    313     mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt 
    314   fi 
    315  
    316   sleep 10 
    317   rm -f mail.txt 
    318  
    319   IGCM_debug_PopStack "IGCM_sys_SendMail" 
    320 } 
    321  
    322 #D-#================================================== 
    323 #D-function IGCM_sys_Mkdir 
    324 #D-* Purpose: Master locale mkdir command 
    325 #D-* Examples: 
    326 #D- 
    327 function IGCM_sys_Mkdir { 
    328   IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    329   if ( $DEBUG_sys ) ; then 
    330     echo "IGCM_sys_Mkdir :" $@ 
    331   fi 
    332   if [ ! -d ${1} ]; then 
    333     \mkdir -p $1 
    334     if [ $? -gt 0 ] ; then 
    335       echo "IGCM_sys_Mkdir : erreur." 
    336       IGCM_debug_Exit "IGCM_sys_Mkdir" 
    337     fi 
    338   fi 
    339   # vérification : 
    340   if [ ! -d ${1} ] ; then 
    341     echo "IGCM_sys_Mkdir : erreur." 
    342     IGCM_debug_Exit "IGCM_sys_Mkdir" 
    343   fi 
    344   IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    345235} 
    346236 
     
    366256  fi 
    367257  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    368 } 
    369  
    370 #D-#================================================== 
    371 #D-function IGCM_sys_MkdirWork 
    372 #D-* Purpose: Mkdir on Work 
    373 #D-* Examples: 
    374 #D- 
    375 function IGCM_sys_MkdirWork { 
    376   IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    377   if ( $DEBUG_sys ) ; then 
    378     echo "IGCM_sys_MkdirWork :" $@ 
    379   fi 
    380   #- creation de repertoire sur le serveur fichier 
    381   if [ ! -d ${1} ]; then 
    382     \mkdir -p $1 
    383     if [ $? -gt 0 ] ; then 
    384       echo "IGCM_sys_MkdirWork : erreur." 
    385       IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    386     fi 
    387   fi 
    388   IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    389 } 
    390  
    391 #D-#================================================== 
    392 #D-function IGCM_sys_Cd 
    393 #D-* Purpose: master cd command 
    394 #D-* Examples: 
    395 #D- 
    396 function IGCM_sys_Cd { 
    397   IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    398   if ( $DEBUG_sys ) ; then 
    399     echo "IGCM_sys_Cd :" $@ 
    400   fi 
    401   \cd $1 
    402   if [ $? -gt 0 ] ; then 
    403     echo "IGCM_sys_Cd : erreur." 
    404     IGCM_debug_Exit "IGCM_sys_Cd" 
    405   fi 
    406   IGCM_debug_PopStack "IGCM_sys_Cd" 
    407 } 
    408  
    409 #D-#================================================== 
    410 #D-function IGCM_sys_Chmod 
    411 #D-* Purpose: Chmod 
    412 #D-* Examples: 
    413 #D- 
    414 function IGCM_sys_Chmod { 
    415   IGCM_debug_PushStack "IGCM_sys_Chmod" $@ 
    416   if ( $DEBUG_sys ) ; then 
    417     echo "IGCM_sys_Chmod :" $@ 
    418   fi 
    419   \chmod $@ 
    420   if [ $? -gt 0 ] ; then 
    421     echo "IGCM_sys_Chmod : erreur." 
    422     IGCM_debug_Exit "IGCM_sys_Chmod" 
    423   fi 
    424   IGCM_debug_PopStack "IGCM_sys_Chmod" 
    425 } 
    426  
    427 #D-#================================================== 
    428 #D-function IGCM_sys_FileSize 
    429 #D-* Purpose: Filesize 
    430 #D-* Examples: 
    431 #D- 
    432 function IGCM_sys_FileSize { 
    433   IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    434  
    435   typeset sizeF 
    436   set +A sizeF -- $( ls -la ${1} ) 
    437   if [ $? -gt 0 ] ; then 
    438     IGCM_debug_Exit "IGCM_sys_FileSize" 
    439   fi 
    440   eval ${2}=${sizeF[4]} 
    441  
    442   IGCM_debug_PopStack "IGCM_sys_FileSize" 
    443 } 
    444  
    445 #D-#================================================== 
    446 #D-function IGCM_sys_TestDir 
    447 #D-* Purpose: Test Directory that must exists 
    448 #D-* Examples: 
    449 #D- 
    450 function IGCM_sys_TestDir { 
    451   IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    452   if ( $DEBUG_sys ) ; then 
    453     echo "IGCM_sys_TestDir :" $@ 
    454   fi 
    455   typeset ExistFlag 
    456   ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    457   IGCM_debug_PopStack "IGCM_sys_TestDir" 
    458  
    459   return ${ExistFlag} 
    460258} 
    461259 
     
    509307 
    510308#D-#================================================== 
    511 #D-function IGCM_sys_TestFileBuffer 
    512 #D-* Purpose: Test file that must NOT EXISTS on Buffer 
    513 #D-* Examples: 
    514 #D- 
    515 function IGCM_sys_TestFileBuffer { 
    516   IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
    517   typeset ExistFlag 
    518   ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    519   IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
    520  
    521   return ${ExistFlag} 
    522 } 
    523  
    524 #D-#================================================== 
    525309#D-function IGCM_sys_CountFileArchive 
    526310#D-* Purpose: Count files on Archive filesystem 
     
    537321 
    538322#D-#================================================== 
    539 #D-function IGCM_sys_CountFileBuffer 
    540 #D-* Purpose: Count files on Scratch filesystem 
    541 #D-* Examples: 
    542 #D- 
    543 function IGCM_sys_CountFileBuffer { 
    544   IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
    545   ls ${@} 2>/dev/null | wc -l 
    546   if [ $? -gt 0 ] ; then 
    547     echo "IGCM_sys_CountFileBuffer : erreur." 
    548   fi 
    549   IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    550 } 
    551  
    552 #D-#================================================== 
    553323#D-function IGCM_sys_Tree 
    554324#D-* Purpose: Tree directories with files on ${ARCHIVE} 
     
    564334 
    565335  IGCM_debug_PopStack "IGCM_sys_Tree" 
    566 } 
    567  
    568 #D-#================================================== 
    569 #D-function IGCM_sys_Tar 
    570 #D-* Purpose: master tar command 
    571 #D-* Examples: 
    572 #D- 
    573 function IGCM_sys_Tar { 
    574   IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    575   if ( $DEBUG_sys ) ; then 
    576     echo "IGCM_sys_Tar :" $@ 
    577   fi 
    578   \tar cf $@ 
    579   if [ $? -gt 0 ] ; then 
    580     echo "IGCM_sys_Tar : erreur." 
    581     IGCM_debug_Exit "IGCM_sys_Tar" 
    582   fi 
    583   IGCM_debug_PopStack "IGCM_sys_Tar" 
    584 } 
    585  
    586 #D-#================================================== 
    587 #D-function IGCM_sys_UnTar 
    588 #D-* Purpose: master un-tar command 
    589 #D-* Examples: 
    590 #D- 
    591 function IGCM_sys_UnTar { 
    592   IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    593   if ( $DEBUG_sys ) ; then 
    594     echo "IGCM_sys_UnTar :" $@ 
    595   fi 
    596   \tar xvf $1 
    597   if [ $? -gt 0 ] ; then 
    598     echo "IGCM_sys_UnTar : erreur." 
    599     IGCM_debug_Exit "IGCM_sys_UnTar" 
    600   fi 
    601   IGCM_debug_PopStack "IGCM_sys_UnTar" 
    602336} 
    603337 
     
    646380 
    647381#D-#================================================== 
    648 #D-function IGCM_sys_Rsync_out 
    649 #D-* Purpose: treat return val of rsync 
    650 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync 
    651 #D-  Error values and explanations can depend on your system version. 
    652 function IGCM_sys_Rsync_out { 
    653   status=$1 
    654   if [ ! $status ] ; then 
    655     echo "rsync error !" 
    656   fi 
    657  
    658   if [ $MYLANG = "fr" ]; then 
    659     case $status in 
    660     0)  return ;; 
    661     1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    662       echo "Erreur de syntaxe ou d'utilisation." 
    663       return;; 
    664     2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    665       echo "Incompatibilité de protocole." 
    666       return;; 
    667     3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    668       echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    669       echo "répertoires" 
    670       return;; 
    671     4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    672       echo "Action demandée non supportée : une tentative de manipulation de" 
    673       echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    674       echo "été faite ; ou une option qui est supportée par le  client  mais" 
    675       echo "pas par le serveur a été spécifiée." 
    676       return;; 
    677     10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    678       echo "Erreur dans le socket d'entrée sortie" 
    679       return;; 
    680     11) echo "Erreur de rsync ; RERR_FILEIO" 
    681       echo "Erreur d'entrée sortie fichier" 
    682       return;; 
    683     12) echo "Erreur de rsync ; RERR_STREAMIO" 
    684       echo "Erreur dans flux de donnée du protocole rsync" 
    685       return;; 
    686     13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    687       echo "Erreur avec les diagnostics du programme" 
    688       return;; 
    689     14) echo "Erreur de rsync ; RERR_IPC" 
    690       echo "Erreur dans le code IPC" 
    691       return;; 
    692     20) echo "Erreur de rsync ; RERR_SIGNAL" 
    693       echo "SIGUSR1 ou SIGINT reçu" 
    694       return;; 
    695     21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    696       echo "Une erreur retournée par waitpid()" 
    697       return;; 
    698     22) echo "Erreur de rsync ; RERR_MALLOC" 
    699       echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    700       return;; 
    701     23) echo "" 
    702       echo "Erreur fichier inexistant" 
    703       return;; 
    704     30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    705       echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    706       return;; 
    707     *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status 
    708       return;; 
    709     esac 
    710   elif [ $MYLANG = "en" ] ; then 
    711     case $status in 
    712     0)  return;; 
    713     1)  echo "rsync error : Syntax or usage error " 
    714       return;; 
    715     2)  echo "rsync error : Protocol incompatibility " 
    716       return;; 
    717     3)  echo "rsync error : Errors selecting input/output files, dirs" 
    718       return;; 
    719     4)  echo "rsync error : Requested action not supported: an attempt" 
    720       echo "was made to manipulate 64-bit files on a platform that cannot support" 
    721       echo "them; or an option was specified that is supported by the client and" 
    722       echo "not by the server." 
    723       return;; 
    724     5)  echo "rsync error : Error starting client-server protocol" 
    725       return;; 
    726     10) echo "rsync error : Error in socket I/O " 
    727       return;; 
    728     11) echo "rsync error : Error in file I/O " 
    729       return;; 
    730     12) echo "rsync error : Error in rsync protocol data stream " 
    731       return;; 
    732     13) echo "rsync error : Errors with program diagnostics " 
    733       return;; 
    734     14) echo "rsync error : Error in IPC code " 
    735       return;; 
    736     20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    737       return;; 
    738     21) echo "rsync error : Some error returned by waitpid() " 
    739       return;; 
    740     22) echo "rsync error : Error allocating core memory buffers " 
    741       return;; 
    742     23) echo "rsync error : Partial transfer due to error" 
    743       return;; 
    744     24) echo "rsync error : Partial transfer due to vanished source files" 
    745       return;; 
    746     30) echo "rsync error : Timeout in data send/receive " 
    747       return;; 
    748     *)  echo "rsync error : return code of rsync unknown :" $status 
    749       return;; 
    750     esac 
    751   else 
    752     echo "unknown language $MYLANG." 
    753     return 
    754   fi 
    755 } 
    756  
    757 #D-#================================================== 
    758 #D-function IGCM_sys_Miror_libIGCM 
    759 #D-* Purpose: Mirror libIGCM PATH and lib to frontend 
    760 #D-* Examples: 
    761 #D- 
    762 function IGCM_sys_Mirror_libIGCM { 
    763   IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    764   if ( $DEBUG_sys ) ; then 
    765     echo "IGCM_sys_Mirror_libIGCM" 
    766   fi 
    767  
    768   typeset status 
    769  
    770   mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    771  
    772   echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    773   ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    774   status=$? 
    775  
    776   if [ ${status} -gt 0 ] ; then 
    777     echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." 
    778     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    779   fi 
    780   IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    781 } 
    782  
    783 #D-#================================================== 
    784 #D-function IGCM_sys_Cp 
    785 #D-* Purpose: generic cp 
    786 #D-* Examples: 
    787 #D- 
    788 function IGCM_sys_Cp { 
    789   IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    790   if ( $DEBUG_sys ) ; then 
    791     echo "IGCM_sys_Cp :" $@ 
    792   fi 
    793  
    794   typeset status 
    795  
    796   echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    797   \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    798   status=$? 
    799  
    800   if [ ${status} -gt 0 ] ; then 
    801     echo "IGCM_sys_Cp : error code ${status}" 
    802     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    803     IGCM_debug_Exit "IGCM_sys_Cp" 
    804   else 
    805     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    806   fi 
    807   IGCM_debug_PopStack "IGCM_sys_Cp" 
    808 } 
    809  
    810 #D-#================================================== 
    811 #D-function IGCM_sys_Rm 
    812 #D-* Purpose: generic rm 
    813 #D-* Examples: 
    814 #D- 
    815 function IGCM_sys_Rm { 
    816   IGCM_debug_PushStack "IGCM_sys_Rm" $@ 
    817   if ( $DEBUG_sys ) ; then 
    818     echo "IGCM_sys_Rm :" $@ 
    819   fi 
    820  
    821   typeset status 
    822  
    823   echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    824   \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    825   status=$? 
    826  
    827   if [ ${status} -gt 0 ] ; then 
    828     echo "IGCM_sys_Rm : error code ${status}" 
    829     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    830     IGCM_debug_Exit "IGCM_sys_Rm" 
    831   else 
    832     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    833   fi 
    834   IGCM_debug_PopStack "IGCM_sys_Rm" 
    835 } 
    836  
    837 #D-#================================================== 
    838382#D-function IGCM_sys_RmRunDir 
    839383#D-* Purpose: rm tmpdir (dummy function most of the time batch 
     
    849393  fi 
    850394  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    851 } 
    852  
    853 #D-#================================================== 
    854 #D-function IGCM_sys_Mv 
    855 #D-* Purpose: generic move 
    856 #D-* Examples: 
    857 #D- 
    858 function IGCM_sys_Mv { 
    859   IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    860   if ( $DEBUG_sys ) ; then 
    861     echo "IGCM_sys_Mv :" $@ 
    862   fi 
    863  
    864   if [ $DRYRUN = 0 ]; then 
    865  
    866     typeset status 
    867  
    868     echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    869     \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    870     status=$? 
    871  
    872     if [ ${status} -gt 0 ] ; then 
    873       echo "IGCM_sys_Mv : error code ${status}" 
    874       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    875       IGCM_debug_Exit "IGCM_sys_Mv" 
    876     else 
    877       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    878     fi 
    879   fi 
    880   IGCM_debug_PopStack "IGCM_sys_Mv" 
    881395} 
    882396 
     
    963477 
    964478#D-#================================================== 
    965 #D-function IGCM_sys_Get_Master 
    966 #D-* Purpose: Copy a complete directory from MASTER filesystem 
    967 #D-* Examples: 
    968 #D- 
    969 function IGCM_sys_Get_Master { 
    970   IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
    971   if ( $DEBUG_sys ) ; then 
    972     echo "IGCM_sys_Get_Master :" $@ 
    973   fi 
    974   if [ $DRYRUN = 0 ]; then 
    975     if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then 
    976       echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
    977       IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    978       return 
    979     fi 
    980  
    981     typeset NB_ESSAI DELAI status i 
    982     # number of tentative 
    983     NB_ESSAI=3 
    984     # time delay between tentative 
    985     DELAI=2 
    986  
    987     i=0 
    988     while [ $i -lt $NB_ESSAI ] ; do 
    989       \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    990       status=$? 
    991       if [ ${status} -gt 0 ]; then 
    992         IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    993         IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 
    994         sleep $DELAI 
    995       else 
    996         break 
    997       fi 
    998       (( i = i + 1 )) 
    999     done 
    1000  
    1001     if [ ${status} -gt 0 ] ; then 
    1002       echo "IGCM_sys_Get_Master : error." 
    1003       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1004       IGCM_debug_Exit "IGCM_sys_Get_Master" 
    1005     else 
    1006       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1007     fi 
    1008   fi 
    1009   IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    1010 } 
    1011  
    1012 #==================================================== 
    1013 #- Call IGCM_sys_Mirror_libIGCM now ! 
    1014 if ( $MirrorlibIGCM ) ; then 
    1015   IGCM_sys_Mirror_libIGCM 
    1016 fi 
    1017  
    1018 #D-#================================================== 
    1019479#D-function IGCM_sys_Put_Rest 
    1020480#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
     
    1074534 
    1075535#D-#================================================== 
    1076 #D-function IGCM_sys_PutBuffer_Rest 
    1077 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
    1078 #D-           File and target directory must exist. 
    1079 #D-* Examples: 
    1080 #D- 
    1081 function IGCM_sys_PutBuffer_Rest { 
    1082   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
    1083   if ( $DEBUG_sys ) ; then 
    1084     echo "IGCM_sys_PutBuffer_Rest :" $@ 
    1085   fi 
    1086   if [ $DRYRUN = 0 ]; then 
    1087     if [ ! -f ${1} ] ; then 
    1088       echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
    1089       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1090     fi 
    1091  
    1092     typeset status 
    1093     # 
    1094     # USUAL WAY 
    1095     \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1096     status=$? 
    1097  
    1098     if [ ${status} -gt 0 ] ; then 
    1099       echo "IGCM_sys_PutBuffer_Rest : error code ${status}" 
    1100       [ -f ${2} ] && ls -l ${2} 
    1101       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1102       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1103       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1104     else 
    1105  
    1106       if [ X${JobType} = XRUN ] ; then 
    1107         [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
    1108         [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
    1109       fi 
    1110  
    1111       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1112     fi 
    1113   fi 
    1114   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    1115 } 
    1116  
    1117 #D-#================================================== 
    1118 #D-function IGCM_sys_PrepareTaredRestart 
    1119 #D-* Purpose: Prepare tared restart to be access by computing job. Identity here. 
    1120 #D-* Examples: 
    1121 #D- 
    1122 function IGCM_sys_PrepareTaredRestart { 
    1123   IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ 
    1124  
    1125   IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" 
    1126 } 
    1127  
    1128 #D-#================================================== 
    1129536#D-function IGCM_sys_Put_Out 
    1130537#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
     
    1176583 
    1177584#D-#================================================== 
    1178 #D-function IGCM_sys_PutBuffer_Out 
    1179 #D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
    1180 #D-* Examples: 
    1181 #D- 
    1182 function IGCM_sys_PutBuffer_Out { 
    1183   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
    1184   if ( $DEBUG_sys ) ; then 
    1185     echo "IGCM_sys_PutBuffer_Out :" $@ 
    1186   fi 
    1187  
    1188   typeset NB_ESSAI DELAI status i exist skip 
    1189  
    1190   # number of tentative 
    1191   NB_ESSAI=3 
    1192   # time delay between tentative 
    1193   DELAI=2 
    1194  
    1195   if [ $DRYRUN = 0 ]; then 
    1196     if [ ! -f ${1} ] ; then 
    1197       echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
    1198       IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1199       return 1 
    1200     fi 
    1201     # 
    1202     IGCM_sys_Mkdir $( dirname $2 ) 
    1203     # 
    1204  
    1205     exist=false 
    1206     skip=false 
    1207     if [ -f $2 ] ; then 
    1208       IGCM_debug_Print 1 "$2 already exist" 
    1209       exist=true 
    1210       if [ "X$( diff $1 $2 )" = X ] ; then 
    1211         IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
    1212         status=0 
    1213         skip=true 
    1214       else 
    1215         IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    1216         skip=false 
    1217       fi 
    1218     fi 
    1219     # 
    1220     if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
    1221       IGCM_sys_Chmod u+w $2 
    1222     fi 
    1223  
    1224     if [ X${skip} = Xfalse ] ; then 
    1225       i=0 
    1226       while [ $i -lt $NB_ESSAI ] ; do 
    1227         if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then 
    1228           # USUAL WAY 
    1229           \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1230           status=$? 
    1231         else 
    1232           # NOT SO USUAL WAY 
    1233           \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1234           status=$? 
    1235         fi 
    1236         if [ ${status} -gt 0 ]; then 
    1237           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1238           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 
    1239           [ -f ${2} ] && ls -l ${2} 
    1240           [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1241           sleep $DELAI 
    1242         else 
    1243           break 
    1244         fi 
    1245         (( i = i + 1 )) 
    1246       done 
    1247     fi 
    1248  
    1249     if [ ${status} -gt 0 ] ; then 
    1250       echo "IGCM_sys_PutBuffer_Out : error." 
    1251       [ -f ${2} ] && ls -l ${2} 
    1252       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1253       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1254       IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
    1255     else 
    1256  
    1257       if [ X${JobType} = XRUN ] ; then 
    1258         if [ X${3} = X ] ; then 
    1259           [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
    1260           [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
    1261         fi 
    1262       fi 
    1263  
    1264       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1265     fi 
    1266   fi 
    1267   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1268   return 0 
    1269 } 
    1270  
    1271 #D-#================================================== 
    1272585#D-function IGCM_sys_Get 
    1273586#D-* Purpose: Get a file from ${ARCHIVE} 
     
    1315628 
    1316629#D-#================================================== 
    1317 #D-function IGCM_sys_GetBuffer 
    1318 #D-* Purpose: Get a file from ${SCRATCHDIR} 
    1319 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
    1320 #D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
    1321 function IGCM_sys_GetBuffer { 
    1322   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
    1323  
    1324   typeset DEST buf_liste target file_work 
    1325   typeset NB_ESSAI DELAI status i 
    1326  
    1327   if ( $DEBUG_sys ) ; then 
    1328     echo "IGCM_sys_GetBuffer :" $@ 
    1329   fi 
    1330  
    1331   # number of tentative 
    1332   NB_ESSAI=3 
    1333   # time delay between tentative 
    1334   DELAI=2 
    1335  
    1336   if [ $DRYRUN -le 2 ]; then 
    1337     if [ X${1} = X'/l' ] ; then 
    1338       eval set +A buf_liste \${${2}} 
    1339     else 
    1340       eval set +A buf_liste ${1} 
    1341     fi 
    1342     eval DEST=\${${#}} 
    1343  
    1344     #USUAL WAY 
    1345     if [ X${1} = X'/l' ] ; then 
    1346       for target in ${buf_liste[*]} ; do 
    1347         local_file=$( basename ${target} ) 
    1348         i=0 
    1349         while [ $i -lt $NB_ESSAI ] ; do 
    1350           \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1351           status=$? 
    1352           if [ ${status} -gt 0 ]; then 
    1353             IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1354             IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
    1355             sleep $DELAI 
    1356           else 
    1357             break 
    1358           fi 
    1359           (( i = i + 1 )) 
    1360         done 
    1361         if [ ${status} -gt 0 ] ; then 
    1362           echo "IGCM_sys_Get : error" 
    1363           cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1364           \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1365           IGCM_debug_Exit "IGCM_sys_GetBuffer" 
    1366         else 
    1367           \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1368         fi 
    1369       done 
    1370     else 
    1371       i=0 
    1372       while [ $i -lt $NB_ESSAI ] ; do 
    1373         \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1374         status=$? 
    1375         if [ ${status} -gt 0 ]; then 
    1376           IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1377           IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
    1378           sleep $DELAI 
    1379         else 
    1380           break 
    1381         fi 
    1382         (( i = i + 1 )) 
    1383       done 
    1384       if [ ${status} -gt 0 ] ; then 
    1385         echo "IGCM_sys_Get : error" 
    1386         cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1387         \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1388         IGCM_debug_Exit "IGCM_sys_GetBuffer" 
    1389       else 
    1390         \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1391       fi 
    1392     fi 
    1393   fi 
    1394   IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
    1395 } 
    1396  
    1397 #D-#================================================== 
    1398 #D-function IGCM_sys_GetDate_FichWork 
    1399 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
    1400 #D-* Examples: 
    1401 #D- 
    1402 function IGCM_sys_GetDate_FichWork { 
    1403   IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1404   if ( $DEBUG_sys ) ; then 
    1405     echo "IGCM_sys_GetDate_FichWork :" $@ 
    1406   fi 
    1407  
    1408   if [ $# -ge 3 ] ; then 
    1409     mode=$3 
    1410     TimeStyle=$4 
    1411   else 
    1412     mode="default" 
    1413     TimeStyle="%Y%m%d%H%M%S" 
    1414   fi 
    1415  
    1416   typeset dateF 
    1417   set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} ) 
    1418  
    1419   case $mode in 
    1420     "default") 
    1421       eval ${2}=${dateF[5]} 
    1422       ;; 
    1423     "SplitFields") 
    1424       eval ${2}="${dateF[5]}\ ${dateF[6]}" 
    1425       ;; 
    1426   esac 
    1427  
    1428  
    1429   # donne la date filesys d'un fichier sur la machine work 
    1430   IGCM_debug_PopStack "IGCM_sys_FichWork" 
    1431 } 
    1432  
    1433 #D-#================================================== 
    1434 #D-function IGCM_sys_GetDate_FichArchive 
    1435 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE 
    1436 #D-* Examples: 
    1437 #D- 
    1438 function IGCM_sys_GetDate_FichArchive { 
    1439   IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1440   if ( $DEBUG_sys ) ; then 
    1441     echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1442   fi 
    1443   typeset dateF 
    1444   set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1445   eval ${2}=${dateF[5]} 
    1446  
    1447   IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    1448 } 
    1449  
    1450 #D-#================================================== 
    1451630#D-function IGCM_sys_GetDate_Monitoring 
    1452631#D-* Purpose: get the last year for which the monitoring has been computed 
     
    1516695  fi 
    1517696  IGCM_debug_PopStack "IGCM_sys_sync" 
    1518 } 
    1519  
    1520 #D-#================================================== 
    1521 #D-function IGCM_sys_rebuild 
    1522 #D-* Purpose: rebuild parallel files 
    1523 #D-* Examples: 
    1524 #D- 
    1525 function IGCM_sys_rebuild { 
    1526   IGCM_debug_PushStack "IGCM_sys_rebuild" $@ 
    1527   if ( $DEBUG_sys ) ; then 
    1528     echo "IGCM_sys_rebuild :" $@ 
    1529   fi 
    1530  
    1531   typeset NB_ESSAI DELAI status i firstArg 
    1532   # number of tentative 
    1533   NB_ESSAI=3 
    1534   # time delay between tentative 
    1535   DELAI=2 
    1536  
    1537   i=0 
    1538   while [ $i -lt $NB_ESSAI ] ; do 
    1539     rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1540     status=$? 
    1541     if [ ${status} -gt 0 ] ; then 
    1542       IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" 
    1543       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1544       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1545       IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    1546       firstArg=${1} 
    1547       \rm ${firstArg} 
    1548       sleep $DELAI 
    1549     else 
    1550       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1551       break 
    1552     fi 
    1553     (( i = i + 1 )) 
    1554   done 
    1555  
    1556   if [ ${status} -gt 0 ] ; then 
    1557     echo "IGCM_sys_rebuild : rebuild error code is ${status}" 
    1558     IGCM_debug_Exit "rebuild" 
    1559   fi 
    1560  
    1561   IGCM_debug_PopStack "IGCM_sys_rebuild" 
    1562 } 
    1563  
    1564 #D-#================================================== 
    1565 #D-function IGCM_sys_rebuild_station 
    1566 #D-* Purpose: rebuild parallel files describing station 
    1567 #D-* Examples: 
    1568 #D- 
    1569 function IGCM_sys_rebuild_station { 
    1570   IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@ 
    1571   typeset i list_opt file_in file_out prefix_invert list_invert 
    1572   if ( $DEBUG_sys ) ; then 
    1573     echo "IGCM_sys_rebuild_station :" $@ 
    1574   fi 
    1575   list_opt=$@ 
    1576  
    1577   # Invert Axis : t,x -> x,t 
    1578   #               t,pres,x -> x,t,pres 
    1579   # So that we can concatenate along x 
    1580   i=0 
    1581   for file_in in ${list_opt} ; do 
    1582     (( i = i + 1)) 
    1583     [ ${i} = 1 ] && file_out=${file_in} && continue 
    1584     # detect time counter and do the job only if present 
    1585     var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') 
    1586     if [ X${var_unlim} = Xtime_counter ] ; then 
    1587       prefix_invert=$( basename ${file_in} .nc ) 
    1588       IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc 
    1589       list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc 
    1590     fi 
    1591   done 
    1592  
    1593   # Concatenate 
    1594   IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc 
    1595  
    1596   # Re-ivert file 
    1597   IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} 
    1598  
    1599   # Station re-ordering is too expansive to be run within libIGCM 
    1600   # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. 
    1601   # This re-ordering must be done "in memory" by the cmorization process 
    1602   # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) 
    1603   # BEGIN reordering 
    1604  
    1605   # Only LMDZ text output contains the exact ordering of the station. 
    1606   # We isolate this in the code below: 
    1607   #  0  38  -157.5000000000000  70.98591549295774 
    1608   #  0  54  27.49999999999999   67.18309859154928 
    1609   #  0  56  -62.50000000000001  82.39436619718309 
    1610   #  0  79  12.49999999999999   78.59154929577466 
    1611   #  0  116 -165.0000000000000  76.05633802816901 
    1612   #  0  117 130.0000000000000   70.98591549295774 
    1613   #  0  118 110.0000000000000   87.46478873239437 
    1614   #  1  40  4.999999999999995   51.97183098591550 
    1615  
    1616 #  typeset iStation iProc list_opt file_in file_out prefix_invert 
    1617 #  typeset -Z4 j4 
    1618 #  typeset -Z3 j3 
    1619  
    1620 #  unset list_opt 
    1621 #  set +A list_opt $@ 
    1622  
    1623   # Filename after rebuild 
    1624 #  file_out=${list_opt[0]} 
    1625   # Prefix of output files 
    1626 #  prefix_invert=$( basename ${file_out} .nc ) 
    1627   # Number of procs 
    1628 #  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) 
    1629  
    1630 #  iProc=0 
    1631 #  while [ ${iProc} -lt ${num_proc} ] ; do 
    1632     # Array containing Station as a number 
    1633 #    unset proc_stn 
    1634 #    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}' ) 
    1635     # Number of stations produced by processor proc 
    1636 #    stationLast=${#proc_stn[*]} 
    1637     # Proc number on 4 digits 
    1638 #    j4=${iProc} 
    1639     # Init 
    1640 #    iStation=0 
    1641 #    while [ ${iStation} -lt ${stationLast} ] ; do 
    1642       # Station number on 3 digits 
    1643 #      j3=${proc_stn[${iStation}]} 
    1644       # Extract station 
    1645       # Invert Axis : t,x -> x,t 
    1646       #               t,pres,x -> x,t,pres 
    1647       # So that we can concatenate along x 
    1648 #      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 
    1649 #      (( iStation = iStation + 1 )) 
    1650 #    done 
    1651 #    (( iProc = iProc + 1 )) 
    1652 #  done 
    1653  
    1654   # Concatenate all station along x 
    1655 #  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc 
    1656  
    1657   # Re-invert file 
    1658 #  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} 
    1659  
    1660   # END reordering 
    1661  
    1662   IGCM_debug_PopStack "IGCM_sys_rebuild_station" 
    1663697} 
    1664698 
     
    20421076  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" 
    20431077} 
    2044  
    2045 ############################################################## 
    2046 # NCO OPERATOR 
    2047  
    2048 #D-#================================================== 
    2049 #D-function IGCM_sys_ncap2 
    2050 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry 
    2051 #D-* Examples: 
    2052 #D- 
    2053 function IGCM_sys_ncap2 { 
    2054   IGCM_debug_PushStack "IGCM_sys_ncap2" $@ 
    2055   if ( $DEBUG_sys ) ; then 
    2056     echo "IGCM_sys_ncap2 :" $@ 
    2057   fi 
    2058  
    2059   typeset NB_ESSAI DELAI status i 
    2060   # number of tentative 
    2061   NB_ESSAI=3 
    2062   # time delay between tentative 
    2063   DELAI=2 
    2064  
    2065   i=0 
    2066   while [ $i -lt $NB_ESSAI ] ; do 
    2067     ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2068     status=$? 
    2069     if [ ${status} -gt 0 ] ; then 
    2070       IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" 
    2071       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2072       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2073       IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2074       sleep $DELAI 
    2075     else 
    2076       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2077       break 
    2078     fi 
    2079     (( i = i + 1 )) 
    2080   done 
    2081  
    2082   if [ ${status} -gt 0 ] ; then 
    2083     echo "IGCM_sys_ncap2 : ncap2 error" 
    2084     IGCM_debug_Exit "ncap2" 
    2085   fi 
    2086  
    2087   IGCM_debug_PopStack "IGCM_sys_ncap2" 
    2088 } 
    2089  
    2090 #D-#================================================== 
    2091 #D-function IGCM_sys_ncatted 
    2092 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry 
    2093 #D-* Examples: 
    2094 #D- 
    2095 function IGCM_sys_ncatted { 
    2096   IGCM_debug_PushStack "IGCM_sys_ncatted" $@ 
    2097   if ( $DEBUG_sys ) ; then 
    2098     echo "IGCM_sys_ncatted :" $@ 
    2099   fi 
    2100  
    2101   typeset NB_ESSAI DELAI status i 
    2102   # number of tentative 
    2103   NB_ESSAI=3 
    2104   # time delay between tentative 
    2105   DELAI=2 
    2106  
    2107   i=0 
    2108   while [ $i -lt $NB_ESSAI ] ; do 
    2109     ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2110     status=$? 
    2111     if [ ${status} -gt 0 ] ; then 
    2112       IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" 
    2113       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2114       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2115       IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2116       sleep $DELAI 
    2117     else 
    2118       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2119       break 
    2120     fi 
    2121     (( i = i + 1 )) 
    2122   done 
    2123  
    2124   if [ ${status} -gt 0 ] ; then 
    2125     echo "IGCM_sys_ncatted : ncatted error" 
    2126     IGCM_debug_Exit "ncatted" 
    2127   fi 
    2128  
    2129   IGCM_debug_PopStack "IGCM_sys_ncatted" 
    2130 } 
    2131  
    2132 #D-#================================================== 
    2133 #D-function IGCM_sys_ncbo 
    2134 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry 
    2135 #D-* Examples: 
    2136 #D- 
    2137 function IGCM_sys_ncbo { 
    2138   IGCM_debug_PushStack "IGCM_sys_ncbo" $@ 
    2139   if ( $DEBUG_sys ) ; then 
    2140     echo "IGCM_sys_ncbo :" $@ 
    2141   fi 
    2142  
    2143   typeset NB_ESSAI DELAI status i 
    2144   # number of tentative 
    2145   NB_ESSAI=3 
    2146   # time delay between tentative 
    2147   DELAI=2 
    2148  
    2149   i=0 
    2150   while [ $i -lt $NB_ESSAI ] ; do 
    2151     ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2152     status=$? 
    2153     if [ ${status} -gt 0 ] ; then 
    2154       IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" 
    2155       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2156       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2157       IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2158       sleep $DELAI 
    2159     else 
    2160       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2161       break 
    2162     fi 
    2163     (( i = i + 1 )) 
    2164   done 
    2165  
    2166   if [ ${status} -gt 0 ] ; then 
    2167     echo "IGCM_sys_ncbo : ncbo error" 
    2168     IGCM_debug_Exit "ncbo" 
    2169   fi 
    2170  
    2171   IGCM_debug_PopStack "IGCM_sys_ncbo" 
    2172 } 
    2173  
    2174 #D-#================================================== 
    2175 #D-function IGCM_sys_ncdif 
    2176 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry 
    2177 #D-* Examples: 
    2178 #D- 
    2179 function IGCM_sys_ncdiff { 
    2180   IGCM_debug_PushStack "IGCM_sys_ncdiff" $@ 
    2181   if ( $DEBUG_sys ) ; then 
    2182     echo "IGCM_sys_ncdiff :" $@ 
    2183   fi 
    2184  
    2185   typeset NB_ESSAI DELAI status i 
    2186   # number of tentative 
    2187   NB_ESSAI=3 
    2188   # time delay between tentative 
    2189   DELAI=2 
    2190  
    2191   i=0 
    2192   while [ $i -lt $NB_ESSAI ] ; do 
    2193     ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2194     status=$? 
    2195     if [ ${status} -gt 0 ] ; then 
    2196       IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" 
    2197       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2198       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2199       IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2200       sleep $DELAI 
    2201     else 
    2202       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2203       break 
    2204     fi 
    2205     (( i = i + 1 )) 
    2206   done 
    2207  
    2208   if [ ${status} -gt 0 ] ; then 
    2209     echo "IGCM_sys_ncdiff : ncdiff error" 
    2210     IGCM_debug_Exit "ncdiff" 
    2211   fi 
    2212  
    2213   IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    2214 } 
    2215  
    2216 #D-#================================================== 
    2217 #D-function IGCM_sys_ncea 
    2218 #D-* Purpose: encapsulate ncea call so as to manage error code and retry 
    2219 #D-* Examples: 
    2220 #D- 
    2221 function IGCM_sys_ncea { 
    2222   IGCM_debug_PushStack "IGCM_sys_ncea" $@ 
    2223   if ( $DEBUG_sys ) ; then 
    2224     echo "IGCM_sys_ncea :" $@ 
    2225   fi 
    2226  
    2227   typeset NB_ESSAI DELAI status i 
    2228   # number of tentative 
    2229   NB_ESSAI=3 
    2230   # time delay between tentative 
    2231   DELAI=2 
    2232  
    2233   i=0 
    2234   while [ $i -lt $NB_ESSAI ] ; do 
    2235     ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2236     status=$? 
    2237     if [ ${status} -gt 0 ] ; then 
    2238       IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" 
    2239       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2240       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2241       IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2242       sleep $DELAI 
    2243     else 
    2244       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2245       break 
    2246     fi 
    2247     (( i = i + 1 )) 
    2248   done 
    2249  
    2250   if [ ${status} -gt 0 ] ; then 
    2251     echo "IGCM_sys_ncea : ncea error" 
    2252     IGCM_debug_Exit "ncea" 
    2253   fi 
    2254  
    2255   IGCM_debug_PopStack "IGCM_sys_ncea" 
    2256 } 
    2257  
    2258 #D-#================================================== 
    2259 #D-function IGCM_sys_ncecat 
    2260 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry 
    2261 #D-* Examples: 
    2262 #D- 
    2263 function IGCM_sys_ncecat { 
    2264   IGCM_debug_PushStack "IGCM_sys_ncecat" $@ 
    2265   if ( $DEBUG_sys ) ; then 
    2266     echo "IGCM_sys_ncecat :" $@ 
    2267   fi 
    2268  
    2269   typeset NB_ESSAI DELAI status i 
    2270   # number of tentative 
    2271   NB_ESSAI=3 
    2272   # time delay between tentative 
    2273   DELAI=2 
    2274  
    2275   i=0 
    2276   while [ $i -lt $NB_ESSAI ] ; do 
    2277     ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2278     status=$? 
    2279     if [ ${status} -gt 0 ] ; then 
    2280       IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" 
    2281       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2282       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2283       IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2284       sleep $DELAI 
    2285     else 
    2286       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2287       break 
    2288     fi 
    2289     (( i = i + 1 )) 
    2290   done 
    2291  
    2292   if [ ${status} -gt 0 ] ; then 
    2293     echo "IGCM_sys_ncecat : ncecat error" 
    2294     IGCM_debug_Exit "ncecat" 
    2295   fi 
    2296  
    2297   IGCM_debug_PopStack "IGCM_sys_ncecat" 
    2298 } 
    2299  
    2300 #D-#================================================== 
    2301 #D-function IGCM_sys_ncflint 
    2302 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry 
    2303 #D-* Examples: 
    2304 #D- 
    2305 function IGCM_sys_ncflint { 
    2306   IGCM_debug_PushStack "IGCM_sys_ncflint" $@ 
    2307   if ( $DEBUG_sys ) ; then 
    2308     echo "IGCM_sys_ncflint :" $@ 
    2309   fi 
    2310  
    2311   typeset NB_ESSAI DELAI status i 
    2312   # number of tentative 
    2313   NB_ESSAI=3 
    2314   # time delay between tentative 
    2315   DELAI=2 
    2316  
    2317   i=0 
    2318   while [ $i -lt $NB_ESSAI ] ; do 
    2319     ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2320     status=$? 
    2321     if [ ${status} -gt 0 ] ; then 
    2322       IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" 
    2323       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2324       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2325       IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2326       sleep $DELAI 
    2327     else 
    2328       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2329       break 
    2330     fi 
    2331     (( i = i + 1 )) 
    2332   done 
    2333  
    2334   if [ ${status} -gt 0 ] ; then 
    2335     echo "IGCM_sys_ncflint : ncflint error" 
    2336     IGCM_debug_Exit "ncflint" 
    2337   fi 
    2338  
    2339   IGCM_debug_PopStack "IGCM_sys_ncflint" 
    2340 } 
    2341  
    2342 #D-#================================================== 
    2343 #D-function IGCM_sys_ncks 
    2344 #D-* Purpose: encapsulate ncks call so as to manage error code and retry 
    2345 #D-* Examples: 
    2346 #D- 
    2347 function IGCM_sys_ncks { 
    2348   IGCM_debug_PushStack "IGCM_sys_ncks" $@ 
    2349   if ( $DEBUG_sys ) ; then 
    2350     echo "IGCM_sys_ncks :" $@ 
    2351   fi 
    2352  
    2353   typeset NB_ESSAI DELAI status i 
    2354   # number of tentative 
    2355   NB_ESSAI=3 
    2356   # time delay between tentative 
    2357   DELAI=2 
    2358  
    2359   i=0 
    2360   while [ $i -lt $NB_ESSAI ] ; do 
    2361     ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2362     status=$? 
    2363     if [ ${status} -gt 0 ] ; then 
    2364       IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" 
    2365       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2366       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2367       IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2368       sleep $DELAI 
    2369     else 
    2370       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2371       break 
    2372     fi 
    2373     (( i = i + 1 )) 
    2374   done 
    2375  
    2376   if [ ${status} -gt 0 ] ; then 
    2377     echo "IGCM_sys_ncks : ncks error" 
    2378     IGCM_debug_Exit "ncks" 
    2379   fi 
    2380  
    2381   IGCM_debug_PopStack "IGCM_sys_ncks" 
    2382 } 
    2383  
    2384 #D-#================================================== 
    2385 #D-function IGCM_sys_ncpdq 
    2386 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry 
    2387 #D-* Examples: 
    2388 #D- 
    2389 function IGCM_sys_ncpdq { 
    2390   IGCM_debug_PushStack "IGCM_sys_ncpdq" $@ 
    2391   if ( $DEBUG_sys ) ; then 
    2392     echo "IGCM_sys_ncpdq :" $@ 
    2393   fi 
    2394  
    2395   typeset NB_ESSAI DELAI status i 
    2396   # number of tentative 
    2397   NB_ESSAI=3 
    2398   # time delay between tentative 
    2399   DELAI=2 
    2400  
    2401   i=0 
    2402   while [ $i -lt $NB_ESSAI ] ; do 
    2403     ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2404     status=$? 
    2405     if [ ${status} -gt 0 ] ; then 
    2406       IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" 
    2407       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2408       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2409       IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2410       sleep $DELAI 
    2411     else 
    2412       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2413       break 
    2414     fi 
    2415     (( i = i + 1 )) 
    2416   done 
    2417  
    2418   if [ ${status} -gt 0 ] ; then 
    2419     echo "IGCM_sys_ncpdq : ncpdq error" 
    2420     IGCM_debug_Exit "ncpdq" 
    2421   fi 
    2422  
    2423   IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    2424 } 
    2425  
    2426 #D-#================================================== 
    2427 #D-function IGCM_sys_ncra 
    2428 #D-* Purpose: encapsulate ncra call so as to manage error code and retry 
    2429 #D-* Examples: 
    2430 #D- 
    2431 function IGCM_sys_ncra { 
    2432   IGCM_debug_PushStack "IGCM_sys_ncra" $@ 
    2433   if ( $DEBUG_sys ) ; then 
    2434     echo "IGCM_sys_ncra :" $@ 
    2435   fi 
    2436  
    2437   typeset NB_ESSAI DELAI status i 
    2438   # number of tentative 
    2439   NB_ESSAI=3 
    2440   # time delay between tentative 
    2441   DELAI=2 
    2442  
    2443   i=0 
    2444   while [ $i -lt $NB_ESSAI ] ; do 
    2445     ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2446     status=$? 
    2447     if [ ${status} -gt 0 ] ; then 
    2448       IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" 
    2449       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2450       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2451       IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2452       sleep $DELAI 
    2453     else 
    2454       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2455       break 
    2456     fi 
    2457     (( i = i + 1 )) 
    2458   done 
    2459  
    2460   if [ ${status} -gt 0 ] ; then 
    2461     echo "IGCM_sys_ncra : ncra error" 
    2462     IGCM_debug_Exit "ncra" 
    2463   fi 
    2464  
    2465   IGCM_debug_PopStack "IGCM_sys_ncra" 
    2466 } 
    2467  
    2468 #D-#================================================== 
    2469 #D-function IGCM_sys_ncrcat 
    2470 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry 
    2471 #D-* Examples: 
    2472 #D- 
    2473 function IGCM_sys_ncrcat { 
    2474   IGCM_debug_PushStack "IGCM_sys_ncrcat" $@ 
    2475   if ( $DEBUG_sys ) ; then 
    2476     echo "IGCM_sys_ncrcat :" $@ 
    2477   fi 
    2478  
    2479   typeset NB_ESSAI DELAI status i lastArg 
    2480   # number of tentative 
    2481   NB_ESSAI=3 
    2482   # time delay between tentative 
    2483   DELAI=2 
    2484  
    2485   i=0 
    2486   while [ $i -lt $NB_ESSAI ] ; do 
    2487     ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2488     status=$? 
    2489     if [ ${status} -gt 0 ] ; then 
    2490       IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" 
    2491       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2492       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2493       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2494       sleep $DELAI 
    2495     elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then 
    2496       IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" 
    2497       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2498       # remove files having corrupted time axis 
    2499       eval lastArg=\${$#} 
    2500       IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" 
    2501       \rm ${lastArg} 
    2502       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2503       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2504       sleep $DELAI 
    2505     else 
    2506       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2507       break 
    2508     fi 
    2509     (( i = i + 1 )) 
    2510   done 
    2511  
    2512   if [ ${status} -gt 0 ] ; then 
    2513     echo "IGCM_sys_ncrcat : ncrcat error" 
    2514     #IGCM_debug_Exit "ncrcat" 
    2515   fi 
    2516  
    2517   IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    2518 } 
    2519  
    2520 #D-#================================================== 
    2521 #D-function IGCM_sys_ncrename 
    2522 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry 
    2523 #D-* Examples: 
    2524 #D- 
    2525 function IGCM_sys_ncrename { 
    2526   IGCM_debug_PushStack "IGCM_sys_ncrename" $@ 
    2527   if ( $DEBUG_sys ) ; then 
    2528     echo "IGCM_sys_ncrename :" $@ 
    2529   fi 
    2530  
    2531   typeset NB_ESSAI DELAI status i 
    2532   # number of tentative 
    2533   NB_ESSAI=3 
    2534   # time delay between tentative 
    2535   DELAI=2 
    2536  
    2537   i=0 
    2538   while [ $i -lt $NB_ESSAI ] ; do 
    2539     ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2540     status=$? 
    2541     if [ ${status} -gt 0 ] ; then 
    2542       IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" 
    2543       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2544       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2545       IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2546       sleep $DELAI 
    2547     else 
    2548       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2549       break 
    2550     fi 
    2551     (( i = i + 1 )) 
    2552   done 
    2553  
    2554   if [ ${status} -gt 0 ] ; then 
    2555     echo "IGCM_sys_ncrename : ncrename error" 
    2556     IGCM_debug_Exit "ncrename" 
    2557   fi 
    2558  
    2559   IGCM_debug_PopStack "IGCM_sys_ncrename" 
    2560 } 
    2561  
    2562 #D-#================================================== 
    2563 #D-function IGCM_sys_ncwa 
    2564 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry 
    2565 #D-* Examples: 
    2566 #D- 
    2567 function IGCM_sys_ncwa { 
    2568   IGCM_debug_PushStack "IGCM_sys_ncwa" $@ 
    2569   if ( $DEBUG_sys ) ; then 
    2570     echo "IGCM_sys_ncwa :" $@ 
    2571   fi 
    2572  
    2573   typeset NB_ESSAI DELAI status i 
    2574   # number of tentative 
    2575   NB_ESSAI=3 
    2576   # time delay between tentative 
    2577   DELAI=2 
    2578  
    2579   i=0 
    2580   while [ $i -lt $NB_ESSAI ] ; do 
    2581     ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2582     status=$? 
    2583     if [ ${status} -gt 0 ] ; then 
    2584       IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" 
    2585       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2586       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2587       IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2588       sleep $DELAI 
    2589     else 
    2590       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2591       break 
    2592     fi 
    2593     (( i = i + 1 )) 
    2594   done 
    2595  
    2596   if [ ${status} -gt 0 ] ; then 
    2597     echo "IGCM_sys_ncwa : ncwa error" 
    2598     IGCM_debug_Exit "ncwa" 
    2599   fi 
    2600  
    2601   IGCM_debug_PopStack "IGCM_sys_ncwa" 
    2602 } 
    2603  
    2604 ############################################################## 
    2605 # CDO OPERATOR 
    2606  
    2607 #D-#================================================== 
    2608 #D-function IGCM_sys_cdo 
    2609 #D-* Purpose: encapsulate cdo call so as to manage error code and retry 
    2610 #D-* Examples: 
    2611 #D- 
    2612 function IGCM_sys_cdo { 
    2613   IGCM_debug_PushStack "IGCM_sys_cdo" $@ 
    2614   if ( $DEBUG_sys ) ; then 
    2615     echo "IGCM_sys_cdo :" $@ 
    2616   fi 
    2617  
    2618   typeset status 
    2619  
    2620   \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2621   status=$? 
    2622   if [ ${status} -gt 0 ] ; then 
    2623     echo "IGCM_sys_cdo : error code ${status}" 
    2624     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2625     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2626     IGCM_debug_PopStack "IGCM_sys_cdo" 
    2627     return 1 
    2628   else 
    2629     IGCM_debug_PopStack "IGCM_sys_cdo" 
    2630     return 0 
    2631   fi 
    2632  
    2633   IGCM_debug_PopStack "IGCM_sys_cdo" 
    2634 } 
Note: See TracChangeset for help on using the changeset viewer.