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

Last change on this file since 1404 was 1380, checked in by mafoipsl, 7 years ago

Add a function IGCM_sys_rebuild_nemo. On curie call $( ccc_home -u p86ipsl )/REBUILD_NEMO/rebuild_nemo. On other system call rebuild as usual. See also ticket #320.

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