-
Notifications
You must be signed in to change notification settings - Fork 2
/
averagefieldspace.cgi
executable file
·65 lines (55 loc) · 1.74 KB
/
averagefieldspace.cgi
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
#!/bin/bash
cat <<EOF
Content-Type: text/html
EOF
. ./init.cgi
. ./getargs.cgi
# check email address
. ./checkemail.cgi
if [ "$EMAIL" = "someone@somewhere" ]; then
echo "Anonymous users cannot use this function as it stores new data on the server. Please <a href=\"registerform.cgi\">register or log in</a>"
. ./myvinkfoot.cgi
exit
fi
if [ $EMAIL = [email protected] ]; then
lwrite=false # true
fi
. ./save_averagefieldspace.cgi
. ./queryfield.cgi
. ./myvinkhead.cgi "Computing derived field" "$kindname $climfield" "noindex,nofollow"
# prevent abuse...
if [ "FORM_avex" = 1 -a "$FORM_avey" = "1" ]; then
echo "The data is already at this spatial resolution. Nothing to do, nothing done."
. ./myvinkfoot.cgi
exit
fi
kindname="${FORM_avex}x${FORM_avey} average of $kindname"
corrargs="$file $FORM_avex $FORM_avey"
outfile=data/`basename ${FORM_field}_${FORM_avex}_${FORM_avey}`
testfile=`echo "$outfile" | tr '%' '0'`
if [ ! -s $testfile.nc -o $testfile.nc -ot $file ]; then
[ "$lwrite" = true ] && echo "averagefieldspace.sh $corrargs $outfile.nc"
echo `date` "$EMAIL ($REMOTE_ADDR) averagefieldspace.sh $corrargs $outfile.nc" >> log/log
(./bin/averagefieldspace.sh $corrargs $outfile.nc) 2>&1
fi
if [ -n "$LSMASK" ]; then
maskfile=data/lsmask_`basename $outfile`
corrargs="$LSMASK $FORM_avex $FORM_avey"
if [ ! -s $maskfile.nc ]; then
[ "$lwrite" = true ] && echo "averagefieldspace.sh $corrargs $maskfile.nc"
(./bin/averagefieldspace $corrargs $maskfile.nc) 2>&1
fi
LSMASK=$maskfile.nc
fi
infofile=$outfile.$EMAIL.info
###echo "cat > $infofile <<EOF"
cat > $infofile <<EOF
$outfile.nc
NPERYEAR=$NPERYEAR
LSMASK=$LSMASK
$kindname
$climfield
EOF
# rest is standard
FORM_field=$infofile
. ./select.cgi