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

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