source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_jeanzay.ksh @ 1498

Last change on this file since 1498 was 1498, checked in by acosce, 4 years ago

Add header for monitoring job on jeanzay - comment ccc_hsm get on libIGCM_sys_jeanzay -> need to find the command adapted to this computing center

  • 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: 54.5 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip, Arnaud Caubel
5# Contact: Arnaud.Caubel__at__lsce.ipsl.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 Jean-Zay
22#D-#==================================================
23#D-
24#D- This ksh library if a layer under some usefull
25#D-environment variables and shell commands.
26#D-All those definitions depend on host particularities.
27#D-It manages a stack mechanism and test validity of operations.
28#D-All function described bellow must be prefixed by IGCM_sys.
29
30#====================================================
31# libIGCM_sys PARAMETERS
32#====================================================
33
34#====================================================
35# set DEBUG_sys to true to output calls of function
36typeset -r DEBUG_sys=${DEBUG_sys:=true}
37
38#====================================================
39# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
40typeset -r DRYRUN=${DRYRUN:=0}
41
42# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
43# -------------------------------------------------------------------------------------
44# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
45# |          |  Cp/Exe/param/files |            |         |                           |
46# |          |  Chmod Qsub         |            |         |                           |
47# -------------------------------------------------------------------------------------
48# |    0     |       yes           |    yes     |  yes    |      yes                  |
49# -------------------------------------------------------------------------------------
50# |    1     |       yes           |    yes     |  yes    |      no                   |
51# -------------------------------------------------------------------------------------
52# |    2     |       yes           |    yes     |  no     |      no                   |
53# -------------------------------------------------------------------------------------
54# |    3     |       yes           |    no      |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56
57#=====================================================
58# Global Variables :
59#=====================================================
60# Language : "fr" or "en"
61typeset -r MYLANG="fr"
62
63#=====================================================
64# Host user names project maxCpuTime
65# $hostname ou hostname
66typeset HOST=${HOST:=$( hostname )}
67# $username ou whoami
68typeset LOGIN=${LOGIN:=$( whoami )}
69# $hostname of the MASTER job
70typeset MASTER=jeanzay
71# add default project set by ins_job
72typeset PROJECT=$( echo ${SLURM_JOB_ACCOUNT:=::default_project::} | cut -c "1-3" ) 
73### jobWarningDelay in seconds
74##typeset jobWarningDelay=${BRIDGE_MSUB_MAXTIME}
75 
76#D-
77#D-#==================================================
78#D-Program used in libIGCM
79#D-#==================================================
80
81# Submit command
82typeset SUBMIT=${SUBMIT:=sbatch}
83# rsync with path
84typeset -r RSYNC=/usr/bin/rsync
85# RSYNC_opt args to rsync
86typeset -r RSYNC_opt="-va"
87# ie storage filesystem
88typeset -r STOREHOST=${MASTER}
89typeset -r REMOTE_RSYNC=/usr/bin/rsync
90
91#====================================================
92# Access to module command
93#====================================================
94. /usr/share/Modules/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  module purge > /dev/null 2>&1
103  . /gpfswork/rech/psl/commun/MachineEnvironment/jeanzay/env_jeanzay > /dev/null 2>&1
104#currently no atlas
105#  . /gpfswork/rech/psl/commun/MachineEnvironment/jeanzay/env_atlas_jeanzay > /dev/null 2>&1
106
107#  export PCMDI_MP=/ccc/work/cont003/igcmg/igcmg/PCMDI-MP
108  export UVCDAT_ANONYMOUS_LOG=FALSE
109fi
110
111# FYI
112[ ! X${TaskType} = Xchecking ] && IGCM_debug_Print 1 "List of loaded modules:"
113[ ! X${TaskType} = Xchecking ] && module list
114
115# For AddNoise (not yet AddPertu3DOCE)
116export PATH=${PATH}:/gpfswork/rech/psl/commun/Tools/AddNoise/bin
117
118# For rebuild
119export PATH=${PATH}:/gpfswork/rech/psl/commun/Tools/rebuild/modipsl_IOIPSL_PLUS_v2_2_4/bin
120
121#====================================================
122# Host specific DIRECTORIES
123#====================================================
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
139typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${SLURM_SUBMIT_DIR}}
140
141#====================================================
142#- IN
143typeset -r R_IN=${R_IN:=/gpfswork/rech/psl/commun/IGCM}
144
145#====================================================
146#- RUN_DIR_PATH : Temporary working directory (=> TMP)
147typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCH}/RUN_DIR/${SLURM_JOBID}_${$}}
148
149#====================================================
150#- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs
151typeset -r OUTCOMMAND_PATH=/tmp
152
153#====================================================
154#- HOST_MPIRUN_COMMAND
155typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time srun "}
156
157#====================================================
158#- Max number of arguments passed to nco operator or demigration command
159UNIX_MAX_LIMIT=360
160
161#====================================================
162#- set PackDefault to true
163PackDefault=true
164
165#====================================================
166#- Default number of MPI task for IPSL coupled model
167#- required for backward compatibility
168#-
169DEFAULT_NUM_PROC_OCE=5
170DEFAULT_NUM_PROC_CPL=1
171(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
172
173#====================================================
174#- Number of computing cores per node
175#-
176NB_CORE_PER_NODE=40
177
178#D-#==================================================
179#D-function IGCM_sys_defineArchives
180#D-* Purpose:
181#D-* Load dfldatadir module : According to project used for submission (default) or set in config.card (optional)
182#D-* Define ARCHIVE : Dedicated to large files
183#D-* Define STORAGE : Dedicated to small/medium files
184#D-* Define R_OUT   : Output tree located on ARCHIVE
185#D-* Define R_FIG   : Output tree located on STORAGE hosting figures (monsitoring and atlas, and/or small files)
186#D-* Define R_BUF   : Output tree located on SCRATCH hosting files waiting for rebuild or pack processes
187#D-* if SpaceName=TEST everything is stored on SCRATCH
188#D-* Examples:
189#D-
190function IGCM_sys_defineArchives {
191  IGCM_debug_PushStack "IGCM_sys_defineArchives"
192
193  # Load dfldatadir depending on the project used for submission (default) or set in config.card (optional)
194  if [ X${config_UserChoices_DataProject} = X ] || [ X${config_UserChoices_DataProject} = DEFAULT ]; then
195    # The variable DataProject is not set in in section UserChoices in config.card or it is set to DEFAULT
196    # Default option: Change IDRPROJ according to the project used for submission
197
198    # jg following line does not work in a submitted job:
199    eval $(idrenv -d ${PROJECT})
200  else
201    # Use the project set by the variable DataProject in section UserChoices in config.card
202    eval $(idrenv -d ${config_UserChoices_DataProject})
203    IGCM_debug_Print 1 "Change DataProject red in config.card : ${config_UserChoices_DataProject}"
204  fi
205  IGCM_debug_Print 1 "Data project for output to be used: ${IDRPROJ}"
206
207  #====================================================
208  #- RUN_DIR_PATH : Temporary working directory (=> TMP)
209  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCH}/RUN_DIR/${SLURM_JOBID}_${$}}
210
211  if [ ! X${config_UserChoices_ARCHIVE} = X ]; then
212    #====================================================
213    #- ARCHIVE (dedicated to large files)
214    ARCHIVE=${config_UserChoices_ARCHIVE}
215  else
216    #====================================================
217    #- ARCHIVE (dedicated to large files)
218    ARCHIVE=${STORE}
219  fi
220
221  if [ ! X${config_UserChoices_STORAGE} = X ]; then
222    #====================================================
223    #- STORAGE (dedicated to small/medium files)
224    STORAGE=${config_UserChoices_STORAGE}
225  else
226    #====================================================
227    #- STORAGE (dedicated to small/medium files)
228    STORAGE=${WORK}
229  fi
230
231  if [ X${config_UserChoices_SpaceName} = XTEST ]; then
232    #====================================================
233    #- R_OUT
234    R_OUT=${SCRATCH}/IGCM_OUT
235
236    #====================================================
237    #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
238    R_FIG=${SCRATCH}/IGCM_OUT
239
240    IGCM_debug_Print 1 "SpaceName=TEST ==> OVERRULE destination path directories"
241
242  else
243    #====================================================
244    #- R_OUT
245    R_OUT=${ARCHIVE}/IGCM_OUT
246
247    #====================================================
248    #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
249    R_FIG=${STORAGE}/IGCM_OUT
250  fi
251
252  #====================================================
253  #- CMIP6 (hosting CMIP6 files produced by XIOS2 and configured by dr2xml)
254  CMIP6_BUF=${STORAGE}/IGCM_OUT
255
256  #====================================================
257  #- R_BUF (ONLY FOR double copy an scratch)
258  R_BUF=${SCRATCH}/IGCM_OUT
259
260  IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
261  IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}"
262  IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}"
263
264  IGCM_debug_PopStack "IGCM_sys_defineArchives"
265}
266
267#D-#==================================================
268#D-function IGCM_sys_RshArchive
269#D-* Purpose: Archive rsh command
270#D-* Examples:
271#D-
272function IGCM_sys_RshArchive {
273  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
274  /bin/ksh <<-EOF
275    ${@}
276EOF
277  status=$?
278  if [ ${status} -gt 0 ] ; then
279    IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}"
280    IGCM_debug_Exit "IGCM_sys_RshArchive"
281  fi
282  IGCM_debug_PopStack "IGCM_sys_RshArchive"
283}
284
285#D-#==================================================
286#D-function IGCM_sys_RshArchive_NoError
287#D-* Purpose: Archive rsh command, without error
288#D-*          used only in monitoring.job
289#D-* Examples:
290#D-
291function IGCM_sys_RshArchive_NoError {
292  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@
293  /bin/ksh <<-EOF
294    ${@} 2> /dev/null
295EOF
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  if [ ! -d ${1} ]; then
311    \mkdir -p $1
312    status=$?
313
314    if [ ${status} -gt 0 ] ; then
315      IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
316      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
317    fi
318  fi
319  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
320}
321
322#D-#==================================================
323#D-function IGCM_sys_TestDirArchive
324#D-* Purpose: Test Directory that must exists on Archive
325#D-* Examples:
326#D-
327function IGCM_sys_TestDirArchive {
328  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
329  if ( $DEBUG_sys ) ; then
330    echo "IGCM_sys_TestDirArchive :" $@
331  fi
332  typeset ExistFlag
333  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
334  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
335  return ${ExistFlag}
336}
337
338#D-#==================================================
339#D-function IGCM_sys_IsFileArchived
340#D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only
341#D-* Examples:
342#D-
343function IGCM_sys_IsFileArchived {
344  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
345  if ( $DEBUG_sys ) ; then
346    echo "IGCM_sys_IsFileArchived :" $@
347  fi
348  typeset IsArchivedFlag
349  IsArchivedFlag=$( [ X$( echo $@ | grep ^\/ccc\/store ) != X ] && echo 0 || echo 1 )
350  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
351
352  return ${IsArchivedFlag}
353}
354
355#D-#==================================================
356#D-function IGCM_sys_TestFileArchive
357#D-* Purpose: Test file that must NOT EXISTS on Archive
358#D-* Examples:
359#D-
360function IGCM_sys_TestFileArchive {
361  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
362  typeset ExistFlag
363  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
364  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
365
366  return ${ExistFlag}
367}
368
369#D-#==================================================
370#D-function IGCM_sys_CountFileArchive
371#D-* Purpose: Count files on Archive filesystem
372#D-* Examples:
373#D-
374function IGCM_sys_CountFileArchive {
375  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
376  ls ${@} 2>/dev/null | wc -l
377  if [ $? -gt 0 ] ; then
378    echo "IGCM_sys_CountFileArchive : erreur."
379  fi
380  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
381}
382
383#D-#==================================================
384#D-function IGCM_sys_Tree
385#D-* Purpose: Tree directories with files on ${ARCHIVE}
386#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
387#D-
388function IGCM_sys_Tree {
389  IGCM_debug_PushStack "IGCM_sys_Tree" $@
390  if ( $DEBUG_sys ) ; then
391    echo "IGCM_sys_Tree :" $@
392  fi
393
394  \ls -lR ${@}
395
396  IGCM_debug_PopStack "IGCM_sys_Tree"
397}
398
399#D-#==================================================
400#D-function IGCM_sys_Qsub
401#D-* Purpose: Qsub new job
402#D-* Examples:
403#D-
404function IGCM_sys_Qsub {
405  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
406  if ( $DEBUG_sys ) ; then
407    echo "IGCM_sys_Qsub :" $@
408  fi
409  typeset options status
410  options="-o ${SUBMIT_DIR}/${Script_Output} -e ${SUBMIT_DIR}/${Script_Output}"
411
412  /usr/bin/time sbatch ${options} $1 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
413  status=$?
414
415  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
416  if [ ${status} -gt 0 ] ; then
417    IGCM_debug_Print 2 "IGCM_sys_Qsub ${options} $1 : error code ${status}"
418    IGCM_debug_Exit "IGCM_sys_Qsub"
419  else
420    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
421  fi
422  IGCM_debug_PopStack "IGCM_sys_Qsub"
423}
424
425#D-#==================================================
426#D-function IGCM_sys_QsubPost
427#D-* Purpose: Qsub new job on scalaire
428#D-* Examples:
429#D-
430function IGCM_sys_QsubPost {
431  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
432  if ( $DEBUG_sys ) ; then
433    echo "IGCM_sys_QsubPost :" $@
434  fi
435  typeset options status
436  options="-o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out"
437
438  sbatch ${options} ${libIGCM_POST}/$1.job > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
439  status=$?
440
441  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
442  if [ ${status} -gt 0 ] ; then
443    IGCM_debug_Print 2 "IGCM_sys_QsubPost ${options} ${libIGCM_POST}/$1.job : error code ${status}"
444    IGCM_debug_Exit "IGCM_sys_QsubPost"
445  else
446    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
447  fi
448  IGCM_debug_PopStack "IGCM_sys_QsubPost"
449}
450
451#D-*************************
452#D- File transfer functions
453#D-*************************
454#D-
455
456#D-#==================================================
457#D-function IGCM_sys_RmRunDir
458#D-* Purpose: rm tmpdir (dummy function most of the time batch
459#D-                      scheduler will do the job)
460#D-* Examples:
461#D-
462function IGCM_sys_RmRunDir {
463  IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@
464  if ( $DEBUG_sys ) ; then
465    echo "IGCM_sys_RmRunDir :" $@
466  fi
467
468  typeset status
469
470  echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
471  \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
472  status=$?
473
474  if [ ${status} -gt 0 ] ; then
475    IGCM_debug_Print 1 "IGCM_sys_RmRunDir : rm error code is ${status}."
476    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
477    IGCM_debug_Exit "IGCM_sys_RmRunDir"
478  else
479    \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
480  fi
481  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
482}
483
484#D-#==================================================
485#D-function IGCM_sys_Put_Dir
486#D-* Purpose: Copy a complete directory on $(ARCHIVE)
487#D-* Examples:
488#D-
489function IGCM_sys_Put_Dir {
490  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
491  if ( $DEBUG_sys ) ; then
492    echo "IGCM_sys_Put_Dir :" $@
493  fi
494  if [ $DRYRUN = 0 ]; then
495    if [ ! -d ${1} ] ; then
496      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
497      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
498      return
499    fi
500
501    typeset status
502
503    # Only if we use rsync
504    #IGCM_sys_TestDirArchive $( dirname $2 )
505    #
506    #USUAL WAY
507    \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
508    status=$?
509
510    if [ ${status} -gt 0 ] ; then
511      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}"
512      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
513      IGCM_debug_Exit "IGCM_sys_Put_Dir"
514    else
515      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
516    fi
517  fi
518  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
519}
520
521#D-#==================================================
522#D-function IGCM_sys_Get_Dir
523#D-* Purpose: Copy a complete directory from ${ARCHIVE}
524#D-* Examples:
525#D-
526function IGCM_sys_Get_Dir {
527  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
528  if ( $DEBUG_sys ) ; then
529    echo "IGCM_sys_Get_Dir :" $@
530  fi
531  if [ $DRYRUN = 0 ]; then
532    typeset NB_ESSAI DELAI status i
533    # number of tentative
534    NB_ESSAI=3
535    # time delay between tentative
536    DELAI=2
537
538    #
539    # USUAL WAY
540    # add 'ccc_hsm get' (to demigrate all offline files) to reduce time of this command :
541 #trouver la bonne commande sur jeanzay   ccc_hsm get -r $1
542
543    i=0
544    while [ $i -lt $NB_ESSAI ] ; do
545      \cp -ur $1 $2 >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
546      status=$?
547      if [ ${status} -gt 0 ] ; then
548        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}"
549        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
550        sleep $DELAI
551      else
552        break
553      fi
554      (( i = i + 1 ))
555    done
556
557    if [ ${status} -gt 0 ] ; then
558      IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
559      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
560      IGCM_debug_Exit "IGCM_sys_Get_Dir"
561    else
562      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
563    fi
564  fi
565  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
566}
567
568#D-#==================================================
569#D-function IGCM_sys_Put_Rest
570#D-* Purpose: Put computied restarts on ${ARCHIVE}.
571#D-           File and target directory must exist.
572#D-* Examples:
573#D-
574function IGCM_sys_Put_Rest {
575  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
576  if ( $DEBUG_sys ) ; then
577    echo "IGCM_sys_Put_Rest :" $@
578  fi
579  if [ $DRYRUN = 0 ]; then
580    if [ ! -f ${1} ] ; then
581      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
582      IGCM_debug_Exit "IGCM_sys_Put_Rest"
583    fi
584
585    typeset status
586    #
587    # USUAL WAY
588    \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
589    status=$?
590
591#       #RSYNC WITH NETWORK SSH CALL
592#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
593#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
594
595#       #RSYNC WITH NFS USE
596#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
597#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
598
599#       status=$?
600#       IGCM_sys_Rsync_out $status
601
602#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
603#       (( status=status+$? ))
604
605    if [ ${status} -gt 0 ] ; then
606      IGCM_debug_Print 2 "IGCM_sys_Put_Rest : cp failed error code ${status}"
607      [ -f ${1} ] && ls -l ${1}
608      [ -f ${2} ] && ls -l ${2}
609      [ -f ${2}/${1} ] && ls -l ${2}/${1}
610      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
611      IGCM_debug_Exit "IGCM_sys_Put_Rest"
612    else
613
614      if [ X${JobType} = XRUN ] ; then
615        [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
616        [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
617      fi
618
619      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
620    fi
621  fi
622  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
623}
624
625#D-#==================================================
626#D-function IGCM_sys_Put_Out
627#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
628#D-* Examples:
629#D-
630function IGCM_sys_Put_Out {
631  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
632  if ( $DEBUG_sys ) ; then
633    echo "IGCM_sys_Put_Out :" $@
634  fi
635
636  typeset NB_ESSAI DELAI status i exist skip
637  typeset fileDeviceNumberInHex directoryDeviceNumberInHex
638
639  # number of tentative
640  NB_ESSAI=3
641  # time delay between tentative
642  DELAI=2
643
644  if [ $DRYRUN = 0 ]; then
645    if [ ! -f ${1} ] ; then
646      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
647      IGCM_debug_PopStack "IGCM_sys_Put_Out"
648      return 1
649    fi
650    #
651    IGCM_sys_MkdirArchive $( dirname $2 )
652    #
653    exist=false
654    skip=false
655    if [ -f $2 ] ; then
656      IGCM_debug_Print 1 "$2 already exist"
657 #trouver la bonne commande sur jeanzay     ccc_hsm get $2
658      exist=true
659      if [ "X$( diff $1 $2 )" = X ] ; then
660        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
661        skip=true
662      else
663        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
664        skip=false
665      fi
666    fi
667    #
668    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
669      IGCM_sys_Chmod u+w $2
670    fi
671
672    if [ X${skip} = Xfalse ] ; then
673      i=0
674      while [ $i -lt $NB_ESSAI ] ; do
675        # Identify file system
676        fileDeviceNumberInHex=$( stat -c %d $1 )
677        status=$?
678        if [ ${status} -gt 0 ] ; then
679          IGCM_debug_Exit "IGCM_sys_Put_Out"
680        fi
681        # Identify file system
682        directoryDeviceNumberInHex=$( stat -c %d $( dirname $2 ) )
683        status=$?
684        if [ ${status} -gt 0 ] ; then
685          IGCM_debug_Exit "IGCM_sys_Put_Out"
686        fi
687
688        if ( [ ${fileDeviceNumberInHex} -ne ${directoryDeviceNumberInHex} ] || [ X$3 = XNOMOVE ] ) ; then
689          # They are not on the same device. USUAL WAY
690          \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
691          status=$?
692        else
693          # They are on the same device. NOT SO USUAL WAY
694          \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
695          status=$?
696        fi
697        if [ ${status} -gt 0 ]; then
698          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
699          IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again."
700          [ -f ${1} ] && ls -l ${1}
701          [ -f ${2} ] && ls -l ${2}
702          [ -f ${2}/${1} ] && ls -l ${2}/${1}
703          sleep $DELAI
704        else
705          break
706        fi
707        (( i = i + 1 ))
708      done
709    fi
710
711#       #RSYNC WITH NETWORK SSH CALL
712#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
713#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
714
715#       #RSYNC WITH NFS USE
716#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
717#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
718
719#       status=$?
720#       IGCM_sys_Rsync_out $status
721
722#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
723#       (( status=status+$? ))
724
725    if [ ${status} -gt 0 ] ; then
726      IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status}"
727      [ -f ${1} ] && ls -l ${1}
728      [ -f ${2} ] && ls -l ${2}
729      [ -f ${2}/${1} ] && ls -l ${2}/${1}
730      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
731      IGCM_debug_Exit "IGCM_sys_Put_Out"
732    else
733
734      if [ X${JobType} = XRUN ] ; then
735        if [ X${3} = X ] ; then
736          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
737          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
738        fi
739      fi
740
741      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
742    fi
743  fi
744  IGCM_debug_PopStack "IGCM_sys_Put_Out"
745  return 0
746}
747
748#D-#==================================================
749#D-function IGCM_sys_Get
750#D-* Purpose: Get a file from ${ARCHIVE}
751#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
752#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
753function IGCM_sys_Get {
754  IGCM_debug_PushStack "IGCM_sys_Get" $@
755
756  typeset DEST dm_liste target file_work
757  typeset NB_ESSAI DELAI status i
758
759  if ( $DEBUG_sys ) ; then
760    echo "IGCM_sys_Get :" $@
761  fi
762
763  # number of tentative
764  NB_ESSAI=3
765  # time delay between tentative
766  DELAI=2
767
768  if [ $DRYRUN -le 2 ]; then
769    if [ X${1} = X'/l' ] ; then
770      eval set +A dm_liste \${${2}}
771    else
772      eval set +A dm_liste ${1}
773    fi
774    eval DEST=\${${#}}
775 #trouver la bonne commande sur jeanzay   ccc_hsm get ${dm_liste[*]} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
776    status=$?
777    if [ ${status} -gt 0 ] ; then
778      echo "WARNING IGCM_sys_Get : error code ${status}"
779      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
780      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
781    fi
782
783    #if [ ${status} -gt 0 ] ; then
784    #  if [ ! "X$( grep "Lost dmusrcmd connection" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then
785    #    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
786    #    echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
787    #    sleep 30
788    #    echo "We try another time"
789    ##    dmget ${dm_liste[*]} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
790    #    ccc_hsm get ${dm_liste[*]} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
791    #    status=$?
792    #    if [ ${status} -gt 0 ] ; then
793    #      echo "ERROR IGCM_sys_Get : again demigration error :"
794    #      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
795    #      IGCM_debug_Exit "IGCM_sys_Get"
796    #    fi
797    #  else
798    #    echo "ERROR IGCM_sys_Get : demigration error :"
799    #    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
800    #    IGCM_debug_Exit "IGCM_sys_Get"
801    #  fi
802    #fi
803
804    #   #RSYNC WITH NETWORK SSH CALL
805    #   echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
806    #   ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
807
808    #   #RSYNC WITH NFS USE
809    #   echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
810    #   ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
811
812    #   status=$?
813    #   IGCM_sys_Rsync_out $status
814
815    #   ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
816    #   (( status=status+$? ))
817
818    #USUAL WAY
819    if [ X${1} = X'/l' ] ; then
820      for target in ${dm_liste[*]} ; do
821        local_file=$( basename ${target} )
822        # test if the target file is present before the loop
823        IGCM_sys_TestFileArchive ${target}
824        status=$?
825        if [ ${status} -gt 0 ] ; then
826          echo "IGCM_sys_Get, ERROR : regular file ${target} DOES NOT EXIST ."
827          IGCM_debug_Exit "IGCM_sys_Get"
828        else
829          i=0
830          while [ $i -lt $NB_ESSAI ] ; do
831            #if [ X${DoLink} = Xtrue ] ; then
832            #  \ln -s ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
833            #  status=$?
834            #  else
835            #  \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
836            #  status=$?
837            #fi
838            \ln -s ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
839            status=$?
840            if [ ${status} -gt 0 ]; then
841              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}"
842              IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
843              sleep $DELAI
844            else
845              break
846            fi
847            (( i = i + 1 ))
848          done
849          if [ ${status} -gt 0 ] ; then
850            echo "IGCM_sys_Get : error"
851            cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
852            \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
853            IGCM_debug_Exit "IGCM_sys_Get"
854          else
855            \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
856          fi
857        fi
858      done
859    else
860      i=0
861      while [ $i -lt $NB_ESSAI ] ; do
862        \cp ${dm_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
863        status=$?
864        if [ ${status} -gt 0 ]; then
865          IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}"
866          IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
867          sleep $DELAI
868        else
869          break
870        fi
871        (( i = i + 1 ))
872      done
873      if [ ${status} -gt 0 ] ; then
874        echo "IGCM_sys_Get : error"
875        cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
876        \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
877        IGCM_debug_Exit "IGCM_sys_Get"
878      else
879        \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
880      fi
881    fi
882  fi
883  IGCM_debug_PopStack "IGCM_sys_Get"
884}
885
886#D-#==================================================
887#D-function IGCM_sys_GetDate_Monitoring
888#D-* Purpose: get the last year for which the monitoring has been computed
889#D-* Examples:
890#D-
891function IGCM_sys_GetDate_Monitoring {
892  IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@
893  if ( $DEBUG_sys ) ; then
894    echo "IGCM_sys_GetDate_Monitoring :" $@
895  fi
896
897  eval ${2}=$( cdo showyear ${1} 2> /dev/null | gawk '{ print $NF }' )
898
899  IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring"
900}
901
902#D-#==================================================
903#D-function IGCM_sys_Dods_Rm
904#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
905#D-* Examples:
906#D-
907function IGCM_sys_Dods_Rm {
908  if ( $DEBUG_sys ) ; then
909    echo "IGCM_sys_Dods_Rm :" $@
910  fi
911  typeset status
912  if [ $DRYRUN = 0 ]; then
913
914#    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
915#      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
916#      echo "Nothing has been done."
917#      return
918#    fi
919
920    if [ "$#" -eq 1 ]; then
921      ## /ccc/cont003/home/igcmg/igcmg/Tools/irene/thredds_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
922      $(ccc_home -u igcmg)/Tools/irene/thredds_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
923      status=$?
924    else
925      ## /ccc/cont003/home/igcmg/igcmg/Tools/irene/thredds_rm public/${LOGIN}/${R_DODS} # > out_dods_rm 2>&1
926      $(ccc_home -u igcmg)/Tools/irene/thredds_rm public/${LOGIN}/${R_DODS} # > out_dods_rm 2>&1
927      status=$?
928    fi
929
930#    if [ ${status} -gt 0 ] ; then
931#      echo "IGCM_sys_Dods_Rm : error."
932#      cat out_dods_rm
933#      IGCM_debug_Exit "IGCM_sys_Dods_Rm"
934#    else
935#      rm out_dods_rm
936#    fi
937
938  fi
939  return $status
940}
941
942#D-#==================================================
943#D-function IGCM_sys_Dods_Cp
944#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
945#D-* Examples:
946#D-
947function IGCM_sys_Dods_Cp {
948  if ( $DEBUG_sys ) ; then
949    echo "IGCM_sys_Dods_Cp :" $@
950  fi
951  typeset status
952  if [ $DRYRUN = 0 ]; then
953
954#    if [ ! -d ${R_SAVE}/${1} ] ; then
955#      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
956#      echo "Nothing has been done."
957#      return
958#    fi
959
960    ## /ccc/cont003/home/igcmg/igcmg/Tools/irene/bin/thredds_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
961    $(ccc_home -u igcmg)/Tools/irene/thredds_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
962    status=$?
963
964#       if [ ${status} -gt 0 ] ; then
965#           echo "IGCM_sys_Dods_Cp : error."
966#           cat out_dods_cp
967#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
968#       else
969#           rm out_dods_cp
970#       fi
971
972  fi
973  return $status
974}
975
976#D-#==================================================
977#D-function IGCM_sys_Put_Dods
978#D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole.
979#D-* Examples:
980#D-
981function IGCM_sys_Put_Dods {
982  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
983  if ( $DEBUG_sys ) ; then
984    echo "IGCM_sys_Put_Dods :" $@
985  fi
986  typeset status
987  if [ $DRYRUN = 0 ]; then
988    if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
989      echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should."
990      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST."
991      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST."
992      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
993      return
994    fi
995
996    if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then
997      echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should."
998      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS."
999      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS."
1000      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1001      return
1002    fi
1003    #
1004    if [ -d ${R_SAVE}/${1} ] ; then
1005      cd ${R_SAVE}
1006    elif [ -d ${R_FIGR}/${1} ] ; then
1007      cd ${R_FIGR}
1008    fi
1009
1010    IGCM_sys_Dods_Rm ${1}
1011    IGCM_sys_Dods_Cp ${1}
1012    status=0
1013
1014    if [ ${status} -gt 0 ] ; then
1015      echo "IGCM_sys_Put_Dods : error."
1016      IGCM_debug_Exit "IGCM_sys_Put_Dods"
1017    fi
1018  fi
1019  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1020}
1021
1022##############################################################
1023# REBUILD OPERATOR
1024
1025#D-#==================================================
1026#D-function IGCM_sys_sync
1027#D-* Purpose: flush buffer on disk
1028#D-* Examples:
1029#D-
1030function IGCM_sys_sync {
1031  IGCM_debug_PushStack "IGCM_sys_sync" $@
1032  if ( $DEBUG_sys ) ; then
1033    echo "IGCM_sys_sync :" $@
1034  fi
1035
1036  /bin/sync
1037
1038  IGCM_debug_PopStack "IGCM_sys_sync"
1039}
1040
1041############################################################
1042# Activate Running Environnment Variables
1043
1044#D-#==================================================
1045#D-function IGCM_sys_activ_variables
1046#D-* Purpose: set environement variables prior to execution
1047#D-* Examples:
1048#D-
1049function IGCM_sys_activ_variables {
1050  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1051  if ( $DEBUG_sys ) ; then
1052    echo "IGCM_sys_activ_variables"
1053  fi
1054
1055# --------------------------------------------------------------------
1056#D- MODULE specifications
1057# --------------------------------------------------------------------
1058  # Source the file EnvFile containing all module load needed to run the model.
1059  # EnvFile can be specified in config.card. If this is the case and if the file exists,
1060  # it will be used. Otherwise a default file will be used.
1061  if [ ! X${config_UserChoices_EnvFile} = X ] && [ -f ${config_UserChoices_EnvFile} ] ; then
1062      # EnvFile is set in config.card and the file exists
1063      IGCM_debug_Print 1 "EnvFile set in config.card will be used"
1064      EnvFile=${config_UserChoices_EnvFile}
1065  else
1066      IGCM_debug_Print 1 "IGCM_sys_active_variables : Default modules will be used"
1067      module purge > /dev/null 2>&1
1068      EnvFile=/gpfswork/rech/psl/commun/MachineEnvironment/jeanzay/env_jeanzay
1069  fi
1070  IGCM_debug_Print 1 "IGCM_sys_active_variables : Following EnvFile will be used :" 
1071  IGCM_debug_Print 1 ${EnvFile}
1072  . ${EnvFile}
1073
1074  IGCM_debug_Print 1 "IGCM_sys_active_variables : Now loaded modules for Jean-Zay. "
1075  module list
1076
1077# --------------------------------------------------------------------
1078#D- MPI specifications
1079# --------------------------------------------------------------------
1080
1081# --------------------------------------------------------------------
1082#D- Other specifications
1083# --------------------------------------------------------------------
1084
1085  ulimit -s unlimited
1086
1087  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1088}
1089
1090############################################################
1091# Desactivate Running Environnment Variables
1092
1093#D-#==================================================
1094#D-function IGCM_sys_desactiv_variables
1095#D-* Purpose: unset environement variables after execution
1096#D-* Examples:
1097#D-
1098function IGCM_sys_desactiv_variables {
1099  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1100  if ( $DEBUG_sys ) ; then
1101    echo "IGCM_sys_desactiv_variables"
1102  fi
1103# --------------------------------------------------------------------
1104#D- MPI specifications
1105# --------------------------------------------------------------------
1106
1107# --------------------------------------------------------------------
1108#D- Other specifications
1109# --------------------------------------------------------------------
1110
1111  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1112}
1113
1114############################################################
1115# Update job headers to be used by the scheduler
1116
1117#D-#==================================================
1118#D-function IGCM_sys_updateHeaders
1119#D-* Purpose: Update job headers to be used by the scheduler
1120#D-* Examples: IGCM_sys_updateHeaders /path/to/Job_MYEXP
1121#D-
1122function IGCM_sys_updateHeaders {
1123  IGCM_debug_PushStack "IGCM_sys_updateHeaders"
1124  if ( $DEBUG_sys ) ; then
1125    echo "IGCM_sys_updateHeaders"
1126  fi
1127  typeset file
1128  file=$1
1129
1130  if [ ${executionType} -eq 1 ] ; then
1131    # MPMD + MPI
1132    sed -e "/::openMPthreads::/d"                  \
1133        -e "s/::JobNumProcTot::/${coreNumber}/"    \
1134      ${file} > ${file}.tmp
1135
1136  elif [ ${executionType} -eq 2 ] ; then
1137    # MPMD + MPI + OMP
1138      sed -e "s/::openMPthreads::/${openMPthreads}/" \
1139          -e "s/::JobNumProcTot::/${mpiTasks}/"    \
1140          ${file} > ${file}.tmp
1141
1142  elif [ ${executionType} -eq 3 ] ; then
1143    # SPMD + MPI/OMP
1144    sed -e "s/::openMPthreads::/${openMPthreads}/" \
1145        -e "s/::JobNumProcTot::/${mpiTasks}/"      \
1146      ${file} > ${file}.tmp
1147
1148  elif [ ${executionType} -eq 4 ] ; then
1149    # SPMD + MPI only
1150    sed -e "s/::JobNumProcTot::/${mpiTasks}/"      \
1151        -e "/::openMPthreads::/d"                  \
1152      ${file} > ${file}.tmp
1153
1154  elif [ ${executionType} -eq 5 ] ; then
1155    # SPMD + OMP only
1156    sed -e "s/::openMPthreads::/${openMPthreads}/" \
1157        -e "/::JobNumProcTot::/d"                  \
1158      ${file} > ${file}.tmp
1159
1160  elif [ ${executionType} -eq 6 ] ; then
1161    # SEQUENTIAL THEN
1162    sed -e "s/::JobNumProcTot::/1/"                \
1163        -e "/::openMPthreads::/d"                  \
1164      ${file} > ${file}.tmp
1165
1166  fi
1167
1168  IGCM_sys_Mv ${file}.tmp ${file}
1169
1170  IGCM_debug_PopStack "IGCM_sys_updateHeaders"
1171}
1172
1173############################################################
1174# Build MPI/OMP scripts run file (dummy function)
1175
1176#D-#==================================================
1177#D-function IGCM_sys_build_run_file
1178#D-* Purpose: build run file (deprecated)
1179#D-* Examples:
1180#D-
1181function IGCM_sys_build_run_file {
1182  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1183}
1184
1185############################################################
1186# Build MPI/OMP scripts
1187
1188#D-#==================================================
1189#D-function IGCM_sys_build_execution_scripts
1190#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
1191#D-* Examples:
1192#D-
1193function IGCM_sys_build_execution_scripts
1194{
1195  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1196  if ( $DEBUG_sys ) ; then
1197    echo "IGCM_sys_build_execution_scripts " $@
1198  fi
1199  IGCM_debug_Print 1 "executionType= ${executionType}"
1200  EXECUTION=${HOST_MPIRUN_COMMAND}
1201
1202  if ( ${OK_PARA_MPMD} ) ; then
1203
1204    # MPMD mode
1205    # 1 MPI only : executionType=1
1206    # 2 MPI/OpenMP : executionType=2
1207
1208    if [ -f run_file ] ; then
1209      IGCM_sys_Rm -f run_file
1210    fi
1211    touch run_file
1212
1213    # case 1 : Only MPI (MPMD)
1214    if  ( ! ${OK_PARA_OMP} ) ; then
1215      # Build run_file
1216      current_core=0
1217      # First loop on the components for the coupler ie oasis (only if oasis3)
1218      # the coupler ie oasis3 must be the first one
1219      for comp in ${config_ListOfComponents[*]} ; do
1220
1221        eval ExeNameIn=\${config_Executable_${comp}[0]}
1222        eval ExeNameOut=\${config_Executable_${comp}[1]}
1223
1224        # Only if the component has an executable
1225        if ( [ "X${ExeNameOut}" != X\"\" ] ) ; then
1226
1227          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1228          (( end_core = ${current_core} + ${comp_proc_mpi_loc} - 1 ))
1229          echo "${current_core}-${end_core} ./${ExeNameOut}" >> run_file
1230          (( current_core = ${end_core} + 1 ))
1231        fi
1232      done
1233
1234      EXECUTION="${HOST_MPIRUN_COMMAND} --multi-prog ./run_file"
1235
1236      IGCM_sys_Chmod u+x run_file
1237      if ( $DEBUG_sys ) ; then
1238        echo "run_file contains : "
1239        cat run_file
1240      fi
1241
1242    else 
1243
1244    # 2 MPI/OpenMP : executionType=2
1245
1246    # MPI-OpenMP (MPMD)
1247    # example of run_file
1248    # 0-70   env OMP_NUM_THREADS=8 ./script_lmdz.x.ksh
1249    # 71-71  env OMP_NUM_THREADS=1 ./script_xios.x.ksh
1250
1251      # Loop on the components to build run_file and script_exec files
1252      current_core=0
1253      for comp in ${config_ListOfComponents[*]} ; do
1254
1255        eval ExeNameIn=\${config_Executable_${comp}[0]}
1256        eval ExeNameOut=\${config_Executable_${comp}[1]}
1257
1258        # Not possible if oasis has an executable (i.e old version of oasis3)
1259        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" = "XCPL" ] ) ; then
1260          IGCM_debug_Exit "ERROR MPMD with hybrid MPI-OpenMP is not available with oasis3 version"
1261          IGCM_debug_Print 2 "Only available with oasis3-MCT version coupler"
1262          IGCM_debug_Verif_Exit
1263        fi
1264
1265        # Only if we really have an executable for the component :
1266        if [ "X${ExeNameOut}" != X\"\" ] ; then
1267
1268          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1269          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1270
1271          # Build script files
1272
1273          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1274          echo ""  >> script_${ExeNameOut}.ksh
1275          if [ ${comp_proc_omp_loc} -gt 1 ] ; then
1276            echo "export OMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1277            echo "export OMP_PLACES=cores"  >> script_${ExeNameOut}.ksh
1278          fi
1279
1280          # to have out/err per process on different files
1281          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${SLURM_PROCID} 2>out_${ExeNameOut}.err.\${SLURM_PROCID}" >> script_${ExeNameOut}.ksh
1282
1283          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1284
1285          # Complete run_file
1286          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1287          (( end_core = ${current_core} + ${comp_proc_mpi_loc} - 1 ))
1288          echo "${current_core}-${end_core}  env OMP_NUM_THREADS=${comp_proc_omp_loc} ./script_${ExeNameOut}.ksh " >> run_file
1289          (( current_core = ${end_core} + 1 ))
1290
1291        fi
1292      done
1293
1294      ## variable added to stop after 60s instead of 600s by default.
1295      ## This is used when no error comes from executables and when something stopped an executable without notice.
1296      export SLURM_WAIT=60
1297
1298      EXECUTION="${HOST_MPIRUN_COMMAND} --multi-prog ./run_file"
1299
1300      IGCM_sys_Chmod u+x run_file
1301      if ( $DEBUG_sys ) ; then
1302        echo "run_file contains : "
1303        cat run_file
1304      fi
1305
1306    fi # if ${OK_PARA_MPMD}
1307
1308  else
1309  # Only one executable (SPMD mode):  executionType=3, 4, 5 and 6
1310
1311    for comp in ${config_ListOfComponents[*]} ; do
1312
1313      # Only if we really have an executable for the component :
1314      eval ExeNameOut=\${config_Executable_${comp}[1]}
1315      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
1316
1317        # Build script files
1318
1319        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1320        echo ""  >> script_${ExeNameOut}.ksh
1321        IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1322
1323        if ( ${OK_PARA_OMP} ) ; then
1324          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1325          echo ""  >> script_${ExeNameOut}.ksh
1326          echo "export OMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1327          echo "export OMP_PLACES=cores"  >> script_${ExeNameOut}.ksh
1328          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1329        fi
1330
1331        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1332       
1333        # To have out/err per process on different files
1334        echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${SLURM_PROCID} 2>out_${ExeNameOut}.err.\${SLURM_PROCID}"  >> script_${ExeNameOut}.ksh
1335        EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh"
1336
1337        IGCM_debug_Print 1 "sys Irene : script_${ExeNameOut}.ksh contains"
1338        cat script_${ExeNameOut}.ksh
1339
1340      fi
1341
1342    done
1343
1344  fi # ${OK_PARA_MPMD}
1345
1346  IGCM_debug_Print 1 "sys Irene : execution command is "
1347  IGCM_debug_Print 1 "$EXECUTION"
1348
1349  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1350}
1351
1352#D-#==================================================
1353#D-function IGCM_sys_check_path
1354#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
1355#D-* do not point to an important use directory. Stop immediately in that case.
1356#D-* Examples:
1357#D-
1358function IGCM_sys_check_path {
1359  IGCM_debug_PushStack "IGCM_sys_check_path"
1360  if ( $DEBUG_sys ) ; then
1361    echo "IGCM_sys_check_path"
1362  fi
1363
1364  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORK} ] || [ X${RUN_DIR_PATH} = X${SCRATCH} ] || [ X${RUN_DIR_PATH} = X${STORE} ] ) ; then
1365    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
1366    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
1367    IGCM_debug_Exit "This will stop the job"
1368  fi
1369  IGCM_debug_PopStack "IGCM_sys_check_path"
1370}
1371
1372#D-#==================================================
1373#D-function IGCM_sys_check_quota
1374#D-* Purpose: check user quota. Stop the simulation if quota above 90%
1375#D-* Examples:
1376#D-
1377function IGCM_sys_check_quota {
1378  IGCM_debug_PushStack "IGCM_sys_check_quota"
1379  if ( $DEBUG_sys ) ; then
1380    echo "IGCM_sys_check_quota"
1381  fi
1382  # Limit of quota (in %)
1383  limit_quota=90
1384
1385  # Check of the volume
1386  volume_quota=$(ccc_quota | grep ' scratch' | gawk '{print $2}')
1387  volume_avail=$(ccc_quota | grep ' scratch' | gawk '{print $3}')
1388
1389  if ( [ ! X${volume_quota} = X ] && [ ! ${volume_quota} = "-" ] ) ; then
1390
1391    unit_avail=${volume_avail: -1}
1392    unit_quota=${volume_quota: -1}
1393
1394    if [ "${unit_quota}" = "*" ] ; then
1395      IGCM_debug_Print 1 "Please, check your quota of volume on scratch"
1396      IGCM_debug_Print 1 "More than 100% of your quota is used"
1397      IGCM_debug_Print 1 "Use the ccc_quota command to check"
1398      IGCM_debug_Print 1 "You must have more than 10% available to run"
1399      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1400      IGCM_debug_Verif_Exit
1401    fi
1402
1403    temp_avail=${volume_avail%%${volume_avail: -1}*}
1404    temp_quota=${volume_quota%%${volume_quota: -1}*}
1405
1406    if [ ! ${unit_avail} = ${unit_quota} ] ; then
1407
1408    # Convertion
1409      if [ ${volume_avail: -1} = "T" ] ; then
1410        (( temp_avail = temp_avail * 1000000000000 ))
1411      elif [ ${volume_avail: -1} = "G" ] ; then
1412        (( temp_avail = temp_avail * 1000000000 ))
1413      elif [ ${volume_avail: -1} = "M" ] ; then
1414        (( temp_avail = temp_avail * 1000000 ))
1415      elif [ ${volume_avail: -1} = "k" ] ; then
1416        (( temp_avail = temp_avail * 1000 ))
1417      else
1418        (( temp_avail = volume_avail ))
1419      fi
1420      if [ ${volume_quota: -1} = "T" ] ; then
1421        (( temp_quota = temp_quota * 1000000000000 ))
1422      elif [ ${volume_quota: -1} = "G" ] ; then
1423        (( temp_quota = temp_quota * 1000000000 ))
1424      elif [ ${volume_quota: -1} = "M" ] ; then
1425        (( temp_quota = temp_quota * 1000000 ))
1426      elif [ ${volume_quota: -1} = "k" ] ; then
1427        (( temp_quota = temp_quota * 1000 ))
1428      else
1429        (( temp_quota = volume_quota ))
1430      fi
1431    fi
1432
1433    quota_volume=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc)
1434#    echo "volume ratio is " $quota_volume
1435
1436    if [ ${quota_volume} -ge ${limit_quota} ] ; then
1437      IGCM_debug_Print 1 "Please, check your quota of volume on scratch"
1438      IGCM_debug_Print 1 "${quota_volume}% of your quota is used"
1439      IGCM_debug_Print 1 "Use the ccc_quota command to check"
1440      IGCM_debug_Print 1 "You must have more than 10% available to run"
1441      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1442      IGCM_debug_Verif_Exit
1443    fi
1444
1445  fi
1446
1447# Check of the number of inodes
1448
1449  inode_quota=$(ccc_quota | grep ' scratch' | gawk '{print $6}')
1450  inode_avail=$(ccc_quota | grep ' scratch' | gawk '{print $7}')
1451
1452  if ( [ ! X${inode_quota} = X ] && [ ! ${inode_quota} = "-" ] ) ; then
1453
1454    unit_avail=${inode_avail: -1}
1455    unit_quota=${inode_quota: -1}
1456
1457    if [ "${unit_quota}" = "*" ] ; then
1458      IGCM_debug_Print 1 "Please, check your quota of inode on scratch"
1459      IGCM_debug_Print 1 "More than 100% of your quota is used"
1460      IGCM_debug_Print 1 "Use the ccc_quota command to check"
1461      IGCM_debug_Print 1 "You must have more than 10% available to run"
1462      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1463      IGCM_debug_Verif_Exit
1464    fi
1465
1466    temp_avail=${inode_avail%%${inode_avail: -1}*}
1467    temp_quota=${inode_quota%%${inode_quota: -1}*}
1468
1469    if [ ! ${unit_avail} = ${unit_quota} ] ; then
1470
1471    # Convertion
1472      if [ ${inode_avail: -1} = "T" ] ; then
1473        (( temp_avail = temp_avail * 1000000000000 ))
1474      elif [ ${inode_avail: -1} = "G" ] ; then
1475        (( temp_avail = temp_avail * 1000000000 ))
1476      elif [ ${inode_avail: -1} = "M" ] ; then
1477        (( temp_avail = temp_avail * 1000000 ))
1478      elif [ ${inode_avail: -1} = "k" ] ; then
1479        (( temp_avail = temp_avail * 1000 ))
1480      else
1481        (( temp_avail = inode_avail ))
1482      fi
1483
1484      if [ ${inode_quota: -1} = "T" ] ; then
1485        (( temp_quota = temp_quota * 1000000000000 ))
1486      elif [ ${inode_quota: -1} = "G" ] ; then
1487        (( temp_quota = temp_quota * 1000000000 ))
1488      elif [ ${inode_quota: -1} = "M" ] ; then
1489        (( temp_quota = temp_quota * 1000000 ))
1490      elif [ ${inode_quota: -1} = "k" ] ; then
1491        (( temp_quota = temp_quota * 1000 ))
1492      else
1493        (( temp_quota = inode_quota ))
1494      fi
1495    fi
1496    quota_inode=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc)
1497#    echo "inode ratio is " $quota_inode
1498
1499    if [ ${quota_inode} -ge ${limit_quota} ] ; then
1500      IGCM_debug_Print 1 "Please, check your quota of inode on scratch"
1501      IGCM_debug_Print 1 "${quota_inode}% of your quota is used"
1502      IGCM_debug_Print 1 "Use the ccc_quota command to check"
1503      IGCM_debug_Print 1 "You must have more than 10% available to run"
1504      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1505      IGCM_debug_Verif_Exit
1506    fi
1507  fi
1508  IGCM_debug_PopStack "IGCM_sys_check_quota"
1509}
1510
1511#D-#==================================================
1512#D-function IGCM_sys_projectAccounting
1513#D-* Purpose: store project accounting information in a file
1514#D-* Examples:
1515#D-
1516function IGCM_sys_projectAccounting {
1517  IGCM_debug_PushStack "IGCM_sys_projectAccounting"
1518  if ( $DEBUG_sys ) ; then
1519    echo "IGCM_sys_check_quota"
1520  fi
1521
1522  ssh irene191 /usr/bin/ccc_myproject > $1
1523
1524  IGCM_debug_PopStack "IGCM_sys_projectAccounting"
1525}
1526
1527#D-#==================================================
1528#D-function IGCM_sys_getJobSchedulerID
1529#D-* Purpose: Get the job ID during execution
1530#D-* Examples: IGCM_sys_getJobSchedulerID jobSchedulerID
1531#D-
1532function IGCM_sys_getJobSchedulerID {
1533  IGCM_debug_PushStack "IGCM_sys_getJobSchedulerID"
1534  if ( $DEBUG_sys ) ; then
1535    echo "IGCM_sys_getJobSchedulerID"
1536  fi
1537
1538  eval ${1}=${BRIDGE_MSUB_JOBID}
1539
1540  IGCM_debug_PopStack "IGCM_sys_getJobSchedulerID"
1541}
1542
1543#D-#==================================================
1544#D-function IGCM_sys_GetJobID
1545#D-* Purpose: Get the job ID from the JobName
1546#D-* Examples: IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID
1547#D-
1548function IGCM_sys_GetJobID {
1549  IGCM_debug_PushStack "IGCM_sys_GetJobID"
1550  if ( $DEBUG_sys ) ; then
1551    echo "IGCM_sys_GetJobID"
1552  fi
1553
1554  # With -f option, the full job name is given in the last column
1555  ID=$( ccc_mstat -f -u $2 | \
1556        gawk -v JobName=$1 '( $NF ~ JobName ) { print $1 }' )
1557
1558  eval ${3}=${ID}
1559  IGCM_debug_PopStack "IGCM_sys_GetJobID"
1560}
1561
1562#D-#==================================================
1563#D-function IGCM_sys_CountJobInQueue
1564#D-* Purpose: Count number of users job
1565#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
1566#D-
1567function IGCM_sys_CountJobInQueue {
1568  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
1569  if ( $DEBUG_sys ) ; then
1570    echo "IGCM_sys_CountJobInQueue"
1571  fi
1572
1573  # With -f option, the full job name is given in the last column
1574  NbRun=$( ccc_mstat -f | gawk -v JobName=$1 'BEGIN { x=0 } ( $NF ~ JobName ) { x=x+1 } END { print x }' )
1575
1576  eval ${2}=${NbRun}
1577
1578  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
1579}
1580
1581#D-#==================================================
1582#D-function IGCM_sys_ListJobInQueue
1583#D-* Purpose: Produce a list of users computing jobs (excluding post-processing)
1584#D-* Examples: IGCM_sys_ListJobInQueue ${User} JobNameList
1585#D-
1586function IGCM_sys_ListJobInQueue {
1587  IGCM_debug_PushStack "IGCM_sys_ListJobInQueue"
1588  if ( $DEBUG_sys ) ; then
1589    echo "IGCM_sys_ListJobInQueue"
1590  fi
1591
1592  # With -f option, the full job name is given in the last column
1593  set -A JobList $( ccc_mstat -f | gawk -v User=$1             \
1594                                        '( $2  == User      && \
1595                                           $NF != /TS/      && \
1596                                           $NF !~ /PACK/    && \
1597                                           $NF !~ /REBUILD/ && \
1598                                           $NF !~ /pack/ )     \
1599                                         { print $NF }' | sed -e "s/\(.*\)\.[0-9]*/\1/" )
1600
1601  eval set -A ${2} ${JobList[*]}
1602
1603  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue"
1604}
1605
1606#D-#==================================================
1607#D-function IGCM_sys_atlas
1608#D-* Purpose: encapsulate atlas call so as to manage error code and curie specificity
1609#D-* Examples:
1610#D-
1611function IGCM_sys_atlas {
1612  IGCM_debug_PushStack "IGCM_sys_atlas" $@
1613  if ( $DEBUG_sys ) ; then
1614    echo "IGCM_sys_atlas :" $@
1615  fi
1616
1617  typeset status
1618
1619  \ccc_mprun atlas $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
1620  status=$?
1621  if [ ${status} -gt 0 ] ; then
1622    echo "IGCM_sys_atlas : error code ${status}"
1623    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
1624    \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
1625    IGCM_debug_PopStack "IGCM_sys_atlas"
1626    return 1
1627  else
1628    IGCM_debug_PopStack "IGCM_sys_atlas"
1629    return 0
1630  fi
1631
1632  IGCM_debug_PopStack "IGCM_sys_atlas"
1633}
1634
1635#D-#==================================================
1636#D-function IGCM_sys_rebuild_nemo
1637#D-* Purpose: rebuild nemo parallel files with nemo specific rebuild on curie
1638#D-* Examples:
1639#D-
1640
1641function IGCM_sys_rebuild_nemo {
1642  IGCM_debug_PushStack "IGCM_sys_rebuild_nemo" $@
1643  if ( $DEBUG_sys ) ; then
1644    echo "IGCM_sys_rebuild_nemo :" $@
1645  fi
1646
1647  /gpfswork/rech/psl/commun/Tools/rebuild_nemo/bin/rebuild_nemo ${1} ${2}
1648
1649  IGCM_debug_PopStack "IGCM_sys_rebuild_nemo"
1650}
1651
Note: See TracBrowser for help on using the repository browser.