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

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