-
Notifications
You must be signed in to change notification settings - Fork 0
/
summary
executable file
·114 lines (101 loc) · 4.53 KB
/
summary
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
#set -x
set -u
: "$ARCHIVE"
NSTEPS=13
update_pbar() {
local w=60 p=$1; shift
printf -v equals "%*s" "$(( $p*$w/$NSTEPS ))" ""; equals=${equals// /=};
printf "\r\e[K|%-*s| %s" "$w" "$equals";
}
update_pbar 0
function count_files() {
ls -1 $1 2>/dev/null | wc -l
}
let ALL_OK=1
function myprint() {
if echo "$2" | grep -q '\([0-9][0-9]*\)/\1'; then
START_COLOR="\e[32m"
END_COLOR="\e[m"
elif echo "$2" | grep -q '[0-9][0-9]*/[0-9][0-9]*'; then
START_COLOR="\x1B[31m"
END_COLOR="\e[m"
let "ALL_OK&=0"
else
START_COLOR="\e[m"
END_COLOR="\e[m"
fi
printf " %-30s $START_COLOR%s$END_COLOR\n" "$1" "$2"
}
case $ARCHIVE in
GEOSFP)
YEAR=${YEAR:=$(date --date='-1 month' +%Y)}
MONTH=${MONTH:=$(date --date='-1 month' +%m)}
DOWNLOAD_DIR=/storage1/fs1/rvmartin/Active/GEOS-Chem-shared/MetFieldProcessing/GEOS_FP-raw/$YEAR/$MONTH
DOWNLOAD_EXPECTED_PER_DAY=144
PROCESSED_DIR=/storage1/fs1/rvmartin/Active/GEOS-Chem-shared/MetFieldProcessing/scratch/GEOS_FP/$YEAR/$MONTH/nc4
NC_SUFFIX="nc"
;;
MERRA2)
YEAR=${YEAR:=$(date --date='-2 month' +%Y)}
MONTH=${MONTH:=$(date --date='-2 month' +%m)}
DOWNLOAD_DIR=/storage1/fs1/rvmartin/Active/GEOS-Chem-shared/MetFieldProcessing/MERRA2-raw/$YEAR/$MONTH
DOWNLOAD_EXPECTED_PER_DAY=10
PROCESSED_DIR=/storage1/fs1/rvmartin/Active/GEOS-Chem-shared/MetFieldProcessing/scratch/MERRA2-raw/$YEAR/$MONTH
NC_SUFFIX="nc4"
;;
*)
exit 1
esac
DAYS_IN_MONTH=$(cal $MONTH $YEAR | awk 'NF {DAYS = $NF}; END {print DAYS}')
DOWNLOADED_FILES=$(count_files "$DOWNLOAD_DIR/*.nc4")
update_pbar 1
function count_processed_files() {
count_files "$1/$2.$YEAR$MONTH*.$3.$NC_SUFFIX"
}
PROCESSED_4x5=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 4x5)
update_pbar 2
PROCESSED_2x25=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 2x25)
update_pbar 3
PROCESSED_05x0625=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 05x0625)
update_pbar 4
PROCESSED_05x0625_AS=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 05x0625.AS)
update_pbar 5
PROCESSED_05x0625_CH=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 05x0625.CH)
update_pbar 6
PROCESSED_05x0625_EU=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 05x0625.EU)
update_pbar 7
PROCESSED_05x0625_NA=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 05x0625.NA)
update_pbar 8
PROCESSED_025x03125=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 025x03125)
update_pbar 9
PROCESSED_025x03125_AS=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 025x03125.AS)
update_pbar 10
PROCESSED_025x03125_CH=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 025x03125.CH)
update_pbar 11
PROCESSED_025x03125_EU=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 025x03125.EU)
update_pbar 12
PROCESSED_025x03125_NA=$(count_processed_files $PROCESSED_DIR ${ARCHIVE} 025x03125.NA)
update_pbar 13
echo ""
myprint "Archive:" "$ARCHIVE"
myprint "Month:" "$YEAR-$MONTH ($DAYS_IN_MONTH days)"
myprint "Downloaded:" $(printf "%4d/%-4d\n" $DOWNLOADED_FILES $(expr $DAYS_IN_MONTH \* $DOWNLOAD_EXPECTED_PER_DAY))
#printf "Downloaded: %4d/%-4d\n" $DOWNLOADED_FILES $(expr $DAYS_IN_MONTH \* $DOWNLOAD_EXPECTED_PER_DAY)
myprint "Processed 4x5:" $(printf "%4d/%-4d\n" $PROCESSED_4x5 $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 2x2.5:" $(printf "%4d/%-4d\n" $PROCESSED_2x25 $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.5x0.625:" $(printf "%4d/%-4d\n" $PROCESSED_05x0625 $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.5x0.625 (AS):" $(printf "%4d/%-4d\n" $PROCESSED_05x0625_AS $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.5x0.625 (CH):" $(printf "%4d/%-4d\n" $PROCESSED_05x0625_CH $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.5x0.625 (EU):" $(printf "%4d/%-4d\n" $PROCESSED_05x0625_EU $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.5x0.625 (NA):" $(printf "%4d/%-4d\n" $PROCESSED_05x0625_NA $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.25x0.3125:" $(printf "%4d/%-4d\n" $PROCESSED_025x03125 $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.25x0.3125 (AS):" $(printf "%4d/%-4d\n" $PROCESSED_025x03125_AS $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.25x0.3125 (CH):" $(printf "%4d/%-4d\n" $PROCESSED_025x03125_CH $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.25x0.3125 (EU):" $(printf "%4d/%-4d\n" $PROCESSED_025x03125_EU $(expr $DAYS_IN_MONTH \* 6))
myprint "Processed 0.25x0.3125 (NA):" $(printf "%4d/%-4d\n" $PROCESSED_025x03125_NA $(expr $DAYS_IN_MONTH \* 6))
if [[ "$ALL_OK" -eq 1 ]]; then
exit 0
else
exit 1
fi