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

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