source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh @ 945

Last change on this file since 945 was 938, checked in by sdipsl, 11 years ago

cleanup.
replace out_rsync by /tmp/out_command.$$

  • Property svn:keywords set to Revision Author Date
File size: 71.2 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip, Christian Laguerre
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
14#=========================================================
15# The documentation of this file can be automatically generated
16# if you use the prefix #D- for comments to be extracted.
17# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
18#=========================================================
19
20#D-#==================================================
21#D-LibIGCM_sys for obelix
22#D-#==================================================
23#D-
24#D- This ksh library if a layer under some usefull
25#D-environment variables and shell commands.
26#D-All those definitions depend on host particularities.
27#D-It manages a stack mechanism and test validity of operations.
28#D-All function described bellow must be prefixed by IGCM_sys.
29
30#====================================================
31# libIGCM_sys PARAMETERS
32#====================================================
33
34#====================================================
35# set DEBUG_sys to true to output calls of function
36typeset -r DEBUG_sys=${DEBUG_sys:=true}
37
38#====================================================
39# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
40typeset -r DRYRUN=${DRYRUN:=0}
41
42# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
43# -------------------------------------------------------------------------------------
44# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
45# |          |  Cp/Exe/param/files |            |         |                           |
46# |          |  Chmod Qsub         |            |         |                           |
47# -------------------------------------------------------------------------------------
48# |    0     |       yes           |    yes     |  yes    |      yes                  |
49# -------------------------------------------------------------------------------------
50# |    1     |       yes           |    yes     |  yes    |      no                   |
51# -------------------------------------------------------------------------------------
52# |    2     |       yes           |    yes     |  no     |      no                   |
53# -------------------------------------------------------------------------------------
54# |    3     |       yes           |    no      |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56
57#=====================================================
58# Global Variables :
59#=====================================================
60# Language : "fr" or "en"
61typeset -r MYLANG="fr"
62
63#=====================================================
64# Host and user names
65# $hostname ou hostname
66typeset  HOST=${HOST:=$( hostname )}
67# $username ou whoami
68typeset  LOGIN=${LOGIN:=$( whoami )}
69# $hostname of the MASTER job
70typeset MASTER=${MASTER:=$( hostname )}
71
72#D-
73#D-#==================================================
74#D-Program used in libIGCM
75#D-#==================================================
76
77# Submit command
78typeset SUBMIT=${SUBMIT:=qsub}
79# rsync with path
80typeset -r RSYNC=/usr/bin/rsync
81# RSYNC_opt args to rsync
82typeset -r RSYNC_opt="-va"
83# ie storage filesystem
84typeset -r STOREHOST=${MASTER}
85
86#====================================================
87# Set environment tools (ferret, nco, cdo)
88#====================================================
89. /home/users/brock/.atlas_env_asterix_ksh
90
91#====================================================
92# Set lf95 environment
93#====================================================
94. /usr/local/install/lf6481/bash_laheyfort_setup
95
96#====================================================
97# Host specific DIRECTORIES
98#====================================================
99
100#====================================================
101#- MirrorlibIGCM for frontend
102typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
103
104#====================================================
105#- libIGCM_POST for frontend
106typeset -r libIGCM_POST=${libIGCM}
107
108#====================================================
109#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
110typeset -r R_EXE="${MODIPSL}/bin"
111
112#====================================================
113#- SUBMIT_DIR : submission dir
114if [ X${PBS_O_WORKDIR} != X ] ; then
115  typeset -r SUBMIT_DIR=${SUBMIT_DIR:=${PBS_O_WORKDIR}}
116else
117  typeset -r SUBMIT_DIR=${SUBMIT_DIR:=${PWD}}
118fi
119
120#====================================================
121#- IN
122typeset -r R_IN=${R_IN:=/home/orchidee01/mmancip/IGCM}
123
124#====================================================
125#- ARCHIVE
126typeset ARCHIVE=${ARCHIVE:=/home/scratch01/${LOGIN}}
127
128#====================================================
129#- STORAGE (dedicated to small/medium files)
130typeset STORAGE=${ARCHIVE}
131
132#====================================================
133#- R_OUT
134typeset R_OUT=${ARCHIVE}/IGCM_OUT
135
136#====================================================
137#- R_FIG (hosting figures : monitoring and atlas, and/or small files)
138typeset R_FIG=${STORAGE}/IGCM_OUT
139
140#====================================================
141#- R_BUF (ONLY FOR double copy an scratch)
142typeset -r R_BUF=${STORAGE}/IGCM_OUT
143
144#====================================================
145#- RUN_DIR_PATH : Temporary working directory (=> TMP)
146if [ X${PBS_JOBID} != X ] ; then
147  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/scratch/$PBS_O_LOGNAME.$PBS_JOBID}
148else
149  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/tmp/tmp$$}
150fi
151
152#====================================================
153#- HOST_MPIRUN_COMMAND
154typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"}
155
156#====================================================
157#- Max number of arguments passed to nco operator or demigration command
158UNIX_MAX_LIMIT=360
159
160#====================================================
161#- Number of core per node (max number of OpenMP task)
162NUM_COREPERNODE=1
163
164#====================================================
165#- Default number of MPI task for IPSL coupled model
166#- required for backward compatibility
167#-
168DEFAULT_NUM_PROC_OCE=1
169DEFAULT_NUM_PROC_CPL=1
170(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
171DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
172
173#D-#==================================================
174#D-function IGCM_sys_ChangeArchive
175#D-* Purpose: Just a dummy call on this machine
176#D-* Examples:
177#D-
178function IGCM_sys_ChangeArchive {
179  IGCM_debug_Print 1 " dummy function : IGCM_sys_ChangeArchive "
180}
181
182#D-#==================================================
183#D-function IGCM_sys_RshMaster
184#D-* Purpose: Connection to frontend machine.
185#D-* Examples:
186#D-
187function IGCM_sys_RshMaster {
188  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
189  /bin/ksh  <<-EOF
190    export libIGCM=${libIGCM}
191    export DEBUG_debug=${DEBUG_debug}
192    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
193    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
194    ${@}
195EOF
196  if [ $? -gt 0 ] ; then
197    echo "IGCM_sys_RshMaster : erreur."
198    IGCM_debug_Exit "IGCM_sys_RshMaster"
199  fi
200  IGCM_debug_PopStack "IGCM_sys_RshMaster"
201}
202
203#D-#==================================================
204#D-function IGCM_sys_RshArchive
205#D-* Purpose: Archive rsh command
206#D-* Examples:
207#D-
208function IGCM_sys_RshArchive {
209  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
210  /bin/ksh <<-EOF
211    ${@}
212EOF
213  status=$?
214  if [ ${status} -gt 0 ] ; then
215    IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}"
216    IGCM_debug_Exit "IGCM_sys_RshArchive"
217  fi
218  IGCM_debug_PopStack "IGCM_sys_RshArchive"
219}
220
221#D-#==================================================
222#D-function IGCM_sys_RshPost
223#D-* Purpose: Post-process rsh command
224#D-* Examples:
225#D-
226function IGCM_sys_RshPost {
227  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
228  if ( $DEBUG_sys ) ; then
229    echo "IGCM_sys_RshPost :" $@
230  fi
231
232  # keep standard input (stdin) for the loop onto temporary file
233  cat >tmp_IGCM_sys_RshPost_$$
234
235# ============ FRONTEND START ============ #
236
237  /bin/ksh <tmp_IGCM_sys_RshPost_$$
238  if [ $? -gt 0 ] ; then
239    echo "IGCM_sys_RshPost : erreur."
240    IGCM_debug_Exit "IGCM_sys_RshPost"
241  fi
242  # delete temporary file
243  \rm tmp_IGCM_sys_RshPost_$$
244  IGCM_debug_PopStack "IGCM_sys_RshPost"
245}
246
247#D-#==================================================
248#D-function IGCM_sys_SendMail
249#D-* Purpose: Send mail when simulation is over
250#D-* Examples:
251#D-
252function IGCM_sys_SendMail {
253  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
254  if ( $DEBUG_sys ) ; then
255    echo "IGCM_sys_SendMail :" $@
256  fi
257
258  if [ X${1} = XAccounting ] ; then
259    status=Accounting
260    mailText=jobAccounting.mail
261  elif ( ${ExitFlag} ) ; then
262    status=failed
263    mailText=jobEnd.mail
264  else
265    status=completed
266    mailText=jobEnd.mail
267  fi
268
269  # Update selected mail template
270  while read -r line; do
271    eval echo $line >> mail.txt ;
272  done < ${libIGCM}/libIGCM_sys/${mailText}
273
274  if [ ! -z ${config_UserChoices_MailName} ] ; then
275    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt
276  elif [ -f ~/.forward ] ; then
277    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt
278  fi
279
280  sleep 10
281  rm -f mail.txt
282
283  IGCM_debug_PopStack "IGCM_sys_SendMail"
284}
285
286#D-#==================================================
287#D-function IGCM_sys_Mkdir
288#D-* Purpose: Master locale mkdir command
289#D-* Examples:
290#D-
291function IGCM_sys_Mkdir {
292  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
293  if ( $DEBUG_sys ) ; then
294    echo "IGCM_sys_Mkdir :" $@
295  fi
296  if [ ! -d ${1} ]; then
297    \mkdir -p $1
298    if [ $? -gt 0 ] ; then
299      echo "IGCM_sys_Mkdir : erreur."
300      IGCM_debug_Exit "IGCM_sys_Mkdir"
301    fi
302  fi
303  # vérification :
304  if [ ! -d ${1} ] ; then
305    echo "IGCM_sys_Mkdir : erreur."
306    IGCM_debug_Exit "IGCM_sys_Mkdir"
307  fi
308  IGCM_debug_PopStack "IGCM_sys_Mkdir"
309}
310
311#D-#==================================================
312#D-function IGCM_sys_MkdirArchive
313#D-* Purpose: Mkdir on Archive
314#D-* Examples:
315#D-
316function IGCM_sys_MkdirArchive {
317  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
318  if ( $DEBUG_sys ) ; then
319    echo "IGCM_sys_MkdirArchive :" $@
320  fi
321  #- creation de repertoire sur le serveur fichier
322  if [ ! -d ${1} ]; then
323    mkdir -p $1
324    status=$?
325
326    if [ ${status} -gt 0 ] ; then
327      IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
328      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
329    fi
330  fi
331  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
332}
333
334#D-#==================================================
335#D-function IGCM_sys_MkdirWork
336#D-* Purpose: Mkdir on Work
337#D-* Examples:
338#D-
339function IGCM_sys_MkdirWork {
340  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
341  if ( $DEBUG_sys ) ; then
342    echo "IGCM_sys_MkdirWork :" $@
343  fi
344  #- creation de repertoire sur le serveur fichier
345  if [ ! -d ${1} ]; then
346    \mkdir -p $1
347    if [ $? -gt 0 ] ; then
348      echo "IGCM_sys_MkdirWork : erreur."
349      IGCM_debug_Exit "IGCM_sys_MkdirWork"
350    fi
351  fi
352  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
353}
354
355#D-#==================================================
356#D-function IGCM_sys_Cd
357#D-* Purpose: master cd command
358#D-* Examples:
359#D-
360function IGCM_sys_Cd {
361  IGCM_debug_PushStack "IGCM_sys_Cd" $@
362  if ( $DEBUG_sys ) ; then
363    echo "IGCM_sys_Cd :" $@
364  fi
365  \cd $1
366  if [ $? -gt 0 ] ; then
367    echo "IGCM_sys_Cd : erreur."
368    IGCM_debug_Exit "IGCM_sys_Cd"
369  fi
370  IGCM_debug_PopStack "IGCM_sys_Cd"
371}
372
373#D-#==================================================
374#D-function IGCM_sys_Chmod
375#D-* Purpose: Chmod
376#D-* Examples:
377#D-
378function IGCM_sys_Chmod {
379  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
380  if ( $DEBUG_sys ) ; then
381    echo "IGCM_sys_Chmod :" $@
382  fi
383  \chmod $@
384  if [ $? -gt 0 ] ; then
385    echo "IGCM_sys_Chmod : erreur."
386    IGCM_debug_Exit "IGCM_sys_Chmod"
387  fi
388  IGCM_debug_PopStack "IGCM_sys_Chmod"
389}
390
391#D-#==================================================
392#D-function IGCM_sys_FileSize
393#D-* Purpose: Filesize
394#D-* Examples:
395#D-
396function IGCM_sys_FileSize {
397  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
398
399  typeset sizeF
400  set +A sizeF -- $( ls -la ${1} )
401  if [ $? -gt 0 ] ; then
402    IGCM_debug_Exit "IGCM_sys_FileSize"
403  fi
404  eval ${2}=${sizeF[4]}
405
406  IGCM_debug_PopStack "IGCM_sys_FileSize"
407}
408
409#D-#==================================================
410#D-function IGCM_sys_TestDir
411#D-* Purpose: Test Directory that must exists
412#D-* Examples:
413#D-
414function IGCM_sys_TestDir {
415  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
416  if ( $DEBUG_sys ) ; then
417    echo "IGCM_sys_TestDir :" $@
418  fi
419  typeset ExistFlag
420  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
421  IGCM_debug_PopStack "IGCM_sys_TestDir"
422
423  return ${ExistFlag}
424}
425
426#D-#==================================================
427#D-function IGCM_sys_TestDirArchive
428#D-* Purpose: Test Directory that must exists on Archive
429#D-* Examples:
430#D-
431function IGCM_sys_TestDirArchive {
432  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
433  if ( $DEBUG_sys ) ; then
434    echo "IGCM_sys_TestDirArchive :" $@
435  fi
436  typeset ExistFlag
437  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
438  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
439  return ${ExistFlag}
440}
441
442#D-#==================================================
443#D-function IGCM_sys_IsFileArchived
444#D-* Purpose: Test file that must NOT EXISTS on Archive
445#D-* Examples:
446#D-
447function IGCM_sys_IsFileArchived {
448  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
449  if ( $DEBUG_sys ) ; then
450    echo "IGCM_sys_IsFileArchived :" $@
451  fi
452  typeset IsArchivedFlag
453  # Never archived for this system
454  IsArchivedFlag=1
455  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
456
457  return ${IsArchivedFlag}
458}
459
460#D-#==================================================
461#D-function IGCM_sys_TestFileArchive
462#D-* Purpose: Test file that must NOT EXISTS on Archive
463#D-* Examples:
464#D-
465function IGCM_sys_TestFileArchive {
466  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
467  typeset ExistFlag
468  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
469  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
470
471  return ${ExistFlag}
472}
473
474#D-#==================================================
475#D-function IGCM_sys_TestFileBuffer
476#D-* Purpose: Test file that must NOT EXISTS on Buffer
477#D-* Examples:
478#D-
479function IGCM_sys_TestFileBuffer {
480  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
481  typeset ExistFlag
482  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
483  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
484
485  return ${ExistFlag}
486}
487
488#D-#==================================================
489#D-function IGCM_sys_CountFileArchive
490#D-* Purpose: Count files on Archive filesystem
491#D-* Examples:
492#D-
493function IGCM_sys_CountFileArchive {
494  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
495  ls ${@} 2>/dev/null | wc -l
496  if [ $? -gt 0 ] ; then
497    echo "IGCM_sys_CountFileArchive : erreur."
498  fi
499  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
500}
501
502#D-#==================================================
503#D-function IGCM_sys_CountFileBuffer
504#D-* Purpose: Count files on Scratch filesystem
505#D-* Examples:
506#D-
507function IGCM_sys_CountFileBuffer {
508  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
509  ls ${@} 2>/dev/null | wc -l
510  if [ $? -gt 0 ] ; then
511    echo "IGCM_sys_CountFileBuffer : erreur."
512  fi
513  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
514}
515
516#D-#==================================================
517#D-function IGCM_sys_Tree
518#D-* Purpose: Tree directories with files on ${ARCHIVE}
519#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
520#D-
521function IGCM_sys_Tree {
522  IGCM_debug_PushStack "IGCM_sys_Tree" $@
523  if ( $DEBUG_sys ) ; then
524    echo "IGCM_sys_Tree :" $@
525  fi
526
527  \tree -f $@
528
529  IGCM_debug_PopStack "IGCM_sys_Tree"
530}
531
532#D-#==================================================
533#D-function IGCM_sys_Tar
534#D-* Purpose: master tar command
535#D-* Examples:
536#D-
537function IGCM_sys_Tar {
538  IGCM_debug_PushStack "IGCM_sys_Tar" $@
539  if ( $DEBUG_sys ) ; then
540    echo "IGCM_sys_Tar :" $@
541  fi
542  \tar cf $@
543  if [ $? -gt 0 ] ; then
544    echo "IGCM_sys_Tar : erreur."
545    IGCM_debug_Exit "IGCM_sys_Tar"
546  fi
547  IGCM_debug_PopStack "IGCM_sys_Tar"
548}
549
550#D-#==================================================
551#D-function IGCM_sys_UnTar
552#D-* Purpose: master un-tar command
553#D-* Examples:
554#D-
555function IGCM_sys_UnTar {
556  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
557  if ( $DEBUG_sys ) ; then
558    echo "IGCM_sys_UnTar :" $@
559  fi
560  \tar xvf $1
561  if [ $? -gt 0 ] ; then
562    echo "IGCM_sys_UnTar : erreur."
563    IGCM_debug_Exit "IGCM_sys_UnTar"
564  fi
565  IGCM_debug_PopStack "IGCM_sys_UnTar"
566}
567
568#D-#==================================================
569#D-function IGCM_sys_Qsub
570#D-* Purpose: Qsub new job
571#D-* Examples:
572#D-
573function IGCM_sys_Qsub {
574  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
575  if ( $DEBUG_sys ) ; then
576    echo "IGCM_sys_Qsub :" $@
577  fi
578  typeset options status
579  options="-o ${SUBMIT_DIR}/${Script_Output}"
580  /usr/local/bin/qsub ${options} < $1
581  status=$?
582  if [ ${status} -gt 0 ] ; then
583    IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}"
584    IGCM_debug_Exit "IGCM_sys_Qsub"
585  fi
586  IGCM_debug_PopStack "IGCM_sys_Qsub"
587}
588
589#D-#==================================================
590#D-function IGCM_sys_QsubPost
591#D-* Purpose: Qsub new job on scalaire
592#D-* Examples:
593#D-
594function IGCM_sys_QsubPost {
595  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
596  if ( $DEBUG_sys ) ; then
597    echo "IGCM_sys_QsubPost :" $@
598  fi
599  typeset options status
600  options="-o ${POST_DIR}/${Script_Post_Output}.out -v ${listVarEnv}"
601  /usr/local/bin/qsub ${options} < ${libIGCM_POST}/$1.job
602  status=$?
603  if [ ${status} -gt 0 ] ; then
604    IGCM_debug_Print 2 "IGCM_sys_QsubPost ${options} ${libIGCM_POST}/$1.job : error code ${status}"
605    IGCM_debug_Exit "IGCM_sys_QsubPost"
606  fi
607  IGCM_debug_PopStack "IGCM_sys_QsubPost"
608}
609
610#D-*************************
611#D- File transfer functions
612#D-*************************
613#D-
614
615#D-#==================================================
616#D-function IGCM_sys_Rsync_out
617#D-* Purpose: treat return val of rsync
618#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
619#D-  Error values and explanations can depend on your system version.
620function IGCM_sys_Rsync_out {
621  status=$1
622  if [ ! $status ] ; then
623    echo "rsync error !"
624  fi
625
626  if [ $MYLANG = "fr" ]; then
627    case $status in
628    0)  return ;;
629    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
630      echo "Erreur de syntaxe ou d'utilisation."
631      return;;
632    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
633      echo "Incompatibilité de protocole."
634      return;;
635    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
636      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
637      echo "répertoires"
638      return;;
639    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
640      echo "Action demandée non supportée : une tentative de manipulation de"
641      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
642      echo "été faite ; ou une option qui est supportée par le  client  mais"
643      echo "pas par le serveur a été spécifiée."
644      return;;
645    10) echo "Erreur de rsync ; RERR_SOCKETIO"
646      echo "Erreur dans le socket d'entrée sortie"
647      return;;
648    11) echo "Erreur de rsync ; RERR_FILEIO"
649      echo "Erreur d'entrée sortie fichier"
650      return;;
651    12) echo "Erreur de rsync ; RERR_STREAMIO"
652      echo "Erreur dans flux de donnée du protocole rsync"
653      return;;
654    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
655      echo "Erreur avec les diagnostics du programme"
656      return;;
657    14) echo "Erreur de rsync ; RERR_IPC"
658      echo "Erreur dans le code IPC"
659      return;;
660    20) echo "Erreur de rsync ; RERR_SIGNAL"
661      echo "SIGUSR1 ou SIGINT reçu"
662      return;;
663    21) echo "Erreur de rsync ; RERR_WAITCHILD"
664      echo "Une erreur retournée par waitpid()"
665      return;;
666    22) echo "Erreur de rsync ; RERR_MALLOC"
667      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
668      return;;
669    23) echo ""
670      echo "Erreur fichier inexistant"
671      return;;
672    30) echo "Erreur de rsync ; RERR_TIMEOUT"
673      echo "Temps d'attente écoulé dans l'envoi/réception de données"
674      return;;
675    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status
676      return;;
677    esac
678  elif [ $MYLANG = "en" ] ; then
679    case $status in
680    0)  return;;
681    1)  echo "rsync error : Syntax or usage error "
682      return;;
683    2)  echo "rsync error : Protocol incompatibility "
684      return;;
685    3)  echo "rsync error : Errors selecting input/output files, dirs"
686      return;;
687    4)  echo "rsync error : Requested action not supported: an attempt"
688      echo "was made to manipulate 64-bit files on a platform that cannot support"
689      echo "them; or an option was specified that is supported by the client and"
690      echo "not by the server."
691      return;;
692    5)  echo "rsync error : Error starting client-server protocol"
693      return;;
694    10) echo "rsync error : Error in socket I/O "
695      return;;
696    11) echo "rsync error : Error in file I/O "
697      return;;
698    12) echo "rsync error : Error in rsync protocol data stream "
699      return;;
700    13) echo "rsync error : Errors with program diagnostics "
701      return;;
702    14) echo "rsync error : Error in IPC code "
703      return;;
704    20) echo "rsync error : Received SIGUSR1 or SIGINT "
705      return;;
706    21) echo "rsync error : Some error returned by waitpid() "
707      return;;
708    22) echo "rsync error : Error allocating core memory buffers "
709      return;;
710    23) echo "rsync error : Partial transfer due to error"
711      return;;
712    24) echo "rsync error : Partial transfer due to vanished source files"
713      return;;
714    30) echo "rsync error : Timeout in data send/receive "
715      return;;
716    *)  echo "rsync error : return code of rsync unknown :" $status
717      return;;
718    esac
719  else
720    echo "unknown language $MYLANG."
721    return
722  fi
723}
724
725#D-#==================================================
726#D-function IGCM_sys_Miror_libIGCM
727#D-* Purpose: Mirror libIGCM PATH and lib to frontend
728#D-* Examples:
729#D-
730function IGCM_sys_Mirror_libIGCM {
731  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
732  if ( $DEBUG_sys ) ; then
733    echo "IGCM_sys_Mirror_libIGCM"
734  fi
735
736  typeset status
737
738  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
739
740  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > /tmp/out_command.$$ 2>&1
741  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> /tmp/out_command.$$ 2>&1
742  status=$?
743
744  if [ ${status} -gt 0 ] ; then
745    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."
746    cat /tmp/out_command.$$
747  fi
748  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
749}
750
751#D-#==================================================
752#D-function IGCM_sys_Cp
753#D-* Purpose: generic cp
754#D-* Examples:
755#D-
756function IGCM_sys_Cp {
757  IGCM_debug_PushStack "IGCM_sys_Cp" $@
758  if ( $DEBUG_sys ) ; then
759    echo "IGCM_sys_Cp :" $@
760  fi
761
762  typeset status
763
764  echo cp $@ > /tmp/out_command.$$ 2>&1
765  \cp $@ >> /tmp/out_command.$$ 2>&1
766  status=$?
767
768  if [ ${status} -gt 0 ] ; then
769    echo "IGCM_sys_Cp : error code ${status}"
770    cat /tmp/out_command.$$
771    IGCM_debug_Exit "IGCM_sys_Cp"
772  else
773    \rm /tmp/out_command.$$
774  fi
775  IGCM_debug_PopStack "IGCM_sys_Cp"
776}
777
778#D-#==================================================
779#D-function IGCM_sys_Rm
780#D-* Purpose: generic rm
781#D-* Examples:
782#D-
783function IGCM_sys_Rm {
784  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
785  if ( $DEBUG_sys ) ; then
786    echo "IGCM_sys_Rm :" $@
787  fi
788
789  typeset status
790
791  echo rm $@ > /tmp/out_command.$$ 2>&1
792  \rm $@ >> /tmp/out_command.$$ 2>&1
793  status=$?
794
795  if [ ${status} -gt 0 ] ; then
796    echo "IGCM_sys_Rm : error code ${status}"
797    cat /tmp/out_command.$$
798    IGCM_debug_Exit "IGCM_sys_Rm"
799  else
800    \rm /tmp/out_command.$$
801  fi
802  IGCM_debug_PopStack "IGCM_sys_Rm"
803}
804
805#D-#==================================================
806#D-function IGCM_sys_RmRunDir
807#D-* Purpose: rm tmpdir (dummy function most of the time batch
808#D-                      scheduler will do the job)
809#D-* Examples:
810#D-
811function IGCM_sys_RmRunDir {
812  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
813  if ( $DEBUG_sys ) ; then
814    echo "IGCM_sys_RmRunDir :" $@
815  fi
816
817  typeset status
818
819  echo rm $@ > /tmp/out_command.$$ 2>&1
820  \rm $@ >> /tmp/out_command.$$ 2>&1
821  status=$?
822
823  if [ ${status} -gt 0 ] ; then
824    echo "IGCM_sys_RmRunDir : rm error code is ${status}."
825    cat /tmp/out_command.$$
826    IGCM_debug_Exit "IGCM_sys_RmRunDir"
827  else
828    \rm /tmp/out_command.$$
829  fi
830  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
831}
832
833#D-#==================================================
834#D-function IGCM_sys_Mv
835#D-* Purpose: generic move
836#D-* Examples:
837#D-
838function IGCM_sys_Mv {
839  IGCM_debug_PushStack "IGCM_sys_Mv" $@
840  if ( $DEBUG_sys ) ; then
841    echo "IGCM_sys_Mv :" $@
842  fi
843
844  if [ $DRYRUN = 0 ]; then
845
846    typeset status
847
848    echo mv $@ > /tmp/out_command.$$ 2>&1
849    \mv $@ >> /tmp/out_command.$$ 2>&1
850    status=$?
851
852    if [ ${status} -gt 0 ] ; then
853      echo "IGCM_sys_Mv : error code ${status}"
854      cat /tmp/out_command.$$
855      IGCM_debug_Exit "IGCM_sys_Mv"
856    else
857      \rm /tmp/out_command.$$
858    fi
859  fi
860  IGCM_debug_PopStack "IGCM_sys_Mv"
861}
862
863#D-#==================================================
864#D-function IGCM_sys_Put_Dir
865#D-* Purpose: Copy a complete directory on $(ARCHIVE)
866#D-* Examples:
867#D-
868function IGCM_sys_Put_Dir {
869  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
870  if ( $DEBUG_sys ) ; then
871    echo "IGCM_sys_Put_Dir :" $@
872  fi
873  if [ $DRYRUN = 0 ]; then
874    if [ ! -d ${1} ] ; then
875      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
876      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
877      return
878    fi
879
880    typeset status
881
882    # Only if we use rsync
883    #IGCM_sys_TestDirArchive $( dirname $2 )
884    #
885    #USUAL WAY
886    \cp -r $1 $2 > /tmp/out_command.$$ 2>&1
887    status=$?
888
889    if [ ${status} -gt 0 ] ; then
890      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}"
891      cat /tmp/out_command.$$
892      IGCM_debug_Exit "IGCM_sys_Put_Dir"
893    else
894      \rm /tmp/out_command.$$
895    fi
896  fi
897  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
898}
899
900#D-#==================================================
901#D-function IGCM_sys_Get_Dir
902#D-* Purpose: Copy a complete directory from ${ARCHIVE}
903#D-* Examples:
904#D-
905function IGCM_sys_Get_Dir {
906  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
907  if ( $DEBUG_sys ) ; then
908    echo "IGCM_sys_Get_Dir :" $@
909  fi
910  if [ $DRYRUN = 0 ]; then
911    if [ ! -d ${1} ] ; then
912      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
913      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
914      return
915    fi
916
917    typeset status
918
919    #USUAL WAY
920    \cp -ur $1 $2 > /tmp/out_command.$$ 2>&1
921    status=$?
922
923    if [ ${status} -gt 0 ] ; then
924      IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
925      cat /tmp/out_command.$$
926      IGCM_debug_Exit "IGCM_sys_Get_Dir"
927    else
928      \rm /tmp/out_command.$$
929    fi
930  fi
931  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
932}
933
934#D-#==================================================
935#D-function IGCM_sys_Get_Master
936#D-* Purpose: Copy a complete directory from MASTER filesystem
937#D-* Examples:
938#D-
939function IGCM_sys_Get_Master {
940  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
941  if ( $DEBUG_sys ) ; then
942    echo "IGCM_sys_Get_Master :" $@
943  fi
944  if [ $DRYRUN = 0 ]; then
945    if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
946      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
947      IGCM_debug_PopStack "IGCM_sys_Get_Master"
948      return
949    fi
950
951    typeset NB_ESSAI DELAI status i
952    # number of tentative
953    NB_ESSAI=3
954    # time delay between tentative
955    DELAI=2
956
957    i=0
958    while [ $i -lt $NB_ESSAI ] ; do
959      \cp -urL $1 $2 > /tmp/out_command.$$ 2>&1
960      status=$?
961      if [ ${status} -gt 0 ]; then
962        IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"
963        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."
964        sleep $DELAI
965      else
966        break
967      fi
968      (( i = i + 1 ))
969    done
970
971    if [ ${status} -gt 0 ] ; then
972      echo "IGCM_sys_Get_Master : error."
973      cat /tmp/out_command.$$
974      IGCM_debug_Exit "IGCM_sys_Get_Master"
975    else
976      \rm /tmp/out_command.$$
977    fi
978  fi
979  IGCM_debug_PopStack "IGCM_sys_Get_Master"
980}
981
982#====================================================
983#- Call IGCM_sys_Mirror_libIGCM now !
984if ( $MirrorlibIGCM ) ; then
985  IGCM_sys_Mirror_libIGCM
986fi
987
988#D-#==================================================
989#D-function IGCM_sys_Put_Rest
990#D-* Purpose: Put computied restarts on ${ARCHIVE}.
991#D-           File and target directory must exist.
992#D-* Examples:
993#D-
994function IGCM_sys_Put_Rest {
995  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
996  if ( $DEBUG_sys ) ; then
997    echo "IGCM_sys_Put_Rest :" $@
998  fi
999  if [ $DRYRUN = 0 ]; then
1000    if [ ! -f ${1} ] ; then
1001      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
1002      IGCM_debug_Exit "IGCM_sys_Put_Rest"
1003    fi
1004
1005    typeset status
1006    #
1007    if [ X${JobType} = XRUN ] ; then
1008      IGCM_sys_Chmod 444 ${1}
1009    fi
1010    #
1011    # Only if we use rsync
1012    #IGCM_sys_MkdirArchive $( dirname $2 )
1013    #
1014    #USUAL WAY
1015    \cp $1 $2 > /tmp/out_command.$$ 2>&1
1016    status=$?
1017
1018#       #RSYNC WITH NETWORK SSH CALL
1019#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > /tmp/out_command.$$ 2>&1
1020#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> /tmp/out_command.$$ 2>&1
1021
1022#       #RSYNC WITH NFS USE
1023#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > /tmp/out_command.$$ 2>&1
1024#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> /tmp/out_command.$$ 2>&1
1025
1026#       status=$?
1027#       IGCM_sys_Rsync_out $status
1028
1029#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
1030#       (( status=status+$? ))
1031
1032    if [ ${status} -gt 0 ] ; then
1033      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
1034      cat /tmp/out_command.$$
1035      IGCM_debug_Exit "IGCM_sys_Put_Rest"
1036    else
1037      \rm /tmp/out_command.$$
1038    fi
1039  fi
1040  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
1041}
1042
1043#D-#==================================================
1044#D-function IGCM_sys_PutBuffer_Rest
1045#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
1046#D-           File and target directory must exist.
1047#D-* Examples:
1048#D-
1049function IGCM_sys_PutBuffer_Rest {
1050  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
1051  if ( $DEBUG_sys ) ; then
1052    echo "IGCM_sys_PutBuffer_Rest :" $@
1053  fi
1054  if [ $DRYRUN = 0 ]; then
1055    if [ ! -f ${1} ] ; then
1056      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
1057      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1058    fi
1059
1060    typeset status
1061    #
1062    if [ X${JobType} = XRUN ] ; then
1063      IGCM_sys_Chmod 444 ${1}
1064    fi
1065
1066    #
1067    # USUAL WAY
1068    \cp $1 $2 > /tmp/out_command.$$ 2>&1
1069    status=$?
1070
1071    if [ ${status} -gt 0 ] ; then
1072      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
1073      [ -f ${2} ] && ls -l ${2}
1074      [ -f ${2}/${1} ] && ls -l ${2}/${1}
1075      cat /tmp/out_command.$$
1076      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1077    else
1078      \rm /tmp/out_command.$$
1079    fi
1080  fi
1081  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
1082}
1083
1084#D-#==================================================
1085#D-function IGCM_sys_PrepareTaredRestart
1086#D-* Purpose: Prepare tared restart to be access by computing job. Identity here.
1087#D-* Examples:
1088#D-
1089function IGCM_sys_PrepareTaredRestart {
1090  IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@
1091
1092  IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"
1093}
1094
1095#D-#==================================================
1096#D-function IGCM_sys_Put_Out
1097#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
1098#D-* Examples:
1099#D-
1100function IGCM_sys_Put_Out {
1101  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
1102  if ( $DEBUG_sys ) ; then
1103    echo "IGCM_sys_Put_Out :" $@
1104  fi
1105
1106  typeset status
1107
1108  if [ $DRYRUN = 0 ]; then
1109    if [ ! -f ${1} ] ; then
1110      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
1111      IGCM_debug_PopStack "IGCM_sys_Put_Out"
1112      return 1
1113    fi
1114    #
1115    IGCM_sys_MkdirArchive $( dirname $2 )
1116    #
1117    if [ X${JobType} = XRUN ] ; then
1118      if [ X${3} = X ] ; then
1119        IGCM_sys_Chmod 444 ${1}
1120      fi
1121    fi
1122    #
1123
1124    echo ${RSYNC} ${RSYNC_opt} $1 $2 > /tmp/out_command.$$ 2>&1
1125    ${RSYNC} ${RSYNC_opt} $1 $2 >> /tmp/out_command.$$ 2>&1
1126    status=$?
1127    IGCM_sys_Rsync_out $status
1128
1129    ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
1130    (( status=status+$? ))
1131
1132    if [ ${status} -gt 0 ] ; then
1133      IGCM_debug_Print 2 "IGCM_sys_Put_Out : rsync failed error code ${status}"
1134      cat /tmp/out_command.$$
1135      IGCM_debug_Exit "IGCM_sys_Put_Out"
1136    else
1137      \rm /tmp/out_command.$$
1138    fi
1139  fi
1140  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1141  return 0
1142}
1143
1144#D-#==================================================
1145#D-function IGCM_sys_PutBuffer_Out
1146#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1147#D-* Examples:
1148#D-
1149function IGCM_sys_PutBuffer_Out {
1150  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1151  if ( $DEBUG_sys ) ; then
1152    echo "IGCM_sys_PutBuffer_Out :" $@
1153  fi
1154
1155  typeset NB_ESSAI DELAI status i exist skip
1156
1157  # number of tentative
1158  NB_ESSAI=3
1159  # time delay between tentative
1160  DELAI=2
1161
1162  if [ $DRYRUN = 0 ]; then
1163    if [ ! -f ${1} ] ; then
1164      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1165      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1166      return 1
1167    fi
1168    #
1169    IGCM_sys_Mkdir $( dirname $2 )
1170    #
1171
1172    exist=false
1173    skip=false
1174    if [ -f $2 ] ; then
1175      IGCM_debug_Print 1 "$2 already exist"
1176      exist=true
1177      if [ "X$( diff $1 $2 )" = X ] ; then
1178        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
1179        status=0
1180        skip=true
1181      else
1182        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
1183        skip=false
1184      fi
1185    fi
1186    #
1187    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
1188      IGCM_sys_Chmod u+w $2
1189    fi
1190
1191    if [ X${skip} = Xfalse ] ; then
1192      i=0
1193      while [ $i -lt $NB_ESSAI ] ; do
1194        # USUAL WAY
1195        \cp $1 $2 > /tmp/out_command.$$ 2>&1
1196        status=$?
1197        if [ ${status} -gt 0 ]; then
1198          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
1199          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."
1200          [ -f ${2} ] && ls -l ${2}
1201          [ -f ${2}/${1} ] && ls -l ${2}/${1}
1202          sleep $DELAI
1203        else
1204          break
1205        fi
1206        (( i = i + 1 ))
1207      done
1208    fi
1209
1210    if [ ${status} -gt 0 ] ; then
1211      echo "IGCM_sys_PutBuffer_Out : error."
1212      [ -f ${2} ] && ls -l ${2}
1213      [ -f ${2}/${1} ] && ls -l ${2}/${1}
1214      cat /tmp/out_command.$$
1215      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1216    else
1217
1218      if [ X${JobType} = XRUN ] ; then
1219        if [ X${3} = X ] ; then
1220          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
1221          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
1222        fi
1223      fi
1224
1225      \rm /tmp/out_command.$$
1226    fi
1227  fi
1228  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1229  return 0
1230}
1231
1232#D-#==================================================
1233#D-function IGCM_sys_Get
1234#D-* Purpose: Get a file from ${ARCHIVE}
1235#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1236#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1237function IGCM_sys_Get {
1238  IGCM_debug_PushStack "IGCM_sys_Get" $@
1239
1240  typeset DEST status dm_liste
1241
1242  if ( $DEBUG_sys ) ; then
1243    echo "IGCM_sys_Get :" $@
1244  fi
1245  if [ $DRYRUN -le 2 ]; then
1246    if [ X${1} = X'/l' ] ; then
1247      eval set +A dm_liste \${${2}}
1248    else
1249      dm_liste=${1}
1250    fi
1251    eval DEST=\${${#}}
1252
1253    # test if the (first) file is present in the old computation :
1254    IGCM_sys_TestFileArchive ${dm_liste[0]}
1255    status=$?
1256    if [ ${status} -gt 0 ] ; then
1257      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1258      IGCM_debug_Exit "IGCM_sys_Get"
1259      return
1260    fi
1261
1262    #USUAL WAY
1263    \cp ${dm_liste[*]} ${DEST} > /tmp/out_command.$$ 2>&1
1264    status=$?
1265
1266    if [ ${status} -gt 0 ] ; then
1267      IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}"
1268      cat /tmp/out_command.$$
1269      IGCM_debug_Exit "IGCM_sys_Get"
1270    else
1271      \rm /tmp/out_command.$$
1272    fi
1273  fi
1274  IGCM_debug_PopStack "IGCM_sys_Get"
1275}
1276
1277#D-#==================================================
1278#D-function IGCM_sys_GetBuffer
1279#D-* Purpose: Get a file from ${SCRATCHDIR}
1280#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1281#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1282function IGCM_sys_GetBuffer {
1283  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1284
1285  typeset DEST buf_liste target file_work
1286  typeset NB_ESSAI DELAI status i
1287
1288  if ( $DEBUG_sys ) ; then
1289    echo "IGCM_sys_GetBuffer :" $@
1290  fi
1291
1292  # number of tentative
1293  NB_ESSAI=3
1294  # time delay between tentative
1295  DELAI=2
1296
1297  if [ $DRYRUN -le 2 ]; then
1298    if [ X${1} = X'/l' ] ; then
1299      eval set +A buf_liste \${${2}}
1300    else
1301      eval set +A buf_liste ${1}
1302    fi
1303    eval DEST=\${${#}}
1304
1305    #USUAL WAY
1306    if [ X${1} = X'/l' ] ; then
1307      for target in ${buf_liste[*]} ; do
1308        local_file=$( basename ${target} )
1309        i=0
1310        while [ $i -lt $NB_ESSAI ] ; do
1311          \cp ${target} ${DEST}/${local_file} >> /tmp/out_command.$$ 2>&1
1312          status=$?
1313          if [ ${status} -gt 0 ]; then
1314            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
1315            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
1316            sleep $DELAI
1317          else
1318            break
1319          fi
1320          (( i = i + 1 ))
1321        done
1322        if [ ${status} -gt 0 ] ; then
1323          echo "IGCM_sys_Get : error"
1324          cat /tmp/out_command.$$
1325          \rm /tmp/out_command.$$
1326          IGCM_debug_Exit "IGCM_sys_GetBuffer"
1327        else
1328          \rm /tmp/out_command.$$
1329        fi
1330      done
1331    else
1332      i=0
1333      while [ $i -lt $NB_ESSAI ] ; do
1334        \cp ${buf_liste} ${DEST} >> /tmp/out_command.$$ 2>&1
1335        status=$?
1336        if [ ${status} -gt 0 ]; then
1337          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
1338          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
1339          sleep $DELAI
1340        else
1341          break
1342        fi
1343        (( i = i + 1 ))
1344      done
1345      if [ ${status} -gt 0 ] ; then
1346        echo "IGCM_sys_Get : error"
1347        cat /tmp/out_command.$$
1348        \rm /tmp/out_command.$$
1349        IGCM_debug_Exit "IGCM_sys_GetBuffer"
1350      else
1351        \rm /tmp/out_command.$$
1352      fi
1353    fi
1354  fi
1355  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1356}
1357
1358#D-#==================================================
1359#D-function IGCM_sys_GetDate_FichWork
1360#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1361#D-* Examples:
1362#D-
1363function IGCM_sys_GetDate_FichWork {
1364  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1365  if ( $DEBUG_sys ) ; then
1366    echo "IGCM_sys_GetDate_FichWork :" $@
1367  fi
1368  typeset dateF
1369  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1370  eval ${2}=${dateF[5]}
1371
1372  # donne la date filesys d'un fichier sur la machine work
1373  IGCM_debug_PopStack "IGCM_sys_FichWork"
1374}
1375
1376#D-#==================================================
1377#D-function IGCM_sys_GetDate_FichArchive
1378#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1379#D-* Examples:
1380#D-
1381function IGCM_sys_GetDate_FichArchive {
1382  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1383  if ( $DEBUG_sys ) ; then
1384    echo "IGCM_sys_GetDate_FichArchive :" $@
1385  fi
1386  typeset dateF
1387  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1388  eval ${2}=${dateF[5]}
1389
1390  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1391}
1392
1393#D-#==================================================
1394#D-function IGCM_sys_Dods_Rm
1395#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
1396#D-* Examples:
1397#D-
1398function IGCM_sys_Dods_Rm {
1399  if ( $DEBUG_sys ) ; then
1400    echo "IGCM_sys_Dods_Rm :" $@
1401  fi
1402  return 0
1403}
1404
1405#D-#==================================================
1406#D-function IGCM_sys_Dods_Cp
1407#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1408#D-* Examples:
1409#D-
1410function IGCM_sys_Dods_Cp {
1411  if ( $DEBUG_sys ) ; then
1412    echo "IGCM_sys_Dods_Cp :" $@
1413  fi
1414  return 0
1415}
1416
1417#D-#==================================================
1418#D-function IGCM_sys_Put_Dods
1419#D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here
1420#D-* Examples:
1421#D-
1422function IGCM_sys_Put_Dods {
1423  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1424  if ( $DEBUG_sys ) ; then
1425    echo "IGCM_sys_Put_Dods :" $@
1426  fi
1427  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1428}
1429
1430##############################################################
1431# REBUILD OPERATOR
1432
1433#D-#==================================================
1434#D-function IGCM_sys_rebuild
1435#D-* Purpose: rebuild parallel files
1436#D-* Examples:
1437#D-
1438function IGCM_sys_rebuild {
1439  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1440  if ( $DEBUG_sys ) ; then
1441    echo "IGCM_sys_rebuild :" $@
1442  fi
1443
1444  typeset NB_ESSAI DELAI status i firstArg
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    /home/users/igcmg/rebuild/bin/rebuild -f -o $@ > /tmp/out_command.$$ 2>&1
1453    status=$?
1454    if [ ${status} -gt 0 ] ; then
1455      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
1456      cat /tmp/out_command.$$
1457      \rm /tmp/out_command.$$
1458      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
1459      firstArg=${1}
1460      \rm ${firstArg}
1461      sleep $DELAI
1462    else
1463      \rm /tmp/out_command.$$
1464      break
1465    fi
1466    (( i = i + 1 ))
1467  done
1468
1469  if [ ${status} -gt 0 ] ; then
1470    echo "IGCM_sys_rebuild : rebuild error code is ${status}"
1471    IGCM_debug_Exit "rebuild"
1472  fi
1473
1474  IGCM_debug_PopStack "IGCM_sys_rebuild"
1475}
1476
1477#D-#==================================================
1478#D-function IGCM_sys_rebuild_station
1479#D-* Purpose: rebuild parallel files describing station
1480#D-* Examples:
1481#D-
1482function IGCM_sys_rebuild_station {
1483  IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@
1484  typeset i list_opt file_in file_out prefix_invert list_invert
1485  if ( $DEBUG_sys ) ; then
1486    echo "IGCM_sys_rebuild_station :" $@
1487  fi
1488  list_opt=$@
1489
1490  # Invert Axis : t,x -> x,t
1491  #               t,pres,x -> x,t,pres
1492  # So that we can concatenate along x
1493  i=0
1494  for file_in in ${list_opt} ; do
1495    (( i = i + 1))
1496    [ ${i} = 1 ] && file_out=${file_in} && continue
1497    prefix_invert=$( basename ${file_in} .nc )
1498    IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc
1499    list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc
1500  done
1501
1502  # Concatenate
1503  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc
1504
1505  # Re-ivert file
1506  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}
1507
1508  # Station re-ordering is too expansive to be run within libIGCM
1509  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.
1510  # This re-ordering must be done "in memory" by the cmorization process
1511  # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)
1512  # BEGIN reordering
1513
1514  # Only LMDZ text output contains the exact ordering of the station.
1515  # We isolate this in the code below:
1516  #  0  38  -157.5000000000000  70.98591549295774
1517  #  0  54  27.49999999999999   67.18309859154928
1518  #  0  56  -62.50000000000001  82.39436619718309
1519  #  0  79  12.49999999999999   78.59154929577466
1520  #  0  116 -165.0000000000000  76.05633802816901
1521  #  0  117 130.0000000000000   70.98591549295774
1522  #  0  118 110.0000000000000   87.46478873239437
1523  #  1  40  4.999999999999995   51.97183098591550
1524#  typeset iStation iProc list_opt file_in file_out prefix_invert
1525#  typeset -Z4 j4
1526#  typeset -Z3 j3
1527
1528#  unset list_opt
1529#  set +A list_opt $@
1530
1531  # Filename after rebuild
1532#  file_out=${list_opt[0]}
1533  # Prefix of output files
1534#  prefix_invert=$( basename ${file_out} .nc )
1535  # Number of procs
1536#  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )
1537
1538#  iProc=0
1539#  while [ ${iProc} -lt ${num_proc} ] ; do
1540    # Array containing Station as a number
1541#    unset proc_stn
1542#    set +A proc_stn $( grep "iophy_mpi rank ip lon lat  $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )
1543    # Number of stations produced by processor proc
1544#    stationLast=${#proc_stn[*]}
1545    # Proc number on 4 digits
1546#    j4=${iProc}
1547    # Init
1548#    iStation=0
1549#    while [ ${iStation} -lt ${stationLast} ] ; do
1550      # Station number on 3 digits
1551#      j3=${proc_stn[${iStation}]}
1552      # Extract station
1553      # Invert Axis : t,x -> x,t
1554      #               t,pres,x -> x,t,pres
1555      # So that we can concatenate along x
1556#      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc
1557#      (( iStation = iStation + 1 ))
1558#    done
1559#    (( iProc = iProc + 1 ))
1560#  done
1561
1562  # Concatenate all station along x
1563#  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc
1564
1565  # Re-invert file
1566#  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}
1567
1568  # END reordering
1569
1570  IGCM_debug_PopStack "IGCM_sys_rebuild_station"
1571}
1572
1573############################################################
1574# Activate Running Environnment Variables
1575
1576#D-#==================================================
1577#D-function IGCM_sys_desactiv_variables
1578#D-* Purpose: set environement variables prior to execution
1579#D-* Examples:
1580#D-
1581function IGCM_sys_activ_variables {
1582  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1583  if ( $DEBUG_sys ) ; then
1584    echo "IGCM_sys_activ_variables"
1585  fi
1586
1587# --------------------------------------------------------------------
1588#D- MPI specifications
1589# --------------------------------------------------------------------
1590
1591# --------------------------------------------------------------------
1592#D- Other specifications
1593# --------------------------------------------------------------------
1594
1595  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1596}
1597
1598############################################################
1599# Desactivate Running Environnment Variables
1600
1601#D-#==================================================
1602#D-function IGCM_sys_desactiv_variables
1603#D-* Purpose: unset environement variables after execution
1604#D-* Examples:
1605#D-
1606function IGCM_sys_desactiv_variables {
1607  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1608  if ( $DEBUG_sys ) ; then
1609    echo "IGCM_sys_desactiv_variables"
1610  fi
1611# --------------------------------------------------------------------
1612#D- MPI specifications
1613# --------------------------------------------------------------------
1614
1615# --------------------------------------------------------------------
1616#D- Other specifications
1617# --------------------------------------------------------------------
1618
1619  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1620}
1621
1622############################################################
1623# Build MPI/OMP scripts run file (dummy function)
1624
1625#D-#==================================================
1626#D-function IGCM_sys_build_run_file
1627#D-* Purpose: build run file (deprecated)
1628#D-* Examples:
1629#D-
1630function IGCM_sys_build_run_file {
1631
1632  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1633
1634}
1635
1636############################################################
1637# Build MPI/OMP scripts
1638
1639#D-#==================================================
1640#D-function IGCM_sys_build_execution_scripts
1641#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
1642#D-* Examples:
1643#D-
1644function IGCM_sys_build_execution_scripts
1645{
1646  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1647  if ( $DEBUG_sys ) ; then
1648    echo "IGCM_sys_build_execution_scripts " $@
1649  fi
1650  typeset nodes listnodes init_node start_num init_exec comp ExeNameIn ExeNameOut
1651  typeset node_num_current node_current comp_proc_mpi_loc comp_proc_omp_loc
1652  typeset num_corempi nombre_restant_node nombre_restant_comp
1653
1654  if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
1655    IGCM_debug_Exit "IGCM_sys_obelix build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
1656  fi
1657
1658  if ( ${OK_PARA_MPMD} ) ; then
1659
1660    if [ -f run_file ] ; then
1661      IGCM_sys_Rm -f run_file
1662    fi
1663    touch run_file
1664
1665    if ( ${OK_PARA_OMP} ) ; then
1666
1667      #  Hosts treatment
1668
1669      ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp
1670
1671      i=0
1672      rm -f hosts
1673      IGCM_debug_Print 1 "sys Obelix, Hosts avaible :"
1674      for nodes in `cat hosts.tmp` ; do
1675        host[$i]=$nodes
1676        echo "${host[$i]} slots=1 max_slots=1" >> hosts
1677        IGCM_debug_Print 1 ${host[$i]}
1678        i=$((i+1))
1679      done
1680      rm -f hosts.tmp
1681
1682      listnodes=${host[*]}
1683
1684      EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts"
1685
1686      # Initialisation
1687
1688      init_node=y
1689      node_num_current=0
1690      start_num=0
1691      init_exec=n
1692
1693      # Test : if oasis is there, we put it at the first position
1694
1695      for comp in ${config_ListOfComponents[*]} ; do
1696
1697        if [ "X${comp}" = "XCPL" ]  ; then
1698
1699          eval ExeNameIn=\${config_Executable_${comp}[0]}
1700          eval ExeNameOut=\${config_Executable_${comp}[1]}
1701
1702          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1703          echo ""  >> script_${ExeNameOut}.ksh
1704          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1705          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1706          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1707          echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err"  >> script_${ExeNameOut}.ksh
1708          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1709
1710          init_node=n
1711
1712          (( nombre_restant_node = NUM_COREPERNODE - 1 ))
1713          node_num_current=0
1714          node_current=${host[${node_num_current}]}
1715
1716          EXECUTION="${EXECUTION} -H ${node_current} -np 1 ./script_${ExeNameOut}.ksh"
1717
1718          init_exec=y
1719          start_num=1
1720
1721        fi
1722
1723      done
1724
1725      # Then loop on the components (except for oasis)
1726
1727      for comp in ${config_ListOfComponents[*]} ; do
1728
1729        eval ExeNameIn=\${config_Executable_${comp}[0]}
1730        eval ExeNameOut=\${config_Executable_${comp}[1]}
1731
1732        # Only if we really have an executable for the component :
1733        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then
1734
1735          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1736          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1737
1738          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1739          # echo "set -vx" >> script_${ExeNameOut}.ksh
1740          echo ""  >> script_${ExeNameOut}.ksh
1741          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1742          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1743          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1744          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1745          echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh
1746          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh
1747          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1748
1749          node_num=0
1750
1751          # We define the number of MPI process to be assigned for the component
1752
1753          nombre_restant_comp=${comp_proc_mpi_loc}
1754
1755          # Loop on the allocated nodes
1756
1757          for node in ${listnodes} ; do
1758
1759            # We go to the current node
1760            if [ ${node_num} = ${node_num_current} ] ; then
1761
1762              node_current=${host[${node_num_current}]}
1763
1764              # If first time on the node : initialisation
1765
1766              if [ ${init_node} = y ] ; then
1767                nombre_restant_node=${NUM_COREPERNODE}
1768              fi
1769
1770              # Test on the number of OMP threads
1771
1772              if [ ${comp_proc_omp_loc} -gt ${nombre_restant_node} ] ; then
1773                (( node_num = node_num + 1 ))
1774                node_num_current=${node_num}
1775                init_node=y
1776                continue
1777              fi
1778
1779              # Number of MPI process to assign
1780
1781              (( num_corempi = nombre_restant_node / comp_proc_omp_loc ))
1782
1783              if [ ${num_corempi} -gt ${nombre_restant_comp} ] ; then
1784                num_corempi=${nombre_restant_comp}
1785              fi
1786
1787              (( nombre_restant_node = nombre_restant_node - num_corempi * comp_proc_omp_loc ))
1788              (( nombre_restant_comp = nombre_restant_comp - num_corempi ))
1789
1790              if [ ${init_exec} = y ] ; then
1791                EXECUTION="${EXECUTION} : -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
1792              else
1793                EXECUTION="${EXECUTION} -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
1794                init_exec=y
1795              fi
1796
1797              ((  start_num = num_corempi + start_num ))
1798
1799            else
1800
1801              (( node_num = node_num + 1 ))
1802              continue
1803            fi
1804
1805            # Test on the number of core/process remaining on the node/component
1806
1807            if [ ${nombre_restant_node} = 0 ] ; then
1808              (( node_num = node_num + 1 ))
1809              node_num_current=${node_num}
1810              init_node=y
1811
1812              if [ ${nombre_restant_comp} = 0 ] ; then
1813                break 1
1814              fi
1815            else
1816
1817              node_num_current=${node_num}
1818              init_node=n
1819
1820              if [ ${nombre_restant_comp} = 0 ] ; then
1821                break 1
1822              fi
1823            fi
1824          done
1825        fi
1826      done
1827
1828    else
1829
1830      # Then first loop on the components for the coupler ie oasis
1831
1832      ## the coupler ie oasis must be the first one
1833      for comp in ${config_ListOfComponents[*]} ; do
1834
1835        eval ExeNameOut=\${config_Executable_${comp}[1]}
1836
1837        # for CPL component only
1838        if [ "X${comp}" = "XCPL" ] ; then
1839          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1840          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file
1841        fi
1842      done
1843
1844      # Then second loop on the components
1845
1846      for comp in ${config_ListOfComponents[*]} ; do
1847
1848        eval ExeNameOut=\${config_Executable_${comp}[1]}
1849
1850        # Only if we really have an executable for the component and not the coupler ie oasis:
1851        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1852          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1853          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1854        fi
1855      done
1856      IGCM_sys_Chmod u+x run_file
1857
1858      EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file"
1859
1860    fi
1861
1862  else # Only one executable. launch it.
1863
1864    for comp in ${config_ListOfComponents[*]} ; do
1865
1866      # Only if we really have an executable for the component :
1867      eval ExeNameOut=\${config_Executable_${comp}[1]}
1868      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
1869
1870        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1871        echo ""  >> script_${ExeNameOut}.ksh
1872        if ( ${OK_PARA_OMP} ) ; then
1873          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1874          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1875        fi
1876        if  ( ${OK_PARA_MPI} ) ; then
1877          # Default : mpirun used if nb_proc gt 1
1878          # pour sortie out/err par process
1879          # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}"  >> script_${ExeNameOut}.ksh
1880          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1881          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1882          EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh"
1883        else
1884          # Default : mpirun is NOT used if nb_proc eq 1
1885          # pour sortie out/err par process
1886          # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
1887          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1888          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1889          EXECUTION="time ./script_${ExeNameOut}.ksh"
1890        fi
1891      fi
1892    done
1893
1894  fi
1895
1896  IGCM_debug_Print 1 "sys Obelix : execution command is"
1897  IGCM_debug_Print 1 "$EXECUTION"
1898
1899  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1900}
1901
1902#D-#==================================================
1903#D-function IGCM_sys_check_path
1904#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
1905#D-* do not point to an important use directory. Stop immediately in that case.
1906#D-* Examples:
1907#D-
1908function IGCM_sys_check_path {
1909  IGCM_debug_PushStack "IGCM_sys_check_path"
1910  if ( $DEBUG_sys ) ; then
1911    echo "IGCM_sys_check_path"
1912  fi
1913
1914  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then
1915    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
1916    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
1917    IGCM_debug_Exit "This will stop the job"
1918  fi
1919  IGCM_debug_PopStack "IGCM_sys_check_path"
1920}
1921
1922#D-#==================================================
1923#D-function IGCM_sys_check_quota. Dummy call here
1924#D-* Purpose: check user quota. Stop the simulation if quota above 90%
1925#D-* Examples:
1926#D-
1927function IGCM_sys_check_quota {
1928  IGCM_debug_PushStack "IGCM_sys_check_quota"
1929  if ( $DEBUG_sys ) ; then
1930    echo "IGCM_sys_check_quota"
1931  fi
1932  IGCM_debug_PopStack "IGCM_sys_check_quota"
1933}
1934
1935#D-#==================================================
1936#D-function IGCM_sys_CountJobInQueue
1937#D-* Purpose: Check if job_name is currently
1938#D-  running or in queue
1939#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
1940#D-
1941function IGCM_sys_CountJobInQueue {
1942  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
1943  if ( $DEBUG_sys ) ; then
1944    echo "IGCM_sys_CountJobInQueue"
1945  fi
1946  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
1947}
1948
1949##############################################################
1950# NCO OPERATOR
1951
1952#D-#==================================================
1953#D-function IGCM_sys_ncap2
1954#D-* Purpose: encapsulate ncap2 call so as to manage error code and retry
1955#D-* Examples:
1956#D-
1957function IGCM_sys_ncap2 {
1958  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1959  if ( $DEBUG_sys ) ; then
1960    echo "IGCM_sys_ncap2 :" $@
1961  fi
1962
1963  typeset NB_ESSAI DELAI status i
1964  # number of tentative
1965  NB_ESSAI=3
1966  # time delay between tentative
1967  DELAI=2
1968
1969  i=0
1970  while [ $i -lt $NB_ESSAI ] ; do
1971    ncap2 "$@" > /tmp/out_command.$$ 2>&1
1972    status=$?
1973    if [ ${status} -gt 0 ] ; then
1974      IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"
1975      cat /tmp/out_command.$$
1976      \rm /tmp/out_command.$$
1977      IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
1978      sleep $DELAI
1979    else
1980      \rm /tmp/out_command.$$
1981      break
1982    fi
1983    (( i = i + 1 ))
1984  done
1985
1986  if [ ${status} -gt 0 ] ; then
1987    echo "IGCM_sys_ncap2 : ncap2 error"
1988    IGCM_debug_Exit "ncap2"
1989  fi
1990
1991  IGCM_debug_PopStack "IGCM_sys_ncap2"
1992}
1993
1994#D-#==================================================
1995#D-function IGCM_sys_ncatted
1996#D-* Purpose: encapsulate ncatted call so as to manage error code and retry
1997#D-* Examples:
1998#D-
1999function IGCM_sys_ncatted {
2000  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
2001  if ( $DEBUG_sys ) ; then
2002    echo "IGCM_sys_ncatted :" $@
2003  fi
2004
2005  typeset NB_ESSAI DELAI status i
2006  # number of tentative
2007  NB_ESSAI=3
2008  # time delay between tentative
2009  DELAI=2
2010
2011  i=0
2012  while [ $i -lt $NB_ESSAI ] ; do
2013    ncatted "$@" > /tmp/out_command.$$ 2>&1
2014    status=$?
2015    if [ ${status} -gt 0 ] ; then
2016      IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"
2017      cat /tmp/out_command.$$
2018      \rm /tmp/out_command.$$
2019      IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2020      sleep $DELAI
2021    else
2022      \rm /tmp/out_command.$$
2023      break
2024    fi
2025    (( i = i + 1 ))
2026  done
2027
2028  if [ ${status} -gt 0 ] ; then
2029    echo "IGCM_sys_ncatted : ncatted error"
2030    IGCM_debug_Exit "ncatted"
2031  fi
2032
2033  IGCM_debug_PopStack "IGCM_sys_ncatted"
2034}
2035
2036#D-#==================================================
2037#D-function IGCM_sys_ncbo
2038#D-* Purpose: encapsulate ncbo call so as to manage error code and retry
2039#D-* Examples:
2040#D-
2041function IGCM_sys_ncbo {
2042  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
2043  if ( $DEBUG_sys ) ; then
2044    echo "IGCM_sys_ncbo :" $@
2045  fi
2046
2047  typeset NB_ESSAI DELAI status i
2048  # number of tentative
2049  NB_ESSAI=3
2050  # time delay between tentative
2051  DELAI=2
2052
2053  i=0
2054  while [ $i -lt $NB_ESSAI ] ; do
2055    ncbo $@ > /tmp/out_command.$$ 2>&1
2056    status=$?
2057    if [ ${status} -gt 0 ] ; then
2058      IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"
2059      cat /tmp/out_command.$$
2060      \rm /tmp/out_command.$$
2061      IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2062      sleep $DELAI
2063    else
2064      \rm /tmp/out_command.$$
2065      break
2066    fi
2067    (( i = i + 1 ))
2068  done
2069
2070  if [ ${status} -gt 0 ] ; then
2071    echo "IGCM_sys_ncbo : ncbo error"
2072    IGCM_debug_Exit "ncbo"
2073  fi
2074
2075  IGCM_debug_PopStack "IGCM_sys_ncbo"
2076}
2077
2078#D-#==================================================
2079#D-function IGCM_sys_ncdif
2080#D-* Purpose: encapsulate ncdiff call so as to manage error code and retry
2081#D-* Examples:
2082#D-
2083function IGCM_sys_ncdiff {
2084  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
2085  if ( $DEBUG_sys ) ; then
2086    echo "IGCM_sys_ncdiff :" $@
2087  fi
2088
2089  typeset NB_ESSAI DELAI status i
2090  # number of tentative
2091  NB_ESSAI=3
2092  # time delay between tentative
2093  DELAI=2
2094
2095  i=0
2096  while [ $i -lt $NB_ESSAI ] ; do
2097    ncdiff $@ > /tmp/out_command.$$ 2>&1
2098    status=$?
2099    if [ ${status} -gt 0 ] ; then
2100      IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"
2101      cat /tmp/out_command.$$
2102      \rm /tmp/out_command.$$
2103      IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2104      sleep $DELAI
2105    else
2106      \rm /tmp/out_command.$$
2107      break
2108    fi
2109    (( i = i + 1 ))
2110  done
2111
2112  if [ ${status} -gt 0 ] ; then
2113    echo "IGCM_sys_ncdiff : ncdiff error"
2114    IGCM_debug_Exit "ncdiff"
2115  fi
2116
2117  IGCM_debug_PopStack "IGCM_sys_ncdiff"
2118}
2119
2120#D-#==================================================
2121#D-function IGCM_sys_ncea
2122#D-* Purpose: encapsulate ncea call so as to manage error code and retry
2123#D-* Examples:
2124#D-
2125function IGCM_sys_ncea {
2126  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
2127  if ( $DEBUG_sys ) ; then
2128    echo "IGCM_sys_ncea :" $@
2129  fi
2130
2131  typeset NB_ESSAI DELAI status i
2132  # number of tentative
2133  NB_ESSAI=3
2134  # time delay between tentative
2135  DELAI=2
2136
2137  i=0
2138  while [ $i -lt $NB_ESSAI ] ; do
2139    ncea $@ > /tmp/out_command.$$ 2>&1
2140    status=$?
2141    if [ ${status} -gt 0 ] ; then
2142      IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"
2143      cat /tmp/out_command.$$
2144      \rm /tmp/out_command.$$
2145      IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2146      sleep $DELAI
2147    else
2148      \rm /tmp/out_command.$$
2149      break
2150    fi
2151    (( i = i + 1 ))
2152  done
2153
2154  if [ ${status} -gt 0 ] ; then
2155    echo "IGCM_sys_ncea : ncea error"
2156    IGCM_debug_Exit "ncea"
2157  fi
2158
2159  IGCM_debug_PopStack "IGCM_sys_ncea"
2160}
2161
2162#D-#==================================================
2163#D-function IGCM_sys_ncecat
2164#D-* Purpose: encapsulate ncecat call so as to manage error code and retry
2165#D-* Examples:
2166#D-
2167function IGCM_sys_ncecat {
2168  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
2169  if ( $DEBUG_sys ) ; then
2170    echo "IGCM_sys_ncecat :" $@
2171  fi
2172
2173  typeset NB_ESSAI DELAI status i
2174  # number of tentative
2175  NB_ESSAI=3
2176  # time delay between tentative
2177  DELAI=2
2178
2179  i=0
2180  while [ $i -lt $NB_ESSAI ] ; do
2181    ncecat $@ > /tmp/out_command.$$ 2>&1
2182    status=$?
2183    if [ ${status} -gt 0 ] ; then
2184      IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"
2185      cat /tmp/out_command.$$
2186      \rm /tmp/out_command.$$
2187      IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2188      sleep $DELAI
2189    else
2190      \rm /tmp/out_command.$$
2191      break
2192    fi
2193    (( i = i + 1 ))
2194  done
2195
2196  if [ ${status} -gt 0 ] ; then
2197    echo "IGCM_sys_ncecat : ncecat error"
2198    IGCM_debug_Exit "ncecat"
2199  fi
2200
2201  IGCM_debug_PopStack "IGCM_sys_ncecat"
2202}
2203
2204#D-#==================================================
2205#D-function IGCM_sys_ncflint
2206#D-* Purpose: encapsulate ncflint call so as to manage error code and retry
2207#D-* Examples:
2208#D-
2209function IGCM_sys_ncflint {
2210  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
2211  if ( $DEBUG_sys ) ; then
2212    echo "IGCM_sys_ncflint :" $@
2213  fi
2214
2215  typeset NB_ESSAI DELAI status i
2216  # number of tentative
2217  NB_ESSAI=3
2218  # time delay between tentative
2219  DELAI=2
2220
2221  i=0
2222  while [ $i -lt $NB_ESSAI ] ; do
2223    ncflint $@ > /tmp/out_command.$$ 2>&1
2224    status=$?
2225    if [ ${status} -gt 0 ] ; then
2226      IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"
2227      cat /tmp/out_command.$$
2228      \rm /tmp/out_command.$$
2229      IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2230      sleep $DELAI
2231    else
2232      \rm /tmp/out_command.$$
2233      break
2234    fi
2235    (( i = i + 1 ))
2236  done
2237
2238  if [ ${status} -gt 0 ] ; then
2239    echo "IGCM_sys_ncflint : ncflint error"
2240    IGCM_debug_Exit "ncflint"
2241  fi
2242
2243  IGCM_debug_PopStack "IGCM_sys_ncflint"
2244}
2245
2246#D-#==================================================
2247#D-function IGCM_sys_ncks
2248#D-* Purpose: encapsulate ncks call so as to manage error code and retry
2249#D-* Examples:
2250#D-
2251function IGCM_sys_ncks {
2252  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
2253  if ( $DEBUG_sys ) ; then
2254    echo "IGCM_sys_ncks :" $@
2255  fi
2256
2257  typeset NB_ESSAI DELAI status i
2258  # number of tentative
2259  NB_ESSAI=3
2260  # time delay between tentative
2261  DELAI=2
2262
2263  i=0
2264  while [ $i -lt $NB_ESSAI ] ; do
2265    ncks $@ > /tmp/out_command.$$ 2>&1
2266    status=$?
2267    if [ ${status} -gt 0 ] ; then
2268      IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"
2269      cat /tmp/out_command.$$
2270      \rm /tmp/out_command.$$
2271      IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2272      sleep $DELAI
2273    else
2274      \rm /tmp/out_command.$$
2275      break
2276    fi
2277    (( i = i + 1 ))
2278  done
2279
2280  if [ ${status} -gt 0 ] ; then
2281    echo "IGCM_sys_ncks : ncks error"
2282    IGCM_debug_Exit "ncks"
2283  fi
2284
2285  IGCM_debug_PopStack "IGCM_sys_ncks"
2286}
2287
2288#D-#==================================================
2289#D-function IGCM_sys_ncpdq
2290#D-* Purpose: encapsulate ncpdq call so as to manage error code and retry
2291#D-* Examples:
2292#D-
2293function IGCM_sys_ncpdq {
2294  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
2295  if ( $DEBUG_sys ) ; then
2296    echo "IGCM_sys_ncpdq :" $@
2297  fi
2298
2299  typeset NB_ESSAI DELAI status i
2300  # number of tentative
2301  NB_ESSAI=3
2302  # time delay between tentative
2303  DELAI=2
2304
2305  i=0
2306  while [ $i -lt $NB_ESSAI ] ; do
2307    ncpdq $@ > /tmp/out_command.$$ 2>&1
2308    status=$?
2309    if [ ${status} -gt 0 ] ; then
2310      IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"
2311      cat /tmp/out_command.$$
2312      \rm /tmp/out_command.$$
2313      IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2314      sleep $DELAI
2315    else
2316      \rm /tmp/out_command.$$
2317      break
2318    fi
2319    (( i = i + 1 ))
2320  done
2321
2322  if [ ${status} -gt 0 ] ; then
2323    echo "IGCM_sys_ncpdq : ncpdq error"
2324    IGCM_debug_Exit "ncpdq"
2325  fi
2326
2327  IGCM_debug_PopStack "IGCM_sys_ncpdq"
2328}
2329
2330#D-#==================================================
2331#D-function IGCM_sys_ncra
2332#D-* Purpose: encapsulate ncra call so as to manage error code and retry
2333#D-* Examples:
2334#D-
2335function IGCM_sys_ncra {
2336  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
2337  if ( $DEBUG_sys ) ; then
2338    echo "IGCM_sys_ncra :" $@
2339  fi
2340
2341  typeset NB_ESSAI DELAI status i
2342  # number of tentative
2343  NB_ESSAI=3
2344  # time delay between tentative
2345  DELAI=2
2346
2347  i=0
2348  while [ $i -lt $NB_ESSAI ] ; do
2349    ncra $@ > /tmp/out_command.$$ 2>&1
2350    status=$?
2351    if [ ${status} -gt 0 ] ; then
2352      IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"
2353      cat /tmp/out_command.$$
2354      \rm /tmp/out_command.$$
2355      IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2356      sleep $DELAI
2357    else
2358      \rm /tmp/out_command.$$
2359      break
2360    fi
2361    (( i = i + 1 ))
2362  done
2363
2364  if [ ${status} -gt 0 ] ; then
2365    echo "IGCM_sys_ncra : ncra error"
2366    IGCM_debug_Exit "ncra"
2367  fi
2368
2369  IGCM_debug_PopStack "IGCM_sys_ncra"
2370}
2371
2372#D-#==================================================
2373#D-function IGCM_sys_ncrcat
2374#D-* Purpose: encapsulate ncrcat call so as to manage error code and retry
2375#D-* Examples:
2376#D-
2377function IGCM_sys_ncrcat {
2378  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
2379  if ( $DEBUG_sys ) ; then
2380    echo "IGCM_sys_ncrcat :" $@
2381  fi
2382
2383  typeset NB_ESSAI DELAI status i lastArg
2384  # number of tentative
2385  NB_ESSAI=3
2386  # time delay between tentative
2387  DELAI=2
2388
2389  i=0
2390  while [ $i -lt $NB_ESSAI ] ; do
2391    ncrcat $@ > /tmp/out_command.$$ 2>&1
2392    status=$?
2393    if [ ${status} -gt 0 ] ; then
2394      IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"
2395      cat /tmp/out_command.$$
2396      \rm /tmp/out_command.$$
2397      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2398      sleep $DELAI
2399    elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" /tmp/out_command.$$ )" = "X" ] ; then
2400      IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"
2401      cat /tmp/out_command.$$
2402      # remove files having corrupted time axis
2403      eval lastArg=\${$#}
2404      IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"
2405      \rm ${lastArg}
2406      \rm /tmp/out_command.$$
2407      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2408      sleep $DELAI
2409    else
2410      \rm /tmp/out_command.$$
2411      break
2412    fi
2413    (( i = i + 1 ))
2414  done
2415
2416  if [ ${status} -gt 0 ] ; then
2417    echo "IGCM_sys_ncrcat : ncrcat error"
2418    #IGCM_debug_Exit "ncrcat"
2419  fi
2420
2421  IGCM_debug_PopStack "IGCM_sys_ncrcat"
2422}
2423
2424#D-#==================================================
2425#D-function IGCM_sys_ncrename
2426#D-* Purpose: encapsulate ncrename call so as to manage error code and retry
2427#D-* Examples:
2428#D-
2429function IGCM_sys_ncrename {
2430  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
2431  if ( $DEBUG_sys ) ; then
2432    echo "IGCM_sys_ncrename :" $@
2433  fi
2434
2435  typeset NB_ESSAI DELAI status i
2436  # number of tentative
2437  NB_ESSAI=3
2438  # time delay between tentative
2439  DELAI=2
2440
2441  i=0
2442  while [ $i -lt $NB_ESSAI ] ; do
2443    ncrename $@ > /tmp/out_command.$$ 2>&1
2444    status=$?
2445    if [ ${status} -gt 0 ] ; then
2446      IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"
2447      cat /tmp/out_command.$$
2448      \rm /tmp/out_command.$$
2449      IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2450      sleep $DELAI
2451    else
2452      \rm /tmp/out_command.$$
2453      break
2454    fi
2455    (( i = i + 1 ))
2456  done
2457
2458  if [ ${status} -gt 0 ] ; then
2459    echo "IGCM_sys_ncrename : ncrename error"
2460    IGCM_debug_Exit "ncrename"
2461  fi
2462
2463  IGCM_debug_PopStack "IGCM_sys_ncrename"
2464}
2465
2466#D-#==================================================
2467#D-function IGCM_sys_ncwa
2468#D-* Purpose: encapsulate ncwa call so as to manage error code and retry
2469#D-* Examples:
2470#D-
2471function IGCM_sys_ncwa {
2472  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
2473  if ( $DEBUG_sys ) ; then
2474    echo "IGCM_sys_ncwa :" $@
2475  fi
2476
2477  typeset NB_ESSAI DELAI status i
2478  # number of tentative
2479  NB_ESSAI=3
2480  # time delay between tentative
2481  DELAI=2
2482
2483  i=0
2484  while [ $i -lt $NB_ESSAI ] ; do
2485    ncwa $@ > /tmp/out_command.$$ 2>&1
2486    status=$?
2487    if [ ${status} -gt 0 ] ; then
2488      IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"
2489      cat /tmp/out_command.$$
2490      \rm /tmp/out_command.$$
2491      IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2492      sleep $DELAI
2493    else
2494      \rm /tmp/out_command.$$
2495      break
2496    fi
2497    (( i = i + 1 ))
2498  done
2499
2500  if [ ${status} -gt 0 ] ; then
2501    echo "IGCM_sys_ncwa : ncwa error"
2502    IGCM_debug_Exit "ncwa"
2503  fi
2504
2505  IGCM_debug_PopStack "IGCM_sys_ncwa"
2506}
2507
2508##############################################################
2509# CDO OPERATOR
2510
2511#D-#==================================================
2512#D-function IGCM_sys_cdo
2513#D-* Purpose: encapsulate cdo call so as to manage error code and retry
2514#D-* Examples:
2515#D-
2516function IGCM_sys_cdo {
2517  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
2518  if ( $DEBUG_sys ) ; then
2519    echo "IGCM_sys_cdo :" $@
2520  fi
2521
2522  typeset status
2523
2524  \cdo $@ > /tmp/out_command.$$ 2>&1
2525  status=$?
2526  if [ ${status} -gt 0 ] ; then
2527    echo "IGCM_sys_cdo : error code ${status}"
2528    cat /tmp/out_command.$$
2529    \rm /tmp/out_command.$$
2530    IGCM_debug_PopStack "IGCM_sys_cdo"
2531    return 1
2532  else
2533    IGCM_debug_PopStack "IGCM_sys_cdo"
2534    return 0
2535  fi
2536
2537  IGCM_debug_PopStack "IGCM_sys_cdo"
2538}
Note: See TracBrowser for help on using the repository browser.