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

Last change on this file since 651 was 651, checked in by aclsce, 12 years ago

Added check to be sure there is enough space on temporary filesystems (only on vargas, titane and mercure sx9).
If there is not enough space, we stop.

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