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

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