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

Last change on this file since 1601 was 1601, checked in by jgipsl, 8 months ago

Update for obelix:

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