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

Last change on this file since 685 was 685, checked in by mafoipsl, 12 years ago

On curie add variable to set OpenMP thread maximum memory and other variables required. Adapt execution command to send a script instead of an executable.

  • Property svn:keywords set to Revision Author Date
File size: 55.9 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:="/usr/bin/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
193#====================================================
194#- Number of core per node (max number of OpenMP task)
195NUM_COREPERNODE=8
196
197#====================================================
198#- Default number of MPI task for IPSL coupled model
199#- required for backward compatibility
200#-
201DEFAULT_NUM_PROC_OCE=5
202DEFAULT_NUM_PROC_CPL=1
203(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
204DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
205
206
207#D-#==================================================
208#D-function IGCM_sys_RshMaster
209#D-* Purpose: Connection to frontend machine.
210#D-* Examples:
211#D-
212function IGCM_sys_RshMaster {
213  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
214  /bin/ksh <<-EOF
215    export libIGCM=${libIGCM}
216    export DEBUG_debug=${DEBUG_debug}
217    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
218    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
219    ${@}
220EOF
221  if [ $? -gt 0 ] ; then
222    echo "IGCM_sys_RshMaster : erreur."
223    IGCM_debug_Exit "IGCM_sys_RshMaster"
224  fi
225  IGCM_debug_PopStack "IGCM_sys_RshMaster"
226}
227
228#D-#==================================================
229#D-function IGCM_sys_RshArchive
230#D-* Purpose: Archive rsh command
231#D-* Examples:
232#D-
233function IGCM_sys_RshArchive {
234  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
235  /bin/ksh <<-EOF
236    ${@}
237EOF
238  if [ $? -gt 0 ] ; then
239    echo "IGCM_sys_RshArchive : erreur."
240    IGCM_debug_Exit "IGCM_sys_RshArchive"
241  fi
242  IGCM_debug_PopStack "IGCM_sys_RshArchive"
243}
244
245#D-#==================================================
246#D-function IGCM_sys_RshPost
247#D-* Purpose: Post-process rsh command
248#D-* Examples:
249#D-
250function IGCM_sys_RshPost {
251  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
252  if ( $DEBUG_sys ) ; then
253    echo "IGCM_sys_RshPost :" $@
254  fi
255
256  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL
257  #cat tmp_IGCM_sys_RshPost_$$
258  # keep standard input (stdin) for the loop onto temporary file
259  cat >tmp_IGCM_sys_RshPost_$$
260
261# ============ FRONTEND START ============ #
262
263  /bin/ksh <tmp_IGCM_sys_RshPost_$$
264  if [ $? -gt 0 ] ; then
265    echo "IGCM_sys_RshPost : erreur."
266    IGCM_debug_Exit "IGCM_sys_RshPost"
267  fi
268  # delete temporary file
269  \rm tmp_IGCM_sys_RshPost_$$
270
271# ============ FRONTEND  END  ============ #
272
273# ============ CESIUM START ============ #
274#  typeset NB_ESSAI DELAI status i
275#  if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then
276#    #little hack so that rebuild submission is done on titane not an cesium
277#
278#    libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' )
279#    POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' )
280#    sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
281#    sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$
282#    sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
283#    sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$
284#    \mv tmp.txt tmp_IGCM_sys_RshPost_$$
285#
286#    echo cat tmp_IGCM_sys_RshPost_$$ AFTER
287#    cat tmp_IGCM_sys_RshPost_$$
288#
289#    /bin/ksh <tmp_IGCM_sys_RshPost_$$
290#    if [ $? -gt 0 ] ; then
291#      echo "IGCM_sys_RshPost : erreur."
292#      IGCM_debug_Exit "IGCM_sys_RshPost"
293#    fi
294#    # delete temporary file
295#    \rm tmp_IGCM_sys_RshPost_$$
296#
297#  else
298#    # number of tentative
299#    NB_ESSAI=10
300#    # time delay between tentative
301#    DELAI=10
302#    i=0
303#    while [ $i -ne $NB_ESSAI ] ; do
304#      ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$
305#      status=$?
306#      if [ ${status} -ne 0 ];
307#      then
308#       sleep $DELAI
309#      else
310#       break
311#      fi
312#      let i=$i+1
313#    done
314#    # delete temporary file
315#    \rm tmp_IGCM_sys_RshPost_$$
316#
317#    if [ ${status} -gt 0 ] ; then
318#      echo "IGCM_sys_RshPost : erreur."
319#      IGCM_debug_Exit "IGCM_sys_RshPost"
320#    fi
321#  fi
322
323# ============ CESIUM  END  ============ #
324
325  IGCM_debug_PopStack "IGCM_sys_RshPost"
326}
327
328#D-#==================================================
329#D-function IGCM_sys_SendMail
330#D-* Purpose: Send mail when simulation is over
331#D-* Examples:
332#D-
333function IGCM_sys_SendMail {
334  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
335  if ( $DEBUG_sys ) ; then
336    echo "IGCM_sys_SendMail :" $@
337  fi
338
339  if ( ${ExitFlag} ) ; then
340    status=failed
341  else
342    status=completed
343  fi
344
345  cat  << END_MAIL > job_end.mail
346Dear ${LOGIN},
347
348  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
349  Job started : ${DateBegin}
350  Job ended   : ${DateEnd}
351  Output files are available in ${R_SAVE}
352  Files to be rebuild are temporarily available in ${REBUILD_DIR}
353  Pre-packed files are temporarily available in ${R_BUFR}
354  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
355END_MAIL
356
357    if [ ! -z ${config_UserChoices_MailName} ] ; then
358        mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail
359    elif [ -f ~/.forward ] ; then
360        mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
361    fi
362    sleep 10
363    rm -f job_end.mail
364
365  if [ $? -gt 0 ] ; then
366    echo "IGCM_sys_SendMail : erreur."
367    IGCM_debug_Exit "IGCM_sys_SendMail"
368  fi
369  IGCM_debug_PopStack "IGCM_sys_SendMail"
370}
371
372#D-#==================================================
373#D-function IGCM_sys_Mkdir
374#D-* Purpose: Master locale mkdir command
375#D-* Examples:
376#D-
377function IGCM_sys_Mkdir {
378  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
379  if ( $DEBUG_sys ) ; then
380    echo "IGCM_sys_Mkdir :" $@
381  fi
382  if [ ! -d ${1} ]; then
383    \mkdir -p $1
384    if [ $? -gt 0 ] ; then
385      echo "IGCM_sys_Mkdir : erreur."
386      IGCM_debug_Exit "IGCM_sys_Mkdir"
387    fi
388  fi
389  # vérification :
390  if [ ! -d ${1} ] ; then
391    echo "IGCM_sys_Mkdir : erreur."
392    IGCM_debug_Exit "IGCM_sys_Mkdir"
393  fi
394  IGCM_debug_PopStack "IGCM_sys_Mkdir"
395}
396
397#D-#==================================================
398#D-function IGCM_sys_MkdirArchive
399#D-* Purpose: Mkdir on Archive
400#D-* Examples:
401#D-
402function IGCM_sys_MkdirArchive {
403  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
404  if ( $DEBUG_sys ) ; then
405    echo "IGCM_sys_MkdirArchive :" $@
406  fi
407  #- creation de repertoire sur le serveur fichier
408  if [ ! -d ${1} ]; then
409    \mkdir -p $1
410    if [ $? -gt 0 ] ; then
411      echo "IGCM_sys_MkdirArchive : erreur."
412      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
413    fi
414  fi
415  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
416}
417
418#D-#==================================================
419#D-function IGCM_sys_MkdirWork
420#D-* Purpose: Mkdir on Work
421#D-* Examples:
422#D-
423function IGCM_sys_MkdirWork {
424  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
425  if ( $DEBUG_sys ) ; then
426    echo "IGCM_sys_MkdirWork :" $@
427  fi
428  #- creation de repertoire sur le serveur fichier
429  if [ ! -d ${1} ]; then
430    \mkdir -p $1
431    if [ $? -gt 0 ] ; then
432      echo "IGCM_sys_MkdirWork : erreur."
433      IGCM_debug_Exit "IGCM_sys_MkdirWork"
434    fi
435  fi
436  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
437}
438
439#D-#==================================================
440#D-function IGCM_sys_Cd
441#D-* Purpose: master cd command
442#D-* Examples:
443#D-
444function IGCM_sys_Cd {
445  IGCM_debug_PushStack "IGCM_sys_Cd" $@
446  if ( $DEBUG_sys ) ; then
447    echo "IGCM_sys_Cd :" $@
448  fi
449  \cd $1
450  if [ $? -gt 0 ] ; then
451    echo "IGCM_sys_Cd : erreur."
452    IGCM_debug_Exit "IGCM_sys_Cd"
453  fi
454  IGCM_debug_PopStack "IGCM_sys_Cd"
455}
456
457#D-#==================================================
458#D-function IGCM_sys_Chmod
459#D-* Purpose: Chmod
460#D-* Examples:
461#D-
462function IGCM_sys_Chmod {
463  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
464  if ( $DEBUG_sys ) ; then
465    echo "IGCM_sys_Chmod :" $@
466  fi
467  if [ $DRYRUN -le 1 ]; then
468    \chmod $@
469    if [ $? -gt 0 ] ; then
470      echo "IGCM_sys_Chmod : erreur."
471      IGCM_debug_Exit "IGCM_sys_Chmod"
472    fi
473  else
474    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
475  fi
476  IGCM_debug_PopStack "IGCM_sys_Chmod"
477}
478
479#D-#==================================================
480#D-function IGCM_sys_FileSize
481#D-* Purpose: Filesize
482#D-* Examples:
483#D-
484function IGCM_sys_FileSize {
485  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
486
487  typeset sizeF
488  set +A sizeF -- $( ls -la ${1} )
489  if [ $? -gt 0 ] ; then
490    IGCM_debug_Exit "IGCM_sys_FileSize"
491  fi
492  eval ${2}=${sizeF[4]}
493
494  IGCM_debug_PopStack "IGCM_sys_FileSize"
495}
496
497#D-#==================================================
498#D-function IGCM_sys_TestDir
499#D-* Purpose: Test Directory that must exists
500#D-* Examples:
501#D-
502function IGCM_sys_TestDir {
503  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
504  if ( $DEBUG_sys ) ; then
505    echo "IGCM_sys_TestDir :" $@
506  fi
507  typeset ExistFlag
508  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
509  IGCM_debug_PopStack "IGCM_sys_TestDir"
510
511  return ${ExistFlag}
512}
513
514#D-#==================================================
515#D-function IGCM_sys_TestDirArchive
516#D-* Purpose: Test Directory that must exists on Archive
517#D-* Examples:
518#D-
519function IGCM_sys_TestDirArchive {
520  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
521  if ( $DEBUG_sys ) ; then
522    echo "IGCM_sys_TestDirArchive :" $@
523  fi
524  typeset ExistFlag
525  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
526  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
527
528  return ${ExistFlag}
529}
530
531#D-#==================================================
532#D-function IGCM_sys_IsFileArchived
533#D-* Purpose: Test file that must NOT EXISTS on Archive
534#D-* Examples:
535#D-
536function IGCM_sys_IsFileArchived {
537  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
538  if ( $DEBUG_sys ) ; then
539    echo "IGCM_sys_IsFileArchived :" $@
540  fi
541  typeset IsArchivedFlag
542  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/ccc\/store ) != X ] && echo 0 || echo 1 )
543  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
544
545  return ${IsArchivedFlag}
546}
547
548#D-#==================================================
549#D-function IGCM_sys_TestFileArchive
550#D-* Purpose: Test file that must NOT EXISTS on Archive
551#D-* Examples:
552#D-
553function IGCM_sys_TestFileArchive {
554  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
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/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} ] && [ ! -f ${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 -rL $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
1184  typeset NB_ESSAI DELAI RET i
1185
1186  # number of tentative
1187  NB_ESSAI=3
1188  # time delay between tentative
1189  DELAI=2
1190
1191  if [ $DRYRUN = 0 ]; then
1192    if [ ! -f ${1} ] ; then
1193      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
1194      IGCM_debug_PopStack "IGCM_sys_Put_Out"
1195      return 1
1196    fi
1197    #
1198    IGCM_sys_MkdirArchive $( dirname $2 )
1199    #
1200
1201    #=====================================================
1202    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1203    #=====================================================
1204
1205    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
1206    #if [ $? -eq 0 ] ; then
1207    #    typeset WORKPATH FILEPATH
1208    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" )
1209    #    IGCM_sys_MkdirWork ${WORKPATH}
1210    #    FILEPATH=${WORKPATH}/$( basename $2 )
1211    #    #
1212    #    IGCM_sys_Cp ${1} ${FILEPATH}
1213    #fi
1214
1215    if [ X${JobType} = XRUN ] ; then
1216      if [ X${3} = X ] ; then
1217        IGCM_sys_Chmod 444 ${1}
1218      fi
1219    fi
1220    #
1221
1222    (( i = 0 ))
1223    while [ $i -lt $NB_ESSAI ] ; do
1224    # USUAL WAY
1225      \cp $1 $2 > out_rsync 2>&1
1226      RET=$?
1227      if [ ${RET} -gt 0 ]; then
1228        IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed ${i}/${NB_ESSAI}"
1229        IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again."
1230        sleep $DELAI
1231      else
1232        break
1233      fi
1234      (( i = i + 1 ))
1235    done
1236
1237#       #RSYNC WITH NETWORK SSH CALL
1238#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1239#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1240
1241#       #RSYNC WITH NFS USE
1242#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1243#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1244
1245#       RET=$?
1246#       IGCM_sys_Rsync_out $RET
1247
1248#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1249#       (( RET=RET+$? ))
1250
1251    if [ ${RET} -gt 0 ] ; then
1252      echo "IGCM_sys_Put_Out : error."
1253      cat out_rsync
1254      IGCM_debug_Exit "IGCM_sys_Put_Out"
1255    else
1256      \rm out_rsync
1257    fi
1258  else
1259    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1260  fi
1261  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1262  return 0
1263}
1264
1265#D-#==================================================
1266#D-function IGCM_sys_PutBuffer_Out
1267#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1268#D-* Examples:
1269#D-
1270function IGCM_sys_PutBuffer_Out {
1271  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1272  if ( $DEBUG_sys ) ; then
1273    echo "IGCM_sys_PutBuffer_Out :" $@
1274  fi
1275  if [ $DRYRUN = 0 ]; then
1276    if [ ! -f ${1} ] ; then
1277      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1278      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1279      return 1
1280    fi
1281    #
1282    IGCM_sys_Mkdir $( dirname $2 )
1283    #
1284    typeset RET
1285
1286    if [ X${JobType} = XRUN ] ; then
1287      if [ X${3} = X ] ; then
1288        IGCM_sys_Chmod 444 ${1}
1289      fi
1290    fi
1291    #
1292    # USUAL WAY
1293    \cp $1 $2 > out_rsync 2>&1
1294    RET=$?
1295
1296    if [ ${RET} -gt 0 ] ; then
1297      echo "IGCM_sys_PutBuffer_Out : error."
1298      cat out_rsync
1299      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1300    else
1301      \rm out_rsync
1302    fi
1303  else
1304    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1305  fi
1306  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1307  return 0
1308}
1309
1310#D-#==================================================
1311#D-function IGCM_sys_Get
1312#D-* Purpose: Get a file from ${ARCHIVE}
1313#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1314#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1315function IGCM_sys_Get {
1316  IGCM_debug_PushStack "IGCM_sys_Get" $@
1317
1318  typeset DEST RET dm_liste ifile target file_work
1319  typeset NB_ESSAI DELAI status i
1320
1321  if ( $DEBUG_sys ) ; then
1322    echo "IGCM_sys_Get :" $@
1323  fi
1324
1325  # number of tentative
1326  NB_ESSAI=3
1327  # time delay between tentative
1328  DELAI=2
1329
1330  if [ $DRYRUN -le 2 ]; then
1331    if [ X${1} = X'/l' ] ; then
1332      # test if the first file is present in the old computation :
1333      eval set +A dm_liste \${${2}}
1334    else
1335      eval set +A dm_liste ${1}
1336    fi
1337    eval DEST=\${${#}}
1338
1339    #=====================================================
1340    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1341    #=====================================================
1342
1343    # Is it an R_OUT file (not R_IN) ?
1344    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1345    #if [ $? -eq 0 ] ; then
1346    #    # Yes  ? then we try to get it in SCRATCHDIR
1347    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" )
1348    #    if [ -f ${file_work[0]} ] ; then
1349    #   IGCM_sys_Cp ${file_work[*]} ${DEST}
1350    #   IGCM_debug_PopStack "IGCM_sys_Get"
1351    #   return
1352    #    fi
1353    #fi
1354
1355    ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1356    RET=$?
1357    if [ ${RET} -gt 0 ] ; then
1358      echo "WARNING IGCM_sys_Get : demigration error."
1359      cat out_rsync
1360      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
1361    fi
1362
1363    #if [ ${RET} -gt 0 ] ; then
1364    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
1365    #   cat out_rsync
1366    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
1367    #   sleep 30
1368    #   echo "We try another time"
1369    ##  dmget ${dm_liste[*]} > out_rsync 2>&1
1370    #   ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1371    #   RET=$?
1372    #   if [ ${RET} -gt 0 ] ; then
1373    #       echo "ERROR IGCM_sys_Get : again demigration error :"
1374    #       cat out_rsync
1375    #       IGCM_debug_Exit "IGCM_sys_Get"
1376    #   fi
1377    #    else
1378    #   echo "ERROR IGCM_sys_Get : demigration error :"
1379    #   cat out_rsync
1380    #   IGCM_debug_Exit "IGCM_sys_Get"
1381    #    fi
1382    #fi
1383
1384    #USUAL WAY
1385    if [ X${1} = X'/l' ] ; then
1386      (( RET=0 ))
1387      for target in ${dm_liste[*]} ; do
1388        local_file=$( basename ${target} )
1389        (( i = 0 ))
1390        # test if the target file is present before the loop
1391        IGCM_sys_TestFileArchive ${target}
1392        RET=$?
1393        if [ ${RET} -gt 0 ] ; then
1394          echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1395          IGCM_debug_Exit "IGCM_sys_Get"
1396        else
1397          while [ $i -lt $NB_ESSAI ] ; do
1398            \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1399            status=$?
1400            if [ ${status} -gt 0 ]; then
1401              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed ${i}/${NB_ESSAI}"
1402              IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
1403              sleep $DELAI
1404            else
1405              break
1406            fi
1407            (( i = i + 1 ))
1408          done
1409          (( RET = RET + status ))
1410        fi
1411      done
1412    else
1413      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1414      RET=$?
1415    fi
1416
1417#       #RSYNC WITH NETWORK SSH CALL
1418#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1419#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1420
1421#       #RSYNC WITH NFS USE
1422#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1423#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1424
1425#       RET=$?
1426#       IGCM_sys_Rsync_out $RET
1427
1428#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1429#       (( RET=RET+$? ))
1430
1431    if [ ${RET} -gt 0 ] ; then
1432      echo "IGCM_sys_Get : copy error."
1433      cat out_rsync
1434      IGCM_debug_Exit "IGCM_sys_Get"
1435    else
1436      \rm out_rsync
1437    fi
1438  else
1439    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1440  fi
1441  IGCM_debug_PopStack "IGCM_sys_Get"
1442}
1443
1444#D-#==================================================
1445#D-function IGCM_sys_GetBuffer
1446#D-* Purpose: Get a file from ${SCRATCHDIR}
1447#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1448#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1449function IGCM_sys_GetBuffer {
1450  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1451
1452  typeset DEST RET buf_liste ifile target file_work
1453
1454  if ( $DEBUG_sys ) ; then
1455    echo "IGCM_sys_GetBuffer :" $@
1456  fi
1457  if [ $DRYRUN -le 2 ]; then
1458    if [ X${1} = X'/l' ] ; then
1459      # test if the first file is present in the old computation :
1460      eval set +A buf_liste \${${2}}
1461    else
1462      eval set +A buf_liste ${1}
1463    fi
1464    eval DEST=\${${#}}
1465
1466    #USUAL WAY
1467    if [ X${1} = X'/l' ] ; then
1468      (( RET=0 ))
1469      for target in ${buf_liste[*]} ; do
1470        local_file=$( basename ${target} )
1471        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1472        (( RET = RET + $? ))
1473      done
1474    else
1475      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
1476      RET=$?
1477    fi
1478
1479    if [ ${RET} -gt 0 ] ; then
1480      echo "IGCM_sys_GetBuffer : copy error."
1481      cat out_rsync
1482      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1483    else
1484      \rm out_rsync
1485    fi
1486  else
1487    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1488  fi
1489  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1490}
1491
1492#D-#==================================================
1493#D-function IGCM_sys_GetDate_FichWork
1494#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1495#D-* Examples:
1496#D-
1497function IGCM_sys_GetDate_FichWork {
1498  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1499  if ( $DEBUG_sys ) ; then
1500    echo "IGCM_sys_GetDate_FichWork :" $@
1501  fi
1502  typeset dateF
1503  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1504  eval ${2}=${dateF[5]}
1505
1506    # donne la date filesys d'un fichier sur la machine work
1507  IGCM_debug_PopStack "IGCM_sys_FichWork"
1508}
1509
1510#D-#==================================================
1511#D-function IGCM_sys_GetDate_FichArchive
1512#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1513#D-* Examples:
1514#D-
1515function IGCM_sys_GetDate_FichArchive {
1516  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1517  if ( $DEBUG_sys ) ; then
1518    echo "IGCM_sys_GetDate_FichArchive :" $@
1519  fi
1520  typeset dateF
1521  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1522  eval ${2}=${dateF[5]}
1523
1524  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1525}
1526
1527#D-#==================================================
1528#D-function IGCM_sys_Dods_Rm
1529#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
1530#D-* Examples:
1531#D-
1532function IGCM_sys_Dods_Rm {
1533  if ( $DEBUG_sys ) ; then
1534    echo "IGCM_sys_Dods_Rm :" $@
1535  fi
1536  typeset RET
1537  RET=0
1538  if [ $DRYRUN = 0 ]; then
1539
1540#    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1541#      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1542#      echo "Nothing has been done."
1543#      return
1544#    fi
1545
1546    /ccc/cont003/home/dsm/p86ipsl/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
1547    RET=$?
1548
1549#       if [ ${RET} -gt 0 ] ; then
1550#           echo "IGCM_sys_Dods_Rm : error."
1551#           cat out_dods_rm
1552#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1553#       else
1554#           rm out_dods_rm
1555#       fi
1556
1557  else
1558    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1559  fi
1560  return $RET
1561}
1562
1563#D-#==================================================
1564#D-function IGCM_sys_Dods_Cp
1565#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1566#D-* Examples:
1567#D-
1568function IGCM_sys_Dods_Cp {
1569  if ( $DEBUG_sys ) ; then
1570    echo "IGCM_sys_Dods_Cp :" $@
1571  fi
1572  typeset RET
1573  RET=0
1574  if [ $DRYRUN = 0 ]; then
1575
1576#    if [ ! -d ${R_SAVE}/${1} ] ; then
1577#      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1578#      echo "Nothing has been done."
1579#      return
1580#    fi
1581
1582    /ccc/cont003/home/dsm/p86ipsl/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
1583    RET=$?
1584
1585#       if [ ${RET} -gt 0 ] ; then
1586#           echo "IGCM_sys_Dods_Cp : error."
1587#           cat out_dods_cp
1588#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1589#       else
1590#           rm out_dods_cp
1591#       fi
1592
1593  else
1594    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1595  fi
1596  return $RET
1597}
1598
1599#D-#==================================================
1600#D-function IGCM_sys_Put_Dods
1601#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1602#D-* Examples:
1603#D-
1604function IGCM_sys_Put_Dods {
1605  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1606  if ( $DEBUG_sys ) ; then
1607    echo "IGCM_sys_Put_Dods :" $@
1608  fi
1609  set -vx
1610  typeset RET
1611  if [ $DRYRUN = 0 ]; then
1612    if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
1613      echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should."
1614      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST."
1615      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST."
1616      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1617      return
1618    fi
1619
1620    if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then
1621      echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should."
1622      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS."
1623      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS."
1624      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1625      return
1626    fi
1627    #
1628    if [ -d ${R_SAVE}/${1} ] ; then
1629      cd ${R_SAVE}
1630    elif [ -d ${R_FIGR}/${1} ] ; then
1631      cd ${R_FIGR}
1632    fi
1633
1634    IGCM_sys_Dods_Rm ${1}
1635    IGCM_sys_Dods_Cp ${1}
1636    RET=0
1637
1638    if [ ${RET} -gt 0 ] ; then
1639      echo "IGCM_sys_Put_Dods : error."
1640      IGCM_debug_Exit "IGCM_sys_Put_Dods"
1641    fi
1642  else
1643    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1644  fi
1645  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1646}
1647
1648##############################################################
1649# REBUILD OPERATOR
1650
1651function IGCM_sys_rebuild {
1652  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1653  if ( $DEBUG_sys ) ; then
1654    echo "IGCM_sys_rebuild :" $@
1655  fi
1656  ~p86ipsl/CESIUM/bin/rebuild -f -o $@
1657  if [ $? -gt 0 ] ; then
1658    echo "IGCM_sys_rebuild : erreur ${@}."
1659    IGCM_debug_Exit "rebuild"
1660  fi
1661
1662  IGCM_debug_PopStack "IGCM_sys_rebuild"
1663}
1664
1665############################################################
1666# Activate Running Environnment Variables
1667
1668function IGCM_sys_activ_variables {
1669  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1670  if ( $DEBUG_sys ) ; then
1671    echo "IGCM_sys_activ_variables"
1672  fi
1673
1674  ulimit -s unlimited
1675
1676  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1677}
1678
1679############################################################
1680# Desactivate Running Environnment Variables
1681
1682function IGCM_sys_desactiv_variables {
1683  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1684  if ( $DEBUG_sys ) ; then
1685    echo "IGCM_sys_desactiv_variables"
1686  fi
1687  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1688}
1689
1690############################################################
1691# Build MPI/OMP scripts run file (dummy function)
1692
1693function IGCM_sys_build_run_file {
1694
1695IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1696
1697}
1698
1699############################################################
1700# Build MPI/OMP scripts
1701function IGCM_sys_build_execution_scripts
1702{
1703  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1704  if ( $DEBUG_sys ) ; then
1705    echo "IGCM_sys_build_execution_scripts " $@
1706  fi
1707
1708    # Verification with MSUB parameter
1709  EXECUTION=${HOST_MPIRUN_COMMAND}
1710
1711  if ( ${OK_PARA_MPMD} ) ; then
1712
1713    if [ -f run_file ] ; then
1714      IGCM_sys_Rm -f run_file
1715    fi
1716    touch run_file
1717
1718# run_file construction
1719
1720# Then first loop on the components for the coupler ie oasis
1721
1722### the coupler ie oasis must be the first one
1723    for comp in ${config_ListOfComponents[*]} ; do
1724
1725      eval ExeNameIn=\${config_Executable_${comp}[0]}
1726      eval ExeNameOut=\${config_Executable_${comp}[1]}
1727
1728        # for CPL component only
1729      if [ "X${comp}" = "XCPL" ] ; then
1730
1731        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1732        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1733        echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1734      fi
1735    done
1736
1737# Then second loop on the components
1738
1739    for comp in ${config_ListOfComponents[*]} ; do
1740
1741      eval ExeNameIn=\${config_Executable_${comp}[0]}
1742      eval ExeNameOut=\${config_Executable_${comp}[1]}
1743
1744        # Only if we really have an executable for the component and not the coupler ie oasis:
1745      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1746
1747        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1748        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1749        echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1750      fi
1751    done
1752
1753    EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file"
1754
1755    IGCM_sys_Chmod u+x run_file
1756    if ( $DEBUG_sys ) ; then
1757      echo "run_file contains : "
1758      cat run_file
1759    fi
1760
1761  else # Only one executable. launch it.
1762
1763    #
1764    for comp in ${config_ListOfComponents[*]} ; do
1765
1766      # Only if we really have an executable for the component :
1767      eval ExeNameOut=\${config_Executable_${comp}[1]}
1768      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
1769
1770        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1771        echo ""  >> script_${ExeNameOut}.ksh
1772        IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1773
1774        if ( ${OK_PARA_OMP} ) ; then
1775          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1776          echo ""  >> script_${ExeNameOut}.ksh
1777          echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1778          echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1779          echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1780          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1781        fi
1782
1783        if  ( ${OK_PARA_MPI} ) ; then
1784          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1785          # Default : ccc_mprun used if nb_proc gt 1
1786          # to have out/err per process on different files
1787          # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${SLURM_PROCID} 2>out_${ExeNameOut}.err.\${SLURM_PROCID}"  >> script_${ExeNameOut}.ksh
1788          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1789          EXECUTION="${HOST_MPIRUN_COMMAND} -n ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
1790        else
1791          # Default : ccc_mprun is NOT used if nb_proc eq 1
1792          # to have out/err per process on different files
1793          # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
1794          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1795          EXECUTION="/usr/bin/time ./script_${ExeNameOut}.ksh"
1796        fi
1797
1798        IGCM_debug_Print 1 "sys Curie : script_${ExeNameOut}.ksh contains"
1799        cat script_${ExeNameOut}.ksh
1800
1801      fi
1802
1803    done
1804
1805  fi
1806
1807  IGCM_debug_Print 1 "sys Curie : execution command is "
1808  IGCM_debug_Print 1 "$EXECUTION"
1809
1810  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1811}
1812
1813##############################################################
1814# NCO OPERATOR
1815
1816function IGCM_sys_ncap2 {
1817  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1818  if ( $DEBUG_sys ) ; then
1819    echo "IGCM_sys_ncap2 :" $@
1820  fi
1821  ncap2 "$@"
1822  if [ $? -gt 0 ] ; then
1823    echo "IGCM_sys_ncap2 : erreur ${@}."
1824    IGCM_debug_Exit "ncap2"
1825  fi
1826
1827  IGCM_debug_PopStack "IGCM_sys_ncap2"
1828}
1829
1830function IGCM_sys_ncatted {
1831  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1832  if ( $DEBUG_sys ) ; then
1833    echo "IGCM_sys_ncatted :" $@
1834  fi
1835  ncatted "$@"
1836  if [ $? -gt 0 ] ; then
1837    echo "IGCM_sys_ncatted : erreur ${@}."
1838    IGCM_debug_Exit "ncatted"
1839  fi
1840
1841  IGCM_debug_PopStack "IGCM_sys_ncatted"
1842}
1843
1844function IGCM_sys_ncbo {
1845  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1846  if ( $DEBUG_sys ) ; then
1847    echo "IGCM_sys_ncbo :" $@
1848  fi
1849  ncbo $@
1850  if [ $? -gt 0 ] ; then
1851    echo "IGCM_sys_ncbo : erreur ${@}."
1852    IGCM_debug_Exit "ncbo"
1853  fi
1854
1855  IGCM_debug_PopStack "IGCM_sys_ncbo"
1856}
1857
1858function IGCM_sys_ncdiff {
1859  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1860  if ( $DEBUG_sys ) ; then
1861    echo "IGCM_sys_ncdiff :" $@
1862  fi
1863  ncdiff $@
1864  if [ $? -gt 0 ] ; then
1865    echo "IGCM_sys_ncdiff : erreur ${@}."
1866    IGCM_debug_Exit "ncdiff"
1867  fi
1868
1869  IGCM_debug_PopStack "IGCM_sys_ncdiff"
1870}
1871
1872function IGCM_sys_ncea {
1873  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1874  if ( $DEBUG_sys ) ; then
1875    echo "IGCM_sys_ncea :" $@
1876  fi
1877  ncea $@
1878  if [ $? -gt 0 ] ; then
1879    echo "IGCM_sys_ncea : erreur ${@}."
1880    IGCM_debug_Exit "ncea"
1881  fi
1882
1883  IGCM_debug_PopStack "IGCM_sys_ncea"
1884}
1885
1886function IGCM_sys_ncecat {
1887  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1888  if ( $DEBUG_sys ) ; then
1889    echo "IGCM_sys_ncecat :" $@
1890  fi
1891  ncecat $@
1892  if [ $? -gt 0 ] ; then
1893    echo "IGCM_sys_ncecat : erreur ${@}."
1894    IGCM_debug_Exit "ncecat"
1895  fi
1896
1897  IGCM_debug_PopStack "IGCM_sys_ncecat"
1898}
1899
1900function IGCM_sys_ncflint {
1901  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1902  if ( $DEBUG_sys ) ; then
1903    echo "IGCM_sys_ncflint :" $@
1904  fi
1905  ncflint $@
1906  if [ $? -gt 0 ] ; then
1907    echo "IGCM_sys_ncflint : erreur ${@}."
1908    IGCM_debug_Exit "ncflint"
1909  fi
1910
1911  IGCM_debug_PopStack "IGCM_sys_ncflint"
1912}
1913
1914function IGCM_sys_ncks {
1915  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1916  if ( $DEBUG_sys ) ; then
1917    echo "IGCM_sys_ncks :" $@
1918  fi
1919  ncks $@
1920  if [ $? -gt 0 ] ; then
1921    echo "IGCM_sys_ncks : erreur ${@}."
1922    IGCM_debug_Exit "ncks"
1923  fi
1924
1925  IGCM_debug_PopStack "IGCM_sys_ncks"
1926}
1927
1928function IGCM_sys_ncpdq {
1929  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1930  if ( $DEBUG_sys ) ; then
1931    echo "IGCM_sys_ncpdq :" $@
1932  fi
1933  ncpdq $@
1934  if [ $? -gt 0 ] ; then
1935    echo "IGCM_sys_ncpdq : erreur ${@}."
1936    IGCM_debug_Exit "ncpdq"
1937  fi
1938
1939  IGCM_debug_PopStack "IGCM_sys_ncpdq"
1940}
1941
1942function IGCM_sys_ncra {
1943  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1944  if ( $DEBUG_sys ) ; then
1945    echo "IGCM_sys_ncra :" $@
1946  fi
1947  ncra $@
1948  if [ $? -gt 0 ] ; then
1949    echo "IGCM_sys_ncra : erreur ${@}."
1950    IGCM_debug_Exit "ncra"
1951  fi
1952
1953  IGCM_debug_PopStack "IGCM_sys_ncra"
1954}
1955
1956function IGCM_sys_ncrcat {
1957  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1958  if ( $DEBUG_sys ) ; then
1959    echo "IGCM_sys_ncrcat :" $@
1960  fi
1961  ncrcat $@
1962  if [ $? -gt 0 ] ; then
1963    echo "IGCM_sys_ncrcat : erreur ${@}."
1964#       IGCM_debug_Exit "ncrcat"
1965  fi
1966
1967  IGCM_debug_PopStack "IGCM_sys_ncrcat"
1968}
1969
1970function IGCM_sys_ncrename {
1971  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1972  if ( $DEBUG_sys ) ; then
1973    echo "IGCM_sys_ncrename :" $@
1974  fi
1975  ncrename $@
1976  if [ $? -gt 0 ] ; then
1977    echo "IGCM_sys_ncrename : erreur ${@}."
1978    IGCM_debug_Exit "ncrename"
1979  fi
1980
1981  IGCM_debug_PopStack "IGCM_sys_ncrename"
1982}
1983
1984function IGCM_sys_ncwa {
1985  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1986  if ( $DEBUG_sys ) ; then
1987    echo "IGCM_sys_ncwa :" $@
1988  fi
1989  ncwa $@
1990  if [ $? -gt 0 ] ; then
1991    echo "IGCM_sys_ncwa : erreur ${@}."
1992    IGCM_debug_Exit "ncwa"
1993  fi
1994
1995  IGCM_debug_PopStack "IGCM_sys_ncwa"
1996}
1997
1998##############################################################
1999# CDO OPERATOR
2000
2001function IGCM_sys_cdo {
2002  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
2003  if ( $DEBUG_sys ) ; then
2004    echo "IGCM_sys_cdo :" $@
2005  fi
2006  \cdo $@
2007  if [ $? -gt 0 ] ; then
2008    echo "IGCM_sys_cdo : erreur ${@}."
2009    IGCM_debug_PopStack "IGCM_sys_cdo"
2010    return 1
2011  else
2012    IGCM_debug_PopStack "IGCM_sys_cdo"
2013    return 0
2014  fi
2015
2016  IGCM_debug_PopStack "IGCM_sys_cdo"
2017}
2018
2019############################################################
2020# Check of space available on temporary filesytems
2021function IGCM_sys_check_quota {
2022    IGCM_debug_PushStack "IGCM_sys_check_quota"
2023    if ( $DEBUG_sys ) ; then
2024        echo "IGCM_sys_check_quota"
2025    fi
2026    IGCM_debug_PopStack "IGCM_sys_check_quota"
2027}
Note: See TracBrowser for help on using the repository browser.