source: branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_mercurex9.ksh @ 593

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

Second merge of libIGCM_MPI_OpenMP branch with libIGCM trunk, revision 591.

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