source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh @ 1572

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