1 | #!/bin/sh |
---|
2 | #liste des "sources" enregistrees sous Amas |
---|
3 | AWK=/bin/awk |
---|
4 | SED=/bin/sed |
---|
5 | GREP=/bin/grep |
---|
6 | WC=/usr/bin/wc |
---|
7 | RM=/bin/rm |
---|
8 | CAT=/bin/cat |
---|
9 | TOUCH=/bin/touch |
---|
10 | DATE=/bin/date |
---|
11 | ECHO=/bin/echo |
---|
12 | LS=/bin/ls |
---|
13 | MKDIR=/bin/mkdir |
---|
14 | TR=/usr/bin/tr |
---|
15 | FIND=/usr/bin/find |
---|
16 | PRINTF=/usr/bin/printf |
---|
17 | XARGS=/usr/bin/xargs |
---|
18 | SORT=/bin/sort |
---|
19 | QSUB=qsub |
---|
20 | |
---|
21 | DefaultIFS=$' \t\n' |
---|
22 | IFS=$DefaultIFS |
---|
23 | |
---|
24 | trim() { echo $1; } |
---|
25 | |
---|
26 | |
---|
27 | # Irods environment settings |
---|
28 | . /usr/local/shared/bin/irods_env.sh -noverbose |
---|
29 | |
---|
30 | scriptName="`basename $0`" |
---|
31 | $ECHO "Processing script ${scriptName} at `date`" |
---|
32 | |
---|
33 | #Path to public backupable path |
---|
34 | publicpath="/afs/in2p3.fr/home/c/campagne/public" |
---|
35 | |
---|
36 | |
---|
37 | #temporary files to synchronize scripts |
---|
38 | tmppublicpath=${TMPPUBLICPATH} |
---|
39 | $LS -l ${tmppublicpath} > /dev/null |
---|
40 | |
---|
41 | |
---|
42 | #Path where the job will do temporary IO |
---|
43 | if [ ${ENVIRONMENT} == "INTERACTIVE" ]; then |
---|
44 | iojobpath="/sps/baoradio/AmasNancay/JEC" |
---|
45 | $MKDIR -p $iojobpath |
---|
46 | elif [ ${ENVIRONMENT} == "BATCH" ] ; then |
---|
47 | iojobpath=${TMPBATCH} |
---|
48 | else |
---|
49 | $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed" |
---|
50 | touch ${tmppublicpath}/statusdaq.finished |
---|
51 | exit 1 |
---|
52 | fi |
---|
53 | cd ${iojobpath} |
---|
54 | |
---|
55 | |
---|
56 | OUT1=./baoils.$$ |
---|
57 | ils /baoradio/data/AmasNancay/ > ${OUT1} |
---|
58 | OUT2=./baoawk1.$$ |
---|
59 | $AWK '($1=="C-") {print $2}' ${OUT1} > ${OUT2} |
---|
60 | $RM $OUT1 |
---|
61 | #Sequence |
---|
62 | tableau=( `$CAT $OUT2 | $AWK '{print $1}'` ) |
---|
63 | IFS=' |
---|
64 | ' |
---|
65 | tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
66 | IFS=$DefaultIFS |
---|
67 | |
---|
68 | $RM $OUT2 |
---|
69 | |
---|
70 | for i in ${tableau[@]} |
---|
71 | do |
---|
72 | OUT2=./baodir.$$ |
---|
73 | $ECHO "source $i" |
---|
74 | listedate=( `ils $i | $AWK '($1=="C-"){print $2}'`) |
---|
75 | IFS=' |
---|
76 | ' |
---|
77 | listedate=( $( $PRINTF "%s\n" "${listedate[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
78 | IFS=$DefaultIFS |
---|
79 | |
---|
80 | for j in ${listedate[@]} |
---|
81 | do |
---|
82 | ils -l $j 2>&1 | $GREP -i "sca" > ${OUT2} |
---|
83 | #test if the SCA file has been already processed |
---|
84 | scatrans=`$GREP -i "sca.*\.sum\.trans" ${OUT2} | $AWK '{print $NF}'` |
---|
85 | #test if the file is empty due to previous processing dysfunction |
---|
86 | emptyfile=`$GREP -i "sca.*\.sum\.trans" ${OUT2} | $AWK '{print $4}'` |
---|
87 | # echo "scrutinize directory <$i>: [$nblines] [$scatrans]" |
---|
88 | if [ "<${scatrans}>" != "<>" ]; then |
---|
89 | scafile=`$GREP -i "sca.*\.sum\.trans" ${OUT2} | $AWK '{print $NF}'` |
---|
90 | if [ "<${scafile}>" = "<>" ]; then |
---|
91 | $ECHO "WARNING (${scriptName}): Cannot download a SCA file for $j" |
---|
92 | else |
---|
93 | #get sca file |
---|
94 | iget -r -f -K ${j}/${scafile} |
---|
95 | ncycle=`$CAT ${scafile} | $WC -l` |
---|
96 | $RM ${scafile} |
---|
97 | $ECHO ">>> $j ---> ${ncycle} cycles" |
---|
98 | fi |
---|
99 | else |
---|
100 | $ECHO ">>> $j ---> NO SCA summary" |
---|
101 | fi |
---|
102 | done |
---|
103 | $RM ${OUT2} |
---|
104 | done |
---|
105 | |
---|
106 | |
---|
107 | |
---|