fixed some hdf4 configure settings, added more hdf4 tests

This commit is contained in:
Ed Hartnett 2011-01-28 18:01:37 +00:00
parent 2ebb1cbafc
commit 1d810b5034
2 changed files with 52 additions and 13 deletions

View File

@ -131,10 +131,22 @@ test "x$with_libcf" = xyes || with_libcf=no
AC_MSG_RESULT($with_libcf)
# Does the user want to turn on HDF4 read ability?
AC_MSG_CHECKING([whether reading of HDF4 SD files is to be enabled])
AC_ARG_ENABLE([hdf4], [AS_HELP_STRING([--enable-hdf4],
[build netcdf-4 with HDF4 read capability (HDF4, HDF5 and zlib required)])])
test "x$enable_hdf4" = xyes || enable_hdf4=no
# Did the user specify a location for the HDF4 library?
AC_MSG_CHECKING([whether a location for the HDF4 library was specified])
AC_ARG_WITH([hdf4],
[AS_HELP_STRING([--with-hdf4=<directory>],
[Specify location of HDF4 library. Configure will \
expect to find subdirs include and lib.])],
[HDF4DIR=$with_hdf4])
AC_MSG_RESULT([$HDF4DIR])
AC_SUBST(HDF4DIR, [$HDF4DIR])
test "x$with_hdf4" = "x" || enable_hdf4=yes
AC_MSG_CHECKING([whether reading of HDF4 SD files is to be enabled])
AC_MSG_RESULT($enable_hdf4)
# Does the user want to turn on extra HDF4 file tests?
@ -244,16 +256,6 @@ AC_ARG_WITH([szlib],
AC_MSG_RESULT([$SZLIBDIR])
AC_SUBST(SZLIBDIR, [$SZLIBDIR])
# Did the user specify a location for the HDF4 library?
AC_MSG_CHECKING([whether a location for the HDF4 library was specified])
AC_ARG_WITH([hdf4],
[AS_HELP_STRING([--with-hdf4=<directory>],
[Specify location of HDF4 library. Configure will \
expect to find subdirs include and lib.])],
[HDF4DIR=$with_hdf4])
AC_MSG_RESULT([$HDF4DIR])
AC_SUBST(HDF4DIR, [$HDF4DIR])
# Did the user specify a default chunk size?
AC_MSG_CHECKING([whether a default chunk size in bytes was specified])
AC_ARG_WITH([default-chunk-size],

View File

@ -18,7 +18,7 @@ int
main(int argc, char **argv)
{
printf("\n*** Testing HDF4/NetCDF-4 interoperability...\n");
printf("*** Creating a HDF4 file...");
printf("*** testing that netCDF can read a HDF4 file with some ints...");
{
#define PRES_NAME "pres"
#define LAT_LEN 3
@ -32,6 +32,8 @@ main(int argc, char **argv)
size_t len_in;
int data_out[LAT_LEN][LON_LEN], data_in[LAT_LEN][LON_LEN];
size_t nstart[DIMS_2] = {0, 0}, ncount[DIMS_2] = {LAT_LEN, LON_LEN};
size_t nindex[DIMS_2] = {0, 0};
int scalar_data_in = 0;
int i, j;
/* Create some data. */
@ -55,12 +57,47 @@ main(int argc, char **argv)
if (nc_inq_dim(ncid, 1, NULL, &len_in)) ERR;
if (len_in != LON_LEN) ERR;
/* Read the data through the netCDF API. */
/* Read the data through a vara function from the netCDF API. */
if (nc_get_vara(ncid, 0, nstart, ncount, data_in)) ERR;
for (i = 0; i < LAT_LEN; i++)
for (j = 0; j < LON_LEN; j++)
if (data_in[i][j] != data_out[i][j]) ERR;
/* Reset for next test. */
for (i = 0; i < LAT_LEN; i++)
for (j = 0; j < LON_LEN; j++)
data_in[i][j] = -88;
/* Read the data through a vara_int function from the netCDF API. */
if (nc_get_vara_int(ncid, 0, nstart, ncount, data_in)) ERR;
for (i = 0; i < LAT_LEN; i++)
for (j = 0; j < LON_LEN; j++)
if (data_in[i][j] != data_out[i][j]) ERR;
/* Reset for next test. */
for (i = 0; i < LAT_LEN; i++)
for (j = 0; j < LON_LEN; j++)
data_in[i][j] = -88;
/* Read the data through a var_int function from the netCDF API. */
if (nc_get_var_int(ncid, 0, data_in)) ERR;
for (i = 0; i < LAT_LEN; i++)
for (j = 0; j < LON_LEN; j++)
if (data_in[i][j] != data_out[i][j]) ERR;
/* Read the data through a var1 function from the netCDF API. */
for (i = 0; i < LAT_LEN; i++)
for (j = 0; j < LON_LEN; j++)
{
nindex[0] = i;
nindex[1] = j;
if (nc_get_var1(ncid, 0, nindex, &scalar_data_in)) ERR;
if (scalar_data_in != data_out[i][j]) ERR;
scalar_data_in = -88; /* reset */
if (nc_get_var1_int(ncid, 0, nindex, &scalar_data_in)) ERR;
if (scalar_data_in != data_out[i][j]) ERR;
}
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;