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

Last change on this file since 559 was 548, checked in by sdipsl, 12 years ago

Bugfix : when retrieving input ifiles from another filesystem than /dmnfs you must not use dmget ... it hangs forever ...

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