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

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