source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_ulam.ksh @ 719

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