source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh @ 801

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