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

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