source: BAORadio/AmasNancay/trunk/statusonoff.sh @ 579

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

version adaptee a grid engin (ana)

  • Property svn:executable set to *
File size: 3.4 KB
Line 
1#!/bin/sh
2#Status de l'etat de la production des fichiers INPUT de calibrations
3GREP=/bin/grep
4AWK=/bin/awk
5ECHO=/bin/echo
6MKDIR=/bin/mkdir
7CAT=/bin/cat
8PRINTF=/usr/bin/printf
9RM=/bin/rm
10SORT=/bin/sort
11XARGS=/usr/bin/xargs
12WC=/usr/bin/wc
13DefaultIFS=$' \t\n'
14IFS=$DefaultIFS
15
16# Irods environment settings
17. /usr/local/shared/bin/irods_env.sh -noverbose
18
19scriptName="`basename $0`"
20$ECHO "Processing script ${scriptName} at `date`"
21
22#Path to public backupable path
23publicpath="/afs/in2p3.fr/home/c/campagne/public"
24
25#Path where the job will do temporary IO
26. ${SCRIPTPATH}/set_iojobpath.sh
27iojobpath=$(set_iojobpath)
28cd ${iojobpath}
29
30
31OUT1=./baoils.$$
32ils /baoradio/data/AmasNancay/ > ${OUT1}
33OUT2=./baoawk1.$$
34$AWK '($1=="C-") {print $2}' ${OUT1} > ${OUT2}
35$RM $OUT1
36#Sequence
37listeSources=( `$CAT $OUT2 | $AWK '{print $1}'` )
38IFS='
39'
40listeSources=( $( $PRINTF "%s\n" "${listeSources[@]}" | $AWK 'x[$0]++ == 0' ) )
41IFS=$DefaultIFS
42$RM $OUT2
43
44for i in ${listeSources[@]}
45do
46#nb: $i contains the full path
47  $ECHO "source ${i}"
48  sourceName=`basename ${i}`
49  listeDates=( `ils $i | $AWK '($1=="C-"){print $2}'`)
50  IFS='
51'
52  listeDates=( $( $PRINTF "%s\n" "${listeDates[@]}" | $AWK 'x[$0]++ == 0' ) )
53  IFS=$DefaultIFS
54
55  for j in ${listeDates[@]}
56  do
57#nb: $j contains the full path
58#  $ECHO "run ${j}"
59#
60#Off directory
61#
62    dateField=`basename ${j}`
63    sourceDate="${sourceName}-${dateField}"
64#look if final data processing files exist
65    onOffOk=`ils ${j} | $GREP -i "data.*\.ppf\|diff.*\.ppf" | $WC -l`
66    offDirExist=`ils ${j} | $GREP -i "Off" | $WC -l`
67    if [ ${offDirExist} != 0 ]; then
68        listeCyclesOff=( `ils ${j}/Off | $GREP -i "datacycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` )
69        IFS='
70  '
71        listeCyclesOff=( $( $PRINTF "%s\n" "${listeCyclesOff[@]}" | $AWK 'x[$0]++ == 0' ) )
72        IFS=$DefaultIFS
73       
74        if [ ${#listeCyclesOff[*]} != 0 ]; then   
75           for c in ${listeCyclesOff[@]}
76           do
77#nb: $c has the format of datacycle<number>
78             nFiles=`ils ${j}/Off/${c} | $GREP -i "medfiltmtx" | $WC -l`
79             if [ ${nFiles} != 0 ]; then
80                 $ECHO "${sourceDate}/Off/${c}: ${nFiles} spectra (${onOffOk} ana)"
81             else
82                 $ECHO "${sourceDate}/Off/${c}: ON-OFF failed"
83             fi
84#end of loop on cycles
85           done
86        else
87            $ECHO "${sourceDate} : No ON-OFF done for Off Diectory"
88        fi
89#end of Off exist
90    else
91        $ECHO "${sourceDate} : No Off Diectory"
92    fi
93#
94#On directory
95#
96    dateField=`basename ${j}`
97    sourceDate="${sourceName}-${dateField}"
98#look if final calibration files exist
99    onOnOk=`ils ${j} | $GREP -i "data.*\.ppf\|diff.*\.ppf" | $WC -l`
100    onDirExist=`ils ${j} | $GREP -i "On" | $WC -l`
101    if [ ${onDirExist} != 0 ]; then
102        listeCyclesOn=( `ils ${j}/On | $GREP -i "datacycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` )
103        IFS='
104  '
105        listeCyclesOn=( $( $PRINTF "%s\n" "${listeCyclesOn[@]}" | $AWK 'x[$0]++ == 0' ) )
106        IFS=$DefaultIFS
107       
108        if [ ${#listeCyclesOn[*]} != 0 ]; then   
109           for c in ${listeCyclesOn[@]}
110           do
111#nb: $c has the format of datacycle<number>
112             nFiles=`ils ${j}/On/${c} | $GREP -i "medfiltmtx" | $WC -l`
113             if [ ${nFiles} != 0 ]; then
114                 $ECHO "${sourceDate}/On/${c}: ${nFiles} spectra (${onOnOk} ana)"
115             else
116                 $ECHO "${sourceDate}/On/${c}: ON-OFF failed"
117             fi
118#end of loop on cycles
119           done
120        else
121            $ECHO "${sourceDate} : No ON-OFF done for On Diectory"
122        fi
123#end of On exist
124    else
125        $ECHO "${sourceDate} : No On Diectory"
126    fi
127#end of loop on dates
128  done 
129#end of loop on sources
130done
Note: See TracBrowser for help on using the repository browser.