source: trunk/libIGCM/libIGCM_sys/libIGCM_sys.ksh @ 1624

Last change on this file since 1624 was 1624, checked in by jgipsl, 4 months ago

Added possibility to declare a restart file as optional which means that libIGCM want stop if the file is not found. Only a warning will be written.

For example, in the following case, if the routing_restart file is not available when starting the model or if it is not produced, libIGCM will not stop. But if the file sechiba_rest is not available, libIGCM will stop as usual.

[RestartFiles]
List=   (sechiba_rest_out.nc, sechiba_rest.nc, sechiba_rest_in.nc) ,\
        (routing_restart.nc, routing_restart.nc, routing_start.nc, OPTIONAL)
  • Read optional argument OPTIONAL on the line where the restart file is declared.
  • Each time when a restart file is not found for coping in or out, if the argument OPTIONAL is set, then just continue. If not set, the file is considered as MANDATORY and libIGCM will exist if it is missing as before.
  • on irene-amd and jean-zay, corrected a bug for the case in config.card DataProject?=DEFAULT


  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

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