-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconvert_all.sh
More file actions
executable file
·118 lines (101 loc) · 2.41 KB
/
convert_all.sh
File metadata and controls
executable file
·118 lines (101 loc) · 2.41 KB
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
115
116
117
118
#!/bin/bash
#Copyright (C) 2025 by Forschungszentrum Juelich GmbH
#Author(s): Jens-Uw Grooss
export MAINDIR=$HOME/data-retrieval
export BINDIR=$MAINDIR/bin
. ${MAINDIR}/settings.default
if [ ! -f ${MAINDIR}/settings.config ]; then
echo Please copy the settings.example to settings.config and configure your setup!
exit 1
fi
. ${MAINDIR}/settings.config
cd $WORKDIR
export YEAR=`date +%Y`
export MONTH=`date +%m`
export DAY=`date +%d`
AMPM=`date +%p`
if [ $AMPM == AM ]
then
export HH=00
else
export HH=12
fi
# script should start at 06h/18h to look for 00 12h forecast
export h_exit=`date --date="+6hours" +%H`
for FCSTEP in $FCSTEPS
do
# Set path, filenames and variables used later in the script
export DATE=${YEAR}-${MONTH}-${DAY}
export YMD=${YEAR}${MONTH}${DAY}
export TIME=${HH}:00:00
export BASE=${DATASET}.${YMD}T${HH}.${FCSTEP}
export init_date=${DATE}T${TIME}
echo BASE: $BASE
export time_units="hours since ${init_date}"
lockfile=grib/${DATASET}.${YMD}T${HH}.${FCSTEP}.ready
echo `date` waiting for lockfile $lockfile
until test -e $lockfile
do
sleep 30
h_now=`date +%H`
if [[ $h_now == $h_exit ]]
then
echo lockfile $lockfile not found by `date`
echo exiting script
exit 1
fi
done
rm $lockfile
# Convert grib to netCDF, set init time
echo `date`: converting ${FCSTEP}h forecast
. $BINDIR/convert.sh
if [ $ECTRANS_ID == "none" ]
then
echo "no ectrans transfer -- move data to " $MSSDIR
if [ x$TRANSFER_MODEL_LEVELS == x"yes" ]; then
mv $mlfile $MSSDIR
fi
if [ -f $tlfile ]; then
mv $tlfile $MSSDIR
fi
if [ -f $plfile ]; then
mv $plfile $MSSDIR
fi
if [ -f $pvfile ]; then
mv $pvfile $MSSDIR
fi
if [ -f $alfile ]; then
mv $alfile $MSSDIR
fi
if [ -f $sfcfile ]; then
mv $sfcfile $MSSDIR
fi
fi
done
echo `date`: converting finished
if [[ x$CLEANUP == x"yes" ]]
then
export CYMD=${CLEANUP_YEAR}${CLEANUP_MONTH}${CLEANUP_DAY}
export CBASE=${DATASET}.${CYMD}T${HH}.${FCSTEP}
echo cleanup $CBASE
# clean up locally
for f in $mlfile $tlfile $plfile $pvfile $alfile $sfcfile grib/${CBASE}*.grib;
do
if [ -f $f ];
then
rm $f
fi
done
if [ $ECTRANS_ID == "none" ]
then
# clean up MSS server dir
for f in $MSSDIR/${CBASE}*.nc
do
if [ -f $f ];
then
rm $f
fi
done
fi
fi
echo `date`: ECMWF data converson finished