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

Last change on this file since 1573 was 1569, checked in by aclsce, 18 months ago

Added fonctionality to create RUN_DIR and Job_debug to be launched directly in the RUN_DIR directory.

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