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

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

On mercure front-end TMPDIR exists and IGCM_sys_RmRunDir should be empty.

  • Property svn:keywords set to Revision Author Date
File size: 45.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 (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#D-#==================================================
144#D-function IGCM_sys_RshMaster
145#D-* Purpose: Just a fake command to wrapp
146#D-           IGCM_card call in post-treatment
147#D-           Ulam do not see brodie filesystem
148#D-           Cesium do not see all mercure filesystem
149#D-           That's why we need this hack.
150#D-* Examples:
151#D-
152function IGCM_sys_RshMaster {
153  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
154  /bin/ksh <<-EOF
155    export libIGCM=${libIGCM}
156    export DEBUG_debug=${DEBUG_debug}
157    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
158    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
159    ${@}
160EOF
161  if [ $? -gt 0 ] ; then
162    echo "IGCM_sys_RshMaster : erreur."
163    IGCM_debug_Exit "IGCM_sys_RshMaster"
164  fi
165  IGCM_debug_PopStack "IGCM_sys_RshMaster"
166}
167
168#D-#==================================================
169#D-function IGCM_sys_RshArchive
170#D-* Purpose: Archive rsh command
171#D-* Examples:
172#D-
173function IGCM_sys_RshArchive {
174  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
175  /bin/ksh <<-EOF
176    ${@}
177EOF
178  if [ $? -gt 0 ] ; then
179    echo "IGCM_sys_RshArchive : erreur."
180    IGCM_debug_Exit "IGCM_sys_RshArchive"
181  fi
182  IGCM_debug_PopStack "IGCM_sys_RshArchive"
183}
184
185#D-#==================================================
186#D-function IGCM_sys_RshPost
187#D-* Purpose: Post-process rsh command
188#D-* Examples:
189#D-
190function IGCM_sys_RshPost {
191  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
192  if ( $DEBUG_sys ) ; then
193    echo "IGCM_sys_RshPost :" $@
194  fi
195  /bin/ksh ${@}
196  if [ $? -gt 0 ] ; then
197    echo "IGCM_sys_RshPost : erreur."
198    IGCM_debug_Exit "IGCM_sys_RshPost"
199  fi
200  IGCM_debug_PopStack "IGCM_sys_RshPost"
201}
202
203#D-#==================================================
204#D-function IGCM_sys_SendMail
205#D-* Purpose: Send mail when simulation is over
206#D-* Examples:
207#D-
208function IGCM_sys_SendMail {
209  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
210  if ( $DEBUG_sys ) ; then
211    echo "IGCM_sys_SendMail :" $@
212  fi
213
214  if ( ${ExitFlag} ) ; then
215    status=failed
216  else
217    status=completed
218  fi
219  cat  << END_MAIL > job_end.mail
220Dear ${LOGIN},
221
222  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
223  Job started : ${DateBegin}
224  Job ended   : ${DateEnd}
225  Output files are available in ${R_SAVE}
226  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
227END_MAIL
228
229  if  [ X"${config_UserChoices_MailName}" != X ] ; then
230    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail
231  elif [ -f ~/.forward ] ; then
232    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
233  else
234    mailx -s "${config_UserChoices_JobName} ${status}" ${LOGIN} < job_end.mail
235  fi
236
237  if [ $? -gt 0 ] ; then
238    echo "IGCM_sys_SendMail : erreur."
239    IGCM_debug_Exit "IGCM_sys_SendMail"
240  fi
241  IGCM_debug_PopStack "IGCM_sys_SendMail"
242}
243
244#D-#==================================================
245#D-function IGCM_sys_Mkdir
246#D-* Purpose: Master locale mkdir command
247#D-* Examples:
248#D-
249function IGCM_sys_Mkdir {
250  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
251  if ( $DEBUG_sys ) ; then
252    echo "IGCM_sys_Mkdir :" $@
253  fi
254  if [ ! -d ${1} ]; then
255    \mkdir -p $1
256    if [ $? -gt 0 ] ; then
257      echo "IGCM_sys_Mkdir : erreur."
258      IGCM_debug_Exit "IGCM_sys_Mkdir"
259    fi
260  fi
261  # vérification :
262  if [ ! -d ${1} ] ; then
263    echo "IGCM_sys_Mkdir : erreur."
264    IGCM_debug_Exit "IGCM_sys_Mkdir"
265  fi
266  IGCM_debug_PopStack "IGCM_sys_Mkdir"
267}
268
269#D-#==================================================
270#D-function IGCM_sys_MkdirArchive
271#D-* Purpose: Mkdir on Archive
272#D-* Examples:
273#D-
274function IGCM_sys_MkdirArchive {
275  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
276  if ( $DEBUG_sys ) ; then
277    echo "IGCM_sys_MkdirArchive :" $@
278  fi
279  #- creation de repertoire sur le serveur fichier
280  if [ ! -d ${1} ]; then 
281    \mkdir -p $1
282    if [ $? -gt 0 ] ; then
283      echo "IGCM_sys_MkdirArchive : erreur."
284      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
285    fi
286  fi
287  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
288}
289
290#D-#==================================================
291#D-function IGCM_sys_MkdirWork
292#D-* Purpose: Mkdir on Work
293#D-* Examples:
294#D-
295function IGCM_sys_MkdirWork {
296  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
297  if ( $DEBUG_sys ) ; then
298    echo "IGCM_sys_MkdirWork :" $@
299  fi
300  #- creation de repertoire sur le serveur fichier
301  if [ ! -d ${1} ]; then 
302    \mkdir -p $1
303    if [ $? -gt 0 ] ; then
304      echo "IGCM_sys_MkdirWork : erreur."
305      IGCM_debug_Exit "IGCM_sys_MkdirWork"
306    fi
307  fi
308  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
309}
310
311#D-#==================================================
312#D-function IGCM_sys_Cd
313#D-* Purpose: master cd command
314#D-* Examples:
315#D-
316function IGCM_sys_Cd {
317  IGCM_debug_PushStack "IGCM_sys_Cd" $@
318  if ( $DEBUG_sys ) ; then
319    echo "IGCM_sys_Cd :" $@
320  fi
321  \cd $1
322  if [ $? -gt 0 ] ; then
323    echo "IGCM_sys_Cd : erreur."
324    IGCM_debug_Exit "IGCM_sys_Cd"
325  fi
326  IGCM_debug_PopStack "IGCM_sys_Cd"
327}
328
329#D-#==================================================
330#D-function IGCM_sys_Chmod
331#D-* Purpose: Chmod
332#D-* Examples:
333#D-
334function IGCM_sys_Chmod {
335  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
336  if ( $DEBUG_sys ) ; then
337    echo "IGCM_sys_Chmod :" $@
338  fi
339  if [ $DRYRUN -le 1 ]; then
340    \chmod $@
341    if [ $? -gt 0 ] ; then
342      echo "IGCM_sys_Chmod : erreur."
343      IGCM_debug_Exit "IGCM_sys_Chmod"
344    fi
345  else
346    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
347  fi
348  IGCM_debug_PopStack "IGCM_sys_Chmod"
349}
350
351#D-#==================================================
352#D-function IGCM_sys_FileSize
353#D-* Purpose: Filesize
354#D-* Examples:
355#D-
356function IGCM_sys_FileSize {
357  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
358
359  typeset sizeF
360  set +A sizeF -- $( ls -la ${1} )
361  if [ $? -gt 0 ] ; then
362    IGCM_debug_Exit "IGCM_sys_FileSize"
363  fi
364  eval ${2}=${sizeF[4]}
365
366  IGCM_debug_PopStack "IGCM_sys_FileSize"
367}
368
369#D-#==================================================
370#D-function IGCM_sys_TestDir
371#D-* Purpose: Test Directory that must exists
372#D-* Examples:
373#D-
374function IGCM_sys_TestDir {
375  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
376  if ( $DEBUG_sys ) ; then
377    echo "IGCM_sys_TestDir :" $@
378  fi
379  typeset ExistFlag
380  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
381  IGCM_debug_PopStack "IGCM_sys_TestDir"
382
383  return ${ExistFlag}
384}
385
386#D-#==================================================
387#D-function IGCM_sys_TestDirArchive
388#D-* Purpose: Test Directory that must exists on Archive
389#D-* Examples:
390#D-
391function IGCM_sys_TestDirArchive {
392  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
393  if ( $DEBUG_sys ) ; then
394    echo "IGCM_sys_TestDirArchive :" $@
395  fi
396  typeset ExistFlag
397  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
398  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
399
400  return ${ExistFlag}
401}
402
403#D-#==================================================
404#D-function IGCM_sys_IsFileArchived
405#D-* Purpose: Test file that must NOT EXISTS on Archive
406#D-* Examples:
407#D-
408function IGCM_sys_IsFileArchived {
409  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
410  if ( $DEBUG_sys ) ; then
411    echo "IGCM_sys_IsFileArchived :" $@
412  fi
413  typeset IsArchivedFlag
414  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/dmnfs ) != X ] && echo 0 || echo 1 )
415  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
416
417  return ${IsArchivedFlag}
418}
419
420#D-#==================================================
421#D-function IGCM_sys_TestFileArchive
422#D-* Purpose: Test file that must NOT EXISTS on Archive
423#D-* Examples:
424#D-
425function IGCM_sys_TestFileArchive {
426  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
427  if ( $DEBUG_sys ) ; then
428    echo "IGCM_sys_TestFileArchive :" $@
429  fi
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} ] ; 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    if [ ${RET} -gt 0 ] ; then
1169      echo "WARNING IGCM_sys_Get : demigration error."
1170      cat out_rsync
1171      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
1172    fi
1173
1174    #if [ ${RET} -gt 0 ] ; then
1175    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
1176    #   cat out_rsync
1177    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
1178    #   sleep 30
1179    #   echo "We try another time"
1180    ##  dmget ${dm_liste[*]} > out_rsync 2>&1
1181    #   ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1182    #   RET=$?
1183    #   if [ ${RET} -gt 0 ] ; then
1184    #       echo "ERROR IGCM_sys_Get : again demigration error :"
1185    #       cat out_rsync
1186    #       IGCM_debug_Exit "IGCM_sys_Get"
1187    #   fi
1188    #    else
1189    #   echo "ERROR IGCM_sys_Get : demigration error :"
1190    #   cat out_rsync
1191    #   IGCM_debug_Exit "IGCM_sys_Get"
1192    #    fi
1193    #fi
1194
1195    #USUAL WAY
1196    if [ X${1} = X'/l' ] ; then
1197      (( RET=0 ))
1198      for target in ${dm_liste[*]} ; do
1199        local_file=$( basename ${target} )
1200        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1201        (( RET = RET + $? ))
1202      done
1203    else
1204      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1205      RET=$?
1206    fi
1207
1208#       #RSYNC WITH NETWORK SSH CALL
1209#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1210#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1211
1212#       #RSYNC WITH NFS USE
1213#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1214#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1215
1216#       RET=$?
1217#       IGCM_sys_Rsync_out $RET
1218
1219#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1220#       (( RET=RET+$? ))
1221
1222    if [ ${RET} -gt 0 ] ; then
1223      echo "IGCM_sys_Get : copy error."
1224      cat out_rsync
1225#      IGCM_debug_Exit "IGCM_sys_Get"
1226    else
1227      \rm out_rsync
1228    fi
1229  else
1230    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1231  fi
1232  IGCM_debug_PopStack "IGCM_sys_Get"
1233}
1234
1235#D-#==================================================
1236#D-function IGCM_sys_GetBuffer
1237#D-* Purpose: Get a file from ${SCRATCHDIR}
1238#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1239#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1240function IGCM_sys_GetBuffer {
1241  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1242
1243  typeset DEST RET buf_liste ifile target file_work
1244
1245  if ( $DEBUG_sys ) ; then
1246    echo "IGCM_sys_GetBuffer :" $@
1247  fi
1248  if [ $DRYRUN -le 2 ]; then
1249    if [ X${1} = X'/l' ] ; then
1250      # test if the first file is present in the old computation :
1251      eval set +A buf_liste \${${2}}
1252    else
1253      eval set +A buf_liste ${1}
1254    fi
1255    eval DEST=\${${#}}
1256
1257    #USUAL WAY
1258    if [ X${1} = X'/l' ] ; then
1259      (( RET=0 ))
1260      for target in ${buf_liste[*]} ; do
1261        local_file=$( basename ${target} )
1262        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1263        (( RET = RET + $? ))
1264      done
1265    else
1266      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
1267      RET=$?
1268    fi
1269
1270    if [ ${RET} -gt 0 ] ; then
1271      echo "IGCM_sys_GetBuffer : copy error."
1272      cat out_rsync
1273      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1274    else
1275      \rm out_rsync
1276    fi
1277  else
1278    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1279  fi
1280  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1281}
1282
1283#D-#==================================================
1284#D-function IGCM_sys_GetDate_FichWork
1285#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1286#D-* Examples:
1287#D-
1288function IGCM_sys_GetDate_FichWork {
1289  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1290  if ( $DEBUG_sys ) ; then
1291    echo "IGCM_sys_GetDate_FichWork :" $@
1292  fi
1293  # donne la date filesys d'un fichier sur la machine work
1294  IGCM_debug_PopStack "IGCM_sys_FichWork"
1295}
1296
1297#D-#==================================================
1298#D-function IGCM_sys_GetDate_FichArchive
1299#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1300#D-* Examples:
1301#D-
1302function IGCM_sys_GetDate_FichArchive {
1303  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1304  if ( $DEBUG_sys ) ; then
1305    echo "IGCM_sys_GetDate_FichArchive :" $@
1306  fi
1307  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1308}
1309
1310#D-#==================================================
1311#D-function IGCM_sys_Dods_Rm
1312#D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole.
1313#D-* Examples:
1314#D-
1315function IGCM_sys_Dods_Rm {
1316  if ( $DEBUG_sys ) ; then
1317    echo "IGCM_sys_Dods_Rm :" $@
1318  fi
1319  typeset RET
1320  RET=0
1321  if [ $DRYRUN = 0 ]; then
1322
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
1329    /ccc/cont003/home/dsm/p86maf/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
1330    RET=$?
1331   
1332#       if [ ${RET} -gt 0 ] ; then
1333#           echo "IGCM_sys_Dods_Rm : error."
1334#           cat out_dods_rm
1335#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1336#       else
1337#           rm out_dods_rm
1338#       fi
1339
1340  else
1341    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1342  fi
1343  return $RET
1344}
1345
1346#D-#==================================================
1347#D-function IGCM_sys_Dods_Cp
1348#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1349#D-* Examples:
1350#D-
1351function IGCM_sys_Dods_Cp {
1352  if ( $DEBUG_sys ) ; then
1353    echo "IGCM_sys_Dods_Cp :" $@
1354  fi
1355  typeset RET
1356  RET=0
1357  if [ $DRYRUN = 0 ]; then
1358
1359#    if [ ! -d ${R_SAVE}/${1} ] ; then
1360#      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1361#      echo "Nothing has been done."
1362#      return
1363#    fi
1364
1365    /ccc/cont003/home/dsm/p86maf/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
1366    RET=$?
1367
1368#       if [ ${RET} -gt 0 ] ; then
1369#           echo "IGCM_sys_Dods_Cp : error."
1370#           cat out_dods_cp
1371#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1372#       else
1373#           rm out_dods_cp
1374#       fi
1375
1376  else
1377    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1378  fi
1379  return $RET
1380}
1381
1382#D-#==================================================
1383#D-function IGCM_sys_Put_Dods
1384#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1385#D-* Examples:
1386#D-
1387function IGCM_sys_Put_Dods {
1388  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1389  if ( $DEBUG_sys ) ; then
1390    echo "IGCM_sys_Put_Dods :" $@
1391  fi
1392  typeset RET
1393  if [ $DRYRUN = 0 ]; then
1394    if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
1395      echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should."
1396      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST."
1397      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST."
1398      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1399      return
1400    fi
1401
1402    if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then
1403      echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should."
1404      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS."
1405      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS."
1406      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1407      return
1408    fi
1409    #
1410    if [ -d ${R_SAVE}/${1} ] ; then
1411      cd ${R_SAVE}
1412    elif [ -d ${R_FIGR}/${1} ] ; then
1413      cd ${R_FIGR}
1414    fi
1415
1416    IGCM_sys_Dods_Rm ${1}
1417    IGCM_sys_Dods_Cp ${1}
1418    RET=0
1419   
1420    if [ ${RET} -gt 0 ] ; then
1421      echo "IGCM_sys_Put_Dods : error."
1422      IGCM_debug_Exit "IGCM_sys_Put_Dods"
1423    fi
1424  else
1425    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1426  fi
1427  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1428}
1429
1430##############################################################
1431# REBUILD OPERATOR
1432
1433function IGCM_sys_rebuild {
1434  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1435  if ( $DEBUG_sys ) ; then
1436    echo "IGCM_sys_rebuild :" $@
1437  fi
1438  /home/cont003/p86ipsl/X86_64/bin/rebuild -f -o $@
1439  if [ $? -gt 0 ] ; then
1440    echo "IGCM_sys_rebuild : erreur ${@}."
1441    IGCM_debug_Exit "rebuild"
1442  fi
1443
1444  IGCM_debug_PopStack "IGCM_sys_rebuild"
1445}
1446
1447##############################################################
1448# NCO OPERATOR
1449
1450function IGCM_sys_ncap2 {
1451  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1452  if ( $DEBUG_sys ) ; then
1453    echo "IGCM_sys_ncap2 :" $@
1454  fi
1455  ncap2 "$@"
1456  if [ $? -gt 0 ] ; then
1457    echo "IGCM_sys_ncap2 : erreur ${@}."
1458    IGCM_debug_Exit "ncap2"
1459  fi
1460
1461  IGCM_debug_PopStack "IGCM_sys_ncap2"
1462}
1463
1464function IGCM_sys_ncatted {
1465  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1466  if ( $DEBUG_sys ) ; then
1467    echo "IGCM_sys_ncatted :" $@
1468  fi
1469  ncatted "$@"
1470  if [ $? -gt 0 ] ; then
1471    echo "IGCM_sys_ncatted : erreur ${@}."
1472    IGCM_debug_Exit "ncatted"
1473  fi
1474
1475  IGCM_debug_PopStack "IGCM_sys_ncatted"
1476}
1477
1478function IGCM_sys_ncbo {
1479  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1480  if ( $DEBUG_sys ) ; then
1481    echo "IGCM_sys_ncbo :" $@
1482  fi
1483  ncbo $@
1484  if [ $? -gt 0 ] ; then
1485    echo "IGCM_sys_ncbo : erreur ${@}."
1486    IGCM_debug_Exit "ncbo"
1487  fi
1488
1489  IGCM_debug_PopStack "IGCM_sys_ncbo"
1490}
1491
1492function IGCM_sys_ncdiff {
1493  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1494  if ( $DEBUG_sys ) ; then
1495    echo "IGCM_sys_ncdiff :" $@
1496  fi
1497  ncdiff $@
1498  if [ $? -gt 0 ] ; then
1499    echo "IGCM_sys_ncdiff : erreur ${@}."
1500    IGCM_debug_Exit "ncdiff"
1501  fi
1502
1503  IGCM_debug_PopStack "IGCM_sys_ncdiff"
1504}
1505
1506function IGCM_sys_ncea {
1507  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1508  if ( $DEBUG_sys ) ; then
1509    echo "IGCM_sys_ncea :" $@
1510  fi
1511  ncea $@
1512  if [ $? -gt 0 ] ; then
1513    echo "IGCM_sys_ncea : erreur ${@}."
1514    IGCM_debug_Exit "ncea"
1515  fi
1516
1517  IGCM_debug_PopStack "IGCM_sys_ncea"
1518}
1519
1520function IGCM_sys_ncecat {
1521  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1522  if ( $DEBUG_sys ) ; then
1523    echo "IGCM_sys_ncecat :" $@
1524  fi
1525  ncecat $@
1526  if [ $? -gt 0 ] ; then
1527    echo "IGCM_sys_ncecat : erreur ${@}."
1528    IGCM_debug_Exit "ncecat"
1529  fi
1530
1531  IGCM_debug_PopStack "IGCM_sys_ncecat"
1532}
1533
1534function IGCM_sys_ncflint {
1535  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1536  if ( $DEBUG_sys ) ; then
1537    echo "IGCM_sys_ncflint :" $@
1538  fi
1539  ncflint $@
1540  if [ $? -gt 0 ] ; then
1541    echo "IGCM_sys_ncflint : erreur ${@}."
1542    IGCM_debug_Exit "ncflint"
1543  fi
1544
1545  IGCM_debug_PopStack "IGCM_sys_ncflint"
1546}
1547
1548function IGCM_sys_ncks {
1549  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1550  if ( $DEBUG_sys ) ; then
1551    echo "IGCM_sys_ncks :" $@
1552  fi
1553  ncks $@
1554  if [ $? -gt 0 ] ; then
1555    echo "IGCM_sys_ncks : erreur ${@}."
1556    IGCM_debug_Exit "ncks"
1557  fi
1558
1559  IGCM_debug_PopStack "IGCM_sys_ncks"
1560}
1561
1562function IGCM_sys_ncpdq {
1563  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1564  if ( $DEBUG_sys ) ; then
1565    echo "IGCM_sys_ncpdq :" $@
1566  fi
1567  ncpdq $@
1568  if [ $? -gt 0 ] ; then
1569    echo "IGCM_sys_ncpdq : erreur ${@}."
1570    IGCM_debug_Exit "ncpdq"
1571  fi
1572
1573  IGCM_debug_PopStack "IGCM_sys_ncpdq"
1574}
1575
1576function IGCM_sys_ncra {
1577  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1578  if ( $DEBUG_sys ) ; then
1579    echo "IGCM_sys_ncra :" $@
1580  fi
1581  ncra $@
1582  if [ $? -gt 0 ] ; then
1583    echo "IGCM_sys_ncra : erreur ${@}."
1584    IGCM_debug_Exit "ncra"
1585  fi
1586
1587  IGCM_debug_PopStack "IGCM_sys_ncra"
1588}
1589
1590function IGCM_sys_ncrcat {
1591  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1592  if ( $DEBUG_sys ) ; then
1593    echo "IGCM_sys_ncrcat :" $@
1594  fi
1595  ncrcat $@
1596  if [ $? -gt 0 ] ; then
1597    echo "IGCM_sys_ncrcat : erreur ${@}."
1598#       IGCM_debug_Exit "ncrcat"
1599  fi
1600
1601  IGCM_debug_PopStack "IGCM_sys_ncrcat"
1602}
1603
1604function IGCM_sys_ncrename {
1605  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1606  if ( $DEBUG_sys ) ; then
1607    echo "IGCM_sys_ncrename :" $@
1608  fi
1609  ncrename $@
1610  if [ $? -gt 0 ] ; then
1611    echo "IGCM_sys_ncrename : erreur ${@}."
1612    IGCM_debug_Exit "ncrename"
1613  fi
1614
1615  IGCM_debug_PopStack "IGCM_sys_ncrename"
1616}
1617
1618function IGCM_sys_ncwa {
1619  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1620  if ( $DEBUG_sys ) ; then
1621    echo "IGCM_sys_ncwa :" $@
1622  fi
1623  ncwa $@
1624  if [ $? -gt 0 ] ; then
1625    echo "IGCM_sys_ncwa : erreur ${@}."
1626    IGCM_debug_Exit "ncwa"
1627  fi
1628
1629  IGCM_debug_PopStack "IGCM_sys_ncwa"
1630}
1631
1632##############################################################
1633# CDO OPERATOR
1634
1635function IGCM_sys_cdo {
1636  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1637  if ( $DEBUG_sys ) ; then
1638    echo "IGCM_sys_cdo :" $@
1639  fi
1640  \cdo $@
1641  if [ $? -gt 0 ] ; then
1642    echo "IGCM_sys_cdo : erreur ${@}."
1643    IGCM_debug_PopStack "IGCM_sys_cdo"
1644    return 1
1645  else
1646    IGCM_debug_PopStack "IGCM_sys_cdo"
1647    return 0
1648  fi
1649
1650  IGCM_debug_PopStack "IGCM_sys_cdo"
1651}
1652
1653############################################################
1654# Activate Running Environnment Variables
1655
1656function IGCM_sys_activ_variables {
1657  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1658  if ( $DEBUG_sys ) ; then
1659    echo "IGCM_sys_activ_variables"
1660  fi
1661  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1662}
1663
1664############################################################
1665# Desactivate Running Environnment Variables
1666
1667function IGCM_sys_desactiv_variables {
1668  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1669  if ( $DEBUG_sys ) ; then
1670    echo "IGCM_sys_desactiv_variables"
1671  fi
1672  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1673}
1674
1675############################################################
1676# Build run file
1677
1678function IGCM_sys_build_run_file {
1679  IGCM_debug_PushStack "IGCM_sys_build_run_file"
1680  if ( $DEBUG_sys ) ; then
1681    echo "IGCM_sys_build_run_file"
1682  fi
1683  IGCM_debug_PopStack "IGCM_sys_build_run_file"
1684}
Note: See TracBrowser for help on using the repository browser.