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

Last change on this file since 645 was 645, checked in by sdipsl, 12 years ago
  • IGCM_sys_CountFileArchive must be a quiet function so as not to disturb tests making us of it
  • Property svn:keywords set to Revision Author Date
File size: 53.4 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip, Arnaud Caubel
5# Contact: Arnaud.Caubel__at__lsce.ipsl.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 Curie
22#D-#==================================================
23#D-
24#D- This ksh library if a layer under some usefull
25#D-environment variables and shell commands.
26#D-All those definitions depend on host particularities.
27#D-It manages a stack mechanism and test validity of operations.
28#D-All function described bellow must be prefixed by IGCM_sys.
29
30#====================================================
31# libIGCM_sys PARAMETERS
32#====================================================
33
34#====================================================
35# set DEBUG_sys to true to output calls of function
36typeset -r DEBUG_sys=${DEBUG_sys:=true}
37
38#====================================================
39# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
40typeset -r DRYRUN=${DRYRUN:=0}
41
42# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
43# -------------------------------------------------------------------------------------
44# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
45# |          |  Cp/Exe param files |            |  Chmod  |                           |
46# |          |      Qsub           |            |         |                           |
47# -------------------------------------------------------------------------------------
48# |    0     |       yes           |    yes     |  yes    |      yes                  |
49# -------------------------------------------------------------------------------------
50# |    1     |       yes           |    yes     |  yes    |      no                   |
51# -------------------------------------------------------------------------------------
52# |    2     |       yes           |    yes     |  no     |      no                   |
53# -------------------------------------------------------------------------------------
54# |    3     |       yes           |    no      |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56
57#=====================================================
58# Global Variables :
59#=====================================================
60# Language : "fr" or "en"
61typeset -r MYLANG="fr"
62
63#=====================================================
64# Host and user names
65# $hostname ou hostname
66typeset  HOST=${HOST:=$( hostname )}
67# $username ou whoami
68typeset  LOGIN=${LOGIN:=$( whoami )}
69# $hostname of the MASTER job
70typeset MASTER=curie
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 STOREHOST=${MASTER}
83
84#====================================================
85# Source default environment
86#====================================================
87##. /etc/profile
88
89#====================================================
90# Set environment tools (ferret, nco, cdo)
91#====================================================
92. /ccc/cont003/home/dsm/p86ipsl/.atlas_env_curie_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# ============ CESIUM START ============ #
104
105#====================================================
106#- Mirror libIGCM from titane to cesium if needed
107#ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $3}' )
108#if [ ! ${ROOTSYS} = "home" ] ; then
109#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true}
110#else
111#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
112#fi
113
114#====================================================
115#- libIGCM_POST
116#if ( ${MirrorlibIGCM} ) ; then
117#  PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" )
118#  typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM
119#else
120#  typeset -r libIGCM_POST=${libIGCM}
121#fi
122
123# ============ CESIUM  END  ============ #
124
125#====================================================
126#- MirrorlibIGCM for frontend
127typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
128
129#====================================================
130#- libIGCM_POST for frontend
131typeset -r libIGCM_POST=${libIGCM}
132
133#====================================================
134#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
135typeset -r R_EXE="${MODIPSL}/bin"
136
137#====================================================
138#- SUBMIT_DIR : submission dir
139typeset SUBMIT_DIR=${SUBMIT_DIR:=${BRIDGE_MSUB_PWD}}
140
141#====================================================
142#- ARCHIVE (dedicated to large files)
143typeset -r ARCHIVE=${CCCSTOREDIR}
144
145#- ARCHIVE (dedicated to small/medium files)
146typeset -r STORAGE=${CCCWORKDIR}
147
148#====================================================
149#- IN
150typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM}
151typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/ccc/work/cont003/dsm/p24data}
152
153#====================================================
154#- R_OUT
155typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
156
157#====================================================
158#- R_FIG (hosting figures : monitoring and atlas, and/or small files)
159typeset -r R_FIG=${STORAGE}/IGCM_OUT
160
161#====================================================
162#- R_BUF (ONLY FOR double copy an scratch)
163typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT
164
165#====================================================
166#- BIG_DIR : BIG_DIR to store files waiting for rebuild
167typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD}
168
169#====================================================
170#- OUT_POST
171typeset -r R_OUT_POST=${SCRATCHDIR}/IGCM_OUT
172
173#====================================================
174#- RUN_DIR_PATH : Temporary working directory (=> TMP)
175if [ ! X${BRIDGE_MSUB_NPROC} = X1 ] ; then
176  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${BRIDGE_MSUB_JOBID}}
177else
178  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/TMPDIR_IGCM/${BRIDGE_MSUB_JOBID}}
179fi
180
181#====================================================
182#- HOST_MPIRUN_COMMAND
183typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time ccc_mprun"}
184
185#====================================================
186#- Max number of arguments passed to nco operator or demigration command
187UNIX_MAX_LIMIT=360
188
189#====================================================
190#- set PackDefault true on curie
191PackDefault=true
192
193NUM_COREPERNODE=8
194
195#====================================================
196#- Default number of MPI task for IPSL coupled model
197#- required for backward compatibility
198#-
199DEFAULT_NUM_PROC_OCE=5
200DEFAULT_NUM_PROC_CPL=1
201(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
202DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
203
204#D-#==================================================
205#D-function IGCM_sys_RshMaster
206#D-* Purpose: Connection to frontend machine.
207#D-* Examples:
208#D-
209function IGCM_sys_RshMaster {
210  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
211  /bin/ksh <<-EOF
212    export libIGCM=${libIGCM}
213    export DEBUG_debug=${DEBUG_debug}
214    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
215    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
216    ${@}
217EOF
218  if [ $? -gt 0 ] ; then
219    echo "IGCM_sys_RshMaster : erreur."
220    IGCM_debug_Exit "IGCM_sys_RshMaster"
221  fi
222  IGCM_debug_PopStack "IGCM_sys_RshMaster"
223}
224
225#D-#==================================================
226#D-function IGCM_sys_RshArchive
227#D-* Purpose: Archive rsh command
228#D-* Examples:
229#D-
230function IGCM_sys_RshArchive {
231  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
232  /bin/ksh <<-EOF
233    ${@}
234EOF
235  if [ $? -gt 0 ] ; then
236    echo "IGCM_sys_RshArchive : erreur."
237    IGCM_debug_Exit "IGCM_sys_RshArchive"
238  fi
239  IGCM_debug_PopStack "IGCM_sys_RshArchive"
240}
241
242#D-#==================================================
243#D-function IGCM_sys_RshPost
244#D-* Purpose: Post-process rsh command
245#D-* Examples:
246#D-
247function IGCM_sys_RshPost {
248  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
249  if ( $DEBUG_sys ) ; then
250    echo "IGCM_sys_RshPost :" $@
251  fi
252
253  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL
254  #cat tmp_IGCM_sys_RshPost_$$
255  # keep standard input (stdin) for the loop onto temporary file
256  cat >tmp_IGCM_sys_RshPost_$$
257
258# ============ FRONTEND START ============ #
259
260  /bin/ksh <tmp_IGCM_sys_RshPost_$$
261  if [ $? -gt 0 ] ; then
262    echo "IGCM_sys_RshPost : erreur."
263    IGCM_debug_Exit "IGCM_sys_RshPost"
264  fi
265  # delete temporary file
266  \rm tmp_IGCM_sys_RshPost_$$
267
268# ============ FRONTEND  END  ============ #
269
270# ============ CESIUM START ============ #
271#  typeset NB_ESSAI DELAI status i
272#  if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then
273#    #little hack so that rebuild submission is done on titane not an cesium
274#
275#    libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' )
276#    POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' )
277#    sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
278#    sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$
279#    sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
280#    sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$
281#    \mv tmp.txt tmp_IGCM_sys_RshPost_$$
282#
283#    echo cat tmp_IGCM_sys_RshPost_$$ AFTER
284#    cat tmp_IGCM_sys_RshPost_$$
285#
286#    /bin/ksh <tmp_IGCM_sys_RshPost_$$
287#    if [ $? -gt 0 ] ; then
288#      echo "IGCM_sys_RshPost : erreur."
289#      IGCM_debug_Exit "IGCM_sys_RshPost"
290#    fi
291#    # delete temporary file
292#    \rm tmp_IGCM_sys_RshPost_$$
293#
294#  else
295#    # number of tentative
296#    NB_ESSAI=10
297#    # time delay between tentative
298#    DELAI=10
299#    i=0
300#    while [ $i -ne $NB_ESSAI ] ; do
301#      ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$
302#      status=$?
303#      if [ ${status} -ne 0 ];
304#      then
305#       sleep $DELAI
306#      else
307#       break
308#      fi
309#      let i=$i+1
310#    done
311#    # delete temporary file
312#    \rm tmp_IGCM_sys_RshPost_$$
313#
314#    if [ ${status} -gt 0 ] ; then
315#      echo "IGCM_sys_RshPost : erreur."
316#      IGCM_debug_Exit "IGCM_sys_RshPost"
317#    fi
318#  fi
319
320# ============ CESIUM  END  ============ #
321
322  IGCM_debug_PopStack "IGCM_sys_RshPost"
323}
324
325#D-#==================================================
326#D-function IGCM_sys_SendMail
327#D-* Purpose: Send mail when simulation is over
328#D-* Examples:
329#D-
330function IGCM_sys_SendMail {
331  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
332  if ( $DEBUG_sys ) ; then
333    echo "IGCM_sys_SendMail :" $@
334  fi
335
336  if ( ${ExitFlag} ) ; then
337    status=failed
338  else
339    status=completed
340  fi
341
342  cat  << END_MAIL > job_end.mail
343Dear ${LOGIN},
344
345  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
346  Job started : ${DateBegin}
347  Job ended   : ${DateEnd}
348  Output files are available in ${R_SAVE}
349  Files to be rebuild are temporarily available in ${REBUILD_DIR}
350  Pre-packed files are temporarily available in ${R_BUFR}
351  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
352END_MAIL
353
354    if [ ! -z ${config_UserChoices_MailName} ] ; then
355        mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail
356    elif [ -f ~/.forward ] ; then
357        mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
358    fi
359    sleep 10
360    rm -f job_end.mail
361
362  if [ $? -gt 0 ] ; then
363    echo "IGCM_sys_SendMail : erreur."
364    IGCM_debug_Exit "IGCM_sys_SendMail"
365  fi
366  IGCM_debug_PopStack "IGCM_sys_SendMail"
367}
368
369#D-#==================================================
370#D-function IGCM_sys_Mkdir
371#D-* Purpose: Master locale mkdir command
372#D-* Examples:
373#D-
374function IGCM_sys_Mkdir {
375  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
376  if ( $DEBUG_sys ) ; then
377    echo "IGCM_sys_Mkdir :" $@
378  fi
379  if [ ! -d ${1} ]; then
380    \mkdir -p $1
381    if [ $? -gt 0 ] ; then
382      echo "IGCM_sys_Mkdir : erreur."
383      IGCM_debug_Exit "IGCM_sys_Mkdir"
384    fi
385  fi
386  # vérification :
387  if [ ! -d ${1} ] ; then
388    echo "IGCM_sys_Mkdir : erreur."
389    IGCM_debug_Exit "IGCM_sys_Mkdir"
390  fi
391  IGCM_debug_PopStack "IGCM_sys_Mkdir"
392}
393
394#D-#==================================================
395#D-function IGCM_sys_MkdirArchive
396#D-* Purpose: Mkdir on Archive
397#D-* Examples:
398#D-
399function IGCM_sys_MkdirArchive {
400  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
401  if ( $DEBUG_sys ) ; then
402    echo "IGCM_sys_MkdirArchive :" $@
403  fi
404  #- creation de repertoire sur le serveur fichier
405  if [ ! -d ${1} ]; then
406    \mkdir -p $1
407    if [ $? -gt 0 ] ; then
408      echo "IGCM_sys_MkdirArchive : erreur."
409      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
410    fi
411  fi
412  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
413}
414
415#D-#==================================================
416#D-function IGCM_sys_MkdirWork
417#D-* Purpose: Mkdir on Work
418#D-* Examples:
419#D-
420function IGCM_sys_MkdirWork {
421  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
422  if ( $DEBUG_sys ) ; then
423    echo "IGCM_sys_MkdirWork :" $@
424  fi
425  #- creation de repertoire sur le serveur fichier
426  if [ ! -d ${1} ]; then
427    \mkdir -p $1
428    if [ $? -gt 0 ] ; then
429      echo "IGCM_sys_MkdirWork : erreur."
430      IGCM_debug_Exit "IGCM_sys_MkdirWork"
431    fi
432  fi
433  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
434}
435
436#D-#==================================================
437#D-function IGCM_sys_Cd
438#D-* Purpose: master cd command
439#D-* Examples:
440#D-
441function IGCM_sys_Cd {
442  IGCM_debug_PushStack "IGCM_sys_Cd" $@
443  if ( $DEBUG_sys ) ; then
444    echo "IGCM_sys_Cd :" $@
445  fi
446  \cd $1
447  if [ $? -gt 0 ] ; then
448    echo "IGCM_sys_Cd : erreur."
449    IGCM_debug_Exit "IGCM_sys_Cd"
450  fi
451  IGCM_debug_PopStack "IGCM_sys_Cd"
452}
453
454#D-#==================================================
455#D-function IGCM_sys_Chmod
456#D-* Purpose: Chmod
457#D-* Examples:
458#D-
459function IGCM_sys_Chmod {
460  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
461  if ( $DEBUG_sys ) ; then
462    echo "IGCM_sys_Chmod :" $@
463  fi
464  if [ $DRYRUN -le 1 ]; then
465    \chmod $@
466    if [ $? -gt 0 ] ; then
467      echo "IGCM_sys_Chmod : erreur."
468      IGCM_debug_Exit "IGCM_sys_Chmod"
469    fi
470  else
471    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
472  fi
473  IGCM_debug_PopStack "IGCM_sys_Chmod"
474}
475
476#D-#==================================================
477#D-function IGCM_sys_FileSize
478#D-* Purpose: Filesize
479#D-* Examples:
480#D-
481function IGCM_sys_FileSize {
482  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
483
484  typeset sizeF
485  set +A sizeF -- $( ls -la ${1} )
486  if [ $? -gt 0 ] ; then
487    IGCM_debug_Exit "IGCM_sys_FileSize"
488  fi
489  eval ${2}=${sizeF[4]}
490
491  IGCM_debug_PopStack "IGCM_sys_FileSize"
492}
493
494#D-#==================================================
495#D-function IGCM_sys_TestDir
496#D-* Purpose: Test Directory that must exists
497#D-* Examples:
498#D-
499function IGCM_sys_TestDir {
500  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
501  if ( $DEBUG_sys ) ; then
502    echo "IGCM_sys_TestDir :" $@
503  fi
504  typeset ExistFlag
505  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
506  IGCM_debug_PopStack "IGCM_sys_TestDir"
507
508  return ${ExistFlag}
509}
510
511#D-#==================================================
512#D-function IGCM_sys_TestDirArchive
513#D-* Purpose: Test Directory that must exists on Archive
514#D-* Examples:
515#D-
516function IGCM_sys_TestDirArchive {
517  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
518  if ( $DEBUG_sys ) ; then
519    echo "IGCM_sys_TestDirArchive :" $@
520  fi
521  typeset ExistFlag
522  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
523  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
524
525  return ${ExistFlag}
526}
527
528#D-#==================================================
529#D-function IGCM_sys_IsFileArchived
530#D-* Purpose: Test file that must NOT EXISTS on Archive
531#D-* Examples:
532#D-
533function IGCM_sys_IsFileArchived {
534  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
535  if ( $DEBUG_sys ) ; then
536    echo "IGCM_sys_IsFileArchived :" $@
537  fi
538  typeset IsArchivedFlag
539  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/ccc\/store ) != X ] && echo 0 || echo 1 )
540  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
541
542  return ${IsArchivedFlag}
543}
544
545#D-#==================================================
546#D-function IGCM_sys_TestFileArchive
547#D-* Purpose: Test file that must NOT EXISTS on Archive
548#D-* Examples:
549#D-
550function IGCM_sys_TestFileArchive {
551  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
552  typeset ExistFlag
553  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
554  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
555
556  return ${ExistFlag}
557}
558
559#D-#==================================================
560#D-function IGCM_sys_TestFileBuffer
561#D-* Purpose: Test file that must NOT EXISTS on Buffer
562#D-* Examples:
563#D-
564function IGCM_sys_TestFileBuffer {
565  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
566  typeset ExistFlag
567  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
568  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
569
570  return ${ExistFlag}
571}
572
573#D-#==================================================
574#D-function IGCM_sys_CountFileArchive
575#D-* Purpose: Count files on Archive filesystem
576#D-* Examples:
577#D-
578function IGCM_sys_CountFileArchive {
579  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
580  ls ${@} 2>/dev/null | wc -l
581  if [ $? -gt 0 ] ; then
582    echo "IGCM_sys_CountFileArchive : erreur."
583  fi
584  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
585}
586
587#D-#==================================================
588#D-function IGCM_sys_CountFileBuffer
589#D-* Purpose: Count files on Scratch filesystem
590#D-* Examples:
591#D-
592function IGCM_sys_CountFileBuffer {
593  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
594  ls ${@} 2>/dev/null | wc -l
595  if [ $? -gt 0 ] ; then
596    echo "IGCM_sys_CountFileBuffer : erreur."
597  fi
598  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
599}
600
601#D-#==================================================
602#D-function IGCM_sys_Tree
603#D-* Purpose: Tree directories with files on ${ARCHIVE}
604#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
605#D-
606function IGCM_sys_Tree {
607  IGCM_debug_PushStack "IGCM_sys_Tree" $@
608  if ( $DEBUG_sys ) ; then
609    echo "IGCM_sys_Tree :" $@
610  fi
611
612  \ls -lR ${@}
613
614  IGCM_debug_PopStack "IGCM_sys_Tree"
615}
616
617#D-#==================================================
618#D-function IGCM_sys_Tar
619#D-* Purpose: master tar command
620#D-* Examples:
621#D-
622function IGCM_sys_Tar {
623  IGCM_debug_PushStack "IGCM_sys_Tar" $@
624  if ( $DEBUG_sys ) ; then
625    echo "IGCM_sys_Tar :" $@
626  fi
627  \tar cf $@
628  if [ $? -gt 0 ] ; then
629    echo "IGCM_sys_Tar : erreur."
630    IGCM_debug_Exit "IGCM_sys_Tar"
631  fi
632  IGCM_debug_PopStack "IGCM_sys_Tar"
633}
634
635#D-#==================================================
636#D-function IGCM_sys_UnTar
637#D-* Purpose: master un-tar command
638#D-* Examples:
639#D-
640function IGCM_sys_UnTar {
641  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
642  if ( $DEBUG_sys ) ; then
643    echo "IGCM_sys_UnTar :" $@
644  fi
645  \tar xvf $1
646  if [ $? -gt 0 ] ; then
647    echo "IGCM_sys_UnTar : erreur."
648    IGCM_debug_Exit "IGCM_sys_UnTar"
649  fi
650  IGCM_debug_PopStack "IGCM_sys_UnTar"
651}
652
653#D-#==================================================
654#D-function IGCM_sys_Qsub
655#D-* Purpose: Qsub new job
656#D-* Examples:
657#D-
658function IGCM_sys_Qsub {
659  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
660  if ( $DEBUG_sys ) ; then
661    echo "IGCM_sys_Qsub :" $@
662  fi
663  typeset options
664  if [ ${config_UserChoices_JobName}.${CumulPeriod} = "." ] ; then
665    options=" -o ${Script_Output} -e ${Script_Output}"
666  else
667    options=" -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod}"
668  fi
669
670  /usr/bin/ccc_msub ${options} < $1
671  if [ $? -gt 0 ] ; then
672    echo "IGCM_sys_Qsub : erreur ${options} $1"
673    IGCM_debug_Exit "IGCM_sys_Qsub"
674  fi
675  IGCM_debug_PopStack "IGCM_sys_Qsub"
676}
677
678#D-#==================================================
679#D-function IGCM_sys_QsubPost
680#D-* Purpose: Qsub new job on scalaire
681#D-* Examples:
682#D-
683function IGCM_sys_QsubPost {
684  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
685  if ( $DEBUG_sys ) ; then
686    echo "IGCM_sys_QsubPost :" $@
687  fi
688  /usr/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out ${libIGCM_POST}/$1.job
689  if [ $? -gt 0 ] ; then
690    echo "IGCM_sys_QsubPost : erreur " $@
691    IGCM_debug_Exit "IGCM_sys_QsubPost"
692  fi
693  IGCM_debug_PopStack "IGCM_sys_QsubPost"
694}
695
696#D-*************************
697#D- File transfer functions
698#D-*************************
699#D-
700
701#D-#==================================================
702#D-function IGCM_sys_Rsync_out
703#D-* Purpose: treat return val of rsync
704#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
705#D-  Error values and explanations can depend on your system version.
706function IGCM_sys_Rsync_out {
707  RET=$1
708  if [ ! $RET ] ; then
709    echo "rsync error !"
710  fi
711
712  if [ $MYLANG = "fr" ]; then
713    case $RET in
714    0)  return ;;
715    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
716      echo "Erreur de syntaxe ou d'utilisation."
717      return;;
718    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
719      echo "Incompatibilité de protocole."
720      return;;
721    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
722      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
723      echo "répertoires"
724      return;;
725    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
726      echo "Action demandée non supportée : une tentative de manipulation de"
727      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
728      echo "été faite ; ou une option qui est supportée par le  client  mais"
729      echo "pas par le serveur a été spécifiée."
730      return;;
731    10) echo "Erreur de rsync ; RERR_SOCKETIO"
732      echo "Erreur dans le socket d'entrée sortie"
733      return;;
734    11) echo "Erreur de rsync ; RERR_FILEIO"
735      echo "Erreur d'entrée sortie fichier"
736      return;;
737    12) echo "Erreur de rsync ; RERR_STREAMIO"
738      echo "Erreur dans flux de donnée du protocole rsync"
739      return;;
740    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
741      echo "Erreur avec les diagnostics du programme"
742      return;;
743    14) echo "Erreur de rsync ; RERR_IPC"
744      echo "Erreur dans le code IPC"
745      return;;
746    20) echo "Erreur de rsync ; RERR_SIGNAL"
747      echo "SIGUSR1 ou SIGINT reçu"
748      return;;
749    21) echo "Erreur de rsync ; RERR_WAITCHILD"
750      echo "Une erreur retournée par waitpid()"
751      return;;
752    22) echo "Erreur de rsync ; RERR_MALLOC"
753      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
754      return;;
755    23) echo ""
756      echo "Erreur fichier inexistant"
757      return;;
758    30) echo "Erreur de rsync ; RERR_TIMEOUT"
759      echo "Temps d'attente écoulé dans l'envoi/réception de données"
760      return;;
761    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
762      return;;
763    esac
764  elif [ $MYLANG = "en" ] ; then
765    case $RET in
766    0)  return;;
767    1)  echo "rsync error : Syntax or usage error "
768      return;;
769    2)  echo "rsync error : Protocol incompatibility "
770      return;;
771    3)  echo "rsync error : Errors selecting input/output files, dirs"
772      return;;
773    4)  echo "rsync error : Requested action not supported: an attempt"
774      echo "was made to manipulate 64-bit files on a platform that cannot support"
775      echo "them; or an option was specified that is supported by the client and"
776      echo "not by the server."
777      return;;
778    5)  echo "rsync error : Error starting client-server protocol"
779      return;;
780    10) echo "rsync error : Error in socket I/O "
781      return;;
782    11) echo "rsync error : Error in file I/O "
783      return;;
784    12) echo "rsync error : Error in rsync protocol data stream "
785      return;;
786    13) echo "rsync error : Errors with program diagnostics "
787      return;;
788    14) echo "rsync error : Error in IPC code "
789      return;;
790    20) echo "rsync error : Received SIGUSR1 or SIGINT "
791      return;;
792    21) echo "rsync error : Some error returned by waitpid() "
793      return;;
794    22) echo "rsync error : Error allocating core memory buffers "
795      return;;
796    23) echo "rsync error : Partial transfer due to error"
797      return;;
798    24) echo "rsync error : Partial transfer due to vanished source files"
799      return;;
800    30) echo "rsync error : Timeout in data send/receive "
801      return;;
802    *)  echo "rsync error : return code of rsync unknown :" $RET
803      return;;
804    esac
805  else
806    echo "unknown language $MYLANG."
807    return
808  fi
809}
810
811#D-#==================================================
812#D-function IGCM_sys_Miror_libIGCM
813#D-* Purpose: Mirror libIGCM PATH and lib to cesium
814#D-* Examples:
815#D-
816function IGCM_sys_Mirror_libIGCM {
817  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
818  if ( $DEBUG_sys ) ; then
819    echo "IGCM_sys_Mirror_libIGCM"
820  fi
821
822  typeset RET DEST
823
824  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
825
826  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
827  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
828  RET=$?
829
830  if [ ${RET} -gt 0 ] ; then
831    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium."
832    cat out_rsync
833  fi
834  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
835}
836
837#====================================================
838#- Call IGCM_sys_Mirror_libIGCM now !
839if ( $MirrorlibIGCM ) ; then
840  IGCM_sys_Mirror_libIGCM
841fi
842
843#D-#==================================================
844#D-function IGCM_sys_Cp
845#D-* Purpose: generic cp
846#D-* Examples:
847#D-
848function IGCM_sys_Cp {
849  IGCM_debug_PushStack "IGCM_sys_Cp" $@
850  if ( $DEBUG_sys ) ; then
851    echo "IGCM_sys_Cp :" $@
852  fi
853
854  typeset RET
855
856  echo cp $@ > out_rsync 2>&1
857  \cp $@ >> out_rsync 2>&1
858  RET=$?
859
860  if [ ${RET} -gt 0 ] ; then
861    echo "IGCM_sys_Cp : error."
862    cat out_rsync
863    IGCM_debug_Exit "IGCM_sys_Cp"
864  else
865    \rm out_rsync
866  fi
867  IGCM_debug_PopStack "IGCM_sys_Cp"
868}
869
870#D-#==================================================
871#D-function IGCM_sys_Rm
872#D-* Purpose: generic rm
873#D-* Examples:
874#D-
875function IGCM_sys_Rm {
876  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
877  if ( $DEBUG_sys ) ; then
878    echo "IGCM_sys_Rm :" $@
879  fi
880
881  typeset RET
882
883  echo rm $@ > out_rsync 2>&1
884  \rm $@ >> out_rsync 2>&1
885  RET=$?
886
887  if [ ${RET} -gt 0 ] ; then
888    echo "IGCM_sys_Rm : error."
889    cat out_rsync
890    IGCM_debug_Exit "IGCM_sys_Rm"
891  else
892    \rm out_rsync
893  fi
894  IGCM_debug_PopStack "IGCM_sys_Rm"
895}
896
897#D-#==================================================
898#D-function IGCM_sys_RmRunDir
899#D-* Purpose: rm tmpdir (dummy function most of the time batch
900#D-                      scheduler will do the job)
901#D-* Examples:
902#D-
903function IGCM_sys_RmRunDir {
904  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
905  if ( $DEBUG_sys ) ; then
906    echo "IGCM_sys_RmRunDir :" $@
907  fi
908
909  typeset RET
910
911  echo rm $@ > out_rsync 2>&1
912  \rm $@ >> out_rsync 2>&1
913  RET=$?
914
915  if [ ${RET} -gt 0 ] ; then
916    echo "IGCM_sys_RmRunDir : error."
917    cat out_rsync
918    IGCM_debug_Exit "IGCM_sys_RmRunDir"
919  else
920    \rm out_rsync
921  fi
922  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
923}
924
925#D-#==================================================
926#D-function IGCM_sys_Mv
927#D-* Purpose: generic move
928#D-* Examples:
929#D-
930function IGCM_sys_Mv {
931  IGCM_debug_PushStack "IGCM_sys_Mv" $@
932  if ( $DEBUG_sys ) ; then
933    echo "IGCM_sys_Mv :" $@
934  fi
935
936  if [ $DRYRUN = 0 ]; then
937
938    typeset RET
939
940    echo mv $@ > out_rsync 2>&1
941    \mv $@ >> out_rsync 2>&1
942    RET=$?
943
944    if [ ${RET} -gt 0 ] ; then
945      echo "IGCM_sys_Mv : error in mv."
946      cat out_rsync
947      IGCM_debug_Exit "IGCM_sys_Mv"
948    else
949      \rm out_rsync
950    fi
951  else
952    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
953  fi
954
955  IGCM_debug_PopStack "IGCM_sys_Mv"
956}
957
958#D-#==================================================
959#D-function IGCM_sys_Put_Dir
960#D-* Purpose: Copy a complete directory on $(ARCHIVE)
961#D-* Examples:
962#D-
963function IGCM_sys_Put_Dir {
964  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
965  if ( $DEBUG_sys ) ; then
966    echo "IGCM_sys_Put_Dir :" $@
967  fi
968  if [ $DRYRUN = 0 ]; then
969    if [ ! -d ${1} ] ; then
970      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
971      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
972      return
973    fi
974
975    typeset RET
976
977    # Only if we use rsync
978    #IGCM_sys_TestDirArchive $( dirname $2 )
979    #
980    #USUAL WAY
981    \cp -r $1 $2 > out_rsync 2>&1
982    RET=$?
983
984    if [ ${RET} -gt 0 ] ; then
985      echo "IGCM_sys_Put_Dir : error."
986      cat out_rsync
987      IGCM_debug_Exit "IGCM_sys_Put_Dir"
988    else
989      \rm out_rsync
990    fi
991  else
992    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
993  fi
994  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
995}
996
997#D-#==================================================
998#D-function IGCM_sys_Get_Dir
999#D-* Purpose: Copy a complete directory from ${ARCHIVE}
1000#D-* Examples:
1001#D-
1002function IGCM_sys_Get_Dir {
1003  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
1004  if ( $DEBUG_sys ) ; then
1005    echo "IGCM_sys_Get_Dir :" $@
1006  fi
1007  if [ $DRYRUN = 0 ]; then
1008#    if [ ! -d ${1} ] ; then
1009#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
1010#      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
1011#      return
1012#    fi
1013
1014    typeset RET
1015
1016        # Only if we use rsync
1017        #IGCM_sys_TestDirArchive $( dirname $2 )
1018        #
1019        #USUAL WAY
1020        # add get (to demigrate all offline files) to reduce time of this command :
1021    ccc_hsm get $1/*
1022    \cp -r $1 $2 > out_rsync 2>&1
1023    RET=$?
1024
1025    if [ ${RET} -gt 0 ] ; then
1026      echo "IGCM_sys_Get_Dir : error."
1027      cat out_rsync
1028      IGCM_debug_Exit "IGCM_sys_Get_Dir"
1029    else
1030      \rm out_rsync
1031    fi
1032  else
1033    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1034  fi
1035  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
1036}
1037
1038#D-#==================================================
1039#D-function IGCM_sys_Get_Master
1040#D-* Purpose: Copy a complete directory from MASTER filesystem
1041#D-* Examples:
1042#D-
1043function IGCM_sys_Get_Master {
1044  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
1045  if ( $DEBUG_sys ) ; then
1046    echo "IGCM_sys_Get_Master :" $@
1047  fi
1048  if [ $DRYRUN = 0 ]; then
1049    if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
1050      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
1051      IGCM_debug_PopStack "IGCM_sys_Get_Master"
1052      return
1053    fi
1054
1055    typeset RET
1056
1057    #USUAL WAY
1058    \cp -r $1 $2 > out_rsync 2>&1
1059    RET=$?
1060
1061    if [ ${RET} -gt 0 ] ; then
1062      echo "IGCM_sys_Get_Master : error."
1063      cat out_rsync
1064      IGCM_debug_Exit "IGCM_sys_Get_Master"
1065    else
1066      \rm out_rsync
1067    fi
1068  else
1069    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1070  fi
1071  IGCM_debug_PopStack "IGCM_sys_Get_Master"
1072}
1073
1074#D-#==================================================
1075#D-function IGCM_sys_Put_Rest
1076#D-* Purpose: Put computied restarts on ${ARCHIVE}.
1077#D-           File and target directory must exist.
1078#D-* Examples:
1079#D-
1080function IGCM_sys_Put_Rest {
1081  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
1082  if ( $DEBUG_sys ) ; then
1083    echo "IGCM_sys_Put_Rest :" $@
1084  fi
1085  if [ $DRYRUN = 0 ]; then
1086    if [ ! -f ${1} ] ; then
1087      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
1088      IGCM_debug_Exit "IGCM_sys_Put_Rest"
1089    fi
1090
1091    typeset RET
1092    #
1093    if [ X${JobType} = XRUN ] ; then
1094      IGCM_sys_Chmod 444 ${1}
1095    fi
1096
1097    #
1098    # USUAL WAY
1099    \cp $1 $2 > out_rsync 2>&1
1100    RET=$?
1101
1102#       #RSYNC WITH NETWORK SSH CALL
1103#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1104#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1105
1106#       #RSYNC WITH NFS USE
1107#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1108#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> 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_Put_Rest : error."
1118      cat out_rsync
1119      IGCM_debug_Exit "IGCM_sys_Put_Rest"
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_Put_Rest"
1127}
1128
1129#D-#==================================================
1130#D-function IGCM_sys_PutBuffer_Rest
1131#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
1132#D-           File and target directory must exist.
1133#D-* Examples:
1134#D-
1135function IGCM_sys_PutBuffer_Rest {
1136  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
1137  if ( $DEBUG_sys ) ; then
1138    echo "IGCM_sys_PutBuffer_Rest :" $@
1139  fi
1140  if [ $DRYRUN = 0 ]; then
1141    if [ ! -f ${1} ] ; then
1142      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
1143      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1144    fi
1145
1146    typeset RET
1147    #
1148    if [ X${JobType} = XRUN ] ; then
1149      IGCM_sys_Chmod 444 ${1}
1150    fi
1151
1152    #
1153    # USUAL WAY
1154    \cp $1 $2 > out_rsync 2>&1
1155    RET=$?
1156
1157    if [ ${RET} -gt 0 ] ; then
1158      echo "IGCM_sys_PutBuffer_Rest : error."
1159      cat out_rsync
1160      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1161    else
1162      \rm out_rsync
1163    fi
1164  else
1165    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1166  fi
1167  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
1168}
1169
1170#D-#==================================================
1171#D-function IGCM_sys_Put_Out
1172#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
1173#D-* Examples:
1174#D-
1175function IGCM_sys_Put_Out {
1176  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
1177  if ( $DEBUG_sys ) ; then
1178    echo "IGCM_sys_Put_Out :" $@
1179  fi
1180  if [ $DRYRUN = 0 ]; then
1181    if [ ! -f ${1} ] ; then
1182      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
1183      IGCM_debug_PopStack "IGCM_sys_Put_Out"
1184      return 1
1185    fi
1186    #
1187    IGCM_sys_MkdirArchive $( dirname $2 )
1188    #
1189    typeset RET
1190
1191    #=====================================================
1192    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1193    #=====================================================
1194
1195    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
1196    #if [ $? -eq 0 ] ; then
1197    #    typeset WORKPATH FILEPATH
1198    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" )
1199    #    IGCM_sys_MkdirWork ${WORKPATH}
1200    #    FILEPATH=${WORKPATH}/$( basename $2 )
1201    #    #
1202    #    IGCM_sys_Cp ${1} ${FILEPATH}
1203    #fi
1204
1205    if [ X${JobType} = XRUN ] ; then
1206      if [ X${3} = X ] ; then
1207        IGCM_sys_Chmod 444 ${1}
1208      fi
1209    fi
1210    #
1211    # USUAL WAY
1212    \cp $1 $2 > out_rsync 2>&1
1213    RET=$?
1214
1215#       #RSYNC WITH NETWORK SSH CALL
1216#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1217#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1218
1219#       #RSYNC WITH NFS USE
1220#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1221#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1222
1223#       RET=$?
1224#       IGCM_sys_Rsync_out $RET
1225
1226#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1227#       (( RET=RET+$? ))
1228
1229    if [ ${RET} -gt 0 ] ; then
1230      echo "IGCM_sys_Put_Out : error."
1231      cat out_rsync
1232      IGCM_debug_Exit "IGCM_sys_Put_Out"
1233    else
1234      \rm out_rsync
1235    fi
1236  else
1237    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1238  fi
1239  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1240  return 0
1241}
1242
1243#D-#==================================================
1244#D-function IGCM_sys_PutBuffer_Out
1245#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1246#D-* Examples:
1247#D-
1248function IGCM_sys_PutBuffer_Out {
1249  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1250  if ( $DEBUG_sys ) ; then
1251    echo "IGCM_sys_PutBuffer_Out :" $@
1252  fi
1253  if [ $DRYRUN = 0 ]; then
1254    if [ ! -f ${1} ] ; then
1255      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1256      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1257      return 1
1258    fi
1259    #
1260    IGCM_sys_Mkdir $( dirname $2 )
1261    #
1262    typeset RET
1263
1264    if [ X${JobType} = XRUN ] ; then
1265      if [ X${3} = X ] ; then
1266        IGCM_sys_Chmod 444 ${1}
1267      fi
1268    fi
1269    #
1270    # USUAL WAY
1271    \cp $1 $2 > out_rsync 2>&1
1272    RET=$?
1273
1274    if [ ${RET} -gt 0 ] ; then
1275      echo "IGCM_sys_PutBuffer_Out : error."
1276      cat out_rsync
1277      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1278    else
1279      \rm out_rsync
1280    fi
1281  else
1282    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1283  fi
1284  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1285  return 0
1286}
1287
1288#D-#==================================================
1289#D-function IGCM_sys_Get
1290#D-* Purpose: Get a file from ${ARCHIVE}
1291#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1292#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1293function IGCM_sys_Get {
1294  IGCM_debug_PushStack "IGCM_sys_Get" $@
1295
1296  typeset DEST RET dm_liste ifile target file_work
1297
1298  if ( $DEBUG_sys ) ; then
1299    echo "IGCM_sys_Get :" $@
1300  fi
1301  if [ $DRYRUN -le 2 ]; then
1302    if [ X${1} = X'/l' ] ; then
1303      # test if the first file is present in the old computation :
1304      eval set +A dm_liste \${${2}}
1305    else
1306      eval set +A dm_liste ${1}
1307    fi
1308    eval DEST=\${${#}}
1309
1310    #=====================================================
1311    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1312    #=====================================================
1313
1314    # Is it an R_OUT file (not R_IN) ?
1315    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1316    #if [ $? -eq 0 ] ; then
1317    #    # Yes  ? then we try to get it in SCRATCHDIR
1318    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" )
1319    #    if [ -f ${file_work[0]} ] ; then
1320    #   IGCM_sys_Cp ${file_work[*]} ${DEST}
1321    #   IGCM_debug_PopStack "IGCM_sys_Get"
1322    #   return
1323    #    fi
1324    #fi
1325
1326    # test if the (first) file is present in the old computation :
1327    IGCM_sys_TestFileArchive ${dm_liste[0]}
1328    RET=$?
1329    if [ ${RET} -gt 0 ] ; then
1330      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1331      IGCM_debug_Exit "IGCM_sys_Get"
1332    fi
1333
1334    ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1335    RET=$?
1336    if [ ${RET} -gt 0 ] ; then
1337      echo "WARNING IGCM_sys_Get : demigration error."
1338      cat out_rsync
1339      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
1340    fi
1341
1342    #if [ ${RET} -gt 0 ] ; then
1343    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
1344    #   cat out_rsync
1345    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
1346    #   sleep 30
1347    #   echo "We try another time"
1348    ##  dmget ${dm_liste[*]} > out_rsync 2>&1
1349    #   ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1350    #   RET=$?
1351    #   if [ ${RET} -gt 0 ] ; then
1352    #       echo "ERROR IGCM_sys_Get : again demigration error :"
1353    #       cat out_rsync
1354    #       IGCM_debug_Exit "IGCM_sys_Get"
1355    #   fi
1356    #    else
1357    #   echo "ERROR IGCM_sys_Get : demigration error :"
1358    #   cat out_rsync
1359    #   IGCM_debug_Exit "IGCM_sys_Get"
1360    #    fi
1361    #fi
1362
1363    #USUAL WAY
1364    if [ X${1} = X'/l' ] ; then
1365      (( RET=0 ))
1366      for target in ${dm_liste[*]} ; do
1367        local_file=$( basename ${target} )
1368        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1369        (( RET = RET + $? ))
1370      done
1371    else
1372      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1373      RET=$?
1374    fi
1375
1376#       #RSYNC WITH NETWORK SSH CALL
1377#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1378#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1379
1380#       #RSYNC WITH NFS USE
1381#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1382#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1383
1384#       RET=$?
1385#       IGCM_sys_Rsync_out $RET
1386
1387#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1388#       (( RET=RET+$? ))
1389
1390    if [ ${RET} -gt 0 ] ; then
1391      echo "IGCM_sys_Get : copy error."
1392      cat out_rsync
1393      IGCM_debug_Exit "IGCM_sys_Get"
1394    else
1395      \rm out_rsync
1396    fi
1397  else
1398    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1399  fi
1400  IGCM_debug_PopStack "IGCM_sys_Get"
1401}
1402
1403#D-#==================================================
1404#D-function IGCM_sys_GetBuffer
1405#D-* Purpose: Get a file from ${SCRATCHDIR}
1406#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1407#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1408function IGCM_sys_GetBuffer {
1409  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1410
1411  typeset DEST RET buf_liste ifile target file_work
1412
1413  if ( $DEBUG_sys ) ; then
1414    echo "IGCM_sys_GetBuffer :" $@
1415  fi
1416  if [ $DRYRUN -le 2 ]; then
1417    if [ X${1} = X'/l' ] ; then
1418      # test if the first file is present in the old computation :
1419      eval set +A buf_liste \${${2}}
1420    else
1421      eval set +A buf_liste ${1}
1422    fi
1423    eval DEST=\${${#}}
1424
1425    #USUAL WAY
1426    if [ X${1} = X'/l' ] ; then
1427      (( RET=0 ))
1428      for target in ${buf_liste[*]} ; do
1429        local_file=$( basename ${target} )
1430        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1431        (( RET = RET + $? ))
1432      done
1433    else
1434      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
1435      RET=$?
1436    fi
1437
1438    if [ ${RET} -gt 0 ] ; then
1439      echo "IGCM_sys_GetBuffer : copy error."
1440      cat out_rsync
1441      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1442    else
1443      \rm out_rsync
1444    fi
1445  else
1446    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1447  fi
1448  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1449}
1450
1451#D-#==================================================
1452#D-function IGCM_sys_GetDate_FichWork
1453#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1454#D-* Examples:
1455#D-
1456function IGCM_sys_GetDate_FichWork {
1457  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1458  if ( $DEBUG_sys ) ; then
1459    echo "IGCM_sys_GetDate_FichWork :" $@
1460  fi
1461  typeset dateF
1462  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1463  eval ${2}=${dateF[5]}
1464
1465    # donne la date filesys d'un fichier sur la machine work
1466  IGCM_debug_PopStack "IGCM_sys_FichWork"
1467}
1468
1469#D-#==================================================
1470#D-function IGCM_sys_GetDate_FichArchive
1471#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1472#D-* Examples:
1473#D-
1474function IGCM_sys_GetDate_FichArchive {
1475  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1476  if ( $DEBUG_sys ) ; then
1477    echo "IGCM_sys_GetDate_FichArchive :" $@
1478  fi
1479  typeset dateF
1480  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1481  eval ${2}=${dateF[5]}
1482
1483  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1484}
1485
1486#D-#==================================================
1487#D-function IGCM_sys_Dods_Rm
1488#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
1489#D-* Examples:
1490#D-
1491function IGCM_sys_Dods_Rm {
1492  if ( $DEBUG_sys ) ; then
1493    echo "IGCM_sys_Dods_Rm :" $@
1494  fi
1495  typeset RET
1496  RET=0
1497  if [ $DRYRUN = 0 ]; then
1498
1499#    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1500#      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1501#      echo "Nothing has been done."
1502#      return
1503#    fi
1504
1505    /ccc/cont003/home/dsm/p86maf/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
1506    RET=$?
1507
1508#       if [ ${RET} -gt 0 ] ; then
1509#           echo "IGCM_sys_Dods_Rm : error."
1510#           cat out_dods_rm
1511#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1512#       else
1513#           rm out_dods_rm
1514#       fi
1515
1516  else
1517    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1518  fi
1519  return $RET
1520}
1521
1522#D-#==================================================
1523#D-function IGCM_sys_Dods_Cp
1524#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1525#D-* Examples:
1526#D-
1527function IGCM_sys_Dods_Cp {
1528  if ( $DEBUG_sys ) ; then
1529    echo "IGCM_sys_Dods_Cp :" $@
1530  fi
1531  typeset RET
1532  RET=0
1533  if [ $DRYRUN = 0 ]; then
1534
1535#    if [ ! -d ${R_SAVE}/${1} ] ; then
1536#      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1537#      echo "Nothing has been done."
1538#      return
1539#    fi
1540
1541    /ccc/cont003/home/dsm/p86maf/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
1542    RET=$?
1543
1544#       if [ ${RET} -gt 0 ] ; then
1545#           echo "IGCM_sys_Dods_Cp : error."
1546#           cat out_dods_cp
1547#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1548#       else
1549#           rm out_dods_cp
1550#       fi
1551
1552  else
1553    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1554  fi
1555  return $RET
1556}
1557
1558#D-#==================================================
1559#D-function IGCM_sys_Put_Dods
1560#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1561#D-* Examples:
1562#D-
1563function IGCM_sys_Put_Dods {
1564  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1565  if ( $DEBUG_sys ) ; then
1566    echo "IGCM_sys_Put_Dods :" $@
1567  fi
1568  set -vx
1569  typeset RET
1570  if [ $DRYRUN = 0 ]; then
1571    if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
1572      echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should."
1573      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST."
1574      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST."
1575      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1576      return
1577    fi
1578
1579    if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then
1580      echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should."
1581      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS."
1582      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS."
1583      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1584      return
1585    fi
1586    #
1587    if [ -d ${R_SAVE}/${1} ] ; then
1588      cd ${R_SAVE}
1589    elif [ -d ${R_FIGR}/${1} ] ; then
1590      cd ${R_FIGR}
1591    fi
1592
1593    IGCM_sys_Dods_Rm ${1}
1594    IGCM_sys_Dods_Cp ${1}
1595    RET=0
1596
1597    if [ ${RET} -gt 0 ] ; then
1598      echo "IGCM_sys_Put_Dods : error."
1599      IGCM_debug_Exit "IGCM_sys_Put_Dods"
1600    fi
1601  else
1602    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1603  fi
1604  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1605}
1606
1607##############################################################
1608# REBUILD OPERATOR
1609
1610function IGCM_sys_rebuild {
1611  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1612  if ( $DEBUG_sys ) ; then
1613    echo "IGCM_sys_rebuild :" $@
1614  fi
1615  ~p86ipsl/CESIUM/bin/rebuild -f -o $@
1616  if [ $? -gt 0 ] ; then
1617    echo "IGCM_sys_rebuild : erreur ${@}."
1618    IGCM_debug_Exit "rebuild"
1619  fi
1620
1621  IGCM_debug_PopStack "IGCM_sys_rebuild"
1622}
1623
1624############################################################
1625# Activate Running Environnment Variables
1626
1627function IGCM_sys_activ_variables {
1628  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1629  if ( $DEBUG_sys ) ; then
1630    echo "IGCM_sys_activ_variables"
1631  fi
1632
1633  ulimit -s unlimited
1634
1635  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1636}
1637
1638############################################################
1639# Desactivate Running Environnment Variables
1640
1641function IGCM_sys_desactiv_variables {
1642  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1643  if ( $DEBUG_sys ) ; then
1644    echo "IGCM_sys_desactiv_variables"
1645  fi
1646  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1647}
1648
1649############################################################
1650# Build MPI/OMP scripts run file (dummy function)
1651
1652function IGCM_sys_build_run_file {
1653
1654IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1655
1656}
1657
1658############################################################
1659# Build MPI/OMP scripts
1660function IGCM_sys_build_execution_scripts
1661{
1662  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1663  if ( $DEBUG_sys ) ; then
1664    echo "IGCM_sys_build_execution_scripts " $@
1665  fi
1666
1667    # Verification with MSUB parameter
1668  EXECUTION=${HOST_MPIRUN_COMMAND}
1669
1670  if ( ${OK_PARA_MPMD} ) ; then
1671
1672    if [ -f run_file ] ; then
1673      IGCM_sys_Rm -f run_file
1674    fi
1675    touch run_file
1676
1677# run_file construction
1678
1679# Then first loop on the components for the coupler ie oasis
1680
1681### the coupler ie oasis must be the first one
1682    for comp in ${config_ListOfComponents[*]} ; do
1683
1684      eval ExeNameIn=\${config_Executable_${comp}[0]}
1685      eval ExeNameOut=\${config_Executable_${comp}[1]}
1686
1687        # for CPL component only
1688      if [ "X${comp}" = "XCPL" ] ; then
1689
1690        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1691        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1692        echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1693      fi
1694    done
1695
1696# Then second loop on the components
1697
1698    for comp in ${config_ListOfComponents[*]} ; do
1699
1700      eval ExeNameIn=\${config_Executable_${comp}[0]}
1701      eval ExeNameOut=\${config_Executable_${comp}[1]}
1702
1703        # Only if we really have an executable for the component and not the coupler ie oasis:
1704      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1705
1706        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1707        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1708        echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1709      fi
1710    done
1711
1712    EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file"
1713
1714    IGCM_sys_Chmod u+x run_file
1715    if ( $DEBUG_sys ) ; then
1716      echo "run_file contains : "
1717      cat run_file
1718    fi
1719
1720  else # Only one executable. launch it.
1721
1722    #
1723    for comp in ${config_ListOfComponents[*]} ; do
1724
1725      eval ExeNameIn=\${config_Executable_${comp}[0]}
1726      eval ExeNameOut=\${config_Executable_${comp}[1]}
1727
1728      if  [ "X${ExeNameOut}" != X\"\" ] ; then
1729        if ( ${OK_PARA_MPI} ) ; then
1730          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1731          EXECUTION="${EXECUTION} -n ${comp_proc_mpi_loc} ./${ExeNameOut}"
1732        else
1733          EXECUTION="${EXECUTION} ./${ExeNameOut}"
1734        fi
1735        if ( ${OK_PARA_OMP} ) ; then
1736          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1737          EXECUTION="export OMP_NUM_THREADS=${comp_proc_omp_loc} ; ${EXECUTION} "
1738        fi
1739      fi
1740
1741    done
1742
1743  fi
1744
1745  IGCM_debug_Print 1 "sys Curie : execution command is "
1746  IGCM_debug_Print 1 "$EXECUTION"
1747
1748  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1749}
1750
1751##############################################################
1752# NCO OPERATOR
1753
1754function IGCM_sys_ncap2 {
1755  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1756  if ( $DEBUG_sys ) ; then
1757    echo "IGCM_sys_ncap2 :" $@
1758  fi
1759  ncap2 "$@"
1760  if [ $? -gt 0 ] ; then
1761    echo "IGCM_sys_ncap2 : erreur ${@}."
1762    IGCM_debug_Exit "ncap2"
1763  fi
1764
1765  IGCM_debug_PopStack "IGCM_sys_ncap2"
1766}
1767
1768function IGCM_sys_ncatted {
1769  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1770  if ( $DEBUG_sys ) ; then
1771    echo "IGCM_sys_ncatted :" $@
1772  fi
1773  ncatted "$@"
1774  if [ $? -gt 0 ] ; then
1775    echo "IGCM_sys_ncatted : erreur ${@}."
1776    IGCM_debug_Exit "ncatted"
1777  fi
1778
1779  IGCM_debug_PopStack "IGCM_sys_ncatted"
1780}
1781
1782function IGCM_sys_ncbo {
1783  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1784  if ( $DEBUG_sys ) ; then
1785    echo "IGCM_sys_ncbo :" $@
1786  fi
1787  ncbo $@
1788  if [ $? -gt 0 ] ; then
1789    echo "IGCM_sys_ncbo : erreur ${@}."
1790    IGCM_debug_Exit "ncbo"
1791  fi
1792
1793  IGCM_debug_PopStack "IGCM_sys_ncbo"
1794}
1795
1796function IGCM_sys_ncdiff {
1797  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1798  if ( $DEBUG_sys ) ; then
1799    echo "IGCM_sys_ncdiff :" $@
1800  fi
1801  ncdiff $@
1802  if [ $? -gt 0 ] ; then
1803    echo "IGCM_sys_ncdiff : erreur ${@}."
1804    IGCM_debug_Exit "ncdiff"
1805  fi
1806
1807  IGCM_debug_PopStack "IGCM_sys_ncdiff"
1808}
1809
1810function IGCM_sys_ncea {
1811  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1812  if ( $DEBUG_sys ) ; then
1813    echo "IGCM_sys_ncea :" $@
1814  fi
1815  ncea $@
1816  if [ $? -gt 0 ] ; then
1817    echo "IGCM_sys_ncea : erreur ${@}."
1818    IGCM_debug_Exit "ncea"
1819  fi
1820
1821  IGCM_debug_PopStack "IGCM_sys_ncea"
1822}
1823
1824function IGCM_sys_ncecat {
1825  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1826  if ( $DEBUG_sys ) ; then
1827    echo "IGCM_sys_ncecat :" $@
1828  fi
1829  ncecat $@
1830  if [ $? -gt 0 ] ; then
1831    echo "IGCM_sys_ncecat : erreur ${@}."
1832    IGCM_debug_Exit "ncecat"
1833  fi
1834
1835  IGCM_debug_PopStack "IGCM_sys_ncecat"
1836}
1837
1838function IGCM_sys_ncflint {
1839  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1840  if ( $DEBUG_sys ) ; then
1841    echo "IGCM_sys_ncflint :" $@
1842  fi
1843  ncflint $@
1844  if [ $? -gt 0 ] ; then
1845    echo "IGCM_sys_ncflint : erreur ${@}."
1846    IGCM_debug_Exit "ncflint"
1847  fi
1848
1849  IGCM_debug_PopStack "IGCM_sys_ncflint"
1850}
1851
1852function IGCM_sys_ncks {
1853  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1854  if ( $DEBUG_sys ) ; then
1855    echo "IGCM_sys_ncks :" $@
1856  fi
1857  ncks $@
1858  if [ $? -gt 0 ] ; then
1859    echo "IGCM_sys_ncks : erreur ${@}."
1860    IGCM_debug_Exit "ncks"
1861  fi
1862
1863  IGCM_debug_PopStack "IGCM_sys_ncks"
1864}
1865
1866function IGCM_sys_ncpdq {
1867  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1868  if ( $DEBUG_sys ) ; then
1869    echo "IGCM_sys_ncpdq :" $@
1870  fi
1871  ncpdq $@
1872  if [ $? -gt 0 ] ; then
1873    echo "IGCM_sys_ncpdq : erreur ${@}."
1874    IGCM_debug_Exit "ncpdq"
1875  fi
1876
1877  IGCM_debug_PopStack "IGCM_sys_ncpdq"
1878}
1879
1880function IGCM_sys_ncra {
1881  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1882  if ( $DEBUG_sys ) ; then
1883    echo "IGCM_sys_ncra :" $@
1884  fi
1885  ncra $@
1886  if [ $? -gt 0 ] ; then
1887    echo "IGCM_sys_ncra : erreur ${@}."
1888    IGCM_debug_Exit "ncra"
1889  fi
1890
1891  IGCM_debug_PopStack "IGCM_sys_ncra"
1892}
1893
1894function IGCM_sys_ncrcat {
1895  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1896  if ( $DEBUG_sys ) ; then
1897    echo "IGCM_sys_ncrcat :" $@
1898  fi
1899  ncrcat $@
1900  if [ $? -gt 0 ] ; then
1901    echo "IGCM_sys_ncrcat : erreur ${@}."
1902#       IGCM_debug_Exit "ncrcat"
1903  fi
1904
1905  IGCM_debug_PopStack "IGCM_sys_ncrcat"
1906}
1907
1908function IGCM_sys_ncrename {
1909  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1910  if ( $DEBUG_sys ) ; then
1911    echo "IGCM_sys_ncrename :" $@
1912  fi
1913  ncrename $@
1914  if [ $? -gt 0 ] ; then
1915    echo "IGCM_sys_ncrename : erreur ${@}."
1916    IGCM_debug_Exit "ncrename"
1917  fi
1918
1919  IGCM_debug_PopStack "IGCM_sys_ncrename"
1920}
1921
1922function IGCM_sys_ncwa {
1923  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1924  if ( $DEBUG_sys ) ; then
1925    echo "IGCM_sys_ncwa :" $@
1926  fi
1927  ncwa $@
1928  if [ $? -gt 0 ] ; then
1929    echo "IGCM_sys_ncwa : erreur ${@}."
1930    IGCM_debug_Exit "ncwa"
1931  fi
1932
1933  IGCM_debug_PopStack "IGCM_sys_ncwa"
1934}
1935
1936##############################################################
1937# CDO OPERATOR
1938
1939function IGCM_sys_cdo {
1940  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1941  if ( $DEBUG_sys ) ; then
1942    echo "IGCM_sys_cdo :" $@
1943  fi
1944  \cdo $@
1945  if [ $? -gt 0 ] ; then
1946    echo "IGCM_sys_cdo : erreur ${@}."
1947    IGCM_debug_PopStack "IGCM_sys_cdo"
1948    return 1
1949  else
1950    IGCM_debug_PopStack "IGCM_sys_cdo"
1951    return 0
1952  fi
1953
1954  IGCM_debug_PopStack "IGCM_sys_cdo"
1955}
Note: See TracBrowser for help on using the repository browser.