source: tags/libIGCM_v2.0_beta4/libIGCM_sys/libIGCM_sys_vargas.ksh @ 1636

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