source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh @ 544

Last change on this file since 544 was 544, checked in by sdipsl, 13 years ago
  • Prepare libIGCM for TGCC migration. For now work for CCRT machines ONLY
  • SX8, SX9 and Titane are independant from DMNFS
    • 30 seconds between execution instead of at least 3 minutes ; sometimes hours
  • SX8, SX9 and Titane use their SCRATCHDIR as a BUFFER (for restart and text)
  • Titane simulations are entirely post-processed on titane mono
    • Working except create_se and atlas (missing software : ncap2, openpbm, ImageMagick?)
  • Cards are the same up to now
  • New indentation to ease readability ("svn diff -x -b" to ignore space when differencing)
  • Project (gen2211) is inherited from AA_job by post-processing jobs
    • will stop during config_check if Project is empty
  • Prepare easy switching (submitting post-processing here or there)
  • Homogenize CCRTs libIGCM_sys
  • Bugfixes
  • Cosmetics

First steps and still a long way to go.

  • Property svn:keywords set to Revision Author Date
File size: 43.8 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip
5# Contact: Sebastien.Denvil__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 Mercure X64
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
70#D-
71#D-#==================================================
72#D-Program used in libIGCM
73#D-#==================================================
74
75# rsync with path
76typeset -r RSYNC=/usr/bin/rsync
77# RSYNC_opt args to rsync
78typeset -r RSYNC_opt="-va"
79# ie storage filesystem
80typeset -r RHOST=mercure
81
82#====================================================
83# Set environment tools (ferret, nco, cdo)
84#====================================================
85. /home/cont003/p86ipsl/.atlas_env_mercure01_ksh
86
87#====================================================
88# Host specific DIRECTORIES
89#====================================================
90
91#====================================================
92#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
93typeset -r R_EXE="${MODIPSL}/bin"
94
95#====================================================
96# For interactive jobs on mercure
97PBS_O_WORKDIR=${PBS_O_WORKDIR:=$(pwd)}
98
99#====================================================
100#- SUBMIT_DIR : submission dir
101typeset SUBMIT_DIR=${SUBMIT_DIR:=${PBS_O_WORKDIR}}
102
103#====================================================
104#- ARCHIVE
105typeset -r ARCHIVE=${DMFDIR}
106
107#====================================================
108#- IN
109typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM}
110typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data}
111
112#====================================================
113#- R_OUT
114typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
115
116#====================================================
117#- R_BUF (ONLY FOR double copy an scratch)
118typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT
119
120#====================================================
121#- BIG_DIR : BIG_DIR to store files waiting for rebuild
122typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD}
123
124#====================================================
125#- OUT_POST
126typeset -r R_OUT_POST=${SCRATCHDIR}/IGCM_OUT
127
128#====================================================
129#- RUN_DIR_PATH : Temporary working directory (=> TMP)
130typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${CSCRATCHDIR}/TMPDIR_IGCM/${JOBID}}
131
132#====================================================
133#- Max number of arguments passed to nco operator or demigration command
134UNIX_MAX_LIMIT=360
135
136#D-#==================================================
137#D-function IGCM_sys_RshMaster
138#D-* Purpose: Just a fake command to wrapp
139#D-           IGCM_card call in post-treatment
140#D-           Ulam do not see brodie filesystem
141#D-           Cesium do not see all mercure filesystem
142#D-           That's why we need this hack.
143#D-* Examples:
144#D-
145function IGCM_sys_RshMaster {
146  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
147  /bin/ksh <<-EOF
148    export libIGCM=${libIGCM}
149    export DEBUG_debug=${DEBUG_debug}
150    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
151    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
152    ${@}
153EOF
154  if [ $? -gt 0 ] ; then
155    echo "IGCM_sys_RshMaster : erreur."
156    IGCM_debug_Exit "IGCM_sys_RshMaster"
157  fi
158  IGCM_debug_PopStack "IGCM_sys_RshMaster"
159}
160
161#D-#==================================================
162#D-function IGCM_sys_RshArchive
163#D-* Purpose: Archive rsh command
164#D-* Examples:
165#D-
166function IGCM_sys_RshArchive {
167  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
168  /bin/ksh <<-EOF
169    ${@}
170EOF
171  if [ $? -gt 0 ] ; then
172    echo "IGCM_sys_RshArchive : erreur."
173    IGCM_debug_Exit "IGCM_sys_RshArchive"
174  fi
175  IGCM_debug_PopStack "IGCM_sys_RshArchive"
176}
177
178#D-#==================================================
179#D-function IGCM_sys_RshPost
180#D-* Purpose: Post-process rsh command
181#D-* Examples:
182#D-
183function IGCM_sys_RshPost {
184  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
185  if ( $DEBUG_sys ) ; then
186    echo "IGCM_sys_RshPost :" $@
187  fi
188  /bin/ksh ${@}
189  if [ $? -gt 0 ] ; then
190    echo "IGCM_sys_RshPost : erreur."
191    IGCM_debug_Exit "IGCM_sys_RshPost"
192  fi
193  IGCM_debug_PopStack "IGCM_sys_RshPost"
194}
195
196#D-#==================================================
197#D-function IGCM_sys_SendMail
198#D-* Purpose: Send mail when simulation is over
199#D-* Examples:
200#D-
201function IGCM_sys_SendMail {
202  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
203  if ( $DEBUG_sys ) ; then
204    echo "IGCM_sys_SendMail :" $@
205  fi
206
207  if ( ${ExitFlag} ) ; then
208    status=failed
209  else
210    status=completed
211  fi
212  cat  << END_MAIL > job_end.mail
213Dear ${LOGIN},
214
215  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
216  Job started : ${DateBegin}
217  Job ended   : ${DateEnd}
218  Output files are available in ${R_SAVE}
219  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
220END_MAIL
221
222  if  [ X"${config_UserChoices_MailName}" != X ] ; then
223    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail
224  elif [ -f ~/.forward ] ; then
225    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
226  else
227    mailx -s "${config_UserChoices_JobName} ${status}" ${LOGIN} < job_end.mail
228  fi
229
230  if [ $? -gt 0 ] ; then
231    echo "IGCM_sys_SendMail : erreur."
232    IGCM_debug_Exit "IGCM_sys_SendMail"
233  fi
234  IGCM_debug_PopStack "IGCM_sys_SendMail"
235}
236
237#D-#==================================================
238#D-function IGCM_sys_Mkdir
239#D-* Purpose: Master locale mkdir command
240#D-* Examples:
241#D-
242function IGCM_sys_Mkdir {
243  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
244  if ( $DEBUG_sys ) ; then
245    echo "IGCM_sys_Mkdir :" $@
246  fi
247  if [ ! -d ${1} ]; then
248    \mkdir -p $1
249    if [ $? -gt 0 ] ; then
250      echo "IGCM_sys_Mkdir : erreur."
251      IGCM_debug_Exit "IGCM_sys_Mkdir"
252    fi
253  fi
254  # vérification :
255  if [ ! -d ${1} ] ; then
256    echo "IGCM_sys_Mkdir : erreur."
257    IGCM_debug_Exit "IGCM_sys_Mkdir"
258  fi
259  IGCM_debug_PopStack "IGCM_sys_Mkdir"
260}
261
262#D-#==================================================
263#D-function IGCM_sys_MkdirArchive
264#D-* Purpose: Mkdir on Archive
265#D-* Examples:
266#D-
267function IGCM_sys_MkdirArchive {
268  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
269  if ( $DEBUG_sys ) ; then
270    echo "IGCM_sys_MkdirArchive :" $@
271  fi
272  #- creation de repertoire sur le serveur fichier
273  if [ ! -d ${1} ]; then 
274    \mkdir -p $1
275    if [ $? -gt 0 ] ; then
276      echo "IGCM_sys_MkdirArchive : erreur."
277      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
278    fi
279  fi
280  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
281}
282
283#D-#==================================================
284#D-function IGCM_sys_MkdirWork
285#D-* Purpose: Mkdir on Work
286#D-* Examples:
287#D-
288function IGCM_sys_MkdirWork {
289  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
290  if ( $DEBUG_sys ) ; then
291    echo "IGCM_sys_MkdirWork :" $@
292  fi
293  #- creation de repertoire sur le serveur fichier
294  if [ ! -d ${1} ]; then 
295    \mkdir -p $1
296    if [ $? -gt 0 ] ; then
297      echo "IGCM_sys_MkdirWork : erreur."
298      IGCM_debug_Exit "IGCM_sys_MkdirWork"
299    fi
300  fi
301  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
302}
303
304#D-#==================================================
305#D-function IGCM_sys_Cd
306#D-* Purpose: master cd command
307#D-* Examples:
308#D-
309function IGCM_sys_Cd {
310  IGCM_debug_PushStack "IGCM_sys_Cd" $@
311  if ( $DEBUG_sys ) ; then
312    echo "IGCM_sys_Cd :" $@
313  fi
314  \cd $1
315  if [ $? -gt 0 ] ; then
316    echo "IGCM_sys_Cd : erreur."
317    IGCM_debug_Exit "IGCM_sys_Cd"
318  fi
319  IGCM_debug_PopStack "IGCM_sys_Cd"
320}
321
322#D-#==================================================
323#D-function IGCM_sys_Chmod
324#D-* Purpose: Chmod
325#D-* Examples:
326#D-
327function IGCM_sys_Chmod {
328  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
329  if ( $DEBUG_sys ) ; then
330    echo "IGCM_sys_Chmod :" $@
331  fi
332  if [ $DRYRUN -le 1 ]; then
333    \chmod $@
334    if [ $? -gt 0 ] ; then
335      echo "IGCM_sys_Chmod : erreur."
336      IGCM_debug_Exit "IGCM_sys_Chmod"
337    fi
338  else
339    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
340  fi
341  IGCM_debug_PopStack "IGCM_sys_Chmod"
342}
343
344#D-#==================================================
345#D-function IGCM_sys_FileSize
346#D-* Purpose: Filesize
347#D-* Examples:
348#D-
349function IGCM_sys_FileSize {
350  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
351
352  typeset sizeF
353  set +A sizeF -- $( ls -la ${1} )
354  if [ $? -gt 0 ] ; then
355    IGCM_debug_Exit "IGCM_sys_FileSize"
356  fi
357  eval ${2}=${sizeF[4]}
358
359  IGCM_debug_PopStack "IGCM_sys_FileSize"
360}
361
362#D-#==================================================
363#D-function IGCM_sys_TestDir
364#D-* Purpose: Test Directory that must exists
365#D-* Examples:
366#D-
367function IGCM_sys_TestDir {
368  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
369  if ( $DEBUG_sys ) ; then
370    echo "IGCM_sys_TestDir :" $@
371  fi
372  typeset ExistFlag
373  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
374  IGCM_debug_PopStack "IGCM_sys_TestDir"
375
376  return ${ExistFlag}
377}
378
379#D-#==================================================
380#D-function IGCM_sys_TestDirArchive
381#D-* Purpose: Test Directory that must exists on Archive
382#D-* Examples:
383#D-
384function IGCM_sys_TestDirArchive {
385  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
386  if ( $DEBUG_sys ) ; then
387    echo "IGCM_sys_TestDirArchive :" $@
388  fi
389  typeset ExistFlag
390  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
391  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
392
393  return ${ExistFlag}
394}
395
396#D-#==================================================
397#D-function IGCM_sys_TestFileArchive
398#D-* Purpose: Test file that must NOT EXISTS on Archive
399#D-* Examples:
400#D-
401function IGCM_sys_TestFileArchive {
402  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
403  if ( $DEBUG_sys ) ; then
404    echo "IGCM_sys_TestFileArchive :" $@
405  fi
406  typeset ExistFlag
407  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
408  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
409
410  return ${ExistFlag}
411}
412
413#D-#==================================================
414#D-function IGCM_sys_TestFileBuffer
415#D-* Purpose: Test file that must NOT EXISTS on Buffer
416#D-* Examples:
417#D-
418function IGCM_sys_TestFileBuffer {
419  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
420  typeset ExistFlag
421  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
422  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
423
424  return ${ExistFlag}
425}
426
427#D-#==================================================
428#D-function IGCM_sys_CountFileArchive
429#D-* Purpose: Count files on Archive filesystem
430#D-* Examples:
431#D-
432function IGCM_sys_CountFileArchive {
433  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
434  ls ${@} 2>/dev/null | wc -l
435  if [ $? -gt 0 ] ; then
436    echo "IGCM_sys_CountFileArchive : erreur."
437  fi
438  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
439}
440
441#D-#==================================================
442#D-function IGCM_sys_CountFileBuffer
443#D-* Purpose: Count files on Scratch filesystem
444#D-* Examples:
445#D-
446function IGCM_sys_CountFileBuffer {
447  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
448  ls ${@} 2>/dev/null | wc -l
449  if [ $? -gt 0 ] ; then
450    echo "IGCM_sys_CountFileBuffer : erreur."
451  fi
452  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
453}
454
455#D-#==================================================
456#D-function IGCM_sys_Tree
457#D-* Purpose: Tree directories with files on ${ARCHIVE}
458#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
459#D-
460function IGCM_sys_Tree {
461  IGCM_debug_PushStack "IGCM_sys_Tree" $@
462  if ( $DEBUG_sys ) ; then
463    echo "IGCM_sys_Tree :" $@
464  fi
465
466  \tree -f $@
467
468  IGCM_debug_PopStack "IGCM_sys_Tree"
469}
470
471#D-#==================================================
472#D-function IGCM_sys_Tar
473#D-* Purpose: master tar command
474#D-* Examples:
475#D-
476function IGCM_sys_Tar {
477  IGCM_debug_PushStack "IGCM_sys_Tar" $@
478  if ( $DEBUG_sys ) ; then
479    echo "IGCM_sys_Tar :" $@
480  fi
481  \tar cf $@
482  if [ $? -gt 0 ] ; then
483    echo "IGCM_sys_Tar : erreur."
484    IGCM_debug_Exit "IGCM_sys_Tar"
485  fi
486  IGCM_debug_PopStack "IGCM_sys_Tar"
487}
488
489#D-#==================================================
490#D-function IGCM_sys_UnTar
491#D-* Purpose: master un-tar command
492#D-* Examples:
493#D-
494function IGCM_sys_UnTar {
495  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
496  if ( $DEBUG_sys ) ; then
497    echo "IGCM_sys_UnTar :" $@
498  fi
499  \tar xvf $1
500  if [ $? -gt 0 ] ; then
501    echo "IGCM_sys_UnTar : erreur."
502    IGCM_debug_Exit "IGCM_sys_UnTar"
503  fi
504  IGCM_debug_PopStack "IGCM_sys_UnTar"
505}
506
507#D-#==================================================
508#D-function IGCM_sys_QsubPost
509#D-* Purpose: Qsub new job on scalaire
510#D-* Examples:
511#D-
512function IGCM_sys_QsubPost {
513  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
514  if ( $DEBUG_sys ) ; then
515    echo "IGCM_sys_QsubPost :" $@
516  fi
517  /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv}
518  if [ $? -gt 0 ] ; then
519    echo "IGCM_sys_QsubPost : erreur " $@
520    IGCM_debug_Exit "IGCM_sys_QsubPost"
521  fi
522  IGCM_debug_PopStack "IGCM_sys_QsubPost"
523}
524
525#D-*************************
526#D- File transfer functions
527#D-*************************
528#D-
529
530#D-#==================================================
531#D-function IGCM_sys_Rsync_out
532#D-* Purpose: treat return val of rsync
533#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
534#D-  Error values and explanations can depend on your system version.
535function IGCM_sys_Rsync_out {
536  RET=$1
537  if [ ! $RET ] ; then
538    echo "rsync error !"
539  fi
540
541  if [ $MYLANG = "fr" ]; then
542    case $RET in
543    0)  return ;;
544    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
545      echo "Erreur de syntaxe ou d'utilisation."
546      return;;
547    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
548      echo "Incompatibilité de protocole."
549      return;;
550    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
551      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
552      echo "répertoires"
553      return;;
554    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
555      echo "Action demandée non supportée : une tentative de manipulation de"
556      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
557      echo "été faite ; ou une option qui est supportée par le  client  mais"
558      echo "pas par le serveur a été spécifiée."
559      return;;
560    10) echo "Erreur de rsync ; RERR_SOCKETIO"
561      echo "Erreur dans le socket d'entrée sortie"
562      return;;
563    11) echo "Erreur de rsync ; RERR_FILEIO"
564      echo "Erreur d'entrée sortie fichier"
565      return;;
566    12) echo "Erreur de rsync ; RERR_STREAMIO"
567      echo "Erreur dans flux de donnée du protocole rsync"
568      return;;
569    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
570      echo "Erreur avec les diagnostics du programme"
571      return;;
572    14) echo "Erreur de rsync ; RERR_IPC"
573      echo "Erreur dans le code IPC"
574      return;;
575    20) echo "Erreur de rsync ; RERR_SIGNAL"
576      echo "SIGUSR1 ou SIGINT reçu"
577      return;;
578    21) echo "Erreur de rsync ; RERR_WAITCHILD"
579      echo "Une erreur retournée par waitpid()"
580      return;;
581    22) echo "Erreur de rsync ; RERR_MALLOC"
582      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
583      return;;
584    23) echo ""
585      echo "Erreur fichier inexistant"
586      return;;
587    30) echo "Erreur de rsync ; RERR_TIMEOUT"
588      echo "Temps d'attente écoulé dans l'envoi/réception de données"
589      return;;
590    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
591      return;;
592    esac
593  elif [ $MYLANG = "en" ] ; then
594    case $RET in
595    0)  return;;               
596    1)  echo "rsync error : Syntax or usage error "
597      return;;
598    2)  echo "rsync error : Protocol incompatibility "
599      return;;
600    3)  echo "rsync error : Errors selecting input/output files, dirs"
601      return;;
602    4)  echo "rsync error : Requested action not supported: an attempt"
603      echo "was made to manipulate 64-bit files on a platform that cannot support"
604      echo "them; or an option was specified that is supported by the client and"
605      echo "not by the server."
606      return;;
607    5)  echo "rsync error : Error starting client-server protocol"
608      return;;
609    10) echo "rsync error : Error in socket I/O "
610      return;;
611    11) echo "rsync error : Error in file I/O "
612      return;;
613    12) echo "rsync error : Error in rsync protocol data stream "
614      return;;
615    13) echo "rsync error : Errors with program diagnostics "
616      return;;
617    14) echo "rsync error : Error in IPC code "
618      return;;
619    20) echo "rsync error : Received SIGUSR1 or SIGINT "
620      return;;
621    21) echo "rsync error : Some error returned by waitpid() "
622      return;;
623    22) echo "rsync error : Error allocating core memory buffers "
624      return;;
625    23) echo "rsync error : Partial transfer due to error"
626      return;;
627    24) echo "rsync error : Partial transfer due to vanished source files"
628      return;;
629    30) echo "rsync error : Timeout in data send/receive "
630      return;;
631    *)  echo "rsync error : return code of rsync unknown :" $RET
632      return;;
633    esac
634  else
635    echo "unknown language $MYLANG."
636    return
637  fi
638}
639
640#D-#==================================================
641#D-function IGCM_sys_Cp
642#D-* Purpose: generic cp
643#D-* Examples:
644#D-
645function IGCM_sys_Cp {
646  IGCM_debug_PushStack "IGCM_sys_Cp" $@
647  if ( $DEBUG_sys ) ; then
648    echo "IGCM_sys_Cp :" $@
649  fi
650
651  typeset RET
652
653  echo cp $@ > out_rsync 2>&1
654  \cp $@ >> out_rsync 2>&1
655  RET=$?
656
657  if [ ${RET} -gt 0 ] ; then
658    echo "IGCM_sys_Cp : error."
659    cat out_rsync
660    IGCM_debug_Exit "IGCM_sys_Cp"
661  else
662    \rm out_rsync
663  fi
664  IGCM_debug_PopStack "IGCM_sys_Cp"
665}
666
667#D-#==================================================
668#D-function IGCM_sys_Rm
669#D-* Purpose: generic rm
670#D-* Examples:
671#D-
672function IGCM_sys_Rm {
673  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
674  if ( $DEBUG_sys ) ; then
675    echo "IGCM_sys_Rm :" $@
676  fi
677
678  typeset RET
679
680  echo rm $@ > out_rsync 2>&1
681  \rm $@ >> out_rsync 2>&1
682  RET=$?
683
684  if [ ${RET} -gt 0 ] ; then
685    echo "IGCM_sys_Rm : error."
686    cat out_rsync
687    IGCM_debug_Exit "IGCM_sys_Rm"
688  else
689    \rm out_rsync
690  fi
691  IGCM_debug_PopStack "IGCM_sys_Rm"
692}
693
694#D-#==================================================
695#D-function IGCM_sys_RmRunDir
696#D-* Purpose: rm tmpdir (dummy function most of the time batch
697#D-                      scheduler will do the job)
698#D-* Examples:
699#D-
700function IGCM_sys_RmRunDir {
701  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
702  if ( $DEBUG_sys ) ; then
703    echo "IGCM_sys_RmRunDir :" $@
704  fi
705
706  typeset RET
707
708  echo rm $@ > out_rsync 2>&1
709  \rm $@ >> out_rsync 2>&1
710  RET=$?
711
712  if [ ${RET} -gt 0 ] ; then
713    echo "IGCM_sys_RmRunDir : error."
714    cat out_rsync
715    IGCM_debug_Exit "IGCM_sys_RmRunDir"
716  else
717    \rm out_rsync
718  fi
719  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
720}
721
722#D-#==================================================
723#D-function IGCM_sys_Mv
724#D-* Purpose: generic move
725#D-* Examples:
726#D-
727function IGCM_sys_Mv {
728  IGCM_debug_PushStack "IGCM_sys_Mv" $@
729  if ( $DEBUG_sys ) ; then
730    echo "IGCM_sys_Mv :" $@
731  fi
732
733  if [ $DRYRUN = 0 ]; then
734
735    typeset RET
736   
737    echo mv $@ > out_rsync 2>&1
738    \mv $@ >> out_rsync 2>&1
739    RET=$?
740   
741    if [ ${RET} -gt 0 ] ; then
742      echo "IGCM_sys_Mv : error in mv."
743      cat out_rsync
744      IGCM_debug_Exit "IGCM_sys_Mv"
745    else
746      \rm out_rsync
747    fi
748  else
749    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
750  fi
751
752  IGCM_debug_PopStack "IGCM_sys_Mv"
753}
754
755#D-#==================================================
756#D-function IGCM_sys_Put_Dir
757#D-* Purpose: Copy a complete directory on $(ARCHIVE)
758#D-* Examples:
759#D-
760function IGCM_sys_Put_Dir {
761  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
762  if ( $DEBUG_sys ) ; then
763    echo "IGCM_sys_Put_Dir :" $@
764  fi
765  if [ $DRYRUN = 0 ]; then
766    if [ ! -d ${1} ] ; then
767      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
768      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
769      return
770    fi
771
772    typeset RET
773
774    # Only if we use rsync
775    #IGCM_sys_TestDirArchive $( dirname $2 )
776    #
777    #USUAL WAY
778    \cp -r $1 $2 > out_rsync 2>&1
779    RET=$?
780
781    if [ ${RET} -gt 0 ] ; then
782      echo "IGCM_sys_Put_Dir : error."
783      cat out_rsync
784      IGCM_debug_Exit "IGCM_sys_Put_Dir"
785    else
786      \rm out_rsync
787    fi
788  else
789    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
790  fi
791  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
792}
793
794#D-#==================================================
795#D-function IGCM_sys_Get_Dir
796#D-* Purpose: Copy a complete directory from $(ARCHIVE)
797#D-* Examples:
798#D-
799function IGCM_sys_Get_Dir {
800  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
801  if ( $DEBUG_sys ) ; then
802    echo "IGCM_sys_Get_Dir :" $@
803  fi
804  if [ $DRYRUN = 0 ]; then
805#       if [ ! -d ${1} ] ; then
806#           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
807#           IGCM_debug_PopStack "IGCM_sys_Get_Dir"
808#           return
809#       fi
810
811    typeset RET
812
813    # Only if we use rsync
814    #IGCM_sys_TestDirArchive $( dirname $2 )
815    #
816    #USUAL WAY
817    # add dmget (to demigrate all offline files) to reduce time of this command :
818    dmget $1/*
819    \cp -r $1 $2 > out_rsync 2>&1
820    RET=$?
821
822    if [ ${RET} -gt 0 ] ; then
823      echo "IGCM_sys_Get_Dir : error."
824      cat out_rsync
825      IGCM_debug_Exit "IGCM_sys_Get_Dir"
826    else
827      \rm out_rsync
828    fi
829  else
830    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
831  fi
832  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
833}
834
835#D-#==================================================
836#D-function IGCM_sys_Get_Master
837#D-* Purpose: Copy a complete directory from MASTER filesystem
838#D-* Examples:
839#D-
840function IGCM_sys_Get_Master {
841  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
842  if ( $DEBUG_sys ) ; then
843    echo "IGCM_sys_Get_Master :" $@
844  fi
845  if [ $DRYRUN = 0 ]; then
846    if [ ! -d ${1} ] ; then
847      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
848      IGCM_debug_PopStack "IGCM_sys_Get_Master"
849      return
850    fi
851
852    typeset RET
853
854    #USUAL WAY
855    \cp -r $1 $2 > out_rsync 2>&1
856    RET=$?
857
858    if [ ${RET} -gt 0 ] ; then
859      echo "IGCM_sys_Get_Master : error."
860      cat out_rsync
861      IGCM_debug_Exit "IGCM_sys_Get_Master"
862    else
863      \rm out_rsync
864    fi
865  else
866    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
867  fi
868  IGCM_debug_PopStack "IGCM_sys_Get_Master"
869}
870
871#D-#==================================================
872#D-function IGCM_sys_Put_Rest
873#D-* Purpose: Put computied restarts on ${ARCHIVE}.
874#D-           File and target directory must exist.
875#D-* Examples:
876#D-
877function IGCM_sys_Put_Rest {
878  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
879  if ( $DEBUG_sys ) ; then
880    echo "IGCM_sys_Put_Rest :" $@
881  fi
882  if [ $DRYRUN = 0 ]; then
883    if [ ! -f ${1} ] ; then
884      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
885      IGCM_debug_Exit "IGCM_sys_Put_Rest"
886    fi
887
888    typeset RET
889    #
890    if [ X${JobType} = XRUN ] ; then
891      IGCM_sys_Chmod 444 ${1}
892    fi
893
894    #
895    # USUAL WAY
896    \cp $1 $2 > out_rsync 2>&1
897    RET=$?
898
899#       #RSYNC WITH NETWORK SSH CALL
900#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
901#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
902
903#       #RSYNC WITH NFS USE
904#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
905#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
906
907#       RET=$?
908#       IGCM_sys_Rsync_out $RET
909
910#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
911#       (( RET=RET+$? ))
912
913    if [ ${RET} -gt 0 ] ; then
914      echo "IGCM_sys_Put_Rest : error."
915      cat out_rsync
916      IGCM_debug_Exit "IGCM_sys_Put_Rest"
917    else
918      \rm out_rsync
919    fi
920  else
921    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
922  fi
923  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
924}
925
926#D-#==================================================
927#D-function IGCM_sys_PutBuffer_Rest
928#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
929#D-           File and target directory must exist.
930#D-* Examples:
931#D-
932function IGCM_sys_PutBuffer_Rest {
933  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
934  if ( $DEBUG_sys ) ; then
935    echo "IGCM_sys_PutBuffer_Rest :" $@
936  fi
937  if [ $DRYRUN = 0 ]; then
938    if [ ! -f ${1} ] ; then
939      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
940      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
941    fi
942
943    typeset RET
944    #
945    if [ X${JobType} = XRUN ] ; then
946      IGCM_sys_Chmod 444 ${1}
947    fi
948
949    #
950    # USUAL WAY
951    \cp $1 $2 > out_rsync 2>&1
952    RET=$?
953
954    if [ ${RET} -gt 0 ] ; then
955      echo "IGCM_sys_PutBuffer_Rest : error."
956      cat out_rsync
957      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
958    else
959      \rm out_rsync
960    fi
961  else
962    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
963  fi
964  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
965}
966
967#D-#==================================================
968#D-function IGCM_sys_Put_Out
969#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
970#D-* Examples:
971#D-
972function IGCM_sys_Put_Out {
973  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
974  if ( $DEBUG_sys ) ; then
975    echo "IGCM_sys_Put_Out :" $@
976  fi
977  if [ $DRYRUN = 0 ]; then
978    if [ ! -f ${1} ] ; then
979      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
980      IGCM_debug_PopStack "IGCM_sys_Put_Out"
981      return 1
982    fi
983    #
984    IGCM_sys_MkdirArchive $( dirname $2 )
985    #
986    typeset RET exist skip
987
988    #=====================================================
989    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
990    #=====================================================
991
992    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
993    #if [ $? -eq 0 ] ; then
994    #    typeset WORKPATH FILEPATH
995    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" )
996    #    IGCM_sys_MkdirWork ${WORKPATH}
997    #    FILEPATH=${WORKPATH}/$( basename $2 )
998    #    #
999    #    IGCM_sys_Cp ${1} ${FILEPATH}
1000    #fi
1001
1002    if [ X${JobType} = XRUN ] ; then
1003      if [ X${3} = X ] ; then
1004        IGCM_sys_Chmod 444 ${1}
1005      fi
1006    fi
1007
1008    exist=false
1009    skip=false
1010    if [ -f $2 ] ; then
1011      IGCM_debug_Print 1 "$2 already exist"
1012      dmget $2
1013      exist=true
1014      if [ "X$( diff $1 $2 )" = X ] ; then
1015        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
1016        skip=true
1017      else
1018        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
1019        skip=false
1020      fi
1021    fi
1022    #
1023    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
1024      IGCM_sys_Chmod u+w $2
1025    fi
1026    # USUAL WAY
1027    if [ X${skip} = Xfalse ] ; then
1028      \cp $1 $2 > out_rsync 2>&1
1029      RET=$?
1030      if [ ${RET} -gt 0 ] ; then
1031        echo "IGCM_sys_Put_Out : error."
1032        cat out_rsync
1033        IGCM_debug_Exit "IGCM_sys_Put_Out"
1034      else
1035        \rm out_rsync
1036      fi
1037    fi
1038
1039#       #RSYNC WITH NETWORK SSH CALL
1040#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1041#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1042
1043#       #RSYNC WITH NFS USE
1044#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1045#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1046
1047#       RET=$?
1048#       IGCM_sys_Rsync_out $RET
1049
1050#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1051#       (( RET=RET+$? ))
1052
1053  else
1054    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1055  fi
1056  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1057  return 0
1058}
1059
1060#D-#==================================================
1061#D-function IGCM_sys_PutBuffer_Out
1062#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1063#D-* Examples:
1064#D-
1065function IGCM_sys_PutBuffer_Out {
1066  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1067  if ( $DEBUG_sys ) ; then
1068    echo "IGCM_sys_PutBuffer_Out :" $@
1069  fi
1070  if [ $DRYRUN = 0 ]; then
1071    if [ ! -f ${1} ] ; then
1072      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1073      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1074      return 1
1075    fi
1076    #
1077    IGCM_sys_Mkdir $( dirname $2 )
1078    #
1079    typeset RET
1080
1081    if [ X${JobType} = XRUN ] ; then
1082      if [ X${3} = X ] ; then
1083        IGCM_sys_Chmod 444 ${1}
1084      fi
1085    fi
1086    #
1087    # USUAL WAY
1088    \cp $1 $2 > out_rsync 2>&1
1089    RET=$?
1090
1091    if [ ${RET} -gt 0 ] ; then
1092      echo "IGCM_sys_PutBuffer_Out : error."
1093      cat out_rsync
1094      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1095    else
1096      \rm out_rsync
1097    fi
1098  else
1099    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1100  fi
1101  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1102  return 0
1103}
1104
1105#D-#==================================================
1106#D-function IGCM_sys_Get
1107#D-* Purpose: Get a file from ${ARCHIVE}
1108#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1109#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1110function IGCM_sys_Get {
1111  IGCM_debug_PushStack "IGCM_sys_Get" $@
1112
1113  typeset DEST RET dm_liste ifile target file_work
1114
1115  if ( $DEBUG_sys ) ; then
1116    echo "IGCM_sys_Get :" $@
1117  fi
1118  if [ $DRYRUN -le 2 ]; then
1119    if [ X${1} = X'/l' ] ; then
1120      # test if the first file is present in the old computation :
1121      eval set +A dm_liste \${${2}}
1122    else
1123      eval set +A dm_liste ${1}
1124    fi
1125    eval DEST=\${${#}}
1126
1127    #=====================================================
1128    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1129    #=====================================================
1130
1131    # Is it an R_OUT file (not R_IN) ?
1132    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1133    #if [ $? -eq 0 ] ; then
1134    #    # Yes  ? then we try to get it in SCRATCHDIR
1135    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" )
1136    #    if [ -f ${file_work[0]} ] ; then
1137    #   IGCM_sys_Cp ${file_work[*]} ${DEST}
1138    #   IGCM_debug_PopStack "IGCM_sys_Get"
1139    #   return
1140    #    fi
1141    #fi
1142
1143    # test if the (first) file is present in the old computation :
1144    IGCM_sys_TestFileArchive ${dm_liste[0]}
1145    RET=$?
1146    if [ ${RET} -gt 0 ] ; then
1147      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1148      IGCM_debug_Exit "IGCM_sys_Get"
1149    fi
1150
1151    dmget ${dm_liste[*]} > out_rsync 2>&1
1152    RET=$?
1153
1154    if [ ${RET} -gt 0 ] ; then
1155      echo "WARNING IGCM_sys_Get : demigration error."
1156      cat out_rsync
1157      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
1158    fi
1159
1160    #if [ ${RET} -gt 0 ] ; then
1161    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
1162    #   cat out_rsync
1163    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
1164    #   sleep 30
1165    #   echo "We try another time"
1166    #   dmget ${dm_liste[*]} > out_rsync 2>&1
1167    #   RET=$?
1168    #   if [ ${RET} -gt 0 ] ; then
1169    #       echo "ERROR IGCM_sys_Get : again demigration error :"
1170    #       cat out_rsync
1171    #       IGCM_debug_Exit "IGCM_sys_Get"
1172    #   fi
1173    #    else
1174    #   echo "ERROR IGCM_sys_Get : demigration error :"
1175    #   cat out_rsync
1176    #   IGCM_debug_Exit "IGCM_sys_Get"
1177    #    fi
1178    #fi
1179
1180    #USUAL WAY
1181    if [ X${1} = X'/l' ] ; then
1182      (( RET=0 ))
1183      for target in ${dm_liste[*]} ; do
1184        local_file=$( basename ${target} )
1185        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1186        (( RET = RET + $? ))
1187      done
1188    else
1189      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1190      RET=$?
1191    fi
1192
1193#       #RSYNC WITH NETWORK SSH CALL
1194#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1195#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1196
1197#       #RSYNC WITH NFS USE
1198#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1199#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1200
1201#       RET=$?
1202#       IGCM_sys_Rsync_out $RET
1203
1204#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1205#       (( RET=RET+$? ))
1206
1207    if [ ${RET} -gt 0 ] ; then
1208      echo "IGCM_sys_Get : copy error."
1209      cat out_rsync
1210#      IGCM_debug_Exit "IGCM_sys_Get"
1211    else
1212      \rm out_rsync
1213    fi
1214  else
1215    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1216  fi
1217  IGCM_debug_PopStack "IGCM_sys_Get"
1218}
1219
1220#D-#==================================================
1221#D-function IGCM_sys_GetBuffer
1222#D-* Purpose: Get a file from ${SCRATCHDIR}
1223#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1224#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1225function IGCM_sys_GetBuffer {
1226  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1227
1228  typeset DEST RET buf_liste ifile target file_work
1229
1230  if ( $DEBUG_sys ) ; then
1231    echo "IGCM_sys_GetBuffer :" $@
1232  fi
1233  if [ $DRYRUN -le 2 ]; then
1234    if [ X${1} = X'/l' ] ; then
1235      # test if the first file is present in the old computation :
1236      eval set +A buf_liste \${${2}}
1237    else
1238      eval set +A buf_liste ${1}
1239    fi
1240    eval DEST=\${${#}}
1241
1242    #USUAL WAY
1243    if [ X${1} = X'/l' ] ; then
1244      (( RET=0 ))
1245      for target in ${buf_liste[*]} ; do
1246        local_file=$( basename ${target} )
1247        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1248        (( RET = RET + $? ))
1249      done
1250    else
1251      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
1252      RET=$?
1253    fi
1254
1255    if [ ${RET} -gt 0 ] ; then
1256      echo "IGCM_sys_GetBuffer : copy error."
1257      cat out_rsync
1258      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1259    else
1260      \rm out_rsync
1261    fi
1262  else
1263    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1264  fi
1265  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1266}
1267
1268#D-#==================================================
1269#D-function IGCM_sys_GetDate_FichWork
1270#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1271#D-* Examples:
1272#D-
1273function IGCM_sys_GetDate_FichWork {
1274  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1275  if ( $DEBUG_sys ) ; then
1276    echo "IGCM_sys_GetDate_FichWork :" $@
1277  fi
1278  # donne la date filesys d'un fichier sur la machine work
1279  IGCM_debug_PopStack "IGCM_sys_FichWork"
1280}
1281
1282#D-#==================================================
1283#D-function IGCM_sys_GetDate_FichArchive
1284#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1285#D-* Examples:
1286#D-
1287function IGCM_sys_GetDate_FichArchive {
1288  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1289  if ( $DEBUG_sys ) ; then
1290    echo "IGCM_sys_GetDate_FichArchive :" $@
1291  fi
1292  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1293}
1294
1295#D-#==================================================
1296#D-function IGCM_sys_Dods_Rm
1297#D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole.
1298#D-* Examples:
1299#D-
1300function IGCM_sys_Dods_Rm {
1301  if ( $DEBUG_sys ) ; then
1302    echo "IGCM_sys_Dods_Rm :" $@
1303  fi
1304  typeset RET
1305  RET=0
1306  if [ $DRYRUN = 0 ]; then
1307    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1308      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1309      echo "Nothing has been done."
1310      return
1311    fi
1312    dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
1313    RET=$?
1314   
1315#       if [ ${RET} -gt 0 ] ; then
1316#           echo "IGCM_sys_Dods_Rm : error."
1317#           cat out_dods_rm
1318#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1319#       else
1320#           rm out_dods_rm
1321#       fi
1322
1323  else
1324    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1325  fi
1326  return $RET
1327}
1328
1329#D-#==================================================
1330#D-function IGCM_sys_Dods_Cp
1331#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1332#D-* Examples:
1333#D-
1334function IGCM_sys_Dods_Cp {
1335  if ( $DEBUG_sys ) ; then
1336    echo "IGCM_sys_Dods_Cp :" $@
1337  fi
1338  typeset RET
1339  RET=0
1340  if [ $DRYRUN = 0 ]; then
1341    if [ ! -d ${R_SAVE}/${1} ] ; then
1342      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1343      echo "Nothing has been done."
1344      return
1345    fi
1346    #
1347    dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
1348    RET=$?
1349
1350#       if [ ${RET} -gt 0 ] ; then
1351#           echo "IGCM_sys_Dods_Cp : error."
1352#           cat out_dods_cp
1353#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1354#       else
1355#           rm out_dods_cp
1356#       fi
1357
1358  else
1359    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1360  fi
1361  return $RET
1362}
1363
1364#D-#==================================================
1365#D-function IGCM_sys_Put_Dods
1366#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1367#D-* Examples:
1368#D-
1369function IGCM_sys_Put_Dods {
1370  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1371  if ( $DEBUG_sys ) ; then
1372    echo "IGCM_sys_Put_Dods :" $@
1373  fi
1374  if [ $DRYRUN = 0 ]; then
1375    if [ ! -d ${R_SAVE}/${1} ] ; then
1376      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
1377      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1378      return
1379    fi
1380
1381    typeset RET
1382        #
1383    cd ${R_SAVE}
1384    IGCM_sys_Dods_Rm ${1}
1385    IGCM_sys_Dods_Cp ${1}
1386    RET=0
1387   
1388    if [ ${RET} -gt 0 ] ; then
1389      echo "IGCM_sys_Put_Dods : error."
1390      IGCM_debug_Exit "IGCM_sys_Put_Dods"
1391    fi
1392  else
1393    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1394  fi
1395  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1396}
1397
1398##############################################################
1399# REBUILD OPERATOR
1400
1401function IGCM_sys_rebuild {
1402  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1403  if ( $DEBUG_sys ) ; then
1404    echo "IGCM_sys_rebuild :" $@
1405  fi
1406  /home/cont003/p86ipsl/X86_64/bin/rebuild -f -o $@
1407  if [ $? -gt 0 ] ; then
1408    echo "IGCM_sys_rebuild : erreur ${@}."
1409    IGCM_debug_Exit "rebuild"
1410  fi
1411
1412  IGCM_debug_PopStack "IGCM_sys_rebuild"
1413}
1414
1415##############################################################
1416# NCO OPERATOR
1417
1418function IGCM_sys_ncap2 {
1419  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1420  if ( $DEBUG_sys ) ; then
1421    echo "IGCM_sys_ncap2 :" $@
1422  fi
1423  ncap2 "$@"
1424  if [ $? -gt 0 ] ; then
1425    echo "IGCM_sys_ncap2 : erreur ${@}."
1426    IGCM_debug_Exit "ncap2"
1427  fi
1428
1429  IGCM_debug_PopStack "IGCM_sys_ncap2"
1430}
1431
1432function IGCM_sys_ncatted {
1433  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1434  if ( $DEBUG_sys ) ; then
1435    echo "IGCM_sys_ncatted :" $@
1436  fi
1437  ncatted "$@"
1438  if [ $? -gt 0 ] ; then
1439    echo "IGCM_sys_ncatted : erreur ${@}."
1440    IGCM_debug_Exit "ncatted"
1441  fi
1442
1443  IGCM_debug_PopStack "IGCM_sys_ncatted"
1444}
1445
1446function IGCM_sys_ncbo {
1447  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1448  if ( $DEBUG_sys ) ; then
1449    echo "IGCM_sys_ncbo :" $@
1450  fi
1451  ncbo $@
1452  if [ $? -gt 0 ] ; then
1453    echo "IGCM_sys_ncbo : erreur ${@}."
1454    IGCM_debug_Exit "ncbo"
1455  fi
1456
1457  IGCM_debug_PopStack "IGCM_sys_ncbo"
1458}
1459
1460function IGCM_sys_ncdiff {
1461  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1462  if ( $DEBUG_sys ) ; then
1463    echo "IGCM_sys_ncdiff :" $@
1464  fi
1465  ncdiff $@
1466  if [ $? -gt 0 ] ; then
1467    echo "IGCM_sys_ncdiff : erreur ${@}."
1468    IGCM_debug_Exit "ncdiff"
1469  fi
1470
1471  IGCM_debug_PopStack "IGCM_sys_ncdiff"
1472}
1473
1474function IGCM_sys_ncea {
1475  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1476  if ( $DEBUG_sys ) ; then
1477    echo "IGCM_sys_ncea :" $@
1478  fi
1479  ncea $@
1480  if [ $? -gt 0 ] ; then
1481    echo "IGCM_sys_ncea : erreur ${@}."
1482    IGCM_debug_Exit "ncea"
1483  fi
1484
1485  IGCM_debug_PopStack "IGCM_sys_ncea"
1486}
1487
1488function IGCM_sys_ncecat {
1489  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1490  if ( $DEBUG_sys ) ; then
1491    echo "IGCM_sys_ncecat :" $@
1492  fi
1493  ncecat $@
1494  if [ $? -gt 0 ] ; then
1495    echo "IGCM_sys_ncecat : erreur ${@}."
1496    IGCM_debug_Exit "ncecat"
1497  fi
1498
1499  IGCM_debug_PopStack "IGCM_sys_ncecat"
1500}
1501
1502function IGCM_sys_ncflint {
1503  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1504  if ( $DEBUG_sys ) ; then
1505    echo "IGCM_sys_ncflint :" $@
1506  fi
1507  ncflint $@
1508  if [ $? -gt 0 ] ; then
1509    echo "IGCM_sys_ncflint : erreur ${@}."
1510    IGCM_debug_Exit "ncflint"
1511  fi
1512
1513  IGCM_debug_PopStack "IGCM_sys_ncflint"
1514}
1515
1516function IGCM_sys_ncks {
1517  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1518  if ( $DEBUG_sys ) ; then
1519    echo "IGCM_sys_ncks :" $@
1520  fi
1521  ncks $@
1522  if [ $? -gt 0 ] ; then
1523    echo "IGCM_sys_ncks : erreur ${@}."
1524    IGCM_debug_Exit "ncks"
1525  fi
1526
1527  IGCM_debug_PopStack "IGCM_sys_ncks"
1528}
1529
1530function IGCM_sys_ncpdq {
1531  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1532  if ( $DEBUG_sys ) ; then
1533    echo "IGCM_sys_ncpdq :" $@
1534  fi
1535  ncpdq $@
1536  if [ $? -gt 0 ] ; then
1537    echo "IGCM_sys_ncpdq : erreur ${@}."
1538    IGCM_debug_Exit "ncpdq"
1539  fi
1540
1541  IGCM_debug_PopStack "IGCM_sys_ncpdq"
1542}
1543
1544function IGCM_sys_ncra {
1545  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1546  if ( $DEBUG_sys ) ; then
1547    echo "IGCM_sys_ncra :" $@
1548  fi
1549  ncra $@
1550  if [ $? -gt 0 ] ; then
1551    echo "IGCM_sys_ncra : erreur ${@}."
1552    IGCM_debug_Exit "ncra"
1553  fi
1554
1555  IGCM_debug_PopStack "IGCM_sys_ncra"
1556}
1557
1558function IGCM_sys_ncrcat {
1559  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1560  if ( $DEBUG_sys ) ; then
1561    echo "IGCM_sys_ncrcat :" $@
1562  fi
1563  ncrcat $@
1564  if [ $? -gt 0 ] ; then
1565    echo "IGCM_sys_ncrcat : erreur ${@}."
1566#       IGCM_debug_Exit "ncrcat"
1567  fi
1568
1569  IGCM_debug_PopStack "IGCM_sys_ncrcat"
1570}
1571
1572function IGCM_sys_ncrename {
1573  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1574  if ( $DEBUG_sys ) ; then
1575    echo "IGCM_sys_ncrename :" $@
1576  fi
1577  ncrename $@
1578  if [ $? -gt 0 ] ; then
1579    echo "IGCM_sys_ncrename : erreur ${@}."
1580    IGCM_debug_Exit "ncrename"
1581  fi
1582
1583  IGCM_debug_PopStack "IGCM_sys_ncrename"
1584}
1585
1586function IGCM_sys_ncwa {
1587  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1588  if ( $DEBUG_sys ) ; then
1589    echo "IGCM_sys_ncwa :" $@
1590  fi
1591  ncwa $@
1592  if [ $? -gt 0 ] ; then
1593    echo "IGCM_sys_ncwa : erreur ${@}."
1594    IGCM_debug_Exit "ncwa"
1595  fi
1596
1597  IGCM_debug_PopStack "IGCM_sys_ncwa"
1598}
1599
1600##############################################################
1601# CDO OPERATOR
1602
1603function IGCM_sys_cdo {
1604  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1605  if ( $DEBUG_sys ) ; then
1606    echo "IGCM_sys_cdo :" $@
1607  fi
1608  \cdo $@
1609  if [ $? -gt 0 ] ; then
1610    echo "IGCM_sys_cdo : erreur ${@}."
1611    IGCM_debug_PopStack "IGCM_sys_cdo"
1612    return 1
1613  else
1614    IGCM_debug_PopStack "IGCM_sys_cdo"
1615    return 0
1616  fi
1617
1618  IGCM_debug_PopStack "IGCM_sys_cdo"
1619}
1620
1621############################################################
1622# Activate Running Environnment Variables
1623
1624function IGCM_sys_activ_variables {
1625  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1626  if ( $DEBUG_sys ) ; then
1627    echo "IGCM_sys_activ_variables"
1628  fi
1629  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1630}
1631
1632############################################################
1633# Desactivate Running Environnment Variables
1634
1635function IGCM_sys_desactiv_variables {
1636  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1637  if ( $DEBUG_sys ) ; then
1638    echo "IGCM_sys_desactiv_variables"
1639  fi
1640  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1641}
1642
1643############################################################
1644# Build run file
1645
1646function IGCM_sys_build_run_file {
1647  IGCM_debug_PushStack "IGCM_sys_build_run_file"
1648  if ( $DEBUG_sys ) ; then
1649    echo "IGCM_sys_build_run_file"
1650  fi
1651  IGCM_debug_PopStack "IGCM_sys_build_run_file"
1652}
Note: See TracBrowser for help on using the repository browser.