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

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