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

Last change on this file since 714 was 714, checked in by sdipsl, 12 years ago

all machine : multiple tries over nco commands.

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