source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh @ 1204

Last change on this file since 1204 was 1201, checked in by sdipsl, 9 years ago
  • add jobWarningDelay in seconds to supervision messages see #253 (threshold for heartbeat)
  • add accountingProject to supervision messages see #255 (may ease gencmip6 data production tracking)
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

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

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

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

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

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

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

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Revision Author Date
File size: 38.8 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sébastien Denvil
5# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#=========================================================
15# The documentation of this file can be automatically generated
16# if you use the prefix #D- for comments to be extracted.
17# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
18#=========================================================
19
20#D-#==================================================
21#D-LibIGCM_sys for Ada
22#D-#==================================================
23#D-
24#D- This ksh library if a layer under some usefull
25#D-environment variables and shell commands.
26#D-All those definitions depend on host particularities.
27#D-It manages a stack mechanism and test validity of operations.
28#D-All function described bellow must be prefixed by IGCM_sys.
29
30#====================================================
31# libIGCM_sys PARAMETERS
32#====================================================
33
34#====================================================
35# set DEBUG_sys to true to output calls of function
36typeset -r DEBUG_sys=${DEBUG_sys:=true}
37
38#====================================================
39# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
40typeset -r DRYRUN=${DRYRUN:=0}
41
42# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
43# -------------------------------------------------------------------------------------
44# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
45# |          |  Cp/Exe/param/files |            |         |                           |
46# |          |  Chmod Qsub         |            |         |                           |
47# -------------------------------------------------------------------------------------
48# |    0     |       yes           |    yes     |  yes    |      yes                  |
49# -------------------------------------------------------------------------------------
50# |    1     |       yes           |    yes     |  yes    |      no                   |
51# -------------------------------------------------------------------------------------
52# |    2     |       yes           |    yes     |  no     |      no                   |
53# -------------------------------------------------------------------------------------
54# |    3     |       yes           |    no      |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56
57#=====================================================
58# Global Variables :
59#=====================================================
60# Language : "fr" or "en"
61typeset -r MYLANG="fr"
62
63#=====================================================
64# Host and user names
65# $hostname ou hostname
66typeset HOST=${HOST:=$( hostname )}
67# $username ou whoami
68typeset LOGIN=${LOGIN:=$( whoami )}
69# $hostname of the MASTER job
70typeset MASTER=ada
71# project name
72typeset PROJECT=$(echo ${LOADL_STEP_GROUP:=NONE})
73# jobWarningDelay in seconds
74typeset jobWarningDelay=$( TZ=utc date -d '1970-01-01 '${wall_clock_time} +%s )
75
76#D-
77#D-#==================================================
78#D-Program used in libIGCM
79#D-#==================================================
80
81# Submit command
82typeset SUBMIT=${SUBMIT:=llsubmit}
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=ergon
89typeset -r REMOTE_RSYNC=/usr/bin/rsync
90
91#====================================================
92# Set environment tools (ferret, nco, cdo, rebuild, ...)
93#====================================================
94source /smplocal/pub/Modules/default/init/ksh
95. /smphome/rech/psl/rpsl035/.atlas_env_ada_bash > /dev/null 2>&1
96export PATH=${PATH}:/smphome/rech/psl/rpsl035/AddNoise/src_X64_ADA/bin
97export PATH=${PATH}:/smphome/rech/psl/rpsl035/AddPerturbation/src_X64_ADA/bin
98export PATH=${PATH}:/smphome/rech/psl/rpsl035/bin/
99
100#====================================================
101# Host specific DIRECTORIES
102#====================================================
103
104#====================================================
105#- MirrorlibIGCM for frontend
106typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
107
108#====================================================
109#- libIGCM_POST for frontend
110typeset -r libIGCM_POST=${libIGCM}
111
112#====================================================
113#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
114typeset -r R_EXE="${MODIPSL}/bin"
115
116#====================================================
117#- SUBMIT_DIR : submission dir
118typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}}
119
120#====================================================
121#- IN
122typeset -r R_IN=${R_IN:=/workgpfs/rech/psl/rpsl035/IGCM}
123typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/u/rech/psl/rpsl376}
124
125#====================================================
126#- RUN_DIR_PATH : Temporary working directory (=> TMP)
127typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${TMPDIR}}
128
129#====================================================
130#- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs
131typeset -r OUTCOMMAND_PATH=${RUN_DIR_PATH:-/tmp}
132
133#====================================================
134#- HOST_MPIRUN_COMMAND
135typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time poe"}
136
137#====================================================
138#- Max number of arguments passed to nco operator or demigration command
139UNIX_MAX_LIMIT=360
140
141#====================================================
142#- set PackDefault to true on ada
143PackDefault=true
144
145#====================================================
146#- Number of core per node (max number of OpenMP task)
147NUM_COREPERNODE=8
148
149#====================================================
150#- Default number of MPI task for IPSL coupled model
151#- required for backward compatibility
152#-
153DEFAULT_NUM_PROC_OCE=5
154DEFAULT_NUM_PROC_CPL=1
155(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
156DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
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 SCRATCHDIR hosting files waiting for rebuild or pack processes
166#D-* if SpaceName=TEST everything is stored on WORKDIR
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=$(echo ${HOME} | sed -e "s,/.*home/,/arch/home/,")
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=${WORKDIR}
190  fi
191
192  if [ X${config_UserChoices_SpaceName} = XTEST ]; then
193    #====================================================
194    #- R_OUT
195    R_OUT=${WORKDIR}/IGCM_OUT
196
197    #====================================================
198    #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
199    R_FIG=${WORKDIR}/IGCM_OUT
200
201    IGCM_debug_Print 1 "SpaceName=TEST ==> OVERRULE destination path directories"
202
203  else
204    #====================================================
205    #- R_OUT
206    R_OUT=${ARCHIVE}/IGCM_OUT
207
208    #====================================================
209    #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
210    R_FIG=${ARCHIVE}/IGCM_OUT
211  fi
212
213  #====================================================
214  #- R_BUF (ONLY FOR double copy an scratch)
215  R_BUF=${WORKDIR}/IGCM_OUT
216
217  IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
218  IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}"
219  IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}"
220
221  IGCM_debug_PopStack "IGCM_sys_defineArchives"
222}
223
224#D-#==================================================
225#D-function IGCM_sys_RshArchive
226#D-* Purpose: Archive rsh command
227#D-* Examples:
228#D-
229function IGCM_sys_RshArchive {
230  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
231  DEBUG_sys=false IGCM_sys_IsFileArchived "$@"
232  if [ $? = 0 ] ; then
233    rsh ${STOREHOST} exec /bin/ksh <<-EOF
234    ${@}
235EOF
236    status=$?
237  else
238    /bin/ksh <<-EOF
239    ${@}
240EOF
241    status=$?
242  fi
243  if [ ${status} -gt 0 ] ; then
244    IGCM_debug_Print 2 "IGCM_sys_RshArchive : rsh or command failed error code ${status}"
245    IGCM_debug_Exit "IGCM_sys_RshArchive"
246  fi
247  IGCM_debug_PopStack "IGCM_sys_RshArchive"
248}
249
250#D-#==================================================
251#D-function IGCM_sys_RshArchive_NoError
252#D-* Purpose: Archive rsh command, without error
253#D-*          used only in monitoring.job
254#D-* Examples:
255#D-
256function IGCM_sys_RshArchive_NoError {
257  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@
258  DEBUG_sys=false IGCM_sys_IsFileArchived "$@"
259  if [ $? = 0 ] ; then
260    rsh ${STOREHOST} exec /bin/ksh <<-EOF
261    ${@} 2> /dev/null
262EOF
263  else
264    /bin/ksh <<-EOF
265    ${@} 2> /dev/null
266EOF
267  fi
268  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError"
269}
270
271#D-#==================================================
272#D-function IGCM_sys_MkdirArchive
273#D-* Purpose: Mkdir on Archive
274#D-* Examples:
275#D-
276function IGCM_sys_MkdirArchive {
277  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
278  if ( $DEBUG_sys ) ; then
279    echo "IGCM_sys_MkdirArchive :" $@
280  fi
281  #- creation de repertoire sur le serveur fichier
282  DEBUG_sys=false IGCM_sys_IsFileArchived $1
283  if [ $? = 0 ] ; then
284    rsh ${STOREHOST} -n mkdir -p $1
285    status=$?
286  else
287    mkdir -p $1
288    status=$?
289  fi
290
291  if [ ${status} -gt 0 ] ; then
292    IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : rsh or mkdir failed error code ${status}"
293    IGCM_debug_Exit "IGCM_sys_MkdirArchive"
294  fi
295  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
296}
297
298#D-#==================================================
299#D-function IGCM_sys_TestDirArchive
300#D-* Purpose: Test Directory that must exists on Archive
301#D-* Examples:
302#D-
303function IGCM_sys_TestDirArchive {
304  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
305  if ( $DEBUG_sys ) ; then
306    echo "IGCM_sys_TestDirArchive :" $@
307  fi
308  typeset ExistFlag
309  #Command depends on targeted file system
310  DEBUG_sys=false IGCM_sys_IsFileArchived $1
311  if [ $? = 0 ] ; then
312    ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" )
313  else
314    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
315  fi
316  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
317  return ${ExistFlag}
318}
319
320#D-#==================================================
321#D-function IGCM_sys_IsFileArchived
322#D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only
323#D-* Examples:
324#D-
325function IGCM_sys_IsFileArchived {
326  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
327  if ( $DEBUG_sys ) ; then
328    echo "IGCM_sys_IsFileArchived :" $@
329  fi
330  typeset IsArchivedFlag
331  IsArchivedFlag=$( [ "X$( echo $@ | grep \/arch\/home )" != "X" ] && echo 0 || echo 1 )
332  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
333
334  return ${IsArchivedFlag}
335}
336
337#D-#==================================================
338#D-function IGCM_sys_TestFileArchive
339#D-* Purpose: Test file that must NOT EXISTS on Archive
340#D-* Examples:
341#D-
342function IGCM_sys_TestFileArchive {
343  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
344  typeset ExistFlag
345  ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" )
346  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
347
348  return ${ExistFlag}
349}
350
351#D-#==================================================
352#D-function IGCM_sys_CountFileArchive
353#D-* Purpose: Count files on Archive filesystem
354#D-* Examples:
355#D-
356function IGCM_sys_CountFileArchive {
357  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
358  #Command depends on targeted file system
359  DEBUG_sys=false IGCM_sys_IsFileArchived $1
360  if [ $? = 0 ] ; then
361    IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l"
362    status=$?
363  else
364    ls ${@} 2>/dev/null | wc -l
365    status=$?
366  fi
367  if [ ${status} -gt 0 ] ; then
368    echo "IGCM_sys_CountFileArchive : erreur."
369  fi
370  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
371}
372
373#D-#==================================================
374#D-function IGCM_sys_Tree
375#D-* Purpose: Tree directories with files on ${ARCHIVE}
376#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
377#D-
378function IGCM_sys_Tree {
379  IGCM_debug_PushStack "IGCM_sys_Tree" $@
380  if ( $DEBUG_sys ) ; then
381    echo "IGCM_sys_Tree :" $@
382  fi
383
384  \mfls -R $@
385
386  IGCM_debug_PopStack "IGCM_sys_Tree"
387}
388
389#D-#==================================================
390#D-function IGCM_sys_Qsub
391#D-* Purpose: Qsub new job
392#D-* Examples:
393#D-
394function IGCM_sys_Qsub {
395  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
396  if ( $DEBUG_sys ) ; then
397    echo "IGCM_sys_Qsub :" $@
398  fi
399  typeset status
400
401  # We have to change output/error file
402  [ ${#@} = 1 ] &&  REP_FOR_JOB=${SUBMIT_DIR}
403  [ ${#@} = 2 ] &&  REP_FOR_JOB=${2}
404  sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Output}:" \
405      -e "s:\# \@ error *= .*:\# \@ error = ${Script_Output}:"   \
406      $1 > ${REP_FOR_JOB}/JOB_FOR_IGCM
407  cd $REP_FOR_JOB ; /usr/bin/llsubmit JOB_FOR_IGCM > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 ; status=$? ; cd - ;
408
409  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
410  if [ ${status} -gt 0 ] ; then
411    IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}"
412    IGCM_debug_Exit "IGCM_sys_Qsub"
413  else
414    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ | tail -1 | sed -e s/\"//g )
415    IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM
416  fi
417  IGCM_debug_PopStack "IGCM_sys_Qsub"
418}
419
420#D-#==================================================
421#D-function IGCM_sys_QsubPost
422#D-* Purpose: Qsub new job on scalaire
423#D-* Examples:
424#D-
425function IGCM_sys_QsubPost {
426  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
427  if ( $DEBUG_sys ) ; then
428    echo "IGCM_sys_QsubPost :" $@
429  fi
430  typeset status
431
432  # We have to change output/error file
433  [ ${#@} = 1 ] &&  REP_FOR_JOB=${POST_DIR}
434  [ ${#@} = 2 ] &&  REP_FOR_JOB=${2}
435
436  sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Post_Output}.out:" \
437      -e "s:\# \@ error *= .*:\# \@ error = ${Script_Post_Output}.out:"   \
438      ${libIGCM_POST}/$1.job > ${REP_FOR_JOB}/JOB_FOR_IGCM_$$
439
440  cd $REP_FOR_JOB ; /usr/bin/llsubmit JOB_FOR_IGCM_$$ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 ; status=$? ; cd - ;
441
442  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
443  if [ ${status} -gt 0 ] ; then
444    IGCM_debug_Print 2 "IGCM_sys_QsubPost $1 : error code ${status}"
445    IGCM_debug_Exit "IGCM_sys_QsubPost"
446  else
447    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ | tail -1 | sed -e s/\"//g )
448    IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM_$$
449  fi
450  IGCM_debug_PopStack "IGCM_sys_QsubPost"
451}
452
453#D-*************************
454#D- File transfer functions
455#D-*************************
456#D-
457
458#D-#==================================================
459#D-function IGCM_sys_RmRunDir
460#D-* Purpose: rm tmpdir (dummy function most of the time batch
461#D-                      scheduler will do the job)
462#D-* Examples:
463#D-
464function IGCM_sys_RmRunDir {
465  IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@
466  if ( $DEBUG_sys ) ; then
467    echo "IGCM_sys_RmRunDir :" $@
468    IGCM_debug_Print 1 "Dummy call, let the scheduler do that."
469  fi
470  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
471}
472
473#D-#==================================================
474#D-function IGCM_sys_Put_Dir
475#D-* Purpose: Copy a complete directory on $(ARCHIVE)
476#D-* Examples:
477#D-
478function IGCM_sys_Put_Dir {
479  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
480  if ( $DEBUG_sys ) ; then
481    echo "IGCM_sys_Put_Dir :" $@
482  fi
483  if [ $DRYRUN = 0 ]; then
484    if [ ! -d ${1} ] ; then
485      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
486      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
487      return
488    fi
489
490    typeset status
491
492    # Only if we use rsync
493    #IGCM_sys_TestDirArchive $( dirname $2 )
494    #
495    #Command depends on targeted file system
496    DEBUG_sys=false IGCM_sys_IsFileArchived $2
497    if [ $? = 0 ] ; then
498      \rcp -r $1 ${STOREHOST}:$2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
499      status=$?
500    else
501      \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
502      status=$?
503    fi
504
505    if [ ${status} -gt 0 ] ; then
506      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : rcp or cp failed error code ${status}"
507      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
508      IGCM_debug_Exit "IGCM_sys_Put_Dir"
509    else
510      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
511    fi
512  fi
513  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
514}
515
516#D-#==================================================
517#D-function IGCM_sys_Get_Dir
518#D-* Purpose: Copy a complete directory from ${ARCHIVE}
519#D-* Examples:
520#D-
521function IGCM_sys_Get_Dir {
522  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
523  if ( $DEBUG_sys ) ; then
524    echo "IGCM_sys_Get_Dir :" $@
525  fi
526  if [ $DRYRUN = 0 ]; then
527    typeset NB_ESSAI DELAI status i
528    # number of tentative
529    NB_ESSAI=3
530    # time delay between tentative
531    DELAI=2
532
533    # Only if we use rsync
534    #IGCM_sys_TestDirArchive $( dirname $2 )
535    #
536    # Command depends on targeted filesystem
537    DEBUG_sys=false IGCM_sys_IsFileArchived $1
538    if [ $? = 0 ] ; then
539      # add dmget (to demigrate all offline files) to reduce time of this command :
540      #IGCM_sys_RshArchive "dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget -q -n"
541      i=0
542      while [ $i -lt $NB_ESSAI ] ; do
543        \rcp -rp ${STOREHOST}:$1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
544        status=$?
545        if [ ${status} -gt 0 ]; then
546          IGCM_debug_Print 2 "IGCM_sys_Get_Dir : rcp failed error code ${status} ${i}/${NB_ESSAI}"
547          IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
548          sleep $DELAI
549        else
550          break
551        fi
552        (( i = i + 1 ))
553      done
554    else
555      \cp -rp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
556      status=$?
557      if [ ${status} -gt 0 ] ; then
558        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
559        cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
560        IGCM_debug_Exit "IGCM_sys_Get_Dir"
561      else
562        \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
563      fi
564    fi
565    if [ ${status} -gt 0 ] ; then
566      IGCM_debug_Print 2 "IGCM_sys_Get_Dir : (r)cp failed error code ${status}"
567      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
568      IGCM_debug_Exit "IGCM_sys_Get_Dir"
569    else
570      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
571    fi
572  fi
573  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
574}
575
576#D-#==================================================
577#D-function IGCM_sys_Put_Rest
578#D-* Purpose: Put computied restarts on ${ARCHIVE}.
579#D-           File and target directory must exist.
580#D-* Examples:
581#D-
582function IGCM_sys_Put_Rest {
583  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
584  if ( $DEBUG_sys ) ; then
585    echo "IGCM_sys_Put_Rest :" $@
586  fi
587  if [ $DRYRUN = 0 ]; then
588    if [ ! -f ${1} ] ; then
589      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
590      IGCM_debug_Exit "IGCM_sys_Put_Rest"
591    fi
592
593    typeset status
594    #
595    if [ X${JobType} = XRUN ] ; then
596      IGCM_sys_Chmod 444 ${1}
597    fi
598    #
599    #
600    #Command depends on targeted file system
601    DEBUG_sys=false IGCM_sys_IsFileArchived $2
602    if [ $? = 0 ] ; then
603      mfput $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
604      status=$?
605    else
606      IGCM_sys_MkdirArchive $( dirname $2 )
607      \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
608      status=$?
609    fi
610
611#       #RSYNC WITH NETWORK RSH CALL
612#       IGCM_sys_MkdirArchive $( dirname $2 )
613#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
614#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
615
616#       #RSYNC WITH NFS USE
617#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
618#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
619
620#       status=$?
621#       IGCM_sys_Rsync_out $status
622
623#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
624#       (( status=status+$? ))
625
626    if [ ${status} -gt 0 ] ; then
627      IGCM_debug_Print 2 "IGCM_sys_Put_Rest : mfput or cp failed error code ${status}"
628      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
629      IGCM_debug_Exit "IGCM_sys_Put_Rest"
630    else
631      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
632    fi
633  fi
634  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
635}
636
637#D-#==================================================
638#D-function IGCM_sys_Put_Out
639#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
640#D-* Examples:
641#D-
642function IGCM_sys_Put_Out {
643  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
644  if ( $DEBUG_sys ) ; then
645    echo "IGCM_sys_Put_Out :" $@
646  fi
647
648  typeset status
649
650  if [ $DRYRUN = 0 ]; then
651    if [ ! -f ${1} ] ; then
652      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
653      IGCM_debug_PopStack "IGCM_sys_Put_Out"
654      return 1
655    fi
656    #
657    if [ X${JobType} = XRUN ] ; then
658      if [ X${3} = X ] ; then
659        IGCM_sys_Chmod 444 ${1}
660      fi
661    fi
662    #
663    #
664    #Command depends on targeted file system
665    DEBUG_sys=false IGCM_sys_IsFileArchived $2
666    if [ $? = 0 ] ; then
667      mfput $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
668      status=$?
669    else
670      IGCM_sys_MkdirArchive $( dirname $2 )
671      \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
672      status=$?
673    fi
674
675#       #RSYNC WITH NETWORK RSH CALL
676#       IGCM_sys_MkdirArchive $( dirname $2 )
677#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
678#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
679
680#       #RSYNC WITH NFS USE
681#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
682#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
683
684#       status=$?
685#       IGCM_sys_Rsync_out $status
686
687#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
688#       (( status=status+$? ))
689
690    if [ ${status} -gt 0 ] ; then
691      IGCM_debug_Print 2 "IGCM_sys_Put_Out : mfput or cp failed error code ${status}"
692      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
693      IGCM_debug_Exit "IGCM_sys_Put_Out"
694    else
695      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
696    fi
697  fi
698  IGCM_debug_PopStack "IGCM_sys_Put_Out"
699  return 0
700}
701
702#D-#==================================================
703#D-function IGCM_sys_Get
704#D-* Purpose: Get a file from ${ARCHIVE}
705#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
706#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
707function IGCM_sys_Get {
708  IGCM_debug_PushStack "IGCM_sys_Get" $@
709
710  typeset DEST status dm_liste
711
712  if ( $DEBUG_sys ) ; then
713    echo "IGCM_sys_Get :" $@
714  fi
715  if [ $DRYRUN -le 2 ]; then
716    if [ X${1} = X'/l' ] ; then
717      eval set +A dm_liste \${${2}}
718    else
719      dm_liste=${1}
720    fi
721    eval DEST=\${${#}}
722
723    # test if the (first) file is present in the old computation :
724    DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]}
725    if [ $? = 0 ] ; then
726      IGCM_sys_TestFileArchive ${dm_liste[0]}
727      status=$?
728    else
729      IGCM_sys_TestFileBuffer ${dm_liste[0]}
730      status=$?
731    fi
732
733    if [ ${status} -gt 0 ] ; then
734      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
735      IGCM_debug_Exit "IGCM_sys_Get"
736      return
737    fi
738
739    #Command depends on targeted file system
740    DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]}
741    if [ $? = 0 ] ; then
742      mfget ${dm_liste[*]} ${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
743      status=$?
744    else
745      \cp ${dm_liste[*]} ${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
746      status=$?
747    fi
748
749#       #RSYNC WITH NETWORK RSH CALL
750#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
751#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
752
753#       #RSYNC WITH NFS USE
754#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
755#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
756
757#       status=$?
758#       IGCM_sys_Rsync_out $status
759
760#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
761#       (( status=status+$? ))
762
763    if [ ${status} -gt 0 ] ; then
764      IGCM_debug_Print 2 "IGCM_sys_Get : mfget or cp failed error code ${status}"
765      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
766      IGCM_debug_Exit "IGCM_sys_Get"
767    else
768      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
769    fi
770  fi
771  IGCM_debug_PopStack "IGCM_sys_Get"
772}
773
774#D-#==================================================
775#D-function IGCM_sys_GetDate_Monitoring
776#D-* Purpose: get the last year for which the monitoring has been computed
777#D-* Examples:
778#D-
779function IGCM_sys_GetDate_Monitoring {
780  IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@
781  if ( $DEBUG_sys ) ; then
782    echo "IGCM_sys_GetDate_Monitoring :" $@
783  fi
784
785  IGCM_sys_Cd /tmp
786  # NASTY HACK. We force /tmp here. This function is called only from the front-end and interactively.
787  RUN_DIR_PATH=/tmp IGCM_sys_Get ${1} .
788  eval ${2}=$( cdo showyear $( basename ${1} ) 2> /dev/null | gawk '{ print $NF }' )
789  # Need to erase this file to avoid collision (permission denied getting file) between users on the front-end
790  IGCM_sys_Rm -f $( basename ${1} )
791  IGCM_sys_Cd -
792
793  IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring"
794}
795
796#D-#==================================================
797#D-function IGCM_sys_Put_Dods
798#D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole.
799#D-* Examples:
800#D-
801function IGCM_sys_Put_Dods {
802  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
803  if ( $DEBUG_sys ) ; then
804    echo "IGCM_sys_Put_Dods :" $@
805  fi
806  typeset status
807  if [ $DRYRUN = 0 ]; then
808    # We take our time on that
809    sleep 10
810    IGCM_sys_TestDirArchive ${R_SAVE}/${1}
811    if [ $? != 0 ] ; then
812      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
813      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
814      return
815    fi
816
817    rsh ${STOREHOST} exec /bin/ksh <<EOF
818          cd ${R_SAVE}
819          /arch/local/bin/dods_rm DODS/pub/${LOGIN}/${R_DODS}/${1} > /dev/null 2>&1
820          /bin/chmod -R u+w ${R_SAVE}/${1}
821          /arch/local/bin/dods_cp ${1} DODS/pub/${LOGIN}/${R_DODS} > /dev/null 2>&1
822          /bin/chmod -R +rX ${R_SAVE}/${1}
823          /bin/chmod -R u+w ${R_SAVE}/${1}
824EOF
825    status=$?
826
827    if [ ${status} -gt 0 ] ; then
828      echo "IGCM_sys_Put_Dods : error."
829      IGCM_debug_Exit "IGCM_sys_Put_Dods"
830    fi
831  fi
832  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
833}
834
835##############################################################
836# REBUILD OPERATOR
837
838#D-#==================================================
839#D-function IGCM_sys_sync
840#D-* Purpose: flush buffer on disk (dummy function on Ada)
841#D-* Examples:
842#D-
843function IGCM_sys_sync {
844  IGCM_debug_PushStack "IGCM_sys_sync" $@
845  if ( $DEBUG_sys ) ; then
846    echo "IGCM_sys_sync :" $@
847    echo "Dummy call, let the system do that."
848  fi
849  IGCM_debug_PopStack "IGCM_sys_sync"
850}
851
852############################################################
853# Activate Running Environnment Variables
854
855#D-#==================================================
856#D-function IGCM_sys_desactiv_variables
857#D-* Purpose: set environement variables prior to execution
858#D-* Examples:
859#D-
860function IGCM_sys_activ_variables {
861  IGCM_debug_PushStack "IGCM_sys_activ_variables"
862  if ( $DEBUG_sys ) ; then
863    echo "IGCM_sys_activ_variables"
864  fi
865
866# --------------------------------------------------------------------
867#D- MPI specifications
868# --------------------------------------------------------------------
869
870# --------------------------------------------------------------------
871#D- Other specifications
872# --------------------------------------------------------------------
873
874  ulimit -s unlimited
875## to be done only one time
876## export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/smplocal/pub/NetCDF/4.1.3/lib:/smplocal/pub/HDF5/1.8.9/seq/lib
877##  echo ${LD_LIBRARY_PATH} | grep -i netcdf >/dev/null 2>&1 || export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/smplocal/pub/NetCDF/4.1.3/lib:/smplocal/pub/HDF5/1.8.9/seq/lib
878  IGCM_debug_Print 1 "set LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
879
880  export MP_STDOUTMODE=combined
881  IGCM_debug_Print 1 "set MP_STDOUTMODE=${MP_STDOUTMODE}"
882
883  ## fix to reduce memory usage. Required since 2014/22/04. On ada IDRIS.
884  #export MP_EUILIBPATH=/smplocal/lib/ibmhpc/pe12012/ppe.pami/gnu/lib64/pami64
885  #IGCM_debug_Print 1 "set MP_EUILIBPATH=${MP_EUILIBPATH}"
886
887  IGCM_debug_PopStack "IGCM_sys_activ_variables"
888}
889
890############################################################
891# Desactivate Running Environnment Variables
892
893#D-#==================================================
894#D-function IGCM_sys_desactiv_variables
895#D-* Purpose: unset environement variables after execution
896#D-* Examples:
897#D-
898function IGCM_sys_desactiv_variables {
899  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
900  if ( $DEBUG_sys ) ; then
901    echo "IGCM_sys_desactiv_variables"
902  fi
903# --------------------------------------------------------------------
904#D- MPI specifications
905# --------------------------------------------------------------------
906
907# --------------------------------------------------------------------
908#D- Other specifications
909# --------------------------------------------------------------------
910
911  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
912}
913
914############################################################
915# Build MPI/OMP scripts run file (dummy function)
916
917#D-#==================================================
918#D-function IGCM_sys_build_run_file
919#D-* Purpose: build run file (deprecated)
920#D-* Examples:
921#D-
922function IGCM_sys_build_run_file {
923
924  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
925
926}
927
928############################################################
929# Build MPI/OMP scripts
930
931#D-#==================================================
932#D-function IGCM_sys_build_execution_scripts
933#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
934#D-* Examples:
935#D-
936function IGCM_sys_build_execution_scripts
937{
938  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
939  if ( $DEBUG_sys ) ; then
940    echo "IGCM_sys_build_execution_scripts " $@
941  fi
942
943  EXECUTION=${HOST_MPIRUN_COMMAND}
944
945  # MPMD mode
946  if ( ${OK_PARA_MPMD} ) ; then
947
948    if [ -f run_file ] ; then
949      IGCM_sys_Rm -f run_file
950    fi
951    touch run_file
952
953    # Build run_file
954
955    # First loop on the components for the coupler ie oasis (only if oasis3)
956    # the coupler ie oasis3 must be the first one
957    for comp in ${config_ListOfComponents[*]} ; do
958
959      eval ExeNameIn=\${config_Executable_${comp}[0]}
960      eval ExeNameOut=\${config_Executable_${comp}[1]}
961
962      # for CPL component only
963      if [ "X${comp}" = "XCPL" ] ; then
964
965        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
966        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
967
968        if ( ${OK_PARA_MPI} ) ; then
969          (( mpi_count = 1 ))
970          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
971            echo "./${ExeNameOut}" >> run_file
972            (( mpi_count = mpi_count + 1 ))
973          done
974        else
975          echo "./${ExeNameOut} " >> run_file
976        fi
977      fi
978    done
979
980    # Then second loop on the components
981    for comp in ${config_ListOfComponents[*]} ; do
982
983      eval ExeNameIn=\${config_Executable_${comp}[0]}
984      eval ExeNameOut=\${config_Executable_${comp}[1]}
985
986      # Only if we really have an executable for the component and not the coupler ie oasis:
987      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
988
989        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
990        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
991
992        if ( ${OK_PARA_MPI} ) ; then
993          (( mpi_count = 1 ))
994          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
995            if ( ${OK_PARA_OMP} ) ; then
996              # Check if the number of threads is correct
997              case ${comp_proc_omp_loc} in
998              1|2)
999                IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads"
1000                ;;
1001              4|8|16)
1002                IGCM_debug_Exit "ERROR with OMP parameters !"
1003                IGCM_debug_Print 2 "Beware : ${comp_proc_omp_loc} is too much for MPMD mode"
1004                IGCM_debug_Print 2 "You will use more CPU than needed"
1005                IGCM_debug_Verif_Exit
1006                ;;
1007              *)
1008                IGCM_debug_Exit "ERROR with OMP parameters !"
1009                IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads"
1010                IGCM_debug_Print 2 "Only 2,4,8,16 as number of OMP threads are possible "
1011                IGCM_debug_Verif_Exit
1012                ;;
1013              esac
1014              echo "env OMP_NUM_THREADS=$comp_proc_omp_loc ./${ExeNameOut}" >> run_file
1015            else
1016              echo "./${ExeNameOut}" >> run_file
1017            fi
1018            (( mpi_count = mpi_count + 1 ))
1019          done
1020        else
1021          echo "./${ExeNameOut} " >> run_file
1022        fi
1023        if ( ${OK_PARA_OMP} ) ; then
1024          export KMP_STACKSIZE=200m
1025        fi
1026      fi
1027    done
1028
1029    EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file"
1030
1031    IGCM_sys_Chmod u+x run_file
1032    if ( $DEBUG_sys ) ; then
1033      echo "run_file contains : "
1034      cat run_file
1035    fi
1036
1037  # Only one executable (SPMD mode).
1038  else
1039
1040    for comp in ${config_ListOfComponents[*]} ; do
1041
1042      # Only if we really have an executable for the component :
1043      eval ExeNameOut=\${config_Executable_${comp}[1]}
1044      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
1045
1046        if ( ${OK_PARA_OMP} ) ; then
1047          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1048          export KMP_STACKSIZE=200m
1049          #export KMP_LIBRARY=turnaround
1050          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1051          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1052          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1053        fi
1054        EXECUTION="${HOST_MPIRUN_COMMAND} ./${ExeNameOut}"
1055      fi
1056
1057    done
1058
1059  fi
1060
1061  IGCM_debug_Print 1 "sys ada : execution command is "
1062  IGCM_debug_Print 1 "$EXECUTION"
1063
1064  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1065}
1066
1067#D-#==================================================
1068#D-function IGCM_sys_check_path
1069#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
1070#D-* do not point to an important use directory. Stop immediately in that case.
1071#D-* Examples:
1072#D-
1073function IGCM_sys_check_path {
1074  IGCM_debug_PushStack "IGCM_sys_check_path"
1075  if ( $DEBUG_sys ) ; then
1076    echo "IGCM_sys_check_path"
1077  fi
1078
1079  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORKDIR} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then
1080    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
1081    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
1082    IGCM_debug_Exit "This will stop the job"
1083  fi
1084  IGCM_debug_PopStack "IGCM_sys_check_path"
1085}
1086
1087#D-#==================================================
1088#D-function IGCM_sys_check_quota
1089#D-* Purpose: check user quota. Stop the simulation if quota above 90%
1090#D-* Examples:
1091#D-
1092function IGCM_sys_check_quota {
1093  IGCM_debug_PushStack "IGCM_sys_check_quota"
1094  if ( $DEBUG_sys ) ; then
1095    echo "IGCM_sys_check_quota"
1096  fi
1097  # Limit of quota (in %)
1098  limit_quota=90
1099
1100  # Check of the volume
1101  volume_quota=$(quota_u -w 2>/dev/null| grep 'Quota soft' | gawk '{print $5}')
1102  if [ ! X${volume_quota} = X ] ; then
1103    quota_volume=${volume_quota%%\%}
1104#    echo $quota_volume
1105    if [ $(echo "${quota_volume} > ${limit_quota}" | bc) -eq 1 ] ; then
1106      IGCM_debug_Print 1 "Please, check your quota of volume on workgpfs"
1107      IGCM_debug_Print 1 "${quota_volume}% of your quota is used"
1108      IGCM_debug_Print 1 "Use the quota_u -w command to check"
1109      IGCM_debug_Print 1 "You must have more than 10% available to run"
1110      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1111      IGCM_debug_Verif_Exit
1112    fi
1113
1114  fi
1115  IGCM_debug_PopStack "IGCM_sys_check_quota"
1116}
1117
1118#D-#==================================================
1119#D-function IGCM_sys_GetJobID
1120#D-* Purpose: Check if job_name is currently
1121#D-  running or in queue
1122#D-* Examples: IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID
1123#D-
1124function IGCM_sys_GetJobID {
1125  IGCM_debug_PushStack "IGCM_sys_GetJobID"
1126  if ( $DEBUG_sys ) ; then
1127    echo "IGCM_sys_GetJobID"
1128  fi
1129
1130  # Print only the full (-W) JobID (%id) and JobName (%jn)
1131  ID=$( llq -u $2 -W -f %id %jn | \
1132        gawk -v JobName=$1 '( $NF ~ JobName ) { print $1 }' )
1133
1134  eval ${3}=${ID}
1135  IGCM_debug_PopStack "IGCM_sys_GetJobID"
1136}
1137
1138#D-#==================================================
1139#D-function IGCM_sys_CountJobInQueue
1140#D-* Purpose: Check if job_name is currently
1141#D-  running or in queue
1142#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
1143#D-
1144function IGCM_sys_CountJobInQueue {
1145  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
1146  if ( $DEBUG_sys ) ; then
1147    echo "IGCM_sys_CountJobInQueue"
1148  fi
1149
1150  # Print only the full (-W) JobName (%jn)
1151  NbRun=$( llq -W -f %jn | grep -c "$1" )
1152
1153  eval ${2}=${NbRun}
1154
1155  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
1156}
1157
1158#D-#==================================================
1159#D-function IGCM_sys_ListJobInQueue
1160#D-* Purpose: Check if job_name is currently
1161#D-  running or in queue
1162#D-* Examples: IGCM_sys_ListJobInQueue ${User} JobNameList
1163#D-
1164function IGCM_sys_ListJobInQueue {
1165  IGCM_debug_PushStack "IGCM_sys_ListJobInQueue"
1166  if ( $DEBUG_sys ) ; then
1167    echo "IGCM_sys_ListJobInQueue"
1168  fi
1169
1170  # With -W option, column width is as large as necessary
1171  set -A JobList $( llq -u $1 -W -f %jn | head -n -2 | tail -n +3 | \
1172                    gawk '( $1 != /TS/      && \
1173                            $1 !~ /PACK/    && \
1174                            $1 !~ /REBUILD/ && \
1175                            $1 !~ /pack/ )     \
1176                          { print $1 }' | sed -e "s/\(.*\)\.[0-9]*/\1/" )
1177
1178  eval set -A ${2} ${JobList[*]}
1179
1180  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue"
1181}
Note: See TracBrowser for help on using the repository browser.