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

Last change on this file since 800 was 800, checked in by sdipsl, 11 years ago
  • default and obelix was outdated. They diverged too much from the others.
  • Property svn:keywords set to Revision Author Date
File size: 61.0 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_Put_Out
1052#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
1053#D-* Examples:
1054#D-
1055function IGCM_sys_Put_Out {
1056  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
1057  if ( $DEBUG_sys ) ; then
1058    echo "IGCM_sys_Put_Out :" $@
1059  fi
1060  if [ $DRYRUN = 0 ]; then
1061    if [ -f ${1} ] ; then
1062      if [ ! -d $( dirname $2 ) ] ; then
1063        IGCM_sys_MkdirArchive $( dirname $2 )
1064      fi
1065    else
1066      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
1067      IGCM_debug_PopStack "IGCM_sys_Put_Out"
1068      return 1
1069    fi
1070
1071    typeset status
1072    #
1073    if [ X${JobType} = XRUN ] ; then
1074      if [ X${3} = X ] ; then
1075        IGCM_sys_Chmod 444 ${1}
1076      fi
1077    fi
1078    #
1079
1080    echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1
1081    ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1
1082    status=$?
1083    IGCM_sys_Rsync_out $status
1084
1085    ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1086    (( status=status+$? ))
1087
1088    if [ ${status} -gt 0 ] ; then
1089      echo "IGCM_sys_Put_Out : error."
1090      cat out_rsync
1091      IGCM_debug_Exit "IGCM_sys_Put_Out"
1092    else
1093      \rm out_rsync
1094    fi
1095  else
1096    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1097  fi
1098  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1099  return 0
1100}
1101
1102#D-#==================================================
1103#D-function IGCM_sys_PutBuffer_Out
1104#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1105#D-* Examples:
1106#D-
1107function IGCM_sys_PutBuffer_Out {
1108  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1109  if ( $DEBUG_sys ) ; then
1110    echo "IGCM_sys_PutBuffer_Out :" $@
1111  fi
1112
1113  typeset status
1114
1115  if [ $DRYRUN = 0 ]; then
1116    if [ ! -f ${1} ] ; then
1117      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1118      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1119      return 1
1120    fi
1121    #
1122    IGCM_sys_Mkdir $( dirname $2 )
1123    #
1124
1125    if [ X${JobType} = XRUN ] ; then
1126      if [ X${3} = X ] ; then
1127        IGCM_sys_Chmod 444 ${1}
1128      fi
1129    fi
1130    #
1131    # USUAL WAY
1132    \cp $1 $2 > out_rsync 2>&1
1133    status=$?
1134
1135    if [ ${status} -gt 0 ] ; then
1136      echo "IGCM_sys_PutBuffer_Out : error."
1137      cat out_rsync
1138      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1139    else
1140      \rm out_rsync
1141    fi
1142  else
1143    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1144  fi
1145  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1146  return 0
1147}
1148
1149#D-#==================================================
1150#D-function IGCM_sys_Get
1151#D-* Purpose: Get a file from ${ARCHIVE}
1152#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1153#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1154function IGCM_sys_Get {
1155  IGCM_debug_PushStack "IGCM_sys_Get" $@
1156
1157  typeset DEST RET status dm_liste ifile target
1158
1159  if ( $DEBUG_sys ) ; then
1160    echo "IGCM_sys_Get :" $@
1161  fi
1162  if [ $DRYRUN -le 2 ]; then
1163    if [ X${1} = X'/l' ] ; then
1164      # test if the first file is present in the old computation :
1165      eval set +A dm_liste \${${2}}
1166    else
1167      dm_liste=${1}
1168    fi
1169    eval DEST=\${${#}}
1170
1171    # test if the (first) file is present in the old computation :
1172    IGCM_sys_TestFileArchive ${dm_liste[0]}
1173    status=$?
1174    if [ ${status} -gt 0 ] ; then
1175      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1176      IGCM_debug_Exit "IGCM_sys_Get"
1177      #return
1178    fi
1179
1180    (( RET=0 ))
1181    for target in ${dm_liste[*]} ; do
1182      \cp ${target} ${DEST} >> out_rsync 2>&1
1183      (( RET=RET+$? ))
1184    done
1185
1186#       echo ${RSYNC} ${RSYNC_opt} $@ > out_rsync 2>&1
1187#       ${RSYNC} ${RSYNC_opt} $@ >> out_rsync 2>&1
1188#       status=$?
1189#       IGCM_sys_Rsync_out $status
1190
1191#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1192#       (( RET=RET+$? ))
1193
1194    if [ ${RET} -gt 0 ] ; then
1195      echo "IGCM_sys_Get : error"
1196      cat out_rsync
1197      \rm out_rsync
1198      IGCM_debug_Exit "IGCM_sys_Get"
1199    else
1200      \rm out_rsync
1201    fi
1202  else
1203    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1204  fi
1205  IGCM_debug_PopStack "IGCM_sys_Get"
1206}
1207
1208#D-#==================================================
1209#D-function IGCM_sys_GetBuffer
1210#D-* Purpose: Get a file from ${SCRATCHDIR}
1211#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1212#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1213function IGCM_sys_GetBuffer {
1214  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1215
1216  typeset DEST RET status buf_liste ifile target file_work
1217
1218  if ( $DEBUG_sys ) ; then
1219    echo "IGCM_sys_GetBuffer :" $@
1220  fi
1221  if [ $DRYRUN -le 2 ]; then
1222    if [ X${1} = X'/l' ] ; then
1223      # test if the first file is present in the old computation :
1224      eval set +A buf_liste \${${2}}
1225    else
1226      eval set +A buf_liste ${1}
1227    fi
1228    eval DEST=\${${#}}
1229
1230    #USUAL WAY
1231    if [ X${1} = X'/l' ] ; then
1232      (( RET=0 ))
1233      for target in ${buf_liste[*]} ; do
1234        local_file=$( basename ${target} )
1235        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1236        (( RET = RET + $? ))
1237      done
1238    else
1239      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
1240      status=$?
1241    fi
1242
1243    if [ ${RET} -gt 0 ] ; then
1244      echo "IGCM_sys_GetBuffer : error"
1245      cat out_rsync
1246      \rm out_rsync
1247      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1248    else
1249      \rm out_rsync
1250    fi
1251  else
1252    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1253  fi
1254  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1255}
1256
1257#D-#==================================================
1258#D-function IGCM_sys_GetDate_FichWork
1259#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1260#D-* Examples:
1261#D-
1262function IGCM_sys_GetDate_FichWork {
1263  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1264  if ( $DEBUG_sys ) ; then
1265    echo "IGCM_sys_GetDate_FichWork :" $@
1266  fi
1267  typeset dateF
1268  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1269  eval ${2}=${dateF[5]}
1270
1271  # donne la date filesys d'un fichier sur la machine work
1272  IGCM_debug_PopStack "IGCM_sys_FichWork"
1273}
1274
1275#D-#==================================================
1276#D-function IGCM_sys_GetDate_FichArchive
1277#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1278#D-* Examples:
1279#D-
1280function IGCM_sys_GetDate_FichArchive {
1281  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1282  if ( $DEBUG_sys ) ; then
1283    echo "IGCM_sys_GetDate_FichArchive :" $@
1284  fi
1285  typeset dateF
1286  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1287  eval ${2}=${dateF[5]}
1288
1289  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1290}
1291
1292#D-#==================================================
1293#D-function IGCM_sys_Dods_Rm
1294#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
1295#D-* Examples:
1296#D-
1297function IGCM_sys_Dods_Rm {
1298  if ( $DEBUG_sys ) ; then
1299    echo "IGCM_sys_Dods_Rm :" $@
1300  fi
1301  return 0
1302}
1303
1304#D-#==================================================
1305#D-function IGCM_sys_Dods_Cp
1306#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1307#D-* Examples:
1308#D-
1309function IGCM_sys_Dods_Cp {
1310  if ( $DEBUG_sys ) ; then
1311    echo "IGCM_sys_Dods_Cp :" $@
1312  fi
1313  return 0
1314}
1315
1316#D-#==================================================
1317#D-function IGCM_sys_Put_Dods
1318#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1319#D-* Examples:
1320#D-
1321function IGCM_sys_Put_Dods {
1322  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1323  if ( $DEBUG_sys ) ; then
1324    echo "IGCM_sys_Put_Dods :" $@
1325  fi
1326  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1327}
1328
1329##############################################################
1330# REBUILD OPERATOR
1331
1332function IGCM_sys_rebuild {
1333  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1334  if ( $DEBUG_sys ) ; then
1335    echo "IGCM_sys_rebuild :" $@
1336  fi
1337
1338  typeset status
1339
1340  /home/users/igcmg/rebuild/bin/rebuild -f -o $@
1341  status=$?
1342  if [ ${status} -gt 0 ] ; then
1343    IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
1344    IGCM_debug_Exit "rebuild"
1345  fi
1346
1347  IGCM_debug_PopStack "IGCM_sys_rebuild"
1348}
1349
1350function IGCM_sys_rebuild_station {
1351  IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@
1352  typeset i list_opt file_in file_out prefix_invert list_invert
1353  if ( $DEBUG_sys ) ; then
1354    echo "IGCM_sys_rebuild_station :" $@
1355  fi
1356  list_opt=$@
1357
1358  # Invert Axis : t,x -> x,t
1359  #               t,pres,x -> x,t,pres
1360  # So that we can concatenate along x
1361  i=0
1362  for file_in in ${list_opt} ; do
1363    (( i = i + 1))
1364    [ ${i} = 1 ] && file_out=${file_in} && continue
1365    prefix_invert=$( basename ${file_in} .nc )
1366    IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc
1367    list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc
1368  done
1369
1370  # Concatenate
1371  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc
1372
1373  # Re-ivert file
1374  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}
1375
1376  # Station re-ordering is too expansive to be run within libICGM
1377  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.
1378  # This re-ordering must be done "in memory" by the cmorization process
1379  # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)
1380  # BEGIN reordering
1381
1382  # Only LMDZ text output contains the exact ordering of the station.
1383  # We isolate this in the code below:
1384  #  0  38  -157.5000000000000  70.98591549295774
1385  #  0  54  27.49999999999999   67.18309859154928
1386  #  0  56  -62.50000000000001  82.39436619718309
1387  #  0  79  12.49999999999999   78.59154929577466
1388  #  0  116 -165.0000000000000  76.05633802816901
1389  #  0  117 130.0000000000000   70.98591549295774
1390  #  0  118 110.0000000000000   87.46478873239437
1391  #  1  40  4.999999999999995   51.97183098591550
1392#  typeset iStation iProc list_opt file_in file_out prefix_invert
1393#  typeset -Z4 j4
1394#  typeset -Z3 j3
1395
1396#  unset list_opt
1397#  set +A list_opt $@
1398
1399  # Filename after rebuild
1400#  file_out=${list_opt[0]}
1401  # Prefix of output files
1402#  prefix_invert=$( basename ${file_out} .nc )
1403  # Number of procs
1404#  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )
1405
1406#  iProc=0
1407#  while [ ${iProc} -lt ${num_proc} ] ; do
1408    # Array containing Station as a number
1409#    unset proc_stn
1410#    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}' )
1411    # Number of stations produced by processor proc
1412#    stationLast=${#proc_stn[*]}
1413    # Proc number on 4 digits
1414#    j4=${iProc}
1415    # Init
1416#    iStation=0
1417#    while [ ${iStation} -lt ${stationLast} ] ; do
1418      # Station number on 3 digits
1419#      j3=${proc_stn[${iStation}]}
1420      # Extract station
1421      # Invert Axis : t,x -> x,t
1422      #               t,pres,x -> x,t,pres
1423      # So that we can concatenate along x
1424#      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
1425#      (( iStation = iStation + 1 ))
1426#    done
1427#    (( iProc = iProc + 1 ))
1428#  done
1429
1430  # Concatenate all station along x
1431#  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc
1432
1433  # Re-invert file
1434#  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}
1435
1436  # END reordering
1437
1438  IGCM_debug_PopStack "IGCM_sys_rebuild_station"
1439}
1440
1441############################################################
1442# Activate Running Environnment Variables
1443
1444function IGCM_sys_activ_variables {
1445  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1446  if ( $DEBUG_sys ) ; then
1447    echo "IGCM_sys_activ_variables"
1448  fi
1449  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1450}
1451
1452############################################################
1453# Desactivate Running Environnment Variables
1454
1455function IGCM_sys_desactiv_variables {
1456  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1457  if ( $DEBUG_sys ) ; then
1458    echo "IGCM_sys_desactiv_variables"
1459  fi
1460  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1461}
1462
1463############################################################
1464# Build MPI/OMP scripts run file (dummy function)
1465
1466function IGCM_sys_build_run_file {
1467
1468  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1469
1470}
1471
1472############################################################
1473# Build MPI/OMP scripts
1474function IGCM_sys_build_execution_scripts
1475{
1476  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1477  if ( $DEBUG_sys ) ; then
1478    echo "IGCM_sys_build_execution_scripts " $@
1479  fi
1480  typeset nodes listnodes init_node start_num init_exec comp ExeNameIn ExeNameOut
1481  typeset node_num_current node_current comp_proc_mpi_loc comp_proc_omp_loc
1482  typeset num_corempi nombre_restant_node nombre_restant_comp
1483
1484  if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
1485    IGCM_debug_Exit "IGCM_sys_titane build_execution_scripts : Job_${config_UserChoices_JobName} doesn't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
1486  fi
1487
1488  if ( ${OK_PARA_MPMD} ) ; then
1489
1490    if [ -f run_file ] ; then
1491      IGCM_sys_Rm -f run_file
1492    fi
1493    touch run_file
1494
1495    if ( ${OK_PARA_OMP} ) ; then
1496
1497      #  Hosts treatment
1498
1499      ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp
1500
1501      i=0
1502      rm -f hosts
1503      IGCM_debug_Print 1 "sys Obelix, Hosts avaible :"
1504      for nodes in `cat hosts.tmp` ; do
1505        host[$i]=$nodes
1506        echo "${host[$i]} slots=1 max_slots=1" >> hosts
1507        IGCM_debug_Print 1 ${host[$i]}
1508        i=$((i+1))
1509      done
1510      rm -f hosts.tmp
1511
1512      listnodes=${host[*]}
1513
1514      EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts"
1515
1516      # Initialisation
1517
1518      init_node=y
1519      node_num_current=0
1520      start_num=0
1521      init_exec=n
1522
1523      # Test : if oasis is there, we put it at the first position
1524
1525      for comp in ${config_ListOfComponents[*]} ; do
1526
1527        if [ "X${comp}" = "XCPL" ]  ; then
1528
1529          eval ExeNameIn=\${config_Executable_${comp}[0]}
1530          eval ExeNameOut=\${config_Executable_${comp}[1]}
1531
1532          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1533          echo ""  >> script_${ExeNameOut}.ksh
1534          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1535          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1536          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1537          echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err"  >> script_${ExeNameOut}.ksh
1538          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1539
1540          init_node=n
1541
1542          (( nombre_restant_node = NUM_COREPERNODE - 1 ))
1543          node_num_current=0
1544          node_current=${host[${node_num_current}]}
1545
1546          EXECUTION="${EXECUTION} -H ${node_current} -np 1 ./script_${ExeNameOut}.ksh"
1547
1548          init_exec=y
1549          start_num=1
1550
1551        fi
1552
1553      done
1554
1555      # Then loop on the components (except for oasis)
1556
1557      for comp in ${config_ListOfComponents[*]} ; do
1558
1559        eval ExeNameIn=\${config_Executable_${comp}[0]}
1560        eval ExeNameOut=\${config_Executable_${comp}[1]}
1561
1562        # Only if we really have an executable for the component :
1563        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then
1564
1565          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1566          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1567
1568          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1569          # echo "set -vx" >> script_${ExeNameOut}.ksh
1570          echo ""  >> script_${ExeNameOut}.ksh
1571          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1572          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1573          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1574          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1575          echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh
1576          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh
1577          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1578
1579          node_num=0
1580
1581          # We define the number of MPI process to be assigned for the component
1582
1583          nombre_restant_comp=${comp_proc_mpi_loc}
1584
1585          # Loop on the allocated nodes
1586
1587          for node in ${listnodes} ; do
1588
1589            # We go to the current node
1590            if [ ${node_num} = ${node_num_current} ] ; then
1591
1592              node_current=${host[${node_num_current}]}
1593
1594              # If first time on the node : initialisation
1595
1596              if [ ${init_node} = y ] ; then
1597                nombre_restant_node=${NUM_COREPERNODE}
1598              fi
1599
1600              # Test on the number of OMP threads
1601
1602              if [ ${comp_proc_omp_loc} -gt ${nombre_restant_node} ] ; then
1603                (( node_num = node_num + 1 ))
1604                node_num_current=${node_num}
1605                init_node=y
1606                continue
1607              fi
1608
1609              # Number of MPI process to assign
1610
1611              (( num_corempi = nombre_restant_node / comp_proc_omp_loc ))
1612
1613              if [ ${num_corempi} -gt ${nombre_restant_comp} ] ; then
1614                num_corempi=${nombre_restant_comp}
1615              fi
1616
1617              (( nombre_restant_node = nombre_restant_node - num_corempi * comp_proc_omp_loc ))
1618              (( nombre_restant_comp = nombre_restant_comp - num_corempi ))
1619
1620              if [ ${init_exec} = y ] ; then
1621                EXECUTION="${EXECUTION} : -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
1622              else
1623                EXECUTION="${EXECUTION} -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
1624                init_exec=y
1625              fi
1626
1627              ((  start_num = num_corempi + start_num ))
1628
1629            else
1630
1631              (( node_num = node_num + 1 ))
1632              continue
1633            fi
1634
1635            # Test on the number of core/process remaining on the node/component
1636
1637            if [ ${nombre_restant_node} = 0 ] ; then
1638              (( node_num = node_num + 1 ))
1639              node_num_current=${node_num}
1640              init_node=y
1641
1642              if [ ${nombre_restant_comp} = 0 ] ; then
1643                break 1
1644              fi
1645            else
1646
1647              node_num_current=${node_num}
1648              init_node=n
1649
1650              if [ ${nombre_restant_comp} = 0 ] ; then
1651                break 1
1652              fi
1653            fi
1654          done
1655        fi
1656      done
1657
1658    else
1659
1660      # Then first loop on the components for the coupler ie oasis
1661
1662      ## the coupler ie oasis must be the first one
1663      for comp in ${config_ListOfComponents[*]} ; do
1664
1665        eval ExeNameOut=\${config_Executable_${comp}[1]}
1666
1667        # for CPL component only
1668        if [ "X${comp}" = "XCPL" ] ; then
1669          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1670          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file
1671        fi
1672      done
1673
1674        # Then second loop on the components
1675
1676      for comp in ${config_ListOfComponents[*]} ; do
1677
1678        eval ExeNameOut=\${config_Executable_${comp}[1]}
1679
1680        # Only if we really have an executable for the component and not the coupler ie oasis:
1681        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1682          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1683          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1684        fi
1685      done
1686      IGCM_sys_Chmod u+x run_file
1687
1688      EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file"
1689
1690    fi
1691
1692  else # Only one executable. launch it.
1693
1694    for comp in ${config_ListOfComponents[*]} ; do
1695
1696      # Only if we really have an executable for the component :
1697      eval ExeNameOut=\${config_Executable_${comp}[1]}
1698      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
1699
1700        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1701        echo ""  >> script_${ExeNameOut}.ksh
1702        if ( ${OK_PARA_OMP} ) ; then
1703          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1704          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1705        fi
1706        if  ( ${OK_PARA_MPI} ) ; then
1707          # Default : mpirun used if nb_proc gt 1
1708          # pour sortie out/err par process
1709          # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}"  >> script_${ExeNameOut}.ksh
1710          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1711          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1712          EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh"
1713        else
1714          # Default : mpirun is NOT used if nb_proc eq 1
1715          # pour sortie out/err par process
1716          # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
1717          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1718          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1719          EXECUTION="time ./script_${ExeNameOut}.ksh"
1720        fi
1721      fi
1722    done
1723
1724  fi
1725
1726  IGCM_debug_Print 1 "sys Obelix : La commande d execution est "
1727  IGCM_debug_Print 1 $EXECUTION
1728
1729  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1730}
1731
1732############################################################
1733# Check of space available on temporary filesytems
1734function IGCM_sys_check_quota {
1735  IGCM_debug_PushStack "IGCM_sys_check_quota"
1736  if ( $DEBUG_sys ) ; then
1737    echo "IGCM_sys_check_quota"
1738  fi
1739  IGCM_debug_PopStack "IGCM_sys_check_quota"
1740}
1741
1742##############################################################
1743# NCO OPERATOR
1744
1745function IGCM_sys_ncap2 {
1746  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1747  if ( $DEBUG_sys ) ; then
1748    echo "IGCM_sys_ncap2 :" $@
1749  fi
1750
1751  typeset NB_ESSAI DELAI status i
1752  # number of tentative
1753  NB_ESSAI=3
1754  # time delay between tentative
1755  DELAI=2
1756
1757  i=0
1758  while [ $i -lt $NB_ESSAI ] ; do
1759    ncap2 "$@" > out_rsync 2>&1
1760    status=$?
1761    if [ ${status} -gt 0 ] ; then
1762      IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"
1763      cat out_rsync
1764      \rm out_rsync
1765      IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
1766      sleep $DELAI
1767    else
1768      \rm out_rsync
1769      break
1770    fi
1771    (( i = i + 1 ))
1772  done
1773
1774  if [ ${status} -gt 0 ] ; then
1775      echo "IGCM_sys_ncap2 : ncap2 error"
1776      IGCM_debug_Exit "ncap2"
1777  fi
1778
1779  IGCM_debug_PopStack "IGCM_sys_ncap2"
1780}
1781
1782function IGCM_sys_ncatted {
1783  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1784  if ( $DEBUG_sys ) ; then
1785    echo "IGCM_sys_ncatted :" $@
1786  fi
1787
1788  typeset NB_ESSAI DELAI status i
1789  # number of tentative
1790  NB_ESSAI=3
1791  # time delay between tentative
1792  DELAI=2
1793
1794  i=0
1795  while [ $i -lt $NB_ESSAI ] ; do
1796    ncatted "$@" > out_rsync 2>&1
1797    status=$?
1798    if [ ${status} -gt 0 ] ; then
1799      IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"
1800      cat out_rsync
1801      \rm out_rsync
1802      IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
1803      sleep $DELAI
1804    else
1805      \rm out_rsync
1806      break
1807    fi
1808    (( i = i + 1 ))
1809  done
1810
1811  if [ ${status} -gt 0 ] ; then
1812      echo "IGCM_sys_ncatted : ncatted error"
1813      IGCM_debug_Exit "ncatted"
1814  fi
1815
1816  IGCM_debug_PopStack "IGCM_sys_ncatted"
1817}
1818
1819function IGCM_sys_ncbo {
1820  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1821  if ( $DEBUG_sys ) ; then
1822    echo "IGCM_sys_ncbo :" $@
1823  fi
1824
1825  typeset NB_ESSAI DELAI status i
1826  # number of tentative
1827  NB_ESSAI=3
1828  # time delay between tentative
1829  DELAI=2
1830
1831  i=0
1832  while [ $i -lt $NB_ESSAI ] ; do
1833    ncbo $@ > out_rsync 2>&1
1834    status=$?
1835    if [ ${status} -gt 0 ] ; then
1836      IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"
1837      cat out_rsync
1838      \rm out_rsync
1839      IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
1840      sleep $DELAI
1841    else
1842      \rm out_rsync
1843      break
1844    fi
1845    (( i = i + 1 ))
1846  done
1847
1848  if [ ${status} -gt 0 ] ; then
1849      echo "IGCM_sys_ncbo : ncbo error"
1850      IGCM_debug_Exit "ncbo"
1851  fi
1852
1853  IGCM_debug_PopStack "IGCM_sys_ncbo"
1854}
1855
1856function IGCM_sys_ncdiff {
1857  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1858  if ( $DEBUG_sys ) ; then
1859    echo "IGCM_sys_ncdiff :" $@
1860  fi
1861
1862  typeset NB_ESSAI DELAI status i
1863  # number of tentative
1864  NB_ESSAI=3
1865  # time delay between tentative
1866  DELAI=2
1867
1868  i=0
1869  while [ $i -lt $NB_ESSAI ] ; do
1870    ncdiff $@ > out_rsync 2>&1
1871    status=$?
1872    if [ ${status} -gt 0 ] ; then
1873      IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"
1874      cat out_rsync
1875      \rm out_rsync
1876      IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
1877      sleep $DELAI
1878    else
1879      \rm out_rsync
1880      break
1881    fi
1882    (( i = i + 1 ))
1883  done
1884
1885  if [ ${status} -gt 0 ] ; then
1886      echo "IGCM_sys_ncdiff : ncdiff error"
1887      IGCM_debug_Exit "ncdiff"
1888  fi
1889
1890  IGCM_debug_PopStack "IGCM_sys_ncdiff"
1891}
1892
1893function IGCM_sys_ncea {
1894  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1895  if ( $DEBUG_sys ) ; then
1896    echo "IGCM_sys_ncea :" $@
1897  fi
1898
1899  typeset NB_ESSAI DELAI status i
1900  # number of tentative
1901  NB_ESSAI=3
1902  # time delay between tentative
1903  DELAI=2
1904
1905  i=0
1906  while [ $i -lt $NB_ESSAI ] ; do
1907    ncea $@ > out_rsync 2>&1
1908    status=$?
1909    if [ ${status} -gt 0 ] ; then
1910      IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"
1911      cat out_rsync
1912      \rm out_rsync
1913      IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
1914      sleep $DELAI
1915    else
1916      \rm out_rsync
1917      break
1918    fi
1919    (( i = i + 1 ))
1920  done
1921
1922  if [ ${status} -gt 0 ] ; then
1923      echo "IGCM_sys_ncea : ncea error"
1924      IGCM_debug_Exit "ncea"
1925  fi
1926
1927  IGCM_debug_PopStack "IGCM_sys_ncea"
1928}
1929
1930function IGCM_sys_ncecat {
1931  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1932  if ( $DEBUG_sys ) ; then
1933    echo "IGCM_sys_ncecat :" $@
1934  fi
1935
1936  typeset NB_ESSAI DELAI status i
1937  # number of tentative
1938  NB_ESSAI=3
1939  # time delay between tentative
1940  DELAI=2
1941
1942  i=0
1943  while [ $i -lt $NB_ESSAI ] ; do
1944    ncecat $@ > out_rsync 2>&1
1945    status=$?
1946    if [ ${status} -gt 0 ] ; then
1947      IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"
1948      cat out_rsync
1949      \rm out_rsync
1950      IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
1951      sleep $DELAI
1952    else
1953      \rm out_rsync
1954      break
1955    fi
1956    (( i = i + 1 ))
1957  done
1958
1959  if [ ${status} -gt 0 ] ; then
1960      echo "IGCM_sys_ncecat : ncecat error"
1961      IGCM_debug_Exit "ncecat"
1962  fi
1963
1964  IGCM_debug_PopStack "IGCM_sys_ncecat"
1965}
1966
1967function IGCM_sys_ncflint {
1968  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1969  if ( $DEBUG_sys ) ; then
1970    echo "IGCM_sys_ncflint :" $@
1971  fi
1972
1973  typeset NB_ESSAI DELAI status i
1974  # number of tentative
1975  NB_ESSAI=3
1976  # time delay between tentative
1977  DELAI=2
1978
1979  i=0
1980  while [ $i -lt $NB_ESSAI ] ; do
1981    ncflint $@ > out_rsync 2>&1
1982    status=$?
1983    if [ ${status} -gt 0 ] ; then
1984      IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"
1985      cat out_rsync
1986      \rm out_rsync
1987      IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
1988      sleep $DELAI
1989    else
1990      \rm out_rsync
1991      break
1992    fi
1993    (( i = i + 1 ))
1994  done
1995
1996  if [ ${status} -gt 0 ] ; then
1997      echo "IGCM_sys_ncflint : ncflint error"
1998      IGCM_debug_Exit "ncflint"
1999  fi
2000
2001  IGCM_debug_PopStack "IGCM_sys_ncflint"
2002}
2003
2004function IGCM_sys_ncks {
2005  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
2006  if ( $DEBUG_sys ) ; then
2007    echo "IGCM_sys_ncks :" $@
2008  fi
2009
2010  typeset NB_ESSAI DELAI status i
2011  # number of tentative
2012  NB_ESSAI=3
2013  # time delay between tentative
2014  DELAI=2
2015
2016  i=0
2017  while [ $i -lt $NB_ESSAI ] ; do
2018    ncks $@ > out_rsync 2>&1
2019    status=$?
2020    if [ ${status} -gt 0 ] ; then
2021      IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"
2022      cat out_rsync
2023      \rm out_rsync
2024      IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2025      sleep $DELAI
2026    else
2027      \rm out_rsync
2028      break
2029    fi
2030    (( i = i + 1 ))
2031  done
2032
2033  if [ ${status} -gt 0 ] ; then
2034      echo "IGCM_sys_ncks : ncks error"
2035      IGCM_debug_Exit "ncks"
2036  fi
2037
2038  IGCM_debug_PopStack "IGCM_sys_ncks"
2039}
2040
2041function IGCM_sys_ncpdq {
2042  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
2043  if ( $DEBUG_sys ) ; then
2044    echo "IGCM_sys_ncpdq :" $@
2045  fi
2046
2047  typeset NB_ESSAI DELAI status i
2048  # number of tentative
2049  NB_ESSAI=3
2050  # time delay between tentative
2051  DELAI=2
2052
2053  i=0
2054  while [ $i -lt $NB_ESSAI ] ; do
2055    ncpdq $@ > out_rsync 2>&1
2056    status=$?
2057    if [ ${status} -gt 0 ] ; then
2058      IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"
2059      cat out_rsync
2060      \rm out_rsync
2061      IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2062      sleep $DELAI
2063    else
2064      \rm out_rsync
2065      break
2066    fi
2067    (( i = i + 1 ))
2068  done
2069
2070  if [ ${status} -gt 0 ] ; then
2071      echo "IGCM_sys_ncpdq : ncpdq error"
2072      IGCM_debug_Exit "ncpdq"
2073  fi
2074
2075  IGCM_debug_PopStack "IGCM_sys_ncpdq"
2076}
2077
2078function IGCM_sys_ncra {
2079  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
2080  if ( $DEBUG_sys ) ; then
2081    echo "IGCM_sys_ncra :" $@
2082  fi
2083
2084  typeset NB_ESSAI DELAI status i
2085  # number of tentative
2086  NB_ESSAI=3
2087  # time delay between tentative
2088  DELAI=2
2089
2090  i=0
2091  while [ $i -lt $NB_ESSAI ] ; do
2092    ncra $@ > out_rsync 2>&1
2093    status=$?
2094    if [ ${status} -gt 0 ] ; then
2095      IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"
2096      cat out_rsync
2097      \rm out_rsync
2098      IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2099      sleep $DELAI
2100    else
2101      \rm out_rsync
2102      break
2103    fi
2104    (( i = i + 1 ))
2105  done
2106
2107  if [ ${status} -gt 0 ] ; then
2108      echo "IGCM_sys_ncra : ncra error"
2109      IGCM_debug_Exit "ncra"
2110  fi
2111
2112  IGCM_debug_PopStack "IGCM_sys_ncra"
2113}
2114
2115function IGCM_sys_ncrcat {
2116  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
2117  if ( $DEBUG_sys ) ; then
2118    echo "IGCM_sys_ncrcat :" $@
2119  fi
2120
2121  typeset NB_ESSAI DELAI status i
2122  # number of tentative
2123  NB_ESSAI=3
2124  # time delay between tentative
2125  DELAI=2
2126
2127  i=0
2128  while [ $i -lt $NB_ESSAI ] ; do
2129    ncrcat $@ > out_rsync 2>&1
2130    status=$?
2131    if [ ${status} -gt 0 ] ; then
2132      IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"
2133      cat out_rsync
2134      \rm out_rsync
2135      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2136      sleep $DELAI
2137    else
2138      \rm out_rsync
2139      break
2140    fi
2141    (( i = i + 1 ))
2142  done
2143
2144  if [ ${status} -gt 0 ] ; then
2145      echo "IGCM_sys_ncrcat : ncrcat error"
2146      #IGCM_debug_Exit "ncrcat"
2147  fi
2148
2149  IGCM_debug_PopStack "IGCM_sys_ncrcat"
2150}
2151
2152function IGCM_sys_ncrename {
2153  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
2154  if ( $DEBUG_sys ) ; then
2155    echo "IGCM_sys_ncrename :" $@
2156  fi
2157
2158  typeset NB_ESSAI DELAI status i
2159  # number of tentative
2160  NB_ESSAI=3
2161  # time delay between tentative
2162  DELAI=2
2163
2164  i=0
2165  while [ $i -lt $NB_ESSAI ] ; do
2166    ncrename $@ > out_rsync 2>&1
2167    status=$?
2168    if [ ${status} -gt 0 ] ; then
2169      IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"
2170      cat out_rsync
2171      \rm out_rsync
2172      IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2173      sleep $DELAI
2174    else
2175      \rm out_rsync
2176      break
2177    fi
2178    (( i = i + 1 ))
2179  done
2180
2181  if [ ${status} -gt 0 ] ; then
2182      echo "IGCM_sys_ncrename : ncrename error"
2183      IGCM_debug_Exit "ncrename"
2184  fi
2185
2186  IGCM_debug_PopStack "IGCM_sys_ncrename"
2187}
2188
2189function IGCM_sys_ncwa {
2190  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
2191  if ( $DEBUG_sys ) ; then
2192    echo "IGCM_sys_ncwa :" $@
2193  fi
2194
2195  typeset NB_ESSAI DELAI status i
2196  # number of tentative
2197  NB_ESSAI=3
2198  # time delay between tentative
2199  DELAI=2
2200
2201  i=0
2202  while [ $i -lt $NB_ESSAI ] ; do
2203    ncwa $@ > out_rsync 2>&1
2204    status=$?
2205    if [ ${status} -gt 0 ] ; then
2206      IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"
2207      cat out_rsync
2208      \rm out_rsync
2209      IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
2210      sleep $DELAI
2211    else
2212      \rm out_rsync
2213      break
2214    fi
2215    (( i = i + 1 ))
2216  done
2217
2218  if [ ${status} -gt 0 ] ; then
2219      echo "IGCM_sys_ncwa : ncwa error"
2220      IGCM_debug_Exit "ncwa"
2221  fi
2222
2223  IGCM_debug_PopStack "IGCM_sys_ncwa"
2224}
2225
2226##############################################################
2227# CDO OPERATOR
2228
2229function IGCM_sys_cdo {
2230  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
2231  if ( $DEBUG_sys ) ; then
2232    echo "IGCM_sys_cdo :" $@
2233  fi
2234
2235  typeset status
2236
2237  \cdo $@ > out_rsync 2>&1
2238  status=$?
2239  if [ ${status} -gt 0 ] ; then
2240    echo "IGCM_sys_cdo : error code ${status}"
2241    cat out_rsync
2242    \rm out_rsync
2243    IGCM_debug_PopStack "IGCM_sys_cdo"
2244    return 1
2245  else
2246    IGCM_debug_PopStack "IGCM_sys_cdo"
2247    return 0
2248  fi
2249
2250  IGCM_debug_PopStack "IGCM_sys_cdo"
2251}
Note: See TracBrowser for help on using the repository browser.