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

Last change on this file since 1474 was 1459, checked in by jgipsl, 6 years ago

Removed variable R_IN_ECMWF (never used in reference experiment setups)

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