source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_ciclad.ksh @ 1440

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