source: tags/libIGCM_v2.8/libIGCM_sys/libIGCM_sys_ciclad.ksh @ 1435

Last change on this file since 1435 was 1299, checked in by sdipsl, 8 years ago
  • small adjustements
  • Property svn:keywords set to Revision Date Author
File size: 38.3 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil
5# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#=========================================================
15# The documentation of this file can be automatically generated
16# if you use the prefix #D- for comments to be extracted.
17# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
18#=========================================================
19
20#D-#==================================================
21#D-LibIGCM_sys for ciclad
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 |            |         |                           |
46# |          |  Chmod 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 user names project maxCpuTime
65# $hostname ou hostname
66typeset HOST=${HOST:=$( hostname )}
67# $username ou whoami
68typeset LOGIN=${LOGIN:=$( whoami )}
69# $hostname of the MASTER job
70typeset MASTER=${MASTER:=$( hostname )}
71# project name
72typeset PROJECT=NONE
73# jobWarningDelay in seconds
74typeset jobWarningDelay=${PBS_WALLTIME}
75
76#D-
77#D-#==================================================
78#D-Program used in libIGCM
79#D-#==================================================
80
81# Submit command
82typeset SUBMIT=${SUBMIT:=qsub}
83# rsync with path
84typeset -r RSYNC=/usr/bin/rsync
85# RSYNC_opt args to rsync
86typeset -r RSYNC_opt="-va"
87# ie storage filesystem
88typeset -r STOREHOST=${MASTER}
89
90#====================================================
91# Access to module command
92#====================================================
93. /usr/share/Modules/init/ksh
94
95#====================================================
96# Set environment tools (ferret, nco, cdo, rebuild, ...)
97#====================================================
98. /home/igcmg/.atlas_env_ciclad_ksh
99[ ! X${TaskType} = Xchecking ] && IGCM_debug_Print 1 "List of loaded modules:"
100[ ! X${TaskType} = Xchecking ] && module list
101
102export PATH=${PATH}:/home/igcmg/rebuild/src_X64_CICLAD/modipsl_v2_2_3_netcdf4.2/bin/
103
104#====================================================
105# Host specific DIRECTORIES
106#====================================================
107
108#====================================================
109#- MirrorlibIGCM for frontend
110typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
111
112#====================================================
113#- libIGCM_POST for frontend
114typeset -r libIGCM_POST=${libIGCM}
115
116#====================================================
117#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
118typeset -r R_EXE="${MODIPSL}/bin"
119
120#====================================================
121#- SUBMIT_DIR : submission dir
122if [ X${PBS_O_WORKDIR} != X ] ; then
123  typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${PBS_O_WORKDIR}}
124else
125  typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${PWD}}
126fi
127
128#====================================================
129#- IN
130typeset -r R_IN=${R_IN:=/prodigfs/ipslfs/igcmg/IGCM}
131typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/prodigfs/ipslfs/igcmg/IGCM}
132
133#====================================================
134#- RUN_DIR_PATH : Temporary working directory (=> TMP)
135if [ X${PBS_JOBID} != X ] ; then
136  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/data/${LOGIN}/RUN_DIR/${PBS_JOBID}_${$}}
137else
138  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/tmp/tmp$$}
139fi
140
141#====================================================
142#- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs
143typeset -r OUTCOMMAND_PATH=/tmp
144
145#====================================================
146#- HOST_MPIRUN_COMMAND
147typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"}
148
149#====================================================
150#- Max number of arguments passed to nco operator or demigration command
151UNIX_MAX_LIMIT=360
152
153#====================================================
154#- set PackDefault to false on ciclad
155PackDefault=false
156
157#====================================================
158#- Default number of MPI task for IPSL coupled model
159#- required for backward compatibility
160#-
161DEFAULT_NUM_PROC_OCE=5
162DEFAULT_NUM_PROC_CPL=1
163(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
164
165#D-#==================================================
166#D-function IGCM_sys_defineArchives
167#D-* Purpose:
168#D-* Define ARCHIVE : Dedicated to large files
169#D-* Define STORAGE : Dedicated to small/medium files
170#D-* Define R_OUT   : Output tree located on ARCHIVE
171#D-* Define R_FIG   : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files)
172#D-* Define R_BUF   : Output tree located on STORAGE hosting files waiting for rebuild or pack processes
173#D-* if SpaceName=TEST nothing special will hapen
174#D-* Examples:
175#D-
176function IGCM_sys_defineArchives {
177  IGCM_debug_PushStack "IGCM_sys_defineArchives"
178
179  if [ ! X${config_UserChoices_ARCHIVE} = X ]; then
180    #====================================================
181    #- ARCHIVE (dedicated to large files)
182    ARCHIVE=${config_UserChoices_ARCHIVE}
183  else
184    #====================================================
185    #- ARCHIVE (dedicated to large files)
186    ARCHIVE=${ARCHIVE:=/data/${LOGIN}}
187  fi
188
189  if [ ! X${config_UserChoices_STORAGE} = X ]; then
190    #====================================================
191    #- STORAGE (dedicated to small/medium files)
192    STORAGE=${config_UserChoices_STORAGE}
193  else
194    #====================================================
195    #- STORAGE (dedicated to small/medium files)
196    STORAGE=${ARCHIVE}
197  fi
198
199  # ON CICLAD NO SPECIAL CASE WHEN X${config_UserChoices_SpaceName} = XTEST
200
201  #====================================================
202  #- R_OUT
203  R_OUT=${ARCHIVE}/IGCM_OUT
204
205  #====================================================
206  #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
207  R_FIG=${STORAGE}/IGCM_OUT
208
209  #====================================================
210  #- R_BUF (ONLY FOR double copy an scratch)
211  R_BUF=${STORAGE}/IGCM_OUT
212
213  IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
214  IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}"
215  IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}"
216
217  IGCM_debug_PopStack "IGCM_sys_defineArchives"
218}
219
220#D-#==================================================
221#D-function IGCM_sys_RshArchive
222#D-* Purpose: Archive rsh command
223#D-* Examples:
224#D-
225function IGCM_sys_RshArchive {
226  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
227  /bin/ksh <<-EOF
228    ${@}
229EOF
230  status=$?
231  if [ ${status} -gt 0 ] ; then
232    IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}"
233    IGCM_debug_Exit "IGCM_sys_RshArchive"
234  fi
235  IGCM_debug_PopStack "IGCM_sys_RshArchive"
236}
237
238#D-#==================================================
239#D-function IGCM_sys_RshArchive_NoError
240#D-* Purpose: Archive rsh command, without error
241#D-*          used only in monitoring.job
242#D-* Examples:
243#D-
244function IGCM_sys_RshArchive_NoError {
245  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@
246  /bin/ksh <<-EOF
247    ${@} 2> /dev/null
248EOF
249  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError"
250}
251
252#D-#==================================================
253#D-function IGCM_sys_MkdirArchive
254#D-* Purpose: Mkdir on Archive
255#D-* Examples:
256#D-
257function IGCM_sys_MkdirArchive {
258  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
259  if ( $DEBUG_sys ) ; then
260    echo "IGCM_sys_MkdirArchive :" $@
261  fi
262  #- creation de repertoire sur le serveur fichier
263  if [ ! -d ${1} ]; then
264    \mkdir -p $1
265    status=$?
266
267    if [ ${status} -gt 0 ] ; then
268      IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
269      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
270    fi
271  fi
272  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
273}
274
275#D-#==================================================
276#D-function IGCM_sys_TestDirArchive
277#D-* Purpose: Test Directory that must exists on Archive
278#D-* Examples:
279#D-
280function IGCM_sys_TestDirArchive {
281  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
282  if ( $DEBUG_sys ) ; then
283    echo "IGCM_sys_TestDirArchive :" $@
284  fi
285  typeset ExistFlag
286  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
287  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
288  return ${ExistFlag}
289}
290
291#D-#==================================================
292#D-function IGCM_sys_IsFileArchived
293#D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only
294#D-* Examples:
295#D-
296function IGCM_sys_IsFileArchived {
297  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
298  if ( $DEBUG_sys ) ; then
299    echo "IGCM_sys_IsFileArchived :" $@
300  fi
301  typeset IsArchivedFlag
302  # Never archived for this system
303  IsArchivedFlag=1
304  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
305
306  return ${IsArchivedFlag}
307}
308
309#D-#==================================================
310#D-function IGCM_sys_TestFileArchive
311#D-* Purpose: Test file that must NOT EXISTS on Archive
312#D-* Examples:
313#D-
314function IGCM_sys_TestFileArchive {
315  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
316  typeset ExistFlag
317  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
318  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
319
320  return ${ExistFlag}
321}
322
323#D-#==================================================
324#D-function IGCM_sys_CountFileArchive
325#D-* Purpose: Count files on Archive filesystem
326#D-* Examples:
327#D-
328function IGCM_sys_CountFileArchive {
329  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
330  ls ${@} 2>/dev/null | wc -l
331  if [ $? -gt 0 ] ; then
332    echo "IGCM_sys_CountFileArchive : erreur."
333  fi
334  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
335}
336
337#D-#==================================================
338#D-function IGCM_sys_Tree
339#D-* Purpose: Tree directories with files on ${ARCHIVE}
340#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
341#D-
342function IGCM_sys_Tree {
343  IGCM_debug_PushStack "IGCM_sys_Tree" $@
344  if ( $DEBUG_sys ) ; then
345    echo "IGCM_sys_Tree :" $@
346  fi
347
348  \ls -lR ${@}
349
350  IGCM_debug_PopStack "IGCM_sys_Tree"
351}
352
353#D-#==================================================
354#D-function IGCM_sys_Qsub
355#D-* Purpose: Qsub new job
356#D-* Examples:
357#D-
358function IGCM_sys_Qsub {
359  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
360  if ( $DEBUG_sys ) ; then
361    echo "IGCM_sys_Qsub :" $@
362  fi
363  typeset options status
364  options="-o ${SUBMIT_DIR}/${Script_Output}"
365  /usr/bin/qsub ${options} $1 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
366  status=$?
367
368  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
369  if [ ${status} -gt 0 ] ; then
370    IGCM_debug_Print 2 "IGCM_sys_Qsub ${options} $1 : error code ${status}"
371    IGCM_debug_Exit "IGCM_sys_Qsub"
372  else
373    JobID=$( gawk {'print $1'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
374  fi
375  IGCM_debug_PopStack "IGCM_sys_Qsub"
376}
377
378#D-#==================================================
379#D-function IGCM_sys_QsubPost
380#D-* Purpose: Qsub new job on scalaire
381#D-* Examples:
382#D-
383function IGCM_sys_QsubPost {
384  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
385  if ( $DEBUG_sys ) ; then
386    echo "IGCM_sys_QsubPost :" $@
387  fi
388  typeset options status
389  options="-o ${POST_DIR}/${Script_Post_Output}.out -v ${listVarEnv}"
390  /usr/bin/qsub ${options} ${libIGCM_POST}/$1.job > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
391  status=$?
392
393  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
394  if [ ${status} -gt 0 ] ; then
395    IGCM_debug_Print 2 "IGCM_sys_QsubPost ${options} ${libIGCM_POST}/$1.job : error code ${status}"
396    IGCM_debug_Exit "IGCM_sys_QsubPost"
397  else
398    JobID=$( gawk {'print $1'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
399  fi
400  IGCM_debug_PopStack "IGCM_sys_QsubPost"
401}
402
403#D-*************************
404#D- File transfer functions
405#D-*************************
406#D-
407
408#D-#==================================================
409#D-function IGCM_sys_RmRunDir
410#D-* Purpose: rm tmpdir (dummy function most of the time batch
411#D-                      scheduler will do the job)
412#D-* Examples:
413#D-
414function IGCM_sys_RmRunDir {
415  IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@
416  if ( $DEBUG_sys ) ; then
417    echo "IGCM_sys_RmRunDir :" $@
418  fi
419
420  typeset status
421
422  echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
423  \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
424  status=$?
425
426  if [ ${status} -gt 0 ] ; then
427    IGCM_debug_Print 1 "IGCM_sys_RmRunDir : rm error code is ${status}."
428    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
429    IGCM_debug_Exit "IGCM_sys_RmRunDir"
430  else
431    \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
432  fi
433  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
434}
435
436#D-#==================================================
437#D-function IGCM_sys_Put_Dir
438#D-* Purpose: Copy a complete directory on $(ARCHIVE)
439#D-* Examples:
440#D-
441function IGCM_sys_Put_Dir {
442  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
443  if ( $DEBUG_sys ) ; then
444    echo "IGCM_sys_Put_Dir :" $@
445  fi
446  if [ $DRYRUN = 0 ]; then
447    if [ ! -d ${1} ] ; then
448      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
449      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
450      return
451    fi
452
453    typeset status
454
455    # Only if we use rsync
456    #IGCM_sys_TestDirArchive $( dirname $2 )
457    #
458    #USUAL WAY
459    \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
460    status=$?
461
462    if [ ${status} -gt 0 ] ; then
463      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}"
464      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
465      IGCM_debug_Exit "IGCM_sys_Put_Dir"
466    else
467      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
468    fi
469  fi
470  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
471}
472
473#D-#==================================================
474#D-function IGCM_sys_Get_Dir
475#D-* Purpose: Copy a complete directory from ${ARCHIVE}
476#D-* Examples:
477#D-
478function IGCM_sys_Get_Dir {
479  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
480  if ( $DEBUG_sys ) ; then
481    echo "IGCM_sys_Get_Dir :" $@
482  fi
483  if [ $DRYRUN = 0 ]; then
484    typeset NB_ESSAI DELAI status i
485    # number of tentative
486    NB_ESSAI=3
487    # time delay between tentative
488    DELAI=2
489
490    #
491    # USUAL WAY
492    i=0
493    while [ $i -lt $NB_ESSAI ] ; do
494      \cp -ur $1 $2 >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
495      status=$?
496      if [ ${status} -gt 0 ] ; then
497        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}"
498        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
499        sleep $DELAI
500      else
501        break
502      fi
503      (( i = i + 1 ))
504    done
505
506    if [ ${status} -gt 0 ] ; then
507      IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
508      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
509      IGCM_debug_Exit "IGCM_sys_Get_Dir"
510    else
511      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
512    fi
513  fi
514  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
515}
516
517#D-#==================================================
518#D-function IGCM_sys_Put_Rest
519#D-* Purpose: Put computied restarts on ${ARCHIVE}.
520#D-           File and target directory must exist.
521#D-* Examples:
522#D-
523function IGCM_sys_Put_Rest {
524  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
525  if ( $DEBUG_sys ) ; then
526    echo "IGCM_sys_Put_Rest :" $@
527  fi
528  if [ $DRYRUN = 0 ]; then
529    if [ ! -f ${1} ] ; then
530      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
531      IGCM_debug_Exit "IGCM_sys_Put_Rest"
532    fi
533
534    typeset status
535    #
536    # USUAL WAY
537    \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
538    status=$?
539
540#       #RSYNC WITH NETWORK SSH CALL
541#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
542#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
543
544#       #RSYNC WITH NFS USE
545#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
546#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
547
548#       status=$?
549#       IGCM_sys_Rsync_out $status
550
551#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
552#       (( status=status+$? ))
553
554    if [ ${status} -gt 0 ] ; then
555      IGCM_debug_Print 2 "IGCM_sys_Put_Rest : cp failed error code ${status}"
556      [ -f ${1} ] && ls -l ${1}
557      [ -f ${2} ] && ls -l ${2}
558      [ -f ${2}/${1} ] && ls -l ${2}/${1}
559      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
560      IGCM_debug_Exit "IGCM_sys_Put_Rest"
561    else
562
563      if [ X${JobType} = XRUN ] ; then
564        [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
565        [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
566      fi
567
568      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
569    fi
570  fi
571  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
572}
573
574#D-#==================================================
575#D-function IGCM_sys_Put_Out
576#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
577#D-* Examples:
578#D-
579function IGCM_sys_Put_Out {
580  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
581  if ( $DEBUG_sys ) ; then
582    echo "IGCM_sys_Put_Out :" $@
583  fi
584
585  typeset status
586
587  if [ $DRYRUN = 0 ]; then
588    if [ ! -f ${1} ] ; then
589      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
590      IGCM_debug_PopStack "IGCM_sys_Put_Out"
591      return 1
592    fi
593    #
594    IGCM_sys_MkdirArchive $( dirname $2 )
595    #
596    if [ X${JobType} = XRUN ] ; then
597      if [ X${3} = X ] ; then
598        IGCM_sys_Chmod 444 ${1}
599      fi
600    fi
601    #
602
603    echo ${RSYNC} ${RSYNC_opt} $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
604    ${RSYNC} ${RSYNC_opt} $1 $2 >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
605    status=$?
606    IGCM_sys_Rsync_out $status
607
608    ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
609    (( status=status+$? ))
610
611    if [ ${status} -gt 0 ] ; then
612      IGCM_debug_Print 2 "IGCM_sys_Put_Out : rsync failed error code ${status}"
613      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
614      IGCM_debug_Exit "IGCM_sys_Put_Out"
615    else
616      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
617    fi
618  fi
619  IGCM_debug_PopStack "IGCM_sys_Put_Out"
620  return 0
621}
622
623#D-#==================================================
624#D-function IGCM_sys_Get
625#D-* Purpose: Get a file from ${ARCHIVE}
626#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
627#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
628function IGCM_sys_Get {
629  IGCM_debug_PushStack "IGCM_sys_Get" $@
630
631  typeset DEST status dm_liste
632
633  if ( $DEBUG_sys ) ; then
634    echo "IGCM_sys_Get :" $@
635  fi
636  if [ $DRYRUN -le 2 ]; then
637    if [ X${1} = X'/l' ] ; then
638      eval set +A dm_liste \${${2}}
639    else
640      dm_liste=${1}
641    fi
642    eval DEST=\${${#}}
643
644    # test if the (first) file is present in the old computation :
645    IGCM_sys_TestFileArchive ${dm_liste[0]}
646    status=$?
647    if [ ${status} -gt 0 ] ; then
648      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
649      IGCM_debug_Exit "IGCM_sys_Get"
650      return
651    fi
652
653    #USUAL WAY
654    \cp ${dm_liste[*]} ${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
655    status=$?
656
657    if [ ${status} -gt 0 ] ; then
658      IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}"
659      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
660      IGCM_debug_Exit "IGCM_sys_Get"
661    else
662      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
663    fi
664  fi
665  IGCM_debug_PopStack "IGCM_sys_Get"
666}
667
668#D-#==================================================
669#D-function IGCM_sys_GetDate_Monitoring
670#D-* Purpose: get the last year for which the monitoring has been computed
671#D-* Examples:
672#D-
673function IGCM_sys_GetDate_Monitoring {
674  IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@
675  if ( $DEBUG_sys ) ; then
676    echo "IGCM_sys_GetDate_Monitoring :" $@
677  fi
678
679  eval ${2}=$( cdo showyear ${1} 2> /dev/null | gawk '{ print $NF }' )
680
681  IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring"
682}
683
684#D-#==================================================
685#D-function IGCM_sys_Dods_Rm
686#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
687#D-* Examples:
688#D-
689function IGCM_sys_Dods_Rm {
690  if ( $DEBUG_sys ) ; then
691    echo "IGCM_sys_Dods_Rm :" $@
692  fi
693  return 0
694}
695
696#D-#==================================================
697#D-function IGCM_sys_Dods_Cp
698#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
699#D-* Examples:
700#D-
701function IGCM_sys_Dods_Cp {
702  if ( $DEBUG_sys ) ; then
703    echo "IGCM_sys_Dods_Cp :" $@
704  fi
705  return 0
706}
707
708#D-#==================================================
709#D-function IGCM_sys_Put_Dods
710#D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here
711#D-* Examples:
712#D-
713function IGCM_sys_Put_Dods {
714  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
715  if ( $DEBUG_sys ) ; then
716    echo "IGCM_sys_Put_Dods :" $@
717  fi
718  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
719}
720
721##############################################################
722# REBUILD OPERATOR
723
724#D-#==================================================
725#D-function IGCM_sys_sync
726#D-* Purpose: flush buffer on disk (dummy function on Ciclad)
727#D-* Examples:
728#D-
729function IGCM_sys_sync {
730  IGCM_debug_PushStack "IGCM_sys_sync" $@
731  if ( $DEBUG_sys ) ; then
732    echo "IGCM_sys_sync :" $@
733    echo "Dummy call, let the system do that."
734  fi
735  IGCM_debug_PopStack "IGCM_sys_sync"
736}
737
738############################################################
739# Activate Running Environnment Variables
740
741#D-#==================================================
742#D-function IGCM_sys_activ_variables
743#D-* Purpose: set environement variables prior to execution
744#D-* Examples:
745#D-
746function IGCM_sys_activ_variables {
747  IGCM_debug_PushStack "IGCM_sys_activ_variables"
748  if ( $DEBUG_sys ) ; then
749    echo "IGCM_sys_activ_variables"
750  fi
751
752# --------------------------------------------------------------------
753#D- MPI specifications
754# --------------------------------------------------------------------
755
756# --------------------------------------------------------------------
757#D- Other specifications
758# --------------------------------------------------------------------
759
760  ulimit -s unlimited
761
762  IGCM_debug_PopStack "IGCM_sys_activ_variables"
763}
764
765############################################################
766# Desactivate Running Environnment Variables
767
768#D-#==================================================
769#D-function IGCM_sys_desactiv_variables
770#D-* Purpose: unset environement variables after execution
771#D-* Examples:
772#D-
773function IGCM_sys_desactiv_variables {
774  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
775  if ( $DEBUG_sys ) ; then
776    echo "IGCM_sys_desactiv_variables"
777  fi
778# --------------------------------------------------------------------
779#D- MPI specifications
780# --------------------------------------------------------------------
781
782# --------------------------------------------------------------------
783#D- Other specifications
784# --------------------------------------------------------------------
785
786  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
787}
788
789############################################################
790# Update job headers to be used by the scheduler
791
792#D-#==================================================
793#D-function IGCM_sys_updateHeaders
794#D-* Purpose: Update job headers to be used by the scheduler
795#D-* Examples: IGCM_sys_updateHeaders /path/to/Job_MYEXP
796#D-
797function IGCM_sys_updateHeaders {
798  IGCM_debug_PushStack "IGCM_sys_updateHeaders"
799  if ( $DEBUG_sys ) ; then
800    echo "IGCM_sys_updateHeaders"
801  fi
802  typeset file
803  file=$1
804
805  if [ ${executionType} -eq 1 ] ; then
806    # MPMD + MPI
807    sed -e "/::openMPthreads::/d"                  \
808        -e "s/::JobNumProcTot::/${coreNumber}/"    \
809      ${file} > ${file}.tmp
810
811  elif [ ${executionType} -eq 2 ] ; then
812    # MPMD + MPI + OMP
813    sed -e "s/::openMPthreads::/${openMPthreads}/" \
814        -e "s/::JobNumProcTot::/${coreNumber}/"    \
815      ${file} > ${file}.tmp
816
817  elif [ ${executionType} -eq 3 ] ; then
818    # SPMD + MPI/OMP
819    sed -e "s/::openMPthreads::/${openMPthreads}/" \
820        -e "s/::JobNumProcTot::/${mpiTasks}/"      \
821      ${file} > ${file}.tmp
822
823  elif [ ${executionType} -eq 4 ] ; then
824    # SPMD + MPI only
825    sed -e "s/::JobNumProcTot::/${mpiTasks}/"      \
826        -e "/::openMPthreads::/d"                  \
827      ${file} > ${file}.tmp
828
829  elif [ ${executionType} -eq 5 ] ; then
830    # SPMD + OMP only
831    sed -e "s/::openMPthreads::/${openMPthreads}/" \
832        -e "/::JobNumProcTot::/d"                  \
833      ${file} > ${file}.tmp
834
835  elif [ ${executionType} -eq 6 ] ; then
836    # SEQUENTIAL THEN
837    sed -e "s/::JobNumProcTot::/1/"                \
838        -e "/::openMPthreads::/d"                  \
839      ${file} > ${file}.tmp
840
841  fi
842
843  IGCM_sys_Mv ${file}.tmp ${file}
844
845  IGCM_debug_PopStack "IGCM_sys_updateHeaders"
846}
847
848############################################################
849# Build MPI/OMP scripts run file (dummy function)
850
851#D-#==================================================
852#D-function IGCM_sys_build_run_file
853#D-* Purpose: build run file (deprecated)
854#D-* Examples:
855#D-
856function IGCM_sys_build_run_file {
857  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
858}
859
860############################################################
861# Build MPI/OMP scripts
862
863#D-#==================================================
864#D-function IGCM_sys_build_execution_scripts
865#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
866#D-* Examples:
867#D-
868function IGCM_sys_build_execution_scripts
869{
870  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
871  if ( $DEBUG_sys ) ; then
872    echo "IGCM_sys_build_execution_scripts " $@
873  fi
874
875  EXECUTION=${HOST_MPIRUN_COMMAND}
876
877  # MPMD mode
878  if ( ${OK_PARA_MPMD} ) ; then
879
880    # Only MPI (MPMD)
881    if  ( ! ${OK_PARA_OMP} ) ; then
882
883      if [ -f run_file ] ; then
884        IGCM_sys_Rm -f run_file
885      fi
886      touch run_file
887
888      # Build run_file
889
890      # First loop on the components for the coupler ie oasis (only if oasis3)
891      # the coupler ie oasis3 must be the first one
892      for comp in ${config_ListOfComponents[*]} ; do
893
894        eval ExeNameIn=\${config_Executable_${comp}[0]}
895        eval ExeNameOut=\${config_Executable_${comp}[1]}
896
897        # for CPL component only
898        if [ "X${comp}" = "XCPL" ]  && [ "X${ExeNameOut}" != X\"\" ] ; then
899          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
900          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
901          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file
902        fi
903      done
904
905      # Then second loop on the components
906      for comp in ${config_ListOfComponents[*]} ; do
907
908        eval ExeNameIn=\${config_Executable_${comp}[0]}
909        eval ExeNameOut=\${config_Executable_${comp}[1]}
910
911        # Only if we really have an executable for the component and not the coupler ie oasis:
912        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
913
914          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
915          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
916          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
917        fi
918      done
919
920      EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file"
921
922      IGCM_sys_Chmod u+x run_file
923      if ( $DEBUG_sys ) ; then
924        echo "run_file contains : "
925        cat run_file
926      fi
927 
928    # MPI-OpenMP (MPMD)
929    else
930
931      #  Hosts treatment
932      ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp
933
934      i=0
935      rm -f hosts
936      IGCM_debug_Print 1 "sys Ciclad, Hosts available :"
937      for nodes in `cat hosts.tmp` ; do
938        host[$i]=$nodes
939        echo "${host[$i]} slots=1 max_slots=1" >> hosts
940        IGCM_debug_Print 1 ${host[$i]}
941        i=$((i+1))
942      done
943      rm -f hosts.tmp
944
945      listnodes=${host[*]}
946
947      EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts"
948
949      # Initialisation
950      rank=0
951      current_core=0
952      core_per_node=8
953      init_exec=n
954
955      # Loop on the components
956      for comp in ${config_ListOfComponents[*]} ; do
957
958        eval ExeNameIn=\${config_Executable_${comp}[0]}
959        eval ExeNameOut=\${config_Executable_${comp}[1]}
960
961        # Not possible if oasis has an executable (i.e old version of oasis3)
962        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" = "XCPL" ] ) ; then
963          IGCM_debug_Exit "ERROR MPMD with hybrid MPI-OpenMP is not available with oasis3 version"
964          IGCM_debug_Print 2 "Only available with oasis3-MCT version coupler"
965          IGCM_debug_Verif_Exit
966        fi
967
968        # Only if we really have an executable for the component :
969        if [ "X${ExeNameOut}" != X\"\" ] ; then
970
971          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
972          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
973
974          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
975          echo ""  >> script_${ExeNameOut}.ksh
976          if [ ${comp_proc_omp_loc} -gt 1 ] ; then
977
978            # Check if the number of threads is correct
979            case ${comp_proc_omp_loc} in
980            2|4|8)
981              IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads"
982              ;;
983            *)
984              IGCM_debug_Exit "ERROR with OMP parameters !"
985              IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads"
986              IGCM_debug_Print 2 "Only 2,4,8 as number of OMP threads are possible "
987              IGCM_debug_Verif_Exit
988              ;;
989            esac
990            #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
991            #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
992            #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
993            echo "export OMP_STACKSIZE=200M" >> script_${ExeNameOut}.ksh
994            echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
995          fi
996          #echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh
997          #echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh
998          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
999          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1000
1001          if [ ${init_exec} = y ] ; then
1002            EXECUTION="${EXECUTION} : -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
1003          else
1004            EXECUTION="${EXECUTION} -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
1005            init_exec=y
1006          fi
1007
1008          # Build rankfile : method used to assign cores and nodes for the MPI process
1009          # Ex :
1010          #rank 0=curie5296 slot=0,1,2,3
1011          #rank 1=curie5296 slot=4,5,6,7
1012          # Example of final command :
1013          # mpirun -hostfile hosts -rankfile rankfile -np 27 ./script_lmdz.x.ksh : -np 5 ./script_opa.xx.ksh
1014          # with script_lmdz.x.ksh :
1015          # #!/bin/ksh
1016          #export OMP_STACKSIZE=200M
1017          #export OMP_NUM_THREADS=4
1018          #./lmdz.x
1019
1020          for nb_proc_mpi in `seq 0 $(($comp_proc_mpi_loc-1))`; do
1021            (( index_host = current_core / core_per_node ))
1022            host_value=${host[${index_host}]}
1023            (( slot =  current_core % core_per_node ))
1024            virg=","
1025            string_final=""
1026            for index in `seq $slot $(($slot+$comp_proc_omp_loc-1))`; do
1027              string=$index$virg
1028              string_final=$string_final$string
1029            done
1030            string_final=$( echo $string_final | sed "s/.$//" )
1031            echo "rank $rank=$host_value slot=$string_final" >> rankfile
1032            (( rank = rank + 1 ))
1033            (( current_core = current_core + comp_proc_omp_loc ))
1034          done
1035        fi
1036      done
1037    fi
1038
1039  # Only one executable (SPMD mode).
1040  else
1041
1042    for comp in ${config_ListOfComponents[*]} ; do
1043
1044      # Only if we really have an executable for the component :
1045      eval ExeNameOut=\${config_Executable_${comp}[1]}
1046      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
1047
1048        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1049        echo ""  >> script_${ExeNameOut}.ksh
1050        if ( ${OK_PARA_OMP} ) ; then
1051          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1052          echo "export OMP_STACKSIZE=200M" >> script_${ExeNameOut}.ksh
1053          echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1054        fi
1055        if  ( ${OK_PARA_MPI} ) ; then
1056          # Default : mpirun used if nb_proc gt 1
1057          # pour sortie out/err par process
1058          # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}"  >> script_${ExeNameOut}.ksh
1059          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1060          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1061          EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh"
1062        else
1063          # Default : mpirun is NOT used if nb_proc eq 1
1064          # pour sortie out/err par process
1065          # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
1066          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1067          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1068          EXECUTION="time ./script_${ExeNameOut}.ksh"
1069        fi
1070
1071        IGCM_debug_Print 1 "sys Ciclad : script_${ExeNameOut}.ksh contains"
1072        cat script_${ExeNameOut}.ksh
1073
1074      fi
1075
1076    done
1077
1078  fi
1079
1080  IGCM_debug_Print 1 "sys Ciclad : execution command is"
1081  IGCM_debug_Print 1 "$EXECUTION"
1082
1083  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1084}
1085
1086#D-#==================================================
1087#D-function IGCM_sys_check_path
1088#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
1089#D-* do not point to an important use directory. Stop immediately in that case.
1090#D-* Examples:
1091#D-
1092function IGCM_sys_check_path {
1093  IGCM_debug_PushStack "IGCM_sys_check_path"
1094  if ( $DEBUG_sys ) ; then
1095    echo "IGCM_sys_check_path"
1096  fi
1097
1098  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then
1099    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
1100    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
1101    IGCM_debug_Exit "This will stop the job"
1102  fi
1103  IGCM_debug_PopStack "IGCM_sys_check_path"
1104}
1105
1106#D-#==================================================
1107#D-function IGCM_sys_check_quota. Dummy call here
1108#D-* Purpose: check user quota. Stop the simulation if quota above 90%
1109#D-* Examples:
1110#D-
1111function IGCM_sys_check_quota {
1112  IGCM_debug_PushStack "IGCM_sys_check_quota"
1113  if ( $DEBUG_sys ) ; then
1114    echo "IGCM_sys_check_quota"
1115  fi
1116
1117  # TO BE IMPLEMENTED
1118
1119  IGCM_debug_PopStack "IGCM_sys_check_quota"
1120}
1121
1122#D-#==================================================
1123#D-function IGCM_sys_projectAccounting
1124#D-* Purpose: store project accounting information in a file
1125#D-* Examples:
1126#D-
1127function IGCM_sys_projectAccounting {
1128  IGCM_debug_PushStack "IGCM_sys_projectAccounting"
1129  if ( $DEBUG_sys ) ; then
1130    echo "IGCM_sys_check_quota"
1131  fi
1132
1133  touch $1
1134
1135  IGCM_debug_PopStack "IGCM_sys_projectAccounting"
1136}
1137
1138#D-#==================================================
1139#D-function IGCM_sys_getJobSchedulerID
1140#D-* Purpose: Get the job ID during execution
1141#D-* Examples: IGCM_sys_getJobSchedulerID jobSchedulerID
1142#D-
1143function IGCM_sys_getJobSchedulerID {
1144  IGCM_debug_PushStack "IGCM_sys_getJobSchedulerID"
1145  if ( $DEBUG_sys ) ; then
1146    echo "IGCM_sys_getJobSchedulerID"
1147  fi
1148
1149  eval ${1}=$( echo ${PBS_JOBID} | awk -F. '{print $1}' )
1150
1151  IGCM_debug_PopStack "IGCM_sys_getJobSchedulerID"
1152}
1153
1154#D-#==================================================
1155#D-function IGCM_sys_GetJobID
1156#D-* Purpose: Get the job ID from the JobName
1157#D-* Examples: IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID
1158#D-
1159function IGCM_sys_GetJobID {
1160  IGCM_debug_PushStack "IGCM_sys_GetJobID"
1161  if ( $DEBUG_sys ) ; then
1162    echo "IGCM_sys_GetJobID"
1163  fi
1164
1165  # With -f option, the full job name is given in the last column
1166  ID="$( qstat -u $2 | grep -w $1 | gawk '-F ' '{print $10}' )"
1167
1168  eval ${3}=${ID}
1169  IGCM_debug_PopStack "IGCM_sys_GetJobID"
1170}
1171
1172#D-#==================================================
1173#D-function IGCM_sys_CountJobInQueue
1174#D-* Purpose: Count number of users job
1175#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
1176#D-
1177function IGCM_sys_CountJobInQueue {
1178  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
1179  if ( $DEBUG_sys ) ; then
1180    echo "IGCM_sys_CountJobInQueue"
1181  fi
1182  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
1183}
1184
1185#D-#==================================================
1186#D-function IGCM_sys_atlas
1187#D-* Purpose: encapsulate atlas call so as to manage error code and curie specificity
1188#D-* Examples:
1189#D-
1190function IGCM_sys_atlas {
1191  IGCM_debug_PushStack "IGCM_sys_atlas" $@
1192  if ( $DEBUG_sys ) ; then
1193    echo "IGCM_sys_atlas :" $@
1194  fi
1195
1196  typeset status
1197
1198  \atlas $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
1199  status=$?
1200  if [ ${status} -gt 0 ] ; then
1201    echo "IGCM_sys_atlas : error code ${status}"
1202    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
1203    \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
1204    IGCM_debug_PopStack "IGCM_sys_atlas"
1205    return 1
1206  else
1207    IGCM_debug_PopStack "IGCM_sys_atlas"
1208    return 0
1209  fi
1210
1211  IGCM_debug_PopStack "IGCM_sys_atlas"
1212}
1213
Note: See TracBrowser for help on using the repository browser.