source: branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_mercure.ksh @ 571

Last change on this file since 571 was 571, checked in by mafoipsl, 12 years ago

First try to merge libIGCM_MPI_OpenMP branch with libIGCM trunk revision 569. Tested on vargas with PackFrequency?=NONE included into config.card.

  • Property svn:keywords set to Revision Author Date
File size: 44.3 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:=/ccc/work/cont003/dsm/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_IsFileArchived
398#D-* Purpose: Test file that must NOT EXISTS on Archive
399#D-* Examples:
400#D-
401function IGCM_sys_IsFileArchived {
402  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
403  if ( $DEBUG_sys ) ; then
404    echo "IGCM_sys_IsFileArchived :" $@
405  fi
406  typeset IsArchivedFlag
407  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/dmnfs ) != X ] && echo 0 || echo 1 )
408  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
409
410  return ${IsArchivedFlag}
411}
412
413#D-#==================================================
414#D-function IGCM_sys_TestFileArchive
415#D-* Purpose: Test file that must NOT EXISTS on Archive
416#D-* Examples:
417#D-
418function IGCM_sys_TestFileArchive {
419  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
420  if ( $DEBUG_sys ) ; then
421    echo "IGCM_sys_TestFileArchive :" $@
422  fi
423  typeset ExistFlag
424  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
425  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
426
427  return ${ExistFlag}
428}
429
430#D-#==================================================
431#D-function IGCM_sys_TestFileBuffer
432#D-* Purpose: Test file that must NOT EXISTS on Buffer
433#D-* Examples:
434#D-
435function IGCM_sys_TestFileBuffer {
436  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
437  typeset ExistFlag
438  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
439  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
440
441  return ${ExistFlag}
442}
443
444#D-#==================================================
445#D-function IGCM_sys_CountFileArchive
446#D-* Purpose: Count files on Archive filesystem
447#D-* Examples:
448#D-
449function IGCM_sys_CountFileArchive {
450  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
451  ls ${@} 2>/dev/null | wc -l
452  if [ $? -gt 0 ] ; then
453    echo "IGCM_sys_CountFileArchive : erreur."
454  fi
455  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
456}
457
458#D-#==================================================
459#D-function IGCM_sys_CountFileBuffer
460#D-* Purpose: Count files on Scratch filesystem
461#D-* Examples:
462#D-
463function IGCM_sys_CountFileBuffer {
464  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
465  ls ${@} 2>/dev/null | wc -l
466  if [ $? -gt 0 ] ; then
467    echo "IGCM_sys_CountFileBuffer : erreur."
468  fi
469  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
470}
471
472#D-#==================================================
473#D-function IGCM_sys_Tree
474#D-* Purpose: Tree directories with files on ${ARCHIVE}
475#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
476#D-
477function IGCM_sys_Tree {
478  IGCM_debug_PushStack "IGCM_sys_Tree" $@
479  if ( $DEBUG_sys ) ; then
480    echo "IGCM_sys_Tree :" $@
481  fi
482
483  \tree -f $@
484
485  IGCM_debug_PopStack "IGCM_sys_Tree"
486}
487
488#D-#==================================================
489#D-function IGCM_sys_Tar
490#D-* Purpose: master tar command
491#D-* Examples:
492#D-
493function IGCM_sys_Tar {
494  IGCM_debug_PushStack "IGCM_sys_Tar" $@
495  if ( $DEBUG_sys ) ; then
496    echo "IGCM_sys_Tar :" $@
497  fi
498  \tar cf $@
499  if [ $? -gt 0 ] ; then
500    echo "IGCM_sys_Tar : erreur."
501    IGCM_debug_Exit "IGCM_sys_Tar"
502  fi
503  IGCM_debug_PopStack "IGCM_sys_Tar"
504}
505
506#D-#==================================================
507#D-function IGCM_sys_UnTar
508#D-* Purpose: master un-tar command
509#D-* Examples:
510#D-
511function IGCM_sys_UnTar {
512  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
513  if ( $DEBUG_sys ) ; then
514    echo "IGCM_sys_UnTar :" $@
515  fi
516  \tar xvf $1
517  if [ $? -gt 0 ] ; then
518    echo "IGCM_sys_UnTar : erreur."
519    IGCM_debug_Exit "IGCM_sys_UnTar"
520  fi
521  IGCM_debug_PopStack "IGCM_sys_UnTar"
522}
523
524#D-#==================================================
525#D-function IGCM_sys_QsubPost
526#D-* Purpose: Qsub new job on scalaire
527#D-* Examples:
528#D-
529function IGCM_sys_QsubPost {
530  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
531  if ( $DEBUG_sys ) ; then
532    echo "IGCM_sys_QsubPost :" $@
533  fi
534  /usr/bin/nqsII/qsub -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv}
535  if [ $? -gt 0 ] ; then
536    echo "IGCM_sys_QsubPost : erreur " $@
537    IGCM_debug_Exit "IGCM_sys_QsubPost"
538  fi
539  IGCM_debug_PopStack "IGCM_sys_QsubPost"
540}
541
542#D-*************************
543#D- File transfer functions
544#D-*************************
545#D-
546
547#D-#==================================================
548#D-function IGCM_sys_Rsync_out
549#D-* Purpose: treat return val of rsync
550#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
551#D-  Error values and explanations can depend on your system version.
552function IGCM_sys_Rsync_out {
553  RET=$1
554  if [ ! $RET ] ; then
555    echo "rsync error !"
556  fi
557
558  if [ $MYLANG = "fr" ]; then
559    case $RET in
560    0)  return ;;
561    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
562      echo "Erreur de syntaxe ou d'utilisation."
563      return;;
564    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
565      echo "Incompatibilité de protocole."
566      return;;
567    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
568      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
569      echo "répertoires"
570      return;;
571    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
572      echo "Action demandée non supportée : une tentative de manipulation de"
573      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
574      echo "été faite ; ou une option qui est supportée par le  client  mais"
575      echo "pas par le serveur a été spécifiée."
576      return;;
577    10) echo "Erreur de rsync ; RERR_SOCKETIO"
578      echo "Erreur dans le socket d'entrée sortie"
579      return;;
580    11) echo "Erreur de rsync ; RERR_FILEIO"
581      echo "Erreur d'entrée sortie fichier"
582      return;;
583    12) echo "Erreur de rsync ; RERR_STREAMIO"
584      echo "Erreur dans flux de donnée du protocole rsync"
585      return;;
586    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
587      echo "Erreur avec les diagnostics du programme"
588      return;;
589    14) echo "Erreur de rsync ; RERR_IPC"
590      echo "Erreur dans le code IPC"
591      return;;
592    20) echo "Erreur de rsync ; RERR_SIGNAL"
593      echo "SIGUSR1 ou SIGINT reçu"
594      return;;
595    21) echo "Erreur de rsync ; RERR_WAITCHILD"
596      echo "Une erreur retournée par waitpid()"
597      return;;
598    22) echo "Erreur de rsync ; RERR_MALLOC"
599      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
600      return;;
601    23) echo ""
602      echo "Erreur fichier inexistant"
603      return;;
604    30) echo "Erreur de rsync ; RERR_TIMEOUT"
605      echo "Temps d'attente écoulé dans l'envoi/réception de données"
606      return;;
607    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
608      return;;
609    esac
610  elif [ $MYLANG = "en" ] ; then
611    case $RET in
612    0)  return;;               
613    1)  echo "rsync error : Syntax or usage error "
614      return;;
615    2)  echo "rsync error : Protocol incompatibility "
616      return;;
617    3)  echo "rsync error : Errors selecting input/output files, dirs"
618      return;;
619    4)  echo "rsync error : Requested action not supported: an attempt"
620      echo "was made to manipulate 64-bit files on a platform that cannot support"
621      echo "them; or an option was specified that is supported by the client and"
622      echo "not by the server."
623      return;;
624    5)  echo "rsync error : Error starting client-server protocol"
625      return;;
626    10) echo "rsync error : Error in socket I/O "
627      return;;
628    11) echo "rsync error : Error in file I/O "
629      return;;
630    12) echo "rsync error : Error in rsync protocol data stream "
631      return;;
632    13) echo "rsync error : Errors with program diagnostics "
633      return;;
634    14) echo "rsync error : Error in IPC code "
635      return;;
636    20) echo "rsync error : Received SIGUSR1 or SIGINT "
637      return;;
638    21) echo "rsync error : Some error returned by waitpid() "
639      return;;
640    22) echo "rsync error : Error allocating core memory buffers "
641      return;;
642    23) echo "rsync error : Partial transfer due to error"
643      return;;
644    24) echo "rsync error : Partial transfer due to vanished source files"
645      return;;
646    30) echo "rsync error : Timeout in data send/receive "
647      return;;
648    *)  echo "rsync error : return code of rsync unknown :" $RET
649      return;;
650    esac
651  else
652    echo "unknown language $MYLANG."
653    return
654  fi
655}
656
657#D-#==================================================
658#D-function IGCM_sys_Cp
659#D-* Purpose: generic cp
660#D-* Examples:
661#D-
662function IGCM_sys_Cp {
663  IGCM_debug_PushStack "IGCM_sys_Cp" $@
664  if ( $DEBUG_sys ) ; then
665    echo "IGCM_sys_Cp :" $@
666  fi
667
668  typeset RET
669
670  echo cp $@ > out_rsync 2>&1
671  \cp $@ >> out_rsync 2>&1
672  RET=$?
673
674  if [ ${RET} -gt 0 ] ; then
675    echo "IGCM_sys_Cp : error."
676    cat out_rsync
677    IGCM_debug_Exit "IGCM_sys_Cp"
678  else
679    \rm out_rsync
680  fi
681  IGCM_debug_PopStack "IGCM_sys_Cp"
682}
683
684#D-#==================================================
685#D-function IGCM_sys_Rm
686#D-* Purpose: generic rm
687#D-* Examples:
688#D-
689function IGCM_sys_Rm {
690  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
691  if ( $DEBUG_sys ) ; then
692    echo "IGCM_sys_Rm :" $@
693  fi
694
695  typeset RET
696
697  echo rm $@ > out_rsync 2>&1
698  \rm $@ >> out_rsync 2>&1
699  RET=$?
700
701  if [ ${RET} -gt 0 ] ; then
702    echo "IGCM_sys_Rm : error."
703    cat out_rsync
704    IGCM_debug_Exit "IGCM_sys_Rm"
705  else
706    \rm out_rsync
707  fi
708  IGCM_debug_PopStack "IGCM_sys_Rm"
709}
710
711#D-#==================================================
712#D-function IGCM_sys_RmRunDir
713#D-* Purpose: rm tmpdir (dummy function most of the time batch
714#D-                      scheduler will do the job)
715#D-* Examples:
716#D-
717function IGCM_sys_RmRunDir {
718  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
719  if ( $DEBUG_sys ) ; then
720    echo "IGCM_sys_RmRunDir :" $@
721  fi
722
723  typeset RET
724
725  echo rm $@ > out_rsync 2>&1
726  \rm $@ >> out_rsync 2>&1
727  RET=$?
728
729  if [ ${RET} -gt 0 ] ; then
730    echo "IGCM_sys_RmRunDir : error."
731    cat out_rsync
732    IGCM_debug_Exit "IGCM_sys_RmRunDir"
733  else
734    \rm out_rsync
735  fi
736  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
737}
738
739#D-#==================================================
740#D-function IGCM_sys_Mv
741#D-* Purpose: generic move
742#D-* Examples:
743#D-
744function IGCM_sys_Mv {
745  IGCM_debug_PushStack "IGCM_sys_Mv" $@
746  if ( $DEBUG_sys ) ; then
747    echo "IGCM_sys_Mv :" $@
748  fi
749
750  if [ $DRYRUN = 0 ]; then
751
752    typeset RET
753   
754    echo mv $@ > out_rsync 2>&1
755    \mv $@ >> out_rsync 2>&1
756    RET=$?
757   
758    if [ ${RET} -gt 0 ] ; then
759      echo "IGCM_sys_Mv : error in mv."
760      cat out_rsync
761      IGCM_debug_Exit "IGCM_sys_Mv"
762    else
763      \rm out_rsync
764    fi
765  else
766    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
767  fi
768
769  IGCM_debug_PopStack "IGCM_sys_Mv"
770}
771
772#D-#==================================================
773#D-function IGCM_sys_Put_Dir
774#D-* Purpose: Copy a complete directory on $(ARCHIVE)
775#D-* Examples:
776#D-
777function IGCM_sys_Put_Dir {
778  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
779  if ( $DEBUG_sys ) ; then
780    echo "IGCM_sys_Put_Dir :" $@
781  fi
782  if [ $DRYRUN = 0 ]; then
783    if [ ! -d ${1} ] ; then
784      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
785      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
786      return
787    fi
788
789    typeset RET
790
791    # Only if we use rsync
792    #IGCM_sys_TestDirArchive $( dirname $2 )
793    #
794    #USUAL WAY
795    \cp -r $1 $2 > out_rsync 2>&1
796    RET=$?
797
798    if [ ${RET} -gt 0 ] ; then
799      echo "IGCM_sys_Put_Dir : error."
800      cat out_rsync
801      IGCM_debug_Exit "IGCM_sys_Put_Dir"
802    else
803      \rm out_rsync
804    fi
805  else
806    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
807  fi
808  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
809}
810
811#D-#==================================================
812#D-function IGCM_sys_Get_Dir
813#D-* Purpose: Copy a complete directory from $(ARCHIVE)
814#D-* Examples:
815#D-
816function IGCM_sys_Get_Dir {
817  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
818  if ( $DEBUG_sys ) ; then
819    echo "IGCM_sys_Get_Dir :" $@
820  fi
821  if [ $DRYRUN = 0 ]; then
822#       if [ ! -d ${1} ] ; then
823#           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
824#           IGCM_debug_PopStack "IGCM_sys_Get_Dir"
825#           return
826#       fi
827
828    typeset RET
829
830    # Only if we use rsync
831    #IGCM_sys_TestDirArchive $( dirname $2 )
832    #
833    #USUAL WAY
834    # add dmget (to demigrate all offline files) to reduce time of this command :
835    dmget $1/*
836    \cp -r $1 $2 > out_rsync 2>&1
837    RET=$?
838
839    if [ ${RET} -gt 0 ] ; then
840      echo "IGCM_sys_Get_Dir : error."
841      cat out_rsync
842      IGCM_debug_Exit "IGCM_sys_Get_Dir"
843    else
844      \rm out_rsync
845    fi
846  else
847    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
848  fi
849  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
850}
851
852#D-#==================================================
853#D-function IGCM_sys_Get_Master
854#D-* Purpose: Copy a complete directory from MASTER filesystem
855#D-* Examples:
856#D-
857function IGCM_sys_Get_Master {
858  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
859  if ( $DEBUG_sys ) ; then
860    echo "IGCM_sys_Get_Master :" $@
861  fi
862  if [ $DRYRUN = 0 ]; then
863    if [ ! -d ${1} ] ; then
864      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
865      IGCM_debug_PopStack "IGCM_sys_Get_Master"
866      return
867    fi
868
869    typeset RET
870
871    #USUAL WAY
872    \cp -r $1 $2 > out_rsync 2>&1
873    RET=$?
874
875    if [ ${RET} -gt 0 ] ; then
876      echo "IGCM_sys_Get_Master : error."
877      cat out_rsync
878      IGCM_debug_Exit "IGCM_sys_Get_Master"
879    else
880      \rm out_rsync
881    fi
882  else
883    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
884  fi
885  IGCM_debug_PopStack "IGCM_sys_Get_Master"
886}
887
888#D-#==================================================
889#D-function IGCM_sys_Put_Rest
890#D-* Purpose: Put computied restarts on ${ARCHIVE}.
891#D-           File and target directory must exist.
892#D-* Examples:
893#D-
894function IGCM_sys_Put_Rest {
895  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
896  if ( $DEBUG_sys ) ; then
897    echo "IGCM_sys_Put_Rest :" $@
898  fi
899  if [ $DRYRUN = 0 ]; then
900    if [ ! -f ${1} ] ; then
901      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
902      IGCM_debug_Exit "IGCM_sys_Put_Rest"
903    fi
904
905    typeset RET
906    #
907    if [ X${JobType} = XRUN ] ; then
908      IGCM_sys_Chmod 444 ${1}
909    fi
910
911    #
912    # USUAL WAY
913    \cp $1 $2 > out_rsync 2>&1
914    RET=$?
915
916#       #RSYNC WITH NETWORK SSH CALL
917#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
918#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
919
920#       #RSYNC WITH NFS USE
921#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
922#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
923
924#       RET=$?
925#       IGCM_sys_Rsync_out $RET
926
927#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
928#       (( RET=RET+$? ))
929
930    if [ ${RET} -gt 0 ] ; then
931      echo "IGCM_sys_Put_Rest : error."
932      cat out_rsync
933      IGCM_debug_Exit "IGCM_sys_Put_Rest"
934    else
935      \rm out_rsync
936    fi
937  else
938    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
939  fi
940  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
941}
942
943#D-#==================================================
944#D-function IGCM_sys_PutBuffer_Rest
945#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
946#D-           File and target directory must exist.
947#D-* Examples:
948#D-
949function IGCM_sys_PutBuffer_Rest {
950  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
951  if ( $DEBUG_sys ) ; then
952    echo "IGCM_sys_PutBuffer_Rest :" $@
953  fi
954  if [ $DRYRUN = 0 ]; then
955    if [ ! -f ${1} ] ; then
956      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
957      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
958    fi
959
960    typeset RET
961    #
962    if [ X${JobType} = XRUN ] ; then
963      IGCM_sys_Chmod 444 ${1}
964    fi
965
966    #
967    # USUAL WAY
968    \cp $1 $2 > out_rsync 2>&1
969    RET=$?
970
971    if [ ${RET} -gt 0 ] ; then
972      echo "IGCM_sys_PutBuffer_Rest : error."
973      cat out_rsync
974      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
975    else
976      \rm out_rsync
977    fi
978  else
979    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
980  fi
981  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
982}
983
984#D-#==================================================
985#D-function IGCM_sys_Put_Out
986#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
987#D-* Examples:
988#D-
989function IGCM_sys_Put_Out {
990  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
991  if ( $DEBUG_sys ) ; then
992    echo "IGCM_sys_Put_Out :" $@
993  fi
994  if [ $DRYRUN = 0 ]; then
995    if [ ! -f ${1} ] ; then
996      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
997      IGCM_debug_PopStack "IGCM_sys_Put_Out"
998      return 1
999    fi
1000    #
1001    IGCM_sys_MkdirArchive $( dirname $2 )
1002    #
1003    typeset RET exist skip
1004
1005    #=====================================================
1006    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1007    #=====================================================
1008
1009    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
1010    #if [ $? -eq 0 ] ; then
1011    #    typeset WORKPATH FILEPATH
1012    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" )
1013    #    IGCM_sys_MkdirWork ${WORKPATH}
1014    #    FILEPATH=${WORKPATH}/$( basename $2 )
1015    #    #
1016    #    IGCM_sys_Cp ${1} ${FILEPATH}
1017    #fi
1018
1019    if [ X${JobType} = XRUN ] ; then
1020      if [ X${3} = X ] ; then
1021        IGCM_sys_Chmod 444 ${1}
1022      fi
1023    fi
1024
1025    exist=false
1026    skip=false
1027    if [ -f $2 ] ; then
1028      IGCM_debug_Print 1 "$2 already exist"
1029      dmget $2
1030      exist=true
1031      if [ "X$( diff $1 $2 )" = X ] ; then
1032        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
1033        skip=true
1034      else
1035        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
1036        skip=false
1037      fi
1038    fi
1039    #
1040    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
1041      IGCM_sys_Chmod u+w $2
1042    fi
1043    # USUAL WAY
1044    if [ X${skip} = Xfalse ] ; then
1045      \cp $1 $2 > out_rsync 2>&1
1046      RET=$?
1047      if [ ${RET} -gt 0 ] ; then
1048        echo "IGCM_sys_Put_Out : error."
1049        cat out_rsync
1050        IGCM_debug_Exit "IGCM_sys_Put_Out"
1051      else
1052        \rm out_rsync
1053      fi
1054    fi
1055
1056#       #RSYNC WITH NETWORK SSH CALL
1057#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1058#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1059
1060#       #RSYNC WITH NFS USE
1061#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1062#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1063
1064#       RET=$?
1065#       IGCM_sys_Rsync_out $RET
1066
1067#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1068#       (( RET=RET+$? ))
1069
1070  else
1071    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1072  fi
1073  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1074  return 0
1075}
1076
1077#D-#==================================================
1078#D-function IGCM_sys_PutBuffer_Out
1079#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1080#D-* Examples:
1081#D-
1082function IGCM_sys_PutBuffer_Out {
1083  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1084  if ( $DEBUG_sys ) ; then
1085    echo "IGCM_sys_PutBuffer_Out :" $@
1086  fi
1087  if [ $DRYRUN = 0 ]; then
1088    if [ ! -f ${1} ] ; then
1089      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1090      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1091      return 1
1092    fi
1093    #
1094    IGCM_sys_Mkdir $( dirname $2 )
1095    #
1096    typeset RET
1097
1098    if [ X${JobType} = XRUN ] ; then
1099      if [ X${3} = X ] ; then
1100        IGCM_sys_Chmod 444 ${1}
1101      fi
1102    fi
1103    #
1104    # USUAL WAY
1105    \cp $1 $2 > out_rsync 2>&1
1106    RET=$?
1107
1108    if [ ${RET} -gt 0 ] ; then
1109      echo "IGCM_sys_PutBuffer_Out : error."
1110      cat out_rsync
1111      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1112    else
1113      \rm out_rsync
1114    fi
1115  else
1116    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1117  fi
1118  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1119  return 0
1120}
1121
1122#D-#==================================================
1123#D-function IGCM_sys_Get
1124#D-* Purpose: Get a file from ${ARCHIVE}
1125#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1126#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1127function IGCM_sys_Get {
1128  IGCM_debug_PushStack "IGCM_sys_Get" $@
1129
1130  typeset DEST RET dm_liste ifile target file_work
1131
1132  if ( $DEBUG_sys ) ; then
1133    echo "IGCM_sys_Get :" $@
1134  fi
1135  if [ $DRYRUN -le 2 ]; then
1136    if [ X${1} = X'/l' ] ; then
1137      # test if the first file is present in the old computation :
1138      eval set +A dm_liste \${${2}}
1139    else
1140      eval set +A dm_liste ${1}
1141    fi
1142    eval DEST=\${${#}}
1143
1144    #=====================================================
1145    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1146    #=====================================================
1147
1148    # Is it an R_OUT file (not R_IN) ?
1149    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1150    #if [ $? -eq 0 ] ; then
1151    #    # Yes  ? then we try to get it in SCRATCHDIR
1152    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" )
1153    #    if [ -f ${file_work[0]} ] ; then
1154    #   IGCM_sys_Cp ${file_work[*]} ${DEST}
1155    #   IGCM_debug_PopStack "IGCM_sys_Get"
1156    #   return
1157    #    fi
1158    #fi
1159
1160    # test if the (first) file is present in the old computation :
1161    IGCM_sys_TestFileArchive ${dm_liste[0]}
1162    RET=$?
1163    if [ ${RET} -gt 0 ] ; then
1164      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1165      IGCM_debug_Exit "IGCM_sys_Get"
1166    fi
1167
1168    dmget ${dm_liste[*]} > out_rsync 2>&1
1169    RET=$?
1170    if [ ${RET} -gt 0 ] ; then
1171      echo "WARNING IGCM_sys_Get : demigration error."
1172      cat out_rsync
1173      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
1174    fi
1175
1176    #if [ ${RET} -gt 0 ] ; then
1177    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
1178    #   cat out_rsync
1179    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
1180    #   sleep 30
1181    #   echo "We try another time"
1182    #   dmget ${dm_liste[*]} > out_rsync 2>&1
1183    #   RET=$?
1184    #   if [ ${RET} -gt 0 ] ; then
1185    #       echo "ERROR IGCM_sys_Get : again demigration error :"
1186    #       cat out_rsync
1187    #       IGCM_debug_Exit "IGCM_sys_Get"
1188    #   fi
1189    #    else
1190    #   echo "ERROR IGCM_sys_Get : demigration error :"
1191    #   cat out_rsync
1192    #   IGCM_debug_Exit "IGCM_sys_Get"
1193    #    fi
1194    #fi
1195
1196    #USUAL WAY
1197    if [ X${1} = X'/l' ] ; then
1198      (( RET=0 ))
1199      for target in ${dm_liste[*]} ; do
1200        local_file=$( basename ${target} )
1201        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1202        (( RET = RET + $? ))
1203      done
1204    else
1205      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1206      RET=$?
1207    fi
1208
1209#       #RSYNC WITH NETWORK SSH CALL
1210#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1211#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1212
1213#       #RSYNC WITH NFS USE
1214#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1215#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1216
1217#       RET=$?
1218#       IGCM_sys_Rsync_out $RET
1219
1220#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1221#       (( RET=RET+$? ))
1222
1223    if [ ${RET} -gt 0 ] ; then
1224      echo "IGCM_sys_Get : copy error."
1225      cat out_rsync
1226#      IGCM_debug_Exit "IGCM_sys_Get"
1227    else
1228      \rm out_rsync
1229    fi
1230  else
1231    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1232  fi
1233  IGCM_debug_PopStack "IGCM_sys_Get"
1234}
1235
1236#D-#==================================================
1237#D-function IGCM_sys_GetBuffer
1238#D-* Purpose: Get a file from ${SCRATCHDIR}
1239#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1240#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1241function IGCM_sys_GetBuffer {
1242  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1243
1244  typeset DEST RET buf_liste ifile target file_work
1245
1246  if ( $DEBUG_sys ) ; then
1247    echo "IGCM_sys_GetBuffer :" $@
1248  fi
1249  if [ $DRYRUN -le 2 ]; then
1250    if [ X${1} = X'/l' ] ; then
1251      # test if the first file is present in the old computation :
1252      eval set +A buf_liste \${${2}}
1253    else
1254      eval set +A buf_liste ${1}
1255    fi
1256    eval DEST=\${${#}}
1257
1258    #USUAL WAY
1259    if [ X${1} = X'/l' ] ; then
1260      (( RET=0 ))
1261      for target in ${buf_liste[*]} ; do
1262        local_file=$( basename ${target} )
1263        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1264        (( RET = RET + $? ))
1265      done
1266    else
1267      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
1268      RET=$?
1269    fi
1270
1271    if [ ${RET} -gt 0 ] ; then
1272      echo "IGCM_sys_GetBuffer : copy error."
1273      cat out_rsync
1274      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1275    else
1276      \rm out_rsync
1277    fi
1278  else
1279    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1280  fi
1281  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1282}
1283
1284#D-#==================================================
1285#D-function IGCM_sys_GetDate_FichWork
1286#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1287#D-* Examples:
1288#D-
1289function IGCM_sys_GetDate_FichWork {
1290  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1291  if ( $DEBUG_sys ) ; then
1292    echo "IGCM_sys_GetDate_FichWork :" $@
1293  fi
1294  # donne la date filesys d'un fichier sur la machine work
1295  IGCM_debug_PopStack "IGCM_sys_FichWork"
1296}
1297
1298#D-#==================================================
1299#D-function IGCM_sys_GetDate_FichArchive
1300#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1301#D-* Examples:
1302#D-
1303function IGCM_sys_GetDate_FichArchive {
1304  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1305  if ( $DEBUG_sys ) ; then
1306    echo "IGCM_sys_GetDate_FichArchive :" $@
1307  fi
1308  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1309}
1310
1311#D-#==================================================
1312#D-function IGCM_sys_Dods_Rm
1313#D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole.
1314#D-* Examples:
1315#D-
1316function IGCM_sys_Dods_Rm {
1317  if ( $DEBUG_sys ) ; then
1318    echo "IGCM_sys_Dods_Rm :" $@
1319  fi
1320  typeset RET
1321  RET=0
1322  if [ $DRYRUN = 0 ]; then
1323    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1324      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1325      echo "Nothing has been done."
1326      return
1327    fi
1328    dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
1329    RET=$?
1330   
1331#       if [ ${RET} -gt 0 ] ; then
1332#           echo "IGCM_sys_Dods_Rm : error."
1333#           cat out_dods_rm
1334#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1335#       else
1336#           rm out_dods_rm
1337#       fi
1338
1339  else
1340    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1341  fi
1342  return $RET
1343}
1344
1345#D-#==================================================
1346#D-function IGCM_sys_Dods_Cp
1347#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1348#D-* Examples:
1349#D-
1350function IGCM_sys_Dods_Cp {
1351  if ( $DEBUG_sys ) ; then
1352    echo "IGCM_sys_Dods_Cp :" $@
1353  fi
1354  typeset RET
1355  RET=0
1356  if [ $DRYRUN = 0 ]; then
1357    if [ ! -d ${R_SAVE}/${1} ] ; then
1358      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1359      echo "Nothing has been done."
1360      return
1361    fi
1362    #
1363    dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
1364    RET=$?
1365
1366#       if [ ${RET} -gt 0 ] ; then
1367#           echo "IGCM_sys_Dods_Cp : error."
1368#           cat out_dods_cp
1369#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1370#       else
1371#           rm out_dods_cp
1372#       fi
1373
1374  else
1375    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1376  fi
1377  return $RET
1378}
1379
1380#D-#==================================================
1381#D-function IGCM_sys_Put_Dods
1382#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1383#D-* Examples:
1384#D-
1385function IGCM_sys_Put_Dods {
1386  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1387  if ( $DEBUG_sys ) ; then
1388    echo "IGCM_sys_Put_Dods :" $@
1389  fi
1390  if [ $DRYRUN = 0 ]; then
1391    if [ ! -d ${R_SAVE}/${1} ] ; then
1392      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
1393      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1394      return
1395    fi
1396
1397    typeset RET
1398        #
1399    cd ${R_SAVE}
1400    IGCM_sys_Dods_Rm ${1}
1401    IGCM_sys_Dods_Cp ${1}
1402    RET=0
1403   
1404    if [ ${RET} -gt 0 ] ; then
1405      echo "IGCM_sys_Put_Dods : error."
1406      IGCM_debug_Exit "IGCM_sys_Put_Dods"
1407    fi
1408  else
1409    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1410  fi
1411  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1412}
1413
1414##############################################################
1415# REBUILD OPERATOR
1416
1417function IGCM_sys_rebuild {
1418  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1419  if ( $DEBUG_sys ) ; then
1420    echo "IGCM_sys_rebuild :" $@
1421  fi
1422  /home/cont003/p86ipsl/X86_64/bin/rebuild -f -o $@
1423  if [ $? -gt 0 ] ; then
1424    echo "IGCM_sys_rebuild : erreur ${@}."
1425    IGCM_debug_Exit "rebuild"
1426  fi
1427
1428  IGCM_debug_PopStack "IGCM_sys_rebuild"
1429}
1430
1431##############################################################
1432# NCO OPERATOR
1433
1434function IGCM_sys_ncap2 {
1435  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1436  if ( $DEBUG_sys ) ; then
1437    echo "IGCM_sys_ncap2 :" $@
1438  fi
1439  ncap2 "$@"
1440  if [ $? -gt 0 ] ; then
1441    echo "IGCM_sys_ncap2 : erreur ${@}."
1442    IGCM_debug_Exit "ncap2"
1443  fi
1444
1445  IGCM_debug_PopStack "IGCM_sys_ncap2"
1446}
1447
1448function IGCM_sys_ncatted {
1449  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1450  if ( $DEBUG_sys ) ; then
1451    echo "IGCM_sys_ncatted :" $@
1452  fi
1453  ncatted "$@"
1454  if [ $? -gt 0 ] ; then
1455    echo "IGCM_sys_ncatted : erreur ${@}."
1456    IGCM_debug_Exit "ncatted"
1457  fi
1458
1459  IGCM_debug_PopStack "IGCM_sys_ncatted"
1460}
1461
1462function IGCM_sys_ncbo {
1463  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1464  if ( $DEBUG_sys ) ; then
1465    echo "IGCM_sys_ncbo :" $@
1466  fi
1467  ncbo $@
1468  if [ $? -gt 0 ] ; then
1469    echo "IGCM_sys_ncbo : erreur ${@}."
1470    IGCM_debug_Exit "ncbo"
1471  fi
1472
1473  IGCM_debug_PopStack "IGCM_sys_ncbo"
1474}
1475
1476function IGCM_sys_ncdiff {
1477  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1478  if ( $DEBUG_sys ) ; then
1479    echo "IGCM_sys_ncdiff :" $@
1480  fi
1481  ncdiff $@
1482  if [ $? -gt 0 ] ; then
1483    echo "IGCM_sys_ncdiff : erreur ${@}."
1484    IGCM_debug_Exit "ncdiff"
1485  fi
1486
1487  IGCM_debug_PopStack "IGCM_sys_ncdiff"
1488}
1489
1490function IGCM_sys_ncea {
1491  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1492  if ( $DEBUG_sys ) ; then
1493    echo "IGCM_sys_ncea :" $@
1494  fi
1495  ncea $@
1496  if [ $? -gt 0 ] ; then
1497    echo "IGCM_sys_ncea : erreur ${@}."
1498    IGCM_debug_Exit "ncea"
1499  fi
1500
1501  IGCM_debug_PopStack "IGCM_sys_ncea"
1502}
1503
1504function IGCM_sys_ncecat {
1505  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1506  if ( $DEBUG_sys ) ; then
1507    echo "IGCM_sys_ncecat :" $@
1508  fi
1509  ncecat $@
1510  if [ $? -gt 0 ] ; then
1511    echo "IGCM_sys_ncecat : erreur ${@}."
1512    IGCM_debug_Exit "ncecat"
1513  fi
1514
1515  IGCM_debug_PopStack "IGCM_sys_ncecat"
1516}
1517
1518function IGCM_sys_ncflint {
1519  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1520  if ( $DEBUG_sys ) ; then
1521    echo "IGCM_sys_ncflint :" $@
1522  fi
1523  ncflint $@
1524  if [ $? -gt 0 ] ; then
1525    echo "IGCM_sys_ncflint : erreur ${@}."
1526    IGCM_debug_Exit "ncflint"
1527  fi
1528
1529  IGCM_debug_PopStack "IGCM_sys_ncflint"
1530}
1531
1532function IGCM_sys_ncks {
1533  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1534  if ( $DEBUG_sys ) ; then
1535    echo "IGCM_sys_ncks :" $@
1536  fi
1537  ncks $@
1538  if [ $? -gt 0 ] ; then
1539    echo "IGCM_sys_ncks : erreur ${@}."
1540    IGCM_debug_Exit "ncks"
1541  fi
1542
1543  IGCM_debug_PopStack "IGCM_sys_ncks"
1544}
1545
1546function IGCM_sys_ncpdq {
1547  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1548  if ( $DEBUG_sys ) ; then
1549    echo "IGCM_sys_ncpdq :" $@
1550  fi
1551  ncpdq $@
1552  if [ $? -gt 0 ] ; then
1553    echo "IGCM_sys_ncpdq : erreur ${@}."
1554    IGCM_debug_Exit "ncpdq"
1555  fi
1556
1557  IGCM_debug_PopStack "IGCM_sys_ncpdq"
1558}
1559
1560function IGCM_sys_ncra {
1561  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1562  if ( $DEBUG_sys ) ; then
1563    echo "IGCM_sys_ncra :" $@
1564  fi
1565  ncra $@
1566  if [ $? -gt 0 ] ; then
1567    echo "IGCM_sys_ncra : erreur ${@}."
1568    IGCM_debug_Exit "ncra"
1569  fi
1570
1571  IGCM_debug_PopStack "IGCM_sys_ncra"
1572}
1573
1574function IGCM_sys_ncrcat {
1575  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1576  if ( $DEBUG_sys ) ; then
1577    echo "IGCM_sys_ncrcat :" $@
1578  fi
1579  ncrcat $@
1580  if [ $? -gt 0 ] ; then
1581    echo "IGCM_sys_ncrcat : erreur ${@}."
1582#       IGCM_debug_Exit "ncrcat"
1583  fi
1584
1585  IGCM_debug_PopStack "IGCM_sys_ncrcat"
1586}
1587
1588function IGCM_sys_ncrename {
1589  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1590  if ( $DEBUG_sys ) ; then
1591    echo "IGCM_sys_ncrename :" $@
1592  fi
1593  ncrename $@
1594  if [ $? -gt 0 ] ; then
1595    echo "IGCM_sys_ncrename : erreur ${@}."
1596    IGCM_debug_Exit "ncrename"
1597  fi
1598
1599  IGCM_debug_PopStack "IGCM_sys_ncrename"
1600}
1601
1602function IGCM_sys_ncwa {
1603  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1604  if ( $DEBUG_sys ) ; then
1605    echo "IGCM_sys_ncwa :" $@
1606  fi
1607  ncwa $@
1608  if [ $? -gt 0 ] ; then
1609    echo "IGCM_sys_ncwa : erreur ${@}."
1610    IGCM_debug_Exit "ncwa"
1611  fi
1612
1613  IGCM_debug_PopStack "IGCM_sys_ncwa"
1614}
1615
1616##############################################################
1617# CDO OPERATOR
1618
1619function IGCM_sys_cdo {
1620  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1621  if ( $DEBUG_sys ) ; then
1622    echo "IGCM_sys_cdo :" $@
1623  fi
1624  \cdo $@
1625  if [ $? -gt 0 ] ; then
1626    echo "IGCM_sys_cdo : erreur ${@}."
1627    IGCM_debug_PopStack "IGCM_sys_cdo"
1628    return 1
1629  else
1630    IGCM_debug_PopStack "IGCM_sys_cdo"
1631    return 0
1632  fi
1633
1634  IGCM_debug_PopStack "IGCM_sys_cdo"
1635}
1636
1637############################################################
1638# Activate Running Environnment Variables
1639
1640function IGCM_sys_activ_variables {
1641  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1642  if ( $DEBUG_sys ) ; then
1643    echo "IGCM_sys_activ_variables"
1644  fi
1645  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1646}
1647
1648############################################################
1649# Desactivate Running Environnment Variables
1650
1651function IGCM_sys_desactiv_variables {
1652  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1653  if ( $DEBUG_sys ) ; then
1654    echo "IGCM_sys_desactiv_variables"
1655  fi
1656  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1657}
1658
1659############################################################
1660# Build run file
1661
1662function IGCM_sys_build_run_file {
1663  IGCM_debug_PushStack "IGCM_sys_build_run_file"
1664  if ( $DEBUG_sys ) ; then
1665    echo "IGCM_sys_build_run_file"
1666  fi
1667  IGCM_debug_PopStack "IGCM_sys_build_run_file"
1668}
Note: See TracBrowser for help on using the repository browser.