Changeset 1181 for trunk


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

Location:
trunk/libIGCM/libIGCM_sys
Files:
6 edited

Legend:

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

    r1172 r1181  
    8585# Set default umask (umask is 0027 on some machines : CCRT machine at least) 
    8686umask 0022 
     87 
     88#D--------------------------------------------------------------------== 
     89#D- 
     90#D-    Define IGCM_sys functions that are common on every systems 
     91#D- 
     92#D--------------------------------------------------------------------== 
     93 
     94#D-#================================================== 
     95#D-function IGCM_sys_RshMaster 
     96#D-* Purpose: Connection to frontend machine. 
     97#D-* Examples: 
     98#D- 
     99function IGCM_sys_RshMaster { 
     100  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
     101  OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF 
     102    export libIGCM=${libIGCM} 
     103    export DEBUG_debug=${DEBUG_debug} 
     104    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
     105    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
     106    ${@} 
     107EOF 
     108  if [ $? -gt 0 ] ; then 
     109    echo "IGCM_sys_RshMaster : erreur." 
     110    IGCM_debug_Exit "IGCM_sys_RshMaster" 
     111  fi 
     112  IGCM_debug_PopStack "IGCM_sys_RshMaster" 
     113} 
     114 
     115#D-#================================================== 
     116#D-function IGCM_sys_RshPost 
     117#D-* Purpose: Post-process rsh command 
     118#D-* Examples: 
     119#D- 
     120function IGCM_sys_RshPost { 
     121  IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
     122  if ( $DEBUG_sys ) ; then 
     123    echo "IGCM_sys_RshPost :" $@ 
     124  fi 
     125  # keep standard input (stdin) for the loop onto temporary file 
     126  cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
     127 
     128  OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
     129  if [ $? -gt 0 ] ; then 
     130    echo "IGCM_sys_RshPost : erreur." 
     131    IGCM_debug_Exit "IGCM_sys_RshPost" 
     132  fi 
     133  # delete temporary file 
     134  \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
     135 
     136# ============ FRONTEND  END  ============ # 
     137 
     138# ============ CESIUM START ============ # 
     139#  typeset NB_ESSAI DELAI status i 
     140#  if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then 
     141#    #little hack so that rebuild submission is done on titane not an cesium 
     142# 
     143#    libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' ) 
     144#    POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' ) 
     145#    sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
     146#    sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
     147#    sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
     148#    sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
     149#    \mv tmp.txt tmp_IGCM_sys_RshPost_$$ 
     150# 
     151#    echo cat tmp_IGCM_sys_RshPost_$$ AFTER 
     152#    cat tmp_IGCM_sys_RshPost_$$ 
     153# 
     154#    /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     155#    if [ $? -gt 0 ] ; then 
     156#      echo "IGCM_sys_RshPost : erreur." 
     157#      IGCM_debug_Exit "IGCM_sys_RshPost" 
     158#    fi 
     159#    # delete temporary file 
     160#    \rm tmp_IGCM_sys_RshPost_$$ 
     161# 
     162#  else 
     163#    # number of tentative 
     164#    NB_ESSAI=10 
     165#    # time delay between tentative 
     166#    DELAI=10 
     167#    i=0 
     168#    while [ $i -ne $NB_ESSAI ] ; do 
     169#      ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
     170#      status=$? 
     171#      if [ ${status} -ne 0 ]; 
     172#      then 
     173#        sleep $DELAI 
     174#      else 
     175#        break 
     176#      fi 
     177#      let i=$i+1 
     178#    done 
     179#    # delete temporary file 
     180#    \rm tmp_IGCM_sys_RshPost_$$ 
     181# 
     182#    if [ ${status} -gt 0 ] ; then 
     183#      echo "IGCM_sys_RshPost : erreur." 
     184#      IGCM_debug_Exit "IGCM_sys_RshPost" 
     185#    fi 
     186#  fi 
     187 
     188# ============ CESIUM  END  ============ # 
     189 
     190  IGCM_debug_PopStack "IGCM_sys_RshPost" 
     191} 
     192 
     193#D-#================================================== 
     194#D-function IGCM_sys_SendMail 
     195#D-* Purpose: Send mail when simulation is over 
     196#D-* Examples: 
     197#D- 
     198function IGCM_sys_SendMail { 
     199  IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
     200  if ( $DEBUG_sys ) ; then 
     201    echo "IGCM_sys_SendMail :" $@ 
     202  fi 
     203 
     204  if [ X${1} = XAccounting ] ; then 
     205    status=Accounting 
     206    mailText=jobAccounting.mail 
     207  elif ( ${ExitFlag} ) ; then 
     208    status=failed 
     209    mailText=jobEnd.mail 
     210  else 
     211    status=completed 
     212    mailText=jobEnd.mail 
     213  fi 
     214 
     215  # Update selected mail template 
     216  while read -r line; do 
     217    eval echo $line >> mail.txt ; 
     218  done < ${libIGCM}/libIGCM_sys/${mailText} 
     219 
     220  if [ ! -z ${config_UserChoices_MailName} ] ; then 
     221    mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt 
     222  elif [ -f ~/.forward ] ; then 
     223    mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt 
     224  else 
     225    mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt 
     226  fi 
     227 
     228  sleep 10 
     229  rm -f mail.txt 
     230 
     231  IGCM_debug_PopStack "IGCM_sys_SendMail" 
     232} 
     233 
     234#D-#================================================== 
     235#D-function IGCM_sys_Mkdir 
     236#D-* Purpose: Master locale mkdir command 
     237#D-* Examples: 
     238#D- 
     239function IGCM_sys_Mkdir { 
     240  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
     241  if ( $DEBUG_sys ) ; then 
     242    echo "IGCM_sys_Mkdir :" $@ 
     243  fi 
     244  if [ ! -d ${1} ]; then 
     245    \mkdir -p $1 
     246    if [ $? -gt 0 ] ; then 
     247      echo "IGCM_sys_Mkdir : erreur." 
     248      IGCM_debug_Exit "IGCM_sys_Mkdir" 
     249    fi 
     250  fi 
     251  # vérification : 
     252  if [ ! -d ${1} ] ; then 
     253    echo "IGCM_sys_Mkdir : erreur." 
     254    IGCM_debug_Exit "IGCM_sys_Mkdir" 
     255  fi 
     256  IGCM_debug_PopStack "IGCM_sys_Mkdir" 
     257} 
     258 
     259#D-#================================================== 
     260#D-function IGCM_sys_MkdirWork 
     261#D-* Purpose: Mkdir on Work 
     262#D-* Examples: 
     263#D- 
     264function IGCM_sys_MkdirWork { 
     265  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
     266  if ( $DEBUG_sys ) ; then 
     267    echo "IGCM_sys_MkdirWork :" $@ 
     268  fi 
     269  #- creation de repertoire sur le serveur fichier 
     270  if [ ! -d ${1} ]; then 
     271    \mkdir -p $1 
     272    if [ $? -gt 0 ] ; then 
     273      echo "IGCM_sys_MkdirWork : erreur." 
     274      IGCM_debug_Exit "IGCM_sys_MkdirWork" 
     275    fi 
     276  fi 
     277  IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
     278} 
     279 
     280#D-#================================================== 
     281#D-function IGCM_sys_Cd 
     282#D-* Purpose: master cd command 
     283#D-* Examples: 
     284#D- 
     285function IGCM_sys_Cd { 
     286  IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
     287  if ( $DEBUG_sys ) ; then 
     288    echo "IGCM_sys_Cd :" $@ 
     289  fi 
     290  \cd $1 
     291  if [ $? -gt 0 ] ; then 
     292    echo "IGCM_sys_Cd : erreur." 
     293    IGCM_debug_Exit "IGCM_sys_Cd" 
     294  fi 
     295  IGCM_debug_PopStack "IGCM_sys_Cd" 
     296} 
     297 
     298#D-#================================================== 
     299#D-function IGCM_sys_Chmod 
     300#D-* Purpose: Chmod 
     301#D-* Examples: 
     302#D- 
     303function IGCM_sys_Chmod { 
     304  IGCM_debug_PushStack "IGCM_sys_Chmod" $@ 
     305  if ( $DEBUG_sys ) ; then 
     306    echo "IGCM_sys_Chmod :" $@ 
     307  fi 
     308  \chmod $@ 
     309  if [ $? -gt 0 ] ; then 
     310    echo "IGCM_sys_Chmod : erreur." 
     311    IGCM_debug_Exit "IGCM_sys_Chmod" 
     312  fi 
     313  IGCM_debug_PopStack "IGCM_sys_Chmod" 
     314} 
     315 
     316#D-#================================================== 
     317#D-function IGCM_sys_FileSize 
     318#D-* Purpose: Filesize 
     319#D-* Examples: 
     320#D- 
     321function IGCM_sys_FileSize { 
     322  IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
     323 
     324  typeset sizeF 
     325  set +A sizeF -- $( ls -la ${1} ) 
     326  if [ $? -gt 0 ] ; then 
     327    IGCM_debug_Exit "IGCM_sys_FileSize" 
     328  fi 
     329  eval ${2}=${sizeF[4]} 
     330 
     331  IGCM_debug_PopStack "IGCM_sys_FileSize" 
     332} 
     333 
     334#D-#================================================== 
     335#D-function IGCM_sys_TestDir 
     336#D-* Purpose: Test Directory that must exists 
     337#D-* Examples: 
     338#D- 
     339function IGCM_sys_TestDir { 
     340  IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
     341  if ( $DEBUG_sys ) ; then 
     342    echo "IGCM_sys_TestDir :" $@ 
     343  fi 
     344  typeset ExistFlag 
     345  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
     346  IGCM_debug_PopStack "IGCM_sys_TestDir" 
     347 
     348  return ${ExistFlag} 
     349} 
     350 
     351#D-#================================================== 
     352#D-function IGCM_sys_TestFileBuffer 
     353#D-* Purpose: Test file that must NOT EXISTS on Buffer 
     354#D-* Examples: 
     355#D- 
     356function IGCM_sys_TestFileBuffer { 
     357  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
     358  typeset ExistFlag 
     359  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
     360  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
     361 
     362  return ${ExistFlag} 
     363} 
     364 
     365#D-#================================================== 
     366#D-function IGCM_sys_CountFileBuffer 
     367#D-* Purpose: Count files on Scratch filesystem 
     368#D-* Examples: 
     369#D- 
     370function IGCM_sys_CountFileBuffer { 
     371  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
     372  ls ${@} 2>/dev/null | wc -l 
     373  if [ $? -gt 0 ] ; then 
     374    echo "IGCM_sys_CountFileBuffer : erreur." 
     375  fi 
     376  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
     377} 
     378 
     379#D-#================================================== 
     380#D-function IGCM_sys_Tar 
     381#D-* Purpose: master tar command 
     382#D-* Examples: 
     383#D- 
     384function IGCM_sys_Tar { 
     385  IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
     386  if ( $DEBUG_sys ) ; then 
     387    echo "IGCM_sys_Tar :" $@ 
     388  fi 
     389  \tar cf $@ 
     390  if [ $? -gt 0 ] ; then 
     391    echo "IGCM_sys_Tar : erreur." 
     392    IGCM_debug_Exit "IGCM_sys_Tar" 
     393  fi 
     394  IGCM_debug_PopStack "IGCM_sys_Tar" 
     395} 
     396 
     397#D-#================================================== 
     398#D-function IGCM_sys_UnTar 
     399#D-* Purpose: master un-tar command 
     400#D-* Examples: 
     401#D- 
     402function IGCM_sys_UnTar { 
     403  IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
     404  if ( $DEBUG_sys ) ; then 
     405    echo "IGCM_sys_UnTar :" $@ 
     406  fi 
     407  \tar xvf $1 
     408  if [ $? -gt 0 ] ; then 
     409    echo "IGCM_sys_UnTar : erreur." 
     410    IGCM_debug_Exit "IGCM_sys_UnTar" 
     411  fi 
     412  IGCM_debug_PopStack "IGCM_sys_UnTar" 
     413} 
     414 
     415#D-************************* 
     416#D- File transfer functions 
     417#D-************************* 
     418#D- 
     419 
     420#D-#================================================== 
     421#D-function IGCM_sys_Rsync_out 
     422#D-* Purpose: treat return val of rsync 
     423#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync 
     424#D-  Error values and explanations can depend on your system version. 
     425function IGCM_sys_Rsync_out { 
     426  IGCM_debug_PushStack "IGCM_sys_Rsync_out" $@ 
     427  if ( $DEBUG_sys ) ; then 
     428    echo "IGCM_sys_UnTar :" $@ 
     429  fi 
     430 
     431  typeset status 
     432  status=$1 
     433 
     434  if [ ! $status ] ; then 
     435    IGCM_debug_Print 1 "IGCM_sys_Rsync_out need an argument" 
     436    IGCM_debug_PopStack "IGCM_sys_Rsync_out" 
     437    return 
     438  fi 
     439 
     440  case $status in 
     441  0)  ;; 
     442  1)  IGCM_debug_Print 1 "rsync error RERR_SYNTAX : Syntax or usage error";; 
     443  2)  IGCM_debug_Print 1 "rsync error RERR_PROTOCOL : Protocol incompatibility";; 
     444  3)  IGCM_debug_Print 1 "rsync error RERR_FILESELECT : Errors selecting input/output files, dirs";; 
     445  4)  IGCM_debug_Print 1 "rsync error RERR_UNSUPPORTED : Requested action not supported." 
     446      IGCM_debug_Print 1 "An attempt was made to manipulate 64-bit files on a platform that cannot support them" 
     447      IGCM_debug_Print 1 "Or an option was specified that is supported by the client and not by the server.";; 
     448  5)  IGCM_debug_Print 1 "rsync error  : Error starting client-server protocol";; 
     449  10) IGCM_debug_Print 1 "rsync error RERR_SOCKETIO : Error in socket I/O";; 
     450  11) IGCM_debug_Print 1 "rsync error RERR_FILEIO: Error in file I/O";; 
     451  12) IGCM_debug_Print 1 "rsync error RERR_STREAMIO : Error in rsync protocol data stream";; 
     452  13) IGCM_debug_Print 1 "rsync error RERR_MESSAGEIO : Errors with program diagnostics";; 
     453  14) IGCM_debug_Print 1 "rsync error RERR_IPC : Error in IPC code";; 
     454  20) IGCM_debug_Print 1 "rsync error RERR_SIGNAL : Received SIGUSR1 or SIGINT";; 
     455  21) IGCM_debug_Print 1 "rsync error RERR_WAITCHILD : Some error returned by waitpid()";; 
     456  22) IGCM_debug_Print 1 "rsync error RERR_MALLOC : Error allocating core memory buffers";; 
     457  23) IGCM_debug_Print 1 "rsync error : Partial transfer due to error";; 
     458  24) IGCM_debug_Print 1 "rsync error : Partial transfer due to vanished source files";; 
     459  30) IGCM_debug_Print 1 "rsync error : Timeout in data send/receive";; 
     460  *)  IGCM_debug_Print 1 "rsync error : return code of rsync unknown :" $status;; 
     461  esac 
     462 
     463  IGCM_debug_PopStack "IGCM_sys_Rsync_out" 
     464} 
     465 
     466#D-#================================================== 
     467#D-function IGCM_sys_Miror_libIGCM 
     468#D-* Purpose: Mirror libIGCM PATH and lib to frontend 
     469#D-* Examples: 
     470#D- 
     471function IGCM_sys_Mirror_libIGCM { 
     472  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
     473  if ( $DEBUG_sys ) ; then 
     474    echo "IGCM_sys_Mirror_libIGCM" 
     475  fi 
     476 
     477  typeset status 
     478 
     479  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
     480 
     481  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     482  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     483  status=$? 
     484 
     485  if [ ${status} -gt 0 ] ; then 
     486    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." 
     487    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     488  fi 
     489  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
     490} 
     491 
     492#D-#================================================== 
     493#D-function IGCM_sys_Cp 
     494#D-* Purpose: generic cp 
     495#D-* Examples: 
     496#D- 
     497function IGCM_sys_Cp { 
     498  IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
     499  if ( $DEBUG_sys ) ; then 
     500    echo "IGCM_sys_Cp :" $@ 
     501  fi 
     502 
     503  typeset status 
     504 
     505  echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     506  \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     507  status=$? 
     508 
     509  if [ ${status} -gt 0 ] ; then 
     510    echo "IGCM_sys_Cp : error code ${status}" 
     511    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     512    IGCM_debug_Exit "IGCM_sys_Cp" 
     513  else 
     514    \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     515  fi 
     516  IGCM_debug_PopStack "IGCM_sys_Cp" 
     517} 
     518 
     519#D-#================================================== 
     520#D-function IGCM_sys_Rm 
     521#D-* Purpose: generic rm 
     522#D-* Examples: 
     523#D- 
     524function IGCM_sys_Rm { 
     525  IGCM_debug_PushStack "IGCM_sys_Rm" $@ 
     526  if ( $DEBUG_sys ) ; then 
     527    echo "IGCM_sys_Rm :" $@ 
     528  fi 
     529 
     530  typeset status 
     531 
     532  echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     533  \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     534  status=$? 
     535 
     536  if [ ${status} -gt 0 ] ; then 
     537    echo "IGCM_sys_Rm : error code ${status}" 
     538    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     539    IGCM_debug_Exit "IGCM_sys_Rm" 
     540  else 
     541    \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     542  fi 
     543  IGCM_debug_PopStack "IGCM_sys_Rm" 
     544} 
     545 
     546#D-#================================================== 
     547#D-function IGCM_sys_Mv 
     548#D-* Purpose: generic move 
     549#D-* Examples: 
     550#D- 
     551function IGCM_sys_Mv { 
     552  IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
     553  if ( $DEBUG_sys ) ; then 
     554    echo "IGCM_sys_Mv :" $@ 
     555  fi 
     556 
     557  if [ $DRYRUN = 0 ]; then 
     558 
     559    typeset status 
     560 
     561    echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     562    \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     563    status=$? 
     564 
     565    if [ ${status} -gt 0 ] ; then 
     566      echo "IGCM_sys_Mv : error code ${status}" 
     567      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     568      IGCM_debug_Exit "IGCM_sys_Mv" 
     569    else 
     570      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     571    fi 
     572  fi 
     573  IGCM_debug_PopStack "IGCM_sys_Mv" 
     574} 
     575 
     576#D-#================================================== 
     577#D-function IGCM_sys_Get_Master 
     578#D-* Purpose: Copy a complete directory from MASTER filesystem 
     579#D-* Examples: 
     580#D- 
     581function IGCM_sys_Get_Master { 
     582  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
     583  if ( $DEBUG_sys ) ; then 
     584    echo "IGCM_sys_Get_Master :" $@ 
     585  fi 
     586  if [ $DRYRUN = 0 ]; then 
     587    if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then 
     588      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
     589      IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     590      return 
     591    fi 
     592 
     593    typeset NB_ESSAI DELAI status i 
     594    # number of tentative 
     595    NB_ESSAI=3 
     596    # time delay between tentative 
     597    DELAI=2 
     598 
     599    i=0 
     600    while [ $i -lt $NB_ESSAI ] ; do 
     601      \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     602      status=$? 
     603      if [ ${status} -gt 0 ]; then 
     604        IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" 
     605        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 
     606        sleep $DELAI 
     607      else 
     608        break 
     609      fi 
     610      (( i = i + 1 )) 
     611    done 
     612 
     613    if [ ${status} -gt 0 ] ; then 
     614      echo "IGCM_sys_Get_Master : error." 
     615      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     616      IGCM_debug_Exit "IGCM_sys_Get_Master" 
     617    else 
     618      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     619    fi 
     620  fi 
     621  IGCM_debug_PopStack "IGCM_sys_Get_Master" 
     622} 
     623 
     624#==================================================== 
     625#- Call IGCM_sys_Mirror_libIGCM now ! 
     626if ( $MirrorlibIGCM ) ; then 
     627  IGCM_sys_Mirror_libIGCM 
     628fi 
     629 
     630#D-#================================================== 
     631#D-function IGCM_sys_PutBuffer_Rest 
     632#D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
     633#D-           File and target directory must exist. 
     634#D-* Examples: 
     635#D- 
     636function IGCM_sys_PutBuffer_Rest { 
     637  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
     638  if ( $DEBUG_sys ) ; then 
     639    echo "IGCM_sys_PutBuffer_Rest :" $@ 
     640  fi 
     641  if [ $DRYRUN = 0 ]; then 
     642    if [ ! -f ${1} ] ; then 
     643      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
     644      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     645    fi 
     646 
     647    typeset status 
     648    # 
     649    # USUAL WAY 
     650    \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     651    status=$? 
     652 
     653    if [ ${status} -gt 0 ] ; then 
     654      echo "IGCM_sys_PutBuffer_Rest : error code ${status}" 
     655      [ -f ${2} ] && ls -l ${2} 
     656      [ -f ${2}/${1} ] && ls -l ${2}/${1} 
     657      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     658      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
     659    else 
     660 
     661      if [ X${JobType} = XRUN ] ; then 
     662        [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
     663        [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
     664      fi 
     665 
     666      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     667    fi 
     668  fi 
     669  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
     670} 
     671 
     672#D-#================================================== 
     673#D-function IGCM_sys_PrepareTaredRestart 
     674#D-* Purpose: Prepare tared restart to be access by computing job. 
     675#D-* Examples: 
     676#D- 
     677function IGCM_sys_PrepareTaredRestart { 
     678  IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ 
     679  if [ $DRYRUN = 0 ]; then 
     680    [ ! -f $( basename $1 ) ] && IGCM_sys_Get $1 . 
     681  fi 
     682  IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" 
     683} 
     684 
     685#D-#================================================== 
     686#D-function IGCM_sys_PutBuffer_Out 
     687#D-* Purpose: Copy a file on the buffer filesystem after having chmod it in readonly 
     688#D-* Examples: 
     689#D- 
     690function IGCM_sys_PutBuffer_Out { 
     691  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
     692  if ( $DEBUG_sys ) ; then 
     693    echo "IGCM_sys_PutBuffer_Out :" $@ 
     694  fi 
     695 
     696  typeset NB_ESSAI DELAI status i exist skip 
     697 
     698  # number of tentative 
     699  NB_ESSAI=3 
     700  # time delay between tentative 
     701  DELAI=2 
     702 
     703  if [ $DRYRUN = 0 ]; then 
     704    if [ ! -f ${1} ] ; then 
     705      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
     706      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     707      return 1 
     708    fi 
     709    # 
     710    IGCM_sys_Mkdir $( dirname $2 ) 
     711    # 
     712 
     713    exist=false 
     714    skip=false 
     715    if [ -f $2 ] ; then 
     716      IGCM_debug_Print 1 "$2 already exist" 
     717      exist=true 
     718      if [ "X$( diff $1 $2 )" = X ] ; then 
     719        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
     720        status=0 
     721        skip=true 
     722      else 
     723        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
     724        skip=false 
     725      fi 
     726    fi 
     727    # 
     728    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
     729      IGCM_sys_Chmod u+w $2 
     730    fi 
     731 
     732    if [ X${skip} = Xfalse ] ; then 
     733      i=0 
     734      while [ $i -lt $NB_ESSAI ] ; do 
     735        if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then 
     736          # USUAL WAY 
     737          \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     738          status=$? 
     739        else 
     740          # NOT SO USUAL WAY 
     741          \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     742          status=$? 
     743        fi 
     744        if [ ${status} -gt 0 ]; then 
     745          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" 
     746          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 
     747          [ -f ${2} ] && ls -l ${2} 
     748          [ -f ${2}/${1} ] && ls -l ${2}/${1} 
     749          sleep $DELAI 
     750        else 
     751          break 
     752        fi 
     753        (( i = i + 1 )) 
     754      done 
     755    fi 
     756 
     757    if [ ${status} -gt 0 ] ; then 
     758      echo "IGCM_sys_PutBuffer_Out : error." 
     759      [ -f ${2} ] && ls -l ${2} 
     760      [ -f ${2}/${1} ] && ls -l ${2}/${1} 
     761      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     762      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
     763    else 
     764 
     765      if [ X${JobType} = XRUN ] ; then 
     766        if [ X${3} = X ] ; then 
     767          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
     768          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
     769        fi 
     770      fi 
     771 
     772      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     773    fi 
     774  fi 
     775  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
     776  return 0 
     777} 
     778 
     779#D-#================================================== 
     780#D-function IGCM_sys_GetBuffer 
     781#D-* Purpose: Get a file from ${SCRATCHDIR} 
     782#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
     783#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
     784function IGCM_sys_GetBuffer { 
     785  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
     786 
     787  typeset DEST buf_liste target file_work 
     788  typeset NB_ESSAI DELAI status i 
     789 
     790  if ( $DEBUG_sys ) ; then 
     791    echo "IGCM_sys_GetBuffer :" $@ 
     792  fi 
     793 
     794  # number of tentative 
     795  NB_ESSAI=3 
     796  # time delay between tentative 
     797  DELAI=2 
     798 
     799  if [ $DRYRUN -le 2 ]; then 
     800    if [ X${1} = X'/l' ] ; then 
     801      eval set +A buf_liste \${${2}} 
     802    else 
     803      eval set +A buf_liste ${1} 
     804    fi 
     805    eval DEST=\${${#}} 
     806 
     807    #USUAL WAY 
     808    if [ X${1} = X'/l' ] ; then 
     809      for target in ${buf_liste[*]} ; do 
     810        local_file=$( basename ${target} ) 
     811        i=0 
     812        while [ $i -lt $NB_ESSAI ] ; do 
     813          \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     814          status=$? 
     815          if [ ${status} -gt 0 ]; then 
     816            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
     817            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
     818            sleep $DELAI 
     819          else 
     820            break 
     821          fi 
     822          (( i = i + 1 )) 
     823        done 
     824        if [ ${status} -gt 0 ] ; then 
     825          echo "IGCM_sys_Get : error" 
     826          cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     827          \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     828          IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     829        else 
     830          \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     831        fi 
     832      done 
     833    else 
     834      i=0 
     835      while [ $i -lt $NB_ESSAI ] ; do 
     836        \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     837        status=$? 
     838        if [ ${status} -gt 0 ]; then 
     839          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
     840          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
     841          sleep $DELAI 
     842        else 
     843          break 
     844        fi 
     845        (( i = i + 1 )) 
     846      done 
     847      if [ ${status} -gt 0 ] ; then 
     848        echo "IGCM_sys_Get : error" 
     849        cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     850        \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     851        IGCM_debug_Exit "IGCM_sys_GetBuffer" 
     852      else 
     853        \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     854      fi 
     855    fi 
     856  fi 
     857  IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
     858} 
     859 
     860#D-#================================================== 
     861#D-function IGCM_sys_GetDate_FichWork 
     862#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
     863#D-* Examples: 
     864#D- 
     865function IGCM_sys_GetDate_FichWork { 
     866  IGCM_debug_PushStack "IGCM_sys_GetDate_FichWork" $@ 
     867  if ( $DEBUG_sys ) ; then 
     868    echo "IGCM_sys_GetDate_FichWork :" $@ 
     869  fi 
     870 
     871  if [ $# -ge 3 ] ; then 
     872    mode=$3 
     873    TimeStyle=$4 
     874  else 
     875    mode="default" 
     876    TimeStyle="%Y%m%d%H%M%S" 
     877  fi 
     878 
     879  typeset dateF 
     880  set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} ) 
     881 
     882  case $mode in 
     883    "default") 
     884      eval ${2}=${dateF[5]} 
     885      ;; 
     886    "SplitFields") 
     887      eval ${2}="${dateF[5]}\ ${dateF[6]}" 
     888      ;; 
     889  esac 
     890 
     891  # donne la date filesys d'un fichier sur la machine work 
     892  IGCM_debug_PopStack "IGCM_sys_GetDate_FichWork" 
     893} 
     894 
     895#D-#================================================== 
     896#D-function IGCM_sys_rebuild 
     897#D-* Purpose: rebuild parallel files 
     898#D-* Examples: 
     899#D- 
     900function IGCM_sys_rebuild { 
     901  IGCM_debug_PushStack "IGCM_sys_rebuild" $@ 
     902  if ( $DEBUG_sys ) ; then 
     903    echo "IGCM_sys_rebuild :" $@ 
     904  fi 
     905 
     906  typeset NB_ESSAI DELAI status i firstArg 
     907  # number of tentative 
     908  NB_ESSAI=3 
     909  # time delay between tentative 
     910  DELAI=2 
     911 
     912  i=0 
     913  while [ $i -lt $NB_ESSAI ] ; do 
     914    rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     915    status=$? 
     916    if [ ${status} -gt 0 ] ; then 
     917      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" 
     918      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     919      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     920      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     921      firstArg=${1} 
     922      \rm ${firstArg} 
     923      sleep $DELAI 
     924    else 
     925      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     926      break 
     927    fi 
     928    (( i = i + 1 )) 
     929  done 
     930 
     931  if [ ${status} -gt 0 ] ; then 
     932    echo "IGCM_sys_rebuild : rebuild error code is ${status}" 
     933    IGCM_debug_Exit "rebuild" 
     934  fi 
     935 
     936  IGCM_debug_PopStack "IGCM_sys_rebuild" 
     937} 
     938 
     939#D-#================================================== 
     940#D-function IGCM_sys_rebuild_station 
     941#D-* Purpose: rebuild parallel files describing station 
     942#D-* Examples: 
     943#D- 
     944function IGCM_sys_rebuild_station { 
     945  IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@ 
     946  typeset i list_opt file_in file_out prefix_invert list_invert 
     947  if ( $DEBUG_sys ) ; then 
     948    echo "IGCM_sys_rebuild_station :" $@ 
     949  fi 
     950 
     951  # Station re-ordering is too expansive to be run within libIGCM 
     952  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. 
     953  # This re-ordering must be done "in memory" by the cmorization process 
     954 
     955  # Only LMDZ text output contains the exact ordering of the station. 
     956  # We isolate this in the code below: 
     957  #  0  38  -157.5000000000000  70.98591549295774 
     958  #  0  54  27.49999999999999   67.18309859154928 
     959  #  0  56  -62.50000000000001  82.39436619718309 
     960  #  0  79  12.49999999999999   78.59154929577466 
     961  #  0  116 -165.0000000000000  76.05633802816901 
     962  #  0  117 130.0000000000000   70.98591549295774 
     963  #  0  118 110.0000000000000   87.46478873239437 
     964  #  1  40  4.999999999999995   51.97183098591550 
     965 
     966  list_opt=$@ 
     967 
     968  # Invert Axis : t,x -> x,t 
     969  #               t,pres,x -> x,t,pres 
     970  # So that we can concatenate along x 
     971  i=0 
     972  for file_in in ${list_opt} ; do 
     973    (( i = i + 1)) 
     974    [ ${i} = 1 ] && file_out=${file_in} && continue 
     975    # detect time counter and do the job only if present 
     976    var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') 
     977    if [ X${var_unlim} = Xtime_counter ] ; then 
     978      prefix_invert=$( basename ${file_in} .nc ) 
     979      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc 
     980      list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc 
     981    fi 
     982  done 
     983 
     984  # Concatenate 
     985  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc 
     986 
     987  # Re-ivert file 
     988  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} 
     989 
     990  IGCM_debug_PopStack "IGCM_sys_rebuild_station" 
     991} 
     992 
     993############################################################## 
     994# NCO OPERATOR 
     995 
     996#D-#================================================== 
     997#D-function IGCM_sys_ncap2 
     998#D-* Purpose: encapsulate ncap2 call so as to manage error code and retry 
     999#D-* Examples: 
     1000#D- 
     1001function IGCM_sys_ncap2 { 
     1002  IGCM_debug_PushStack "IGCM_sys_ncap2" $@ 
     1003  if ( $DEBUG_sys ) ; then 
     1004    echo "IGCM_sys_ncap2 :" $@ 
     1005  fi 
     1006 
     1007  typeset NB_ESSAI DELAI status i 
     1008  # number of tentative 
     1009  NB_ESSAI=3 
     1010  # time delay between tentative 
     1011  DELAI=2 
     1012 
     1013  i=0 
     1014  while [ $i -lt $NB_ESSAI ] ; do 
     1015    ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1016    status=$? 
     1017    if [ ${status} -gt 0 ] ; then 
     1018      IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" 
     1019      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1020      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1021      IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1022      sleep $DELAI 
     1023    else 
     1024      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1025      break 
     1026    fi 
     1027    (( i = i + 1 )) 
     1028  done 
     1029 
     1030  if [ ${status} -gt 0 ] ; then 
     1031    echo "IGCM_sys_ncap2 : ncap2 error" 
     1032    IGCM_debug_Exit "ncap2" 
     1033  fi 
     1034 
     1035  IGCM_debug_PopStack "IGCM_sys_ncap2" 
     1036} 
     1037 
     1038#D-#================================================== 
     1039#D-function IGCM_sys_ncatted 
     1040#D-* Purpose: encapsulate ncatted call so as to manage error code and retry 
     1041#D-* Examples: 
     1042#D- 
     1043function IGCM_sys_ncatted { 
     1044  IGCM_debug_PushStack "IGCM_sys_ncatted" $@ 
     1045  if ( $DEBUG_sys ) ; then 
     1046    echo "IGCM_sys_ncatted :" $@ 
     1047  fi 
     1048 
     1049  typeset NB_ESSAI DELAI status i 
     1050  # number of tentative 
     1051  NB_ESSAI=3 
     1052  # time delay between tentative 
     1053  DELAI=2 
     1054 
     1055  i=0 
     1056  while [ $i -lt $NB_ESSAI ] ; do 
     1057    ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1058    status=$? 
     1059    if [ ${status} -gt 0 ] ; then 
     1060      IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" 
     1061      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1062      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1063      IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1064      sleep $DELAI 
     1065    else 
     1066      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1067      break 
     1068    fi 
     1069    (( i = i + 1 )) 
     1070  done 
     1071 
     1072  if [ ${status} -gt 0 ] ; then 
     1073    echo "IGCM_sys_ncatted : ncatted error" 
     1074    IGCM_debug_Exit "ncatted" 
     1075  fi 
     1076 
     1077  IGCM_debug_PopStack "IGCM_sys_ncatted" 
     1078} 
     1079 
     1080#D-#================================================== 
     1081#D-function IGCM_sys_ncbo 
     1082#D-* Purpose: encapsulate ncbo call so as to manage error code and retry 
     1083#D-* Examples: 
     1084#D- 
     1085function IGCM_sys_ncbo { 
     1086  IGCM_debug_PushStack "IGCM_sys_ncbo" $@ 
     1087  if ( $DEBUG_sys ) ; then 
     1088    echo "IGCM_sys_ncbo :" $@ 
     1089  fi 
     1090 
     1091  typeset NB_ESSAI DELAI status i 
     1092  # number of tentative 
     1093  NB_ESSAI=3 
     1094  # time delay between tentative 
     1095  DELAI=2 
     1096 
     1097  i=0 
     1098  while [ $i -lt $NB_ESSAI ] ; do 
     1099    ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1100    status=$? 
     1101    if [ ${status} -gt 0 ] ; then 
     1102      IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" 
     1103      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1104      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1105      IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1106      sleep $DELAI 
     1107    else 
     1108      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1109      break 
     1110    fi 
     1111    (( i = i + 1 )) 
     1112  done 
     1113 
     1114  if [ ${status} -gt 0 ] ; then 
     1115    echo "IGCM_sys_ncbo : ncbo error" 
     1116    IGCM_debug_Exit "ncbo" 
     1117  fi 
     1118 
     1119  IGCM_debug_PopStack "IGCM_sys_ncbo" 
     1120} 
     1121 
     1122#D-#================================================== 
     1123#D-function IGCM_sys_ncdif 
     1124#D-* Purpose: encapsulate ncdiff call so as to manage error code and retry 
     1125#D-* Examples: 
     1126#D- 
     1127function IGCM_sys_ncdiff { 
     1128  IGCM_debug_PushStack "IGCM_sys_ncdiff" $@ 
     1129  if ( $DEBUG_sys ) ; then 
     1130    echo "IGCM_sys_ncdiff :" $@ 
     1131  fi 
     1132 
     1133  typeset NB_ESSAI DELAI status i 
     1134  # number of tentative 
     1135  NB_ESSAI=3 
     1136  # time delay between tentative 
     1137  DELAI=2 
     1138 
     1139  i=0 
     1140  while [ $i -lt $NB_ESSAI ] ; do 
     1141    ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1142    status=$? 
     1143    if [ ${status} -gt 0 ] ; then 
     1144      IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" 
     1145      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1146      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1147      IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1148      sleep $DELAI 
     1149    else 
     1150      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1151      break 
     1152    fi 
     1153    (( i = i + 1 )) 
     1154  done 
     1155 
     1156  if [ ${status} -gt 0 ] ; then 
     1157    echo "IGCM_sys_ncdiff : ncdiff error" 
     1158    IGCM_debug_Exit "ncdiff" 
     1159  fi 
     1160 
     1161  IGCM_debug_PopStack "IGCM_sys_ncdiff" 
     1162} 
     1163 
     1164#D-#================================================== 
     1165#D-function IGCM_sys_ncea 
     1166#D-* Purpose: encapsulate ncea call so as to manage error code and retry 
     1167#D-* Examples: 
     1168#D- 
     1169function IGCM_sys_ncea { 
     1170  IGCM_debug_PushStack "IGCM_sys_ncea" $@ 
     1171  if ( $DEBUG_sys ) ; then 
     1172    echo "IGCM_sys_ncea :" $@ 
     1173  fi 
     1174 
     1175  typeset NB_ESSAI DELAI status i 
     1176  # number of tentative 
     1177  NB_ESSAI=3 
     1178  # time delay between tentative 
     1179  DELAI=2 
     1180 
     1181  i=0 
     1182  while [ $i -lt $NB_ESSAI ] ; do 
     1183    ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1184    status=$? 
     1185    if [ ${status} -gt 0 ] ; then 
     1186      IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" 
     1187      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1188      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1189      IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1190      sleep $DELAI 
     1191    else 
     1192      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1193      break 
     1194    fi 
     1195    (( i = i + 1 )) 
     1196  done 
     1197 
     1198  if [ ${status} -gt 0 ] ; then 
     1199    echo "IGCM_sys_ncea : ncea error" 
     1200    IGCM_debug_Exit "ncea" 
     1201  fi 
     1202 
     1203  IGCM_debug_PopStack "IGCM_sys_ncea" 
     1204} 
     1205 
     1206#D-#================================================== 
     1207#D-function IGCM_sys_ncecat 
     1208#D-* Purpose: encapsulate ncecat call so as to manage error code and retry 
     1209#D-* Examples: 
     1210#D- 
     1211function IGCM_sys_ncecat { 
     1212  IGCM_debug_PushStack "IGCM_sys_ncecat" $@ 
     1213  if ( $DEBUG_sys ) ; then 
     1214    echo "IGCM_sys_ncecat :" $@ 
     1215  fi 
     1216 
     1217  typeset NB_ESSAI DELAI status i 
     1218  # number of tentative 
     1219  NB_ESSAI=3 
     1220  # time delay between tentative 
     1221  DELAI=2 
     1222 
     1223  i=0 
     1224  while [ $i -lt $NB_ESSAI ] ; do 
     1225    ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1226    status=$? 
     1227    if [ ${status} -gt 0 ] ; then 
     1228      IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" 
     1229      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1230      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1231      IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1232      sleep $DELAI 
     1233    else 
     1234      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1235      break 
     1236    fi 
     1237    (( i = i + 1 )) 
     1238  done 
     1239 
     1240  if [ ${status} -gt 0 ] ; then 
     1241    echo "IGCM_sys_ncecat : ncecat error" 
     1242    IGCM_debug_Exit "ncecat" 
     1243  fi 
     1244 
     1245  IGCM_debug_PopStack "IGCM_sys_ncecat" 
     1246} 
     1247 
     1248#D-#================================================== 
     1249#D-function IGCM_sys_ncflint 
     1250#D-* Purpose: encapsulate ncflint call so as to manage error code and retry 
     1251#D-* Examples: 
     1252#D- 
     1253function IGCM_sys_ncflint { 
     1254  IGCM_debug_PushStack "IGCM_sys_ncflint" $@ 
     1255  if ( $DEBUG_sys ) ; then 
     1256    echo "IGCM_sys_ncflint :" $@ 
     1257  fi 
     1258 
     1259  typeset NB_ESSAI DELAI status i 
     1260  # number of tentative 
     1261  NB_ESSAI=3 
     1262  # time delay between tentative 
     1263  DELAI=2 
     1264 
     1265  i=0 
     1266  while [ $i -lt $NB_ESSAI ] ; do 
     1267    ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1268    status=$? 
     1269    if [ ${status} -gt 0 ] ; then 
     1270      IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" 
     1271      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1272      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1273      IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1274      sleep $DELAI 
     1275    else 
     1276      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1277      break 
     1278    fi 
     1279    (( i = i + 1 )) 
     1280  done 
     1281 
     1282  if [ ${status} -gt 0 ] ; then 
     1283    echo "IGCM_sys_ncflint : ncflint error" 
     1284    IGCM_debug_Exit "ncflint" 
     1285  fi 
     1286 
     1287  IGCM_debug_PopStack "IGCM_sys_ncflint" 
     1288} 
     1289 
     1290#D-#================================================== 
     1291#D-function IGCM_sys_ncks 
     1292#D-* Purpose: encapsulate ncks call so as to manage error code and retry 
     1293#D-* Examples: 
     1294#D- 
     1295function IGCM_sys_ncks { 
     1296  IGCM_debug_PushStack "IGCM_sys_ncks" $@ 
     1297  if ( $DEBUG_sys ) ; then 
     1298    echo "IGCM_sys_ncks :" $@ 
     1299  fi 
     1300 
     1301  typeset NB_ESSAI DELAI status i 
     1302  # number of tentative 
     1303  NB_ESSAI=3 
     1304  # time delay between tentative 
     1305  DELAI=2 
     1306 
     1307  i=0 
     1308  while [ $i -lt $NB_ESSAI ] ; do 
     1309    ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1310    status=$? 
     1311    if [ ${status} -gt 0 ] ; then 
     1312      IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" 
     1313      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1314      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1315      IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1316      sleep $DELAI 
     1317    else 
     1318      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1319      break 
     1320    fi 
     1321    (( i = i + 1 )) 
     1322  done 
     1323 
     1324  if [ ${status} -gt 0 ] ; then 
     1325    echo "IGCM_sys_ncks : ncks error" 
     1326    IGCM_debug_Exit "ncks" 
     1327  fi 
     1328 
     1329  IGCM_debug_PopStack "IGCM_sys_ncks" 
     1330} 
     1331 
     1332#D-#================================================== 
     1333#D-function IGCM_sys_ncpdq 
     1334#D-* Purpose: encapsulate ncpdq call so as to manage error code and retry 
     1335#D-* Examples: 
     1336#D- 
     1337function IGCM_sys_ncpdq { 
     1338  IGCM_debug_PushStack "IGCM_sys_ncpdq" $@ 
     1339  if ( $DEBUG_sys ) ; then 
     1340    echo "IGCM_sys_ncpdq :" $@ 
     1341  fi 
     1342 
     1343  typeset NB_ESSAI DELAI status i 
     1344  # number of tentative 
     1345  NB_ESSAI=3 
     1346  # time delay between tentative 
     1347  DELAI=2 
     1348 
     1349  i=0 
     1350  while [ $i -lt $NB_ESSAI ] ; do 
     1351    ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1352    status=$? 
     1353    if [ ${status} -gt 0 ] ; then 
     1354      IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" 
     1355      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1356      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1357      IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1358      sleep $DELAI 
     1359    else 
     1360      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1361      break 
     1362    fi 
     1363    (( i = i + 1 )) 
     1364  done 
     1365 
     1366  if [ ${status} -gt 0 ] ; then 
     1367    echo "IGCM_sys_ncpdq : ncpdq error" 
     1368    IGCM_debug_Exit "ncpdq" 
     1369  fi 
     1370 
     1371  IGCM_debug_PopStack "IGCM_sys_ncpdq" 
     1372} 
     1373 
     1374#D-#================================================== 
     1375#D-function IGCM_sys_ncra 
     1376#D-* Purpose: encapsulate ncra call so as to manage error code and retry 
     1377#D-* Examples: 
     1378#D- 
     1379function IGCM_sys_ncra { 
     1380  IGCM_debug_PushStack "IGCM_sys_ncra" $@ 
     1381  if ( $DEBUG_sys ) ; then 
     1382    echo "IGCM_sys_ncra :" $@ 
     1383  fi 
     1384 
     1385  typeset NB_ESSAI DELAI status i 
     1386  # number of tentative 
     1387  NB_ESSAI=3 
     1388  # time delay between tentative 
     1389  DELAI=2 
     1390 
     1391  i=0 
     1392  while [ $i -lt $NB_ESSAI ] ; do 
     1393    ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1394    status=$? 
     1395    if [ ${status} -gt 0 ] ; then 
     1396      IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" 
     1397      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1398      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1399      IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1400      sleep $DELAI 
     1401    else 
     1402      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1403      break 
     1404    fi 
     1405    (( i = i + 1 )) 
     1406  done 
     1407 
     1408  if [ ${status} -gt 0 ] ; then 
     1409    echo "IGCM_sys_ncra : ncra error" 
     1410    IGCM_debug_Exit "ncra" 
     1411  fi 
     1412 
     1413  IGCM_debug_PopStack "IGCM_sys_ncra" 
     1414} 
     1415 
     1416#D-#================================================== 
     1417#D-function IGCM_sys_ncrcat 
     1418#D-* Purpose: encapsulate ncrcat call so as to manage error code and retry 
     1419#D-* Examples: 
     1420#D- 
     1421function IGCM_sys_ncrcat { 
     1422  IGCM_debug_PushStack "IGCM_sys_ncrcat" $@ 
     1423  if ( $DEBUG_sys ) ; then 
     1424    echo "IGCM_sys_ncrcat :" $@ 
     1425  fi 
     1426 
     1427  typeset NB_ESSAI DELAI status i lastArg 
     1428  # number of tentative 
     1429  NB_ESSAI=3 
     1430  # time delay between tentative 
     1431  DELAI=2 
     1432 
     1433  i=0 
     1434  while [ $i -lt $NB_ESSAI ] ; do 
     1435    ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1436    status=$? 
     1437    if [ ${status} -gt 0 ] ; then 
     1438      IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" 
     1439      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1440      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1441      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1442      sleep $DELAI 
     1443    elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then 
     1444      IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" 
     1445      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1446      # remove files having corrupted time axis 
     1447      eval lastArg=\${$#} 
     1448      IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" 
     1449      \rm ${lastArg} 
     1450      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1451      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1452      sleep $DELAI 
     1453    else 
     1454      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1455      break 
     1456    fi 
     1457    (( i = i + 1 )) 
     1458  done 
     1459 
     1460  if [ ${status} -gt 0 ] ; then 
     1461    echo "IGCM_sys_ncrcat : ncrcat error" 
     1462    #IGCM_debug_Exit "ncrcat" 
     1463  fi 
     1464 
     1465  IGCM_debug_PopStack "IGCM_sys_ncrcat" 
     1466} 
     1467 
     1468#D-#================================================== 
     1469#D-function IGCM_sys_ncrename 
     1470#D-* Purpose: encapsulate ncrename call so as to manage error code and retry 
     1471#D-* Examples: 
     1472#D- 
     1473function IGCM_sys_ncrename { 
     1474  IGCM_debug_PushStack "IGCM_sys_ncrename" $@ 
     1475  if ( $DEBUG_sys ) ; then 
     1476    echo "IGCM_sys_ncrename :" $@ 
     1477  fi 
     1478 
     1479  typeset NB_ESSAI DELAI status i 
     1480  # number of tentative 
     1481  NB_ESSAI=3 
     1482  # time delay between tentative 
     1483  DELAI=2 
     1484 
     1485  i=0 
     1486  while [ $i -lt $NB_ESSAI ] ; do 
     1487    ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1488    status=$? 
     1489    if [ ${status} -gt 0 ] ; then 
     1490      IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" 
     1491      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1492      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1493      IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1494      sleep $DELAI 
     1495    else 
     1496      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1497      break 
     1498    fi 
     1499    (( i = i + 1 )) 
     1500  done 
     1501 
     1502  if [ ${status} -gt 0 ] ; then 
     1503    echo "IGCM_sys_ncrename : ncrename error" 
     1504    IGCM_debug_Exit "ncrename" 
     1505  fi 
     1506 
     1507  IGCM_debug_PopStack "IGCM_sys_ncrename" 
     1508} 
     1509 
     1510#D-#================================================== 
     1511#D-function IGCM_sys_ncwa 
     1512#D-* Purpose: encapsulate ncwa call so as to manage error code and retry 
     1513#D-* Examples: 
     1514#D- 
     1515function IGCM_sys_ncwa { 
     1516  IGCM_debug_PushStack "IGCM_sys_ncwa" $@ 
     1517  if ( $DEBUG_sys ) ; then 
     1518    echo "IGCM_sys_ncwa :" $@ 
     1519  fi 
     1520 
     1521  typeset NB_ESSAI DELAI status i 
     1522  # number of tentative 
     1523  NB_ESSAI=3 
     1524  # time delay between tentative 
     1525  DELAI=2 
     1526 
     1527  i=0 
     1528  while [ $i -lt $NB_ESSAI ] ; do 
     1529    ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1530    status=$? 
     1531    if [ ${status} -gt 0 ] ; then 
     1532      IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" 
     1533      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1534      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1535      IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
     1536      sleep $DELAI 
     1537    else 
     1538      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1539      break 
     1540    fi 
     1541    (( i = i + 1 )) 
     1542  done 
     1543 
     1544  if [ ${status} -gt 0 ] ; then 
     1545    echo "IGCM_sys_ncwa : ncwa error" 
     1546    IGCM_debug_Exit "ncwa" 
     1547  fi 
     1548 
     1549  IGCM_debug_PopStack "IGCM_sys_ncwa" 
     1550} 
     1551 
     1552############################################################## 
     1553# CDO OPERATOR 
     1554 
     1555#D-#================================================== 
     1556#D-function IGCM_sys_cdo 
     1557#D-* Purpose: encapsulate cdo call so as to manage error code and retry 
     1558#D-* Examples: 
     1559#D- 
     1560function IGCM_sys_cdo { 
     1561  IGCM_debug_PushStack "IGCM_sys_cdo" $@ 
     1562  if ( $DEBUG_sys ) ; then 
     1563    echo "IGCM_sys_cdo :" $@ 
     1564  fi 
     1565 
     1566  typeset status 
     1567 
     1568  \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
     1569  status=$? 
     1570  if [ ${status} -gt 0 ] ; then 
     1571    echo "IGCM_sys_cdo : error code ${status}" 
     1572    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1573    \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
     1574    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1575    return 1 
     1576  else 
     1577    IGCM_debug_PopStack "IGCM_sys_cdo" 
     1578    return 0 
     1579  fi 
     1580 
     1581  IGCM_debug_PopStack "IGCM_sys_cdo" 
     1582} 
     1583 
     1584#  
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh

    r1180 r1181  
    219219 
    220220#D-#================================================== 
    221 #D-function IGCM_sys_RshMaster 
    222 #D-* Purpose: Connection to frontend machine. 
    223 #D-* Examples: 
    224 #D- 
    225 function IGCM_sys_RshMaster { 
    226   IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    227   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF 
    228     export libIGCM=${libIGCM} 
    229     export DEBUG_debug=${DEBUG_debug} 
    230     . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
    231     . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
    232     ${@} 
    233 EOF 
    234   if [ $? -gt 0 ] ; then 
    235     echo "IGCM_sys_RshMaster : erreur." 
    236     IGCM_debug_Exit "IGCM_sys_RshMaster" 
    237   fi 
    238   IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    239 } 
    240  
    241 #D-#================================================== 
    242221#D-function IGCM_sys_RshArchive 
    243222#D-* Purpose: Archive rsh command 
     
    287266 
    288267#D-#================================================== 
    289 #D-function IGCM_sys_RshPost 
    290 #D-* Purpose: Post-process rsh command 
    291 #D-* Examples: 
    292 #D- 
    293 function IGCM_sys_RshPost { 
    294   IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    295   if ( $DEBUG_sys ) ; then 
    296     echo "IGCM_sys_RshPost :" $@ 
    297   fi 
    298   # keep standard input (stdin) for the loop onto temporary file 
    299   cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    300  
    301   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    302   if [ $? -gt 0 ] ; then 
    303     echo "IGCM_sys_RshPost : erreur." 
    304     IGCM_debug_Exit "IGCM_sys_RshPost" 
    305   fi 
    306   # delete temporary file 
    307   \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    308  
    309   IGCM_debug_PopStack "IGCM_sys_RshPost" 
    310 } 
    311  
    312 #D-#================================================== 
    313 #D-function IGCM_sys_SendMail 
    314 #D-* Purpose: Send mail when simulation is over 
    315 #D-* Examples: 
    316 #D- 
    317 function IGCM_sys_SendMail { 
    318   IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    319   if ( $DEBUG_sys ) ; then 
    320     echo "IGCM_sys_SendMail :" $@ 
    321   fi 
    322  
    323   if [ X${1} = XAccounting ] ; then 
    324     status=Accounting 
    325     mailText=jobAccounting.mail 
    326   elif ( ${ExitFlag} ) ; then 
    327     status=failed 
    328     mailText=jobEnd.mail 
    329   else 
    330     status=completed 
    331     mailText=jobEnd.mail 
    332   fi 
    333  
    334   # Update selected mail template 
    335   while read -r line; do 
    336     eval echo $line >> mail.txt ; 
    337   done < ${libIGCM}/libIGCM_sys/${mailText} 
    338  
    339   if [ ! -z ${config_UserChoices_MailName} ] ; then 
    340     mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt 
    341   elif [ -f ~/.forward ] ; then 
    342     mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt 
    343   else 
    344     mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt 
    345   fi 
    346  
    347   sleep 10 
    348   rm -f mail.txt 
    349  
    350   IGCM_debug_PopStack "IGCM_sys_SendMail" 
    351 } 
    352  
    353 #D-#================================================== 
    354 #D-function IGCM_sys_Mkdir 
    355 #D-* Purpose: Master locale mkdir command 
    356 #D-* Examples: 
    357 #D- 
    358 function IGCM_sys_Mkdir { 
    359   IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    360   if ( $DEBUG_sys ) ; then 
    361     echo "IGCM_sys_Mkdir :" $@ 
    362   fi 
    363   if [ ! -d ${1} ]; then 
    364     \mkdir -p $1 
    365     if [ $? -gt 0 ] ; then 
    366       echo "IGCM_sys_Mkdir : erreur." 
    367       IGCM_debug_Exit "IGCM_sys_Mkdir" 
    368     fi 
    369   fi 
    370   # vérification : 
    371   if [ ! -d ${1} ] ; then 
    372     echo "IGCM_sys_Mkdir : erreur." 
    373     IGCM_debug_Exit "IGCM_sys_Mkdir" 
    374   fi 
    375   IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    376 } 
    377  
    378 #D-#================================================== 
    379268#D-function IGCM_sys_MkdirArchive 
    380269#D-* Purpose: Mkdir on Archive 
     
    404293 
    405294#D-#================================================== 
    406 #D-function IGCM_sys_MkdirWork 
    407 #D-* Purpose: Mkdir on Work 
    408 #D-* Examples: 
    409 #D- 
    410 function IGCM_sys_MkdirWork { 
    411   IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    412   if ( $DEBUG_sys ) ; then 
    413     echo "IGCM_sys_MkdirWork :" $@ 
    414   fi 
    415   #- creation de repertoire sur le serveur fichier 
    416   if [ ! -d ${1} ]; then 
    417     \mkdir -p $1 
    418     if [ $? -gt 0 ] ; then 
    419       echo "IGCM_sys_MkdirWork : erreur." 
    420       IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    421     fi 
    422   fi 
    423   IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    424 } 
    425  
    426 #D-#================================================== 
    427 #D-function IGCM_sys_Cd 
    428 #D-* Purpose: master cd command 
    429 #D-* Examples: 
    430 #D- 
    431 function IGCM_sys_Cd { 
    432   IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    433   if ( $DEBUG_sys ) ; then 
    434     echo "IGCM_sys_Cd :" $@ 
    435   fi 
    436   \cd $1 
    437   if [ $? -gt 0 ] ; then 
    438     echo "IGCM_sys_Cd : erreur." 
    439     IGCM_debug_Exit "IGCM_sys_Cd" 
    440   fi 
    441   IGCM_debug_PopStack "IGCM_sys_Cd" 
    442 } 
    443  
    444 #D-#================================================== 
    445 #D-function IGCM_sys_Chmod 
    446 #D-* Purpose: Chmod 
    447 #D-* Examples: 
    448 #D- 
    449 function IGCM_sys_Chmod { 
    450   IGCM_debug_PushStack "IGCM_sys_Chmod" $@ 
    451   if ( $DEBUG_sys ) ; then 
    452     echo "IGCM_sys_Chmod :" $@ 
    453   fi 
    454   \chmod $@ 
    455   if [ $? -gt 0 ] ; then 
    456     echo "IGCM_sys_Chmod : erreur." 
    457     IGCM_debug_Exit "IGCM_sys_Chmod" 
    458   fi 
    459   IGCM_debug_PopStack "IGCM_sys_Chmod" 
    460 } 
    461  
    462 #D-#================================================== 
    463 #D-function IGCM_sys_FileSize 
    464 #D-* Purpose: Filesize 
    465 #D-* Examples: 
    466 #D- 
    467 function IGCM_sys_FileSize { 
    468   IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    469  
    470   typeset sizeF 
    471   set +A sizeF -- $( ls -la ${1} ) 
    472   if [ $? -gt 0 ] ; then 
    473     IGCM_debug_Exit "IGCM_sys_FileSize" 
    474   fi 
    475   eval ${2}=${sizeF[4]} 
    476  
    477   IGCM_debug_PopStack "IGCM_sys_FileSize" 
    478 } 
    479  
    480 #D-#================================================== 
    481 #D-function IGCM_sys_TestDir 
    482 #D-* Purpose: Test Directory that must exists 
    483 #D-* Examples: 
    484 #D- 
    485 function IGCM_sys_TestDir { 
    486   IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    487   if ( $DEBUG_sys ) ; then 
    488     echo "IGCM_sys_TestDir :" $@ 
    489   fi 
    490   typeset ExistFlag 
    491   ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    492   IGCM_debug_PopStack "IGCM_sys_TestDir" 
    493  
    494   return ${ExistFlag} 
    495 } 
    496  
    497 #D-#================================================== 
    498295#D-function IGCM_sys_TestDirArchive 
    499296#D-* Purpose: Test Directory that must exists on Archive 
     
    544341  ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) 
    545342  IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 
    546  
    547   return ${ExistFlag} 
    548 } 
    549  
    550 #D-#================================================== 
    551 #D-function IGCM_sys_TestFileBuffer 
    552 #D-* Purpose: Test file that must NOT EXISTS on Buffer 
    553 #D-* Examples: 
    554 #D- 
    555 function IGCM_sys_TestFileBuffer { 
    556   IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
    557   typeset ExistFlag 
    558   ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    559   IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
    560343 
    561344  return ${ExistFlag} 
     
    585368 
    586369#D-#================================================== 
    587 #D-function IGCM_sys_CountFileBuffer 
    588 #D-* Purpose: Count files on Scratch filesystem 
    589 #D-* Examples: 
    590 #D- 
    591 function IGCM_sys_CountFileBuffer { 
    592   IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
    593   ls ${@} 2>/dev/null | wc -l 
    594   if [ $? -gt 0 ] ; then 
    595     echo "IGCM_sys_CountFileBuffer : erreur." 
    596   fi 
    597   IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    598 } 
    599  
    600 #D-#================================================== 
    601370#D-function IGCM_sys_Tree 
    602371#D-* Purpose: Tree directories with files on ${ARCHIVE} 
     
    612381 
    613382  IGCM_debug_PopStack "IGCM_sys_Tree" 
    614 } 
    615  
    616 #D-#================================================== 
    617 #D-function IGCM_sys_Tar 
    618 #D-* Purpose: master tar command 
    619 #D-* Examples: 
    620 #D- 
    621 function IGCM_sys_Tar { 
    622   IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    623   if ( $DEBUG_sys ) ; then 
    624     echo "IGCM_sys_Tar :" $@ 
    625   fi 
    626   \tar cf $@ 
    627   if [ $? -gt 0 ] ; then 
    628     echo "IGCM_sys_Tar : erreur." 
    629     IGCM_debug_Exit "IGCM_sys_Tar" 
    630   fi 
    631   IGCM_debug_PopStack "IGCM_sys_Tar" 
    632 } 
    633  
    634 #D-#================================================== 
    635 #D-function IGCM_sys_UnTar 
    636 #D-* Purpose: master un-tar command 
    637 #D-* Examples: 
    638 #D- 
    639 function IGCM_sys_UnTar { 
    640   IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    641   if ( $DEBUG_sys ) ; then 
    642     echo "IGCM_sys_UnTar :" $@ 
    643   fi 
    644   \tar xvf $1 
    645   if [ $? -gt 0 ] ; then 
    646     echo "IGCM_sys_UnTar : erreur." 
    647     IGCM_debug_Exit "IGCM_sys_UnTar" 
    648   fi 
    649   IGCM_debug_PopStack "IGCM_sys_UnTar" 
    650383} 
    651384 
     
    720453 
    721454#D-#================================================== 
    722 #D-function IGCM_sys_Rsync_out 
    723 #D-* Purpose: treat return val of rsync 
    724 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync 
    725 #D-  Error values and explanations can depend on your system version. 
    726 function IGCM_sys_Rsync_out { 
    727   status=$1 
    728   if [ ! $status ] ; then 
    729     echo "rsync error !" 
    730   fi 
    731  
    732   if [ $MYLANG = "fr" ]; then 
    733     case $status in 
    734     0)  return ;; 
    735     1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    736       echo "Erreur de syntaxe ou d'utilisation." 
    737       return;; 
    738     2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    739       echo "Incompatibilité de protocole." 
    740       return;; 
    741     3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    742       echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    743       echo "répertoires" 
    744       return;; 
    745     4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    746       echo "Action demandée non supportée : une tentative de manipulation de" 
    747       echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    748       echo "été faite ; ou une option qui est supportée par le  client  mais" 
    749       echo "pas par le serveur a été spécifiée." 
    750       return;; 
    751     10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    752       echo "Erreur dans le socket d'entrée sortie" 
    753       return;; 
    754     11) echo "Erreur de rsync ; RERR_FILEIO" 
    755       echo "Erreur d'entrée sortie fichier" 
    756       return;; 
    757     12) echo "Erreur de rsync ; RERR_STREAMIO" 
    758       echo "Erreur dans flux de donnée du protocole rsync" 
    759       return;; 
    760     13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    761       echo "Erreur avec les diagnostics du programme" 
    762       return;; 
    763     14) echo "Erreur de rsync ; RERR_IPC" 
    764       echo "Erreur dans le code IPC" 
    765       return;; 
    766     20) echo "Erreur de rsync ; RERR_SIGNAL" 
    767       echo "SIGUSR1 ou SIGINT reçu" 
    768       return;; 
    769     21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    770       echo "Une erreur retournée par waitpid()" 
    771       return;; 
    772     22) echo "Erreur de rsync ; RERR_MALLOC" 
    773       echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    774       return;; 
    775     23) echo "" 
    776       echo "Erreur fichier inexistant" 
    777       return;; 
    778     30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    779       echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    780       return;; 
    781     *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status 
    782       return;; 
    783     esac 
    784   elif [ $MYLANG = "en" ] ; then 
    785     case $status in 
    786     0)  return;; 
    787     1)  echo "rsync error : Syntax or usage error " 
    788       return;; 
    789     2)  echo "rsync error : Protocol incompatibility " 
    790       return;; 
    791     3)  echo "rsync error : Errors selecting input/output files, dirs" 
    792       return;; 
    793     4)  echo "rsync error : Requested action not supported: an attempt" 
    794       echo "was made to manipulate 64-bit files on a platform that cannot support" 
    795       echo "them; or an option was specified that is supported by the client and" 
    796       echo "not by the server." 
    797       return;; 
    798     5)  echo "rsync error : Error starting client-server protocol" 
    799       return;; 
    800     10) echo "rsync error : Error in socket I/O " 
    801       return;; 
    802     11) echo "rsync error : Error in file I/O " 
    803       return;; 
    804     12) echo "rsync error : Error in rsync protocol data stream " 
    805       return;; 
    806     13) echo "rsync error : Errors with program diagnostics " 
    807       return;; 
    808     14) echo "rsync error : Error in IPC code " 
    809       return;; 
    810     20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    811       return;; 
    812     21) echo "rsync error : Some error returned by waitpid() " 
    813       return;; 
    814     22) echo "rsync error : Error allocating core memory buffers " 
    815       return;; 
    816     23) echo "rsync error : Partial transfer due to error" 
    817       return;; 
    818     24) echo "rsync error : Partial transfer due to vanished source files" 
    819       return;; 
    820     30) echo "rsync error : Timeout in data send/receive " 
    821       return;; 
    822     *)  echo "rsync error : return code of rsync unknown :" $status 
    823       return;; 
    824     esac 
    825   else 
    826     echo "unknown language $MYLANG." 
    827     return 
    828   fi 
    829 } 
    830  
    831 #D-#================================================== 
    832 #D-function IGCM_sys_Miror_libIGCM 
    833 #D-* Purpose: Mirror libIGCM PATH and lib to frontend 
    834 #D-* Examples: 
    835 #D- 
    836 function IGCM_sys_Mirror_libIGCM { 
    837   IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    838   if ( $DEBUG_sys ) ; then 
    839     echo "IGCM_sys_Mirror_libIGCM" 
    840   fi 
    841  
    842   typeset status 
    843  
    844   mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    845  
    846   echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    847   ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    848   status=$? 
    849  
    850   if [ ${status} -gt 0 ] ; then 
    851     echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." 
    852     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    853   fi 
    854   IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    855 } 
    856  
    857 #D-#================================================== 
    858 #D-function IGCM_sys_Cp 
    859 #D-* Purpose: generic cp 
    860 #D-* Examples: 
    861 #D- 
    862 function IGCM_sys_Cp { 
    863   IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    864   if ( $DEBUG_sys ) ; then 
    865     echo "IGCM_sys_Cp :" $@ 
    866   fi 
    867  
    868   typeset status 
    869  
    870   echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    871   \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    872   status=$? 
    873  
    874   if [ ${status} -gt 0 ] ; then 
    875     echo "IGCM_sys_Cp : error code ${status}" 
    876     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    877     IGCM_debug_Exit "IGCM_sys_Cp" 
    878   else 
    879     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    880   fi 
    881   IGCM_debug_PopStack "IGCM_sys_Cp" 
    882 } 
    883  
    884 #D-#================================================== 
    885 #D-function IGCM_sys_Rm 
    886 #D-* Purpose: generic rm 
    887 #D-* Examples: 
    888 #D- 
    889 function IGCM_sys_Rm { 
    890   IGCM_debug_PushStack "IGCM_sys_Rm" $@ 
    891   if ( $DEBUG_sys ) ; then 
    892     echo "IGCM_sys_Rm :" $@ 
    893   fi 
    894  
    895   typeset status 
    896  
    897   echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    898   \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    899   status=$? 
    900  
    901   if [ ${status} -gt 0 ] ; then 
    902     echo "IGCM_sys_Rm : error code ${status}" 
    903     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    904     IGCM_debug_Exit "IGCM_sys_Rm" 
    905   else 
    906     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    907   fi 
    908   IGCM_debug_PopStack "IGCM_sys_Rm" 
    909 } 
    910  
    911 #D-#================================================== 
    912455#D-function IGCM_sys_RmRunDir 
    913456#D-* Purpose: rm tmpdir (dummy function most of the time batch 
     
    922465  fi 
    923466  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    924 } 
    925  
    926 #D-#================================================== 
    927 #D-function IGCM_sys_Mv 
    928 #D-* Purpose: generic move 
    929 #D-* Examples: 
    930 #D- 
    931 function IGCM_sys_Mv { 
    932   IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    933   if ( $DEBUG_sys ) ; then 
    934     echo "IGCM_sys_Mv :" $@ 
    935   fi 
    936  
    937   if [ $DRYRUN = 0 ]; then 
    938  
    939     typeset status 
    940  
    941     echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    942     \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    943     status=$? 
    944  
    945     if [ ${status} -gt 0 ] ; then 
    946       echo "IGCM_sys_Mv : error code ${status}" 
    947       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    948       IGCM_debug_Exit "IGCM_sys_Mv" 
    949     else 
    950       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    951     fi 
    952   fi 
    953   IGCM_debug_PopStack "IGCM_sys_Mv" 
    954467} 
    955468 
     
    1058571 
    1059572#D-#================================================== 
    1060 #D-function IGCM_sys_Get_Master 
    1061 #D-* Purpose: Copy a complete directory from MASTER filesystem 
    1062 #D-* Examples: 
    1063 #D- 
    1064 function IGCM_sys_Get_Master { 
    1065   IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
    1066   if ( $DEBUG_sys ) ; then 
    1067     echo "IGCM_sys_Get_Master :" $@ 
    1068   fi 
    1069   if [ $DRYRUN = 0 ]; then 
    1070     if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then 
    1071       echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
    1072       IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    1073       return 
    1074     fi 
    1075  
    1076     typeset NB_ESSAI DELAI status i 
    1077     # number of tentative 
    1078     NB_ESSAI=3 
    1079     # time delay between tentative 
    1080     DELAI=2 
    1081  
    1082     i=0 
    1083     while [ $i -lt $NB_ESSAI ] ; do 
    1084       \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1085       status=$? 
    1086       if [ ${status} -gt 0 ]; then 
    1087         IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1088         IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 
    1089         sleep $DELAI 
    1090       else 
    1091         break 
    1092       fi 
    1093       (( i = i + 1 )) 
    1094     done 
    1095  
    1096     if [ ${status} -gt 0 ] ; then 
    1097       echo "IGCM_sys_Get_Master : error." 
    1098       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1099       IGCM_debug_Exit "IGCM_sys_Get_Master" 
    1100     else 
    1101       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1102     fi 
    1103   fi 
    1104   IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    1105 } 
    1106  
    1107 #==================================================== 
    1108 #- Call IGCM_sys_Mirror_libIGCM now ! 
    1109 if ( $MirrorlibIGCM ) ; then 
    1110   IGCM_sys_Mirror_libIGCM 
    1111 fi 
    1112  
    1113 #D-#================================================== 
    1114573#D-function IGCM_sys_Put_Rest 
    1115574#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
     
    1173632 
    1174633#D-#================================================== 
    1175 #D-function IGCM_sys_PutBuffer_Rest 
    1176 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
    1177 #D-           File and target directory must exist. 
    1178 #D-* Examples: 
    1179 #D- 
    1180 function IGCM_sys_PutBuffer_Rest { 
    1181   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
    1182   if ( $DEBUG_sys ) ; then 
    1183     echo "IGCM_sys_PutBuffer_Rest :" $@ 
    1184   fi 
    1185   if [ $DRYRUN = 0 ]; then 
    1186     if [ ! -f ${1} ] ; then 
    1187       echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
    1188       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1189     fi 
    1190  
    1191     typeset status 
    1192     # 
    1193     # USUAL WAY 
    1194     \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1195     status=$? 
    1196  
    1197     if [ ${status} -gt 0 ] ; then 
    1198       echo "IGCM_sys_PutBuffer_Rest : error code ${status}" 
    1199       [ -f ${2} ] && ls -l ${2} 
    1200       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1201       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1202       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1203     else 
    1204  
    1205       if [ X${JobType} = XRUN ] ; then 
    1206         [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
    1207         [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
    1208       fi 
    1209  
    1210       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1211     fi 
    1212   fi 
    1213   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    1214 } 
    1215  
    1216 #D-#================================================== 
    1217 #D-function IGCM_sys_PrepareTaredRestart 
    1218 #D-* Purpose: Prepare tared restart to be access by computing job. 
    1219 #D-* Examples: 
    1220 #D- 
    1221 function IGCM_sys_PrepareTaredRestart { 
    1222   IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ 
    1223   if [ $DRYRUN = 0 ]; then 
    1224     [ ! -f $( basename $1 ) ] && IGCM_sys_Get $1 . 
    1225   fi 
    1226   IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" 
    1227 } 
    1228  
    1229 #D-#================================================== 
    1230634#D-function IGCM_sys_Put_Out 
    1231635#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 
     
    1293697 
    1294698#D-#================================================== 
    1295 #D-function IGCM_sys_PutBuffer_Out 
    1296 #D-* Purpose: Copy a file on ${WORKDIR} after having chmod it in readonly 
    1297 #D-* Examples: 
    1298 #D- 
    1299 function IGCM_sys_PutBuffer_Out { 
    1300   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
    1301   if ( $DEBUG_sys ) ; then 
    1302     echo "IGCM_sys_PutBuffer_Out :" $@ 
    1303   fi 
    1304  
    1305   typeset NB_ESSAI DELAI status i exist skip 
    1306  
    1307   # number of tentative 
    1308   NB_ESSAI=3 
    1309   # time delay between tentative 
    1310   DELAI=2 
    1311  
    1312   if [ $DRYRUN = 0 ]; then 
    1313     if [ ! -f ${1} ] ; then 
    1314       echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
    1315       IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1316       return 1 
    1317     fi 
    1318     # 
    1319     IGCM_sys_Mkdir $( dirname $2 ) 
    1320     # 
    1321  
    1322     exist=false 
    1323     skip=false 
    1324     if [ -f $2 ] ; then 
    1325       IGCM_debug_Print 1 "$2 already exist" 
    1326       exist=true 
    1327       if [ "X$( diff $1 $2 )" = X ] ; then 
    1328         IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
    1329         status=0 
    1330         skip=true 
    1331       else 
    1332         IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    1333         skip=false 
    1334       fi 
    1335     fi 
    1336     # 
    1337     if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
    1338       IGCM_sys_Chmod u+w $2 
    1339     fi 
    1340  
    1341     if [ X${skip} = Xfalse ] ; then 
    1342       i=0 
    1343       while [ $i -lt $NB_ESSAI ] ; do 
    1344         if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then 
    1345           # USUAL WAY 
    1346           \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1347           status=$? 
    1348         else 
    1349           # NOT SO USUAL WAY 
    1350           \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1351           status=$? 
    1352         fi 
    1353         if [ ${status} -gt 0 ]; then 
    1354           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1355           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 
    1356           [ -f ${2} ] && ls -l ${2} 
    1357           [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1358           sleep $DELAI 
    1359         else 
    1360           break 
    1361         fi 
    1362         (( i = i + 1 )) 
    1363       done 
    1364     fi 
    1365  
    1366     if [ ${status} -gt 0 ] ; then 
    1367       echo "IGCM_sys_PutBuffer_Out : error." 
    1368       [ -f ${2} ] && ls -l ${2} 
    1369       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1370       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1371       IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
    1372     else 
    1373  
    1374       if [ X${JobType} = XRUN ] ; then 
    1375         if [ X${3} = X ] ; then 
    1376           [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
    1377           [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
    1378         fi 
    1379       fi 
    1380  
    1381       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1382     fi 
    1383   fi 
    1384   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1385   return 0 
    1386 } 
    1387  
    1388 #D-#================================================== 
    1389699#D-function IGCM_sys_Get 
    1390700#D-* Purpose: Get a file from ${ARCHIVE} 
     
    1456766  fi 
    1457767  IGCM_debug_PopStack "IGCM_sys_Get" 
    1458 } 
    1459  
    1460 #D-#================================================== 
    1461 #D-function IGCM_sys_GetBuffer 
    1462 #D-* Purpose: Get a file from ${SCRATCHDIR} 
    1463 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
    1464 #D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
    1465 function IGCM_sys_GetBuffer { 
    1466   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
    1467  
    1468   typeset DEST buf_liste target file_work 
    1469   typeset NB_ESSAI DELAI status i 
    1470  
    1471   if ( $DEBUG_sys ) ; then 
    1472     echo "IGCM_sys_GetBuffer :" $@ 
    1473   fi 
    1474  
    1475   # number of tentative 
    1476   NB_ESSAI=3 
    1477   # time delay between tentative 
    1478   DELAI=2 
    1479  
    1480   if [ $DRYRUN -le 2 ]; then 
    1481     if [ X${1} = X'/l' ] ; then 
    1482       eval set +A buf_liste \${${2}} 
    1483     else 
    1484       eval set +A buf_liste ${1} 
    1485     fi 
    1486     eval DEST=\${${#}} 
    1487  
    1488     #USUAL WAY 
    1489     if [ X${1} = X'/l' ] ; then 
    1490       for target in ${buf_liste[*]} ; do 
    1491         local_file=$( basename ${target} ) 
    1492         i=0 
    1493         while [ $i -lt $NB_ESSAI ] ; do 
    1494           \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1495           status=$? 
    1496           if [ ${status} -gt 0 ]; then 
    1497             IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1498             IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
    1499             sleep $DELAI 
    1500           else 
    1501             break 
    1502           fi 
    1503           (( i = i + 1 )) 
    1504         done 
    1505         if [ ${status} -gt 0 ] ; then 
    1506           echo "IGCM_sys_Get : error" 
    1507           cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1508           \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1509           IGCM_debug_Exit "IGCM_sys_GetBuffer" 
    1510         else 
    1511           \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1512         fi 
    1513       done 
    1514     else 
    1515       i=0 
    1516       while [ $i -lt $NB_ESSAI ] ; do 
    1517         \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1518         status=$? 
    1519         if [ ${status} -gt 0 ]; then 
    1520           IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1521           IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
    1522           sleep $DELAI 
    1523         else 
    1524           break 
    1525         fi 
    1526         (( i = i + 1 )) 
    1527       done 
    1528       if [ ${status} -gt 0 ] ; then 
    1529         echo "IGCM_sys_Get : error" 
    1530         cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1531         \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1532         IGCM_debug_Exit "IGCM_sys_GetBuffer" 
    1533       else 
    1534         \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1535       fi 
    1536     fi 
    1537   fi 
    1538   IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
    1539 } 
    1540  
    1541 #D-#================================================== 
    1542 #D-function IGCM_sys_GetDate_FichWork 
    1543 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
    1544 #D-* Examples: 
    1545 #D- 
    1546 function IGCM_sys_GetDate_FichWork { 
    1547   IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1548   if ( $DEBUG_sys ) ; then 
    1549     echo "IGCM_sys_GetDate_FichWork :" $@ 
    1550   fi 
    1551  
    1552   if [ $# -ge 3 ] ; then 
    1553     mode=$3 
    1554     TimeStyle=$4 
    1555   else 
    1556     mode="default" 
    1557     TimeStyle="%Y%m%d%H%M%S" 
    1558   fi 
    1559  
    1560   typeset dateF 
    1561   set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} ) 
    1562  
    1563   case $mode in 
    1564     "default") 
    1565       eval ${2}=${dateF[5]} 
    1566       ;; 
    1567     "SplitFields") 
    1568       eval ${2}="${dateF[5]}\ ${dateF[6]}" 
    1569       ;; 
    1570   esac 
    1571  
    1572  
    1573   # donne la date filesys d'un fichier sur la machine work 
    1574   IGCM_debug_PopStack "IGCM_sys_FichWork" 
    1575 } 
    1576  
    1577 #D-#================================================== 
    1578 #D-function IGCM_sys_GetDate_FichArchive 
    1579 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE 
    1580 #D-* Examples: 
    1581 #D- 
    1582 function IGCM_sys_GetDate_FichArchive { 
    1583   IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1584   if ( $DEBUG_sys ) ; then 
    1585     echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1586   fi 
    1587   typeset dateF 
    1588   set +A dateF -- $( rsh ${STOREHOST} -n ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1589   eval ${2}=${dateF[5]} 
    1590  
    1591   IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    1592768} 
    1593769 
     
    1668844  fi 
    1669845  IGCM_debug_PopStack "IGCM_sys_sync" 
    1670 } 
    1671  
    1672 #D-#================================================== 
    1673 #D-function IGCM_sys_rebuild 
    1674 #D-* Purpose: rebuild parallel files 
    1675 #D-* Examples: 
    1676 #D- 
    1677 function IGCM_sys_rebuild { 
    1678   IGCM_debug_PushStack "IGCM_sys_rebuild" $@ 
    1679   if ( $DEBUG_sys ) ; then 
    1680     echo "IGCM_sys_rebuild :" $@ 
    1681   fi 
    1682  
    1683   typeset NB_ESSAI DELAI status i firstArg 
    1684   # number of tentative 
    1685   NB_ESSAI=3 
    1686   # time delay between tentative 
    1687   DELAI=2 
    1688  
    1689   i=0 
    1690   while [ $i -lt $NB_ESSAI ] ; do 
    1691     rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1692     status=$? 
    1693     if [ ${status} -gt 0 ] ; then 
    1694       IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" 
    1695       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1696       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1697       IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    1698       firstArg=${1} 
    1699       \rm ${firstArg} 
    1700       sleep $DELAI 
    1701     else 
    1702       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1703       break 
    1704     fi 
    1705     (( i = i + 1 )) 
    1706   done 
    1707  
    1708   if [ ${status} -gt 0 ] ; then 
    1709     echo "IGCM_sys_rebuild : rebuild error code is ${status}" 
    1710     IGCM_debug_Exit "rebuild" 
    1711   fi 
    1712  
    1713   IGCM_debug_PopStack "IGCM_sys_rebuild" 
    1714 } 
    1715  
    1716 #D-#================================================== 
    1717 #D-function IGCM_sys_rebuild_station 
    1718 #D-* Purpose: rebuild parallel files describing station 
    1719 #D-* Examples: 
    1720 #D- 
    1721 function IGCM_sys_rebuild_station { 
    1722   IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@ 
    1723   typeset i list_opt file_in file_out prefix_invert list_invert 
    1724   if ( $DEBUG_sys ) ; then 
    1725     echo "IGCM_sys_rebuild_station :" $@ 
    1726   fi 
    1727   list_opt=$@ 
    1728  
    1729   # Invert Axis : t,x -> x,t 
    1730   #               t,pres,x -> x,t,pres 
    1731   # So that we can concatenate along x 
    1732   i=0 
    1733   for file_in in ${list_opt} ; do 
    1734     (( i = i + 1)) 
    1735     [ ${i} = 1 ] && file_out=${file_in} && continue 
    1736     # detect time counter and do the job only if present 
    1737     var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') 
    1738     if [ X${var_unlim} = Xtime_counter ] ; then 
    1739       prefix_invert=$( basename ${file_in} .nc ) 
    1740       IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc 
    1741       list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc 
    1742     fi 
    1743   done 
    1744  
    1745   # Concatenate 
    1746   IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc 
    1747  
    1748   # Re-ivert file 
    1749   IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} 
    1750  
    1751   # Station re-ordering is too expansive to be run within libIGCM 
    1752   # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. 
    1753   # This re-ordering must be done "in memory" by the cmorization process 
    1754   # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) 
    1755   # BEGIN reordering 
    1756  
    1757   # Only LMDZ text output contains the exact ordering of the station. 
    1758   # We isolate this in the code below: 
    1759   #  0  38  -157.5000000000000  70.98591549295774 
    1760   #  0  54  27.49999999999999   67.18309859154928 
    1761   #  0  56  -62.50000000000001  82.39436619718309 
    1762   #  0  79  12.49999999999999   78.59154929577466 
    1763   #  0  116 -165.0000000000000  76.05633802816901 
    1764   #  0  117 130.0000000000000   70.98591549295774 
    1765   #  0  118 110.0000000000000   87.46478873239437 
    1766   #  1  40  4.999999999999995   51.97183098591550 
    1767  
    1768 #  typeset iStation iProc list_opt file_in file_out prefix_invert 
    1769 #  typeset -Z4 j4 
    1770 #  typeset -Z3 j3 
    1771  
    1772 #  unset list_opt 
    1773 #  set +A list_opt $@ 
    1774  
    1775   # Filename after rebuild 
    1776 #  file_out=${list_opt[0]} 
    1777   # Prefix of output files 
    1778 #  prefix_invert=$( basename ${file_out} .nc ) 
    1779   # Number of procs 
    1780 #  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) 
    1781  
    1782 #  iProc=0 
    1783 #  while [ ${iProc} -lt ${num_proc} ] ; do 
    1784     # Array containing Station as a number 
    1785 #    unset proc_stn 
    1786 #    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}' ) 
    1787     # Number of stations produced by processor proc 
    1788 #    stationLast=${#proc_stn[*]} 
    1789     # Proc number on 4 digits 
    1790 #    j4=${iProc} 
    1791     # Init 
    1792 #    iStation=0 
    1793 #    while [ ${iStation} -lt ${stationLast} ] ; do 
    1794       # Station number on 3 digits 
    1795 #      j3=${proc_stn[${iStation}]} 
    1796       # Extract station 
    1797       # Invert Axis : t,x -> x,t 
    1798       #               t,pres,x -> x,t,pres 
    1799       # So that we can concatenate along x 
    1800 #      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 
    1801 #      (( iStation = iStation + 1 )) 
    1802 #    done 
    1803 #    (( iProc = iProc + 1 )) 
    1804 #  done 
    1805  
    1806   # Concatenate all station along x 
    1807 #  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc 
    1808  
    1809   # Re-invert file 
    1810 #  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} 
    1811  
    1812   # END reordering 
    1813  
    1814   IGCM_debug_PopStack "IGCM_sys_rebuild_station" 
    1815846} 
    1816847 
     
    21451176  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue" 
    21461177} 
    2147  
    2148 ############################################################## 
    2149 # NCO OPERATOR 
    2150  
    2151 #D-#================================================== 
    2152 #D-function IGCM_sys_ncap2 
    2153 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry 
    2154 #D-* Examples: 
    2155 #D- 
    2156 function IGCM_sys_ncap2 { 
    2157   IGCM_debug_PushStack "IGCM_sys_ncap2" $@ 
    2158   if ( $DEBUG_sys ) ; then 
    2159     echo "IGCM_sys_ncap2 :" $@ 
    2160   fi 
    2161  
    2162   typeset NB_ESSAI DELAI status i 
    2163   # number of tentative 
    2164   NB_ESSAI=3 
    2165   # time delay between tentative 
    2166   DELAI=2 
    2167  
    2168   i=0 
    2169   while [ $i -lt $NB_ESSAI ] ; do 
    2170     ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2171     status=$? 
    2172     if [ ${status} -gt 0 ] ; then 
    2173       IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" 
    2174       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2175       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2176       IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2177       sleep $DELAI 
    2178     else 
    2179       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2180       break 
    2181     fi 
    2182     (( i = i + 1 )) 
    2183   done 
    2184  
    2185   if [ ${status} -gt 0 ] ; then 
    2186     echo "IGCM_sys_ncap2 : ncap2 error" 
    2187     IGCM_debug_Exit "ncap2" 
    2188   fi 
    2189  
    2190   IGCM_debug_PopStack "IGCM_sys_ncap2" 
    2191 } 
    2192  
    2193 #D-#================================================== 
    2194 #D-function IGCM_sys_ncatted 
    2195 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry 
    2196 #D-* Examples: 
    2197 #D- 
    2198 function IGCM_sys_ncatted { 
    2199   IGCM_debug_PushStack "IGCM_sys_ncatted" $@ 
    2200   if ( $DEBUG_sys ) ; then 
    2201     echo "IGCM_sys_ncatted :" $@ 
    2202   fi 
    2203  
    2204   typeset NB_ESSAI DELAI status i 
    2205   # number of tentative 
    2206   NB_ESSAI=3 
    2207   # time delay between tentative 
    2208   DELAI=2 
    2209  
    2210   i=0 
    2211   while [ $i -lt $NB_ESSAI ] ; do 
    2212     ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2213     status=$? 
    2214     if [ ${status} -gt 0 ] ; then 
    2215       IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" 
    2216       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2217       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2218       IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2219       sleep $DELAI 
    2220     else 
    2221       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2222       break 
    2223     fi 
    2224     (( i = i + 1 )) 
    2225   done 
    2226  
    2227   if [ ${status} -gt 0 ] ; then 
    2228     echo "IGCM_sys_ncatted : ncatted error" 
    2229     IGCM_debug_Exit "ncatted" 
    2230   fi 
    2231  
    2232   IGCM_debug_PopStack "IGCM_sys_ncatted" 
    2233 } 
    2234  
    2235 #D-#================================================== 
    2236 #D-function IGCM_sys_ncbo 
    2237 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry 
    2238 #D-* Examples: 
    2239 #D- 
    2240 function IGCM_sys_ncbo { 
    2241   IGCM_debug_PushStack "IGCM_sys_ncbo" $@ 
    2242   if ( $DEBUG_sys ) ; then 
    2243     echo "IGCM_sys_ncbo :" $@ 
    2244   fi 
    2245  
    2246   typeset NB_ESSAI DELAI status i 
    2247   # number of tentative 
    2248   NB_ESSAI=3 
    2249   # time delay between tentative 
    2250   DELAI=2 
    2251  
    2252   i=0 
    2253   while [ $i -lt $NB_ESSAI ] ; do 
    2254     ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2255     status=$? 
    2256     if [ ${status} -gt 0 ] ; then 
    2257       IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" 
    2258       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2259       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2260       IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2261       sleep $DELAI 
    2262     else 
    2263       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2264       break 
    2265     fi 
    2266     (( i = i + 1 )) 
    2267   done 
    2268  
    2269   if [ ${status} -gt 0 ] ; then 
    2270     echo "IGCM_sys_ncbo : ncbo error" 
    2271     IGCM_debug_Exit "ncbo" 
    2272   fi 
    2273  
    2274   IGCM_debug_PopStack "IGCM_sys_ncbo" 
    2275 } 
    2276  
    2277 #D-#================================================== 
    2278 #D-function IGCM_sys_ncdif 
    2279 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry 
    2280 #D-* Examples: 
    2281 #D- 
    2282 function IGCM_sys_ncdiff { 
    2283   IGCM_debug_PushStack "IGCM_sys_ncdiff" $@ 
    2284   if ( $DEBUG_sys ) ; then 
    2285     echo "IGCM_sys_ncdiff :" $@ 
    2286   fi 
    2287  
    2288   typeset NB_ESSAI DELAI status i 
    2289   # number of tentative 
    2290   NB_ESSAI=3 
    2291   # time delay between tentative 
    2292   DELAI=2 
    2293  
    2294   i=0 
    2295   while [ $i -lt $NB_ESSAI ] ; do 
    2296     ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2297     status=$? 
    2298     if [ ${status} -gt 0 ] ; then 
    2299       IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" 
    2300       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2301       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2302       IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2303       sleep $DELAI 
    2304     else 
    2305       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2306       break 
    2307     fi 
    2308     (( i = i + 1 )) 
    2309   done 
    2310  
    2311   if [ ${status} -gt 0 ] ; then 
    2312     echo "IGCM_sys_ncdiff : ncdiff error" 
    2313     IGCM_debug_Exit "ncdiff" 
    2314   fi 
    2315  
    2316   IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    2317 } 
    2318  
    2319 #D-#================================================== 
    2320 #D-function IGCM_sys_ncea 
    2321 #D-* Purpose: encapsulate ncea call so as to manage error code and retry 
    2322 #D-* Examples: 
    2323 #D- 
    2324 function IGCM_sys_ncea { 
    2325   IGCM_debug_PushStack "IGCM_sys_ncea" $@ 
    2326   if ( $DEBUG_sys ) ; then 
    2327     echo "IGCM_sys_ncea :" $@ 
    2328   fi 
    2329  
    2330   typeset NB_ESSAI DELAI status i 
    2331   # number of tentative 
    2332   NB_ESSAI=3 
    2333   # time delay between tentative 
    2334   DELAI=2 
    2335  
    2336   i=0 
    2337   while [ $i -lt $NB_ESSAI ] ; do 
    2338     ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2339     status=$? 
    2340     if [ ${status} -gt 0 ] ; then 
    2341       IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" 
    2342       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2343       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2344       IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2345       sleep $DELAI 
    2346     else 
    2347       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2348       break 
    2349     fi 
    2350     (( i = i + 1 )) 
    2351   done 
    2352  
    2353   if [ ${status} -gt 0 ] ; then 
    2354     echo "IGCM_sys_ncea : ncea error" 
    2355     IGCM_debug_Exit "ncea" 
    2356   fi 
    2357  
    2358   IGCM_debug_PopStack "IGCM_sys_ncea" 
    2359 } 
    2360  
    2361 #D-#================================================== 
    2362 #D-function IGCM_sys_ncecat 
    2363 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry 
    2364 #D-* Examples: 
    2365 #D- 
    2366 function IGCM_sys_ncecat { 
    2367   IGCM_debug_PushStack "IGCM_sys_ncecat" $@ 
    2368   if ( $DEBUG_sys ) ; then 
    2369     echo "IGCM_sys_ncecat :" $@ 
    2370   fi 
    2371  
    2372   typeset NB_ESSAI DELAI status i 
    2373   # number of tentative 
    2374   NB_ESSAI=3 
    2375   # time delay between tentative 
    2376   DELAI=2 
    2377  
    2378   i=0 
    2379   while [ $i -lt $NB_ESSAI ] ; do 
    2380     ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2381     status=$? 
    2382     if [ ${status} -gt 0 ] ; then 
    2383       IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" 
    2384       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2385       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2386       IGCM_debug_Print 2 "IGCM_sys_ncecat : ${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_ncecat : ncecat error" 
    2397     IGCM_debug_Exit "ncecat" 
    2398   fi 
    2399  
    2400   IGCM_debug_PopStack "IGCM_sys_ncecat" 
    2401 } 
    2402  
    2403 #D-#================================================== 
    2404 #D-function IGCM_sys_ncflint 
    2405 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry 
    2406 #D-* Examples: 
    2407 #D- 
    2408 function IGCM_sys_ncflint { 
    2409   IGCM_debug_PushStack "IGCM_sys_ncflint" $@ 
    2410   if ( $DEBUG_sys ) ; then 
    2411     echo "IGCM_sys_ncflint :" $@ 
    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     ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2423     status=$? 
    2424     if [ ${status} -gt 0 ] ; then 
    2425       IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" 
    2426       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2427       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2428       IGCM_debug_Print 2 "IGCM_sys_ncflint : ${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_ncflint : ncflint error" 
    2439     IGCM_debug_Exit "ncflint" 
    2440   fi 
    2441  
    2442   IGCM_debug_PopStack "IGCM_sys_ncflint" 
    2443 } 
    2444  
    2445 #D-#================================================== 
    2446 #D-function IGCM_sys_ncks 
    2447 #D-* Purpose: encapsulate ncks call so as to manage error code and retry 
    2448 #D-* Examples: 
    2449 #D- 
    2450 function IGCM_sys_ncks { 
    2451   IGCM_debug_PushStack "IGCM_sys_ncks" $@ 
    2452   if ( $DEBUG_sys ) ; then 
    2453     echo "IGCM_sys_ncks :" $@ 
    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     ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2465     status=$? 
    2466     if [ ${status} -gt 0 ] ; then 
    2467       IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" 
    2468       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2469       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2470       IGCM_debug_Print 2 "IGCM_sys_ncks : ${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_ncks : ncks error" 
    2481     IGCM_debug_Exit "ncks" 
    2482   fi 
    2483  
    2484   IGCM_debug_PopStack "IGCM_sys_ncks" 
    2485 } 
    2486  
    2487 #D-#================================================== 
    2488 #D-function IGCM_sys_ncpdq 
    2489 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry 
    2490 #D-* Examples: 
    2491 #D- 
    2492 function IGCM_sys_ncpdq { 
    2493   IGCM_debug_PushStack "IGCM_sys_ncpdq" $@ 
    2494   if ( $DEBUG_sys ) ; then 
    2495     echo "IGCM_sys_ncpdq :" $@ 
    2496   fi 
    2497  
    2498   typeset NB_ESSAI DELAI status i 
    2499   # number of tentative 
    2500   NB_ESSAI=3 
    2501   # time delay between tentative 
    2502   DELAI=2 
    2503  
    2504   i=0 
    2505   while [ $i -lt $NB_ESSAI ] ; do 
    2506     ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2507     status=$? 
    2508     if [ ${status} -gt 0 ] ; then 
    2509       IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" 
    2510       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2511       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2512       IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2513       sleep $DELAI 
    2514     else 
    2515       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2516       break 
    2517     fi 
    2518     (( i = i + 1 )) 
    2519   done 
    2520  
    2521   if [ ${status} -gt 0 ] ; then 
    2522     echo "IGCM_sys_ncpdq : ncpdq error" 
    2523     IGCM_debug_Exit "ncpdq" 
    2524   fi 
    2525  
    2526   IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    2527 } 
    2528  
    2529 #D-#================================================== 
    2530 #D-function IGCM_sys_ncra 
    2531 #D-* Purpose: encapsulate ncra call so as to manage error code and retry 
    2532 #D-* Examples: 
    2533 #D- 
    2534 function IGCM_sys_ncra { 
    2535   IGCM_debug_PushStack "IGCM_sys_ncra" $@ 
    2536   if ( $DEBUG_sys ) ; then 
    2537     echo "IGCM_sys_ncra :" $@ 
    2538   fi 
    2539  
    2540   typeset NB_ESSAI DELAI status i 
    2541   # number of tentative 
    2542   NB_ESSAI=3 
    2543   # time delay between tentative 
    2544   DELAI=2 
    2545  
    2546   i=0 
    2547   while [ $i -lt $NB_ESSAI ] ; do 
    2548     ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2549     status=$? 
    2550     if [ ${status} -gt 0 ] ; then 
    2551       IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" 
    2552       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2553       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2554       IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2555       sleep $DELAI 
    2556     else 
    2557       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2558       break 
    2559     fi 
    2560     (( i = i + 1 )) 
    2561   done 
    2562  
    2563   if [ ${status} -gt 0 ] ; then 
    2564     echo "IGCM_sys_ncra : ncra error" 
    2565     IGCM_debug_Exit "ncra" 
    2566   fi 
    2567  
    2568   IGCM_debug_PopStack "IGCM_sys_ncra" 
    2569 } 
    2570  
    2571 #D-#================================================== 
    2572 #D-function IGCM_sys_ncrcat 
    2573 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry 
    2574 #D-* Examples: 
    2575 #D- 
    2576 function IGCM_sys_ncrcat { 
    2577   IGCM_debug_PushStack "IGCM_sys_ncrcat" $@ 
    2578   if ( $DEBUG_sys ) ; then 
    2579     echo "IGCM_sys_ncrcat :" $@ 
    2580   fi 
    2581  
    2582   typeset NB_ESSAI DELAI status i lastArg 
    2583   # number of tentative 
    2584   NB_ESSAI=3 
    2585   # time delay between tentative 
    2586   DELAI=2 
    2587  
    2588   i=0 
    2589   while [ $i -lt $NB_ESSAI ] ; do 
    2590     ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2591     status=$? 
    2592     if [ ${status} -gt 0 ] ; then 
    2593       IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" 
    2594       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2595       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2596       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2597       sleep $DELAI 
    2598     elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then 
    2599       IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" 
    2600       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2601       # remove files having corrupted time axis 
    2602       eval lastArg=\${$#} 
    2603       IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" 
    2604       \rm ${lastArg} 
    2605       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2606       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2607       sleep $DELAI 
    2608     else 
    2609       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2610       break 
    2611     fi 
    2612     (( i = i + 1 )) 
    2613   done 
    2614  
    2615   if [ ${status} -gt 0 ] ; then 
    2616     echo "IGCM_sys_ncrcat : ncrcat error" 
    2617     #IGCM_debug_Exit "ncrcat" 
    2618   fi 
    2619  
    2620   IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    2621 } 
    2622  
    2623 #D-#================================================== 
    2624 #D-function IGCM_sys_ncrename 
    2625 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry 
    2626 #D-* Examples: 
    2627 #D- 
    2628 function IGCM_sys_ncrename { 
    2629   IGCM_debug_PushStack "IGCM_sys_ncrename" $@ 
    2630   if ( $DEBUG_sys ) ; then 
    2631     echo "IGCM_sys_ncrename :" $@ 
    2632   fi 
    2633  
    2634   typeset NB_ESSAI DELAI status i 
    2635   # number of tentative 
    2636   NB_ESSAI=3 
    2637   # time delay between tentative 
    2638   DELAI=2 
    2639  
    2640   i=0 
    2641   while [ $i -lt $NB_ESSAI ] ; do 
    2642     ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2643     status=$? 
    2644     if [ ${status} -gt 0 ] ; then 
    2645       IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" 
    2646       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2647       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2648       IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2649       sleep $DELAI 
    2650     else 
    2651       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2652       break 
    2653     fi 
    2654     (( i = i + 1 )) 
    2655   done 
    2656  
    2657   if [ ${status} -gt 0 ] ; then 
    2658     echo "IGCM_sys_ncrename : ncrename error" 
    2659     IGCM_debug_Exit "ncrename" 
    2660   fi 
    2661  
    2662   IGCM_debug_PopStack "IGCM_sys_ncrename" 
    2663 } 
    2664  
    2665 #D-#================================================== 
    2666 #D-function IGCM_sys_ncwa 
    2667 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry 
    2668 #D-* Examples: 
    2669 #D- 
    2670 function IGCM_sys_ncwa { 
    2671   IGCM_debug_PushStack "IGCM_sys_ncwa" $@ 
    2672   if ( $DEBUG_sys ) ; then 
    2673     echo "IGCM_sys_ncwa :" $@ 
    2674   fi 
    2675  
    2676   typeset NB_ESSAI DELAI status i 
    2677   # number of tentative 
    2678   NB_ESSAI=3 
    2679   # time delay between tentative 
    2680   DELAI=2 
    2681  
    2682   i=0 
    2683   while [ $i -lt $NB_ESSAI ] ; do 
    2684     ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2685     status=$? 
    2686     if [ ${status} -gt 0 ] ; then 
    2687       IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" 
    2688       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2689       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2690       IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2691       sleep $DELAI 
    2692     else 
    2693       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2694       break 
    2695     fi 
    2696     (( i = i + 1 )) 
    2697   done 
    2698  
    2699   if [ ${status} -gt 0 ] ; then 
    2700     echo "IGCM_sys_ncwa : ncwa error" 
    2701     IGCM_debug_Exit "ncwa" 
    2702   fi 
    2703  
    2704   IGCM_debug_PopStack "IGCM_sys_ncwa" 
    2705 } 
    2706  
    2707 ############################################################## 
    2708 # CDO OPERATOR 
    2709  
    2710 #D-#================================================== 
    2711 #D-function IGCM_sys_cdo 
    2712 #D-* Purpose: encapsulate cdo call so as to manage error code and retry 
    2713 #D-* Examples: 
    2714 #D- 
    2715 function IGCM_sys_cdo { 
    2716   IGCM_debug_PushStack "IGCM_sys_cdo" $@ 
    2717   if ( $DEBUG_sys ) ; then 
    2718     echo "IGCM_sys_cdo :" $@ 
    2719   fi 
    2720  
    2721   typeset status 
    2722  
    2723   \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2724   status=$? 
    2725   if [ ${status} -gt 0 ] ; then 
    2726     echo "IGCM_sys_cdo : error code ${status}" 
    2727     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2728     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2729     IGCM_debug_PopStack "IGCM_sys_cdo" 
    2730     return 1 
    2731   else 
    2732     IGCM_debug_PopStack "IGCM_sys_cdo" 
    2733     return 0 
    2734   fi 
    2735  
    2736   IGCM_debug_PopStack "IGCM_sys_cdo" 
    2737 } 
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh

    r1180 r1181  
    256256 
    257257#D-#================================================== 
    258 #D-function IGCM_sys_RshMaster 
    259 #D-* Purpose: Connection to frontend machine. 
    260 #D-* Examples: 
    261 #D- 
    262 function IGCM_sys_RshMaster { 
    263   IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 
    264   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF 
    265     export libIGCM=${libIGCM} 
    266     export DEBUG_debug=${DEBUG_debug} 
    267     . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
    268     . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
    269     ${@} 
    270 EOF 
    271   if [ $? -gt 0 ] ; then 
    272     echo "IGCM_sys_RshMaster : erreur." 
    273     IGCM_debug_Exit "IGCM_sys_RshMaster" 
    274   fi 
    275   IGCM_debug_PopStack "IGCM_sys_RshMaster" 
    276 } 
    277  
    278 #D-#================================================== 
    279258#D-function IGCM_sys_RshArchive 
    280259#D-* Purpose: Archive rsh command 
     
    303282  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ 
    304283  /bin/ksh <<-EOF 
    305     ${@} 2> \dev\null 
     284    ${@} 2> /dev/null 
    306285EOF 
    307286  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" 
    308 } 
    309  
    310 #D-#================================================== 
    311 #D-function IGCM_sys_RshPost 
    312 #D-* Purpose: Post-process rsh command 
    313 #D-* Examples: 
    314 #D- 
    315 function IGCM_sys_RshPost { 
    316   IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 
    317   if ( $DEBUG_sys ) ; then 
    318     echo "IGCM_sys_RshPost :" $@ 
    319   fi 
    320   # keep standard input (stdin) for the loop onto temporary file 
    321   cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    322  
    323   OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    324   if [ $? -gt 0 ] ; then 
    325     echo "IGCM_sys_RshPost : erreur." 
    326     IGCM_debug_Exit "IGCM_sys_RshPost" 
    327   fi 
    328   # delete temporary file 
    329   \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 
    330  
    331 # ============ FRONTEND  END  ============ # 
    332  
    333 # ============ CESIUM START ============ # 
    334 #  typeset NB_ESSAI DELAI status i 
    335 #  if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then 
    336 #    #little hack so that rebuild submission is done on titane not an cesium 
    337 # 
    338 #    libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' ) 
    339 #    POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' ) 
    340 #    sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
    341 #    sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
    342 #    sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 
    343 #    sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 
    344 #    \mv tmp.txt tmp_IGCM_sys_RshPost_$$ 
    345 # 
    346 #    echo cat tmp_IGCM_sys_RshPost_$$ AFTER 
    347 #    cat tmp_IGCM_sys_RshPost_$$ 
    348 # 
    349 #    /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
    350 #    if [ $? -gt 0 ] ; then 
    351 #      echo "IGCM_sys_RshPost : erreur." 
    352 #      IGCM_debug_Exit "IGCM_sys_RshPost" 
    353 #    fi 
    354 #    # delete temporary file 
    355 #    \rm tmp_IGCM_sys_RshPost_$$ 
    356 # 
    357 #  else 
    358 #    # number of tentative 
    359 #    NB_ESSAI=10 
    360 #    # time delay between tentative 
    361 #    DELAI=10 
    362 #    i=0 
    363 #    while [ $i -ne $NB_ESSAI ] ; do 
    364 #      ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 
    365 #      status=$? 
    366 #      if [ ${status} -ne 0 ]; 
    367 #      then 
    368 #        sleep $DELAI 
    369 #      else 
    370 #        break 
    371 #      fi 
    372 #      let i=$i+1 
    373 #    done 
    374 #    # delete temporary file 
    375 #    \rm tmp_IGCM_sys_RshPost_$$ 
    376 # 
    377 #    if [ ${status} -gt 0 ] ; then 
    378 #      echo "IGCM_sys_RshPost : erreur." 
    379 #      IGCM_debug_Exit "IGCM_sys_RshPost" 
    380 #    fi 
    381 #  fi 
    382  
    383 # ============ CESIUM  END  ============ # 
    384  
    385   IGCM_debug_PopStack "IGCM_sys_RshPost" 
    386 } 
    387  
    388 #D-#================================================== 
    389 #D-function IGCM_sys_SendMail 
    390 #D-* Purpose: Send mail when simulation is over 
    391 #D-* Examples: 
    392 #D- 
    393 function IGCM_sys_SendMail { 
    394   IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 
    395   if ( $DEBUG_sys ) ; then 
    396     echo "IGCM_sys_SendMail :" $@ 
    397   fi 
    398  
    399   if [ X${1} = XAccounting ] ; then 
    400     status=Accounting 
    401     mailText=jobAccounting.mail 
    402   elif ( ${ExitFlag} ) ; then 
    403     status=failed 
    404     mailText=jobEnd.mail 
    405   else 
    406     status=completed 
    407     mailText=jobEnd.mail 
    408   fi 
    409  
    410   # Update selected mail template 
    411   while read -r line; do 
    412     eval echo $line >> mail.txt ; 
    413   done < ${libIGCM}/libIGCM_sys/${mailText} 
    414  
    415   if [ ! -z ${config_UserChoices_MailName} ] ; then 
    416     mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt 
    417   elif [ -f ~/.forward ] ; then 
    418     mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt 
    419   else 
    420     mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt 
    421   fi 
    422  
    423   sleep 10 
    424   rm -f mail.txt 
    425  
    426   IGCM_debug_PopStack "IGCM_sys_SendMail" 
    427 } 
    428  
    429 #D-#================================================== 
    430 #D-function IGCM_sys_Mkdir 
    431 #D-* Purpose: Master locale mkdir command 
    432 #D-* Examples: 
    433 #D- 
    434 function IGCM_sys_Mkdir { 
    435   IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 
    436   if ( $DEBUG_sys ) ; then 
    437     echo "IGCM_sys_Mkdir :" $@ 
    438   fi 
    439   if [ ! -d ${1} ]; then 
    440     \mkdir -p $1 
    441     if [ $? -gt 0 ] ; then 
    442       echo "IGCM_sys_Mkdir : erreur." 
    443       IGCM_debug_Exit "IGCM_sys_Mkdir" 
    444     fi 
    445   fi 
    446   # vérification : 
    447   if [ ! -d ${1} ] ; then 
    448     echo "IGCM_sys_Mkdir : erreur." 
    449     IGCM_debug_Exit "IGCM_sys_Mkdir" 
    450   fi 
    451   IGCM_debug_PopStack "IGCM_sys_Mkdir" 
    452287} 
    453288 
     
    473308  fi 
    474309  IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 
    475 } 
    476  
    477 #D-#================================================== 
    478 #D-function IGCM_sys_MkdirWork 
    479 #D-* Purpose: Mkdir on Work 
    480 #D-* Examples: 
    481 #D- 
    482 function IGCM_sys_MkdirWork { 
    483   IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 
    484   if ( $DEBUG_sys ) ; then 
    485     echo "IGCM_sys_MkdirWork :" $@ 
    486   fi 
    487   #- creation de repertoire sur le serveur fichier 
    488   if [ ! -d ${1} ]; then 
    489     \mkdir -p $1 
    490     if [ $? -gt 0 ] ; then 
    491       echo "IGCM_sys_MkdirWork : erreur." 
    492       IGCM_debug_Exit "IGCM_sys_MkdirWork" 
    493     fi 
    494   fi 
    495   IGCM_debug_PopStack "IGCM_sys_MkdirWork" 
    496 } 
    497  
    498 #D-#================================================== 
    499 #D-function IGCM_sys_Cd 
    500 #D-* Purpose: master cd command 
    501 #D-* Examples: 
    502 #D- 
    503 function IGCM_sys_Cd { 
    504   IGCM_debug_PushStack "IGCM_sys_Cd" $@ 
    505   if ( $DEBUG_sys ) ; then 
    506     echo "IGCM_sys_Cd :" $@ 
    507   fi 
    508   \cd $1 
    509   if [ $? -gt 0 ] ; then 
    510     echo "IGCM_sys_Cd : erreur." 
    511     IGCM_debug_Exit "IGCM_sys_Cd" 
    512   fi 
    513   IGCM_debug_PopStack "IGCM_sys_Cd" 
    514 } 
    515  
    516 #D-#================================================== 
    517 #D-function IGCM_sys_Chmod 
    518 #D-* Purpose: Chmod 
    519 #D-* Examples: 
    520 #D- 
    521 function IGCM_sys_Chmod { 
    522   IGCM_debug_PushStack "IGCM_sys_Chmod" $@ 
    523   if ( $DEBUG_sys ) ; then 
    524     echo "IGCM_sys_Chmod :" $@ 
    525   fi 
    526   \chmod $@ 
    527   if [ $? -gt 0 ] ; then 
    528     echo "IGCM_sys_Chmod : erreur." 
    529     IGCM_debug_Exit "IGCM_sys_Chmod" 
    530   fi 
    531   IGCM_debug_PopStack "IGCM_sys_Chmod" 
    532 } 
    533  
    534 #D-#================================================== 
    535 #D-function IGCM_sys_FileSize 
    536 #D-* Purpose: Filesize 
    537 #D-* Examples: 
    538 #D- 
    539 function IGCM_sys_FileSize { 
    540   IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 
    541  
    542   typeset sizeF 
    543   set +A sizeF -- $( ls -la ${1} ) 
    544   if [ $? -gt 0 ] ; then 
    545     IGCM_debug_Exit "IGCM_sys_FileSize" 
    546   fi 
    547   eval ${2}=${sizeF[4]} 
    548  
    549   IGCM_debug_PopStack "IGCM_sys_FileSize" 
    550 } 
    551  
    552 #D-#================================================== 
    553 #D-function IGCM_sys_TestDir 
    554 #D-* Purpose: Test Directory that must exists 
    555 #D-* Examples: 
    556 #D- 
    557 function IGCM_sys_TestDir { 
    558   IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 
    559   if ( $DEBUG_sys ) ; then 
    560     echo "IGCM_sys_TestDir :" $@ 
    561   fi 
    562   typeset ExistFlag 
    563   ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 
    564   IGCM_debug_PopStack "IGCM_sys_TestDir" 
    565  
    566   return ${ExistFlag} 
    567310} 
    568311 
     
    615358 
    616359#D-#================================================== 
    617 #D-function IGCM_sys_TestFileBuffer 
    618 #D-* Purpose: Test file that must NOT EXISTS on Buffer 
    619 #D-* Examples: 
    620 #D- 
    621 function IGCM_sys_TestFileBuffer { 
    622   IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 
    623   typeset ExistFlag 
    624   ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 
    625   IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 
    626  
    627   return ${ExistFlag} 
    628 } 
    629  
    630 #D-#================================================== 
    631360#D-function IGCM_sys_CountFileArchive 
    632361#D-* Purpose: Count files on Archive filesystem 
     
    643372 
    644373#D-#================================================== 
    645 #D-function IGCM_sys_CountFileBuffer 
    646 #D-* Purpose: Count files on Scratch filesystem 
    647 #D-* Examples: 
    648 #D- 
    649 function IGCM_sys_CountFileBuffer { 
    650   IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 
    651   ls ${@} 2>/dev/null | wc -l 
    652   if [ $? -gt 0 ] ; then 
    653     echo "IGCM_sys_CountFileBuffer : erreur." 
    654   fi 
    655   IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 
    656 } 
    657  
    658 #D-#================================================== 
    659374#D-function IGCM_sys_Tree 
    660375#D-* Purpose: Tree directories with files on ${ARCHIVE} 
     
    670385 
    671386  IGCM_debug_PopStack "IGCM_sys_Tree" 
    672 } 
    673  
    674 #D-#================================================== 
    675 #D-function IGCM_sys_Tar 
    676 #D-* Purpose: master tar command 
    677 #D-* Examples: 
    678 #D- 
    679 function IGCM_sys_Tar { 
    680   IGCM_debug_PushStack "IGCM_sys_Tar" $@ 
    681   if ( $DEBUG_sys ) ; then 
    682     echo "IGCM_sys_Tar :" $@ 
    683   fi 
    684   \tar cf $@ 
    685   if [ $? -gt 0 ] ; then 
    686     echo "IGCM_sys_Tar : erreur." 
    687     IGCM_debug_Exit "IGCM_sys_Tar" 
    688   fi 
    689   IGCM_debug_PopStack "IGCM_sys_Tar" 
    690 } 
    691  
    692 #D-#================================================== 
    693 #D-function IGCM_sys_UnTar 
    694 #D-* Purpose: master un-tar command 
    695 #D-* Examples: 
    696 #D- 
    697 function IGCM_sys_UnTar { 
    698   IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 
    699   if ( $DEBUG_sys ) ; then 
    700     echo "IGCM_sys_UnTar :" $@ 
    701   fi 
    702   \tar xvf $1 
    703   if [ $? -gt 0 ] ; then 
    704     echo "IGCM_sys_UnTar : erreur." 
    705     IGCM_debug_Exit "IGCM_sys_UnTar" 
    706   fi 
    707   IGCM_debug_PopStack "IGCM_sys_UnTar" 
    708387} 
    709388 
     
    774453 
    775454#D-#================================================== 
    776 #D-function IGCM_sys_Rsync_out 
    777 #D-* Purpose: treat return val of rsync 
    778 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync 
    779 #D-  Error values and explanations can depend on your system version. 
    780 function IGCM_sys_Rsync_out { 
    781   status=$1 
    782   if [ ! $status ] ; then 
    783     echo "rsync error !" 
    784   fi 
    785  
    786   if [ $MYLANG = "fr" ]; then 
    787     case $status in 
    788     0)  return ;; 
    789     1)  echo "Erreur de rsync ; RERR_SYNTAX : " 
    790       echo "Erreur de syntaxe ou d'utilisation." 
    791       return;; 
    792     2)  echo "Erreur de rsync ; RERR_PROTOCOL : " 
    793       echo "Incompatibilité de protocole." 
    794       return;; 
    795     3)  echo "Erreur de rsync ; RERR_FILESELECT 3" 
    796       echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et" 
    797       echo "répertoires" 
    798       return;; 
    799     4)  echo "Erreur de rsync ; RERR_UNSUPPORTED" 
    800       echo "Action demandée non supportée : une tentative de manipulation de" 
    801       echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a" 
    802       echo "été faite ; ou une option qui est supportée par le  client  mais" 
    803       echo "pas par le serveur a été spécifiée." 
    804       return;; 
    805     10) echo "Erreur de rsync ; RERR_SOCKETIO" 
    806       echo "Erreur dans le socket d'entrée sortie" 
    807       return;; 
    808     11) echo "Erreur de rsync ; RERR_FILEIO" 
    809       echo "Erreur d'entrée sortie fichier" 
    810       return;; 
    811     12) echo "Erreur de rsync ; RERR_STREAMIO" 
    812       echo "Erreur dans flux de donnée du protocole rsync" 
    813       return;; 
    814     13) echo "Erreur de rsync ; RERR_MESSAGEIO" 
    815       echo "Erreur avec les diagnostics du programme" 
    816       return;; 
    817     14) echo "Erreur de rsync ; RERR_IPC" 
    818       echo "Erreur dans le code IPC" 
    819       return;; 
    820     20) echo "Erreur de rsync ; RERR_SIGNAL" 
    821       echo "SIGUSR1 ou SIGINT reçu" 
    822       return;; 
    823     21) echo "Erreur de rsync ; RERR_WAITCHILD" 
    824       echo "Une erreur retournée par waitpid()" 
    825       return;; 
    826     22) echo "Erreur de rsync ; RERR_MALLOC" 
    827       echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 
    828       return;; 
    829     23) echo "" 
    830       echo "Erreur fichier inexistant" 
    831       return;; 
    832     30) echo "Erreur de rsync ; RERR_TIMEOUT" 
    833       echo "Temps d'attente écoulé dans l'envoi/réception de données" 
    834       return;; 
    835     *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status 
    836       return;; 
    837     esac 
    838   elif [ $MYLANG = "en" ] ; then 
    839     case $status in 
    840     0)  return;; 
    841     1)  echo "rsync error : Syntax or usage error " 
    842       return;; 
    843     2)  echo "rsync error : Protocol incompatibility " 
    844       return;; 
    845     3)  echo "rsync error : Errors selecting input/output files, dirs" 
    846       return;; 
    847     4)  echo "rsync error : Requested action not supported: an attempt" 
    848       echo "was made to manipulate 64-bit files on a platform that cannot support" 
    849       echo "them; or an option was specified that is supported by the client and" 
    850       echo "not by the server." 
    851       return;; 
    852     5)  echo "rsync error : Error starting client-server protocol" 
    853       return;; 
    854     10) echo "rsync error : Error in socket I/O " 
    855       return;; 
    856     11) echo "rsync error : Error in file I/O " 
    857       return;; 
    858     12) echo "rsync error : Error in rsync protocol data stream " 
    859       return;; 
    860     13) echo "rsync error : Errors with program diagnostics " 
    861       return;; 
    862     14) echo "rsync error : Error in IPC code " 
    863       return;; 
    864     20) echo "rsync error : Received SIGUSR1 or SIGINT " 
    865       return;; 
    866     21) echo "rsync error : Some error returned by waitpid() " 
    867       return;; 
    868     22) echo "rsync error : Error allocating core memory buffers " 
    869       return;; 
    870     23) echo "rsync error : Partial transfer due to error" 
    871       return;; 
    872     24) echo "rsync error : Partial transfer due to vanished source files" 
    873       return;; 
    874     30) echo "rsync error : Timeout in data send/receive " 
    875       return;; 
    876     *)  echo "rsync error : return code of rsync unknown :" $status 
    877       return;; 
    878     esac 
    879   else 
    880     echo "unknown language $MYLANG." 
    881     return 
    882   fi 
    883 } 
    884  
    885 #D-#================================================== 
    886 #D-function IGCM_sys_Miror_libIGCM 
    887 #D-* Purpose: Mirror libIGCM PATH and lib to frontend 
    888 #D-* Examples: 
    889 #D- 
    890 function IGCM_sys_Mirror_libIGCM { 
    891   IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 
    892   if ( $DEBUG_sys ) ; then 
    893     echo "IGCM_sys_Mirror_libIGCM" 
    894   fi 
    895  
    896   typeset status 
    897  
    898   mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 
    899  
    900   echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    901   ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    902   status=$? 
    903  
    904   if [ ${status} -gt 0 ] ; then 
    905     echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." 
    906     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    907   fi 
    908   IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 
    909 } 
    910  
    911 #D-#================================================== 
    912 #D-function IGCM_sys_Cp 
    913 #D-* Purpose: generic cp 
    914 #D-* Examples: 
    915 #D- 
    916 function IGCM_sys_Cp { 
    917   IGCM_debug_PushStack "IGCM_sys_Cp" $@ 
    918   if ( $DEBUG_sys ) ; then 
    919     echo "IGCM_sys_Cp :" $@ 
    920   fi 
    921  
    922   typeset status 
    923  
    924   echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    925   \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    926   status=$? 
    927  
    928   if [ ${status} -gt 0 ] ; then 
    929     echo "IGCM_sys_Cp : error code ${status}" 
    930     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    931     IGCM_debug_Exit "IGCM_sys_Cp" 
    932   else 
    933     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    934   fi 
    935   IGCM_debug_PopStack "IGCM_sys_Cp" 
    936 } 
    937  
    938 #D-#================================================== 
    939 #D-function IGCM_sys_Rm 
    940 #D-* Purpose: generic rm 
    941 #D-* Examples: 
    942 #D- 
    943 function IGCM_sys_Rm { 
    944   IGCM_debug_PushStack "IGCM_sys_Rm" $@ 
    945   if ( $DEBUG_sys ) ; then 
    946     echo "IGCM_sys_Rm :" $@ 
    947   fi 
    948  
    949   typeset status 
    950  
    951   echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    952   \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    953   status=$? 
    954  
    955   if [ ${status} -gt 0 ] ; then 
    956     echo "IGCM_sys_Rm : error code ${status}" 
    957     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    958     IGCM_debug_Exit "IGCM_sys_Rm" 
    959   else 
    960     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    961   fi 
    962   IGCM_debug_PopStack "IGCM_sys_Rm" 
    963 } 
    964  
    965 #D-#================================================== 
    966455#D-function IGCM_sys_RmRunDir 
    967456#D-* Purpose: rm tmpdir (dummy function most of the time batch 
     
    989478  fi 
    990479  IGCM_debug_PopStack "IGCM_sys_RmRunDir" 
    991 } 
    992  
    993 #D-#================================================== 
    994 #D-function IGCM_sys_Mv 
    995 #D-* Purpose: generic move 
    996 #D-* Examples: 
    997 #D- 
    998 function IGCM_sys_Mv { 
    999   IGCM_debug_PushStack "IGCM_sys_Mv" $@ 
    1000   if ( $DEBUG_sys ) ; then 
    1001     echo "IGCM_sys_Mv :" $@ 
    1002   fi 
    1003  
    1004   if [ $DRYRUN = 0 ]; then 
    1005  
    1006     typeset status 
    1007  
    1008     echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1009     \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1010     status=$? 
    1011  
    1012     if [ ${status} -gt 0 ] ; then 
    1013       echo "IGCM_sys_Mv : error code ${status}" 
    1014       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1015       IGCM_debug_Exit "IGCM_sys_Mv" 
    1016     else 
    1017       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1018     fi 
    1019   fi 
    1020   IGCM_debug_PopStack "IGCM_sys_Mv" 
    1021480} 
    1022481 
     
    1106565 
    1107566#D-#================================================== 
    1108 #D-function IGCM_sys_Get_Master 
    1109 #D-* Purpose: Copy a complete directory from MASTER filesystem 
    1110 #D-* Examples: 
    1111 #D- 
    1112 function IGCM_sys_Get_Master { 
    1113   IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 
    1114   if ( $DEBUG_sys ) ; then 
    1115     echo "IGCM_sys_Get_Master :" $@ 
    1116   fi 
    1117   if [ $DRYRUN = 0 ]; then 
    1118     if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then 
    1119       echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 
    1120       IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    1121       return 
    1122     fi 
    1123  
    1124     typeset NB_ESSAI DELAI status i 
    1125     # number of tentative 
    1126     NB_ESSAI=3 
    1127     # time delay between tentative 
    1128     DELAI=2 
    1129  
    1130     i=0 
    1131     while [ $i -lt $NB_ESSAI ] ; do 
    1132       \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1133       status=$? 
    1134       if [ ${status} -gt 0 ]; then 
    1135         IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1136         IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 
    1137         sleep $DELAI 
    1138       else 
    1139         break 
    1140       fi 
    1141       (( i = i + 1 )) 
    1142     done 
    1143  
    1144     if [ ${status} -gt 0 ] ; then 
    1145       echo "IGCM_sys_Get_Master : error." 
    1146       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1147       IGCM_debug_Exit "IGCM_sys_Get_Master" 
    1148     else 
    1149       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1150     fi 
    1151   fi 
    1152   IGCM_debug_PopStack "IGCM_sys_Get_Master" 
    1153 } 
    1154  
    1155 #==================================================== 
    1156 #- Call IGCM_sys_Mirror_libIGCM now ! 
    1157 if ( $MirrorlibIGCM ) ; then 
    1158   IGCM_sys_Mirror_libIGCM 
    1159 fi 
    1160  
    1161 #D-#================================================== 
    1162567#D-function IGCM_sys_Put_Rest 
    1163568#D-* Purpose: Put computied restarts on ${ARCHIVE}. 
     
    1214619  fi 
    1215620  IGCM_debug_PopStack "IGCM_sys_Put_Rest" 
    1216 } 
    1217  
    1218 #D-#================================================== 
    1219 #D-function IGCM_sys_PutBuffer_Rest 
    1220 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 
    1221 #D-           File and target directory must exist. 
    1222 #D-* Examples: 
    1223 #D- 
    1224 function IGCM_sys_PutBuffer_Rest { 
    1225   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 
    1226   if ( $DEBUG_sys ) ; then 
    1227     echo "IGCM_sys_PutBuffer_Rest :" $@ 
    1228   fi 
    1229   if [ $DRYRUN = 0 ]; then 
    1230     if [ ! -f ${1} ] ; then 
    1231       echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 
    1232       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1233     fi 
    1234  
    1235     typeset status 
    1236     # 
    1237     # USUAL WAY 
    1238     \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1239     status=$? 
    1240  
    1241     if [ ${status} -gt 0 ] ; then 
    1242       echo "IGCM_sys_PutBuffer_Rest : error code ${status}" 
    1243       [ -f ${2} ] && ls -l ${2} 
    1244       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1245       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1246       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 
    1247     else 
    1248  
    1249       if [ X${JobType} = XRUN ] ; then 
    1250         [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
    1251         [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
    1252       fi 
    1253  
    1254       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1255     fi 
    1256   fi 
    1257   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 
    1258 } 
    1259  
    1260 #D-#================================================== 
    1261 #D-function IGCM_sys_PrepareTaredRestart 
    1262 #D-* Purpose: Prepare tared restart to be access by computing job. 
    1263 #D-* Examples: 
    1264 #D- 
    1265 function IGCM_sys_PrepareTaredRestart { 
    1266   IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ 
    1267   if [ $DRYRUN = 0 ]; then 
    1268     [ ! -f $( basename $1 ) ] && IGCM_sys_Get $1 . 
    1269   fi 
    1270   IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" 
    1271621} 
    1272622 
     
    1377727  fi 
    1378728  IGCM_debug_PopStack "IGCM_sys_Put_Out" 
    1379   return 0 
    1380 } 
    1381  
    1382 #D-#================================================== 
    1383 #D-function IGCM_sys_PutBuffer_Out 
    1384 #D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly 
    1385 #D-* Examples: 
    1386 #D- 
    1387 function IGCM_sys_PutBuffer_Out { 
    1388   IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 
    1389   if ( $DEBUG_sys ) ; then 
    1390     echo "IGCM_sys_PutBuffer_Out :" $@ 
    1391   fi 
    1392  
    1393   typeset NB_ESSAI DELAI status i exist skip 
    1394  
    1395   # number of tentative 
    1396   NB_ESSAI=3 
    1397   # time delay between tentative 
    1398   DELAI=2 
    1399  
    1400   if [ $DRYRUN = 0 ]; then 
    1401     if [ ! -f ${1} ] ; then 
    1402       echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 
    1403       IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1404       return 1 
    1405     fi 
    1406     # 
    1407     IGCM_sys_Mkdir $( dirname $2 ) 
    1408     # 
    1409  
    1410     exist=false 
    1411     skip=false 
    1412     if [ -f $2 ] ; then 
    1413       IGCM_debug_Print 1 "$2 already exist" 
    1414       exist=true 
    1415       if [ "X$( diff $1 $2 )" = X ] ; then 
    1416         IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
    1417         status=0 
    1418         skip=true 
    1419       else 
    1420         IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    1421         skip=false 
    1422       fi 
    1423     fi 
    1424     # 
    1425     if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
    1426       IGCM_sys_Chmod u+w $2 
    1427     fi 
    1428  
    1429     if [ X${skip} = Xfalse ] ; then 
    1430       i=0 
    1431       while [ $i -lt $NB_ESSAI ] ; do 
    1432         if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then 
    1433           # USUAL WAY 
    1434           \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1435           status=$? 
    1436         else 
    1437           # NOT SO USUAL WAY 
    1438           \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1439           status=$? 
    1440         fi 
    1441         if [ ${status} -gt 0 ]; then 
    1442           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1443           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 
    1444           [ -f ${2} ] && ls -l ${2} 
    1445           [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1446           sleep $DELAI 
    1447         else 
    1448           break 
    1449         fi 
    1450         (( i = i + 1 )) 
    1451       done 
    1452     fi 
    1453  
    1454     if [ ${status} -gt 0 ] ; then 
    1455       echo "IGCM_sys_PutBuffer_Out : error." 
    1456       [ -f ${2} ] && ls -l ${2} 
    1457       [ -f ${2}/${1} ] && ls -l ${2}/${1} 
    1458       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1459       IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 
    1460     else 
    1461  
    1462       if [ X${JobType} = XRUN ] ; then 
    1463         if [ X${3} = X ] ; then 
    1464           [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 
    1465           [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 
    1466         fi 
    1467       fi 
    1468  
    1469       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1470     fi 
    1471   fi 
    1472   IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 
    1473729  return 0 
    1474730} 
     
    1613869 
    1614870#D-#================================================== 
    1615 #D-function IGCM_sys_GetBuffer 
    1616 #D-* Purpose: Get a file from ${SCRATCHDIR} 
    1617 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 
    1618 #D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 
    1619 function IGCM_sys_GetBuffer { 
    1620   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
    1621  
    1622   typeset DEST buf_liste target file_work 
    1623   typeset NB_ESSAI DELAI status i 
    1624  
    1625   if ( $DEBUG_sys ) ; then 
    1626     echo "IGCM_sys_GetBuffer :" $@ 
    1627   fi 
    1628  
    1629   # number of tentative 
    1630   NB_ESSAI=3 
    1631   # time delay between tentative 
    1632   DELAI=2 
    1633  
    1634   if [ $DRYRUN -le 2 ]; then 
    1635     if [ X${1} = X'/l' ] ; then 
    1636       eval set +A buf_liste \${${2}} 
    1637     else 
    1638       eval set +A buf_liste ${1} 
    1639     fi 
    1640     eval DEST=\${${#}} 
    1641  
    1642     #USUAL WAY 
    1643     if [ X${1} = X'/l' ] ; then 
    1644       for target in ${buf_liste[*]} ; do 
    1645         local_file=$( basename ${target} ) 
    1646         i=0 
    1647         while [ $i -lt $NB_ESSAI ] ; do 
    1648           \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1649           status=$? 
    1650           if [ ${status} -gt 0 ]; then 
    1651             IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1652             IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
    1653             sleep $DELAI 
    1654           else 
    1655             break 
    1656           fi 
    1657           (( i = i + 1 )) 
    1658         done 
    1659         if [ ${status} -gt 0 ] ; then 
    1660           echo "IGCM_sys_Get : error" 
    1661           cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1662           \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1663           IGCM_debug_Exit "IGCM_sys_GetBuffer" 
    1664         else 
    1665           \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1666         fi 
    1667       done 
    1668     else 
    1669       i=0 
    1670       while [ $i -lt $NB_ESSAI ] ; do 
    1671         \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1672         status=$? 
    1673         if [ ${status} -gt 0 ]; then 
    1674           IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 
    1675           IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 
    1676           sleep $DELAI 
    1677         else 
    1678           break 
    1679         fi 
    1680         (( i = i + 1 )) 
    1681       done 
    1682       if [ ${status} -gt 0 ] ; then 
    1683         echo "IGCM_sys_Get : error" 
    1684         cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1685         \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1686         IGCM_debug_Exit "IGCM_sys_GetBuffer" 
    1687       else 
    1688         \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1689       fi 
    1690     fi 
    1691   fi 
    1692   IGCM_debug_PopStack "IGCM_sys_GetBuffer" 
    1693 } 
    1694  
    1695 #D-#================================================== 
    1696 #D-function IGCM_sys_GetDate_FichWork 
    1697 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 
    1698 #D-* Examples: 
    1699 #D- 
    1700 function IGCM_sys_GetDate_FichWork { 
    1701   IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 
    1702   if ( $DEBUG_sys ) ; then 
    1703     echo "IGCM_sys_GetDate_FichWork :" $@ 
    1704   fi 
    1705  
    1706   if [ $# -ge 3 ] ; then 
    1707     mode=$3 
    1708     TimeStyle=$4 
    1709   else 
    1710     mode="default" 
    1711     TimeStyle="%Y%m%d%H%M%S" 
    1712   fi 
    1713  
    1714   typeset dateF 
    1715   set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} ) 
    1716  
    1717   case $mode in 
    1718     "default") 
    1719       eval ${2}=${dateF[5]} 
    1720       ;; 
    1721     "SplitFields") 
    1722       eval ${2}="${dateF[5]}\ ${dateF[6]}" 
    1723       ;; 
    1724   esac 
    1725  
    1726  
    1727   # donne la date filesys d'un fichier sur la machine work 
    1728   IGCM_debug_PopStack "IGCM_sys_FichWork" 
    1729 } 
    1730  
    1731 #D-#================================================== 
    1732 #D-function IGCM_sys_GetDate_FichArchive 
    1733 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE 
    1734 #D-* Examples: 
    1735 #D- 
    1736 function IGCM_sys_GetDate_FichArchive { 
    1737   IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 
    1738   if ( $DEBUG_sys ) ; then 
    1739     echo "IGCM_sys_GetDate_FichArchive :" $@ 
    1740   fi 
    1741   typeset dateF 
    1742   set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} ) 
    1743   eval ${2}=${dateF[5]} 
    1744  
    1745   IGCM_debug_PopStack "IGCM_sys_FichArchive" 
    1746 } 
    1747  
    1748 #D-#================================================== 
    1749871#D-function IGCM_sys_GetDate_Monitoring 
    1750872#D-* Purpose: get the last year for which the monitoring has been computed 
     
    18911013 
    18921014  IGCM_debug_PopStack "IGCM_sys_sync" 
    1893 } 
    1894  
    1895 #D-#================================================== 
    1896 #D-function IGCM_sys_rebuild 
    1897 #D-* Purpose: rebuild parallel files 
    1898 #D-* Examples: 
    1899 #D- 
    1900 function IGCM_sys_rebuild { 
    1901   IGCM_debug_PushStack "IGCM_sys_rebuild" $@ 
    1902   if ( $DEBUG_sys ) ; then 
    1903     echo "IGCM_sys_rebuild :" $@ 
    1904   fi 
    1905  
    1906   typeset NB_ESSAI DELAI status i firstArg 
    1907   # number of tentative 
    1908   NB_ESSAI=3 
    1909   # time delay between tentative 
    1910   DELAI=2 
    1911  
    1912   i=0 
    1913   while [ $i -lt $NB_ESSAI ] ; do 
    1914     rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    1915     status=$? 
    1916     if [ ${status} -gt 0 ] ; then 
    1917       IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" 
    1918       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1919       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1920       IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    1921       firstArg=${1} 
    1922       \rm ${firstArg} 
    1923       sleep $DELAI 
    1924     else 
    1925       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    1926       break 
    1927     fi 
    1928     (( i = i + 1 )) 
    1929   done 
    1930  
    1931   if [ ${status} -gt 0 ] ; then 
    1932     echo "IGCM_sys_rebuild : rebuild error code is ${status}" 
    1933     IGCM_debug_Exit "rebuild" 
    1934   fi 
    1935  
    1936   IGCM_debug_PopStack "IGCM_sys_rebuild" 
    1937 } 
    1938  
    1939 #D-#================================================== 
    1940 #D-function IGCM_sys_rebuild_station 
    1941 #D-* Purpose: rebuild parallel files describing station 
    1942 #D-* Examples: 
    1943 #D- 
    1944 function IGCM_sys_rebuild_station { 
    1945   IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@ 
    1946   typeset i list_opt file_in file_out prefix_invert list_invert 
    1947   if ( $DEBUG_sys ) ; then 
    1948     echo "IGCM_sys_rebuild_station :" $@ 
    1949   fi 
    1950   list_opt=$@ 
    1951  
    1952   # Invert Axis : t,x -> x,t 
    1953   #               t,pres,x -> x,t,pres 
    1954   # So that we can concatenate along x 
    1955   i=0 
    1956   for file_in in ${list_opt} ; do 
    1957     (( i = i + 1)) 
    1958     [ ${i} = 1 ] && file_out=${file_in} && continue 
    1959     # detect time counter and do the job only if present 
    1960     var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') 
    1961     if [ X${var_unlim} = Xtime_counter ] ; then 
    1962       prefix_invert=$( basename ${file_in} .nc ) 
    1963       IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc 
    1964       list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc 
    1965     fi 
    1966   done 
    1967  
    1968   # Concatenate 
    1969   IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc 
    1970  
    1971   # Re-ivert file 
    1972   IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} 
    1973  
    1974   # Station re-ordering is too expansive to be run within libIGCM 
    1975   # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. 
    1976   # This re-ordering must be done "in memory" by the cmorization process 
    1977   # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) 
    1978   # BEGIN reordering 
    1979  
    1980   # Only LMDZ text output contains the exact ordering of the station. 
    1981   # We isolate this in the code below: 
    1982   #  0  38  -157.5000000000000  70.98591549295774 
    1983   #  0  54  27.49999999999999   67.18309859154928 
    1984   #  0  56  -62.50000000000001  82.39436619718309 
    1985   #  0  79  12.49999999999999   78.59154929577466 
    1986   #  0  116 -165.0000000000000  76.05633802816901 
    1987   #  0  117 130.0000000000000   70.98591549295774 
    1988   #  0  118 110.0000000000000   87.46478873239437 
    1989   #  1  40  4.999999999999995   51.97183098591550 
    1990  
    1991 #  typeset iStation iProc list_opt file_in file_out prefix_invert 
    1992 #  typeset -Z4 j4 
    1993 #  typeset -Z3 j3 
    1994  
    1995 #  unset list_opt 
    1996 #  set +A list_opt $@ 
    1997  
    1998   # Filename after rebuild 
    1999 #  file_out=${list_opt[0]} 
    2000   # Prefix of output files 
    2001 #  prefix_invert=$( basename ${file_out} .nc ) 
    2002   # Number of procs 
    2003 #  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) 
    2004  
    2005 #  iProc=0 
    2006 #  while [ ${iProc} -lt ${num_proc} ] ; do 
    2007     # Array containing Station as a number 
    2008 #    unset proc_stn 
    2009 #    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}' ) 
    2010     # Number of stations produced by processor proc 
    2011 #    stationLast=${#proc_stn[*]} 
    2012     # Proc number on 4 digits 
    2013 #    j4=${iProc} 
    2014     # Init 
    2015 #    iStation=0 
    2016 #    while [ ${iStation} -lt ${stationLast} ] ; do 
    2017       # Station number on 3 digits 
    2018 #      j3=${proc_stn[${iStation}]} 
    2019       # Extract station 
    2020       # Invert Axis : t,x -> x,t 
    2021       #               t,pres,x -> x,t,pres 
    2022       # So that we can concatenate along x 
    2023 #      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 
    2024 #      (( iStation = iStation + 1 )) 
    2025 #    done 
    2026 #    (( iProc = iProc + 1 )) 
    2027 #  done 
    2028  
    2029   # Concatenate all station along x 
    2030 #  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc 
    2031  
    2032   # Re-invert file 
    2033 #  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} 
    2034  
    2035   # END reordering 
    2036  
    2037   IGCM_debug_PopStack "IGCM_sys_rebuild_station" 
    20381015} 
    20391016 
     
    25671544  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue" 
    25681545} 
    2569  
    2570 ############################################################## 
    2571 # NCO OPERATOR 
    2572  
    2573 #D-#================================================== 
    2574 #D-function IGCM_sys_ncap2 
    2575 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry 
    2576 #D-* Examples: 
    2577 #D- 
    2578 function IGCM_sys_ncap2 { 
    2579   IGCM_debug_PushStack "IGCM_sys_ncap2" $@ 
    2580   if ( $DEBUG_sys ) ; then 
    2581     echo "IGCM_sys_ncap2 :" $@ 
    2582   fi 
    2583  
    2584   typeset NB_ESSAI DELAI status i 
    2585   # number of tentative 
    2586   NB_ESSAI=3 
    2587   # time delay between tentative 
    2588   DELAI=2 
    2589  
    2590   i=0 
    2591   while [ $i -lt $NB_ESSAI ] ; do 
    2592     ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2593     status=$? 
    2594     if [ ${status} -gt 0 ] ; then 
    2595       IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" 
    2596       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2597       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2598       IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2599       sleep $DELAI 
    2600     else 
    2601       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2602       break 
    2603     fi 
    2604     (( i = i + 1 )) 
    2605   done 
    2606  
    2607   if [ ${status} -gt 0 ] ; then 
    2608     echo "IGCM_sys_ncap2 : ncap2 error" 
    2609     IGCM_debug_Exit "ncap2" 
    2610   fi 
    2611  
    2612   IGCM_debug_PopStack "IGCM_sys_ncap2" 
    2613 } 
    2614  
    2615 #D-#================================================== 
    2616 #D-function IGCM_sys_ncatted 
    2617 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry 
    2618 #D-* Examples: 
    2619 #D- 
    2620 function IGCM_sys_ncatted { 
    2621   IGCM_debug_PushStack "IGCM_sys_ncatted" $@ 
    2622   if ( $DEBUG_sys ) ; then 
    2623     echo "IGCM_sys_ncatted :" $@ 
    2624   fi 
    2625  
    2626   typeset NB_ESSAI DELAI status i 
    2627   # number of tentative 
    2628   NB_ESSAI=3 
    2629   # time delay between tentative 
    2630   DELAI=2 
    2631  
    2632   i=0 
    2633   while [ $i -lt $NB_ESSAI ] ; do 
    2634     ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2635     status=$? 
    2636     if [ ${status} -gt 0 ] ; then 
    2637       IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" 
    2638       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2639       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2640       IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2641       sleep $DELAI 
    2642     else 
    2643       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2644       break 
    2645     fi 
    2646     (( i = i + 1 )) 
    2647   done 
    2648  
    2649   if [ ${status} -gt 0 ] ; then 
    2650     echo "IGCM_sys_ncatted : ncatted error" 
    2651     IGCM_debug_Exit "ncatted" 
    2652   fi 
    2653  
    2654   IGCM_debug_PopStack "IGCM_sys_ncatted" 
    2655 } 
    2656  
    2657 #D-#================================================== 
    2658 #D-function IGCM_sys_ncbo 
    2659 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry 
    2660 #D-* Examples: 
    2661 #D- 
    2662 function IGCM_sys_ncbo { 
    2663   IGCM_debug_PushStack "IGCM_sys_ncbo" $@ 
    2664   if ( $DEBUG_sys ) ; then 
    2665     echo "IGCM_sys_ncbo :" $@ 
    2666   fi 
    2667  
    2668   typeset NB_ESSAI DELAI status i 
    2669   # number of tentative 
    2670   NB_ESSAI=3 
    2671   # time delay between tentative 
    2672   DELAI=2 
    2673  
    2674   i=0 
    2675   while [ $i -lt $NB_ESSAI ] ; do 
    2676     ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2677     status=$? 
    2678     if [ ${status} -gt 0 ] ; then 
    2679       IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" 
    2680       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2681       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2682       IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2683       sleep $DELAI 
    2684     else 
    2685       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2686       break 
    2687     fi 
    2688     (( i = i + 1 )) 
    2689   done 
    2690  
    2691   if [ ${status} -gt 0 ] ; then 
    2692     echo "IGCM_sys_ncbo : ncbo error" 
    2693     IGCM_debug_Exit "ncbo" 
    2694   fi 
    2695  
    2696   IGCM_debug_PopStack "IGCM_sys_ncbo" 
    2697 } 
    2698  
    2699 #D-#================================================== 
    2700 #D-function IGCM_sys_ncdif 
    2701 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry 
    2702 #D-* Examples: 
    2703 #D- 
    2704 function IGCM_sys_ncdiff { 
    2705   IGCM_debug_PushStack "IGCM_sys_ncdiff" $@ 
    2706   if ( $DEBUG_sys ) ; then 
    2707     echo "IGCM_sys_ncdiff :" $@ 
    2708   fi 
    2709  
    2710   typeset NB_ESSAI DELAI status i 
    2711   # number of tentative 
    2712   NB_ESSAI=3 
    2713   # time delay between tentative 
    2714   DELAI=2 
    2715  
    2716   i=0 
    2717   while [ $i -lt $NB_ESSAI ] ; do 
    2718     ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2719     status=$? 
    2720     if [ ${status} -gt 0 ] ; then 
    2721       IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" 
    2722       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2723       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2724       IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2725       sleep $DELAI 
    2726     else 
    2727       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2728       break 
    2729     fi 
    2730     (( i = i + 1 )) 
    2731   done 
    2732  
    2733   if [ ${status} -gt 0 ] ; then 
    2734     echo "IGCM_sys_ncdiff : ncdiff error" 
    2735     IGCM_debug_Exit "ncdiff" 
    2736   fi 
    2737  
    2738   IGCM_debug_PopStack "IGCM_sys_ncdiff" 
    2739 } 
    2740  
    2741 #D-#================================================== 
    2742 #D-function IGCM_sys_ncea 
    2743 #D-* Purpose: encapsulate ncea call so as to manage error code and retry 
    2744 #D-* Examples: 
    2745 #D- 
    2746 function IGCM_sys_ncea { 
    2747   IGCM_debug_PushStack "IGCM_sys_ncea" $@ 
    2748   if ( $DEBUG_sys ) ; then 
    2749     echo "IGCM_sys_ncea :" $@ 
    2750   fi 
    2751  
    2752   typeset NB_ESSAI DELAI status i 
    2753   # number of tentative 
    2754   NB_ESSAI=3 
    2755   # time delay between tentative 
    2756   DELAI=2 
    2757  
    2758   i=0 
    2759   while [ $i -lt $NB_ESSAI ] ; do 
    2760     ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2761     status=$? 
    2762     if [ ${status} -gt 0 ] ; then 
    2763       IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" 
    2764       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2765       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2766       IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2767       sleep $DELAI 
    2768     else 
    2769       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2770       break 
    2771     fi 
    2772     (( i = i + 1 )) 
    2773   done 
    2774  
    2775   if [ ${status} -gt 0 ] ; then 
    2776     echo "IGCM_sys_ncea : ncea error" 
    2777     IGCM_debug_Exit "ncea" 
    2778   fi 
    2779  
    2780   IGCM_debug_PopStack "IGCM_sys_ncea" 
    2781 } 
    2782  
    2783 #D-#================================================== 
    2784 #D-function IGCM_sys_ncecat 
    2785 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry 
    2786 #D-* Examples: 
    2787 #D- 
    2788 function IGCM_sys_ncecat { 
    2789   IGCM_debug_PushStack "IGCM_sys_ncecat" $@ 
    2790   if ( $DEBUG_sys ) ; then 
    2791     echo "IGCM_sys_ncecat :" $@ 
    2792   fi 
    2793  
    2794   typeset NB_ESSAI DELAI status i 
    2795   # number of tentative 
    2796   NB_ESSAI=3 
    2797   # time delay between tentative 
    2798   DELAI=2 
    2799  
    2800   i=0 
    2801   while [ $i -lt $NB_ESSAI ] ; do 
    2802     ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2803     status=$? 
    2804     if [ ${status} -gt 0 ] ; then 
    2805       IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" 
    2806       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2807       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2808       IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2809       sleep $DELAI 
    2810     else 
    2811       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2812       break 
    2813     fi 
    2814     (( i = i + 1 )) 
    2815   done 
    2816  
    2817   if [ ${status} -gt 0 ] ; then 
    2818     echo "IGCM_sys_ncecat : ncecat error" 
    2819     IGCM_debug_Exit "ncecat" 
    2820   fi 
    2821  
    2822   IGCM_debug_PopStack "IGCM_sys_ncecat" 
    2823 } 
    2824  
    2825 #D-#================================================== 
    2826 #D-function IGCM_sys_ncflint 
    2827 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry 
    2828 #D-* Examples: 
    2829 #D- 
    2830 function IGCM_sys_ncflint { 
    2831   IGCM_debug_PushStack "IGCM_sys_ncflint" $@ 
    2832   if ( $DEBUG_sys ) ; then 
    2833     echo "IGCM_sys_ncflint :" $@ 
    2834   fi 
    2835  
    2836   typeset NB_ESSAI DELAI status i 
    2837   # number of tentative 
    2838   NB_ESSAI=3 
    2839   # time delay between tentative 
    2840   DELAI=2 
    2841  
    2842   i=0 
    2843   while [ $i -lt $NB_ESSAI ] ; do 
    2844     ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2845     status=$? 
    2846     if [ ${status} -gt 0 ] ; then 
    2847       IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" 
    2848       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2849       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2850       IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2851       sleep $DELAI 
    2852     else 
    2853       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2854       break 
    2855     fi 
    2856     (( i = i + 1 )) 
    2857   done 
    2858  
    2859   if [ ${status} -gt 0 ] ; then 
    2860     echo "IGCM_sys_ncflint : ncflint error" 
    2861     IGCM_debug_Exit "ncflint" 
    2862   fi 
    2863  
    2864   IGCM_debug_PopStack "IGCM_sys_ncflint" 
    2865 } 
    2866  
    2867 #D-#================================================== 
    2868 #D-function IGCM_sys_ncks 
    2869 #D-* Purpose: encapsulate ncks call so as to manage error code and retry 
    2870 #D-* Examples: 
    2871 #D- 
    2872 function IGCM_sys_ncks { 
    2873   IGCM_debug_PushStack "IGCM_sys_ncks" $@ 
    2874   if ( $DEBUG_sys ) ; then 
    2875     echo "IGCM_sys_ncks :" $@ 
    2876   fi 
    2877  
    2878   typeset NB_ESSAI DELAI status i 
    2879   # number of tentative 
    2880   NB_ESSAI=3 
    2881   # time delay between tentative 
    2882   DELAI=2 
    2883  
    2884   i=0 
    2885   while [ $i -lt $NB_ESSAI ] ; do 
    2886     ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2887     status=$? 
    2888     if [ ${status} -gt 0 ] ; then 
    2889       IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" 
    2890       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2891       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2892       IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2893       sleep $DELAI 
    2894     else 
    2895       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2896       break 
    2897     fi 
    2898     (( i = i + 1 )) 
    2899   done 
    2900  
    2901   if [ ${status} -gt 0 ] ; then 
    2902     echo "IGCM_sys_ncks : ncks error" 
    2903     IGCM_debug_Exit "ncks" 
    2904   fi 
    2905  
    2906   IGCM_debug_PopStack "IGCM_sys_ncks" 
    2907 } 
    2908  
    2909 #D-#================================================== 
    2910 #D-function IGCM_sys_ncpdq 
    2911 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry 
    2912 #D-* Examples: 
    2913 #D- 
    2914 function IGCM_sys_ncpdq { 
    2915   IGCM_debug_PushStack "IGCM_sys_ncpdq" $@ 
    2916   if ( $DEBUG_sys ) ; then 
    2917     echo "IGCM_sys_ncpdq :" $@ 
    2918   fi 
    2919  
    2920   typeset NB_ESSAI DELAI status i 
    2921   # number of tentative 
    2922   NB_ESSAI=3 
    2923   # time delay between tentative 
    2924   DELAI=2 
    2925  
    2926   i=0 
    2927   while [ $i -lt $NB_ESSAI ] ; do 
    2928     ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2929     status=$? 
    2930     if [ ${status} -gt 0 ] ; then 
    2931       IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" 
    2932       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2933       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2934       IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2935       sleep $DELAI 
    2936     else 
    2937       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2938       break 
    2939     fi 
    2940     (( i = i + 1 )) 
    2941   done 
    2942  
    2943   if [ ${status} -gt 0 ] ; then 
    2944     echo "IGCM_sys_ncpdq : ncpdq error" 
    2945     IGCM_debug_Exit "ncpdq" 
    2946   fi 
    2947  
    2948   IGCM_debug_PopStack "IGCM_sys_ncpdq" 
    2949 } 
    2950  
    2951 #D-#================================================== 
    2952 #D-function IGCM_sys_ncra 
    2953 #D-* Purpose: encapsulate ncra call so as to manage error code and retry 
    2954 #D-* Examples: 
    2955 #D- 
    2956 function IGCM_sys_ncra { 
    2957   IGCM_debug_PushStack "IGCM_sys_ncra" $@ 
    2958   if ( $DEBUG_sys ) ; then 
    2959     echo "IGCM_sys_ncra :" $@ 
    2960   fi 
    2961  
    2962   typeset NB_ESSAI DELAI status i 
    2963   # number of tentative 
    2964   NB_ESSAI=3 
    2965   # time delay between tentative 
    2966   DELAI=2 
    2967  
    2968   i=0 
    2969   while [ $i -lt $NB_ESSAI ] ; do 
    2970     ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    2971     status=$? 
    2972     if [ ${status} -gt 0 ] ; then 
    2973       IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" 
    2974       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2975       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2976       IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    2977       sleep $DELAI 
    2978     else 
    2979       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    2980       break 
    2981     fi 
    2982     (( i = i + 1 )) 
    2983   done 
    2984  
    2985   if [ ${status} -gt 0 ] ; then 
    2986     echo "IGCM_sys_ncra : ncra error" 
    2987     IGCM_debug_Exit "ncra" 
    2988   fi 
    2989  
    2990   IGCM_debug_PopStack "IGCM_sys_ncra" 
    2991 } 
    2992  
    2993 #D-#================================================== 
    2994 #D-function IGCM_sys_ncrcat 
    2995 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry 
    2996 #D-* Examples: 
    2997 #D- 
    2998 function IGCM_sys_ncrcat { 
    2999   IGCM_debug_PushStack "IGCM_sys_ncrcat" $@ 
    3000   if ( $DEBUG_sys ) ; then 
    3001     echo "IGCM_sys_ncrcat :" $@ 
    3002   fi 
    3003  
    3004   typeset NB_ESSAI DELAI status i lastArg 
    3005   # number of tentative 
    3006   NB_ESSAI=3 
    3007   # time delay between tentative 
    3008   DELAI=2 
    3009  
    3010   i=0 
    3011   while [ $i -lt $NB_ESSAI ] ; do 
    3012     ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    3013     status=$? 
    3014     if [ ${status} -gt 0 ] ; then 
    3015       IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" 
    3016       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3017       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3018       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    3019       sleep $DELAI 
    3020     elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then 
    3021       IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" 
    3022       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3023       # remove files having corrupted time axis 
    3024       eval lastArg=\${$#} 
    3025       IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" 
    3026       \rm ${lastArg} 
    3027       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3028       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    3029       sleep $DELAI 
    3030     else 
    3031       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3032       break 
    3033     fi 
    3034     (( i = i + 1 )) 
    3035   done 
    3036  
    3037   if [ ${status} -gt 0 ] ; then 
    3038     echo "IGCM_sys_ncrcat : ncrcat error" 
    3039     #IGCM_debug_Exit "ncrcat" 
    3040   fi 
    3041  
    3042   IGCM_debug_PopStack "IGCM_sys_ncrcat" 
    3043 } 
    3044  
    3045 #D-#================================================== 
    3046 #D-function IGCM_sys_ncrename 
    3047 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry 
    3048 #D-* Examples: 
    3049 #D- 
    3050 function IGCM_sys_ncrename { 
    3051   IGCM_debug_PushStack "IGCM_sys_ncrename" $@ 
    3052   if ( $DEBUG_sys ) ; then 
    3053     echo "IGCM_sys_ncrename :" $@ 
    3054   fi 
    3055  
    3056   typeset NB_ESSAI DELAI status i 
    3057   # number of tentative 
    3058   NB_ESSAI=3 
    3059   # time delay between tentative 
    3060   DELAI=2 
    3061  
    3062   i=0 
    3063   while [ $i -lt $NB_ESSAI ] ; do 
    3064     ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    3065     status=$? 
    3066     if [ ${status} -gt 0 ] ; then 
    3067       IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" 
    3068       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3069       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3070       IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    3071       sleep $DELAI 
    3072     else 
    3073       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3074       break 
    3075     fi 
    3076     (( i = i + 1 )) 
    3077   done 
    3078  
    3079   if [ ${status} -gt 0 ] ; then 
    3080     echo "IGCM_sys_ncrename : ncrename error" 
    3081     IGCM_debug_Exit "ncrename" 
    3082   fi 
    3083  
    3084   IGCM_debug_PopStack "IGCM_sys_ncrename" 
    3085 } 
    3086  
    3087 #D-#================================================== 
    3088 #D-function IGCM_sys_ncwa 
    3089 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry 
    3090 #D-* Examples: 
    3091 #D- 
    3092 function IGCM_sys_ncwa { 
    3093   IGCM_debug_PushStack "IGCM_sys_ncwa" $@ 
    3094   if ( $DEBUG_sys ) ; then 
    3095     echo "IGCM_sys_ncwa :" $@ 
    3096   fi 
    3097  
    3098   typeset NB_ESSAI DELAI status i 
    3099   # number of tentative 
    3100   NB_ESSAI=3 
    3101   # time delay between tentative 
    3102   DELAI=2 
    3103  
    3104   i=0 
    3105   while [ $i -lt $NB_ESSAI ] ; do 
    3106     ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    3107     status=$? 
    3108     if [ ${status} -gt 0 ] ; then 
    3109       IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" 
    3110       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3111       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3112       IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 
    3113       sleep $DELAI 
    3114     else 
    3115       \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3116       break 
    3117     fi 
    3118     (( i = i + 1 )) 
    3119   done 
    3120  
    3121   if [ ${status} -gt 0 ] ; then 
    3122     echo "IGCM_sys_ncwa : ncwa error" 
    3123     IGCM_debug_Exit "ncwa" 
    3124   fi 
    3125  
    3126   IGCM_debug_PopStack "IGCM_sys_ncwa" 
    3127 } 
    3128  
    3129 ############################################################## 
    3130 # CDO OPERATOR 
    3131  
    3132 #D-#================================================== 
    3133 #D-function IGCM_sys_cdo 
    3134 #D-* Purpose: encapsulate cdo call so as to manage error code and retry 
    3135 #D-* Examples: 
    3136 #D- 
    3137 function IGCM_sys_cdo { 
    3138   IGCM_debug_PushStack "IGCM_sys_cdo" $@ 
    3139   if ( $DEBUG_sys ) ; then 
    3140     echo "IGCM_sys_cdo :" $@ 
    3141   fi 
    3142  
    3143   typeset status 
    3144  
    3145   \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 
    3146   status=$? 
    3147   if [ ${status} -gt 0 ] ; then 
    3148     echo "IGCM_sys_cdo : error code ${status}" 
    3149     cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3150     \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 
    3151     IGCM_debug_PopStack "IGCM_sys_cdo" 
    3152     return 1 
    3153   else 
    3154     IGCM_debug_PopStack "IGCM_sys_cdo" 
    3155     return 0 
    3156   fi 
    3157  
    3158   IGCM_debug_PopStack "IGCM_sys_cdo" 
    3159 } 
  • 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 } 
  • 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 } 
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh

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