source: tags/libIGCM_v2.0_beta4/libIGCM_sys/libIGCM_sys_mercurex8.ksh @ 1636

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