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

Last change on this file since 437 was 437, checked in by sdipsl, 13 years ago

Send mail notification when computing job stops
It could be that we send a notification if a post-processing job stops in PROD mode ---> need some refactoring and caution...

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