source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh @ 1196

Last change on this file since 1196 was 1196, checked in by sdipsl, 9 years ago
  • Fix a typo
  • 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: 51.1 KB
RevLine 
[622]1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip, Arnaud Caubel
5# Contact: Arnaud.Caubel__at__lsce.ipsl.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#=========================================================
15# The documentation of this file can be automatically generated
[623]16# if you use the prefix #D- for comments to be extracted.
[622]17# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
18#=========================================================
19
20#D-#==================================================
[623]21#D-LibIGCM_sys for Curie
[622]22#D-#==================================================
23#D-
[623]24#D- This ksh library if a layer under some usefull
[622]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 |
[809]45# |          |  Cp/Exe/param/files |            |         |                           |
46# |          |  Chmod Qsub         |            |         |                           |
[622]47# -------------------------------------------------------------------------------------
48# |    0     |       yes           |    yes     |  yes    |      yes                  |
49# -------------------------------------------------------------------------------------
50# |    1     |       yes           |    yes     |  yes    |      no                   |
51# -------------------------------------------------------------------------------------
52# |    2     |       yes           |    yes     |  no     |      no                   |
53# -------------------------------------------------------------------------------------
54# |    3     |       yes           |    no      |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56
57#=====================================================
58# Global Variables :
59#=====================================================
60# Language : "fr" or "en"
61typeset -r MYLANG="fr"
62
63#=====================================================
64# Host and user names
65# $hostname ou hostname
[1158]66typeset HOST=${HOST:=$( hostname )}
[622]67# $username ou whoami
[1158]68typeset LOGIN=${LOGIN:=$( whoami )}
[622]69# $hostname of the MASTER job
70typeset MASTER=curie
[880]71# add default project on curie
[900]72typeset DEFAULT_PROJECT=gen0826
[622]73
74#D-
75#D-#==================================================
76#D-Program used in libIGCM
77#D-#==================================================
78
[742]79# Submit command
[747]80typeset SUBMIT=${SUBMIT:=ccc_msub}
[622]81# rsync with path
82typeset -r RSYNC=/usr/bin/rsync
83# RSYNC_opt args to rsync
84typeset -r RSYNC_opt="-va"
85# ie storage filesystem
[623]86typeset -r STOREHOST=${MASTER}
[1180]87typeset -r REMOTE_RSYNC=/usr/bin/rsync
[622]88
89#====================================================
[1180]90# Set environment tools (ferret, nco, cdo, rebuild, ...)
[622]91#====================================================
[996]92if [ X${TaskType} = Xcomputing ] ; then
[1193]93  . /ccc/cont003/home/dsm/p86ipsl/.atlas_env_netcdf4.3.3.1_hdf5_parallel_curie_ksh > /dev/null 2>&1
[996]94# to run with netcdf 3.6.3 ie compilation done before 17/2/2014
95# uncomment 2 lines :
96#  module unload netcdf
97#  module load netcdf/3.6.3
98else
[1196]99  . /ccc/cont003/home/dsm/p86ipsl/.atlas_env_netcdf4.3.3.1_hdf5_parallel_curie_ksh > /dev/null 2>&1
[1166]100  PCMDI_MP=/ccc/work/cont003/dsm/p86ipsl/PCMDI-MP
[996]101fi
[1179]102export PATH=${PATH}:/ccc/cont003/home/dsm/p86ipsl/AddNoise/src_X64_CURIE/bin
103export PATH=${PATH}:/ccc/cont003/home/dsm/p86ipsl/AddPerturbation/src_X64_CURIE/bin
104export PATH=${PATH}:$( ccc_home -u p86ipsl )/rebuild/src_X64_CURIE/modipsl_v2_2_2_netcdf4.2/bin/
[622]105
106#====================================================
107# Specific for ocean additionnal diagnostic
108export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO"
109export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET"
110
111#====================================================
112# Host specific DIRECTORIES
113#====================================================
114
[623]115# ============ CESIUM START ============ #
116
[622]117#====================================================
[623]118#- Mirror libIGCM from titane to cesium if needed
119#ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $3}' )
120#if [ ! ${ROOTSYS} = "home" ] ; then
121#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true}
122#else
123#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
124#fi
125
126#====================================================
127#- libIGCM_POST
128#if ( ${MirrorlibIGCM} ) ; then
129#  PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" )
130#  typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM
131#else
132#  typeset -r libIGCM_POST=${libIGCM}
133#fi
134
135# ============ CESIUM  END  ============ #
136
137#====================================================
138#- MirrorlibIGCM for frontend
139typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
140
141#====================================================
142#- libIGCM_POST for frontend
143typeset -r libIGCM_POST=${libIGCM}
144
145#====================================================
[622]146#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
147typeset -r R_EXE="${MODIPSL}/bin"
148
149#====================================================
150#- SUBMIT_DIR : submission dir
[1010]151typeset -x SUBMIT_DIR=${SUBMIT_DIR:=${BRIDGE_MSUB_PWD}}
[622]152
153#====================================================
154#- IN
155typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM}
156typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/ccc/work/cont003/dsm/p24data}
157
158#====================================================
159#- RUN_DIR_PATH : Temporary working directory (=> TMP)
[850]160typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${BRIDGE_MSUB_JOBID}_${$}}
[622]161
162#====================================================
[1179]163#- OUTCOMMAND_PATH : tmp place to store command lines standard error and outputs
[1186]164typeset -r OUTCOMMAND_PATH=/tmp
[1179]165
166#====================================================
[622]167#- HOST_MPIRUN_COMMAND
[808]168typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time ccc_mprun -E-K1"}
[622]169
170#====================================================
171#- Max number of arguments passed to nco operator or demigration command
172UNIX_MAX_LIMIT=360
173
[623]174#====================================================
[1180]175#- set PackDefault to true on curie
[623]176PackDefault=true
177
[664]178#====================================================
179#- Number of core per node (max number of OpenMP task)
[622]180NUM_COREPERNODE=8
181
[623]182#====================================================
183#- Default number of MPI task for IPSL coupled model
184#- required for backward compatibility
185#-
186DEFAULT_NUM_PROC_OCE=5
187DEFAULT_NUM_PROC_CPL=1
[637]188(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
189DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
[623]190
[725]191#D-#==================================================
[1057]192#D-function IGCM_sys_defineArchives
193#D-* Purpose:
194#D-* Define ARCHIVE : Dedicated to large files
195#D-* Define STORAGE : Dedicated to small/medium files
196#D-* Define R_OUT   : Output tree located on ARCHIVE
197#D-* Define R_FIG   : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files)
198#D-* Define R_BUF   : Output tree located on SCRATCHDIR hosting files waiting for rebuild or pack processes
199#D-* if SpaceName=TEST everything is stored on SCRATCHDIR
[725]200#D-* Examples:
201#D-
[1057]202function IGCM_sys_defineArchives {
203  IGCM_debug_PushStack "IGCM_sys_defineArchives"
[676]204
[1060]205  if [ ! X${config_UserChoices_ARCHIVE} = X ]; then
[1057]206    #====================================================
207    #- ARCHIVE (dedicated to large files)
[1063]208    ARCHIVE=${config_UserChoices_ARCHIVE}
[1057]209  else
210    #====================================================
211    #- ARCHIVE (dedicated to large files)
[1063]212    ARCHIVE=${CCCSTOREDIR}
[1057]213  fi
[725]214
[1060]215  if [ ! X${config_UserChoices_STORAGE} = X ]; then
[1057]216    #====================================================
217    #- STORAGE (dedicated to small/medium files)
[1063]218    STORAGE=${config_UserChoices_STORAGE}
[1057]219  else
220    #====================================================
221    #- STORAGE (dedicated to small/medium files)
[1063]222    STORAGE=${CCCWORKDIR}
[1057]223  fi
[725]224
[1057]225  if [ X${config_UserChoices_SpaceName} = XTEST ]; then
226    #====================================================
227    #- R_OUT
[1063]228    R_OUT=${SCRATCHDIR}/IGCM_OUT
[1057]229
230    #====================================================
231    #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
[1063]232    R_FIG=${SCRATCHDIR}/IGCM_OUT
[1057]233
234    IGCM_debug_Print 1 "SpaceName=TEST ==> OVERRULE destination path directories"
235
236  else
237    #====================================================
238    #- R_OUT
[1063]239    R_OUT=${ARCHIVE}/IGCM_OUT
[1057]240
241    #====================================================
242    #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
[1063]243    R_FIG=${STORAGE}/IGCM_OUT
[1057]244  fi
245
246  #====================================================
247  #- R_BUF (ONLY FOR double copy an scratch)
[1063]248  R_BUF=${SCRATCHDIR}/IGCM_OUT
[1057]249
250  IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
251  IGCM_debug_Print 1 "R_BUF has been defined = ${R_BUF}"
252  IGCM_debug_Print 1 "R_FIG has been defined = ${R_FIG}"
253
254  IGCM_debug_PopStack "IGCM_sys_defineArchives"
[725]255}
256
[622]257#D-#==================================================
258#D-function IGCM_sys_RshArchive
259#D-* Purpose: Archive rsh command
260#D-* Examples:
261#D-
262function IGCM_sys_RshArchive {
[623]263  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
264  /bin/ksh <<-EOF
[622]265    ${@}
266EOF
[811]267  status=$?
268  if [ ${status} -gt 0 ] ; then
269    IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}"
[623]270    IGCM_debug_Exit "IGCM_sys_RshArchive"
271  fi
272  IGCM_debug_PopStack "IGCM_sys_RshArchive"
[622]273}
274
275#D-#==================================================
[845]276#D-function IGCM_sys_RshArchive_NoError
277#D-* Purpose: Archive rsh command, without error
278#D-*          used only in monitoring.job
279#D-* Examples:
280#D-
281function IGCM_sys_RshArchive_NoError {
282  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@
283  /bin/ksh <<-EOF
[1181]284    ${@} 2> /dev/null
[845]285EOF
286  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError"
287}
288
289#D-#==================================================
[622]290#D-function IGCM_sys_MkdirArchive
291#D-* Purpose: Mkdir on Archive
292#D-* Examples:
293#D-
294function IGCM_sys_MkdirArchive {
[623]295  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
296  if ( $DEBUG_sys ) ; then
297    echo "IGCM_sys_MkdirArchive :" $@
298  fi
299  #- creation de repertoire sur le serveur fichier
300  if [ ! -d ${1} ]; then
301    \mkdir -p $1
[811]302    status=$?
303
304    if [ ${status} -gt 0 ] ; then
305      IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
[623]306      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
[622]307    fi
[623]308  fi
309  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
[622]310}
311
312#D-#==================================================
313#D-function IGCM_sys_TestDirArchive
314#D-* Purpose: Test Directory that must exists on Archive
315#D-* Examples:
316#D-
317function IGCM_sys_TestDirArchive {
[623]318  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
319  if ( $DEBUG_sys ) ; then
320    echo "IGCM_sys_TestDirArchive :" $@
321  fi
322  typeset ExistFlag
323  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
324  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
325  return ${ExistFlag}
[622]326}
327
328#D-#==================================================
[623]329#D-function IGCM_sys_IsFileArchived
[1179]330#D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only
[623]331#D-* Examples:
332#D-
333function IGCM_sys_IsFileArchived {
334  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
335  if ( $DEBUG_sys ) ; then
336    echo "IGCM_sys_IsFileArchived :" $@
337  fi
338  typeset IsArchivedFlag
[818]339  IsArchivedFlag=$( [ X$( echo $@ | grep ^\/ccc\/store ) != X ] && echo 0 || echo 1 )
[623]340  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
341
342  return ${IsArchivedFlag}
343}
344
345#D-#==================================================
[622]346#D-function IGCM_sys_TestFileArchive
347#D-* Purpose: Test file that must NOT EXISTS on Archive
348#D-* Examples:
349#D-
350function IGCM_sys_TestFileArchive {
[623]351  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
352  typeset ExistFlag
353  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
354  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
[622]355
[623]356  return ${ExistFlag}
[622]357}
358
359#D-#==================================================
360#D-function IGCM_sys_CountFileArchive
361#D-* Purpose: Count files on Archive filesystem
362#D-* Examples:
363#D-
364function IGCM_sys_CountFileArchive {
[623]365  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
366  ls ${@} 2>/dev/null | wc -l
367  if [ $? -gt 0 ] ; then
368    echo "IGCM_sys_CountFileArchive : erreur."
369  fi
370  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
[622]371}
372
373#D-#==================================================
374#D-function IGCM_sys_Tree
375#D-* Purpose: Tree directories with files on ${ARCHIVE}
376#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
377#D-
378function IGCM_sys_Tree {
[623]379  IGCM_debug_PushStack "IGCM_sys_Tree" $@
380  if ( $DEBUG_sys ) ; then
381    echo "IGCM_sys_Tree :" $@
382  fi
[622]383
[623]384  \ls -lR ${@}
[622]385
[623]386  IGCM_debug_PopStack "IGCM_sys_Tree"
[622]387}
388
389#D-#==================================================
390#D-function IGCM_sys_Qsub
391#D-* Purpose: Qsub new job
392#D-* Examples:
393#D-
394function IGCM_sys_Qsub {
[623]395  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
396  if ( $DEBUG_sys ) ; then
397    echo "IGCM_sys_Qsub :" $@
398  fi
[811]399  typeset options status
[923]400  options="-o ${SUBMIT_DIR}/${Script_Output} -e ${SUBMIT_DIR}/${Script_Output}"
[622]401
[1179]402  /usr/bin/ccc_msub ${options} $1 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[811]403  status=$?
[948]404
[1179]405  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[811]406  if [ ${status} -gt 0 ] ; then
407    IGCM_debug_Print 2 "IGCM_sys_Qsub ${options} $1 : error code ${status}"
[623]408    IGCM_debug_Exit "IGCM_sys_Qsub"
[948]409  else
[1179]410    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
[623]411  fi
412  IGCM_debug_PopStack "IGCM_sys_Qsub"
[622]413}
414
415#D-#==================================================
416#D-function IGCM_sys_QsubPost
417#D-* Purpose: Qsub new job on scalaire
418#D-* Examples:
419#D-
420function IGCM_sys_QsubPost {
[623]421  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
422  if ( $DEBUG_sys ) ; then
423    echo "IGCM_sys_QsubPost :" $@
424  fi
[923]425  typeset options status
[880]426  MY_PROJECT=$(echo ${BRIDGE_MSUB_PROJECT:=${DEFAULT_PROJECT}} | cut -d@ -f1 )
[923]427
[1062]428  # EASIER TO DO THIS INSTEAD OF DUPLICATING libIGCM_sys_curie.ksh
429  case $( hostname -s ) in
430  curie*)
431    options="-Q normal -A ${MY_PROJECT} -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out";;
432  airain*)
433    options="-q ivybridge -A dsm -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out"
434  esac
435
[1179]436  /usr/bin/ccc_msub ${options} ${libIGCM_POST}/$1.job > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[811]437  status=$?
[948]438
[1179]439  cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[811]440  if [ ${status} -gt 0 ] ; then
[923]441    IGCM_debug_Print 2 "IGCM_sys_QsubPost ${options} ${libIGCM_POST}/$1.job : error code ${status}"
[623]442    IGCM_debug_Exit "IGCM_sys_QsubPost"
[948]443  else
[1179]444    JobID=$( gawk {'print $4'} ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )
[623]445  fi
446  IGCM_debug_PopStack "IGCM_sys_QsubPost"
[622]447}
448
449#D-*************************
[623]450#D- File transfer functions
[622]451#D-*************************
452#D-
453
454#D-#==================================================
455#D-function IGCM_sys_RmRunDir
456#D-* Purpose: rm tmpdir (dummy function most of the time batch
457#D-                      scheduler will do the job)
458#D-* Examples:
459#D-
460function IGCM_sys_RmRunDir {
[1057]461  IGCM_debug_PushStack "IGCM_sys_RmRunDir" $@
[623]462  if ( $DEBUG_sys ) ; then
463    echo "IGCM_sys_RmRunDir :" $@
464  fi
[622]465
[715]466  typeset status
[622]467
[1179]468  echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
469  \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[715]470  status=$?
[622]471
[715]472  if [ ${status} -gt 0 ] ; then
[1183]473    IGCM_debug_Print 1 "IGCM_sys_RmRunDir : rm error code is ${status}."
[1179]474    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[623]475    IGCM_debug_Exit "IGCM_sys_RmRunDir"
476  else
[1179]477    \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[623]478  fi
479  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
[622]480}
481
482#D-#==================================================
483#D-function IGCM_sys_Put_Dir
484#D-* Purpose: Copy a complete directory on $(ARCHIVE)
485#D-* Examples:
486#D-
487function IGCM_sys_Put_Dir {
[623]488  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
489  if ( $DEBUG_sys ) ; then
490    echo "IGCM_sys_Put_Dir :" $@
491  fi
492  if [ $DRYRUN = 0 ]; then
493    if [ ! -d ${1} ] ; then
494      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
495      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
496      return
[622]497    fi
498
[715]499    typeset status
[622]500
[623]501    # Only if we use rsync
502    #IGCM_sys_TestDirArchive $( dirname $2 )
503    #
504    #USUAL WAY
[1179]505    \cp -r $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[715]506    status=$?
[622]507
[715]508    if [ ${status} -gt 0 ] ; then
[811]509      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}"
[1179]510      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[623]511      IGCM_debug_Exit "IGCM_sys_Put_Dir"
[622]512    else
[1179]513      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[622]514    fi
[623]515  fi
516  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
[622]517}
518
519#D-#==================================================
520#D-function IGCM_sys_Get_Dir
[623]521#D-* Purpose: Copy a complete directory from ${ARCHIVE}
[622]522#D-* Examples:
523#D-
524function IGCM_sys_Get_Dir {
[623]525  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
526  if ( $DEBUG_sys ) ; then
527    echo "IGCM_sys_Get_Dir :" $@
528  fi
529  if [ $DRYRUN = 0 ]; then
[708]530    typeset NB_ESSAI DELAI status i
531    # number of tentative
532    NB_ESSAI=3
533    # time delay between tentative
534    DELAI=2
[622]535
[676]536    #
[708]537    # USUAL WAY
538    # add 'ccc_hsm get' (to demigrate all offline files) to reduce time of this command :
[713]539    ccc_hsm get -r $1
[622]540
[709]541    i=0
[708]542    while [ $i -lt $NB_ESSAI ] ; do
[1179]543      \cp -ur $1 $2 >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[708]544      status=$?
[811]545      if [ ${status} -gt 0 ] ; then
[713]546        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}"
[708]547        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
548        sleep $DELAI
549      else
550        break
551      fi
552      (( i = i + 1 ))
553    done
554
555    if [ ${status} -gt 0 ] ; then
[1178]556      IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
[1179]557      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[623]558      IGCM_debug_Exit "IGCM_sys_Get_Dir"
[622]559    else
[1179]560      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[622]561    fi
[623]562  fi
563  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
[622]564}
565
566#D-#==================================================
567#D-function IGCM_sys_Put_Rest
[623]568#D-* Purpose: Put computied restarts on ${ARCHIVE}.
[622]569#D-           File and target directory must exist.
570#D-* Examples:
571#D-
572function IGCM_sys_Put_Rest {
[623]573  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
574  if ( $DEBUG_sys ) ; then
575    echo "IGCM_sys_Put_Rest :" $@
576  fi
577  if [ $DRYRUN = 0 ]; then
578    if [ ! -f ${1} ] ; then
579      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
580      IGCM_debug_Exit "IGCM_sys_Put_Rest"
[622]581    fi
582
[715]583    typeset status
[623]584    #
585    # USUAL WAY
[1179]586    \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[715]587    status=$?
[622]588
[623]589#       #RSYNC WITH NETWORK SSH CALL
[1179]590#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
591#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[622]592
[623]593#       #RSYNC WITH NFS USE
[1179]594#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
595#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[622]596
[715]597#       status=$?
598#       IGCM_sys_Rsync_out $status
[622]599
[1179]600#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[715]601#       (( status=status+$? ))
[623]602
[715]603    if [ ${status} -gt 0 ] ; then
[1179]604      IGCM_debug_Print 2 "IGCM_sys_Put_Rest : cp failed error code ${status}"
[765]605      [ -f ${1} ] && ls -l ${1}
[759]606      [ -f ${2} ] && ls -l ${2}
607      [ -f ${2}/${1} ] && ls -l ${2}/${1}
[1179]608      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[623]609      IGCM_debug_Exit "IGCM_sys_Put_Rest"
[622]610    else
[759]611
612      if [ X${JobType} = XRUN ] ; then
613        [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
614        [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
615      fi
616
[1179]617      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[622]618    fi
[623]619  fi
620  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
[622]621}
622
623#D-#==================================================
624#D-function IGCM_sys_Put_Out
[623]625#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
[622]626#D-* Examples:
627#D-
628function IGCM_sys_Put_Out {
[623]629  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
630  if ( $DEBUG_sys ) ; then
631    echo "IGCM_sys_Put_Out :" $@
632  fi
[667]633
[711]634  typeset NB_ESSAI DELAI status i exist skip
[667]635
636  # number of tentative
[668]637  NB_ESSAI=3
[667]638  # time delay between tentative
[668]639  DELAI=2
[667]640
[623]641  if [ $DRYRUN = 0 ]; then
642    if [ ! -f ${1} ] ; then
643      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
644      IGCM_debug_PopStack "IGCM_sys_Put_Out"
645      return 1
[622]646    fi
[623]647    #
648    IGCM_sys_MkdirArchive $( dirname $2 )
649    #
[711]650    exist=false
651    skip=false
652    if [ -f $2 ] ; then
653      IGCM_debug_Print 1 "$2 already exist"
654      ccc_hsm get $2
655      exist=true
656      if [ "X$( diff $1 $2 )" = X ] ; then
657        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
658        skip=true
[667]659      else
[711]660        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
661        skip=false
[667]662      fi
[711]663    fi
664    #
665    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
666      IGCM_sys_Chmod u+w $2
667    fi
[622]668
[711]669    if [ X${skip} = Xfalse ] ; then
[719]670      i=0
[711]671      while [ $i -lt $NB_ESSAI ] ; do
[1037]672        if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then
673          # USUAL WAY
[1179]674          \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[1037]675          status=$?
676        else
677          # NOT SO USUAL WAY
[1179]678          \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[1037]679          status=$?
680        fi
[711]681        if [ ${status} -gt 0 ]; then
[713]682          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
[711]683          IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again."
[765]684          [ -f ${1} ] && ls -l ${1}
[759]685          [ -f ${2} ] && ls -l ${2}
686          [ -f ${2}/${1} ] && ls -l ${2}/${1}
[711]687          sleep $DELAI
688        else
689          break
690        fi
691        (( i = i + 1 ))
692      done
693    fi
694
[623]695#       #RSYNC WITH NETWORK SSH CALL
[1179]696#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
697#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[622]698
[623]699#       #RSYNC WITH NFS USE
[1179]700#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
701#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[622]702
[711]703#       status=$?
704#       IGCM_sys_Rsync_out $status
[622]705
[1179]706#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[711]707#       (( status=status+$? ))
[622]708
[711]709    if [ ${status} -gt 0 ] ; then
[1179]710      IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status}"
[765]711      [ -f ${1} ] && ls -l ${1}
[759]712      [ -f ${2} ] && ls -l ${2}
713      [ -f ${2}/${1} ] && ls -l ${2}/${1}
[1179]714      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[623]715      IGCM_debug_Exit "IGCM_sys_Put_Out"
[622]716    else
[759]717
718      if [ X${JobType} = XRUN ] ; then
719        if [ X${3} = X ] ; then
720          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
721          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
722        fi
723      fi
724
[1179]725      \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[622]726    fi
[623]727  fi
728  IGCM_debug_PopStack "IGCM_sys_Put_Out"
729  return 0
[622]730}
731
732#D-#==================================================
733#D-function IGCM_sys_Get
734#D-* Purpose: Get a file from ${ARCHIVE}
735#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
736#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
737function IGCM_sys_Get {
[623]738  IGCM_debug_PushStack "IGCM_sys_Get" $@
[622]739
[773]740  typeset DEST dm_liste target file_work
[667]741  typeset NB_ESSAI DELAI status i
[622]742
[623]743  if ( $DEBUG_sys ) ; then
744    echo "IGCM_sys_Get :" $@
745  fi
[667]746
747  # number of tentative
[668]748  NB_ESSAI=3
[667]749  # time delay between tentative
[668]750  DELAI=2
[667]751
[623]752  if [ $DRYRUN -le 2 ]; then
753    if [ X${1} = X'/l' ] ; then
754      eval set +A dm_liste \${${2}}
755    else
756      eval set +A dm_liste ${1}
[622]757    fi
[623]758    eval DEST=\${${#}}
[1179]759    ccc_hsm get ${dm_liste[*]} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[715]760    status=$?
761    if [ ${status} -gt 0 ] ; then
762      echo "WARNING IGCM_sys_Get : error code ${status}"
[1179]763      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[623]764      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
765    fi
[622]766
[715]767    #if [ ${status} -gt 0 ] ; then
[1179]768    #  if [ ! "X$( grep "Lost dmusrcmd connection" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then
769    #    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[785]770    #    echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
771    #    sleep 30
772    #    echo "We try another time"
[1179]773    ##    dmget ${dm_liste[*]} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
774    #    ccc_hsm get ${dm_liste[*]} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[785]775    #    status=$?
776    #    if [ ${status} -gt 0 ] ; then
777    #      echo "ERROR IGCM_sys_Get : again demigration error :"
[1179]778    #      cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[785]779    #      IGCM_debug_Exit "IGCM_sys_Get"
[623]780    #    fi
[785]781    #  else
782    #    echo "ERROR IGCM_sys_Get : demigration error :"
[1179]783    #    cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[785]784    #    IGCM_debug_Exit "IGCM_sys_Get"
785    #  fi
[623]786    #fi
[622]787
[719]788    #   #RSYNC WITH NETWORK SSH CALL
[1179]789    #   echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
790    #   ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[719]791
792    #   #RSYNC WITH NFS USE
[1179]793    #   echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
794    #   ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[719]795
796    #   status=$?
797    #   IGCM_sys_Rsync_out $status
798
[1179]799    #   ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[719]800    #   (( status=status+$? ))
801
[623]802    #USUAL WAY
803    if [ X${1} = X'/l' ] ; then
804      for target in ${dm_liste[*]} ; do
805        local_file=$( basename ${target} )
[668]806        # test if the target file is present before the loop
807        IGCM_sys_TestFileArchive ${target}
[715]808        status=$?
809        if [ ${status} -gt 0 ] ; then
[701]810          echo "IGCM_sys_Get, ERROR : regular file ${target} DOES NOT EXIST ."
[668]811          IGCM_debug_Exit "IGCM_sys_Get"
812        else
[719]813          i=0
[668]814          while [ $i -lt $NB_ESSAI ] ; do
[1037]815            #if [ X${DoLink} = Xtrue ] ; then
[1179]816            #  \ln -s ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[1037]817            #  status=$?
818            #  else
[1179]819            #  \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[1037]820            #  status=$?
821            #fi
[1179]822            \ln -s ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[668]823            status=$?
824            if [ ${status} -gt 0 ]; then
[713]825              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}"
[676]826              IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
827              sleep $DELAI
[668]828            else
[676]829              break
[668]830            fi
831            (( i = i + 1 ))
832          done
[719]833          if [ ${status} -gt 0 ] ; then
834            echo "IGCM_sys_Get : error"
[1179]835            cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
836            \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[719]837            IGCM_debug_Exit "IGCM_sys_Get"
838          else
[1179]839            \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[719]840          fi
[668]841        fi
[623]842      done
843    else
[719]844      i=0
845      while [ $i -lt $NB_ESSAI ] ; do
[1179]846        \cp ${dm_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
[719]847        status=$?
848        if [ ${status} -gt 0 ]; then
849          IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}"
850          IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
851          sleep $DELAI
852        else
853          break
854        fi
855        (( i = i + 1 ))
856      done
857      if [ ${status} -gt 0 ] ; then
858        echo "IGCM_sys_Get : error"
[1179]859        cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
860        \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[719]861        IGCM_debug_Exit "IGCM_sys_Get"
862      else
[1179]863        \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
[719]864      fi
[623]865    fi
866  fi
867  IGCM_debug_PopStack "IGCM_sys_Get"
868}
[622]869
[623]870#D-#==================================================
[835]871#D-function IGCM_sys_GetDate_Monitoring
872#D-* Purpose: get the last year for which the monitoring has been computed
873#D-* Examples:
874#D-
875function IGCM_sys_GetDate_Monitoring {
876  IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@
877  if ( $DEBUG_sys ) ; then
878    echo "IGCM_sys_GetDate_Monitoring :" $@
879  fi
880
881  eval ${2}=$( cdo showyear ${1} 2> /dev/null | gawk '{ print $NF }' )
882
883  IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring"
884}
885
886#D-#==================================================
[623]887#D-function IGCM_sys_Dods_Rm
888#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
889#D-* Examples:
890#D-
891function IGCM_sys_Dods_Rm {
892  if ( $DEBUG_sys ) ; then
893    echo "IGCM_sys_Dods_Rm :" $@
894  fi
[715]895  typeset status
[623]896  if [ $DRYRUN = 0 ]; then
897
898#    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
899#      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
900#      echo "Nothing has been done."
901#      return
902#    fi
903
[649]904    /ccc/cont003/home/dsm/p86ipsl/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
[715]905    status=$?
[623]906
[785]907#    if [ ${status} -gt 0 ] ; then
908#      echo "IGCM_sys_Dods_Rm : error."
909#      cat out_dods_rm
910#      IGCM_debug_Exit "IGCM_sys_Dods_Rm"
911#    else
912#      rm out_dods_rm
913#    fi
[623]914
915  fi
[715]916  return $status
[623]917}
918
919#D-#==================================================
920#D-function IGCM_sys_Dods_Cp
921#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
922#D-* Examples:
923#D-
924function IGCM_sys_Dods_Cp {
925  if ( $DEBUG_sys ) ; then
926    echo "IGCM_sys_Dods_Cp :" $@
927  fi
[715]928  typeset status
[623]929  if [ $DRYRUN = 0 ]; then
930
931#    if [ ! -d ${R_SAVE}/${1} ] ; then
932#      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
933#      echo "Nothing has been done."
934#      return
935#    fi
936
[649]937    /ccc/cont003/home/dsm/p86ipsl/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
[715]938    status=$?
[623]939
[715]940#       if [ ${status} -gt 0 ] ; then
[623]941#           echo "IGCM_sys_Dods_Cp : error."
942#           cat out_dods_cp
943#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
944#       else
945#           rm out_dods_cp
946#       fi
947
948  fi
[715]949  return $status
[623]950}
951
952#D-#==================================================
953#D-function IGCM_sys_Put_Dods
[1178]954#D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole.
[623]955#D-* Examples:
956#D-
957function IGCM_sys_Put_Dods {
958  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
959  if ( $DEBUG_sys ) ; then
960    echo "IGCM_sys_Put_Dods :" $@
961  fi
[715]962  typeset status
[623]963  if [ $DRYRUN = 0 ]; then
964    if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
965      echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should."
966      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST."
967      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST."
968      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
969      return
[622]970    fi
[623]971
972    if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then
973      echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should."
974      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS."
975      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS."
976      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
977      return
978    fi
979    #
980    if [ -d ${R_SAVE}/${1} ] ; then
981      cd ${R_SAVE}
982    elif [ -d ${R_FIGR}/${1} ] ; then
983      cd ${R_FIGR}
984    fi
985
986    IGCM_sys_Dods_Rm ${1}
987    IGCM_sys_Dods_Cp ${1}
[715]988    status=0
[623]989
[715]990    if [ ${status} -gt 0 ] ; then
[623]991      echo "IGCM_sys_Put_Dods : error."
992      IGCM_debug_Exit "IGCM_sys_Put_Dods"
993    fi
994  fi
995  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
[622]996}
997
998##############################################################
999# REBUILD OPERATOR
1000
[811]1001#D-#==================================================
[1163]1002#D-function IGCM_sys_sync
1003#D-* Purpose: flush buffer on disk
1004#D-* Examples:
1005#D-
1006function IGCM_sys_sync {
1007  IGCM_debug_PushStack "IGCM_sys_sync" $@
1008  if ( $DEBUG_sys ) ; then
1009    echo "IGCM_sys_sync :" $@
1010  fi
1011
1012  /bin/sync
1013
1014  IGCM_debug_PopStack "IGCM_sys_sync"
1015}
1016
[622]1017############################################################
1018# Activate Running Environnment Variables
1019
[811]1020#D-#==================================================
1021#D-function IGCM_sys_desactiv_variables
1022#D-* Purpose: set environement variables prior to execution
1023#D-* Examples:
1024#D-
[622]1025function IGCM_sys_activ_variables {
[623]1026  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1027  if ( $DEBUG_sys ) ; then
1028    echo "IGCM_sys_activ_variables"
1029  fi
[622]1030
[811]1031# --------------------------------------------------------------------
1032#D- MPI specifications
1033# --------------------------------------------------------------------
[1191]1034
[811]1035# --------------------------------------------------------------------
1036#D- Other specifications
1037# --------------------------------------------------------------------
1038
[623]1039  ulimit -s unlimited
[622]1040
[623]1041  IGCM_debug_PopStack "IGCM_sys_activ_variables"
[622]1042}
1043
1044############################################################
1045# Desactivate Running Environnment Variables
1046
[811]1047#D-#==================================================
1048#D-function IGCM_sys_desactiv_variables
1049#D-* Purpose: unset environement variables after execution
1050#D-* Examples:
1051#D-
[622]1052function IGCM_sys_desactiv_variables {
[623]1053  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1054  if ( $DEBUG_sys ) ; then
1055    echo "IGCM_sys_desactiv_variables"
1056  fi
[811]1057# --------------------------------------------------------------------
1058#D- MPI specifications
1059# --------------------------------------------------------------------
1060
1061# --------------------------------------------------------------------
1062#D- Other specifications
1063# --------------------------------------------------------------------
1064
[623]1065  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
[622]1066}
1067
[623]1068############################################################
1069# Build MPI/OMP scripts run file (dummy function)
[622]1070
[811]1071#D-#==================================================
1072#D-function IGCM_sys_build_run_file
1073#D-* Purpose: build run file (deprecated)
1074#D-* Examples:
1075#D-
[622]1076function IGCM_sys_build_run_file {
1077
[811]1078  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
[622]1079
1080}
1081
1082############################################################
1083# Build MPI/OMP scripts
[811]1084
1085#D-#==================================================
1086#D-function IGCM_sys_build_execution_scripts
1087#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
1088#D-* Examples:
1089#D-
[623]1090function IGCM_sys_build_execution_scripts
[622]1091{
[623]1092  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1093  if ( $DEBUG_sys ) ; then
1094    echo "IGCM_sys_build_execution_scripts " $@
1095  fi
[622]1096
[623]1097  EXECUTION=${HOST_MPIRUN_COMMAND}
[622]1098
[1078]1099  # MPMD mode
[623]1100  if ( ${OK_PARA_MPMD} ) ; then
[622]1101
[1078]1102    # Only MPI (MPMD)
1103    if  ( ! ${OK_PARA_OMP} ) ; then
[622]1104
[1078]1105      if [ -f run_file ] ; then
1106        IGCM_sys_Rm -f run_file
1107      fi
1108      touch run_file
[622]1109
[1078]1110      # Build run_file
[622]1111
[1078]1112      # First loop on the components for the coupler ie oasis (only if oasis3)
1113      # the coupler ie oasis3 must be the first one
1114      for comp in ${config_ListOfComponents[*]} ; do
[622]1115
[1078]1116        eval ExeNameIn=\${config_Executable_${comp}[0]}
1117        eval ExeNameOut=\${config_Executable_${comp}[1]}
[622]1118
[1078]1119        # for CPL component only
1120        if [ "X${comp}" = "XCPL" ] && [ "X${ExeNameOut}" != X\"\" ] ; then
[1000]1121
[1078]1122          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1123          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1124          echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1125        fi
1126      done
[622]1127
[1078]1128      # Then second loop on the components
1129      for comp in ${config_ListOfComponents[*]} ; do
[622]1130
[1078]1131        eval ExeNameIn=\${config_Executable_${comp}[0]}
1132        eval ExeNameOut=\${config_Executable_${comp}[1]}
[622]1133
[1078]1134        # Only if we really have an executable for the component and not the coupler ie oasis:
1135        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
[622]1136
[1078]1137          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1138          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1139          echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1140        fi
1141      done
[622]1142
[1078]1143      EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file"
[622]1144
[1078]1145      IGCM_sys_Chmod u+x run_file
1146      if ( $DEBUG_sys ) ; then
1147        echo "run_file contains : "
1148        cat run_file
1149      fi
[622]1150
[1078]1151    # MPI-OpenMP (MPMD)
1152    else
[622]1153
[1078]1154      # Use of mpirun instead of ccc_mprun
1155      EXECUTION="time mpirun"
[622]1156
[1078]1157      #  Hosts treatment
1158      ${EXECUTION} hostname | sort | uniq > hosts.tmp
[622]1159
[1078]1160      i=0
1161      rm -f hosts rankfile
1162      IGCM_debug_Print 1 "sys Curie, Hosts available :"
1163      for nodes in `cat hosts.tmp`
1164      do
1165        host[$i]=$nodes
1166        echo "${host[$i]}" >> hosts
1167        IGCM_debug_Print 1 ${host[$i]}
1168        i=$((i+1))
1169      done
1170      rm -f hosts.tmp
[1000]1171
[1078]1172      listnodes=${host[*]}
[1000]1173
[1078]1174      EXECUTION="${EXECUTION} -hostfile hosts -rankfile rankfile"
[1000]1175
[1078]1176      # Initialisation
1177      rank=0
1178      current_core=0
1179      core_per_node=16
1180      init_exec=n
[1000]1181
[1078]1182      # Loop on the components
1183      for comp in ${config_ListOfComponents[*]} ; do
[1000]1184
[1078]1185        eval ExeNameIn=\${config_Executable_${comp}[0]}
1186        eval ExeNameOut=\${config_Executable_${comp}[1]}
[1000]1187
[1078]1188        # Not possible if oasis has an executable (i.e old version of oasis3)
1189        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" = "XCPL" ] ) ; then
1190          IGCM_debug_Exit "ERROR MPMD with hybrid MPI-OpenMP is not available with oasis3 version"
1191          IGCM_debug_Print 2 "Only available with oasis3-MCT version coupler"
1192          IGCM_debug_Verif_Exit
1193        fi
[1000]1194
[1078]1195        # Only if we really have an executable for the component :
1196        if [ "X${ExeNameOut}" != X\"\" ] ; then
[1000]1197
[1078]1198          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1199          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
[1000]1200
[1078]1201          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1202          echo ""  >> script_${ExeNameOut}.ksh
1203          if [ ${comp_proc_omp_loc} -gt 1 ] ; then
1204
1205            # Check if the number of threads is correct
1206            case ${comp_proc_omp_loc} in
1207            2|4|8|16)
1208              IGCM_debug_Print 1 "You run ${ExeNameOut} on ${comp_proc_omp_loc} OMP threads"
1209              ;;
1210            *)
1211              IGCM_debug_Exit "ERROR with OMP parameters !"
1212              IGCM_debug_Print 2 "${comp_proc_omp_loc} is not possible as number of OMP threads"
1213              IGCM_debug_Print 2 "Only 2,4,8,16 as number of OMP threads are possible "
1214              IGCM_debug_Verif_Exit
1215              ;;
1216            esac
1217            echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1218            echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1219            echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1220            echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1221          fi
1222          #echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh
[1157]1223          #echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh
[1078]1224          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1225          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1226
1227          if [ ${init_exec} = y ] ; then
1228            EXECUTION="${EXECUTION} : -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
1229          else
1230            EXECUTION="${EXECUTION} -np ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
1231            init_exec=y
1232          fi
1233
[1000]1234# Build rankfile : method used to assign cores and nodes for the MPI process
[1078]1235# Ex :
[1191]1236#rank 0=curie5296 slot=0,1,2,3
1237#rank 1=curie5296 slot=4,5,6,7
[1000]1238# Example of final command :
1239# mpirun -hostfile hosts -rankfile rankfile -np 27 ./script_lmdz.x.ksh : -np 5 ./script_opa.xx.ksh
1240# with script_lmdz.x.ksh :
1241# #!/bin/ksh
1242#export KMP_STACKSIZE=3g
1243#export KMP_LIBRARY=turnaround
1244#export MKL_SERIAL=YES
1245#OMP_NUM_THREADS=4
1246#./lmdz.x
1247#
1248
[1078]1249          for nb_proc_mpi in `seq 0 $(($comp_proc_mpi_loc-1))`; do
1250            (( index_host = current_core / core_per_node ))
1251            host_value=${host[${index_host}]}
1252            (( slot =  current_core % core_per_node ))
1253            virg=","
1254            string_final=""
1255            for index in `seq $slot $(($slot+$comp_proc_omp_loc-1))`; do
[1191]1256              string=$index$virg
[1078]1257              string_final=$string_final$string
1258            done
1259            string_final=$( echo $string_final | sed "s/.$//" )
1260            echo "rank $rank=$host_value slot=$string_final" >> rankfile
1261            (( rank = rank + 1 ))
1262            (( current_core = current_core + comp_proc_omp_loc ))
1263          done
1264        fi
[1000]1265
[1078]1266      done
1267    fi
[1000]1268
[1078]1269  # Only one executable (SPMD mode).
1270  else
[1000]1271
[622]1272    for comp in ${config_ListOfComponents[*]} ; do
1273
[685]1274      # Only if we really have an executable for the component :
[623]1275      eval ExeNameOut=\${config_Executable_${comp}[1]}
[685]1276      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
[622]1277
[685]1278        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1279        echo ""  >> script_${ExeNameOut}.ksh
1280        IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1281
1282        if ( ${OK_PARA_OMP} ) ; then
1283          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1284          echo ""  >> script_${ExeNameOut}.ksh
1285          echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1286          echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1287          echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1288          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1289        fi
1290
1291        if  ( ${OK_PARA_MPI} ) ; then
[623]1292          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
[685]1293          # Default : ccc_mprun used if nb_proc gt 1
1294          # to have out/err per process on different files
1295          # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${SLURM_PROCID} 2>out_${ExeNameOut}.err.\${SLURM_PROCID}"  >> script_${ExeNameOut}.ksh
1296          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1297          EXECUTION="${HOST_MPIRUN_COMMAND} -n ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
[623]1298        else
[685]1299          # Default : ccc_mprun is NOT used if nb_proc eq 1
1300          # to have out/err per process on different files
1301          # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
1302          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
1303          EXECUTION="/usr/bin/time ./script_${ExeNameOut}.ksh"
[622]1304        fi
[685]1305
1306        IGCM_debug_Print 1 "sys Curie : script_${ExeNameOut}.ksh contains"
1307        cat script_${ExeNameOut}.ksh
1308
[623]1309      fi
[622]1310
1311    done
1312
[623]1313  fi
[622]1314
[623]1315  IGCM_debug_Print 1 "sys Curie : execution command is "
1316  IGCM_debug_Print 1 "$EXECUTION"
[622]1317
[623]1318  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
[622]1319}
1320
[933]1321#D-#==================================================
1322#D-function IGCM_sys_check_path
1323#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
1324#D-* do not point to an important use directory. Stop immediately in that case.
1325#D-* Examples:
1326#D-
1327function IGCM_sys_check_path {
1328  IGCM_debug_PushStack "IGCM_sys_check_path"
1329  if ( $DEBUG_sys ) ; then
1330    echo "IGCM_sys_check_path"
1331  fi
[811]1332
[933]1333  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORKDIR} ] || [ X${RUN_DIR_PATH} = X${SCRATCHDIR} ] || [ X${RUN_DIR_PATH} = X${CCCWORKDIR} ] || [ X${RUN_DIR_PATH} = X${CCCSTOREDIR} ] ) ; then
1334    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
1335    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
[936]1336    IGCM_debug_Exit "This will stop the job"
[933]1337  fi
1338  IGCM_debug_PopStack "IGCM_sys_check_path"
1339}
1340
[811]1341#D-#==================================================
1342#D-function IGCM_sys_check_quota
1343#D-* Purpose: check user quota. Stop the simulation if quota above 90%
1344#D-* Examples:
1345#D-
[714]1346function IGCM_sys_check_quota {
[776]1347  IGCM_debug_PushStack "IGCM_sys_check_quota"
1348  if ( $DEBUG_sys ) ; then
1349    echo "IGCM_sys_check_quota"
1350  fi
1351  # Limit of quota (in %)
1352  limit_quota=90
1353
1354  # Check of the volume
[912]1355  volume_quota=$(ccc_quota | grep ' scratch' | gawk '{print $2}')
1356  volume_avail=$(ccc_quota | grep ' scratch' | gawk '{print $3}')
[776]1357
1358  if ( [ ! X${volume_quota} = X ] && [ ! ${volume_quota} = "-" ] ) ; then
1359
1360    unit_avail=${volume_avail: -1}
1361    unit_quota=${volume_quota: -1}
1362
1363    if [ "${unit_quota}" = "*" ] ; then
[811]1364      IGCM_debug_Print 1 "Please, check your quota of volume on scratch"
1365      IGCM_debug_Print 1 "More than 100% of your quota is used"
1366      IGCM_debug_Print 1 "Use the ccc_quota command to check"
1367      IGCM_debug_Print 1 "You must have more than 10% available to run"
1368      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1369      IGCM_debug_Verif_Exit
[714]1370    fi
[776]1371
1372    temp_avail=${volume_avail%%${volume_avail: -1}*}
1373    temp_quota=${volume_quota%%${volume_quota: -1}*}
1374
1375    if [ ! ${unit_avail} = ${unit_quota} ] ; then
1376
1377    # Convertion
1378      if [ ${volume_avail: -1} = "T" ] ; then
1379        (( temp_avail = temp_avail * 1000000000000 ))
1380      elif [ ${volume_avail: -1} = "G" ] ; then
1381        (( temp_avail = temp_avail * 1000000000 ))
1382      elif [ ${volume_avail: -1} = "M" ] ; then
1383        (( temp_avail = temp_avail * 1000000 ))
1384      elif [ ${volume_avail: -1} = "k" ] ; then
1385        (( temp_avail = temp_avail * 1000 ))
1386      else
1387        (( temp_avail = volume_avail ))
1388      fi
1389      if [ ${volume_quota: -1} = "T" ] ; then
1390        (( temp_quota = temp_quota * 1000000000000 ))
1391      elif [ ${volume_quota: -1} = "G" ] ; then
1392        (( temp_quota = temp_quota * 1000000000 ))
1393      elif [ ${volume_quota: -1} = "M" ] ; then
1394        (( temp_quota = temp_quota * 1000000 ))
1395      elif [ ${volume_quota: -1} = "k" ] ; then
1396        (( temp_quota = temp_quota * 1000 ))
1397      else
1398        (( temp_quota = volume_quota ))
1399      fi
1400    fi
1401
1402    quota_volume=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc)
1403#    echo "volume ratio is " $quota_volume
1404
1405    if [ ${quota_volume} -ge ${limit_quota} ] ; then
1406      IGCM_debug_Print 1 "Please, check your quota of volume on scratch"
1407      IGCM_debug_Print 1 "${quota_volume}% of your quota is used"
1408      IGCM_debug_Print 1 "Use the ccc_quota command to check"
1409      IGCM_debug_Print 1 "You must have more than 10% available to run"
1410      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1411      IGCM_debug_Verif_Exit
1412    fi
1413
1414  fi
1415
1416# Check of the number of inodes
1417
[912]1418  inode_quota=$(ccc_quota | grep ' scratch' | gawk '{print $6}')
1419  inode_avail=$(ccc_quota | grep ' scratch' | gawk '{print $7}')
[776]1420
1421  if ( [ ! X${inode_quota} = X ] && [ ! ${inode_quota} = "-" ] ) ; then
1422
1423    unit_avail=${inode_avail: -1}
1424    unit_quota=${inode_quota: -1}
1425
1426    if [ "${unit_quota}" = "*" ] ; then
[811]1427      IGCM_debug_Print 1 "Please, check your quota of inode on scratch"
1428      IGCM_debug_Print 1 "More than 100% of your quota is used"
1429      IGCM_debug_Print 1 "Use the ccc_quota command to check"
1430      IGCM_debug_Print 1 "You must have more than 10% available to run"
1431      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1432      IGCM_debug_Verif_Exit
[776]1433    fi
1434
1435    temp_avail=${inode_avail%%${inode_avail: -1}*}
1436    temp_quota=${inode_quota%%${inode_quota: -1}*}
1437
1438    if [ ! ${unit_avail} = ${unit_quota} ] ; then
1439
1440    # Convertion
1441      if [ ${inode_avail: -1} = "T" ] ; then
1442        (( temp_avail = temp_avail * 1000000000000 ))
1443      elif [ ${inode_avail: -1} = "G" ] ; then
1444        (( temp_avail = temp_avail * 1000000000 ))
1445      elif [ ${inode_avail: -1} = "M" ] ; then
1446        (( temp_avail = temp_avail * 1000000 ))
1447      elif [ ${inode_avail: -1} = "k" ] ; then
1448        (( temp_avail = temp_avail * 1000 ))
1449      else
1450        (( temp_avail = inode_avail ))
1451      fi
1452
1453      if [ ${inode_quota: -1} = "T" ] ; then
1454        (( temp_quota = temp_quota * 1000000000000 ))
1455      elif [ ${inode_quota: -1} = "G" ] ; then
1456        (( temp_quota = temp_quota * 1000000000 ))
1457      elif [ ${inode_quota: -1} = "M" ] ; then
1458        (( temp_quota = temp_quota * 1000000 ))
1459      elif [ ${inode_quota: -1} = "k" ] ; then
1460        (( temp_quota = temp_quota * 1000 ))
1461      else
1462        (( temp_quota = inode_quota ))
1463      fi
1464    fi
1465    quota_inode=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc)
1466#    echo "inode ratio is " $quota_inode
1467
1468    if [ ${quota_inode} -ge ${limit_quota} ] ; then
1469      IGCM_debug_Print 1 "Please, check your quota of inode on scratch"
1470      IGCM_debug_Print 1 "${quota_inode}% of your quota is used"
1471      IGCM_debug_Print 1 "Use the ccc_quota command to check"
1472      IGCM_debug_Print 1 "You must have more than 10% available to run"
1473      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1474      IGCM_debug_Verif_Exit
1475    fi
1476  fi
1477  IGCM_debug_PopStack "IGCM_sys_check_quota"
[714]1478}
1479
[773]1480#D-#==================================================
[958]1481#D-function IGCM_sys_GetJobID
1482#D-* Purpose: Check if job_name is currently
1483#D-  running or in queue
1484#D-* Examples: IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID
1485#D-
1486function IGCM_sys_GetJobID {
1487  IGCM_debug_PushStack "IGCM_sys_GetJobID"
1488  if ( $DEBUG_sys ) ; then
1489    echo "IGCM_sys_GetJobID"
1490  fi
1491
1492  # With -f option, the full job name is given in the last column
1493  ID=$( ccc_mstat -f -u $2 | \
1494        gawk -v JobName=$1 '( $NF ~ JobName ) { print $1 }' )
1495
1496  eval ${3}=${ID}
1497  IGCM_debug_PopStack "IGCM_sys_GetJobID"
1498}
1499
1500#D-#==================================================
[773]1501#D-function IGCM_sys_CountJobInQueue
1502#D-* Purpose: Check if job_name is currently
1503#D-  running or in queue
1504#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
1505#D-
1506function IGCM_sys_CountJobInQueue {
1507  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
1508  if ( $DEBUG_sys ) ; then
1509    echo "IGCM_sys_CountJobInQueue"
1510  fi
1511
1512  # With -f option, the full job name is given in the last column
[834]1513  NbRun=$( ccc_mstat -f | gawk -v JobName=$1 'BEGIN { x=0 } ( $NF ~ JobName ) { x=x+1 } END { print x }' )
[773]1514
1515  eval ${2}=${NbRun}
1516
1517  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
1518}
1519
[955]1520#D-#==================================================
1521#D-function IGCM_sys_ListJobInQueue
1522#D-* Purpose: Check if job_name is currently
1523#D-  running or in queue
1524#D-* Examples: IGCM_sys_ListJobInQueue ${User} JobNameList
1525#D-
1526function IGCM_sys_ListJobInQueue {
1527  IGCM_debug_PushStack "IGCM_sys_ListJobInQueue"
1528  if ( $DEBUG_sys ) ; then
1529    echo "IGCM_sys_ListJobInQueue"
1530  fi
1531
1532  # With -f option, the full job name is given in the last column
1533  set -A JobList $( ccc_mstat -f | gawk -v User=$1             \
1534                                        '( $2  == User      && \
1535                                           $NF != /TS/      && \
1536                                           $NF !~ /PACK/    && \
1537                                           $NF !~ /REBUILD/ && \
1538                                           $NF !~ /pack/ )     \
1539                                         { print $NF }' | sed -e "s/\(.*\)\.[0-9]*/\1/" )
1540
1541  eval set -A ${2} ${JobList[*]}
1542
1543  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue"
1544}
Note: See TracBrowser for help on using the repository browser.