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

Last change on this file since 645 was 645, checked in by sdipsl, 12 years ago
  • IGCM_sys_CountFileArchive must be a quiet function so as not to disturb tests making us of it
  • Property svn:keywords set to Revision Author Date
File size: 36.5 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  MASTER=${MASTER:=$( hostname )}
67# $username ou whoami
68typeset  LOGIN=${LOGIN:=$( whoami )}
69
70#D-
71#D-#==================================================
72#D-Program used in libIGCM
73#D-#==================================================
74
75# rsync with path
76typeset -r RSYNC=/usr/bin/rsync
77# RSYNC_opt args to rsync
78typeset -r RSYNC_opt="-va"
79
80#====================================================
81# Set environment tools (ferret, nco, cdo)
82#====================================================
83. /home/users/brock/.atlas_env_asterix_ksh
84
85#====================================================
86# Set lf95 environment
87#====================================================
88. /usr/local/install/lf6481/bash_laheyfort_setup
89
90#====================================================
91# Host specific DIRECTORIES
92#====================================================
93
94#====================================================
95#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
96typeset -r R_EXE="${MODIPSL}/bin"
97
98#====================================================
99#- SCRATCHDIR (=> ${R_DONNEES})
100if [ X${PBS_O_WORKDIR} != X ] ; then
101    typeset -r SCRATCHDIR=/scratch/$PBS_O_LOGNAME.$PBS_JOBID
102#==${WORKDIR}
103# cf /usr/Local/Env sur obelix
104else
105    typeset -r SCRATCHDIR=/tmp
106fi
107#FOR DEBUG RUN :
108#typeset -r SCRATCHDIR=/home/scratch01/${LOGIN}
109
110#====================================================
111#- SUBMIT_DIR : submission dir
112if [ X${PBS_O_WORKDIR} != X ] ; then
113    typeset -r SUBMIT_DIR=${SUBMIT_DIR:=${PBS_O_WORKDIR}}
114else
115    typeset -r SUBMIT_DIR=${SUBMIT_DIR:=${PWD}}
116fi
117#====================================================
118#- ARCHIVE
119typeset -r ARCHIVE=${ARCHIVE:=/home/scratch01/${LOGIN}}
120
121#====================================================
122#- libIGCM_POST
123typeset -r libIGCM_POST=${libIGCM}
124
125#====================================================
126#- IN
127typeset -r R_IN=${R_IN:=/home/orchidee01/mmancip/IGCM}
128
129#====================================================
130#- OUT
131typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
132
133#====================================================
134#- OUT_POST
135typeset -r R_OUT_POST=${R_OUT}
136
137#====================================================
138#- RUN_DIR_PATH : Temporary working directory (=> TMP)
139typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/tmp$$}
140
141#====================================================
142#- BIG_DIR : BIG_DIR to store files waiting for rebuild
143typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD}
144
145#====================================================
146#- HOST_MPIRUN_COMMAND
147typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"}
148
149#=========================================================
150#- Add "time" before mpirun command
151MPIRUN_COMMAND="time "${MPIRUN_COMMAND}
152echo ${MPIRUN_COMMAND}
153
154#====================================================
155#- Max number of arguments passed to nco operator or demigration command
156UNIX_MAX_LIMIT=360
157
158#D-#==================================================
159#D-function IGCM_sys_RshMaster
160#D-* Purpose: Just a fake command to wrapp
161#D-           IGCM_card call in post-treatment
162#D-           Ulam do not see brodie filesystem
163#D-           Cesium do not see all mercure filesystem
164#D-           That's why we need this hack.
165#D-* Examples:
166#D-
167function IGCM_sys_RshMaster {
168    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
169
170    ssh obelix3 exec /bin/ksh  <<-EOF
171    export libIGCM=${libIGCM}
172    export DEBUG_debug=${DEBUG_debug}
173    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
174    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
175    ${@}
176EOF
177    if [ $? -gt 0 ] ; then
178        echo "IGCM_sys_RshMaster : erreur."
179        IGCM_debug_Exit "IGCM_sys_RshMaster"
180    fi
181    IGCM_debug_PopStack "IGCM_sys_RshMaster"
182}
183
184#D-#==================================================
185#D-function IGCM_sys_RshArchive
186#D-* Purpose: Archive rsh command
187#D-* Examples:
188#D-
189function IGCM_sys_RshArchive {
190    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
191    /bin/ksh <<-EOF
192    ${@}
193EOF
194    if [ $? -gt 0 ] ; then
195        echo "IGCM_sys_RshArchive : erreur."
196        IGCM_debug_Exit "IGCM_sys_RshArchive"
197    fi
198    IGCM_debug_PopStack "IGCM_sys_RshArchive"
199}
200
201#D-#==================================================
202#D-function IGCM_sys_RshPost
203#D-* Purpose: Post-process rsh command
204#D-* Examples:
205#D-
206(( RshPNum = 0 ))
207function IGCM_sys_RshPost {
208    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
209    if ( $DEBUG_sys ) ; then
210        echo "IGCM_sys_RshPost :" $@
211    fi
212    ssh obelix3 exec /bin/ksh $@ > out_RshPost.${RshPNum}
213    if [ $? -gt 0 ] ; then
214        echo "IGCM_sys_RshPost : erreur."
215        IGCM_debug_Exit "IGCM_sys_RshPost"
216    fi
217    (( RshPNum = RshPNum + 1 ))
218    IGCM_debug_PopStack "IGCM_sys_RshPost"
219}
220
221#D-#==================================================
222#D-function IGCM_sys_SendMail
223#D-* Purpose: Send mail when simulation is over
224#D-* Examples:
225#D-
226function IGCM_sys_SendMail {
227    IGCM_debug_PushStack "IGCM_sys_SendMail" $@
228    if ( $DEBUG_sys ) ; then
229        echo "IGCM_sys_SendMail :" $@
230    fi
231
232    if ( ${ExitFlag} ) ; then
233        status=failed
234    else
235        status=completed
236    fi
237    cat  << END_MAIL > job_end.mail
238Dear ${LOGIN},
239
240  Simulation ${config_UserChoices_JobName} ${status} on supercomputer `hostname`.
241  Job started : ${PeriodDateBegin}
242  Job ended   : ${PeriodDateEnd}
243  Output files are available in ${R_SAVE}
244  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
245END_MAIL
246
247    if [ ! -z ${config_UserChoices_MailName} ] ; then
248        mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail
249    elif [ -f ~/.forward ] ; then
250        mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
251    fi
252
253    if [ $? -gt 0 ] ; then
254        echo "IGCM_sys_SendMail : erreur."
255        IGCM_debug_Exit "IGCM_sys_SendMail"
256    fi
257    IGCM_debug_PopStack "IGCM_sys_SendMail"
258}
259
260#D-#==================================================
261#D-function IGCM_sys_Mkdir
262#D-* Purpose: Master locale mkdir command
263#D-* Examples:
264#D-
265function IGCM_sys_Mkdir {
266    IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
267    if ( $DEBUG_sys ) ; then
268        echo "IGCM_sys_Mkdir :" $@
269    fi
270    if [ ! -d ${1} ]; then
271        \mkdir -p $1
272        if [ $? -gt 0 ] ; then
273            echo "IGCM_sys_Mkdir : erreur."
274            IGCM_debug_Exit "IGCM_sys_Mkdir"
275        fi
276    fi
277    # vérification :
278    if [ ! -d ${1} ] ; then
279        echo "IGCM_sys_Mkdir : erreur."
280        IGCM_debug_Exit "IGCM_sys_Mkdir"
281    fi
282    IGCM_debug_PopStack "IGCM_sys_Mkdir"
283}
284
285#D-#==================================================
286#D-function IGCM_sys_MkdirArchive
287#D-* Purpose: Mkdir on Archive
288#D-* Examples:
289#D-
290function IGCM_sys_MkdirArchive {
291    IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
292    if ( $DEBUG_sys ) ; then
293        echo "IGCM_sys_MkdirArchive :" $@
294    fi
295    #- creation de repertoire sur le serveur fichier
296    if [ ! -d ${1} ]; then 
297        \mkdir -p $1
298        if [ $? -gt 0 ] ; then
299            echo "IGCM_sys_MkdirArchive : erreur."
300            IGCM_debug_Exit "IGCM_sys_MkdirArchive"
301        fi
302    fi
303    IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
304}
305
306#D-#==================================================
307#D-function IGCM_sys_MkdirWork
308#D-* Purpose: Mkdir on Work
309#D-* Examples:
310#D-
311function IGCM_sys_MkdirWork {
312    IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
313    if ( $DEBUG_sys ) ; then
314        echo "IGCM_sys_MkdirWork :" $@
315    fi
316    #- creation de repertoire sur le serveur fichier
317    if [ ! -d ${1} ]; then 
318        \mkdir -p $1
319        if [ $? -gt 0 ] ; then
320            echo "IGCM_sys_MkdirWork : erreur."
321            IGCM_debug_Exit "IGCM_sys_MkdirWork"
322        fi
323    fi
324    IGCM_debug_PopStack "IGCM_sys_MkdirWork"
325}
326
327#D-#==================================================
328#D-function IGCM_sys_Cd
329#D-* Purpose: master cd command
330#D-* Examples:
331#D-
332function IGCM_sys_Cd {
333    IGCM_debug_PushStack "IGCM_sys_Cd" $@
334    if ( $DEBUG_sys ) ; then
335        echo "IGCM_sys_Cd :" $@
336    fi
337    \cd $1
338    if [ $? -gt 0 ] ; then
339        echo "IGCM_sys_Cd : erreur."
340        IGCM_debug_Exit "IGCM_sys_Cd"
341    fi
342    IGCM_debug_PopStack "IGCM_sys_Cd"
343}
344
345#D-#==================================================
346#D-function IGCM_sys_Chmod
347#D-* Purpose: Chmod
348#D-* Examples:
349#D-
350function IGCM_sys_Chmod {
351    IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
352    if ( $DEBUG_sys ) ; then
353        echo "IGCM_sys_Chmod :" $@
354    fi
355    if [ $DRYRUN -le 1 ]; then
356        \chmod $@
357        if [ $? -gt 0 ] ; then
358            echo "IGCM_sys_Chmod : erreur."
359            IGCM_debug_Exit "IGCM_sys_Chmod"
360        fi
361    else
362        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
363    fi
364    IGCM_debug_PopStack "IGCM_sys_Chmod"
365}
366
367#D-#==================================================
368#D-function IGCM_sys_FileSize
369#D-* Purpose: Filesize
370#D-* Examples:
371#D-
372function IGCM_sys_FileSize {
373    IGCM_debug_PushStack "IGCM_sys_FileSize" $@
374
375    typeset sizeF
376    set +A sizeF -- $( ls -la ${1} )
377    if [ $? -gt 0 ] ; then
378        IGCM_debug_Exit "IGCM_sys_FileSize"
379    fi
380    eval ${2}=${sizeF[4]}
381
382    IGCM_debug_PopStack "IGCM_sys_FileSize"
383}
384
385#D-#==================================================
386#D-function IGCM_sys_TestDir
387#D-* Purpose: Test Directory that must exists
388#D-* Examples:
389#D-
390function IGCM_sys_TestDir {
391    IGCM_debug_PushStack "IGCM_sys_TestDir" $@
392    if ( $DEBUG_sys ) ; then
393        echo "IGCM_sys_TestDir :" $@
394    fi
395    typeset ExistFlag
396    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
397    IGCM_debug_PopStack "IGCM_sys_TestDir"
398
399    return ${ExistFlag}
400}
401
402#D-#==================================================
403#D-function IGCM_sys_TestDirArchive
404#D-* Purpose: Test Directory that must exists on Archive
405#D-* Examples:
406#D-
407function IGCM_sys_TestDirArchive {
408    IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
409    if ( $DEBUG_sys ) ; then
410        echo "IGCM_sys_TestDirArchive :" $@
411    fi
412    typeset ExistFlag
413    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
414    IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
415
416    return ${ExistFlag}
417}
418
419#D-#==================================================
420#D-function IGCM_sys_TestFileArchive
421#D-* Purpose: Test file that must NOT EXISTS on Archive
422#D-* Examples:
423#D-
424function IGCM_sys_TestFileArchive {
425    IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
426    typeset ExistFlag
427    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
428    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
429
430    return ${ExistFlag}
431}
432
433#D-#==================================================
434#D-function IGCM_sys_CountFileArchive
435#D-* Purpose: Count files on Archive filesystem
436#D-* Examples:
437#D-
438function IGCM_sys_CountFileArchive {
439    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
440    ls ${@} 2>/dev/null | wc -l
441    if [ $? -gt 0 ] ; then
442        echo "IGCM_sys_CountFileArchive : erreur."
443    fi
444    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
445}
446
447#D-#==================================================
448#D-function IGCM_sys_Tree
449#D-* Purpose: Tree directories with files on ${ARCHIVE}
450#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
451#D-
452function IGCM_sys_Tree {
453    IGCM_debug_PushStack "IGCM_sys_Tree" $@
454    if ( $DEBUG_sys ) ; then
455        echo "IGCM_sys_Tree :" $@
456    fi
457
458    \tree -f $@
459
460    IGCM_debug_PopStack "IGCM_sys_Tree"
461}
462
463#D-#==================================================
464#D-function IGCM_sys_Tar
465#D-* Purpose: master un-tar command
466#D-* Examples:
467#D-
468function IGCM_sys_Tar {
469    IGCM_debug_PushStack "IGCM_sys_Tar" $@
470    if ( $DEBUG_sys ) ; then
471        echo "IGCM_sys_Tar :" $@
472    fi
473    \tar cf $@
474    if [ $? -gt 0 ] ; then
475        echo "IGCM_sys_Tar : erreur."
476        IGCM_debug_Exit "IGCM_sys_Tar"
477    fi
478
479    IGCM_debug_PopStack "IGCM_sys_Tar"
480}
481
482#D-#==================================================
483#D-function IGCM_sys_UnTar
484#D-* Purpose: master un-tar command
485#D-* Examples:
486#D-
487function IGCM_sys_UnTar {
488    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
489    if ( $DEBUG_sys ) ; then
490        echo "IGCM_sys_UnTar :" $@
491    fi
492    \tar xvf $1
493    if [ $? -gt 0 ] ; then
494        echo "IGCM_sys_UnTar : erreur."
495        IGCM_debug_Exit "IGCM_sys_UnTar"
496    fi
497    IGCM_debug_PopStack "IGCM_sys_UnTar"
498}
499
500#D-#==================================================
501#D-function IGCM_sys_Qsub
502#D-* Purpose: Qsub new job
503#D-* Examples:
504#D-
505function IGCM_sys_Qsub {
506    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
507    if ( $DEBUG_sys ) ; then
508        echo "IGCM_sys_Qsub :" $@
509    fi
510#    /usr/local/bin/qsub -q short -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1
511    /usr/local/bin/qsub -q medium -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1
512    if [ $? -gt 0 ] ; then
513        echo "IGCM_sys_Qsub : erreur."
514        IGCM_debug_Exit "IGCM_sys_Qsub"
515    fi
516    IGCM_debug_PopStack "IGCM_sys_Qsub"
517}
518
519#D-#==================================================
520#D-function IGCM_sys_QsubPost
521#D-* Purpose: Qsub new job on scalaire
522#D-* Examples:
523#D-
524function IGCM_sys_QsubPost {
525    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
526    if ( $DEBUG_sys ) ; then
527        echo "IGCM_sys_QsubPost :" $@
528    fi
529    /usr/local/bin/qsub -q medium -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM_POST}/$1.job -v ${listVarEnv}
530    if [ $? -gt 0 ] ; then
531        echo "IGCM_sys_QsubPost : erreur " $@
532        IGCM_debug_Exit "IGCM_sys_QsubPost"
533    fi
534    IGCM_debug_PopStack "IGCM_sys_QsubPost"
535}
536
537#D-*************************
538#D- File transfer functions
539#D-*************************
540#D-
541
542#D-#==================================================
543#D-function IGCM_sys_Rsync_out
544#D-* Purpose: treat return val of rsync
545#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
546#D-  Error values and explanations can depend on your system version.
547function IGCM_sys_Rsync_out {
548    RET=$1
549    if [ ! $RET ] ; then
550        echo "rsync error !"
551    fi
552
553    if [ $MYLANG = "fr" ]; then
554        case $RET in
555            0)  return ;;
556            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
557                echo "Erreur de syntaxe ou d'utilisation."
558                return;;
559            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
560                echo "Incompatibilité de protocole."
561                return;;
562            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
563                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
564                echo "répertoires"
565                return;;
566            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
567                echo "Action demandée non supportée : une tentative de manipulation de"
568                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
569                echo "été faite ; ou une option qui est supportée par le  client  mais"
570                echo "pas par le serveur a été spécifiée."
571                return;;
572            10) echo "Erreur de rsync ; RERR_SOCKETIO"
573                echo "Erreur dans le socket d'entrée sortie"
574                return;;
575            11) echo "Erreur de rsync ; RERR_FILEIO"
576                echo "Erreur d'entrée sortie fichier"
577                return;;
578            12) echo "Erreur de rsync ; RERR_STREAMIO"
579                echo "Erreur dans flux de donnée du protocole rsync"
580                return;;
581            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
582                echo "Erreur avec les diagnostics du programme"
583                return;;
584            14) echo "Erreur de rsync ; RERR_IPC"
585                echo "Erreur dans le code IPC"
586                return;;
587            20) echo "Erreur de rsync ; RERR_SIGNAL"
588                echo "SIGUSR1 ou SIGINT reçu"
589                return;;
590            21) echo "Erreur de rsync ; RERR_WAITCHILD"
591                echo "Une erreur retournée par waitpid()"
592                return;;
593            22) echo "Erreur de rsync ; RERR_MALLOC"
594                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
595                return;;
596            23) echo ""
597                echo "Erreur fichier inexistant"
598                return;;
599            30) echo "Erreur de rsync ; RERR_TIMEOUT"
600                echo "Temps d'attente écoulé dans l'envoi/réception de données"
601                return;;
602            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
603                return;;
604        esac
605    elif [ $MYLANG = "en" ] ; then
606        case $RET in
607            0)  return;;               
608            1)  echo "rsync error : Syntax or usage error "
609                return;;
610            2)  echo "rsync error : Protocol incompatibility "
611                return;;
612            3)  echo "rsync error : Errors selecting input/output files, dirs"
613                return;;
614            4)  echo "rsync error : Requested action not supported: an attempt"
615                echo "was made to manipulate 64-bit files on a platform that cannot support"
616                echo "them; or an option was specified that is supported by the client and"
617                echo "not by the server."
618                return;;
619            5)  echo "rsync error : Error starting client-server protocol"
620                return;;
621            10) echo "rsync error : Error in socket I/O "
622                return;;
623            11) echo "rsync error : Error in file I/O "
624                return;;
625            12) echo "rsync error : Error in rsync protocol data stream "
626                return;;
627            13) echo "rsync error : Errors with program diagnostics "
628                return;;
629            14) echo "rsync error : Error in IPC code "
630                return;;
631            20) echo "rsync error : Received SIGUSR1 or SIGINT "
632                return;;
633            21) echo "rsync error : Some error returned by waitpid() "
634                return;;
635            22) echo "rsync error : Error allocating core memory buffers "
636                return;;
637            23) echo "rsync error : Partial transfer due to error"
638                return;;
639            24) echo "rsync error : Partial transfer due to vanished source files"
640                return;;
641            30) echo "rsync error : Timeout in data send/receive "
642                return;;
643            *)  echo "rsync error : return code of rsync unknown :" $RET
644                return;;
645        esac
646    else
647        echo "unknown language $MYLANG."
648        return
649    fi
650}
651   
652#D-#==================================================
653#D-function IGCM_sys_Cp
654#D-* Purpose: generic cp
655#D-* Examples:
656#D-
657function IGCM_sys_Cp {
658    IGCM_debug_PushStack "IGCM_sys_Cp" $@
659    if ( $DEBUG_sys ) ; then
660        echo "IGCM_sys_Cp :" $@
661    fi
662
663    typeset RET
664
665    echo cp --preserve=timestamps $@ > out_rsync 2>&1
666    \cp --preserve=timestamps $@ >> out_rsync 2>&1
667    RET=$?
668   
669    if [ ${RET} -gt 0 ] ; then
670        echo "IGCM_sys_Cp : error."
671        cat out_rsync
672        IGCM_debug_Exit "IGCM_sys_Cp"
673    else
674        rm out_rsync
675    fi
676    IGCM_debug_PopStack "IGCM_sys_Cp"
677}
678
679#D-#==================================================
680#D-function IGCM_sys_Rm
681#D-* Purpose: generic rm
682#D-* Examples:
683#D-
684function IGCM_sys_Rm {
685    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
686    if ( $DEBUG_sys ) ; then
687        echo "IGCM_sys_Rm :" $@
688    fi
689
690    typeset RET
691
692    echo rm $@ > out_rsync 2>&1
693    \rm $@ >> out_rsync 2>&1
694    RET=$?
695   
696    if [ ${RET} -gt 0 ] ; then
697        echo "IGCM_sys_Rm : error."
698        cat out_rsync
699        IGCM_debug_Exit "IGCM_sys_Rm"
700    else
701        rm out_rsync
702    fi
703    IGCM_debug_PopStack "IGCM_sys_Rm"
704}
705
706#D-#==================================================
707#D-function IGCM_sys_RmRunDir
708#D-* Purpose: rm tmpdir (dummy function most of the time batch
709#D-                      scheduler will do the job)
710#D-* Examples:
711#D-
712function IGCM_sys_RmRunDir {
713    IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
714    if ( $DEBUG_sys ) ; then
715        echo "IGCM_sys_RmRunDir :" $@
716    fi
717
718    typeset RET
719
720    echo rm $@ > out_rsync 2>&1
721    \rm $@ >> out_rsync 2>&1
722    RET=$?
723
724    if [ ${RET} -gt 0 ] ; then
725        echo "IGCM_sys_RmRunDir : error."
726        cat out_rsync
727        IGCM_debug_Exit "IGCM_sys_RmRunDir"
728    fi
729
730    IGCM_debug_PopStack "IGCM_sys_RmRunDir"
731}
732
733#D-#==================================================
734#D-function IGCM_sys_Mv
735#D-* Purpose: generic move
736#D-* Examples:
737#D-
738function IGCM_sys_Mv {
739    IGCM_debug_PushStack "IGCM_sys_Mv" $@
740    if ( $DEBUG_sys ) ; then
741        echo "IGCM_sys_Mv :" $@
742    fi
743
744    if [ $DRYRUN = 0 ]; then
745
746        typeset RET
747           
748        echo mv $@ > out_rsync 2>&1
749        \mv $@ >> out_rsync 2>&1
750        RET=$?
751   
752        if [ ${RET} -gt 0 ] ; then
753            echo "IGCM_sys_Mv : error in mv."
754            cat out_rsync
755            IGCM_debug_Exit "IGCM_sys_Mv"
756        else
757            rm out_rsync
758        fi
759    else
760        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
761    fi
762
763    IGCM_debug_PopStack "IGCM_sys_Mv"
764}
765
766#D-#==================================================
767#D-function IGCM_sys_Put_Dir
768#D-* Purpose: Copy a complete directory on $(ARCHIVE)
769#D-* Examples:
770#D-
771function IGCM_sys_Put_Dir {
772    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
773    if ( $DEBUG_sys ) ; then
774        echo "IGCM_sys_Put_Dir :" $@
775    fi
776    if [ $DRYRUN = 0 ]; then
777        if [ ! -d ${1} ] ; then
778            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
779            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
780            return
781        fi
782
783        typeset RET
784
785        # Only if we use rsync
786        #IGCM_sys_TestDirArchive $( dirname $2 )
787        #
788        #USUAL WAY
789        \cp -R $1 $2 > out_rsync 2>&1
790        RET=$?
791
792        if [ ${RET} -gt 0 ] ; then
793            echo "IGCM_sys_Put_Dir : error."
794            cat out_rsync
795            IGCM_debug_Exit "IGCM_sys_Put_Dir"
796        else
797            rm out_rsync
798        fi
799    else
800        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
801    fi
802    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
803}
804
805#D-#==================================================
806#D-function IGCM_sys_Get_Dir
807#D-* Purpose: Copy a complete directory from $(ARCHIVE)
808#D-* Examples:
809#D-
810function IGCM_sys_Get_Dir {
811    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
812    if ( $DEBUG_sys ) ; then
813        echo "IGCM_sys_Get_Dir :" $@
814    fi
815    if [ $DRYRUN = 0 ]; then
816        if [ ! -d ${1} ] ; then
817            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
818            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
819            return
820        fi
821
822        typeset RET
823
824        #USUAL WAY
825        \cp -R $1 $2 > out_rsync 2>&1
826        RET=$?
827
828        if [ ${RET} -gt 0 ] ; then
829            echo "IGCM_sys_Get_Dir : error."
830            cat out_rsync
831            IGCM_debug_Exit "IGCM_sys_Get_Dir"
832        else
833            rm out_rsync
834        fi
835    else
836        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
837    fi
838    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
839}
840
841#D-#==================================================
842#D-function IGCM_sys_Get_Master
843#D-* Purpose: Copy a complete directory from MASTER filesystem
844#D-* Examples:
845#D-
846function IGCM_sys_Get_Master {
847    IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
848    if ( $DEBUG_sys ) ; then
849        echo "IGCM_sys_Get_Master :" $@
850    fi
851    if [ $DRYRUN = 0 ]; then
852        if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
853            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
854            IGCM_debug_PopStack "IGCM_sys_Get_Master"
855            return
856        fi
857
858        typeset RET
859
860        #USUAL WAY
861        cp -R $1 $2 > out_rsync 2>&1
862        RET=$?
863
864        if [ ${RET} -gt 0 ] ; then
865            echo "IGCM_sys_Get_Master : error."
866            cat out_rsync
867            IGCM_debug_Exit "IGCM_sys_Get_Master"
868        else
869            rm out_rsync
870        fi
871    else
872        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
873    fi
874    IGCM_debug_PopStack "IGCM_sys_Get_Master"
875}
876
877#D-#==================================================
878#D-function IGCM_sys_Put_Rest
879#D-* Purpose: Put computied restarts on $(ARCHIVE).
880#D-           File and target directory must exist.
881#D-* Examples:
882#D-
883function IGCM_sys_Put_Rest {
884    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
885    if ( $DEBUG_sys ) ; then
886        echo "IGCM_sys_Put_Rest :" $@
887    fi
888    if [ $DRYRUN = 0 ]; then
889
890        IGCM_sys_TestDirArchive $( dirname $2 )
891
892        if [ ! -f ${1} ] ; then
893            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
894            IGCM_debug_Exit "IGCM_sys_Put_Rest"
895        fi
896        if [ X${JobType} = XRUN ] ; then
897            IGCM_sys_Chmod 444 ${1}
898        fi
899
900        typeset RET
901
902        echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1
903        ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1
904        RET=$?
905        IGCM_sys_Rsync_out $RET
906
907        ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
908        (( RET=RET+$? ))
909
910        if [ ${RET} -gt 0 ] ; then
911            echo "IGCM_sys_Put_Rest : error."
912            cat out_rsync
913            IGCM_debug_Exit "IGCM_sys_Put_Rest"
914        else
915            rm out_rsync
916        fi
917    else
918        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
919    fi
920    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
921}
922
923#D-#==================================================
924#D-function IGCM_sys_Put_Out
925#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
926#D-* Examples:
927#D-
928function IGCM_sys_Put_Out {
929    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
930    if ( $DEBUG_sys ) ; then
931        echo "IGCM_sys_Put_Out :" $@
932    fi
933    if [ $DRYRUN = 0 ]; then
934        if [ -f ${1} ] ; then
935            if [ ! -d $( dirname $2 ) ] ; then
936                IGCM_sys_MkdirArchive $( dirname $2 )
937            fi
938        else
939            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
940            IGCM_debug_PopStack "IGCM_sys_Put_Out"
941            return 1
942        fi
943
944        typeset RET
945        #
946        if [ X${JobType} = XRUN ] ; then
947            if [ X${3} = X ] ; then
948                IGCM_sys_Chmod 444 ${1}
949            fi
950        fi
951        #
952
953        echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1
954        ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1
955        RET=$?
956        IGCM_sys_Rsync_out $RET
957
958        ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
959        (( RET=RET+$? ))
960
961        if [ ${RET} -gt 0 ] ; then
962            echo "IGCM_sys_Put_Out : error."
963            cat out_rsync
964            IGCM_debug_Exit "IGCM_sys_Put_Out"
965        else
966            rm out_rsync
967        fi
968    else
969        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
970    fi
971    IGCM_debug_PopStack "IGCM_sys_Put_Out"
972    return 0
973}
974
975#D-#==================================================
976#D-function IGCM_sys_Get
977#D-* Purpose: Get a file from ${ARCHIVE}
978#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
979#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
980function IGCM_sys_Get {
981    IGCM_debug_PushStack "IGCM_sys_Get" $@
982
983    typeset DEST RET dm_liste ifile target
984
985    if ( $DEBUG_sys ) ; then
986        echo "IGCM_sys_Get :" $@
987    fi
988    if [ $DRYRUN -le 2 ]; then
989        if [ X${1} = X'/l' ] ; then
990            # test if the first file is present in the old computation :
991            eval set +A dm_liste \${${2}}
992        else
993            dm_liste=${1}
994        fi
995        eval DEST=\${${#}}
996
997        # test if the (first) file is present in the old computation :
998        IGCM_sys_TestFileArchive ${dm_liste[0]}
999        RET=$?
1000        if [ ${RET} -gt 0 ] ; then
1001            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1002            IGCM_debug_Exit "IGCM_sys_Get"
1003            #return
1004        fi
1005
1006        (( RET=0 ))
1007        for target in ${dm_liste[*]} ; do
1008          \cp ${target} ${DEST} >> out_rsync 2>&1
1009          (( RET=RET+$? ))
1010        done
1011
1012#       echo ${RSYNC} ${RSYNC_opt} $@ > out_rsync 2>&1
1013#       ${RSYNC} ${RSYNC_opt} $@ >> out_rsync 2>&1
1014#       RET=$?
1015#       IGCM_sys_Rsync_out $RET
1016
1017#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1018#       (( RET=RET+$? ))
1019
1020        if [ ${RET} -gt 0 ] ; then
1021            echo "IGCM_sys_Get : copy error."
1022            cat out_rsync
1023            IGCM_debug_Exit "IGCM_sys_Get"
1024        else
1025            rm out_rsync
1026        fi
1027    else
1028        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1029    fi
1030    IGCM_debug_PopStack "IGCM_sys_Get"
1031}
1032
1033#D-#==================================================
1034#D-function IGCM_sys_Dods_Rm
1035#D-* Purpose: Suppress files in /tmp/DODS for simulation of internet protocole.
1036#D-* Examples:
1037#D-
1038function IGCM_sys_Dods_Rm {
1039    if ( $DEBUG_sys ) ; then
1040        echo "IGCM_sys_Dods_Rm :" $@
1041    fi
1042    return 0
1043}
1044
1045
1046#D-#==================================================
1047#D-function IGCM_sys_Dods_Cp
1048#D-* Purpose: Copy from $(ARCHIVE) files to /tmp/DODS for simulation of internet protocole.
1049#D-* Examples:
1050#D-
1051function IGCM_sys_Dods_Cp {
1052    if ( $DEBUG_sys ) ; then
1053        echo "IGCM_sys_Dods_Cp :" $@
1054    fi
1055    return 0
1056}
1057
1058#D-#==================================================
1059#D-function IGCM_sys_Put_Dods
1060#D-* Purpose: Put $(ARCHIVE) files on /tmp/DODS for simulation of internet protocole.
1061#D-* Examples:
1062#D-
1063function IGCM_sys_Put_Dods {
1064    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1065    if ( $DEBUG_sys ) ; then
1066        echo "IGCM_sys_Put_Dods :" $@
1067    fi
1068    if [ $DRYRUN = 0 ]; then
1069        RET=0
1070       
1071        if [ ${RET} -gt 0 ] ; then
1072            echo "IGCM_sys_Put_Dods : error."
1073            IGCM_debug_Exit "IGCM_sys_Put_Dods"
1074        fi
1075    else
1076        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1077    fi
1078    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1079}
1080
1081#D-#==================================================
1082#D-function IGCM_sys_GetDate_FichWork
1083#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1084#D-* Examples:
1085#D-
1086function IGCM_sys_GetDate_FichWork {
1087    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1088    if ( $DEBUG_sys ) ; then
1089        echo "IGCM_sys_GetDate_FichWork :" $@
1090    fi
1091    typeset dateF
1092    set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1093    eval ${2}=${dateF[5]}
1094
1095    # donne la date filesys d'un fichier sur la machine work
1096    IGCM_debug_PopStack "IGCM_sys_FichWork"
1097}
1098
1099#D-#==================================================
1100#D-function IGCM_sys_GetDate_FichArchive
1101#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1102#D-* Examples:
1103#D-
1104function IGCM_sys_GetDate_FichArchive {
1105    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1106    if ( $DEBUG_sys ) ; then
1107        echo "IGCM_sys_GetDate_FichArchive :" $@
1108    fi
1109    typeset dateF
1110    set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1111    eval ${2}=${dateF[5]}
1112
1113    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1114}
1115
1116##############################################################
1117# REBUILD OPERATOR
1118
1119function IGCM_sys_rebuild {
1120    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1121    if ( $DEBUG_sys ) ; then
1122        echo "IGCM_sys_rebuild :" $@
1123    fi
1124    /home/users/igcmg/rebuild/bin/rebuild -f -o $@
1125    if [ $? -gt 0 ] ; then
1126       echo "IGCM_sys_rebuild : erreur ${@}."
1127       IGCM_debug_Exit "rebuild"
1128    fi
1129
1130    IGCM_debug_PopStack "IGCM_sys_rebuild"
1131}
1132
1133##############################################################
1134# NCO OPERATOR
1135
1136function IGCM_sys_ncap2 {
1137    IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1138    if ( $DEBUG_sys ) ; then
1139        echo "IGCM_sys_ncap2 :" $@
1140    fi
1141    /usr/local/bin/ncap2 "$@"
1142    if [ $? -gt 0 ] ; then
1143       echo "IGCM_sys_ncap2 : erreur ${@}."
1144       IGCM_debug_Exit "ncap2"
1145    fi
1146
1147    IGCM_debug_PopStack "IGCM_sys_ncap2"
1148}
1149
1150function IGCM_sys_ncatted {
1151    IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1152    if ( $DEBUG_sys ) ; then
1153        echo "IGCM_sys_ncatted :" $@
1154    fi
1155    /usr/local/bin/ncatted "$@"
1156    if [ $? -gt 0 ] ; then
1157       echo "IGCM_sys_ncatted : erreur ${@}."
1158       IGCM_debug_Exit "ncatted"
1159    fi
1160
1161    IGCM_debug_PopStack "IGCM_sys_ncatted"
1162}
1163
1164function IGCM_sys_ncbo {
1165    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1166    if ( $DEBUG_sys ) ; then
1167        echo "IGCM_sys_ncbo :" $@
1168    fi
1169    /usr/local/bin/ncbo $@
1170    if [ $? -gt 0 ] ; then
1171       echo "IGCM_sys_ncbo : erreur ${@}."
1172       IGCM_debug_Exit "ncbo"
1173    fi
1174
1175    IGCM_debug_PopStack "IGCM_sys_ncbo"
1176}
1177
1178function IGCM_sys_ncdiff {
1179    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1180    if ( $DEBUG_sys ) ; then
1181        echo "IGCM_sys_ncdiff :" $@
1182    fi
1183    /usr/local/bin/ncdiff $@
1184    if [ $? -gt 0 ] ; then
1185       echo "IGCM_sys_ncdiff : erreur ${@}."
1186       IGCM_debug_Exit "ncdiff"
1187    fi
1188
1189    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1190}
1191
1192function IGCM_sys_ncea {
1193    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1194    if ( $DEBUG_sys ) ; then
1195        echo "IGCM_sys_ncea :" $@
1196    fi
1197    /usr/local/bin/ncea $@
1198    if [ $? -gt 0 ] ; then
1199       echo "IGCM_sys_ncea : erreur ${@}."
1200       IGCM_debug_Exit "ncea"
1201    fi
1202
1203    IGCM_debug_PopStack "IGCM_sys_ncea"
1204}
1205
1206function IGCM_sys_ncecat {
1207    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1208    if ( $DEBUG_sys ) ; then
1209        echo "IGCM_sys_ncecat :" $@
1210    fi
1211    /usr/local/bin/ncecat $@
1212    if [ $? -gt 0 ] ; then
1213       echo "IGCM_sys_ncecat : erreur ${@}."
1214       IGCM_debug_Exit "ncecat"
1215    fi
1216
1217    IGCM_debug_PopStack "IGCM_sys_ncecat"
1218}
1219
1220function IGCM_sys_ncflint {
1221    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1222    if ( $DEBUG_sys ) ; then
1223        echo "IGCM_sys_ncflint :" $@
1224    fi
1225    /usr/local/bin/ncflint $@
1226    if [ $? -gt 0 ] ; then
1227       echo "IGCM_sys_ncflint : erreur ${@}."
1228       IGCM_debug_Exit "ncflint"
1229    fi
1230
1231    IGCM_debug_PopStack "IGCM_sys_ncflint"
1232}
1233
1234function IGCM_sys_ncks {
1235    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1236    if ( $DEBUG_sys ) ; then
1237        echo "IGCM_sys_ncks :" $@
1238    fi
1239    /usr/local/bin/ncks $@
1240    if [ $? -gt 0 ] ; then
1241       echo "IGCM_sys_ncks : erreur ${@}."
1242       IGCM_debug_Exit "ncks"
1243    fi
1244
1245    IGCM_debug_PopStack "IGCM_sys_ncks"
1246}
1247
1248function IGCM_sys_ncpdq {
1249    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1250    if ( $DEBUG_sys ) ; then
1251        echo "IGCM_sys_ncpdq :" $@
1252    fi
1253    /usr/local/bin/ncpdq $@
1254    if [ $? -gt 0 ] ; then
1255       echo "IGCM_sys_ncpdq : erreur ${@}."
1256       IGCM_debug_Exit "ncpdq"
1257    fi
1258
1259    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1260}
1261
1262function IGCM_sys_ncra {
1263    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1264    if ( $DEBUG_sys ) ; then
1265        echo "IGCM_sys_ncra :" $@
1266    fi
1267    /usr/local/bin/ncra $@
1268    if [ $? -gt 0 ] ; then
1269       echo "IGCM_sys_ncra : erreur ${@}."
1270       IGCM_debug_Exit "ncra"
1271    fi
1272
1273    IGCM_debug_PopStack "IGCM_sys_ncra"
1274}
1275
1276function IGCM_sys_ncrcat {
1277    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1278    if ( $DEBUG_sys ) ; then
1279        echo "IGCM_sys_ncrcat :" $@
1280    fi
1281    /usr/local/bin/ncrcat $@
1282    if [ $? -gt 0 ] ; then
1283       echo "IGCM_sys_ncrcat : erreur ${@}."
1284#       IGCM_debug_Exit "ncrcat"
1285    fi
1286
1287    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1288}
1289
1290function IGCM_sys_ncrename {
1291    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1292    if ( $DEBUG_sys ) ; then
1293        echo "IGCM_sys_ncrename :" $@
1294    fi
1295    /usr/local/bin/ncrename $@
1296    if [ $? -gt 0 ] ; then
1297       echo "IGCM_sys_ncrename : erreur ${@}."
1298       IGCM_debug_Exit "ncrename"
1299    fi
1300
1301    IGCM_debug_PopStack "IGCM_sys_ncrename"
1302}
1303
1304function IGCM_sys_ncwa {
1305    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1306    if ( $DEBUG_sys ) ; then
1307        echo "IGCM_sys_ncwa :" $@
1308    fi
1309    /usr/local/bin/ncwa $@
1310    if [ $? -gt 0 ] ; then
1311       echo "IGCM_sys_ncwa : erreur ${@}."
1312       IGCM_debug_Exit "ncwa"
1313    fi
1314
1315    IGCM_debug_PopStack "IGCM_sys_ncwa"
1316}
1317
1318##############################################################
1319# CDO OPERATOR
1320
1321function IGCM_sys_cdo {
1322    IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1323
1324    \cdo $@
1325    if [ $? -gt 0 ] ; then
1326       echo "IGCM_sys_cdo : erreur ${@}."
1327       IGCM_debug_PopStack "IGCM_sys_cdo"
1328       return 1
1329    else
1330        IGCM_debug_PopStack "IGCM_sys_cdo"
1331        return 0
1332    fi
1333
1334    IGCM_debug_PopStack "IGCM_sys_cdo"
1335}
1336
1337############################################################
1338# Activate Running Environnment Variables
1339
1340function IGCM_sys_activ_variables {
1341    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1342    if ( $DEBUG_sys ) ; then
1343        echo "IGCM_sys_activ_variables"
1344    fi
1345    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1346}
1347
1348############################################################
1349# Desactivate Running Environnment Variables
1350
1351function IGCM_sys_desactiv_variables {
1352    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1353    if ( $DEBUG_sys ) ; then
1354        echo "IGCM_sys_desactiv_variables"
1355    fi
1356    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1357}
1358
1359############################################################
1360# Build run file
1361
1362function IGCM_sys_build_run_file {
1363    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1364    if ( $DEBUG_sys ) ; then
1365        echo "IGCM_sys_build_run_file"
1366    fi
1367    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1368}
Note: See TracBrowser for help on using the repository browser.