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

Last change on this file since 1573 was 1485, checked in by jgipsl, 5 years ago

Do for other hosts what already was done for irene: now read EnvFile? from config.card and source this file if it exists, otherwise source default file. Also some homogenization.

  • 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: 55.4 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sébastien Denvil
5# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#=========================================================
15# The documentation of this file can be automatically generated
16# if you use the prefix #D- for comments to be extracted.
17# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
18#=========================================================
19
20#D-#==================================================
21#D-LibIGCM_sys for Ada
22#D-#==================================================
23#D-
24#D- This ksh library if a layer under some usefull
25#D-environment variables and shell commands.
26#D-All those definitions depend on host particularities.
27#D-It manages a stack mechanism and test validity of operations.
28#D-All function described bellow must be prefixed by IGCM_sys.
29
30#====================================================
31# libIGCM_sys PARAMETERS
32#====================================================
33
34#====================================================
35# set DEBUG_sys to true to output calls of function
36typeset -r DEBUG_sys=${DEBUG_sys:=true}
37
38#====================================================
39# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
40typeset -r DRYRUN=${DRYRUN:=0}
41
42# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
43# -------------------------------------------------------------------------------------
44# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
45# |          |  Cp/Exe/param/files |            |         |                           |
46# |          |  Chmod Qsub         |            |         |                           |
47# -------------------------------------------------------------------------------------
48# |    0     |       yes           |    yes     |  yes    |      yes                  |
49# -------------------------------------------------------------------------------------
50# |    1     |       yes           |    yes     |  yes    |      no                   |
51# -------------------------------------------------------------------------------------
52# |    2     |       yes           |    yes     |  no     |      no                   |
53# -------------------------------------------------------------------------------------
54# |    3     |       yes           |    no      |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56
57#=====================================================
58# Global Variables :
59#=====================================================
60# Language : "fr" or "en"
61typeset -r MYLANG="fr"
62
63#=====================================================
64# Host and user names
65# $hostname ou hostname
66typeset HOST=${HOST:=$( hostname )}
67# $username ou whoami
68typeset LOGIN=${LOGIN:=$( whoami )}
69# $hostname of the MASTER job
70typeset MASTER=ada
71# project name
72typeset PROJECT=$(echo ${LOADL_STEP_GROUP:=NONE})
73# jobWarningDelay in seconds
74typeset jobWarningDelay=$( TZ=utc date -d '1970-01-01 '${wall_clock_limit} +%s )
75
76#D-
77#D-#==================================================
78#D-Program used in libIGCM
79#D-#==================================================
80
81# Submit command
82typeset SUBMIT=${SUBMIT:=llsubmit}
83# rsync with path
84typeset -r RSYNC=/usr/bin/rsync
85# RSYNC_opt args to rsync
86typeset -r RSYNC_opt="-va"
87# ie storage filesystem
88typeset -r STOREHOST=ergon
89typeset -r REMOTE_RSYNC=/usr/bin/rsync
90
91#====================================================
92# Access to module command
93#====================================================
94source /smplocal/pub/Modules/default/init/ksh
95
96#====================================================
97# Set environment tools (ferret, nco, cdo, rebuild, ...)
98#====================================================
99if [ X${TaskType} = Xcomputing ] ; then
100    IGCM_debug_Print 1 "Modules will be loaded later in IGCM_sys_activ_variables."
101else
102    if ( [ "X${LOADL_STEP_TYPE}" = "XPARALLEL" ] || [ "X${LOADL_STEP_TYPE}" = "XSERIAL" ] ) ; then
103        . /smphome/rech/psl/rpsl035/.atlas_env_ada_intel_2013_0_bash > /dev/null 2>&1
104    else
105        module unload intel > /dev/null 2>&1
106        module load intel/2016.2 > /dev/null 2>&1
107        . /smphome/rech/psl/rpsl035/.atlas_env_ada_bash > /dev/null 2>&1
108        export PCMDI_MP=/workgpfs/rech/psl/rpsl035/PCMDI-MP
109        export UVCDAT_ANONYMOUS_LOG=no
110    fi
111fi
112
113# Load python
114module load python/2.7.10 > /dev/null 2>&1
115
116[ ! X${TaskType} = Xchecking ] && IGCM_debug_Print 1 "List of loaded modules:"
117[ ! X${TaskType} = Xchecking ] && module list
118
119export PATH=${PATH}:/smphome/rech/psl/rpsl035/AddNoise/src_X64_ADA/bin
120export PATH=${PATH}:/smphome/rech/psl/rpsl035/AddPerturbation/src_X64_ADA/bin
121export PATH=${PATH}:/smphome/rech/psl/rpsl035/bin/
122
123#====================================================
124# Host specific DIRECTORIES
125#====================================================
126
127#====================================================
128#- MirrorlibIGCM for frontend
129typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
130
131#====================================================
132#- libIGCM_POST for frontend
133typeset -r libIGCM_POST=${libIGCM}
134
135#====================================================
136#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
137typeset -r R_EXE="${MODIPSL}/bin"
138
139#====================================================
140#- SUBMIT_DIR : submission dir
141typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}}
142
143#====================================================
144#- IN
145typeset -r R_IN=${R_IN:=/workgpfs/rech/psl/rpsl035/IGCM}
146
147#====================================================
148#- RUN_DIR_PATH : Temporary working directory (=> TMP)
149typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${TMPDIR}}
150
151#====================================================
152#- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs
153typeset -r OUTCOMMAND_PATH=${RUN_DIR_PATH:-/tmp}
154
155#====================================================
156#- HOST_MPIRUN_COMMAND
157if ( [ "X${LOADL_STEP_TYPE}" = "XPARALLEL" ] || [ "X${LOADL_STEP_TYPE}" = "XSERIAL" ] ) ; then
158  typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time poe"}
159else
160  typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time mpirun"}
161fi
162#====================================================
163#- Max number of arguments passed to nco operator or demigration command
164UNIX_MAX_LIMIT=360
165
166#====================================================
167#- set PackDefault to true on ada
168PackDefault=true
169
170#====================================================
171#- Number of cores per node
172core_per_node=32
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 SCRATCHDIR hosting files waiting for rebuild or pack processes
190#D-* if SpaceName=TEST everything is stored on WORKDIR
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=$(echo ${HOME} | sed -e "s,/.*home/,/arch/home/,")
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=${WORKDIR}
214  fi
215
216  if [ X${config_UserChoices_SpaceName} = XTEST ]; then
217    #====================================================
218    #- R_OUT
219    R_OUT=${WORKDIR}/IGCM_OUT
220
221    #====================================================
222    #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
223    R_FIG=${WORKDIR}/IGCM_OUT
224
225    IGCM_debug_Print 1 "SpaceName=TEST ==> OVERRULE destination path directories"
226
227  else
228    #====================================================
229    #- R_OUT
230    R_OUT=${ARCHIVE}/IGCM_OUT
231
232    #====================================================
233    #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
234    R_FIG=${ARCHIVE}/IGCM_OUT
235  fi
236
237  #====================================================
238  #- CMIP6 (hosting CMIP6 files produced by XIOS2 and configured by dr2xml)
239  CMIP6_BUF=${STORAGE}/IGCM_OUT
240
241  #====================================================
242  #- R_BUF (ONLY FOR double copy an scratch)
243  R_BUF=${WORKDIR}/IGCM_OUT
244
245  IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
246  IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}"
247  IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}"
248
249  IGCM_debug_PopStack "IGCM_sys_defineArchives"
250}
251
252#D-#==================================================
253#D-function IGCM_sys_RshArchive
254#D-* Purpose: Archive rsh command
255#D-* Examples:
256#D-
257function IGCM_sys_RshArchive {
258  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
259  DEBUG_sys=false IGCM_sys_IsFileArchived "$@"
260  if [ $? = 0 ] ; then
261    rsh ${STOREHOST} exec /bin/ksh <<-EOF
262    ${@}
263EOF
264    status=$?
265  else
266    /bin/ksh <<-EOF
267    ${@}
268EOF
269    status=$?
270  fi
271  if [ ${status} -gt 0 ] ; then
272    IGCM_debug_Print 2 "IGCM_sys_RshArchive : rsh or command failed error code ${status}"
273    IGCM_debug_Exit "IGCM_sys_RshArchive"
274  fi
275  IGCM_debug_PopStack "IGCM_sys_RshArchive"
276}
277
278#D-#==================================================
279#D-function IGCM_sys_RshArchive_NoError
280#D-* Purpose: Archive rsh command, without error
281#D-*          used only in monitoring.job
282#D-* Examples:
283#D-
284function IGCM_sys_RshArchive_NoError {
285  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@
286  DEBUG_sys=false IGCM_sys_IsFileArchived "$@"
287  if [ $? = 0 ] ; then
288    rsh ${STOREHOST} exec /bin/ksh <<-EOF
289    ${@} 2> /dev/null
290EOF
291  else
292    /bin/ksh <<-EOF
293    ${@} 2> /dev/null
294EOF
295  fi
296  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError"
297}
298
299#D-#==================================================
300#D-function IGCM_sys_MkdirArchive
301#D-* Purpose: Mkdir on Archive
302#D-* Examples:
303#D-
304function IGCM_sys_MkdirArchive {
305  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
306  if ( $DEBUG_sys ) ; then
307    echo "IGCM_sys_MkdirArchive :" $@
308  fi
309  #- creation de repertoire sur le serveur fichier
310  DEBUG_sys=false IGCM_sys_IsFileArchived $1
311  if [ $? = 0 ] ; then
312    rsh ${STOREHOST} -n mkdir -p $1
313    status=$?
314  else
315    mkdir -p $1
316    status=$?
317  fi
318
319  if [ ${status} -gt 0 ] ; then
320    IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : rsh or mkdir failed error code ${status}"
321    IGCM_debug_Exit "IGCM_sys_MkdirArchive"
322  fi
323  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
324}
325
326#D-#==================================================
327#D-function IGCM_sys_TestDirArchive
328#D-* Purpose: Test Directory that must exists on Archive
329#D-* Examples:
330#D-
331function IGCM_sys_TestDirArchive {
332  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
333  if ( $DEBUG_sys ) ; then
334    echo "IGCM_sys_TestDirArchive :" $@
335  fi
336  typeset ExistFlag
337  #Command depends on targeted file system
338  DEBUG_sys=false IGCM_sys_IsFileArchived $1
339  if [ $? = 0 ] ; then
340    ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" )
341  else
342    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
343  fi
344  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
345  return ${ExistFlag}
346}
347
348#D-#==================================================
349#D-function IGCM_sys_IsFileArchived
350#D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only
351#D-* Examples:
352#D-
353function IGCM_sys_IsFileArchived {
354  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
355  if ( $DEBUG_sys ) ; then
356    echo "IGCM_sys_IsFileArchived :" $@
357  fi
358  typeset IsArchivedFlag
359  IsArchivedFlag=$( [ "X$( echo $@ | grep \/arch\/home )" != "X" ] && echo 0 || echo 1 )
360  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
361
362  return ${IsArchivedFlag}
363}
364
365#D-#==================================================
366#D-function IGCM_sys_TestFileArchive
367#D-* Purpose: Test file that must NOT EXISTS on Archive
368#D-* Examples:
369#D-
370function IGCM_sys_TestFileArchive {
371  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
372  typeset ExistFlag
373  ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" )
374  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
375
376  return ${ExistFlag}
377}
378
379#D-#==================================================
380#D-function IGCM_sys_CountFileArchive
381#D-* Purpose: Count files on Archive filesystem
382#D-* Examples:
383#D-
384function IGCM_sys_CountFileArchive {
385  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
386  #Command depends on targeted file system
387  DEBUG_sys=false IGCM_sys_IsFileArchived $1
388  if [ $? = 0 ] ; then
389    IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l"
390    status=$?
391  else
392    ls ${@} 2>/dev/null | wc -l
393    status=$?
394  fi
395  if [ ${status} -gt 0 ] ; then
396    echo "IGCM_sys_CountFileArchive : erreur."
397  fi
398  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
399}
400
401#D-#==================================================
402#D-function IGCM_sys_Tree
403#D-* Purpose: Tree directories with files on ${ARCHIVE}
404#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
405#D-
406function IGCM_sys_Tree {
407  IGCM_debug_PushStack "IGCM_sys_Tree" $@
408  if ( $DEBUG_sys ) ; then
409    echo "IGCM_sys_Tree :" $@
410  fi
411
412  \mfls -R $@
413
414  IGCM_debug_PopStack "IGCM_sys_Tree"
415}
416
417#D-#==================================================
418#D-function IGCM_sys_Qsub
419#D-* Purpose: Qsub new job
420#D-* Examples:
421#D-
422function IGCM_sys_Qsub {
423  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
424  if ( $DEBUG_sys ) ; then
425    echo "IGCM_sys_Qsub :" $@
426  fi
427  typeset status
428
429  # We have to change output/error file
430  [ ${#@} = 1 ] &&  REP_FOR_JOB=${SUBMIT_DIR}
431  [ ${#@} = 2 ] &&  REP_FOR_JOB=${2}
432  sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Output}:" \
433    -e "s:\# \@ error *= .*:\# \@ error = ${Script_Output}:"   \
434    $1 > ${REP_FOR_JOB}/JOB_FOR_IGCM
435  cd $REP_FOR_JOB ; /usr/bin/llsubmit JOB_FOR_IGCM > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 ; status=$? ; cd - ;
436
437  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
438  if [ ${status} -gt 0 ] ; then
439    IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}"
440    IGCM_debug_Exit "IGCM_sys_Qsub"
441  else
442    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ | tail -1 | sed -e s/\"//g )
443    IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM
444  fi
445  IGCM_debug_PopStack "IGCM_sys_Qsub"
446}
447
448#D-#==================================================
449#D-function IGCM_sys_QsubPost
450#D-* Purpose: Qsub new job on scalaire
451#D-* Examples:
452#D-
453function IGCM_sys_QsubPost {
454  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
455  if ( $DEBUG_sys ) ; then
456    echo "IGCM_sys_QsubPost :" $@
457  fi
458  typeset status
459
460  # We have to change output/error file
461  [ ${#@} = 1 ] &&  REP_FOR_JOB=${POST_DIR}
462  [ ${#@} = 2 ] &&  REP_FOR_JOB=${2}
463
464  sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Post_Output}.out:" \
465    -e "s:\# \@ error *= .*:\# \@ error = ${Script_Post_Output}.out:"   \
466    ${libIGCM_POST}/$1.job > ${REP_FOR_JOB}/JOB_FOR_IGCM_$$
467
468  cd $REP_FOR_JOB ; /usr/bin/llsubmit JOB_FOR_IGCM_$$ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 ; status=$? ; cd - ;
469
470  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
471  if [ ${status} -gt 0 ] ; then
472    IGCM_debug_Print 2 "IGCM_sys_QsubPost $1 : error code ${status}"
473    IGCM_debug_Exit "IGCM_sys_QsubPost"
474  else
475    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ | tail -1 | sed -e s/\"//g )
476    IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM_$$
477  fi
478  IGCM_debug_PopStack "IGCM_sys_QsubPost"
479}
480
481#D-*************************
482#D- File transfer functions
483#D-*************************
484#D-
485
486#D-#==================================================
487#D-function IGCM_sys_RmRunDir
488#D-* Purpose: rm tmpdir (dummy function most of the time batch
489#D-                      scheduler will do the job)
490#D-* Examples:
491#D-
492function IGCM_sys_RmRunDir {
493  IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@
494  if ( $DEBUG_sys ) ; then
495    echo "IGCM_sys_RmRunDir :" $@
496    IGCM_debug_Print 1 "Dummy call, let the scheduler do that."
497  fi
498  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
499}
500
501#D-#==================================================
502#D-function IGCM_sys_Put_Dir
503#D-* Purpose: Copy a complete directory on $(ARCHIVE)
504#D-* Examples:
505#D-
506function IGCM_sys_Put_Dir {
507  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
508  if ( $DEBUG_sys ) ; then
509    echo "IGCM_sys_Put_Dir :" $@
510  fi
511  if [ $DRYRUN = 0 ]; then
512    if [ ! -d ${1} ] ; then
513      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
514      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
515      return
516    fi
517
518    typeset status
519
520    # Only if we use rsync
521    #IGCM_sys_TestDirArchive $( dirname $2 )
522    #
523    #Command depends on targeted file system
524    DEBUG_sys=false IGCM_sys_IsFileArchived $2
525    if [ $? = 0 ] ; then
526      \rcp -r $1 ${STOREHOST}:$2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
527      status=$?
528    else
529      \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
530      status=$?
531    fi
532
533    if [ ${status} -gt 0 ] ; then
534      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : rcp or cp failed error code ${status}"
535      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
536      IGCM_debug_Exit "IGCM_sys_Put_Dir"
537    else
538      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
539    fi
540  fi
541  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
542}
543
544#D-#==================================================
545#D-function IGCM_sys_Get_Dir
546#D-* Purpose: Copy a complete directory from ${ARCHIVE}
547#D-* Examples:
548#D-
549function IGCM_sys_Get_Dir {
550  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
551  if ( $DEBUG_sys ) ; then
552    echo "IGCM_sys_Get_Dir :" $@
553  fi
554  if [ $DRYRUN = 0 ]; then
555    typeset NB_ESSAI DELAI status i
556    # number of tentative
557    NB_ESSAI=3
558    # time delay between tentative
559    DELAI=2
560
561    # Only if we use rsync
562    #IGCM_sys_TestDirArchive $( dirname $2 )
563    #
564    # Command depends on targeted filesystem
565    DEBUG_sys=false IGCM_sys_IsFileArchived $1
566    if [ $? = 0 ] ; then
567      # add dmget (to demigrate all offline files) to reduce time of this command :
568      #IGCM_sys_RshArchive "dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget -q -n"
569      i=0
570      while [ $i -lt $NB_ESSAI ] ; do
571        \rcp -rp ${STOREHOST}:$1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
572        status=$?
573        if [ ${status} -gt 0 ]; then
574          IGCM_debug_Print 2 "IGCM_sys_Get_Dir : rcp failed error code ${status} ${i}/${NB_ESSAI}"
575          IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
576          sleep $DELAI
577        else
578          break
579        fi
580        (( i = i + 1 ))
581      done
582    else
583      \cp -rp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
584      status=$?
585      if [ ${status} -gt 0 ] ; then
586        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
587        cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
588        IGCM_debug_Exit "IGCM_sys_Get_Dir"
589      else
590        \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
591      fi
592    fi
593    if [ ${status} -gt 0 ] ; then
594      IGCM_debug_Print 2 "IGCM_sys_Get_Dir : (r)cp failed error code ${status}"
595      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
596      IGCM_debug_Exit "IGCM_sys_Get_Dir"
597    else
598      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
599    fi
600  fi
601  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
602}
603
604#D-#==================================================
605#D-function IGCM_sys_Put_Rest
606#D-* Purpose: Put computied restarts on ${ARCHIVE}.
607#D-           File and target directory must exist.
608#D-* Examples:
609#D-
610function IGCM_sys_Put_Rest {
611  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
612  if ( $DEBUG_sys ) ; then
613    echo "IGCM_sys_Put_Rest :" $@
614  fi
615  if [ $DRYRUN = 0 ]; then
616    if [ ! -f ${1} ] ; then
617      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
618      IGCM_debug_Exit "IGCM_sys_Put_Rest"
619    fi
620
621    typeset status
622    #
623    if [ X${JobType} = XRUN ] ; then
624      IGCM_sys_Chmod 444 ${1}
625    fi
626    #
627    #
628    #Command depends on targeted file system
629    DEBUG_sys=false IGCM_sys_IsFileArchived $2
630    if [ $? = 0 ] ; then
631      mfput $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
632      status=$?
633    else
634      IGCM_sys_MkdirArchive $( dirname $2 )
635      \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
636      status=$?
637    fi
638
639#       #RSYNC WITH NETWORK RSH CALL
640#       IGCM_sys_MkdirArchive $( dirname $2 )
641#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
642#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
643
644#       #RSYNC WITH NFS USE
645#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
646#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
647
648#       status=$?
649#       IGCM_sys_Rsync_out $status
650
651#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
652#       (( status=status+$? ))
653
654    if [ ${status} -gt 0 ] ; then
655      IGCM_debug_Print 2 "IGCM_sys_Put_Rest : mfput or cp failed error code ${status}"
656      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
657      IGCM_debug_Exit "IGCM_sys_Put_Rest"
658    else
659      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
660    fi
661  fi
662  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
663}
664
665#D-#==================================================
666#D-function IGCM_sys_Put_Out
667#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
668#D-* Examples:
669#D-
670function IGCM_sys_Put_Out {
671  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
672  if ( $DEBUG_sys ) ; then
673    echo "IGCM_sys_Put_Out :" $@
674  fi
675
676  typeset status
677
678  if [ $DRYRUN = 0 ]; then
679    if [ ! -f ${1} ] ; then
680      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
681      IGCM_debug_PopStack "IGCM_sys_Put_Out"
682      return 1
683    fi
684    #
685    if [ X${JobType} = XRUN ] ; then
686      if [ X${3} = X ] ; then
687        IGCM_sys_Chmod 444 ${1}
688      fi
689    fi
690    #
691    #
692    #Command depends on targeted file system
693    DEBUG_sys=false IGCM_sys_IsFileArchived $2
694    if [ $? = 0 ] ; then
695      mfput $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
696      status=$?
697    else
698      IGCM_sys_MkdirArchive $( dirname $2 )
699      \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
700      status=$?
701    fi
702
703#       #RSYNC WITH NETWORK RSH CALL
704#       IGCM_sys_MkdirArchive $( dirname $2 )
705#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
706#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
707
708#       #RSYNC WITH NFS USE
709#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
710#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
711
712#       status=$?
713#       IGCM_sys_Rsync_out $status
714
715#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
716#       (( status=status+$? ))
717
718    if [ ${status} -gt 0 ] ; then
719      IGCM_debug_Print 2 "IGCM_sys_Put_Out : mfput or cp failed error code ${status}"
720      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
721      IGCM_debug_Exit "IGCM_sys_Put_Out"
722    else
723      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
724    fi
725  fi
726  IGCM_debug_PopStack "IGCM_sys_Put_Out"
727  return 0
728}
729
730#D-#==================================================
731#D-function IGCM_sys_Get
732#D-* Purpose: Get a file from ${ARCHIVE}
733#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
734#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
735function IGCM_sys_Get {
736  IGCM_debug_PushStack "IGCM_sys_Get" $@
737
738  typeset DEST status dm_liste
739
740  if ( $DEBUG_sys ) ; then
741    echo "IGCM_sys_Get :" $@
742  fi
743  if [ $DRYRUN -le 2 ]; then
744    if [ X${1} = X'/l' ] ; then
745      eval set +A dm_liste \${${2}}
746    else
747      dm_liste=${1}
748    fi
749    eval DEST=\${${#}}
750
751    # test if the (first) file is present in the old computation :
752    DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]}
753    if [ $? = 0 ] ; then
754      IGCM_sys_TestFileArchive ${dm_liste[0]}
755      status=$?
756    else
757      IGCM_sys_TestFileBuffer ${dm_liste[0]}
758      status=$?
759    fi
760
761    if [ ${status} -gt 0 ] ; then
762      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
763      IGCM_debug_Exit "IGCM_sys_Get"
764      return
765    fi
766
767    #Command depends on targeted file system
768    DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]}
769    if [ $? = 0 ] ; then
770      mfget ${dm_liste[*]} ${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
771      status=$?
772    else
773      \cp ${dm_liste[*]} ${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
774      status=$?
775    fi
776
777#       #RSYNC WITH NETWORK RSH CALL
778#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
779#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
780
781#       #RSYNC WITH NFS USE
782#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
783#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
784
785#       status=$?
786#       IGCM_sys_Rsync_out $status
787
788#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
789#       (( status=status+$? ))
790
791    if [ ${status} -gt 0 ] ; then
792      IGCM_debug_Print 2 "IGCM_sys_Get : mfget or cp failed error code ${status}"
793      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
794      IGCM_debug_Exit "IGCM_sys_Get"
795    else
796      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
797    fi
798  fi
799  IGCM_debug_PopStack "IGCM_sys_Get"
800}
801
802#D-#==================================================
803#D-function IGCM_sys_GetDate_Monitoring
804#D-* Purpose: get the last year for which the monitoring has been computed
805#D-* Examples:
806#D-
807function IGCM_sys_GetDate_Monitoring {
808  IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@
809  if ( $DEBUG_sys ) ; then
810    echo "IGCM_sys_GetDate_Monitoring :" $@
811  fi
812
813  IGCM_sys_Cd /tmp
814  # NASTY HACK. We force /tmp here. This function is called only from the front-end and interactively.
815  RUN_DIR_PATH=/tmp IGCM_sys_Get ${1} .
816  eval ${2}=$( cdo showyear $( basename ${1} ) 2> /dev/null | gawk '{ print $NF }' )
817  # Need to erase this file to avoid collision (permission denied getting file) between users on the front-end
818  IGCM_sys_Rm -f $( basename ${1} )
819  IGCM_sys_Cd -
820
821  IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring"
822}
823
824#D-#==================================================
825#D-function IGCM_sys_Dods_Rm
826#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
827#D-* Examples:
828#D-
829function IGCM_sys_Dods_Rm {
830  if ( $DEBUG_sys ) ; then
831    echo "IGCM_sys_Dods_Rm :" $@
832  fi
833
834  typeset status
835  if [ $DRYRUN = 0 ]; then
836    if [ "$#" -eq 1 ]; then
837      rsh ${STOREHOST} exec /bin/ksh <<EOF
838          cd ${R_SAVE}
839          /arch/local/bin/dods_rm DODS/pub/${LOGIN}/${R_DODS}/${1} > /dev/null 2>&1
840EOF
841      status=$?
842    else
843      rsh ${STOREHOST} exec /bin/ksh <<EOF
844          cd ${R_SAVE}
845          /arch/local/bin/dods_rm DODS/pub/${LOGIN}/${R_DODS} > /dev/null 2>&1
846EOF
847      status=$?
848    fi
849  fi
850
851  return ${status}
852}
853
854#D-#==================================================
855#D-function IGCM_sys_Dods_Cp
856#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
857#D-* Examples:
858#D-
859function IGCM_sys_Dods_Cp {
860  if ( $DEBUG_sys ) ; then
861    echo "IGCM_sys_Dods_Cp :" $@
862  fi
863  return 0
864}
865
866#D-#==================================================
867#D-function IGCM_sys_Put_Dods
868#D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole.
869#D-* Examples:
870#D-
871function IGCM_sys_Put_Dods {
872  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
873  if ( $DEBUG_sys ) ; then
874    echo "IGCM_sys_Put_Dods :" $@
875  fi
876  typeset status
877  if [ $DRYRUN = 0 ]; then
878    # We take our time on that
879    sleep 10
880    IGCM_sys_TestDirArchive ${R_SAVE}/${1}
881    if [ $? != 0 ] ; then
882      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
883      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
884      return
885    fi
886
887    rsh ${STOREHOST} exec /bin/ksh <<EOF
888          cd ${R_SAVE}
889          /arch/local/bin/dods_rm DODS/pub/${LOGIN}/${R_DODS}/${1} > /dev/null 2>&1
890          /bin/chmod -R u+w ${R_SAVE}/${1}
891          /arch/local/bin/dods_cp ${1} DODS/pub/${LOGIN}/${R_DODS} > /dev/null 2>&1
892          /bin/chmod -R +rX ${R_SAVE}/${1}
893          /bin/chmod -R u+w ${R_SAVE}/${1}
894EOF
895    status=$?
896
897    if [ ${status} -gt 0 ] ; then
898      echo "IGCM_sys_Put_Dods : error."
899      IGCM_debug_Exit "IGCM_sys_Put_Dods"
900    fi
901  fi
902  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
903}
904
905##############################################################
906# REBUILD OPERATOR
907
908#D-#==================================================
909#D-function IGCM_sys_sync
910#D-* Purpose: flush buffer on disk (dummy function on Ada)
911#D-* Examples:
912#D-
913function IGCM_sys_sync {
914  IGCM_debug_PushStack "IGCM_sys_sync" $@
915  if ( $DEBUG_sys ) ; then
916    echo "IGCM_sys_sync :" $@
917    echo "Dummy call, let the system do that."
918  fi
919  IGCM_debug_PopStack "IGCM_sys_sync"
920}
921
922############################################################
923# Activate Running Environnment Variables
924
925#D-#==================================================
926#D-function IGCM_sys_activ_variables
927#D-* Purpose: set environement variables prior to execution
928#D-* Examples:
929#D-
930function IGCM_sys_activ_variables {
931  IGCM_debug_PushStack "IGCM_sys_activ_variables"
932  if ( $DEBUG_sys ) ; then
933    echo "IGCM_sys_activ_variables"
934  fi
935
936# --------------------------------------------------------------------
937#D- MODULE specifications
938# --------------------------------------------------------------------
939  # Source the file EnvFile containing all module load needed to run the model.
940  # EnvFile can be specified in config.card. If this is the case and if the file exists,
941  # it will be used. Otherwise a default file will be used.
942  if [ ! X${config_UserChoices_EnvFile} = X ] && [ -f ${config_UserChoices_EnvFile} ] ; then
943      # EnvFile is set in config.card and the file exists
944      IGCM_debug_Print 1 "EnvFile set in config.card will be used"
945      EnvFile=${config_UserChoices_EnvFile}
946  else
947      IGCM_debug_Print 1 "IGCM_sys_active_variables : Default modules will be used"
948      EnvFile=/smphome/rech/psl/rpsl035/.atlas_env_ada_intel_2013_0_bash > /dev/null 2>&1
949  fi
950  IGCM_debug_Print 1 "IGCM_sys_active_variables : Following EnvFile will be used :" 
951  IGCM_debug_Print 1 ${EnvFile}
952  . ${EnvFile}
953
954  IGCM_debug_Print 1 "IGCM_sys_active_variables : Now loaded modules for Ada. "
955  module list
956
957# --------------------------------------------------------------------
958#D- MPI specifications
959# --------------------------------------------------------------------
960
961# --------------------------------------------------------------------
962#D- Other specifications
963# --------------------------------------------------------------------
964
965  ulimit -s unlimited
966## to be done only one time
967## export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/smplocal/pub/NetCDF/4.1.3/lib:/smplocal/pub/HDF5/1.8.9/seq/lib
968##  echo ${LD_LIBRARY_PATH} | grep -i netcdf >/dev/null 2>&1 || export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/smplocal/pub/NetCDF/4.1.3/lib:/smplocal/pub/HDF5/1.8.9/seq/lib
969  IGCM_debug_Print 1 "set LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
970
971  export MP_STDOUTMODE=combined
972  IGCM_debug_Print 1 "set MP_STDOUTMODE=${MP_STDOUTMODE}"
973
974  ## fix to reduce memory usage. Required since 2014/22/04. On ada IDRIS.
975  #export MP_EUILIBPATH=/smplocal/lib/ibmhpc/pe12012/ppe.pami/gnu/lib64/pami64
976  #IGCM_debug_Print 1 "set MP_EUILIBPATH=${MP_EUILIBPATH}"
977
978  IGCM_debug_PopStack "IGCM_sys_activ_variables"
979}
980
981############################################################
982# Desactivate Running Environnment Variables
983
984#D-#==================================================
985#D-function IGCM_sys_desactiv_variables
986#D-* Purpose: unset environement variables after execution
987#D-* Examples:
988#D-
989function IGCM_sys_desactiv_variables {
990  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
991  if ( $DEBUG_sys ) ; then
992    echo "IGCM_sys_desactiv_variables"
993  fi
994# --------------------------------------------------------------------
995#D- MPI specifications
996# --------------------------------------------------------------------
997
998# --------------------------------------------------------------------
999#D- Other specifications
1000# --------------------------------------------------------------------
1001
1002  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1003}
1004
1005############################################################
1006# Update job headers to be used by the scheduler
1007
1008#D-#==================================================
1009#D-function IGCM_sys_updateHeaders
1010#D-* Purpose: Update job headers to be used by the scheduler
1011#D-* Examples: IGCM_sys_updateHeaders /path/to/Job_MYEXP
1012#D-
1013function IGCM_sys_updateHeaders {
1014  IGCM_debug_PushStack "IGCM_sys_updateHeaders"
1015  if ( $DEBUG_sys ) ; then
1016    echo "IGCM_sys_updateHeaders"
1017  fi
1018  typeset file
1019  file=$1
1020
1021  if [ ${executionType} -eq 1 ] ; then
1022    # MPMD + MPI
1023    if [ X${MPIEnvironment} = XIBM ] ; then
1024      sed -e "/::openMPthreads::/d"                  \
1025        -e "s/::JobNumProcTot::/${coreNumber}/"    \
1026        ${file} > ${file}.tmp
1027    else
1028      sed -e "/::openMPthreads::/d"                  \
1029        -e "s/@ job_type = parallel/@ job_type = mpich/" \
1030        -e "s/::JobNumProcTot::/${coreNumber}/"    \
1031        ${file} > ${file}.tmp
1032    fi
1033
1034  elif [ ${executionType} -eq 2 ] ; then
1035    # MPMD + MPI + OMP
1036    if [ X${MPIEnvironment} = XIBM ] ; then
1037      sed -e "s/::openMPthreads::/${openMPthreads}/" \
1038        -e "s/::JobNumProcTot::/${mpiTasks}/"    \
1039        ${file} > ${file}.tmp
1040    else
1041      (( nodeNumber = coreNumber / core_per_node ))
1042      [ $(( ${coreNumber} % ${core_per_node} )) -ne 0 ] && (( nodeNumber = nodeNumber + 1 ))
1043      sed -e "/::openMPthreads::/d"                  \
1044        -e "s/@ job_type = parallel/@ job_type = mpich/" \
1045        -e "s/@ total_tasks = ::JobNumProcTot::/@ node = ${nodeNumber} /"    \
1046        -e "/@ as_limit = 3.5gb/d"      \
1047        -e "s/::JobNumProcTot::/${mpiTasks}/"      \
1048        ${file} > ${file}.tmp
1049    fi
1050
1051  elif [ ${executionType} -eq 3 ] ; then
1052    # SPMD + MPI/OMP
1053    if [ X${MPIEnvironment} = XIBM ] ; then
1054      sed -e "s/::openMPthreads::/${openMPthreads}/" \
1055        -e "s/::JobNumProcTot::/${mpiTasks}/"      \
1056        ${file} > ${file}.tmp
1057    else
1058      sed -e "s/::openMPthreads::/${openMPthreads}/" \
1059        -e "s/@ job_type = parallel/@ job_type = mpich/" \
1060        -e "s/::JobNumProcTot::/${mpiTasks}/"      \
1061        ${file} > ${file}.tmp
1062    fi
1063
1064  elif [ ${executionType} -eq 4 ] ; then
1065    # SPMD + MPI only
1066    if [ X${MPIEnvironment} = XIBM ] ; then
1067      sed -e "s/::JobNumProcTot::/${mpiTasks}/"      \
1068        -e "/::openMPthreads::/d"                  \
1069        ${file} > ${file}.tmp
1070    else
1071      sed -e "s/::JobNumProcTot::/${mpiTasks}/"      \
1072        -e "s/@ job_type = parallel/@ job_type = mpich/" \
1073        -e "/::openMPthreads::/d"                  \
1074        ${file} > ${file}.tmp
1075    fi
1076
1077  elif [ ${executionType} -eq 5 ] ; then
1078    # SPMD + OMP only
1079    sed -e "s/::openMPthreads::/${openMPthreads}/" \
1080        -e "s/@ job_type = parallel/@ job_type = serial/" \
1081        -e "/::JobNumProcTot::/d"                  \
1082      ${file} > ${file}.tmp
1083
1084  elif [ ${executionType} -eq 6 ] ; then
1085    # SEQUENTIAL THEN
1086    sed -e "s/::JobNumProcTot::/1/"                \
1087        -e "s/@ job_type = parallel/@ job_type = serial/" \
1088        -e "/::openMPthreads::/d"                  \
1089      ${file} > ${file}.tmp
1090
1091  fi
1092
1093  IGCM_sys_Mv ${file}.tmp ${file}
1094
1095  IGCM_debug_PopStack "IGCM_sys_updateHeaders"
1096}
1097
1098############################################################
1099# Build MPI/OMP scripts run file (dummy function)
1100
1101#D-#==================================================
1102#D-function IGCM_sys_build_run_file
1103#D-* Purpose: build run file (deprecated)
1104#D-* Examples:
1105#D-
1106function IGCM_sys_build_run_file {
1107
1108  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1109
1110}
1111
1112############################################################
1113# Build MPI/OMP scripts
1114
1115#D-#==================================================
1116#D-function IGCM_sys_build_execution_scripts
1117#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
1118#D-* Examples:
1119#D-
1120function IGCM_sys_build_execution_scripts
1121{
1122  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1123  if ( $DEBUG_sys ) ; then
1124    echo "IGCM_sys_build_execution_scripts " $@
1125  fi
1126
1127  EXECUTION=${HOST_MPIRUN_COMMAND}
1128
1129  # MPMD mode
1130  if ( ${OK_PARA_MPMD} ) ; then
1131
1132    # MPI IBM Environment
1133    if ( [ "X${LOADL_STEP_TYPE}" = "XPARALLEL" ] || [ "X${LOADL_STEP_TYPE}" = "XSERIAL" ] ) ; then
1134      IGCM_debug_Print 1 "You use IBM MPI environment"
1135      if [ -f run_file ] ; then
1136        IGCM_sys_Rm -f run_file
1137      fi
1138      touch run_file
1139
1140      # Build run_file
1141
1142      # First loop on the components for the coupler ie oasis (only if oasis3)
1143      # the coupler ie oasis3 must be the first one
1144      for comp in ${config_ListOfComponents[*]} ; do
1145
1146        eval ExeNameIn=\${config_Executable_${comp}[0]}
1147        eval ExeNameOut=\${config_Executable_${comp}[1]}
1148
1149        # for CPL component only
1150        if [ "X${comp}" = "XCPL" ] ; then
1151
1152          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1153          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1154
1155          if ( ${OK_PARA_MPI} ) ; then
1156            (( mpi_count = 1 ))
1157            until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1158              echo "./${ExeNameOut}" >> run_file
1159              (( mpi_count = mpi_count + 1 ))
1160            done
1161          else
1162            echo "./${ExeNameOut} " >> run_file
1163          fi
1164        fi
1165
1166      done
1167
1168      # Then second loop on the components
1169      for comp in ${config_ListOfComponents[*]} ; do
1170
1171        eval ExeNameIn=\${config_Executable_${comp}[0]}
1172        eval ExeNameOut=\${config_Executable_${comp}[1]}
1173
1174        # Only if we really have an executable for the component and not the coupler ie oasis:
1175        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1176
1177          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1178          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1179
1180          if ( ${OK_PARA_OMP} ) ; then
1181            # Check if the number of threads is correct
1182            case ${comp_proc_omp_loc} in
1183            1|2|4)
1184              IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads on IBM MPI Environment"
1185              IGCM_debug_Print 1 "Beware : it may you use more CPU than needed."
1186              ;;
1187            8)
1188              IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads on IBM MPI Environment"
1189              IGCM_debug_Print 1 "Beware : it may you use more CPU than needed."
1190              IGCM_debug_Print 1 "Beware : these settings should not be used for IPSLCM coupled model!"
1191              ;;
1192            16)
1193              IGCM_debug_Exit "ERROR with OMP parameters !"
1194              IGCM_debug_Print 2 "Beware : ${comp_proc_omp_loc} is too much for MPMD mode"
1195              IGCM_debug_Print 2 "You will use more CPU than needed : try to use Intel-MPI environment to do such a thing !"
1196              IGCM_debug_Verif_Exit
1197              ;;
1198            *)
1199              IGCM_debug_Exit "ERROR with OMP parameters !"
1200              IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads"
1201              IGCM_debug_Print 2 "Only 1,2,4,8,16 as number of OMP threads are possible "
1202              IGCM_debug_Verif_Exit
1203              ;;
1204            esac
1205
1206          fi
1207
1208          if ( ${OK_PARA_MPI} ) ; then
1209            (( mpi_count = 1 ))
1210            until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1211              if ( ${OK_PARA_OMP} ) ; then
1212                echo "env OMP_NUM_THREADS=$comp_proc_omp_loc ./${ExeNameOut}" >> run_file
1213              else
1214                echo "./${ExeNameOut}" >> run_file
1215              fi
1216              (( mpi_count = mpi_count + 1 ))
1217            done
1218          else
1219            echo "./${ExeNameOut} " >> run_file
1220          fi
1221        fi
1222      done
1223      if ( ${OK_PARA_OMP} ) ; then
1224        export KMP_STACKSIZE=200m
1225      fi
1226
1227      EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file"
1228
1229      IGCM_sys_Chmod u+x run_file
1230      if ( $DEBUG_sys ) ; then
1231        echo "run_file contains : "
1232        cat run_file
1233      fi
1234
1235
1236    # MPI Intel Environment
1237    else
1238      IGCM_debug_Print 1 "You use Intel MPI environment"
1239
1240      # Only MPI (MPMD)
1241      if  ( ! ${OK_PARA_OMP} ) ; then
1242        init_exec=n
1243 
1244        # First loop on the components for the coupler ie oasis (only if oasis3)
1245        # the coupler ie oasis3 must be the first one
1246        for comp in ${config_ListOfComponents[*]} ; do
1247
1248          eval ExeNameIn=\${config_Executable_${comp}[0]}
1249          eval ExeNameOut=\${config_Executable_${comp}[1]}
1250
1251          # for CPL component only
1252          if [ "X${comp}" = "XCPL"  ]  && [ "X${ExeNameOut}" != X\"\" ] ; then
1253
1254            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1255            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1256
1257            echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1258            echo ""  >> script_${ExeNameOut}.ksh
1259            echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1260            IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1261            EXECUTION="${EXECUTION} -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
1262            init_exec=y
1263          fi
1264        done
1265        # Then second loop on the components
1266        for comp in ${config_ListOfComponents[*]} ; do
1267
1268          eval ExeNameIn=\${config_Executable_${comp}[0]}
1269          eval ExeNameOut=\${config_Executable_${comp}[1]}
1270
1271          # Only if we really have an executable for the component and not the coupler ie oasis:
1272          if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1273
1274            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1275            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1276
1277            echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1278            echo ""  >> script_${ExeNameOut}.ksh
1279            echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1280            IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1281
1282            if [ ${init_exec} = y ] ; then
1283              EXECUTION="${EXECUTION} : -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
1284            else
1285              EXECUTION="${EXECUTION} -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
1286              init_exec=y
1287            fi
1288          fi
1289        done
1290      # MPI-OpenMP (MPMD)
1291      else
1292
1293        # Execution specifications
1294        EXECUTION="${EXECUTION} -configfile run_file"
1295        export KMP_STACKSIZE=200m
1296        if [ -f run_file ] ; then
1297          IGCM_sys_Rm -f run_file
1298        fi
1299        touch run_file
1300
1301        # Initialisation of variables
1302        string_final=""
1303        string_final_hexa=""
1304        current_core=0
1305        executable_nb=1
1306
1307        #  Hosts treatment
1308        for nodes in `echo $LOADL_PROCESSOR_LIST`
1309        do
1310          host[$i]=$nodes
1311          i=$((i+1))
1312        done
1313
1314        # Loop on the components
1315        for comp in ${config_ListOfComponents[*]} ; do
1316
1317          eval ExeNameIn=\${config_Executable_${comp}[0]}
1318          eval ExeNameOut=\${config_Executable_${comp}[1]}
1319
1320          # Not possible if oasis has an executable (i.e old version of oasis3)
1321          if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" = "XCPL" ] ) ; then
1322            IGCM_debug_Exit "ERROR MPMD with hybrid MPI-OpenMP is not available with oasis3 version"
1323            IGCM_debug_Print 2 "Only available with oasis3-MCT version coupler"
1324            IGCM_debug_Verif_Exit
1325          fi
1326
1327          # Only if we really have an executable for the component :
1328          if [ "X${ExeNameOut}" != X\"\" ] ; then
1329
1330            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1331            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1332
1333            # Check if the number of threads is correct
1334            case ${comp_proc_omp_loc} in
1335            1|2|4|8|16)
1336              IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads"
1337              ;;
1338            *)
1339              IGCM_debug_Exit "ERROR with OMP parameters !"
1340              IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads"
1341              IGCM_debug_Print 2 "Only 1,2,4,8,16 as number of OMP threads are possible "
1342              IGCM_debug_Verif_Exit
1343              ;;
1344            esac
1345
1346
1347            # Build run_file for Ada Intel-MPI environment : method used to assign cores and nodes for the MPI process by using hexadecimal mask
1348            # Example of run_file :
1349            #-host host0 -n 4 -env I_MPI_PIN_DOMAIN=[ff,ff00,ff0000,ff000000] ./a.out
1350            #-host host1 -n 4 -env I_MPI_PIN_DOMAIN=[ff,ff00,ff0000,ff000000] ./a.out
1351            #-host host2 -n 10 -env I_MPI_PIN_DOMAIN=[3,c,30,c0,300,c00,3000,c000,30000,c0000,100000,200000,400000,800000,1000000,2000000,4000000,8000000,10000000,20000000] ./b.out
1352            #-host host2 -n 10 ./c.out
1353            # Example of final command :
1354            # mpirun -configfile run_file
1355
1356            rank=0
1357            # For one specific executable, loop on mpi process
1358            for nb_proc_mpi in `seq 0 $(($comp_proc_mpi_loc-1))`; do
1359              (( index_host = current_core / core_per_node ))
1360              host_value=${host[${index_host}]}
1361              (( slot =  current_core % core_per_node ))
1362              # loop on omp threads for each mpi process (set the appropriate bit to 1 and append it to previous one)
1363              for index in `seq $slot $(($slot+$comp_proc_omp_loc-1))`; do
1364                string_final="1"$string_final
1365              done
1366              # convert binary mask to hexadecimal mask
1367              if [ $rank -ne 0 ] ; then
1368                string_final_hexa=$string_final_hexa","$( printf '%x\n' "$((2#$string_final))" )
1369              else
1370                string_final_hexa=$( printf '%x\n' "$((2#$string_final))" )
1371              fi
1372              # replace bit 1 by bit 0 in order to append next one (next one wil be 1)
1373              string_final=$( echo $string_final | sed "s/1/0/g" )
1374              # mpi rank = mpi_rank + 1
1375              (( rank = rank + 1 ))
1376              # current core takes into account the number of omp threads which was previously append
1377              (( current_core = current_core + comp_proc_omp_loc ))
1378              # We write to the configuration file either we switch to the next node or we switch to the next executable
1379              if ( [ $(( current_core / core_per_node )) -ne $index_host ] || [ $nb_proc_mpi -eq $(($comp_proc_mpi_loc-1)) ] ) ; then
1380                # I_MPI_PIN_DOMAIN variable must be given once per node
1381                if [ $executable_nb -eq 1 ] ; then
1382                  echo "-host $host_value -n $rank -env I_MPI_PIN_DOMAIN=[$string_final_hexa] ./$ExeNameOut" >> run_file
1383                else
1384                  sed -i "/$host_value/s/\]/\,$string_final_hexa\]/g" run_file
1385                  echo "-host $host_value -n $rank ./$ExeNameOut" >> run_file
1386                fi
1387                # +1 for the number of executbale on the same node
1388                if [ $nb_proc_mpi -eq $(($comp_proc_mpi_loc-1)) ] ; then
1389                  (( executable_nb = executable_nb + 1 ))
1390                fi
1391                # Some initializations if we switch to the next node
1392                if [ $(( current_core / core_per_node )) -ne $index_host ] ; then
1393                  string_final=""
1394                  string_final_hexa=""
1395                  rank=0
1396                  executable_nb=1
1397                fi
1398              fi
1399            done
1400
1401          fi
1402        done
1403        IGCM_sys_Chmod u+x run_file
1404        if ( $DEBUG_sys ) ; then
1405          echo "run_file contains : "
1406          cat run_file
1407        fi
1408      fi
1409    fi
1410
1411  # Only one executable (SPMD mode).
1412  else
1413
1414    for comp in ${config_ListOfComponents[*]} ; do
1415
1416      # Only if we really have an executable for the component :
1417      eval ExeNameOut=\${config_Executable_${comp}[1]}
1418      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
1419
1420        if ( ${OK_PARA_OMP} ) ; then
1421          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1422          export KMP_STACKSIZE=200m
1423          #export KMP_LIBRARY=turnaround
1424          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1425          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1426          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1427        fi
1428        if  ( ${OK_PARA_MPI} ) ; then
1429          if ( [ "X${LOADL_STEP_TYPE}" = "XPARALLEL" ] || [ "X${LOADL_STEP_TYPE}" = "XSERIAL" ] ) ; then
1430            EXECUTION="${HOST_MPIRUN_COMMAND} ./${ExeNameOut}"
1431          else
1432            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1433            EXECUTION="${HOST_MPIRUN_COMMAND} -np ${comp_proc_mpi_loc} ./${ExeNameOut}"
1434          fi
1435        else
1436          EXECUTION="/usr/bin/time ./${ExeNameOut}"
1437        fi
1438      fi
1439
1440    done
1441
1442  fi
1443
1444  IGCM_debug_Print 1 "sys ada : execution command is "
1445  IGCM_debug_Print 1 "$EXECUTION"
1446
1447  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1448}
1449
1450#D-#==================================================
1451#D-function IGCM_sys_check_path
1452#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
1453#D-* do not point to an important use directory. Stop immediately in that case.
1454#D-* Examples:
1455#D-
1456function IGCM_sys_check_path {
1457  IGCM_debug_PushStack "IGCM_sys_check_path"
1458  if ( $DEBUG_sys ) ; then
1459    echo "IGCM_sys_check_path"
1460  fi
1461
1462  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORKDIR} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then
1463    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
1464    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
1465    IGCM_debug_Exit "This will stop the job"
1466  fi
1467  IGCM_debug_PopStack "IGCM_sys_check_path"
1468}
1469
1470#D-#==================================================
1471#D-function IGCM_sys_check_quota
1472#D-* Purpose: check user quota. Stop the simulation if quota above 90%
1473#D-* Examples:
1474#D-
1475function IGCM_sys_check_quota {
1476  IGCM_debug_PushStack "IGCM_sys_check_quota"
1477  if ( $DEBUG_sys ) ; then
1478    echo "IGCM_sys_check_quota"
1479  fi
1480  # Limit of quota (in %)
1481  limit_quota=90
1482
1483  # Check of the volume
1484  volume_quota=$(quota_u -w 2>/dev/null| grep 'Quota soft' | gawk '{print $5}')
1485  if [ ! X${volume_quota} = X ] ; then
1486    quota_volume=${volume_quota%%\%}
1487#    echo $quota_volume
1488    if [ $(echo "${quota_volume} > ${limit_quota}" | bc) -eq 1 ] ; then
1489      IGCM_debug_Print 1 "Please, check your quota of volume on workgpfs"
1490      IGCM_debug_Print 1 "${quota_volume}% of your quota is used"
1491      IGCM_debug_Print 1 "Use the quota_u -w command to check"
1492      IGCM_debug_Print 1 "You must have more than 10% available to run"
1493      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1494      IGCM_debug_Verif_Exit
1495    fi
1496
1497  fi
1498  IGCM_debug_PopStack "IGCM_sys_check_quota"
1499}
1500
1501#D-#==================================================
1502#D-function IGCM_sys_projectAccounting
1503#D-* Purpose: store project accounting information in a file
1504#D-* Examples:
1505#D-
1506function IGCM_sys_projectAccounting {
1507  IGCM_debug_PushStack "IGCM_sys_projectAccounting"
1508  if ( $DEBUG_sys ) ; then
1509    echo "IGCM_sys_check_quota"
1510  fi
1511
1512  cpt > $1
1513
1514  IGCM_debug_PopStack "IGCM_sys_projectAccounting"
1515}
1516
1517#D-#==================================================
1518#D-function IGCM_sys_getJobSchedulerID
1519#D-* Purpose: Get the job ID during execution
1520#D-* Examples: IGCM_sys_getJobSchedulerID jobSchedulerID
1521#D-
1522function IGCM_sys_getJobSchedulerID {
1523  IGCM_debug_PushStack "IGCM_sys_getJobSchedulerID"
1524  if ( $DEBUG_sys ) ; then
1525    echo "IGCM_sys_getJobSchedulerID"
1526  fi
1527
1528  eval ${1}=$( echo $LOADL_STEP_ID | awk -F. '{print $4}' )
1529
1530  IGCM_debug_PopStack "IGCM_sys_getJobSchedulerID"
1531}
1532
1533#D-#==================================================
1534#D-function IGCM_sys_GetJobID
1535#D-* Purpose: Get the job ID from the JobName
1536#D-* Examples: IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID
1537#D-
1538function IGCM_sys_GetJobID {
1539  IGCM_debug_PushStack "IGCM_sys_GetJobID"
1540  if ( $DEBUG_sys ) ; then
1541    echo "IGCM_sys_GetJobID"
1542  fi
1543
1544  # Print only the full (-W) JobID (%id) and JobName (%jn)
1545  ID=$( llq -u $2 -W -f %id %jn | \
1546    gawk -v JobName=$1 '( $NF ~ JobName ) { print $1 }' )
1547
1548  eval ${3}=${ID}
1549  IGCM_debug_PopStack "IGCM_sys_GetJobID"
1550}
1551
1552#D-#==================================================
1553#D-function IGCM_sys_CountJobInQueue
1554#D-* Purpose: Count number of users job
1555#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
1556#D-
1557function IGCM_sys_CountJobInQueue {
1558  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
1559  if ( $DEBUG_sys ) ; then
1560    echo "IGCM_sys_CountJobInQueue"
1561  fi
1562
1563  # Print only the full (-W) JobName (%jn)
1564  NbRun=$( llq -W -f %jn | grep -c "$1" )
1565
1566  eval ${2}=${NbRun}
1567
1568  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
1569}
1570
1571#D-#==================================================
1572#D-function IGCM_sys_ListJobInQueue
1573#D-* Purpose: Produce a list of users jobs
1574#D-* Examples: IGCM_sys_ListJobInQueue ${User} JobNameList
1575#D-
1576function IGCM_sys_ListJobInQueue {
1577  IGCM_debug_PushStack "IGCM_sys_ListJobInQueue"
1578  if ( $DEBUG_sys ) ; then
1579    echo "IGCM_sys_ListJobInQueue"
1580  fi
1581
1582  # With -W option, column width is as large as necessary
1583  set -A JobList $( llq -u $1 -W -f %jn | head -n -2 | tail -n +3 | \
1584    gawk '( $1 != /TS/      && \
1585                            $1 !~ /PACK/    && \
1586                            $1 !~ /REBUILD/ && \
1587                            $1 !~ /pack/ )     \
1588                          { print $1 }' | sed -e "s/\(.*\)\.[0-9]*/\1/" )
1589
1590  eval set -A ${2} ${JobList[*]}
1591
1592  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue"
1593}
1594
1595#D-#==================================================
1596#D-function IGCM_sys_atlas
1597#D-* Purpose: encapsulate atlas call so as to manage error code and curie specificity
1598#D-* Examples:
1599#D-
1600function IGCM_sys_atlas {
1601  IGCM_debug_PushStack "IGCM_sys_atlas" $@
1602  if ( $DEBUG_sys ) ; then
1603    echo "IGCM_sys_atlas :" $@
1604  fi
1605
1606  typeset status
1607
1608  \atlas $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
1609  status=$?
1610  if [ ${status} -gt 0 ] ; then
1611    echo "IGCM_sys_atlas : error code ${status}"
1612    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
1613    \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
1614    IGCM_debug_PopStack "IGCM_sys_atlas"
1615    return 1
1616  else
1617    IGCM_debug_PopStack "IGCM_sys_atlas"
1618    return 0
1619  fi
1620
1621  IGCM_debug_PopStack "IGCM_sys_atlas"
1622}
1623
1624#D-#==================================================
1625#D-function IGCM_sys_rebuild_nemo
1626#D-* Purpose: rebuild nemo parallel files with general rebuild
1627#D-* Examples:
1628#D-
1629
1630function IGCM_sys_rebuild_nemo {
1631  IGCM_debug_PushStack "IGCM_sys_rebuild_nemo" $@
1632  if ( $DEBUG_sys ) ; then
1633    echo "IGCM_sys_rebuild_nemo :" $@
1634  fi
1635
1636  nemo_generic_restart_file_name_out=${1}
1637  nemo_extension_out=${3}
1638  shift ; shift ; shift
1639
1640  IGCM_sys_rebuild -o ${nemo_generic_restart_file_name_out}.${nemo_extension_out} $@
1641
1642  IGCM_debug_PopStack "IGCM_sys_rebuild_nemo"
1643}
1644
1645
Note: See TracBrowser for help on using the repository browser.