source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_vargas.ksh @ 832

Last change on this file since 832 was 804, checked in by sdipsl, 11 years ago
  • Files waiting for rebuild are stored within the relevant simulation tree. see #87

--> /IGCM_OUT/TagName/SpaceName/ExperiementName/JobName/REBUILD

  • Using only 1 proc and having RebuildFrequency? != NONE won't be an issue. see #88
  • Homogenize RUN_DIR PATH during computing and post-processing. see #92
  • Save text files before restarts and outputs. (more chance to have a clue of what went wrong) see #103
  • Remove useless variable BIG_DIR
  • Cosmectics
  • Property svn:keywords set to Revision Author Date
File size: 50.3 KB
RevLine 
[70]1#!/bin/ksh
2
3#**************************************************************
4# Author: Sébastien Denvil
[373]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
[70]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
[619]16# if you use the prefix #D- for comments to be extracted.
[70]17# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
18#=========================================================
19
20#D-#==================================================
21#D-LibIGCM_sys for Vargas
22#D-#==================================================
23#D-
[619]24#D- This ksh library if a layer under some usefull
[70]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 |            |  Chmod  |                           |
46# |          |      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#=====================================================
[619]64# Host and user names
[217]65# $hostname ou hostname
[228]66typeset  HOST=${HOST:=$( hostname )}
[70]67# $username ou whoami
[228]68typeset  LOGIN=${LOGIN:=$( whoami )}
[70]69# $hostname of the MASTER job
[77]70typeset -r MASTER=vargas
[70]71
72#D-
73#D-#==================================================
74#D-Program used in libIGCM
75#D-#==================================================
76
[742]77# Submit command
78typeset SUBMIT=${SUBMIT:=llsubmit}
[70]79# rsync with path
80typeset -r RSYNC=/usr/local/bin/rsync
81# RSYNC_opt args to rsync
82typeset -r RSYNC_opt="-va"
[192]83# ie storage filesystem
[537]84typeset -r STOREHOST=gaya.idris.fr
[70]85typeset -r REMOTE_RSYNC=/u/rech/ces/rces452/RSYNC/bin/rsync
86
87#====================================================
88# Host specific DIRECTORIES
89#====================================================
90
91#====================================================
92#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
93typeset -r R_EXE="${MODIPSL}/bin"
94
95#====================================================
96#- SUBMIT_DIR : submission dir
97typeset SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}}
98
99#====================================================
[725]100#- IN
101typeset -r R_IN=${R_IN:=/u/rech/psl/rpsl035/IGCM}
102typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/u/rech/psl/rpsl376}
103
104#====================================================
[70]105#- ARCHIVE
[132]106typeset -r ARCHIVE=$( echo ${HOME} | sed -e "s/homegpfs/u/" )
[70]107
108#====================================================
[619]109#- Mirror libIGCM from vargas to ulam
[70]110typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true}
111
112#====================================================
113#- libIGCM_POST
[109]114PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" )
[132]115typeset -r HOME_POST=$( echo ${HOME} | sed -e "s/homegpfs/home/" )
[192]116typeset -r libIGCM_POST=${HOME_POST}/MIRROR/${PATHlibIGCM}/libIGCM
[70]117
118#====================================================
119#- OUT
120typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
121
122#====================================================
[619]123#- R_BUF  Buffer to pack files
124typeset -r R_BUF=${WORKDIR}/IGCM_OUT
125
126#====================================================
[70]127#- RUN_DIR_PATH : Temporary working directory (=> TMP)
128typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${TMPDIR}}
129
130#====================================================
131#- HOST_MPIRUN_COMMAND
132typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time poe"}
133
134#====================================================
135#- Max number of arguments passed to nco operator or demigration command
[619]136UNIX_MAX_LIMIT=120
[70]137
[619]138#====================================================
139#- Default number of MPI task for IPSL coupled model
140#- required for backward compatibility
141#-
142DEFAULT_NUM_PROC_OCE=5
143DEFAULT_NUM_PROC_CPL=1
[644]144[ X${BATCH_NUM_PROC_TOT} = X ] || (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
[637]145DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
[619]146
[70]147#D-#==================================================
[725]148#D-function IGCM_sys_ChangeArchive
149#D-* Purpose: Just a dummy call on this machine
150#D-* Examples:
151#D-
152function IGCM_sys_ChangeArchive {
153
154  IGCM_debug_Print 1 " dummy function : IGCM_sys_ChangeArchive "
155
156}
157
158#D-#==================================================
[537]159#D-function IGCM_sys_RshMaster
160#D-* Purpose: Connection to frontend machine.
161#D-* Examples:
162#D-
163(( RshMNum = 0 ))
164function IGCM_sys_RshMaster {
[619]165  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
[537]166
[619]167  typeset THEFILE OUTFILE ERR
[537]168
[619]169  RshDIR=${WORKDIR}/RUN_DIR/${config_UserChoices_TagName}/${config_UserChoices_JobName}.${$}
170  if [ ! -d ${RshDIR} ] ; then
171    IGCM_sys_Mkdir ${RshDIR}
172  fi
173  THEFILE=${RshDIR}/file_sys_RshMaster_$$_${RshMNum}
174  echo '#!/bin/ksh' > ${THEFILE}
175  echo "export libIGCM=${libIGCM} > /dev/null 2>&1" >> ${THEFILE}
176  echo "export DEBUG_debug=${DEBUG_debug} > /dev/null 2>&1" >> ${THEFILE}
177  echo ". ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh > /dev/null 2>&1" >> ${THEFILE}
178  echo ". ${libIGCM}/libIGCM_card/libIGCM_card.ksh > /dev/null 2>&1" >> ${THEFILE}
179  echo "${@} " >> ${THEFILE}
[537]180
[634]181  # No frontend queue on brodie : just rsh the job on the frontend with submission.
[619]182  sed -e "s@IGCM_sys_Qsub\(.*\)@\1@" ${THEFILE} > ${THEFILE}_
[537]183
[619]184  chmod u+x  ${THEFILE}_
[537]185
[619]186  OUTFILE=${RshDIR}/out_RshMaster.$$.${RshMNum}
187  (( RshMNum = RshMNum + 1 ))
[537]188
[619]189  rsh ${MASTER} 'bash -c "nohup '${THEFILE}'_ > '${OUTFILE}' 2>&1 &"'
190  if [ $? -gt 0 ] ; then
191    echo "IGCM_sys_RshMaster : erreur."
192    IGCM_debug_Exit "IGCM_sys_RshMaster"
193  fi
194  IGCM_debug_PopStack "IGCM_sys_RshMaster"
[537]195}
196
197#D-#==================================================
[70]198#D-function IGCM_sys_RshArchive
199#D-* Purpose: Archive rsh command
200#D-* Examples:
201#D-
202function IGCM_sys_RshArchive {
[619]203  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
204  rsh ${STOREHOST} exec /bin/ksh <<-EOF
[70]205    ${@}
206EOF
[619]207  if [ $? -gt 0 ] ; then
208    echo "IGCM_sys_RshArchive : erreur."
209    IGCM_debug_Exit "IGCM_sys_RshArchive"
210  fi
211  IGCM_debug_PopStack "IGCM_sys_RshArchive"
[70]212}
213
214#D-#==================================================
215#D-function IGCM_sys_RshPost
216#D-* Purpose: Post-process rsh command
217#D-* Examples:
218#D-
219function IGCM_sys_RshPost {
[619]220  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
221  if ( $DEBUG_sys ) ; then
222    echo "IGCM_sys_RshPost :" $@
223  fi
[479]224
[619]225  # keep standard input to keep it for postpone if ulam don't answer
226  cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
[479]227
[619]228  ## Add submission for old postponed files only if command is a Qsub
229  ##
230  ISITQSUB=0
231  grep Qsub /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} >/dev/null 2>&1 && ISITQSUB=1
232  if  ( [ ${ISITQSUB} -gt 0 ] ) ; then
233    if [ -d ${SUBMIT_DIR}/POSTPONE ] ; then
234      for postponed_file in ${SUBMIT_DIR}/POSTPONE/* ; do
235        if [ -f ${postponed_file} ] ; then
236          IGCM_debug_Print 2 " submit postponed file : " ${postponed_file}
237          rsh ulam exec /bin/ksh <${postponed_file}
238          if [ $? -eq 0 ] ; then
239            IGCM_sys_Rm ${postponed_file}
240          else
241            IGCM_debug_Print 2 "keep postponed file for an other submission :" ${postponed_file}
242          fi
243        fi
244      done
[70]245    fi
[619]246  fi
[479]247
[619]248  RETURN=0
249  # rsh ulam command
250  rsh ulam exec /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
251  RETURN=$?
[479]252
[619]253  # keep standard input for postpone if ulam don't answer
254  if ( [ ${RETURN} -gt 0 ] ) ; then
255    IGCM_debug_Print 2 "Postpone tmp_IGCM_sys_RshPost_$$_${LOGNAME}"
256    [ -d ${SUBMIT_DIR}/POSTPONE ] || mkdir ${SUBMIT_DIR}/POSTPONE
257    mv /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} ${SUBMIT_DIR}/POSTPONE
258  else
259    IGCM_sys_Rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
260  fi
261  IGCM_debug_PopStack "IGCM_sys_RshPost"
[70]262}
263
264#D-#==================================================
[153]265#D-function IGCM_sys_SendMail
266#D-* Purpose: Send mail when simulation is over
267#D-* Examples:
268#D-
269function IGCM_sys_SendMail {
[619]270  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
271  if ( $DEBUG_sys ) ; then
272    echo "IGCM_sys_SendMail :" $@
273  fi
[437]274
[619]275  if ( ${ExitFlag} ) ; then
276    status=failed
277  else
278    status=completed
279  fi
280  cat  << END_MAIL > job_end.mail
[437]281Dear ${LOGIN},
282
[453]283  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
[153]284  Job started : ${DateBegin}
285  Job ended   : ${DateEnd}
[434]286  Output files are available in ${R_SAVE}
[453]287  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
[153]288END_MAIL
289
[619]290  if [ ! -z ${config_UserChoices_MailName} ] ; then
291    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail
292  elif [ -f ~/.forward ] ; then
293    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
294  else
295    mailx -s "${config_UserChoices_JobName} ${status}" ${USER} < job_end.mail
296  fi
[153]297
[619]298  if [ $? -gt 0 ] ; then
299    echo "IGCM_sys_SendMail : erreur."
300    IGCM_debug_Exit "IGCM_sys_SendMail"
301  fi
302  IGCM_debug_PopStack "IGCM_sys_SendMail"
[153]303}
304
305#D-#==================================================
[70]306#D-function IGCM_sys_Mkdir
307#D-* Purpose: Master locale mkdir command
308#D-* Examples:
309#D-
310function IGCM_sys_Mkdir {
[619]311  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
312  if ( $DEBUG_sys ) ; then
313    echo "IGCM_sys_Mkdir :" $@
314  fi
315  if [ ! -d ${1} ]; then
316    \mkdir -p $1
317    if [ $? -gt 0 ] ; then
318      echo "IGCM_sys_Mkdir : erreur."
319      IGCM_debug_Exit "IGCM_sys_Mkdir"
[70]320    fi
[619]321  fi
[70]322    # vérification :
[619]323  if [ ! -d ${1} ] ; then
324    echo "IGCM_sys_Mkdir : erreur."
325    IGCM_debug_Exit "IGCM_sys_Mkdir"
326  fi
327  IGCM_debug_PopStack "IGCM_sys_Mkdir"
[70]328}
329
330#D-#==================================================
331#D-function IGCM_sys_MkdirArchive
332#D-* Purpose: Mkdir on Archive
333#D-* Examples:
334#D-
335function IGCM_sys_MkdirArchive {
[619]336  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
337  if ( $DEBUG_sys ) ; then
338    echo "IGCM_sys_MkdirArchive :" $@
339  fi
340  #- creation de repertoire sur le serveur fichier
341  rsh ${STOREHOST} -n mkdir -p $1
[70]342
[619]343  if [ $? -gt 0 ] ; then
344    echo "IGCM_sys_MkdirArchive : erreur."
345    IGCM_debug_Exit "IGCM_sys_MkdirArchive"
346  fi
347  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
[70]348}
349
350#D-#==================================================
351#D-function IGCM_sys_MkdirWork
352#D-* Purpose: Mkdir on Work
353#D-* Examples:
354#D-
355function IGCM_sys_MkdirWork {
[619]356  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
357  if ( $DEBUG_sys ) ; then
358    echo "IGCM_sys_MkdirWork :" $@
359  fi
360  #- creation de repertoire sur le serveur fichier
361  if [ ! -d ${1} ]; then
362    \mkdir -p $1
363    if [ $? -gt 0 ] ; then
364      echo "IGCM_sys_MkdirWork : erreur."
365      IGCM_debug_Exit "IGCM_sys_MkdirWork"
[70]366    fi
[619]367  fi
368  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
[70]369}
370
371#D-#==================================================
372#D-function IGCM_sys_Cd
373#D-* Purpose: master cd command
374#D-* Examples:
375#D-
376function IGCM_sys_Cd {
[619]377  IGCM_debug_PushStack "IGCM_sys_Cd" $@
378  if ( $DEBUG_sys ) ; then
379    echo "IGCM_sys_Cd :" $@
380  fi
381  \cd $1
382  if [ $? -gt 0 ] ; then
383    echo "IGCM_sys_Cd : erreur."
384    IGCM_debug_Exit "IGCM_sys_Cd"
385  fi
386  IGCM_debug_PopStack "IGCM_sys_Cd"
[70]387}
388
389#D-#==================================================
390#D-function IGCM_sys_Chmod
391#D-* Purpose: Chmod
392#D-* Examples:
393#D-
394function IGCM_sys_Chmod {
[619]395  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
396  if ( $DEBUG_sys ) ; then
397    echo "IGCM_sys_Chmod :" $@
398  fi
399  if [ $DRYRUN -le 1 ]; then
400    \chmod $@
401    if [ $? -gt 0 ] ; then
402      echo "IGCM_sys_Chmod : erreur."
403      IGCM_debug_Exit "IGCM_sys_Chmod"
[70]404    fi
[619]405  else
406    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
407  fi
408  IGCM_debug_PopStack "IGCM_sys_Chmod"
[70]409}
410
411#D-#==================================================
412#D-function IGCM_sys_FileSize
413#D-* Purpose: Filesize
414#D-* Examples:
415#D-
416function IGCM_sys_FileSize {
[619]417  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
[70]418
[619]419  typeset sizeF
420  set +A sizeF -- $( ls -la ${1} )
421  if [ $? -gt 0 ] ; then
422    IGCM_debug_Exit "IGCM_sys_FileSize"
423  fi
424  eval ${2}=${sizeF[4]}
[70]425
[619]426  IGCM_debug_PopStack "IGCM_sys_FileSize"
[70]427}
428
429#D-#==================================================
430#D-function IGCM_sys_TestDir
431#D-* Purpose: Test Directory that must exists
432#D-* Examples:
433#D-
434function IGCM_sys_TestDir {
[619]435  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
436  if ( $DEBUG_sys ) ; then
437    echo "IGCM_sys_TestDir :" $@
438  fi
439  typeset ExistFlag
440  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
441  IGCM_debug_PopStack "IGCM_sys_TestDir"
[70]442
[619]443  return ${ExistFlag}
[70]444}
445
446#D-#==================================================
447#D-function IGCM_sys_TestDirArchive
448#D-* Purpose: Test Directory that must exists on Archive
449#D-* Examples:
450#D-
451function IGCM_sys_TestDirArchive {
[619]452  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
453  if ( $DEBUG_sys ) ; then
454    echo "IGCM_sys_TestDirArchive :" $@
455  fi
456  typeset ExistFlag
457  ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" )
458  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
[70]459
[619]460  return ${ExistFlag}
[70]461}
462
463#D-#==================================================
[619]464#D-function IGCM_sys_IsFileArchived
465#D-* Purpose: Test file that must NOT EXISTS on Archive
466#D-* always true on vargas.
467#D-* Examples:
468#D-
469function IGCM_sys_IsFileArchived {
470  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
471  if ( $DEBUG_sys ) ; then
472    echo "IGCM_sys_IsFileArchived :" $@
473  fi
474  typeset IsArchivedFlag
475  IsArchivedFlag=$( echo 0 )
476  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
477
478  return ${IsArchivedFlag}
479}
480
481#D-#==================================================
[70]482#D-function IGCM_sys_TestFileArchive
483#D-* Purpose: Test file that must NOT EXISTS on Archive
484#D-* Examples:
485#D-
486function IGCM_sys_TestFileArchive {
[619]487  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
488  typeset ExistFlag
489  ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" )
490  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
[70]491
[619]492  return ${ExistFlag}
[70]493}
494
495#D-#==================================================
[619]496#D-function IGCM_sys_TestFileBuffer
497#D-* Purpose: Test file that must NOT EXISTS on Buffer
498#D-* Examples:
499#D-
500function IGCM_sys_TestFileBuffer {
501  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
502  typeset ExistFlag
503  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
504  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
505
506  return ${ExistFlag}
507}
508
509#D-#==================================================
[70]510#D-function IGCM_sys_CountFileArchive
511#D-* Purpose: Count files on Archive filesystem
512#D-* Examples:
513#D-
514function IGCM_sys_CountFileArchive {
[619]515  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
516  IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l"
517  if [ $? -gt 0 ] ; then
518    echo "IGCM_sys_CountFileArchive : erreur."
519  fi
520  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
[70]521}
522
523#D-#==================================================
[619]524#D-function IGCM_sys_CountFileBuffer
525#D-* Purpose: Count files on Scratch filesystem
526#D-* Examples:
527#D-
528function IGCM_sys_CountFileBuffer {
529  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
530  ls ${@} 2>/dev/null | wc -l
531  if [ $? -gt 0 ] ; then
532    echo "IGCM_sys_CountFileBuffer : erreur."
533  fi
534  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
535}
536
537#D-#==================================================
[70]538#D-function IGCM_sys_Tree
539#D-* Purpose: Tree directories with files on ${ARCHIVE}
540#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
541#D-
542function IGCM_sys_Tree {
[619]543  IGCM_debug_PushStack "IGCM_sys_Tree" $@
544  if ( $DEBUG_sys ) ; then
545    echo "IGCM_sys_Tree :" $@
546  fi
[70]547
[619]548  \mfls -r $@
[70]549
[619]550  IGCM_debug_PopStack "IGCM_sys_Tree"
[70]551}
552
553#D-#==================================================
554#D-function IGCM_sys_Tar
555#D-* Purpose: master un-tar command
556#D-* Examples:
557#D-
558function IGCM_sys_Tar {
[619]559  IGCM_debug_PushStack "IGCM_sys_Tar" $@
560  if ( $DEBUG_sys ) ; then
561    echo "IGCM_sys_Tar :" $@
562  fi
563  \tar cf $@
564  if [ $? -gt 0 ] ; then
565    echo "IGCM_sys_Tar : erreur."
566    IGCM_debug_Exit "IGCM_sys_Tar"
567  fi
568  IGCM_debug_PopStack "IGCM_sys_Tar"
[70]569}
570
571#D-#==================================================
572#D-function IGCM_sys_UnTar
573#D-* Purpose: master un-tar command
574#D-* Examples:
575#D-
576function IGCM_sys_UnTar {
[619]577  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
578  if ( $DEBUG_sys ) ; then
579    echo "IGCM_sys_UnTar :" $@
580  fi
581  \tar xvf $1
582  if [ $? -gt 0 ] ; then
583    echo "IGCM_sys_UnTar : erreur."
584    IGCM_debug_Exit "IGCM_sys_UnTar"
585  fi
586  IGCM_debug_PopStack "IGCM_sys_UnTar"
[70]587}
588
589#D-#==================================================
590#D-function IGCM_sys_Qsub
591#D-* Purpose: Qsub new job
592#D-* Examples:
593#D-
594function IGCM_sys_Qsub {
[619]595  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
[476]596
[619]597  typeset ERROR
598  ERROR=0
599
600  if ( $DEBUG_sys ) ; then
601    echo "IGCM_sys_Qsub :" $@
602  fi
603  # We have to change output/error file
604  [ ${#@} = 1 ] &&  REP_FOR_JOB=$LOADL_STEP_INITDIR
605  [ ${#@} = 2 ] &&  REP_FOR_JOB=$2
606  sed -e "s/\# \@ output *= .*/\# \@ output = ${Script_Output}/" -e "s/\# \@ error *= .*/\# \@ error = ${Script_Output}/" <$1 >${REP_FOR_JOB}/JOB_FOR_IGCM
607  {
608    [ ${#@} = 1 ] &&  ( cd $LOADL_STEP_INITDIR ; /usr/local/bin/llsubmit JOB_FOR_IGCM ; ERROR=$? ; cd - ; )
609    [ ${#@} = 2 ] &&  ( cd $2 ; /usr/local/bin/llsubmit JOB_FOR_IGCM ; ERROR=$? ; cd - ; )
610  }
611  if [ ${ERROR} -gt 0 ] ; then
612    echo "IGCM_sys_Qsub : erreur $@."
613    IGCM_debug_Exit "IGCM_sys_Qsub"
614  fi
615  IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM
616  IGCM_debug_PopStack "IGCM_sys_Qsub"
617
[70]618}
619
620#D-#==================================================
621#D-function IGCM_sys_QsubPost
622#D-* Purpose: Qsub new job on scalaire
623#D-* Examples:
624#D-
625function IGCM_sys_QsubPost {
[619]626  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
627  if ( $DEBUG_sys ) ; then
628    echo "IGCM_sys_QsubPost :" $@
629  fi
630  cd ${POST_DIR}
631  /opt/ibmll/LoadL/full/bin/llsubmit ${libIGCM_POST}/$1.job
632  cd -
633  if [ $? -gt 0 ] ; then
634    echo "IGCM_sys_QsubPost : erreur " $@
635    IGCM_debug_Exit "IGCM_sys_QsubPost"
636  fi
637  IGCM_debug_PopStack "IGCM_sys_QsubPost"
[70]638}
639
640#D-*************************
[619]641#D- File transfer functions
[70]642#D-*************************
643#D-
644
645#D-#==================================================
646#D-function IGCM_sys_Rsync_out
647#D-* Purpose: treat return val of rsync
648#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
649#D-  Error values and explanations can depend on your system version.
650function IGCM_sys_Rsync_out {
[719]651  status=$1
652  if [ ! $status ] ; then
[619]653    echo "rsync error !"
654  fi
[70]655
[619]656  if [ $MYLANG = "fr" ]; then
[719]657    case $status in
[619]658    0)  return ;;
659    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
660      echo "Erreur de syntaxe ou d'utilisation."
661      return;;
662    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
663      echo "Incompatibilité de protocole."
664      return;;
665    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
666      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
667      echo "répertoires"
668      return;;
669    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
670      echo "Action demandée non supportée : une tentative de manipulation de"
671      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
672      echo "été faite ; ou une option qui est supportée par le  client  mais"
673      echo "pas par le serveur a été spécifiée."
674      return;;
675    10) echo "Erreur de rsync ; RERR_SOCKETIO"
676      echo "Erreur dans le socket d'entrée sortie"
677      return;;
678    11) echo "Erreur de rsync ; RERR_FILEIO"
679      echo "Erreur d'entrée sortie fichier"
680      return;;
681    12) echo "Erreur de rsync ; RERR_STREAMIO"
682      echo "Erreur dans flux de donnée du protocole rsync"
683      return;;
684    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
685      echo "Erreur avec les diagnostics du programme"
686      return;;
687    14) echo "Erreur de rsync ; RERR_IPC"
688      echo "Erreur dans le code IPC"
689      return;;
690    20) echo "Erreur de rsync ; RERR_SIGNAL"
691      echo "SIGUSR1 ou SIGINT reçu"
692      return;;
693    21) echo "Erreur de rsync ; RERR_WAITCHILD"
694      echo "Une erreur retournée par waitpid()"
695      return;;
696    22) echo "Erreur de rsync ; RERR_MALLOC"
697      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
698      return;;
699    23) echo ""
700      echo "Erreur fichier inexistant"
701      return;;
702    30) echo "Erreur de rsync ; RERR_TIMEOUT"
703      echo "Temps d'attente écoulé dans l'envoi/réception de données"
704      return;;
[719]705    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status
[619]706      return;;
707    esac
708  elif [ $MYLANG = "en" ] ; then
[719]709    case $status in
[619]710    0)  return;;
711    1)  echo "rsync error : Syntax or usage error "
712      return;;
713    2)  echo "rsync error : Protocol incompatibility "
714      return;;
715    3)  echo "rsync error : Errors selecting input/output files, dirs"
716      return;;
717    4)  echo "rsync error : Requested action not supported: an attempt"
718      echo "was made to manipulate 64-bit files on a platform that cannot support"
719      echo "them; or an option was specified that is supported by the client and"
720      echo "not by the server."
721      return;;
722    5)  echo "rsync error : Error starting client-server protocol"
723      return;;
724    10) echo "rsync error : Error in socket I/O "
725      return;;
726    11) echo "rsync error : Error in file I/O "
727      return;;
728    12) echo "rsync error : Error in rsync protocol data stream "
729      return;;
730    13) echo "rsync error : Errors with program diagnostics "
731      return;;
732    14) echo "rsync error : Error in IPC code "
733      return;;
734    20) echo "rsync error : Received SIGUSR1 or SIGINT "
735      return;;
736    21) echo "rsync error : Some error returned by waitpid() "
737      return;;
738    22) echo "rsync error : Error allocating core memory buffers "
739      return;;
740    23) echo "rsync error : Partial transfer due to error"
741      return;;
742    24) echo "rsync error : Partial transfer due to vanished source files"
743      return;;
744    30) echo "rsync error : Timeout in data send/receive "
745      return;;
[719]746    *)  echo "rsync error : return code of rsync unknown :" $status
[619]747      return;;
748    esac
749  else
750    echo "unknown language $MYLANG."
751    return
752  fi
[70]753}
754
755#D-#==================================================
756#D-function IGCM_sys_Miror_libIGCM
757#D-* Purpose: Mirror libIGCM PATH and lib to ulam
758#D-* Examples:
759#D-
760function IGCM_sys_Mirror_libIGCM {
[619]761  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
762  if ( $DEBUG_sys ) ; then
763    echo "IGCM_sys_Mirror_libIGCM"
764  fi
[70]765
[719]766  typeset status
[70]767
[619]768  IGCM_sys_RshPost <<-EOF
[193]769    mkdir -p ${HOME_POST}/MIRROR/${PATHlibIGCM}
[70]770EOF
[619]771  rsh ulam -n hostname > /dev/null 2>&1
[719]772  status=$?
773  if [ $status -eq 0 ] ; then
[619]774    echo ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME_POST}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
775    ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME_POST}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
[719]776    status=$?
[70]777
[719]778    if [ ${status} -gt 0 ] ; then
[619]779      echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on ulam."
780      cat out_rsync
[70]781    fi
[619]782    IGCM_sys_Rm out_rsync
783  else
784    echo "No POST-TREATMENT avaible because ulam is down."
785  fi
786  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
[70]787}
788
789#D-#==================================================
790#D-function IGCM_sys_Cp
791#D-* Purpose: generic cp
792#D-* Examples:
793#D-
794function IGCM_sys_Cp {
[619]795  IGCM_debug_PushStack "IGCM_sys_Cp" $@
796  if ( $DEBUG_sys ) ; then
797    echo "IGCM_sys_Cp :" $@
798  fi
[70]799
[719]800  typeset status
[70]801
[619]802  echo cp $@ > out_rsync 2>&1
803  \cp $@ >> out_rsync 2>&1
[719]804  status=$?
[70]805
[719]806  if [ ${status} -gt 0 ] ; then
[619]807    echo "IGCM_sys_Cp : error."
808    cat out_rsync
809    IGCM_debug_Exit "IGCM_sys_Cp"
810  else
811    \rm out_rsync
812  fi
813  IGCM_debug_PopStack "IGCM_sys_Cp"
[70]814}
815
816#D-#==================================================
[92]817#D-function IGCM_sys_Rm
818#D-* Purpose: generic rm
819#D-* Examples:
820#D-
821function IGCM_sys_Rm {
[619]822  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
823  if ( $DEBUG_sys ) ; then
824    echo "IGCM_sys_Rm :" $@
825  fi
[92]826
[719]827  typeset status
[92]828
[619]829  echo rm $@ > out_rsync 2>&1
830  \rm $@ >> out_rsync 2>&1
[719]831  status=$?
[92]832
[719]833  if [ ${status} -gt 0 ] ; then
[619]834    echo "IGCM_sys_Rm : error."
835    cat out_rsync
836    IGCM_debug_Exit "IGCM_sys_Rm"
837  else
838    \rm out_rsync
839  fi
840  IGCM_debug_PopStack "IGCM_sys_Rm"
[92]841}
842
843#D-#==================================================
[203]844#D-function IGCM_sys_RmRunDir
845#D-* Purpose: rm tmpdir (dummy function most of the time batch
846#D-                      scheduler will do the job)
847#D-* Examples:
848#D-
849function IGCM_sys_RmRunDir {
[619]850  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
851  if ( $DEBUG_sys ) ; then
852    echo "IGCM_sys_RmRunDir :" $@
853    echo "Dummy call, let the scheduler do that."
854  fi
855  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
[203]856}
857
858#D-#==================================================
[70]859#D-function IGCM_sys_Mv
860#D-* Purpose: generic move
861#D-* Examples:
862#D-
863function IGCM_sys_Mv {
[619]864  IGCM_debug_PushStack "IGCM_sys_Mv" $@
865  if ( $DEBUG_sys ) ; then
866    echo "IGCM_sys_Mv :" $@
867  fi
[70]868
[619]869  if [ $DRYRUN = 0 ]; then
[70]870
[719]871    typeset status
[619]872
873    echo mv $@ > out_rsync 2>&1
874    \mv $@ >> out_rsync 2>&1
[719]875    status=$?
[619]876
[719]877    if [ ${status} -gt 0 ] ; then
[619]878      echo "IGCM_sys_Mv : error in mv."
879      cat out_rsync
880      IGCM_debug_Exit "IGCM_sys_Mv"
[173]881    else
[619]882      \rm out_rsync
[70]883    fi
[619]884  else
885    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
886  fi
[70]887
[619]888  IGCM_debug_PopStack "IGCM_sys_Mv"
[70]889}
890
891#D-#==================================================
892#D-function IGCM_sys_Put_Dir
893#D-* Purpose: Copy a complete directory on $(ARCHIVE)
894#D-* Examples:
895#D-
896function IGCM_sys_Put_Dir {
[619]897  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
898  if ( $DEBUG_sys ) ; then
899    echo "IGCM_sys_Put_Dir :" $@
900  fi
901  if [ $DRYRUN = 0 ]; then
902    if [ ! -d ${1} ] ; then
903      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
904      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
905      return
[70]906    fi
907
[719]908    typeset status
[70]909
[619]910    # Only if we use rsync
911    #IGCM_sys_TestDirArchive $( dirname $2 )
912    #
913    #USUAL WAY
914    rcp -r $1 ${STOREHOST}:$2 > out_rsync 2>&1
[719]915    status=$?
[70]916
[719]917    if [ ${status} -gt 0 ] ; then
[619]918      echo "IGCM_sys_Put_Dir : error."
919      cat out_rsync
920      IGCM_debug_Exit "IGCM_sys_Put_Dir"
[70]921    else
[619]922      \rm out_rsync
[70]923    fi
[619]924  else
925    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
926  fi
927  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
[70]928}
929
930#D-#==================================================
931#D-function IGCM_sys_Get_Dir
932#D-* Purpose: Copy a complete directory from $(ARCHIVE)
933#D-* Examples:
934#D-
935function IGCM_sys_Get_Dir {
[619]936  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
937  if ( $DEBUG_sys ) ; then
938    echo "IGCM_sys_Get_Dir :" $@
939  fi
940  if [ $DRYRUN = 0 ]; then
941    if [ ! -d ${1} ] ; then
942      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
943      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
944      return
[70]945    fi
946
[719]947    typeset status
[70]948
[619]949        #USUAL WAY
950    rcp -rp ${STOREHOST}:$1 $2 > out_rsync 2>&1
[719]951    status=$?
[70]952
[719]953    if [ ${status} -gt 0 ] ; then
[619]954      echo "IGCM_sys_Get_Dir : error."
955      cat out_rsync
956      IGCM_debug_Exit "IGCM_sys_Get_Dir"
[70]957    fi
[619]958  else
959    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
960  fi
961  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
[70]962}
963
[689]964#====================================================
965#- Call IGCM_sys_Mirror_libIGCM now !
966if ( $MirrorlibIGCM ) ; then
967  IGCM_sys_Mirror_libIGCM
968fi
969
[70]970#D-#==================================================
971#D-function IGCM_sys_Put_Rest
972#D-* Purpose: Put computied restarts on $(ARCHIVE).
973#D-           File and target directory must exist.
974#D-* Examples:
975#D-
976function IGCM_sys_Put_Rest {
[619]977  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
978  if ( $DEBUG_sys ) ; then
979    echo "IGCM_sys_Put_Rest :" $@
980  fi
981  if [ $DRYRUN = 0 ]; then
982    if [ ! -f ${1} ] ; then
983      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
984      IGCM_debug_Exit "IGCM_sys_Put_Rest"
[70]985    fi
986
[719]987    typeset status
[619]988        #
989    if [ X${JobType} = XRUN ] ; then
990      IGCM_sys_Chmod 444 ${1}
991    fi
992    #
993    # Only if we use rsync
994    #IGCM_sys_MkdirArchive $( dirname $2 )
995    #
996    #USUAL WAY
997    mfput $1 $2 > out_rsync 2>&1
[719]998    status=$?
[70]999
[619]1000#       #RSYNC WITH NETWORK RSH CALL
1001#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1002#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
[70]1003
[619]1004#       #RSYNC WITH NFS USE
1005#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1006#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
[70]1007
[719]1008#       status=$?
1009#       IGCM_sys_Rsync_out $status
[70]1010
[619]1011#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
[719]1012#       (( status=status+$? ))
[619]1013
[719]1014    if [ ${status} -gt 0 ] ; then
[619]1015      echo "IGCM_sys_Put_Rest : error."
1016      cat out_rsync
1017      IGCM_debug_Exit "IGCM_sys_Put_Rest"
[70]1018    else
[619]1019      \rm out_rsync
[70]1020    fi
[619]1021  else
1022    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1023  fi
1024  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
[70]1025}
1026
1027#D-#==================================================
[619]1028#D-function IGCM_sys_PutBuffer_Rest
1029#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
1030#D-           File and target directory must exist.
1031#D-* Examples:
1032#D-
1033function IGCM_sys_PutBuffer_Rest {
1034  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
1035  if ( $DEBUG_sys ) ; then
1036    echo "IGCM_sys_PutBuffer_Rest :" $@
1037  fi
1038  if [ $DRYRUN = 0 ]; then
1039    if [ ! -f ${1} ] ; then
1040      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
1041      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1042    fi
1043
[719]1044    typeset status
[619]1045    #
1046    if [ X${JobType} = XRUN ] ; then
1047      IGCM_sys_Chmod 444 ${1}
1048    fi
1049
1050    #
1051    # USUAL WAY
1052    \cp $1 $2 > out_rsync 2>&1
[719]1053    status=$?
[619]1054
[719]1055    if [ ${status} -gt 0 ] ; then
[619]1056      echo "IGCM_sys_PutBuffer_Rest : error."
1057      cat out_rsync
1058      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1059    else
1060      \rm out_rsync
1061    fi
1062  else
1063    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1064  fi
1065  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
1066}
1067
1068#D-#==================================================
[70]1069#D-function IGCM_sys_Put_Out
1070#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
1071#D-* Examples:
1072#D-
1073function IGCM_sys_Put_Out {
[619]1074  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
1075  if ( $DEBUG_sys ) ; then
1076    echo "IGCM_sys_Put_Out :" $@
1077  fi
1078  if [ $DRYRUN = 0 ]; then
1079    if [ ! -f ${1} ] ; then
1080      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
1081      IGCM_debug_PopStack "IGCM_sys_Put_Out"
1082      return 1
[70]1083    fi
1084
[719]1085    typeset status
[619]1086        #
1087    if [ X${JobType} = XRUN ] ; then
1088      if [ X${3} = X ] ; then
1089        IGCM_sys_Chmod 444 ${1}
1090      fi
1091    fi
1092    #
1093    # Only if we use rsync
1094    #IGCM_sys_MkdirArchive $( dirname $2 )
1095    #
1096    #USUAL WAY
1097    mfput $1 $2 > out_rsync 2>&1
[719]1098    status=$?
[70]1099
[619]1100#       #RSYNC WITH NETWORK RSH CALL
1101#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1102#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
[70]1103
[619]1104#       #RSYNC WITH NFS USE
1105#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1106#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
[70]1107
[719]1108#       status=$?
1109#       IGCM_sys_Rsync_out $status
[70]1110
[619]1111#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
[719]1112#       (( status=status+$? ))
[70]1113
[719]1114    if [ ${status} -gt 0 ] ; then
[619]1115      echo "IGCM_sys_Put_Out : error."
1116      cat out_rsync
1117      IGCM_debug_Exit "IGCM_sys_Put_Out"
[70]1118    else
[619]1119      \rm out_rsync
[70]1120    fi
[619]1121    IGCM_sys_Rm out_rsync
1122  else
1123    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1124  fi
1125  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1126  return 0
[70]1127}
1128
1129#D-#==================================================
[619]1130#D-function IGCM_sys_PutBuffer_Out
1131#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1132#D-* Examples:
1133#D-
1134function IGCM_sys_PutBuffer_Out {
1135  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1136  if ( $DEBUG_sys ) ; then
1137    echo "IGCM_sys_PutBuffer_Out :" $@
1138  fi
1139  if [ $DRYRUN = 0 ]; then
1140    if [ ! -f ${1} ] ; then
1141      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1142      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1143      return 1
1144    fi
1145    #
1146    IGCM_sys_Mkdir $( dirname $2 )
1147    #
[719]1148    typeset status
[619]1149
1150    if [ X${JobType} = XRUN ] ; then
1151      if [ X${3} = X ] ; then
1152        IGCM_sys_Chmod 444 ${1}
1153      fi
1154    fi
1155    #
1156    # USUAL WAY
1157    \cp $1 $2 > out_rsync 2>&1
[719]1158    status=$?
[619]1159
[719]1160    if [ ${status} -gt 0 ] ; then
[619]1161      echo "IGCM_sys_PutBuffer_Out : error."
1162      cat out_rsync
1163      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1164    else
1165      \rm out_rsync
1166    fi
1167  else
1168    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1169  fi
1170  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1171  return 0
1172}
1173
1174#D-#==================================================
[70]1175#D-function IGCM_sys_Get
1176#D-* Purpose: Get a file from ${ARCHIVE}
1177#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1178#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1179function IGCM_sys_Get {
[619]1180  IGCM_debug_PushStack "IGCM_sys_Get" $@
[70]1181
[719]1182  typeset DEST status dm_liste ifile target
[70]1183
[619]1184  if ( $DEBUG_sys ) ; then
1185    echo "IGCM_sys_Get :" $@
1186  fi
1187  if [ $DRYRUN -le 2 ]; then
1188    if [ X${1} = X'/l' ] ; then
1189      # test if the first file is present in the old computation :
1190      eval set +A dm_liste \${${2}}
1191    else
1192      dm_liste=${1}
[70]1193    fi
[619]1194    eval DEST=\${${#}}
[70]1195
[619]1196    # test if the (first) file is present in the old computation :
1197    IGCM_sys_TestFileArchive ${dm_liste[0]}
[719]1198    status=$?
1199    if [ ${status} -gt 0 ] ; then
[619]1200      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1201      IGCM_debug_Exit "IGCM_sys_Get"
1202      return
1203    fi
[70]1204
[619]1205    # SD : dm_liste is not suited for computing job
1206    #      because we change filename during transfert
1207    #      dm_liste is better suited for post-treatment
1208    #dm_liste=" "
1209    #(( ifile=1 ))
1210    #while [ $ifile -lt $# ] ; do
1211    #    dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} )
1212    #    (( ifile = ifile + 1 ))
1213    #done
1214    #DEST=$( eval echo \${${#}} )
[70]1215
[619]1216    #USUAL WAY
1217    mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1
[719]1218    status=$?
[70]1219
[619]1220#       #RSYNC WITH NETWORK RSH CALL
1221#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1222#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
[70]1223
[619]1224#       #RSYNC WITH NFS USE
1225#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1226#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
[70]1227
[719]1228#       status=$?
1229#       IGCM_sys_Rsync_out $status
[70]1230
[619]1231#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
[719]1232#       (( status=status+$? ))
[70]1233
[719]1234    if [ ${status} -gt 0 ] ; then
[619]1235      echo "IGCM_sys_Get : copy error."
1236      cat out_rsync
1237      IGCM_debug_Exit "IGCM_sys_Get"
[70]1238    else
[619]1239      \rm out_rsync
[70]1240    fi
[619]1241  else
1242    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1243  fi
1244  IGCM_debug_PopStack "IGCM_sys_Get"
[70]1245}
1246
[619]1247#D-#==================================================
1248#D-function IGCM_sys_GetBuffer
1249#D-* Purpose: Get a file from ${SCRATCHDIR}
1250#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1251#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1252function IGCM_sys_GetBuffer {
1253  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1254
[719]1255  typeset DEST status buf_liste ifile target file_work
[619]1256
1257  if ( $DEBUG_sys ) ; then
1258    echo "IGCM_sys_GetBuffer :" $@
1259  fi
1260  if [ $DRYRUN -le 2 ]; then
1261    if [ X${1} = X'/l' ] ; then
1262      # test if the first file is present in the old computation :
1263      eval set +A buf_liste \${${2}}
1264    else
1265      eval set +A buf_liste ${1}
1266    fi
1267    eval DEST=\${${#}}
1268
1269    #USUAL WAY
1270    if [ X${1} = X'/l' ] ; then
[719]1271      (( status=0 ))
[619]1272      for target in ${buf_liste[*]} ; do
1273        local_file=$( basename ${target} )
1274        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
[719]1275        (( status = status + $? ))
[619]1276      done
1277    else
1278      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
[719]1279      status=$?
[619]1280    fi
1281
[719]1282    if [ ${status} -gt 0 ] ; then
[619]1283      echo "IGCM_sys_GetBuffer : copy error."
1284      cat out_rsync
1285      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1286    else
1287      \rm out_rsync
1288    fi
1289  else
1290    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1291  fi
1292  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1293}
1294
[70]1295############################################################## A FINIR !!
1296
1297#D-#==================================================
1298#D-function IGCM_sys_GetDate_FichWork
1299#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1300#D-* Examples:
1301#D-
1302function IGCM_sys_GetDate_FichWork {
[619]1303  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1304  if ( $DEBUG_sys ) ; then
1305    echo "IGCM_sys_GetDate_FichWork :" $@
1306  fi
1307  typeset dateF
1308  set +A dateF -- $( rsh ${MASTER} -n /opt/freeware/bin/ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1309  eval ${2}=${dateF[5]}
[537]1310
[619]1311  # donne la date filesys d'un fichier sur la machine work
1312  IGCM_debug_PopStack "IGCM_sys_FichWork"
[70]1313}
1314
1315#D-#==================================================
1316#D-function IGCM_sys_GetDate_FichArchive
[619]1317#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
[70]1318#D-* Examples:
1319#D-
1320function IGCM_sys_GetDate_FichArchive {
[619]1321  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1322  if ( $DEBUG_sys ) ; then
1323    echo "IGCM_sys_GetDate_FichArchive :" $@
1324  fi
1325  typeset dateF
1326  set +A dateF -- $( rsh ${STOREHOST} -n ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1327  eval ${2}=${dateF[5]}
[537]1328
[619]1329  IGCM_debug_PopStack "IGCM_sys_FichArchive"
[70]1330}
1331
1332##############################################################
1333# REBUILD OPERATOR
1334
1335function IGCM_sys_rebuild {
[619]1336  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1337  if ( $DEBUG_sys ) ; then
1338    echo "IGCM_sys_rebuild :" $@
1339  fi
1340  /homegpfs/rech/psl/rpsl035/bin/rebuild -f -o $@
1341  if [ $? -gt 0 ] ; then
1342    echo "IGCM_sys_rebuild : erreur ${@}."
1343    IGCM_debug_Exit "rebuild"
1344  fi
[70]1345
[619]1346  IGCM_debug_PopStack "IGCM_sys_rebuild"
[70]1347}
1348
[697]1349function IGCM_sys_rebuild_station {
1350  IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@
1351  typeset i list_opt file_in file_out prefix_invert list_invert
1352  if ( $DEBUG_sys ) ; then
1353    echo "IGCM_sys_rebuild_station :" $@
1354  fi
1355  list_opt=$@
1356
1357  # Invert Axis : t,x -> x,t
1358  #               t,pres,x -> x,t,pres
1359  # So that we can concatenate along x
1360  i=0
1361  for file_in in ${list_opt} ; do
1362    (( i = i + 1))
1363    [ ${i} = 1 ] && file_out=${file_in} && continue
1364    prefix_invert=$( basename ${file_in} .nc )
1365    IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc
1366    list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc
1367  done
1368
1369  # Concatenate
1370  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc
1371
1372  # Re-ivert file
1373  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}
1374
1375  # Station re-ordering is too expansive to be run within libICGM
1376  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.
1377  # This re-ordering must be done "in memory" by the cmorization process
1378  # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)
1379  # BEGIN reordering
1380
1381  # Only LMDZ text output contains the exact ordering of the station.
1382  # We isolate this in the code below:
1383  #  0  38  -157.5000000000000  70.98591549295774
1384  #  0  54  27.49999999999999   67.18309859154928
1385  #  0  56  -62.50000000000001  82.39436619718309
1386  #  0  79  12.49999999999999   78.59154929577466
1387  #  0  116 -165.0000000000000  76.05633802816901
1388  #  0  117 130.0000000000000   70.98591549295774
1389  #  0  118 110.0000000000000   87.46478873239437
1390  #  1  40  4.999999999999995   51.97183098591550
1391#  typeset iStation iProc list_opt file_in file_out prefix_invert
1392#  typeset -Z4 j4
1393#  typeset -Z3 j3
1394
1395#  unset list_opt
1396#  set +A list_opt $@
1397
1398  # Filename after rebuild
1399#  file_out=${list_opt[0]}
1400  # Prefix of output files
1401#  prefix_invert=$( basename ${file_out} .nc )
1402  # Number of procs
1403#  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )
1404
1405#  iProc=0
1406#  while [ ${iProc} -lt ${num_proc} ] ; do
1407    # Array containing Station as a number
1408#    unset proc_stn
1409#    set +A proc_stn $( grep "iophy_mpi rank ip lon lat  $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | awk ' {print $2}' )
1410    # Number of stations produced by processor proc
1411#    stationLast=${#proc_stn[*]}
1412    # Proc number on 4 digits
1413#    j4=${iProc}
1414    # Init
1415#    iStation=0
1416#    while [ ${iStation} -lt ${stationLast} ] ; do
1417      # Station number on 3 digits
1418#      j3=${proc_stn[${iStation}]}
1419      # Extract station
1420      # Invert Axis : t,x -> x,t
1421      #               t,pres,x -> x,t,pres
1422      # So that we can concatenate along x
1423#      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc
1424#      (( iStation = iStation + 1 ))
1425#    done
1426#    (( iProc = iProc + 1 ))
1427#  done
1428
1429  # Concatenate all station along x
1430#  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc
1431
1432  # Re-invert file
1433#  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}
1434
1435  # END reordering
1436
1437  IGCM_debug_PopStack "IGCM_sys_rebuild_station"
1438}
1439
[70]1440############################################################
1441# Activate Running Environnment Variables
1442
1443function IGCM_sys_activ_variables {
[619]1444  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1445  if ( $DEBUG_sys ) ; then
1446    echo "IGCM_sys_activ_variables "
1447  fi
[70]1448
1449# --------------------------------------------------------------------
[688]1450#D- OpenMP thread memory specifications : only one time
[70]1451# --------------------------------------------------------------------
[688]1452echo $XLSMPOPTS | grep stack=524288000 1>/dev/null 2>&1 || export XLSMPOPTS=$XLSMPOPTS:stack=524288000
[70]1453
1454# --------------------------------------------------------------------
1455#D- Other specifications
1456# --------------------------------------------------------------------
1457
[619]1458  IGCM_debug_PopStack "IGCM_sys_activ_variables"
[70]1459
1460}
1461
1462############################################################
1463# Desactivate Running Environnment Variables
1464
1465function IGCM_sys_desactiv_variables {
[619]1466  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1467  if ( $DEBUG_sys ) ; then
1468    echo "IGCM_sys_desactiv_variables "
1469  fi
[70]1470# --------------------------------------------------------------------
1471#D- MPI specifications
1472# --------------------------------------------------------------------
1473
1474# --------------------------------------------------------------------
1475#D- Other specifications
1476# --------------------------------------------------------------------
1477
[619]1478  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1479
[70]1480}
1481
1482############################################################
[619]1483# Build MPI/OMP scripts
1484function IGCM_sys_build_execution_scripts
1485{
1486  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1487  if ( $DEBUG_sys ) ; then
1488    echo "IGCM_sys_build_execution_scripts " $@
1489  fi
[70]1490
[619]1491  typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count
1492
1493  if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
1494    IGCM_debug_Exit "IGCM_sys_vargas build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
1495  fi
1496
1497  if ( ${OK_PARA_MPMD} ) ; then
1498
1499    if [ -f run_file ] ; then
1500      IGCM_sys_Rm -f run_file
1501    fi
1502    touch run_file
1503
1504    if ( ${OK_PARA_OMP} ) ; then
1505# NEW : 2 Noeuds
1506# @ task_geometry={(0)(1,2,3)}
1507# Nombre de processus demandes
1508      echo "Job_${config_UserChoices_JobName} includes task_geometry = \c"
1509      cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g"
1510      echo "Job_${config_UserChoices_JobName} includes task_geometry  with NbNodes = \c"
1511      cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c
1512      NbNodes_Job=$(( $( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c ) - 1 ))
1513
1514      if [ ${NbNodes_Job} -eq 0 ] ; then
1515        IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no task_geometry defined with OpenMP run."
1516        exit 1
1517      fi
1518    else
1519
1520# OLD :
1521# @ total_tasks = 3
1522# @ environment = "BATCH_NUM_PROC_TOT=3"
1523# Pas d OpenMP
1524# @ resources = ConsumableCpus(1)
1525
1526      echo "Job_${config_UserChoices_JobName} includes total_tasks = \c"
1527      cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //"
1528      NbProc_Job=$( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" )
1529      NbProc_Job=${NbProc_Job:=0}
1530      if [ ${NbProc_Job} -eq 0 ] ; then
1531        IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no total_tasks defined with MPI only run."
1532        exit 1
1533      fi
1534      if ( $( egrep '^# *@ *resources *= *ConsumableCpus\(1\)' ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} >/dev/null 2>&1 ) ) ; then
1535        IGCM_debug_Print 2 "ressources =  ConsumableCpus(1) line found into Job_${config_UserChoices_JobName}"
1536      else
1537        IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources = line not found. Job should include resources = ConsumableCpus(1) "
1538        exit 1
1539      fi
1540    fi
1541
1542# run_file construction
1543
1544# Then first loop on the components for the coupler ie oasis
1545
1546### the coupler ie oasis must be the first one
1547    for comp in ${config_ListOfComponents[*]} ; do
1548
1549      eval ExeNameIn=\${config_Executable_${comp}[0]}
1550      eval ExeNameOut=\${config_Executable_${comp}[1]}
1551
1552      # for CPL component only
1553      if [ "X${comp}" = "XCPL" ] ; then
1554
1555        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1556        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1557
1558        if ( ${OK_PARA_MPI} ) ; then
1559
1560          (( mpi_count = 1 ))
1561          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1562            if ( ${OK_PARA_OMP} ) ; then
1563              echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1564            else
1565              echo "./${ExeNameOut}" >> run_file
1566            fi
1567            (( mpi_count = mpi_count + 1 ))
1568          done
1569        else
1570          if ( ${OK_PARA_OMP} ) ; then
1571            echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1572          else
1573            echo "./${ExeNameOut} " >> run_file
1574          fi
1575        fi
1576      fi
1577    done
1578
1579# Then second loop on the components
1580
1581    for comp in ${config_ListOfComponents[*]} ; do
1582
1583      eval ExeNameIn=\${config_Executable_${comp}[0]}
1584      eval ExeNameOut=\${config_Executable_${comp}[1]}
1585
1586      # Only if we really have an executable for the component and not the coupler ie oasis:
1587      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1588
1589        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1590        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1591
1592        if ( ${OK_PARA_MPI} ) ; then
1593
1594          (( mpi_count = 1 ))
1595          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1596            if ( ${OK_PARA_OMP} ) ; then
1597              echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1598            else
1599              echo "./${ExeNameOut}" >> run_file
1600            fi
1601            (( mpi_count = mpi_count + 1 ))
1602          done
1603        else
1604          if ( ${OK_PARA_OMP} ) ; then
1605            echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1606          else
1607                    # to be tested : no MPI only OpenMP into MPMD mode
1608            echo "./${ExeNameOut} " >> run_file
1609          fi
1610        fi
1611      fi
1612    done
1613
1614    EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file"
1615
1616    IGCM_sys_Chmod u+x run_file
[70]1617    if ( $DEBUG_sys ) ; then
[619]1618      echo "run_file contains : "
1619      cat run_file
[70]1620    fi
[395]1621
[619]1622  else # Only one executable. launch it.
[395]1623
[619]1624    for comp in ${config_ListOfComponents[*]} ; do
[395]1625
[619]1626      eval ExeNameIn=\${config_Executable_${comp}[0]}
1627      eval ExeNameOut=\${config_Executable_${comp}[1]}
[70]1628
[664]1629      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
1630        EXECUTION="time ./${ExeNameOut}"
1631      fi
[70]1632
[619]1633    done
[395]1634
[619]1635  fi
1636
1637  IGCM_debug_Print 1 "sys vargas : execution command is "
1638  IGCM_debug_Print 1 "$EXECUTION"
1639
1640  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
[70]1641}
[619]1642
1643function IGCM_sys_build_run_file {
1644
1645  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1646
1647}
[651]1648
1649############################################################
1650# Check of space available on temporary filesytems
1651function IGCM_sys_check_quota {
1652  IGCM_debug_PushStack "IGCM_sys_check_quota" 
1653  if ( $DEBUG_sys ) ; then
1654    echo "IGCM_sys_check_quota "
1655  fi
1656  # Limit of quota (in %)
1657  limit_quota=90
1658  # Check of the volume
1659  volume_quota=$(quota_u -w | grep 'Quota soft' | awk '{print $5}')
1660  if [ ! X${volume_quota} = X ] ; then
1661    quota_volume=${volume_quota%%\%}
1662#    echo $quota_volume
1663    if [ ${quota_volume} -ge ${limit_quota} ] ; then
[654]1664      IGCM_debug_Print 1 "Please, check your quota of volume on workgpfs"
1665      IGCM_debug_Print 1 "${quota_volume}% of your quota is used"
1666      IGCM_debug_Print 1 "Use the quota_u -w command to check"
[651]1667      IGCM_debug_Print 1 "You must have more than 10% available to run"
1668      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
1669      IGCM_debug_Verif_Exit
1670    fi
1671
1672  fi
1673  IGCM_debug_PopStack "IGCM_sys_check_quota"
1674}
[768]1675
1676#D-#==================================================
1677#D-function IGCM_sys_CountJobInQueue
1678#D-* Purpose: Check if job_name is currently
1679#D-  running or in queue
1680#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
1681#D-
1682
1683function IGCM_sys_CountJobInQueue {
1684  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
1685  if ( $DEBUG_sys ) ; then
1686    echo "IGCM_sys_CountJobInQueue"
1687  fi
1688
1689  # Print only the full (-W) JobName (%jn)
1690  NbRun=$( llq -W -f %jn | grep -c "$1" )
1691
1692  eval ${2}=${NbRun}
1693
1694  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
1695}
Note: See TracBrowser for help on using the repository browser.