-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgen_meteo.sh
executable file
·111 lines (83 loc) · 2.89 KB
/
gen_meteo.sh
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
#!/bin/bash
#
# This is a script to get a placeholder meteo for Kazakhstan
# from yesterdays global 0.2 forecast
#
set -e
set -u
#export MAILTO="$MAILTO,[email protected],[email protected]"
metdatdir=/lustre/tmp/silamdata/tmp
case `hostname` in
haze*)
getfileherepref="rsync -av eslogin:${metdatdir}"
cdoaec="-z aec"
;;
voima*|teho*|eslogin*)
. environment
getfileherepref="ln -s ${metdatdir}"
cdoaec=""
;;
*)
echo Unknown hostname `hostname`
exit 5
;;
esac
outdir=meteo
tmpdir=/dev/shm/KAZ-meteo
mkdir -p $tmpdir
cd $scriptdir
anmdh=`date -u -d "$fcdate - 1 day" +%m%d%H`
antime=`date -u -d "$fcdate - 1 day" +%Y%m%d`
## Clumsy. For some reason cdo can't handle different leveltypes smoothly
for hh in `seq 0 3 $((${maxhours}+24))`; do
valdate=`date -u -d "$hh hours $antime" +"%m%d%H"`
filebase=F4D${anmdh}00${valdate}001
tmpf="$tmpdir/$filebase"
outf=$outdir/$filebase
[ -f $outf ] && continue
echo Doing $getfileherepref/$filebase $tmpdir/
[ -e $tmpf ] || $getfileherepref/$filebase $tmpdir/
grib_copy -w typeOfLevel=surface $tmpf $tmpf-surface.tmp
cdo sellonlatbox,44.,90.,35.,61. $tmpf-surface.tmp $tmpf-surfacecut.tmp
cutlist="$tmpf-surfacecut.tmp"
rmlist="$tmpf-surface.tmp $tmpf-surfacecut.tmp"
if [ $hh -gt 0 ]; then
grib_copy -w typeOfLevel=hybrid $tmpf $tmpf-hybrid.tmp
grib_copy -w typeOfLevel=depthBelowLandLayer $tmpf $tmpf-soil.tmp
cdo ${cdoaec} sellonlatbox,44.,90.,35.,61. $tmpf-hybrid.tmp $tmpf-hybridcut.tmp
#cdo sellonlatbox,44.,90.,35.,61. $tmpf-hybrid.tmp $tmpf-hybridcut.tmp
cdo sellonlatbox,44.,90.,35.,61. $tmpf-soil.tmp $tmpf-soilcut.tmp
cutlist="$cutlist $tmpf-hybridcut.tmp $tmpf-soilcut.tmp"
rmlist="$rmlist $tmpf-hybrid.tmp $tmpf-hybridcut.tmp $tmpf-soil.tmp $tmpf-soilcut.tmp"
fi
cat $cutlist > $outf.tmp
#grib_set -w editionNumber=2 -s packingType=grid_ccsds $outf.tmp1 $outf.tmp
mv $outf.tmp $outf
ls -l $tmpf $outf
rm $tmpf $rmlist
# grib_set -w editionNumber=2 -s packingType=grid_ccsds $file $outf.tmp && mv $outf.tmp $outf
done
# Vegetation file
filebase=ecglob100_VEG_${antime}00+00.sfc
tmpf="$tmpdir/$filebase"
outf=$outdir/$filebase
if [ ! -f $outf ]; then
[ -e $tmpf ] || $getfileherepref/$filebase $tmpdir/
# rsync -av $file $tmpdir/
cdo sellonlatbox,44.,90.,35.,61. $tmpf ${outf}.tmp
mv ${outf}.tmp $outf
ls -l $tmpf $outf
rm $tmpf
fi
rm -rf $tmpdir
#echo 'Checking ECMWF VEG files'
#veg_latest=/lustre/tmp/silamdata/tmp/ecglob100_VEG__latest.sfc
#veg_latest_arch=/arch/silam/bulk/data/meteo/EC_OPER/veg/ecglob100_VEG__latest.sfc
#
#if [[ ! -r $veg_latest || $veg_latest -ot $veg_latest_arch ]]; then
# echo "Restoring VEG file"
# cp -pv $veg_latest_arch $veg_latest
#fi
#echo Done!
#
#exit 0