source: tags/libIGCM_v1_9/libIGCM_sys/libIGCM_sys_cesium.ksh @ 552

Last change on this file since 552 was 361, checked in by sdipsl, 14 years ago

Some cleanup

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