source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh @ 452

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