source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh @ 1272

Last change on this file since 1272 was 1272, checked in by mafoipsl, 8 years ago

Add a system function IGCM_sys_atlas specially adapted on curie (bug ksh) and allowing error discovery for all systems.
Use IGCM_sys_atlas funcion in AA_atlas jobs.

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

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