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

Last change on this file since 1183 was 1183, checked in by sdipsl, 9 years ago

cosmetics

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