source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_cesium.ksh @ 664

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