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

Last change on this file since 623 was 623, checked in by sdipsl, 12 years ago
  • adapt curie system for the pack
  • homogenize curie and titane system. Easier to maintain
  • Property svn:keywords set to Revision Author Date
File size: 53.3 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
201DEFAULT_NUM_PROC_ATM=26
202DEFAULT_NUM_PROC_TOTAL=32
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  if ( $DEBUG_sys ) ; then
553    echo "IGCM_sys_TestFileArchive :" $@
554  fi
555  typeset ExistFlag
556  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
557  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
558
559  return ${ExistFlag}
560}
561
562#D-#==================================================
563#D-function IGCM_sys_TestFileBuffer
564#D-* Purpose: Test file that must NOT EXISTS on Buffer
565#D-* Examples:
566#D-
567function IGCM_sys_TestFileBuffer {
568  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
569  typeset ExistFlag
570  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
571  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
572
573  return ${ExistFlag}
574}
575
576#D-#==================================================
577#D-function IGCM_sys_CountFileArchive
578#D-* Purpose: Count files on Archive filesystem
579#D-* Examples:
580#D-
581function IGCM_sys_CountFileArchive {
582  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
583  ls ${@} 2>/dev/null | wc -l
584  if [ $? -gt 0 ] ; then
585    echo "IGCM_sys_CountFileArchive : erreur."
586  fi
587  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
588}
589
590#D-#==================================================
591#D-function IGCM_sys_CountFileBuffer
592#D-* Purpose: Count files on Scratch filesystem
593#D-* Examples:
594#D-
595function IGCM_sys_CountFileBuffer {
596  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
597  ls ${@} 2>/dev/null | wc -l
598  if [ $? -gt 0 ] ; then
599    echo "IGCM_sys_CountFileBuffer : erreur."
600  fi
601  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
602}
603
604#D-#==================================================
605#D-function IGCM_sys_Tree
606#D-* Purpose: Tree directories with files on ${ARCHIVE}
607#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
608#D-
609function IGCM_sys_Tree {
610  IGCM_debug_PushStack "IGCM_sys_Tree" $@
611  if ( $DEBUG_sys ) ; then
612    echo "IGCM_sys_Tree :" $@
613  fi
614
615  \ls -lR ${@}
616
617  IGCM_debug_PopStack "IGCM_sys_Tree"
618}
619
620#D-#==================================================
621#D-function IGCM_sys_Tar
622#D-* Purpose: master tar command
623#D-* Examples:
624#D-
625function IGCM_sys_Tar {
626  IGCM_debug_PushStack "IGCM_sys_Tar" $@
627  if ( $DEBUG_sys ) ; then
628    echo "IGCM_sys_Tar :" $@
629  fi
630  \tar cf $@
631  if [ $? -gt 0 ] ; then
632    echo "IGCM_sys_Tar : erreur."
633    IGCM_debug_Exit "IGCM_sys_Tar"
634  fi
635  IGCM_debug_PopStack "IGCM_sys_Tar"
636}
637
638#D-#==================================================
639#D-function IGCM_sys_UnTar
640#D-* Purpose: master un-tar command
641#D-* Examples:
642#D-
643function IGCM_sys_UnTar {
644  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
645  if ( $DEBUG_sys ) ; then
646    echo "IGCM_sys_UnTar :" $@
647  fi
648  \tar xvf $1
649  if [ $? -gt 0 ] ; then
650    echo "IGCM_sys_UnTar : erreur."
651    IGCM_debug_Exit "IGCM_sys_UnTar"
652  fi
653  IGCM_debug_PopStack "IGCM_sys_UnTar"
654}
655
656#D-#==================================================
657#D-function IGCM_sys_Qsub
658#D-* Purpose: Qsub new job
659#D-* Examples:
660#D-
661function IGCM_sys_Qsub {
662  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
663  if ( $DEBUG_sys ) ; then
664    echo "IGCM_sys_Qsub :" $@
665  fi
666  typeset options
667  if [ ${config_UserChoices_JobName}.${CumulPeriod} = "." ] ; then
668    options=" -o ${Script_Output} -e ${Script_Output}"
669  else
670    options=" -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod}"
671  fi
672
673  /usr/local/bin/ccc_msub ${options} < $1
674  if [ $? -gt 0 ] ; then
675    echo "IGCM_sys_Qsub : erreur ${options} $1"
676    IGCM_debug_Exit "IGCM_sys_Qsub"
677  fi
678  IGCM_debug_PopStack "IGCM_sys_Qsub"
679}
680
681#D-#==================================================
682#D-function IGCM_sys_QsubPost
683#D-* Purpose: Qsub new job on scalaire
684#D-* Examples:
685#D-
686function IGCM_sys_QsubPost {
687  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
688  if ( $DEBUG_sys ) ; then
689    echo "IGCM_sys_QsubPost :" $@
690  fi
691  /usr/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out ${libIGCM_POST}/$1.job
692  if [ $? -gt 0 ] ; then
693    echo "IGCM_sys_QsubPost : erreur " $@
694    IGCM_debug_Exit "IGCM_sys_QsubPost"
695  fi
696  IGCM_debug_PopStack "IGCM_sys_QsubPost"
697}
698
699#D-*************************
700#D- File transfer functions
701#D-*************************
702#D-
703
704#D-#==================================================
705#D-function IGCM_sys_Rsync_out
706#D-* Purpose: treat return val of rsync
707#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
708#D-  Error values and explanations can depend on your system version.
709function IGCM_sys_Rsync_out {
710  RET=$1
711  if [ ! $RET ] ; then
712    echo "rsync error !"
713  fi
714
715  if [ $MYLANG = "fr" ]; then
716    case $RET in
717    0)  return ;;
718    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
719      echo "Erreur de syntaxe ou d'utilisation."
720      return;;
721    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
722      echo "Incompatibilité de protocole."
723      return;;
724    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
725      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
726      echo "répertoires"
727      return;;
728    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
729      echo "Action demandée non supportée : une tentative de manipulation de"
730      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
731      echo "été faite ; ou une option qui est supportée par le  client  mais"
732      echo "pas par le serveur a été spécifiée."
733      return;;
734    10) echo "Erreur de rsync ; RERR_SOCKETIO"
735      echo "Erreur dans le socket d'entrée sortie"
736      return;;
737    11) echo "Erreur de rsync ; RERR_FILEIO"
738      echo "Erreur d'entrée sortie fichier"
739      return;;
740    12) echo "Erreur de rsync ; RERR_STREAMIO"
741      echo "Erreur dans flux de donnée du protocole rsync"
742      return;;
743    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
744      echo "Erreur avec les diagnostics du programme"
745      return;;
746    14) echo "Erreur de rsync ; RERR_IPC"
747      echo "Erreur dans le code IPC"
748      return;;
749    20) echo "Erreur de rsync ; RERR_SIGNAL"
750      echo "SIGUSR1 ou SIGINT reçu"
751      return;;
752    21) echo "Erreur de rsync ; RERR_WAITCHILD"
753      echo "Une erreur retournée par waitpid()"
754      return;;
755    22) echo "Erreur de rsync ; RERR_MALLOC"
756      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
757      return;;
758    23) echo ""
759      echo "Erreur fichier inexistant"
760      return;;
761    30) echo "Erreur de rsync ; RERR_TIMEOUT"
762      echo "Temps d'attente écoulé dans l'envoi/réception de données"
763      return;;
764    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
765      return;;
766    esac
767  elif [ $MYLANG = "en" ] ; then
768    case $RET in
769    0)  return;;
770    1)  echo "rsync error : Syntax or usage error "
771      return;;
772    2)  echo "rsync error : Protocol incompatibility "
773      return;;
774    3)  echo "rsync error : Errors selecting input/output files, dirs"
775      return;;
776    4)  echo "rsync error : Requested action not supported: an attempt"
777      echo "was made to manipulate 64-bit files on a platform that cannot support"
778      echo "them; or an option was specified that is supported by the client and"
779      echo "not by the server."
780      return;;
781    5)  echo "rsync error : Error starting client-server protocol"
782      return;;
783    10) echo "rsync error : Error in socket I/O "
784      return;;
785    11) echo "rsync error : Error in file I/O "
786      return;;
787    12) echo "rsync error : Error in rsync protocol data stream "
788      return;;
789    13) echo "rsync error : Errors with program diagnostics "
790      return;;
791    14) echo "rsync error : Error in IPC code "
792      return;;
793    20) echo "rsync error : Received SIGUSR1 or SIGINT "
794      return;;
795    21) echo "rsync error : Some error returned by waitpid() "
796      return;;
797    22) echo "rsync error : Error allocating core memory buffers "
798      return;;
799    23) echo "rsync error : Partial transfer due to error"
800      return;;
801    24) echo "rsync error : Partial transfer due to vanished source files"
802      return;;
803    30) echo "rsync error : Timeout in data send/receive "
804      return;;
805    *)  echo "rsync error : return code of rsync unknown :" $RET
806      return;;
807    esac
808  else
809    echo "unknown language $MYLANG."
810    return
811  fi
812}
813
814#D-#==================================================
815#D-function IGCM_sys_Miror_libIGCM
816#D-* Purpose: Mirror libIGCM PATH and lib to cesium
817#D-* Examples:
818#D-
819function IGCM_sys_Mirror_libIGCM {
820  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
821  if ( $DEBUG_sys ) ; then
822    echo "IGCM_sys_Mirror_libIGCM"
823  fi
824
825  typeset RET DEST
826
827  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
828
829  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
830  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
831  RET=$?
832
833  if [ ${RET} -gt 0 ] ; then
834    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium."
835    cat out_rsync
836  fi
837  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
838}
839
840#====================================================
841#- Call IGCM_sys_Mirror_libIGCM now !
842if ( $MirrorlibIGCM ) ; then
843  IGCM_sys_Mirror_libIGCM
844fi
845
846#D-#==================================================
847#D-function IGCM_sys_Cp
848#D-* Purpose: generic cp
849#D-* Examples:
850#D-
851function IGCM_sys_Cp {
852  IGCM_debug_PushStack "IGCM_sys_Cp" $@
853  if ( $DEBUG_sys ) ; then
854    echo "IGCM_sys_Cp :" $@
855  fi
856
857  typeset RET
858
859  echo cp $@ > out_rsync 2>&1
860  \cp $@ >> out_rsync 2>&1
861  RET=$?
862
863  if [ ${RET} -gt 0 ] ; then
864    echo "IGCM_sys_Cp : error."
865    cat out_rsync
866    IGCM_debug_Exit "IGCM_sys_Cp"
867  else
868    \rm out_rsync
869  fi
870  IGCM_debug_PopStack "IGCM_sys_Cp"
871}
872
873#D-#==================================================
874#D-function IGCM_sys_Rm
875#D-* Purpose: generic rm
876#D-* Examples:
877#D-
878function IGCM_sys_Rm {
879  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
880  if ( $DEBUG_sys ) ; then
881    echo "IGCM_sys_Rm :" $@
882  fi
883
884  typeset RET
885
886  echo rm $@ > out_rsync 2>&1
887  \rm $@ >> out_rsync 2>&1
888  RET=$?
889
890  if [ ${RET} -gt 0 ] ; then
891    echo "IGCM_sys_Rm : error."
892    cat out_rsync
893    IGCM_debug_Exit "IGCM_sys_Rm"
894  else
895    \rm out_rsync
896  fi
897  IGCM_debug_PopStack "IGCM_sys_Rm"
898}
899
900#D-#==================================================
901#D-function IGCM_sys_RmRunDir
902#D-* Purpose: rm tmpdir (dummy function most of the time batch
903#D-                      scheduler will do the job)
904#D-* Examples:
905#D-
906function IGCM_sys_RmRunDir {
907  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
908  if ( $DEBUG_sys ) ; then
909    echo "IGCM_sys_RmRunDir :" $@
910  fi
911
912  typeset RET
913
914  echo rm $@ > out_rsync 2>&1
915  \rm $@ >> out_rsync 2>&1
916  RET=$?
917
918  if [ ${RET} -gt 0 ] ; then
919    echo "IGCM_sys_RmRunDir : error."
920    cat out_rsync
921    IGCM_debug_Exit "IGCM_sys_RmRunDir"
922  else
923    \rm out_rsync
924  fi
925  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
926}
927
928#D-#==================================================
929#D-function IGCM_sys_Mv
930#D-* Purpose: generic move
931#D-* Examples:
932#D-
933function IGCM_sys_Mv {
934  IGCM_debug_PushStack "IGCM_sys_Mv" $@
935  if ( $DEBUG_sys ) ; then
936    echo "IGCM_sys_Mv :" $@
937  fi
938
939  if [ $DRYRUN = 0 ]; then
940
941    typeset RET
942
943    echo mv $@ > out_rsync 2>&1
944    \mv $@ >> out_rsync 2>&1
945    RET=$?
946
947    if [ ${RET} -gt 0 ] ; then
948      echo "IGCM_sys_Mv : error in mv."
949      cat out_rsync
950      IGCM_debug_Exit "IGCM_sys_Mv"
951    else
952      \rm out_rsync
953    fi
954  else
955    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
956  fi
957
958  IGCM_debug_PopStack "IGCM_sys_Mv"
959}
960
961#D-#==================================================
962#D-function IGCM_sys_Put_Dir
963#D-* Purpose: Copy a complete directory on $(ARCHIVE)
964#D-* Examples:
965#D-
966function IGCM_sys_Put_Dir {
967  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
968  if ( $DEBUG_sys ) ; then
969    echo "IGCM_sys_Put_Dir :" $@
970  fi
971  if [ $DRYRUN = 0 ]; then
972    if [ ! -d ${1} ] ; then
973      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
974      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
975      return
976    fi
977
978    typeset RET
979
980    # Only if we use rsync
981    #IGCM_sys_TestDirArchive $( dirname $2 )
982    #
983    #USUAL WAY
984    \cp -r $1 $2 > out_rsync 2>&1
985    RET=$?
986
987    if [ ${RET} -gt 0 ] ; then
988      echo "IGCM_sys_Put_Dir : error."
989      cat out_rsync
990      IGCM_debug_Exit "IGCM_sys_Put_Dir"
991    else
992      \rm out_rsync
993    fi
994  else
995    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
996  fi
997  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
998}
999
1000#D-#==================================================
1001#D-function IGCM_sys_Get_Dir
1002#D-* Purpose: Copy a complete directory from ${ARCHIVE}
1003#D-* Examples:
1004#D-
1005function IGCM_sys_Get_Dir {
1006  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
1007  if ( $DEBUG_sys ) ; then
1008    echo "IGCM_sys_Get_Dir :" $@
1009  fi
1010  if [ $DRYRUN = 0 ]; then
1011#    if [ ! -d ${1} ] ; then
1012#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
1013#      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
1014#      return
1015#    fi
1016
1017    typeset RET
1018
1019        # Only if we use rsync
1020        #IGCM_sys_TestDirArchive $( dirname $2 )
1021        #
1022        #USUAL WAY
1023        # add get (to demigrate all offline files) to reduce time of this command :
1024    ccc_hsm get $1/*
1025    \cp -r $1 $2 > out_rsync 2>&1
1026    RET=$?
1027
1028    if [ ${RET} -gt 0 ] ; then
1029      echo "IGCM_sys_Get_Dir : error."
1030      cat out_rsync
1031      IGCM_debug_Exit "IGCM_sys_Get_Dir"
1032    else
1033      \rm out_rsync
1034    fi
1035  else
1036    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1037  fi
1038  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
1039}
1040
1041#D-#==================================================
1042#D-function IGCM_sys_Get_Master
1043#D-* Purpose: Copy a complete directory from MASTER filesystem
1044#D-* Examples:
1045#D-
1046function IGCM_sys_Get_Master {
1047  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
1048  if ( $DEBUG_sys ) ; then
1049    echo "IGCM_sys_Get_Master :" $@
1050  fi
1051  if [ $DRYRUN = 0 ]; then
1052    if [ ! -d ${1} ] ; then
1053      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
1054      IGCM_debug_PopStack "IGCM_sys_Get_Master"
1055      return
1056    fi
1057
1058    typeset RET
1059
1060    #USUAL WAY
1061    \cp -r $1 $2 > out_rsync 2>&1
1062    RET=$?
1063
1064    if [ ${RET} -gt 0 ] ; then
1065      echo "IGCM_sys_Get_Master : error."
1066      cat out_rsync
1067      IGCM_debug_Exit "IGCM_sys_Get_Master"
1068    else
1069      \rm out_rsync
1070    fi
1071  else
1072    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1073  fi
1074  IGCM_debug_PopStack "IGCM_sys_Get_Master"
1075}
1076
1077#D-#==================================================
1078#D-function IGCM_sys_Put_Rest
1079#D-* Purpose: Put computied restarts on ${ARCHIVE}.
1080#D-           File and target directory must exist.
1081#D-* Examples:
1082#D-
1083function IGCM_sys_Put_Rest {
1084  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
1085  if ( $DEBUG_sys ) ; then
1086    echo "IGCM_sys_Put_Rest :" $@
1087  fi
1088  if [ $DRYRUN = 0 ]; then
1089    if [ ! -f ${1} ] ; then
1090      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
1091      IGCM_debug_Exit "IGCM_sys_Put_Rest"
1092    fi
1093
1094    typeset RET
1095    #
1096    if [ X${JobType} = XRUN ] ; then
1097      IGCM_sys_Chmod 444 ${1}
1098    fi
1099
1100    #
1101    # USUAL WAY
1102    \cp $1 $2 > out_rsync 2>&1
1103    RET=$?
1104
1105#       #RSYNC WITH NETWORK SSH CALL
1106#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1107#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1108
1109#       #RSYNC WITH NFS USE
1110#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1111#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1112
1113#       RET=$?
1114#       IGCM_sys_Rsync_out $RET
1115
1116#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1117#       (( RET=RET+$? ))
1118
1119    if [ ${RET} -gt 0 ] ; then
1120      echo "IGCM_sys_Put_Rest : error."
1121      cat out_rsync
1122      IGCM_debug_Exit "IGCM_sys_Put_Rest"
1123    else
1124      \rm out_rsync
1125    fi
1126  else
1127    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1128  fi
1129  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
1130}
1131
1132#D-#==================================================
1133#D-function IGCM_sys_PutBuffer_Rest
1134#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
1135#D-           File and target directory must exist.
1136#D-* Examples:
1137#D-
1138function IGCM_sys_PutBuffer_Rest {
1139  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
1140  if ( $DEBUG_sys ) ; then
1141    echo "IGCM_sys_PutBuffer_Rest :" $@
1142  fi
1143  if [ $DRYRUN = 0 ]; then
1144    if [ ! -f ${1} ] ; then
1145      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
1146      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1147    fi
1148
1149    typeset RET
1150    #
1151    if [ X${JobType} = XRUN ] ; then
1152      IGCM_sys_Chmod 444 ${1}
1153    fi
1154
1155    #
1156    # USUAL WAY
1157    \cp $1 $2 > out_rsync 2>&1
1158    RET=$?
1159
1160    if [ ${RET} -gt 0 ] ; then
1161      echo "IGCM_sys_PutBuffer_Rest : error."
1162      cat out_rsync
1163      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1164    else
1165      \rm out_rsync
1166    fi
1167  else
1168    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1169  fi
1170  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
1171}
1172
1173#D-#==================================================
1174#D-function IGCM_sys_Put_Out
1175#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
1176#D-* Examples:
1177#D-
1178function IGCM_sys_Put_Out {
1179  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
1180  if ( $DEBUG_sys ) ; then
1181    echo "IGCM_sys_Put_Out :" $@
1182  fi
1183  if [ $DRYRUN = 0 ]; then
1184    if [ ! -f ${1} ] ; then
1185      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
1186      IGCM_debug_PopStack "IGCM_sys_Put_Out"
1187      return 1
1188    fi
1189    #
1190    IGCM_sys_MkdirArchive $( dirname $2 )
1191    #
1192    typeset RET
1193
1194    #=====================================================
1195    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1196    #=====================================================
1197
1198    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
1199    #if [ $? -eq 0 ] ; then
1200    #    typeset WORKPATH FILEPATH
1201    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" )
1202    #    IGCM_sys_MkdirWork ${WORKPATH}
1203    #    FILEPATH=${WORKPATH}/$( basename $2 )
1204    #    #
1205    #    IGCM_sys_Cp ${1} ${FILEPATH}
1206    #fi
1207
1208    if [ X${JobType} = XRUN ] ; then
1209      if [ X${3} = X ] ; then
1210        IGCM_sys_Chmod 444 ${1}
1211      fi
1212    fi
1213    #
1214    # USUAL WAY
1215    \cp $1 $2 > out_rsync 2>&1
1216    RET=$?
1217
1218#       #RSYNC WITH NETWORK SSH CALL
1219#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1220#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1221
1222#       #RSYNC WITH NFS USE
1223#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1224#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1225
1226#       RET=$?
1227#       IGCM_sys_Rsync_out $RET
1228
1229#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1230#       (( RET=RET+$? ))
1231
1232    if [ ${RET} -gt 0 ] ; then
1233      echo "IGCM_sys_Put_Out : error."
1234      cat out_rsync
1235      IGCM_debug_Exit "IGCM_sys_Put_Out"
1236    else
1237      \rm out_rsync
1238    fi
1239  else
1240    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1241  fi
1242  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1243  return 0
1244}
1245
1246#D-#==================================================
1247#D-function IGCM_sys_PutBuffer_Out
1248#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1249#D-* Examples:
1250#D-
1251function IGCM_sys_PutBuffer_Out {
1252  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1253  if ( $DEBUG_sys ) ; then
1254    echo "IGCM_sys_PutBuffer_Out :" $@
1255  fi
1256  if [ $DRYRUN = 0 ]; then
1257    if [ ! -f ${1} ] ; then
1258      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1259      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1260      return 1
1261    fi
1262    #
1263    IGCM_sys_Mkdir $( dirname $2 )
1264    #
1265    typeset RET
1266
1267    if [ X${JobType} = XRUN ] ; then
1268      if [ X${3} = X ] ; then
1269        IGCM_sys_Chmod 444 ${1}
1270      fi
1271    fi
1272    #
1273    # USUAL WAY
1274    \cp $1 $2 > out_rsync 2>&1
1275    RET=$?
1276
1277    if [ ${RET} -gt 0 ] ; then
1278      echo "IGCM_sys_PutBuffer_Out : error."
1279      cat out_rsync
1280      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1281    else
1282      \rm out_rsync
1283    fi
1284  else
1285    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1286  fi
1287  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1288  return 0
1289}
1290
1291#D-#==================================================
1292#D-function IGCM_sys_Get
1293#D-* Purpose: Get a file from ${ARCHIVE}
1294#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1295#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1296function IGCM_sys_Get {
1297  IGCM_debug_PushStack "IGCM_sys_Get" $@
1298
1299  typeset DEST RET dm_liste ifile target file_work
1300
1301  if ( $DEBUG_sys ) ; then
1302    echo "IGCM_sys_Get :" $@
1303  fi
1304  if [ $DRYRUN -le 2 ]; then
1305    if [ X${1} = X'/l' ] ; then
1306      # test if the first file is present in the old computation :
1307      eval set +A dm_liste \${${2}}
1308    else
1309      eval set +A dm_liste ${1}
1310    fi
1311    eval DEST=\${${#}}
1312
1313    #=====================================================
1314    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1315    #=====================================================
1316
1317    # Is it an R_OUT file (not R_IN) ?
1318    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1319    #if [ $? -eq 0 ] ; then
1320    #    # Yes  ? then we try to get it in SCRATCHDIR
1321    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" )
1322    #    if [ -f ${file_work[0]} ] ; then
1323    #   IGCM_sys_Cp ${file_work[*]} ${DEST}
1324    #   IGCM_debug_PopStack "IGCM_sys_Get"
1325    #   return
1326    #    fi
1327    #fi
1328
1329    # test if the (first) file is present in the old computation :
1330    IGCM_sys_TestFileArchive ${dm_liste[0]}
1331    RET=$?
1332    if [ ${RET} -gt 0 ] ; then
1333      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1334      IGCM_debug_Exit "IGCM_sys_Get"
1335    fi
1336
1337    ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1338    RET=$?
1339    if [ ${RET} -gt 0 ] ; then
1340      echo "WARNING IGCM_sys_Get : demigration error."
1341      cat out_rsync
1342      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
1343    fi
1344
1345    #if [ ${RET} -gt 0 ] ; then
1346    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
1347    #   cat out_rsync
1348    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
1349    #   sleep 30
1350    #   echo "We try another time"
1351    ##  dmget ${dm_liste[*]} > out_rsync 2>&1
1352    #   ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1353    #   RET=$?
1354    #   if [ ${RET} -gt 0 ] ; then
1355    #       echo "ERROR IGCM_sys_Get : again demigration error :"
1356    #       cat out_rsync
1357    #       IGCM_debug_Exit "IGCM_sys_Get"
1358    #   fi
1359    #    else
1360    #   echo "ERROR IGCM_sys_Get : demigration error :"
1361    #   cat out_rsync
1362    #   IGCM_debug_Exit "IGCM_sys_Get"
1363    #    fi
1364    #fi
1365
1366    #USUAL WAY
1367    if [ X${1} = X'/l' ] ; then
1368      (( RET=0 ))
1369      for target in ${dm_liste[*]} ; do
1370        local_file=$( basename ${target} )
1371        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1372        (( RET = RET + $? ))
1373      done
1374    else
1375      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1376      RET=$?
1377    fi
1378
1379#       #RSYNC WITH NETWORK SSH CALL
1380#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1381#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1382
1383#       #RSYNC WITH NFS USE
1384#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1385#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1386
1387#       RET=$?
1388#       IGCM_sys_Rsync_out $RET
1389
1390#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1391#       (( RET=RET+$? ))
1392
1393    if [ ${RET} -gt 0 ] ; then
1394      echo "IGCM_sys_Get : copy error."
1395      cat out_rsync
1396      IGCM_debug_Exit "IGCM_sys_Get"
1397    else
1398      \rm out_rsync
1399    fi
1400  else
1401    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1402  fi
1403  IGCM_debug_PopStack "IGCM_sys_Get"
1404}
1405
1406#D-#==================================================
1407#D-function IGCM_sys_GetBuffer
1408#D-* Purpose: Get a file from ${SCRATCHDIR}
1409#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1410#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1411function IGCM_sys_GetBuffer {
1412  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1413
1414  typeset DEST RET buf_liste ifile target file_work
1415
1416  if ( $DEBUG_sys ) ; then
1417    echo "IGCM_sys_GetBuffer :" $@
1418  fi
1419  if [ $DRYRUN -le 2 ]; then
1420    if [ X${1} = X'/l' ] ; then
1421      # test if the first file is present in the old computation :
1422      eval set +A buf_liste \${${2}}
1423    else
1424      eval set +A buf_liste ${1}
1425    fi
1426    eval DEST=\${${#}}
1427
1428    #USUAL WAY
1429    if [ X${1} = X'/l' ] ; then
1430      (( RET=0 ))
1431      for target in ${buf_liste[*]} ; do
1432        local_file=$( basename ${target} )
1433        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1434        (( RET = RET + $? ))
1435      done
1436    else
1437      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
1438      RET=$?
1439    fi
1440
1441    if [ ${RET} -gt 0 ] ; then
1442      echo "IGCM_sys_GetBuffer : copy error."
1443      cat out_rsync
1444      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1445    else
1446      \rm out_rsync
1447    fi
1448  else
1449    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1450  fi
1451  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1452}
1453
1454#D-#==================================================
1455#D-function IGCM_sys_GetDate_FichWork
1456#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1457#D-* Examples:
1458#D-
1459function IGCM_sys_GetDate_FichWork {
1460  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1461  if ( $DEBUG_sys ) ; then
1462    echo "IGCM_sys_GetDate_FichWork :" $@
1463  fi
1464  typeset dateF
1465  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1466  eval ${2}=${dateF[5]}
1467
1468    # donne la date filesys d'un fichier sur la machine work
1469  IGCM_debug_PopStack "IGCM_sys_FichWork"
1470}
1471
1472#D-#==================================================
1473#D-function IGCM_sys_GetDate_FichArchive
1474#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1475#D-* Examples:
1476#D-
1477function IGCM_sys_GetDate_FichArchive {
1478  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1479  if ( $DEBUG_sys ) ; then
1480    echo "IGCM_sys_GetDate_FichArchive :" $@
1481  fi
1482  typeset dateF
1483  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1484  eval ${2}=${dateF[5]}
1485
1486  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1487}
1488
1489#D-#==================================================
1490#D-function IGCM_sys_Dods_Rm
1491#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
1492#D-* Examples:
1493#D-
1494function IGCM_sys_Dods_Rm {
1495  if ( $DEBUG_sys ) ; then
1496    echo "IGCM_sys_Dods_Rm :" $@
1497  fi
1498  typeset RET
1499  RET=0
1500  if [ $DRYRUN = 0 ]; then
1501
1502#    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1503#      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1504#      echo "Nothing has been done."
1505#      return
1506#    fi
1507
1508    /ccc/cont003/home/dsm/p86maf/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
1509    RET=$?
1510
1511#       if [ ${RET} -gt 0 ] ; then
1512#           echo "IGCM_sys_Dods_Rm : error."
1513#           cat out_dods_rm
1514#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1515#       else
1516#           rm out_dods_rm
1517#       fi
1518
1519  else
1520    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1521  fi
1522  return $RET
1523}
1524
1525#D-#==================================================
1526#D-function IGCM_sys_Dods_Cp
1527#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1528#D-* Examples:
1529#D-
1530function IGCM_sys_Dods_Cp {
1531  if ( $DEBUG_sys ) ; then
1532    echo "IGCM_sys_Dods_Cp :" $@
1533  fi
1534  typeset RET
1535  RET=0
1536  if [ $DRYRUN = 0 ]; then
1537
1538#    if [ ! -d ${R_SAVE}/${1} ] ; then
1539#      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1540#      echo "Nothing has been done."
1541#      return
1542#    fi
1543
1544    /ccc/cont003/home/dsm/p86maf/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
1545    RET=$?
1546
1547#       if [ ${RET} -gt 0 ] ; then
1548#           echo "IGCM_sys_Dods_Cp : error."
1549#           cat out_dods_cp
1550#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1551#       else
1552#           rm out_dods_cp
1553#       fi
1554
1555  else
1556    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1557  fi
1558  return $RET
1559}
1560
1561#D-#==================================================
1562#D-function IGCM_sys_Put_Dods
1563#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1564#D-* Examples:
1565#D-
1566function IGCM_sys_Put_Dods {
1567  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1568  if ( $DEBUG_sys ) ; then
1569    echo "IGCM_sys_Put_Dods :" $@
1570  fi
1571  set -vx
1572  typeset RET
1573  if [ $DRYRUN = 0 ]; then
1574    if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
1575      echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should."
1576      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST."
1577      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST."
1578      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1579      return
1580    fi
1581
1582    if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then
1583      echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should."
1584      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS."
1585      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS."
1586      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1587      return
1588    fi
1589    #
1590    if [ -d ${R_SAVE}/${1} ] ; then
1591      cd ${R_SAVE}
1592    elif [ -d ${R_FIGR}/${1} ] ; then
1593      cd ${R_FIGR}
1594    fi
1595
1596    IGCM_sys_Dods_Rm ${1}
1597    IGCM_sys_Dods_Cp ${1}
1598    RET=0
1599
1600    if [ ${RET} -gt 0 ] ; then
1601      echo "IGCM_sys_Put_Dods : error."
1602      IGCM_debug_Exit "IGCM_sys_Put_Dods"
1603    fi
1604  else
1605    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1606  fi
1607  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1608}
1609
1610##############################################################
1611# REBUILD OPERATOR
1612
1613function IGCM_sys_rebuild {
1614  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1615  if ( $DEBUG_sys ) ; then
1616    echo "IGCM_sys_rebuild :" $@
1617  fi
1618  ~p86ipsl/CESIUM/bin/rebuild -f -o $@
1619  if [ $? -gt 0 ] ; then
1620    echo "IGCM_sys_rebuild : erreur ${@}."
1621    IGCM_debug_Exit "rebuild"
1622  fi
1623
1624  IGCM_debug_PopStack "IGCM_sys_rebuild"
1625}
1626
1627############################################################
1628# Activate Running Environnment Variables
1629
1630function IGCM_sys_activ_variables {
1631  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1632  if ( $DEBUG_sys ) ; then
1633    echo "IGCM_sys_activ_variables"
1634  fi
1635
1636  ulimit -s unlimited
1637
1638  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1639}
1640
1641############################################################
1642# Desactivate Running Environnment Variables
1643
1644function IGCM_sys_desactiv_variables {
1645  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1646  if ( $DEBUG_sys ) ; then
1647    echo "IGCM_sys_desactiv_variables"
1648  fi
1649  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1650}
1651
1652############################################################
1653# Build MPI/OMP scripts run file (dummy function)
1654
1655function IGCM_sys_build_run_file {
1656
1657IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1658
1659}
1660
1661############################################################
1662# Build MPI/OMP scripts
1663function IGCM_sys_build_execution_scripts
1664{
1665  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1666  if ( $DEBUG_sys ) ; then
1667    echo "IGCM_sys_build_execution_scripts " $@
1668  fi
1669
1670    # Verification with MSUB parameter
1671  EXECUTION=${HOST_MPIRUN_COMMAND}
1672
1673  if ( ${OK_PARA_MPMD} ) ; then
1674
1675    if [ -f run_file ] ; then
1676      IGCM_sys_Rm -f run_file
1677    fi
1678    touch run_file
1679
1680# run_file construction
1681
1682# Then first loop on the components for the coupler ie oasis
1683
1684### the coupler ie oasis must be the first one
1685    for comp in ${config_ListOfComponents[*]} ; do
1686
1687      eval ExeNameIn=\${config_Executable_${comp}[0]}
1688      eval ExeNameOut=\${config_Executable_${comp}[1]}
1689
1690        # for CPL component only
1691      if [ "X${comp}" = "XCPL" ] ; then
1692
1693        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1694        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1695        echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1696      fi
1697    done
1698
1699# Then second loop on the components
1700
1701    for comp in ${config_ListOfComponents[*]} ; do
1702
1703      eval ExeNameIn=\${config_Executable_${comp}[0]}
1704      eval ExeNameOut=\${config_Executable_${comp}[1]}
1705
1706        # Only if we really have an executable for the component and not the coupler ie oasis:
1707      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1708
1709        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1710        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1711        echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1712      fi
1713    done
1714
1715    EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file"
1716
1717    IGCM_sys_Chmod u+x run_file
1718    if ( $DEBUG_sys ) ; then
1719      echo "run_file contains : "
1720      cat run_file
1721    fi
1722
1723  else # Only one executable. launch it.
1724
1725    #
1726    for comp in ${config_ListOfComponents[*]} ; do
1727
1728      eval ExeNameIn=\${config_Executable_${comp}[0]}
1729      eval ExeNameOut=\${config_Executable_${comp}[1]}
1730
1731      if  [ "X${ExeNameOut}" != X\"\" ] ; then
1732        if ( ${OK_PARA_MPI} ) ; then
1733          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1734          EXECUTION="${EXECUTION} -n ${comp_proc_mpi_loc} ./${ExeNameOut}"
1735        else
1736          EXECUTION="${EXECUTION} ./${ExeNameOut}"
1737        fi
1738        if ( ${OK_PARA_OMP} ) ; then
1739          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1740          EXECUTION="export OMP_NUM_THREADS=${comp_proc_omp_loc} ; ${EXECUTION} "
1741        fi
1742      fi
1743
1744    done
1745
1746  fi
1747
1748  IGCM_debug_Print 1 "sys Curie : execution command is "
1749  IGCM_debug_Print 1 "$EXECUTION"
1750
1751  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1752}
1753
1754##############################################################
1755# NCO OPERATOR
1756
1757function IGCM_sys_ncap2 {
1758  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1759  if ( $DEBUG_sys ) ; then
1760    echo "IGCM_sys_ncap2 :" $@
1761  fi
1762  ncap2 "$@"
1763  if [ $? -gt 0 ] ; then
1764    echo "IGCM_sys_ncap2 : erreur ${@}."
1765    IGCM_debug_Exit "ncap2"
1766  fi
1767
1768  IGCM_debug_PopStack "IGCM_sys_ncap2"
1769}
1770
1771function IGCM_sys_ncatted {
1772  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1773  if ( $DEBUG_sys ) ; then
1774    echo "IGCM_sys_ncatted :" $@
1775  fi
1776  ncatted "$@"
1777  if [ $? -gt 0 ] ; then
1778    echo "IGCM_sys_ncatted : erreur ${@}."
1779    IGCM_debug_Exit "ncatted"
1780  fi
1781
1782  IGCM_debug_PopStack "IGCM_sys_ncatted"
1783}
1784
1785function IGCM_sys_ncbo {
1786  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1787  if ( $DEBUG_sys ) ; then
1788    echo "IGCM_sys_ncbo :" $@
1789  fi
1790  ncbo $@
1791  if [ $? -gt 0 ] ; then
1792    echo "IGCM_sys_ncbo : erreur ${@}."
1793    IGCM_debug_Exit "ncbo"
1794  fi
1795
1796  IGCM_debug_PopStack "IGCM_sys_ncbo"
1797}
1798
1799function IGCM_sys_ncdiff {
1800  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1801  if ( $DEBUG_sys ) ; then
1802    echo "IGCM_sys_ncdiff :" $@
1803  fi
1804  ncdiff $@
1805  if [ $? -gt 0 ] ; then
1806    echo "IGCM_sys_ncdiff : erreur ${@}."
1807    IGCM_debug_Exit "ncdiff"
1808  fi
1809
1810  IGCM_debug_PopStack "IGCM_sys_ncdiff"
1811}
1812
1813function IGCM_sys_ncea {
1814  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1815  if ( $DEBUG_sys ) ; then
1816    echo "IGCM_sys_ncea :" $@
1817  fi
1818  ncea $@
1819  if [ $? -gt 0 ] ; then
1820    echo "IGCM_sys_ncea : erreur ${@}."
1821    IGCM_debug_Exit "ncea"
1822  fi
1823
1824  IGCM_debug_PopStack "IGCM_sys_ncea"
1825}
1826
1827function IGCM_sys_ncecat {
1828  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1829  if ( $DEBUG_sys ) ; then
1830    echo "IGCM_sys_ncecat :" $@
1831  fi
1832  ncecat $@
1833  if [ $? -gt 0 ] ; then
1834    echo "IGCM_sys_ncecat : erreur ${@}."
1835    IGCM_debug_Exit "ncecat"
1836  fi
1837
1838  IGCM_debug_PopStack "IGCM_sys_ncecat"
1839}
1840
1841function IGCM_sys_ncflint {
1842  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1843  if ( $DEBUG_sys ) ; then
1844    echo "IGCM_sys_ncflint :" $@
1845  fi
1846  ncflint $@
1847  if [ $? -gt 0 ] ; then
1848    echo "IGCM_sys_ncflint : erreur ${@}."
1849    IGCM_debug_Exit "ncflint"
1850  fi
1851
1852  IGCM_debug_PopStack "IGCM_sys_ncflint"
1853}
1854
1855function IGCM_sys_ncks {
1856  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1857  if ( $DEBUG_sys ) ; then
1858    echo "IGCM_sys_ncks :" $@
1859  fi
1860  ncks $@
1861  if [ $? -gt 0 ] ; then
1862    echo "IGCM_sys_ncks : erreur ${@}."
1863    IGCM_debug_Exit "ncks"
1864  fi
1865
1866  IGCM_debug_PopStack "IGCM_sys_ncks"
1867}
1868
1869function IGCM_sys_ncpdq {
1870  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1871  if ( $DEBUG_sys ) ; then
1872    echo "IGCM_sys_ncpdq :" $@
1873  fi
1874  ncpdq $@
1875  if [ $? -gt 0 ] ; then
1876    echo "IGCM_sys_ncpdq : erreur ${@}."
1877    IGCM_debug_Exit "ncpdq"
1878  fi
1879
1880  IGCM_debug_PopStack "IGCM_sys_ncpdq"
1881}
1882
1883function IGCM_sys_ncra {
1884  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1885  if ( $DEBUG_sys ) ; then
1886    echo "IGCM_sys_ncra :" $@
1887  fi
1888  ncra $@
1889  if [ $? -gt 0 ] ; then
1890    echo "IGCM_sys_ncra : erreur ${@}."
1891    IGCM_debug_Exit "ncra"
1892  fi
1893
1894  IGCM_debug_PopStack "IGCM_sys_ncra"
1895}
1896
1897function IGCM_sys_ncrcat {
1898  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1899  if ( $DEBUG_sys ) ; then
1900    echo "IGCM_sys_ncrcat :" $@
1901  fi
1902  ncrcat $@
1903  if [ $? -gt 0 ] ; then
1904    echo "IGCM_sys_ncrcat : erreur ${@}."
1905#       IGCM_debug_Exit "ncrcat"
1906  fi
1907
1908  IGCM_debug_PopStack "IGCM_sys_ncrcat"
1909}
1910
1911function IGCM_sys_ncrename {
1912  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1913  if ( $DEBUG_sys ) ; then
1914    echo "IGCM_sys_ncrename :" $@
1915  fi
1916  ncrename $@
1917  if [ $? -gt 0 ] ; then
1918    echo "IGCM_sys_ncrename : erreur ${@}."
1919    IGCM_debug_Exit "ncrename"
1920  fi
1921
1922  IGCM_debug_PopStack "IGCM_sys_ncrename"
1923}
1924
1925function IGCM_sys_ncwa {
1926  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1927  if ( $DEBUG_sys ) ; then
1928    echo "IGCM_sys_ncwa :" $@
1929  fi
1930  ncwa $@
1931  if [ $? -gt 0 ] ; then
1932    echo "IGCM_sys_ncwa : erreur ${@}."
1933    IGCM_debug_Exit "ncwa"
1934  fi
1935
1936  IGCM_debug_PopStack "IGCM_sys_ncwa"
1937}
1938
1939##############################################################
1940# CDO OPERATOR
1941
1942function IGCM_sys_cdo {
1943  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1944  if ( $DEBUG_sys ) ; then
1945    echo "IGCM_sys_cdo :" $@
1946  fi
1947  \cdo $@
1948  if [ $? -gt 0 ] ; then
1949    echo "IGCM_sys_cdo : erreur ${@}."
1950    IGCM_debug_PopStack "IGCM_sys_cdo"
1951    return 1
1952  else
1953    IGCM_debug_PopStack "IGCM_sys_cdo"
1954    return 0
1955  fi
1956
1957  IGCM_debug_PopStack "IGCM_sys_cdo"
1958}
Note: See TracBrowser for help on using the repository browser.