netcdf-c/hdf4_test/run_get_hdf4_files.sh

60 lines
1.3 KiB
Bash
Raw Normal View History

2010-06-03 21:24:43 +08:00
#!/bin/sh
# This shell gets some sample HDF4 files from the netCDF ftp site for
# testing. Then it runs program tst_interops3 on the test file to
# check that HDF4 reading works.
2010-06-03 21:24:43 +08:00
# Ed Hartnett
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
2010-06-03 21:24:43 +08:00
# Uncomment for quiet wget operation.
#Q=-q
2018-03-18 10:26:28 +08:00
# Get a file from the ftp site; retry several times
getfile() {
FTPFILE="ftp://ftp.unidata.ucar.edu/pub/netcdf/sample_data/hdf4/$1.gz"
2018-04-03 03:56:00 +08:00
for try in 1 2 3 4 ; do # try 4 times
2018-04-03 03:56:00 +08:00
2018-04-24 06:38:08 +08:00
# signal success/failure
if wget -c $Q --passive-ftp $FTPFILE || curl -O $FTPFILE ; then
2018-03-18 10:26:28 +08:00
return 0 # got it
fi
echo "wget failed: try $try"
sleep 5 # seconds
done
return 1 # did not get it
}
2010-06-03 21:24:43 +08:00
set -e
echo ""
echo "Getting HDF4 sample files from Unidata FTP site..."
2010-06-03 21:24:43 +08:00
file_list="AMSR_E_L2_Rain_V10_200905312326_A.hdf AMSR_E_L3_DailyLand_V06_20020619.hdf \
MYD29.A2009152.0000.005.2009153124331.hdf MYD29.A2002185.0000.005.2007160150627.hdf \
MOD29.A2000055.0005.005.2006267200024.hdf"
echo "Getting HDF4 test files $file_list"
for f1 in $file_list
do
if ! test -f $f1; then
2018-03-18 10:26:28 +08:00
if getfile $f1 ; then
gunzip $f1.gz
else
echo Could not ftp $f1.gz
return 1
fi
2010-06-03 21:24:43 +08:00
fi
done
echo ""
echo "Running test program to check HDF4 sample files..."
${execdir}/tst_interops3
2010-06-03 21:24:43 +08:00
echo "SUCCESS!!!"
exit 0