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

Last change on this file since 637 was 637, checked in by mafoipsl, 12 years ago

Allow different number of proc on titane, vargas and curie. Add default porject number in SE_Checker.

  • Property svn:keywords set to Revision Author Date
File size: 45.3 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(( 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#====================================================
785#- Call IGCM_sys_Mirror_libIGCM now !
786if ( $MirrorlibIGCM ) ; then
787  IGCM_sys_Mirror_libIGCM
788fi
789
790#D-#==================================================
791#D-function IGCM_sys_Cp
792#D-* Purpose: generic cp
793#D-* Examples:
794#D-
795function IGCM_sys_Cp {
796  IGCM_debug_PushStack "IGCM_sys_Cp" $@
797  if ( $DEBUG_sys ) ; then
798    echo "IGCM_sys_Cp :" $@
799  fi
800
801  typeset RET
802
803  echo cp $@ > out_rsync 2>&1
804  \cp $@ >> out_rsync 2>&1
805  RET=$?
806
807  if [ ${RET} -gt 0 ] ; then
808    echo "IGCM_sys_Cp : error."
809    cat out_rsync
810    IGCM_debug_Exit "IGCM_sys_Cp"
811  else
812    \rm out_rsync
813  fi
814  IGCM_debug_PopStack "IGCM_sys_Cp"
815}
816
817#D-#==================================================
818#D-function IGCM_sys_Rm
819#D-* Purpose: generic rm
820#D-* Examples:
821#D-
822function IGCM_sys_Rm {
823  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
824  if ( $DEBUG_sys ) ; then
825    echo "IGCM_sys_Rm :" $@
826  fi
827
828  typeset RET
829
830  echo rm $@ > out_rsync 2>&1
831  \rm $@ >> out_rsync 2>&1
832  RET=$?
833
834  if [ ${RET} -gt 0 ] ; then
835    echo "IGCM_sys_Rm : error."
836    cat out_rsync
837    IGCM_debug_Exit "IGCM_sys_Rm"
838  else
839    \rm out_rsync
840  fi
841  IGCM_debug_PopStack "IGCM_sys_Rm"
842}
843
844#D-#==================================================
845#D-function IGCM_sys_RmRunDir
846#D-* Purpose: rm tmpdir (dummy function most of the time batch
847#D-                      scheduler will do the job)
848#D-* Examples:
849#D-
850function IGCM_sys_RmRunDir {
851  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
852  if ( $DEBUG_sys ) ; then
853    echo "IGCM_sys_RmRunDir :" $@
854    echo "Dummy call, let the scheduler do that."
855  fi
856  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
857}
858
859#D-#==================================================
860#D-function IGCM_sys_Mv
861#D-* Purpose: generic move
862#D-* Examples:
863#D-
864function IGCM_sys_Mv {
865  IGCM_debug_PushStack "IGCM_sys_Mv" $@
866  if ( $DEBUG_sys ) ; then
867    echo "IGCM_sys_Mv :" $@
868  fi
869
870  if [ $DRYRUN = 0 ]; then
871
872    typeset RET
873
874    echo mv $@ > out_rsync 2>&1
875    \mv $@ >> out_rsync 2>&1
876    RET=$?
877
878    if [ ${RET} -gt 0 ] ; then
879      echo "IGCM_sys_Mv : error in mv."
880      cat out_rsync
881      IGCM_debug_Exit "IGCM_sys_Mv"
882    else
883      \rm out_rsync
884    fi
885  else
886    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
887  fi
888
889  IGCM_debug_PopStack "IGCM_sys_Mv"
890}
891
892#D-#==================================================
893#D-function IGCM_sys_Put_Dir
894#D-* Purpose: Copy a complete directory on $(ARCHIVE)
895#D-* Examples:
896#D-
897function IGCM_sys_Put_Dir {
898  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
899  if ( $DEBUG_sys ) ; then
900    echo "IGCM_sys_Put_Dir :" $@
901  fi
902  if [ $DRYRUN = 0 ]; then
903    if [ ! -d ${1} ] ; then
904      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
905      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
906      return
907    fi
908
909    typeset RET
910
911    # Only if we use rsync
912    #IGCM_sys_TestDirArchive $( dirname $2 )
913    #
914    #USUAL WAY
915    rcp -r $1 ${STOREHOST}:$2 > out_rsync 2>&1
916    RET=$?
917
918    if [ ${RET} -gt 0 ] ; then
919      echo "IGCM_sys_Put_Dir : error."
920      cat out_rsync
921      IGCM_debug_Exit "IGCM_sys_Put_Dir"
922    else
923      \rm out_rsync
924    fi
925  else
926    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
927  fi
928  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
929}
930
931#D-#==================================================
932#D-function IGCM_sys_Get_Dir
933#D-* Purpose: Copy a complete directory from $(ARCHIVE)
934#D-* Examples:
935#D-
936function IGCM_sys_Get_Dir {
937  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
938  if ( $DEBUG_sys ) ; then
939    echo "IGCM_sys_Get_Dir :" $@
940  fi
941  if [ $DRYRUN = 0 ]; then
942    if [ ! -d ${1} ] ; then
943      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
944      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
945      return
946    fi
947
948    typeset RET
949
950        #USUAL WAY
951    rcp -rp ${STOREHOST}:$1 $2 > out_rsync 2>&1
952    RET=$?
953
954    if [ ${RET} -gt 0 ] ; then
955      echo "IGCM_sys_Get_Dir : error."
956      cat out_rsync
957      IGCM_debug_Exit "IGCM_sys_Get_Dir"
958    fi
959  else
960    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
961  fi
962  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
963}
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
1344############################################################
1345# Activate Running Environnment Variables
1346
1347function IGCM_sys_activ_variables {
1348  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1349  if ( $DEBUG_sys ) ; then
1350    echo "IGCM_sys_activ_variables "
1351  fi
1352
1353# --------------------------------------------------------------------
1354#D- MPI specifications
1355# --------------------------------------------------------------------
1356
1357# --------------------------------------------------------------------
1358#D- Other specifications
1359# --------------------------------------------------------------------
1360
1361  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1362
1363}
1364
1365############################################################
1366# Desactivate Running Environnment Variables
1367
1368function IGCM_sys_desactiv_variables {
1369  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1370  if ( $DEBUG_sys ) ; then
1371    echo "IGCM_sys_desactiv_variables "
1372  fi
1373# --------------------------------------------------------------------
1374#D- MPI specifications
1375# --------------------------------------------------------------------
1376
1377# --------------------------------------------------------------------
1378#D- Other specifications
1379# --------------------------------------------------------------------
1380
1381  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1382
1383}
1384
1385############################################################
1386# Build MPI/OMP scripts
1387function IGCM_sys_build_execution_scripts
1388{
1389  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1390  if ( $DEBUG_sys ) ; then
1391    echo "IGCM_sys_build_execution_scripts " $@
1392  fi
1393
1394  typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count
1395
1396  if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
1397    IGCM_debug_Exit "IGCM_sys_vargas build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
1398  fi
1399
1400  if ( ${OK_PARA_MPMD} ) ; then
1401
1402    if [ -f run_file ] ; then
1403      IGCM_sys_Rm -f run_file
1404    fi
1405    touch run_file
1406
1407    if ( ${OK_PARA_OMP} ) ; then
1408# NEW : 2 Noeuds
1409# @ task_geometry={(0)(1,2,3)}
1410# Nombre de processus demandes
1411      echo "Job_${config_UserChoices_JobName} includes task_geometry = \c"
1412      cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g"
1413      echo "Job_${config_UserChoices_JobName} includes task_geometry  with NbNodes = \c"
1414      cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c
1415      NbNodes_Job=$(( $( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c ) - 1 ))
1416
1417      if [ ${NbNodes_Job} -eq 0 ] ; then
1418        IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no task_geometry defined with OpenMP run."
1419        exit 1
1420      fi
1421    else
1422
1423# OLD :
1424# @ total_tasks = 3
1425# @ environment = "BATCH_NUM_PROC_TOT=3"
1426# Pas d OpenMP
1427# @ resources = ConsumableCpus(1)
1428
1429      echo "Job_${config_UserChoices_JobName} includes total_tasks = \c"
1430      cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //"
1431      NbProc_Job=$( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" )
1432      NbProc_Job=${NbProc_Job:=0}
1433      if [ ${NbProc_Job} -eq 0 ] ; then
1434        IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no total_tasks defined with MPI only run."
1435        exit 1
1436      fi
1437      if ( $( egrep '^# *@ *resources *= *ConsumableCpus\(1\)' ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} >/dev/null 2>&1 ) ) ; then
1438        IGCM_debug_Print 2 "ressources =  ConsumableCpus(1) line found into Job_${config_UserChoices_JobName}"
1439      else
1440        IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources = line not found. Job should include resources = ConsumableCpus(1) "
1441        exit 1
1442      fi
1443    fi
1444
1445# run_file construction
1446
1447# Then first loop on the components for the coupler ie oasis
1448
1449### the coupler ie oasis must be the first one
1450    for comp in ${config_ListOfComponents[*]} ; do
1451
1452      eval ExeNameIn=\${config_Executable_${comp}[0]}
1453      eval ExeNameOut=\${config_Executable_${comp}[1]}
1454
1455      # for CPL component only
1456      if [ "X${comp}" = "XCPL" ] ; then
1457
1458        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1459        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1460
1461        if ( ${OK_PARA_MPI} ) ; then
1462
1463          (( mpi_count = 1 ))
1464          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1465            if ( ${OK_PARA_OMP} ) ; then
1466              echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1467            else
1468              echo "./${ExeNameOut}" >> run_file
1469            fi
1470            (( mpi_count = mpi_count + 1 ))
1471          done
1472        else
1473          if ( ${OK_PARA_OMP} ) ; then
1474            echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1475          else
1476            echo "./${ExeNameOut} " >> run_file
1477          fi
1478        fi
1479      fi
1480    done
1481
1482# Then second loop on the components
1483
1484    for comp in ${config_ListOfComponents[*]} ; do
1485
1486      eval ExeNameIn=\${config_Executable_${comp}[0]}
1487      eval ExeNameOut=\${config_Executable_${comp}[1]}
1488
1489      # Only if we really have an executable for the component and not the coupler ie oasis:
1490      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1491
1492        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1493        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1494
1495        if ( ${OK_PARA_MPI} ) ; then
1496
1497          (( mpi_count = 1 ))
1498          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1499            if ( ${OK_PARA_OMP} ) ; then
1500              echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1501            else
1502              echo "./${ExeNameOut}" >> run_file
1503            fi
1504            (( mpi_count = mpi_count + 1 ))
1505          done
1506        else
1507          if ( ${OK_PARA_OMP} ) ; then
1508            echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1509          else
1510                    # to be tested : no MPI only OpenMP into MPMD mode
1511            echo "./${ExeNameOut} " >> run_file
1512          fi
1513        fi
1514      fi
1515    done
1516
1517    EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file"
1518
1519    IGCM_sys_Chmod u+x run_file
1520    if ( $DEBUG_sys ) ; then
1521      echo "run_file contains : "
1522      cat run_file
1523    fi
1524
1525  else # Only one executable. launch it.
1526
1527    for comp in ${config_ListOfComponents[*]} ; do
1528
1529      eval ExeNameIn=\${config_Executable_${comp}[0]}
1530      eval ExeNameOut=\${config_Executable_${comp}[1]}
1531
1532      [ "X${ExeNameOut}" != X\"\" ] &&  EXECUTION="time ./${ExeNameOut}"
1533
1534    done
1535
1536  fi
1537
1538  IGCM_debug_Print 1 "sys vargas : execution command is "
1539  IGCM_debug_Print 1 "$EXECUTION"
1540
1541  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1542}
1543
1544function IGCM_sys_build_run_file {
1545
1546  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1547
1548}
Note: See TracBrowser for help on using the repository browser.