source: BAORadio/AmasNancay/trunk/mkarchive.sh@ 580

Last change on this file since 580 was 579, checked in by torrento, 14 years ago

version adaptee a grid engin (ana)

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1#!/bin/sh
2#make an archive of the processing
3DATE=/bin/date
4GREP=/bin/grep
5AWK=/bin/awk
6ECHO=/bin/echo
7WC=/usr/bin/wc
8CAT=/bin/cat
9PRINTF=/usr/bin/printf
10FIND=/usr/bin/find
11MKDIR=/bin/mkdir
12XARGS=/usr/bin/xargs
13SORT=/bin/sort
14RM=/bin/rm
15TR=/usr/bin/tr
16CP=/bin/cp
17LS=/bin/ls
18CHMOD=/bin/chmod
19
20DefaultIFS=$' \t\n'
21IFS=$DefaultIFS
22
23#set Irods environment
24. /usr/local/shared/bin/irods_env.sh -noverbose
25
26scriptName="`basename $0`"
27$ECHO "Processing script ${scriptName} at `date`"
28#which source to analyse
29
30#Process cmd line args: the -src option is mandatory (source name as Abell85)
31sourceRadio=
32dateSelected=
33prependTag=""
34appendTag=""
35simulationMode=Off
36while [ $# -gt 0 ]
37 do
38 case "$1" in
39 -src) sourceRadio=$2; shift;;
40 -date) dateSelected=$2; shift;;
41 -ppTag) prependTag=$2; shift;;
42 -apTag) appendTag=$2; shift;;
43 -sim) simulationMode=On;;
44 -h)
45 echo >&2 \
46 "usage: $0 -src souce -date YYYYMMDD -ppTag <tag> -apTag <tag> [-sim to trig simulation mode]"
47 exit 1;;
48 *) break;; # terminate while loop
49 esac
50 shift
51done
52
53
54if [ ${simulationMode} = "On" ]; then
55 $ECHO "INFO ${scriptName} running in SIMUL mode"
56fi
57
58if [ "<${sourceRadio}>" = "<>" ]; then
59 $ECHO "FATAL: You have forgotten to select the source option (-src)"
60 exit 1
61fi
62
63if [ "<${prependTag}>" = "<>" -a "<${appendTag}>" = "<>" ]; then
64 $ECHO "FATAL: choose either a prepend Tag or a append Tag"
65 exit
66fi
67
68
69case ${sourceRadio} in
70 Abell85) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
71 Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
72 Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
73 *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen"
74 exit 1;;
75esac
76
77srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
78
79#Path to public backupable path
80publicpath="/afs/in2p3.fr/home/c/campagne/public"
81
82
83#temporary files to synchronize scripts
84tmppublicpath=${TMPPUBLICPATH}
85#wakeup the NFS disk
86$LS -l ${tmppublicpath} > /dev/null
87
88#Path where the job will do temporary IO
89. ${SCRIPTPATH}/set_iojobpath.sh
90iojobpath=$(set_iojobpath)
91cd ${iojobpath}
92
93localpath="${sourceRadio}"
94$MKDIR -p ./${localpath}
95cd ./${localpath}
96
97
98#Path of the utility scripts
99scriptpath=${SCRIPTPATH}
100
101OUT1=${publicpath}/baodaqstatus-current.txt
102if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then
103 $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
104 exit 1
105fi
106
107
108
109$ECHO "You have selected sourceRadio = ${sourceRadio} [date = ${dateSelected}]"
110tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
111IFS='
112'
113tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
114IFS=$DefaultIFS
115
116$ECHO "We are in directory `pwd`"
117
118for i in ${tableau[@]}
119 do
120#
121
122 $ECHO "DEBUG: (${scriptName}) irods root dir $i"
123
124
125
126 #make a new archive directory
127 archiveDir=${prependTag}Arch${appendTag}
128
129 archExist=`ils ${i} 2>&1 | $GREP -i ".*C-.*${archiveDir}"| $WC -l`
130 if [ ${archExist} -gt 0 ]; then
131 $ECHO "FATAL: ${archiveDir} already exit in ${i}"
132 exit 1
133 fi
134
135 imkdir -v ${i}/${archiveDir}
136
137 #Move the Off and On directory
138 imv -v ${i}/Off ${i}/${archiveDir}/Off
139 imv -v ${i}/On ${i}/${archiveDir}/On
140
141 #recreate On and Off directories
142 imkdir -v ${i}/Off
143 imkdir -v ${i}/On
144
145 #mv the fichiers de calibrations BAO
146 calibfiles=( `ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" ` )
147 IFS='
148'
149 calibfiles=( $( $PRINTF "%s\n" "${calibfiles[@]}" | $AWK 'x[$0]++ == 0' ) )
150 IFS=$DefaultIFS
151
152 for j in ${calibfiles[@]}
153 do
154 file=`$ECHO $j`
155 imv -v ${i}/${file} ${i}/${archiveDir}/${file}
156 done
157
158 #mv the ppf files
159 ppffiles=( `ils ${i} 2>&1 | $GREP -i ".*\.ppf" ` )
160 IFS='
161'
162 ppffiles=( $( $PRINTF "%s\n" "${ppffiles[@]}" | $AWK 'x[$0]++ == 0' ) )
163 IFS=$DefaultIFS
164
165 for j in ${ppffiles[@]}
166 do
167 file=`$ECHO $j`
168 imv -v ${i}/${file} ${i}/${archiveDir}/${file}
169 done
170
171 #save the gain file
172 gainfile=`ils ${i} 2>&1 | $GREP -i "gain.*\.fits"`
173 file=`$ECHO ${gainfile}`
174 icp -v ${i}/${file} ${i}/${archiveDir}/${file}
175
176done
177
178exit 0
Note: See TracBrowser for help on using the repository browser.