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

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