-
Notifications
You must be signed in to change notification settings - Fork 0
/
jessica
executable file
·97 lines (76 loc) · 2.76 KB
/
jessica
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#This program launches nathalie on selected days of a month.
#-g option is used in a special case (study of Hefei data). It extracts valid days from the file named AODfinal_yyyy_mm.txt, which is created by the program germaine.
#Use no option to write dates manually in a file named datesvalides_YEAR_MONTH.txt
#Valid dates in datesvalides_YEAR_MONTH.txt have to be 2 digits, 1 day per line.
#usage : jessica [-OPTION] yyyy-mm (in ./data/ directory)
#Time reading, for runtime
START=$(date +%s)
#OPTIONS
gopt=0
while getopts 'g:' OPTION
do
case $OPTION in
g) gopt=1
date=$OPTARG
;;
esac
done
# Reading date
if [ "$gopt" != "1" ]
then date=$1
fi
echo $date | sed 's/-/ /g' > yearmonth.tmp
read annee mois < yearmonth.tmp
rm -f yearmonth.tmp
#When -g option is used. Writing of valid dates in datesvalides_YEAR_MONTH.tmp from AODfinal_YEAR_MONTH.txt
if [ "$gopt" = "1" ]
then
if [ ! -e AODfinal_$annee"_"$mois".txt" ] # verification de l existence du fichier AODfinal_ANNEE_MOIS.txt
then echo "AODfinal_"$annee"_"$mois".txt does not exist. Execute germaine.anal on corresponding month to create it."
exit 1
fi
rm -f datesvalides_$annee"_"$mois".txt" # réinitialisation des anciennes dates valides
if [ $mois -lt 10 ] # pour correspondre au format de AODfinal_ANNEE_MOIS.txt
then
if [ ${mois:0:1} = 0 ]
then month=${mois:1:1}
fi
fi
cat AODfinal_$annee"_"$mois".txt" | grep "$annee $month " > datesvalides_$annee"_"$mois".tmp"
jour="bidon" # reinitialisation de variable
while read bidon bidon j bidon
do
if [ $j -lt 10 ]
then
if [ ${j:0:1} != 0 ]
then j="0"$j
fi
fi
if [ "$jour" != "$j" ]
then jour=$j
echo $jour >> datesvalides_$annee"_"$mois".txt"
fi
done < datesvalides_$annee"_"$mois".tmp"
rm -f datesvalides_$annee"_"$mois".tmp"
fi
#Reading valid dates in datesvalides_YEAR_MONTH.txt
if [ ! -e datesvalides_$annee"_"$mois".txt" ] # message d erreur si le fichier n existe pas
then echo "datesvalides_$annee"_"$mois.txt does not exist. Create this file manually or launch jessica with -g option."
else
if [! -d ./nata_out ]
then mkdir ./nata_out
fi
#Beginning of the loop, to launch nathalie
while read day
do
nathalie -d $annee"-"$mois"-"$day > ./nata_out/nata_$annee"-"$mois"-"$day".out"
done < datesvalides_$annee"_"$mois".txt"
# Runtime
END=$(date +%s)
RUNTIME=$((END-START))
HEURE=$((RUNTIME/3600))
MIN=$((RUNTIME/60-HEURE*60))
SEC=$((RUNTIME-RUNTIME/60*60))
echo "jessica is done with data from $annee $mois, after $HEURE h $MIN min $SEC sec of work"
fi