source: CONFIG_DEVT/IPSLCM6.5_work_ENSEMBLES/libIGCM/libIGCM_sys/libIGCM_sys.ksh @ 5899

Last change on this file since 5899 was 5899, checked in by aclsce, 3 years ago

Modified libIGCM and configuration to run XIOS ensembles.

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