source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex8.ksh @ 618

Last change on this file since 618 was 618, checked in by sdipsl, 12 years ago
  • Bugfix in IGCM_sys_IsFileArchived
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Revision Author Date
File size: 41.8 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip
5# Contact: Martial.Mancip__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 SX8-R
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#D-#==================================================
174#D-function IGCM_sys_RshMaster
175#D-* Purpose: Connection to frontend machine.
176#D-* Examples:
177#D-
178function IGCM_sys_RshMaster {
179  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
180  ssh -t ${MASTER} /bin/ksh <<-EOF
181  export libIGCM=${libIGCM}
182  export DEBUG_debug=${DEBUG_debug}
183  . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
184  . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
185  ${@}
186EOF
187  if [ $? -gt 0 ] ; then
188    echo "IGCM_sys_RshMaster : erreur."
189    IGCM_debug_Exit "IGCM_sys_RshMaster"
190  fi
191  IGCM_debug_PopStack "IGCM_sys_RshMaster"
192}
193
194#D-#==================================================
195#D-function IGCM_sys_RshArchive
196#D-* Purpose: Archive rsh command
197#D-* Examples:
198#D-
199function IGCM_sys_RshArchive {
200  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
201  /bin/ksh <<-EOF
202    ${@}
203EOF
204  if [ $? -gt 0 ] ; then
205    echo "IGCM_sys_RshArchive : erreur."
206    IGCM_debug_Exit "IGCM_sys_RshArchive"
207  fi
208  IGCM_debug_PopStack "IGCM_sys_RshArchive"
209}
210
211#D-#==================================================
212#D-function IGCM_sys_RshPost
213#D-* Purpose: Post-process rsh command
214#D-* Examples:
215#D-
216function IGCM_sys_RshPost {
217  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
218  if ( $DEBUG_sys ) ; then
219    echo "IGCM_sys_RshPost :" $@
220  fi
221
222  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL
223  #cat tmp_IGCM_sys_RshPost_$$
224  # keep standard input (stdin) for the loop onto temporary file
225  cat >tmp_IGCM_sys_RshPost_$$
226
227# ============ FRONTEND START ============ #
228
229  /bin/ksh <tmp_IGCM_sys_RshPost_$$
230  if [ $? -gt 0 ] ; then
231    echo "IGCM_sys_RshPost : erreur."
232    IGCM_debug_Exit "IGCM_sys_RshPost"
233  fi
234  \rm tmp_IGCM_sys_RshPost_$$
235
236# ============ FRONTEND  END  ============ #
237
238# ============ CESIUM START ============ #
239#  typeset NB_ESSAI DELAI status i
240#  # number of tentative
241#  NB_ESSAI=10
242#  # time delay between tentative
243#  DELAI=10
244#  (( i = 0 ))
245#  while [ $i -lt $NB_ESSAI ] ; do
246#    ssh -t mercure01 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$
247#    status=$?
248#    if [ ${status} -gt 0 ]; then
249#      IGCM_debug_Print 2 "IGCM_sys_RshPost : ssh failed ${i}/${NB_ESSAI}"
250#      IGCM_debug_Print 2 "IGCM_sys_RshPost : sleep ${DELAI} seconds and try again."
251#      sleep $DELAI
252#    else
253#      break
254#    fi
255#    (( i = i + 1 ))
256#  done
257#  # delete temporary file
258#  /bin/rm tmp_IGCM_sys_RshPost_$$
259# ============ CESIUM  END  ============ #
260
261  IGCM_debug_PopStack "IGCM_sys_RshPost"
262}
263
264#D-#==================================================
265#D-function IGCM_sys_SendMail
266#D-* Purpose: Send mail when simulation is over
267#D-* Examples:
268#D-
269function IGCM_sys_SendMail {
270  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
271  if ( $DEBUG_sys ) ; then
272    echo "IGCM_sys_SendMail :" $@
273  fi
274
275  if ( ${ExitFlag} ) ; then
276    status=failed
277  else
278    status=completed
279  fi
280  cat  << END_MAIL > job_end.mail
281  Dear ${LOGIN},
282
283  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
284  Job started : ${DateBegin}
285  Job ended   : ${DateEnd}
286  Output files are available in ${R_SAVE}
287  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
288END_MAIL
289
290  if  [ X"${config_UserChoices_MailName}" != X ] ; then
291    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail
292  elif [ -f ~/.forward ] ; then
293    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
294  else
295    mailx -s "${config_UserChoices_JobName} ${status}" ${LOGIN} < job_end.mail
296  fi
297
298  if [ $? -gt 0 ] ; then
299    echo "IGCM_sys_SendMail : erreur."
300    IGCM_debug_Exit "IGCM_sys_SendMail"
301  fi
302  IGCM_debug_PopStack "IGCM_sys_SendMail"
303}
304
305#D-#==================================================
306#D-function IGCM_sys_Mkdir
307#D-* Purpose: Master locale mkdir command
308#D-* Examples:
309#D-
310function IGCM_sys_Mkdir {
311  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
312  if ( $DEBUG_sys ) ; then
313    echo "IGCM_sys_Mkdir :" $@
314  fi
315  if [ ! -d ${1} ]; then
316    \mkdir -p $1
317    if [ $? -gt 0 ] ; then
318      echo "IGCM_sys_Mkdir : erreur."
319      IGCM_debug_Exit "IGCM_sys_Mkdir"
320    fi
321  fi
322  # vérification :
323  if [ ! -d ${1} ] ; then
324    echo "IGCM_sys_Mkdir : erreur."
325    IGCM_debug_Exit "IGCM_sys_Mkdir"
326  fi
327  IGCM_debug_PopStack "IGCM_sys_Mkdir"
328}
329
330#D-#==================================================
331#D-function IGCM_sys_MkdirArchive
332#D-* Purpose: Mkdir on Archive
333#D-* Examples:
334#D-
335function IGCM_sys_MkdirArchive {
336  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
337  if ( $DEBUG_sys ) ; then
338    echo "IGCM_sys_MkdirArchive :" $@
339  fi
340  #- creation de repertoire sur le serveur fichier
341  if [ ! -d ${1} ]; then 
342    \mkdir -p $1
343    if [ $? -gt 0 ] ; then
344      echo "IGCM_sys_MkdirArchive : erreur."
345      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
346    fi
347  fi
348  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
349}
350
351#D-#==================================================
352#D-function IGCM_sys_MkdirWork
353#D-* Purpose: Mkdir on Work
354#D-* Examples:
355#D-
356function IGCM_sys_MkdirWork {
357  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
358  if ( $DEBUG_sys ) ; then
359    echo "IGCM_sys_MkdirWork :" $@
360  fi
361  #- creation de repertoire sur le serveur fichier
362  if [ ! -d ${1} ]; then 
363    \mkdir -p $1
364    if [ $? -gt 0 ] ; then
365      echo "IGCM_sys_MkdirWork : erreur."
366      IGCM_debug_Exit "IGCM_sys_MkdirWork"
367    fi
368  fi
369  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
370}
371
372#D-#==================================================
373#D-function IGCM_sys_Cd
374#D-* Purpose: master cd command
375#D-* Examples:
376#D-
377function IGCM_sys_Cd {
378  IGCM_debug_PushStack "IGCM_sys_Cd" $@
379  if ( $DEBUG_sys ) ; then
380    echo "IGCM_sys_Cd :" $@
381  fi
382  \cd $1
383  if [ $? -gt 0 ] ; then
384    echo "IGCM_sys_Cd : erreur."
385    IGCM_debug_Exit "IGCM_sys_Cd"
386  fi
387  IGCM_debug_PopStack "IGCM_sys_Cd"
388}
389
390#D-#==================================================
391#D-function IGCM_sys_Chmod
392#D-* Purpose: Chmod
393#D-* Examples:
394#D-
395function IGCM_sys_Chmod {
396  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
397  if ( $DEBUG_sys ) ; then
398    echo "IGCM_sys_Chmod :" $@
399  fi
400  if [ $DRYRUN -le 1 ]; then
401    \chmod $@
402    if [ $? -gt 0 ] ; then
403      echo "IGCM_sys_Chmod : erreur."
404      IGCM_debug_Exit "IGCM_sys_Chmod"
405    fi
406  else
407    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
408  fi
409  IGCM_debug_PopStack "IGCM_sys_Chmod"
410}
411
412#D-#==================================================
413#D-function IGCM_sys_FileSize
414#D-* Purpose: Filesize
415#D-* Examples:
416#D-
417function IGCM_sys_FileSize {
418  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
419
420  typeset sizeF
421  set +A sizeF -- $( ls -la ${1} )
422  if [ $? -gt 0 ] ; then
423    IGCM_debug_Exit "IGCM_sys_FileSize"
424  fi
425  eval ${2}=${sizeF[4]}
426
427  IGCM_debug_PopStack "IGCM_sys_FileSize"
428}
429
430#D-#==================================================
431#D-function IGCM_sys_TestDir
432#D-* Purpose: Test Directory that must exists
433#D-* Examples:
434#D-
435function IGCM_sys_TestDir {
436  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
437  if ( $DEBUG_sys ) ; then
438    echo "IGCM_sys_TestDir :" $@
439  fi
440  typeset ExistFlag
441  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
442  IGCM_debug_PopStack "IGCM_sys_TestDir"
443
444  return ${ExistFlag}
445}
446
447#D-#==================================================
448#D-function IGCM_sys_TestDirArchive
449#D-* Purpose: Test Directory that must exists on Archive
450#D-* Examples:
451#D-
452function IGCM_sys_TestDirArchive {
453  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
454  if ( $DEBUG_sys ) ; then
455    echo "IGCM_sys_TestDirArchive :" $@
456  fi
457  typeset ExistFlag
458  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
459  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
460
461  return ${ExistFlag}
462}
463
464#D-#==================================================
465#D-function IGCM_sys_IsFileArchived
466#D-* Purpose: Test file that must NOT EXISTS on Archive
467#D-* Examples:
468#D-
469function IGCM_sys_IsFileArchived {
470  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
471  if ( $DEBUG_sys ) ; then
472    echo "IGCM_sys_IsFileArchived :" $@
473  fi
474  typeset IsArchivedFlag
475  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/ccc\/store ) != X ] && echo 0 || echo 1 )
476  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
477
478  return ${IsArchivedFlag}
479}
480
481#D-#==================================================
482#D-function IGCM_sys_TestFileArchive
483#D-* Purpose: Test file that must NOT EXISTS on Archive
484#D-* Examples:
485#D-
486function IGCM_sys_TestFileArchive {
487  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
488  if ( $DEBUG_sys ) ; then
489    echo "IGCM_sys_TestFileArchive :" $@
490  fi
491  typeset ExistFlag
492  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
493  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
494
495  return ${ExistFlag}
496}
497
498#D-#==================================================
499#D-function IGCM_sys_TestFileBuffer
500#D-* Purpose: Test file that must NOT EXISTS on Buffer
501#D-* Examples:
502#D-
503function IGCM_sys_TestFileBuffer {
504  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
505  typeset ExistFlag
506  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
507  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
508
509  return ${ExistFlag}
510}
511
512#D-#==================================================
513#D-function IGCM_sys_CountFileArchive
514#D-* Purpose: Count files on Archive filesystem
515#D-* Examples:
516#D-
517function IGCM_sys_CountFileArchive {
518  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
519  ls ${@} 2>/dev/null | wc -l
520  if [ $? -gt 0 ] ; then
521    echo "IGCM_sys_CountFileArchive : erreur."
522  fi
523  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
524}
525
526#D-#==================================================
527#D-function IGCM_sys_CountFileBuffer
528#D-* Purpose: Count files on Scratch filesystem
529#D-* Examples:
530#D-
531function IGCM_sys_CountFileBuffer {
532  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
533  ls ${@} 2>/dev/null | wc -l
534  if [ $? -gt 0 ] ; then
535    echo "IGCM_sys_CountFileBuffer : erreur."
536  fi
537  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
538}
539
540#D-#==================================================
541#D-function IGCM_sys_Tree
542#D-* Purpose: Tree directories with files on ${ARCHIVE}
543#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
544#D-
545function IGCM_sys_Tree {
546  IGCM_debug_PushStack "IGCM_sys_Tree" $@
547  if ( $DEBUG_sys ) ; then
548    echo "IGCM_sys_Tree :" $@
549  fi
550
551  \ls -lR ${@}
552
553  IGCM_debug_PopStack "IGCM_sys_Tree"
554}
555
556#D-#==================================================
557#D-function IGCM_sys_Tar
558#D-* Purpose: master tar command
559#D-* Examples:
560#D-
561function IGCM_sys_Tar {
562  IGCM_debug_PushStack "IGCM_sys_Tar" $@
563  if ( $DEBUG_sys ) ; then
564    echo "IGCM_sys_Tar :" $@
565  fi
566  \tar cf $@
567  if [ $? -gt 0 ] ; then
568    echo "IGCM_sys_Tar : erreur."
569    IGCM_debug_Exit "IGCM_sys_Tar"
570  fi
571  IGCM_debug_PopStack "IGCM_sys_Tar"
572}
573
574#D-#==================================================
575#D-function IGCM_sys_UnTar
576#D-* Purpose: master un-tar command
577#D-* Examples:
578#D-
579function IGCM_sys_UnTar {
580  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
581  if ( $DEBUG_sys ) ; then
582    echo "IGCM_sys_UnTar :" $@
583  fi
584  \tar xvf $1
585  if [ $? -gt 0 ] ; then
586    echo "IGCM_sys_UnTar : erreur."
587    IGCM_debug_Exit "IGCM_sys_UnTar"
588  fi
589  IGCM_debug_PopStack "IGCM_sys_UnTar"
590}
591
592#D-#==================================================
593#D-function IGCM_sys_Qsub
594#D-* Purpose: Qsub new job
595#D-* Examples:
596#D-
597function IGCM_sys_Qsub {
598  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
599  if ( $DEBUG_sys ) ; then
600    echo "IGCM_sys_Qsub :" $@
601  fi
602  /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1
603  if [ $? -gt 0 ] ; then
604    echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@."
605    IGCM_debug_Exit "IGCM_sys_Qsub"
606  fi
607  IGCM_debug_PopStack "IGCM_sys_Qsub"
608}
609
610#D-#==================================================
611#D-function IGCM_sys_QsubPost
612#D-* Purpose: Qsub new job on scalaire
613#D-* Examples:
614#D-
615function IGCM_sys_QsubPost {
616  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
617  if ( $DEBUG_sys ) ; then
618    echo "IGCM_sys_QsubPost :" $@
619  fi
620
621# ============ FRONTEND START ============ #
622
623  /usr/bin/nqsII/qsub -q scalaire -o ${POST_DIR}/${Script_Post_Output}.out ${libIGCM}/$1.job -v ${listVarEnv}
624
625# ============ FRONTEND  END  ============ #
626
627# ============ CESIUM START ============ #
628#  typeset NB_ESSAI DELAI status i
629#  # number of tentative
630#  NB_ESSAI=10
631#  # time delay between tentative
632#  DELAI=10
633#  (( i = 0 ))
634#  while [ $i -lt $NB_ESSAI ] ; do
635#    /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
636#    status=$?
637#    if [ ${status} -gt 0 ]; then
638#      sleep $DELAI
639#    else
640#      break
641#    fi
642#    (( i = i + 1 ))
643#  done
644# ============ CESIUM  END  ============ #
645
646  if [ $? -gt 0 ] ; then
647    echo "IGCM_sys_QsubPost : erreur " $@
648    IGCM_debug_Exit "IGCM_sys_QsubPost"
649  fi
650  IGCM_debug_PopStack "IGCM_sys_QsubPost"
651}
652
653#D-*************************
654#D- File transfer functions
655#D-*************************
656#D-
657
658#D-#==================================================
659#D-function IGCM_sys_Rsync_out
660#D-* Purpose: treat return val of rsync
661#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
662#D-  Error values and explanations can depend on your system version.
663function IGCM_sys_Rsync_out {
664  RET=$1
665  if [ ! $RET ] ; then
666    echo "rsync error !"
667  fi
668
669  if [ $MYLANG = "fr" ]; then
670    case $RET in
671    0)  return ;;
672    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
673      echo "Erreur de syntaxe ou d'utilisation."
674      return;;
675    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
676      echo "Incompatibilité de protocole."
677      return;;
678    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
679      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
680      echo "répertoires"
681      return;;
682    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
683      echo "Action demandée non supportée : une tentative de manipulation de"
684      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
685      echo "été faite ; ou une option qui est supportée par le  client  mais"
686      echo "pas par le serveur a été spécifiée."
687      return;;
688    10) echo "Erreur de rsync ; RERR_SOCKETIO"
689      echo "Erreur dans le socket d'entrée sortie"
690      return;;
691    11) echo "Erreur de rsync ; RERR_FILEIO"
692      echo "Erreur d'entrée sortie fichier"
693      return;;
694    12) echo "Erreur de rsync ; RERR_STREAMIO"
695      echo "Erreur dans flux de donnée du protocole rsync"
696      return;;
697    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
698      echo "Erreur avec les diagnostics du programme"
699      return;;
700    14) echo "Erreur de rsync ; RERR_IPC"
701      echo "Erreur dans le code IPC"
702      return;;
703    20) echo "Erreur de rsync ; RERR_SIGNAL"
704      echo "SIGUSR1 ou SIGINT reçu"
705      return;;
706    21) echo "Erreur de rsync ; RERR_WAITCHILD"
707      echo "Une erreur retournée par waitpid()"
708      return;;
709    22) echo "Erreur de rsync ; RERR_MALLOC"
710      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
711      return;;
712    23) echo ""
713      echo "Erreur fichier inexistant"
714      return;;
715    30) echo "Erreur de rsync ; RERR_TIMEOUT"
716      echo "Temps d'attente écoulé dans l'envoi/réception de données"
717      return;;
718    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
719      return;;
720    esac
721  elif [ $MYLANG = "en" ] ; then
722    case $RET in
723    0)  return;;               
724    1)  echo "rsync error : Syntax or usage error "
725      return;;
726    2)  echo "rsync error : Protocol incompatibility "
727      return;;
728    3)  echo "rsync error : Errors selecting input/output files, dirs"
729      return;;
730    4)  echo "rsync error : Requested action not supported: an attempt"
731      echo "was made to manipulate 64-bit files on a platform that cannot support"
732      echo "them; or an option was specified that is supported by the client and"
733      echo "not by the server."
734      return;;
735    5)  echo "rsync error : Error starting client-server protocol"
736      return;;
737    10) echo "rsync error : Error in socket I/O "
738      return;;
739    11) echo "rsync error : Error in file I/O "
740      return;;
741    12) echo "rsync error : Error in rsync protocol data stream "
742      return;;
743    13) echo "rsync error : Errors with program diagnostics "
744      return;;
745    14) echo "rsync error : Error in IPC code "
746      return;;
747    20) echo "rsync error : Received SIGUSR1 or SIGINT "
748      return;;
749    21) echo "rsync error : Some error returned by waitpid() "
750      return;;
751    22) echo "rsync error : Error allocating core memory buffers "
752      return;;
753    23) echo "rsync error : Partial transfer due to error"
754      return;;
755    24) echo "rsync error : Partial transfer due to vanished source files"
756      return;;
757    30) echo "rsync error : Timeout in data send/receive "
758      return;;
759    *)  echo "rsync error : return code of rsync unknown :" $RET
760      return;;
761    esac
762  else
763    echo "unknown language $MYLANG."
764    return
765  fi
766}
767
768#D-#==================================================
769#D-function IGCM_sys_Miror_libIGCM
770#D-* Purpose: Mirror libIGCM PATH and lib to cesium
771#D-* Examples:
772#D-
773function IGCM_sys_Mirror_libIGCM {
774  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
775  if ( $DEBUG_sys ) ; then
776    echo "IGCM_sys_Mirror_libIGCM"
777  fi
778
779  typeset RET DEST
780
781  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
782
783  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
784  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
785  RET=$?
786
787  if [ ${RET} -gt 0 ] ; then
788    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium."
789    cat out_rsync
790  fi
791  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
792}
793
794#====================================================
795#- Call IGCM_sys_Mirror_libIGCM now !
796if ( $MirrorlibIGCM ) ; then
797  IGCM_sys_Mirror_libIGCM
798fi
799
800#D-#==================================================
801#D-function IGCM_sys_Cp
802#D-* Purpose: generic cp
803#D-* Examples:
804#D-
805function IGCM_sys_Cp {
806  IGCM_debug_PushStack "IGCM_sys_Cp" $@
807  if ( $DEBUG_sys ) ; then
808    echo "IGCM_sys_Cp :" $@
809  fi
810
811  typeset RET
812
813  echo cp $@ > out_rsync 2>&1
814  \cp $@ >> out_rsync 2>&1
815  RET=$?
816
817  if [ ${RET} -gt 0 ] ; then
818    echo "IGCM_sys_Cp : error."
819    cat out_rsync
820    IGCM_debug_Exit "IGCM_sys_Cp"
821  else
822    \rm out_rsync
823  fi
824  IGCM_debug_PopStack "IGCM_sys_Cp"
825}
826
827#D-#==================================================
828#D-function IGCM_sys_Rm
829#D-* Purpose: generic rm
830#D-* Examples:
831#D-
832function IGCM_sys_Rm {
833  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
834  if ( $DEBUG_sys ) ; then
835    echo "IGCM_sys_Rm :" $@
836  fi
837
838  typeset RET
839
840  echo rm $@ > out_rsync 2>&1
841  \rm $@ >> out_rsync 2>&1
842  RET=$?
843
844  if [ ${RET} -gt 0 ] ; then
845    echo "IGCM_sys_Rm : error."
846    cat out_rsync
847    IGCM_debug_Exit "IGCM_sys_Rm"
848  else
849    \rm out_rsync
850  fi
851  IGCM_debug_PopStack "IGCM_sys_Rm"
852}
853
854#D-#==================================================
855#D-function IGCM_sys_Mv
856#D-* Purpose: generic move
857#D-* Examples:
858#D-
859function IGCM_sys_Mv {
860  IGCM_debug_PushStack "IGCM_sys_Mv" $@
861  if ( $DEBUG_sys ) ; then
862    echo "IGCM_sys_Mv :" $@
863  fi
864
865  if [ $DRYRUN = 0 ]; then
866
867    typeset RET
868   
869    echo mv $@ > out_rsync 2>&1
870    \mv $@ >> out_rsync 2>&1
871    RET=$?
872   
873    if [ ${RET} -gt 0 ] ; then
874      echo "IGCM_sys_Mv : error in mv."
875      cat out_rsync
876      IGCM_debug_Exit "IGCM_sys_Mv"
877    else
878      \rm out_rsync
879    fi
880  else
881    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
882  fi
883
884  IGCM_debug_PopStack "IGCM_sys_Mv"
885}
886
887#D-#==================================================
888#D-function IGCM_sys_Put_Dir
889#D-* Purpose: Copy a complete directory on $(ARCHIVE)
890#D-* Examples:
891#D-
892function IGCM_sys_Put_Dir {
893  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
894  if ( $DEBUG_sys ) ; then
895    echo "IGCM_sys_Put_Dir :" $@
896  fi
897  if [ $DRYRUN = 0 ]; then
898    if [ ! -d ${1} ] ; then
899      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
900      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
901      return
902    fi
903
904    typeset RET
905
906    # Only if we use rsync
907    #IGCM_sys_TestDirArchive $( dirname $2 )
908    #
909    #USUAL WAY
910    \cp -r $1 $2 > out_rsync 2>&1
911    RET=$?
912
913    if [ ${RET} -gt 0 ] ; then
914      echo "IGCM_sys_Put_Dir : error."
915      cat out_rsync
916      IGCM_debug_Exit "IGCM_sys_Put_Dir"
917    else
918      \rm out_rsync
919    fi
920  else
921    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
922  fi
923  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
924}
925
926#D-#==================================================
927#D-function IGCM_sys_Get_Dir
928#D-* Purpose: Copy a complete directory from ${ARCHIVE}
929#D-* Examples:
930#D-
931function IGCM_sys_Get_Dir {
932  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
933  if ( $DEBUG_sys ) ; then
934    echo "IGCM_sys_Get_Dir :" $@
935  fi
936  if [ $DRYRUN = 0 ]; then
937#    if [ ! -d ${1} ] ; then
938#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
939#      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
940#      return
941#    fi
942
943    typeset RET
944
945    # Only if we use rsync
946    #IGCM_sys_TestDirArchive $( dirname $2 )
947    #
948    # USUAL WAY
949    # add dmfind/dmget (to demigrate all offline files) :
950    #dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget
951    \cp -r $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    else
959      \rm out_rsync
960    fi
961  else
962    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
963  fi
964  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
965}
966
967#D-#==================================================
968#D-function IGCM_sys_Put_Rest
969#D-* Purpose: Put computied restarts on ${ARCHIVE}.
970#D-           File and target directory must exist.
971#D-* Examples:
972#D-
973function IGCM_sys_Put_Rest {
974  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
975  if ( $DEBUG_sys ) ; then
976    echo "IGCM_sys_Put_Rest :" $@
977  fi
978  if [ $DRYRUN = 0 ]; then
979    if [ ! -f ${1} ] ; then
980      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
981      IGCM_debug_Exit "IGCM_sys_Put_Rest"
982    fi
983
984    typeset RET
985    #
986    if [ X${JobType} = XRUN ] ; then
987      IGCM_sys_Chmod 444 ${1}
988    fi
989
990    #
991    # USUAL WAY
992    \cp $1 $2 > out_rsync 2>&1
993    RET=$?
994
995#       #RSYNC WITH NETWORK SSH CALL
996#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
997#       ${RSYNC} ${RSYNC_opt} -e ssh ${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 having 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    IGCM_sys_MkdirArchive $( dirname $2 )
1081    #
1082    typeset RET
1083
1084    #=====================================================
1085    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1086    #=====================================================
1087
1088    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
1089    #if [ $? -eq 0 ] ; then
1090    #    typeset WORKPATH FILEPATH
1091    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" )
1092    #    IGCM_sys_MkdirWork ${WORKPATH}
1093    #    FILEPATH=${WORKPATH}/$( basename $2 )
1094    #    #
1095    #    IGCM_sys_Cp ${1} ${FILEPATH}
1096    #fi
1097
1098    if [ X${JobType} = XRUN ] ; then
1099      if [ X${3} = X ] ; then
1100        IGCM_sys_Chmod 444 ${1}
1101      fi
1102    fi
1103    #
1104    # USUAL WAY
1105    \cp $1 $2 > out_rsync 2>&1
1106    RET=$?
1107
1108#       #RSYNC WITH NETWORK SSH CALL
1109#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1110#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1111
1112#       #RSYNC WITH NFS USE
1113#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1114#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1115
1116#       RET=$?
1117#       IGCM_sys_Rsync_out $RET
1118
1119#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1120#       (( RET=RET+$? ))
1121
1122    if [ ${RET} -gt 0 ] ; then
1123      echo "IGCM_sys_Put_Out : error."
1124      cat out_rsync
1125      IGCM_debug_Exit "IGCM_sys_Put_Out"
1126    else
1127      \rm out_rsync
1128    fi
1129  else
1130    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1131  fi
1132  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1133  return 0
1134}
1135
1136#D-#==================================================
1137#D-function IGCM_sys_PutBuffer_Out
1138#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1139#D-* Examples:
1140#D-
1141function IGCM_sys_PutBuffer_Out {
1142  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1143  if ( $DEBUG_sys ) ; then
1144    echo "IGCM_sys_PutBuffer_Out :" $@
1145  fi
1146  if [ $DRYRUN = 0 ]; then
1147    if [ ! -f ${1} ] ; then
1148      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1149      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1150      return 1
1151    fi
1152    #
1153    IGCM_sys_Mkdir $( dirname $2 )
1154    #
1155    typeset RET
1156
1157    if [ X${JobType} = XRUN ] ; then
1158      if [ X${3} = X ] ; then
1159        IGCM_sys_Chmod 444 ${1}
1160      fi
1161    fi
1162    #
1163    # USUAL WAY
1164    \cp $1 $2 > out_rsync 2>&1
1165    RET=$?
1166
1167    if [ ${RET} -gt 0 ] ; then
1168      echo "IGCM_sys_PutBuffer_Out : error."
1169      cat out_rsync
1170      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1171    else
1172      \rm out_rsync
1173    fi
1174  else
1175    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1176  fi
1177  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1178  return 0
1179}
1180
1181#D-#==================================================
1182#D-function IGCM_sys_Get
1183#D-* Purpose: Get a file from ${ARCHIVE}
1184#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1185#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1186function IGCM_sys_Get {
1187  IGCM_debug_PushStack "IGCM_sys_Get" $@
1188
1189  typeset DEST RET dm_liste ifile target file_work
1190
1191  if ( $DEBUG_sys ) ; then
1192    echo "IGCM_sys_Get :" $@
1193  fi
1194  if [ $DRYRUN -le 2 ]; then
1195    if [ X${1} = X'/l' ] ; then
1196      # test if the first file is present in the old computation :
1197      eval set +A dm_liste \${${2}}
1198    else
1199      eval set +A dm_liste ${1}
1200    fi
1201    eval DEST=\${${#}}
1202
1203    #=====================================================
1204    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1205    #=====================================================
1206
1207    # Is it an R_OUT file (not R_IN) ?
1208    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1209    #if [ $? -eq 0 ] ; then
1210    #    # Yes  ? then we try to get it in SCRATCHDIR
1211    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" )
1212    #    if [ -f ${file_work[0]} ] ; then
1213    #   IGCM_sys_Cp ${file_work[*]} ${DEST}
1214    #   IGCM_debug_PopStack "IGCM_sys_Get"
1215    #   return
1216    #    fi
1217    #fi
1218
1219    # test if the (first) file is present in the old computation :
1220    IGCM_sys_TestFileArchive ${dm_liste[0]}
1221    RET=$?
1222    if [ ${RET} -gt 0 ] ; then
1223      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1224      IGCM_debug_Exit "IGCM_sys_Get"
1225    fi
1226
1227    #dmget ${dm_liste[*]} > out_rsync 2>&1
1228    ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1229    RET=$?
1230    if [ ${RET} -gt 0 ] ; then
1231      echo "WARNING IGCM_sys_Get : demigration error."
1232      cat out_rsync
1233      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
1234    fi
1235
1236    #if [ ${RET} -gt 0 ] ; then
1237    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
1238    #   cat out_rsync
1239    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
1240    #   sleep 30
1241    #   echo "We try another time"
1242    ##  dmget ${dm_liste[*]} > out_rsync 2>&1
1243    #   ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1244    #   RET=$?
1245    #   if [ ${RET} -gt 0 ] ; then
1246    #       echo "ERROR IGCM_sys_Get : again demigration error :"
1247    #       cat out_rsync
1248    #       IGCM_debug_Exit "IGCM_sys_Get"
1249    #   fi
1250    #    else
1251    #   echo "ERROR IGCM_sys_Get : demigration error :"
1252    #   cat out_rsync
1253    #   IGCM_debug_Exit "IGCM_sys_Get"
1254    #    fi
1255    #fi
1256
1257    #USUAL WAY
1258    if [ X${1} = X'/l' ] ; then
1259      (( RET=0 ))
1260      for target in ${dm_liste[*]} ; do
1261        local_file=$( basename ${target} )
1262        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1263        (( RET = RET + $? ))
1264      done
1265    else
1266      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1267      RET=$?
1268    fi
1269
1270#       #RSYNC WITH NETWORK SSH CALL
1271#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1272#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1273
1274#       #RSYNC WITH NFS USE
1275#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1276#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1277
1278#       RET=$?
1279#       IGCM_sys_Rsync_out $RET
1280
1281#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1282#       (( RET=RET+$? ))
1283
1284    if [ ${RET} -gt 0 ] ; then
1285      echo "IGCM_sys_Get : copy error."
1286      cat out_rsync
1287      IGCM_debug_Exit "IGCM_sys_Get"
1288    else
1289      \rm out_rsync
1290    fi
1291  else
1292    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1293  fi
1294  IGCM_debug_PopStack "IGCM_sys_Get"
1295}
1296
1297#D-#==================================================
1298#D-function IGCM_sys_GetBuffer
1299#D-* Purpose: Get a file from ${SCRATCHDIR}
1300#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1301#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1302function IGCM_sys_GetBuffer {
1303  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1304
1305  typeset DEST RET buf_liste ifile target file_work
1306
1307  if ( $DEBUG_sys ) ; then
1308    echo "IGCM_sys_GetBuffer :" $@
1309  fi
1310  if [ $DRYRUN -le 2 ]; then
1311    if [ X${1} = X'/l' ] ; then
1312      # test if the first file is present in the old computation :
1313      eval set +A buf_liste \${${2}}
1314    else
1315      eval set +A buf_liste ${1}
1316    fi
1317    eval DEST=\${${#}}
1318
1319    #USUAL WAY
1320    if [ X${1} = X'/l' ] ; then
1321      (( RET=0 ))
1322      for target in ${buf_liste[*]} ; do
1323        local_file=$( basename ${target} )
1324        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1325        (( RET = RET + $? ))
1326      done
1327    else
1328      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
1329      RET=$?
1330    fi
1331
1332    if [ ${RET} -gt 0 ] ; then
1333      echo "IGCM_sys_GetBuffer : copy error."
1334      cat out_rsync
1335      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1336    else
1337      \rm out_rsync
1338    fi
1339  else
1340    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1341  fi
1342  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1343}
1344
1345#D-#==================================================
1346#D-function IGCM_sys_GetDate_FichWork
1347#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1348#D-* Examples:
1349#D-
1350function IGCM_sys_GetDate_FichWork {
1351  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1352  if ( $DEBUG_sys ) ; then
1353    echo "IGCM_sys_GetDate_FichWork :" $@
1354  fi
1355  typeset dateF
1356  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1357  eval ${2}=${dateF[5]}
1358
1359    # donne la date filesys d'un fichier sur la machine work
1360  IGCM_debug_PopStack "IGCM_sys_FichWork"
1361}
1362
1363#D-#==================================================
1364#D-function IGCM_sys_GetDate_FichArchive
1365#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1366#D-* Examples:
1367#D-
1368function IGCM_sys_GetDate_FichArchive {
1369  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1370  if ( $DEBUG_sys ) ; then
1371    echo "IGCM_sys_GetDate_FichArchive :" $@
1372  fi
1373  typeset dateF
1374  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1375  eval ${2}=${dateF[5]}
1376
1377  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1378}
1379
1380##############################################################
1381# REBUILD OPERATOR
1382
1383function IGCM_sys_rebuild {
1384  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1385  if ( $DEBUG_sys ) ; then
1386    echo "IGCM_sys_rebuild :" $@
1387  fi
1388  /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@
1389  if [ $? -gt 0 ] ; then
1390    echo "IGCM_sys_rebuild : erreur ${@}."
1391    IGCM_debug_Exit "rebuild"
1392  fi
1393
1394  IGCM_debug_PopStack "IGCM_sys_rebuild"
1395}
1396
1397############################################################
1398# Activate Running Environnment Variables
1399
1400function IGCM_sys_activ_variables {
1401  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1402  if ( $DEBUG_sys ) ; then
1403    echo "IGCM_sys_activ_variables"
1404  fi
1405
1406# --------------------------------------------------------------------
1407#D- MPI specifications
1408# --------------------------------------------------------------------
1409
1410#D-- MPISUSPEND
1411  export MPISUSPEND=${MPISUSPEND:=OFF}
1412
1413#D-- MPIPROGINF #other choices : ALL_DETAIL2
1414  export MPIPROGINF=ALL
1415#D- activate ftrace (with -ftrace)
1416  export F_FTRACE=YES
1417#D- communication information (with -ftrace)
1418  export MPICOMMINF=DETAIL
1419
1420# --------------------------------------------------------------------
1421#D- Other specifications
1422# --------------------------------------------------------------------
1423
1424#D- max number of character/line in output job
1425  export F_SYSLEN=5000
1426#D- number of error that can be admitted on the NEC
1427  export F_ERRCNT=0
1428#D- global performance
1429  export F_PROGINF=DETAIL
1430
1431#D- I/O performance (FORTRAN I/O only not netCDF)
1432  export F_FILEINF=${F_FILEINF:=NO}
1433#D- netCDF I/O performance
1434  export NC_FILEINF=${NC_FILEINF:=NO}
1435
1436  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1437}
1438
1439############################################################
1440# Desactivate Running Environnment Variables
1441
1442function IGCM_sys_desactiv_variables {
1443  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1444  if ( $DEBUG_sys ) ; then
1445    echo "IGCM_sys_desactiv_variables"
1446  fi
1447# --------------------------------------------------------------------
1448#D- MPI specifications
1449# --------------------------------------------------------------------
1450
1451#D-- MPIPROGINF
1452  export MPIPROGINF=NO
1453
1454# --------------------------------------------------------------------
1455#D- Other specifications
1456# --------------------------------------------------------------------
1457
1458#D- global performance
1459  export F_PROGINF=NO 
1460
1461  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1462}
1463
1464############################################################
1465# Build run file
1466
1467function IGCM_sys_build_run_file {
1468  IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1469  if ( $DEBUG_sys ) ; then
1470    echo "IGCM_sys_build_run_file " $@
1471  fi
1472  (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 ))
1473  (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1474  (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1475 
1476  if [ $1 = MPI2 ]; then
1477    cat <<EOF > run_file
1478-p 1 -np 1 -e ./oasis
1479EOF
1480    (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 ))
1481    config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"'
1482
1483  elif [ $1 = MPI1 ]; then
1484    cat <<EOF > run_file
1485-p $NUM_PROC_OASIS -e ./oasis
1486-p $NUM_PROC_ATM -e ./lmdz.x
1487-p $NUM_PROC_OCE -e ./opa.xx
1488EOF
1489  fi
1490  IGCM_debug_PopStack "IGCM_sys_build_run_file"
1491}
Note: See TracBrowser for help on using the repository browser.