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

Last change on this file since 1482 was 1481, checked in by jgipsl, 5 years ago

Added case for executionType=6. This is needed for ENSEMBLE configuration.

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