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

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