2010-06-03 21:24:43 +08:00
|
|
|
/*
|
2018-12-07 05:56:42 +08:00
|
|
|
Copyright 2018, UCAR/Unidata
|
2010-06-03 21:24:43 +08:00
|
|
|
See COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
|
|
|
|
This is part of netCDF.
|
2016-10-22 01:17:39 +08:00
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
This program runs some extra tests.
|
|
|
|
|
|
|
|
$Id: tst_misc.c,v 1.6 2010/05/05 22:15:36 dmh Exp $
|
|
|
|
*/
|
|
|
|
|
2015-08-16 06:26:35 +08:00
|
|
|
#include "config.h"
|
2010-06-03 21:24:43 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2015-08-16 06:26:35 +08:00
|
|
|
#include "netcdf.h"
|
|
|
|
#include "nc_tests.h"
|
2016-10-22 01:17:39 +08:00
|
|
|
#include "err_macros.h"
|
2015-08-16 06:26:35 +08:00
|
|
|
#ifdef USE_PARALLEL
|
|
|
|
#include "netcdf_par.h"
|
|
|
|
#endif
|
2010-06-03 21:24:43 +08:00
|
|
|
|
|
|
|
#define FILE_NAME "tst_misc.nc"
|
|
|
|
|
|
|
|
int
|
2016-10-22 01:17:39 +08:00
|
|
|
main(int argc, char **argv)
|
2010-06-03 21:24:43 +08:00
|
|
|
{
|
2015-08-16 06:26:35 +08:00
|
|
|
#ifdef TEST_PNETCDF
|
|
|
|
MPI_Init(&argc, &argv);
|
|
|
|
#endif
|
2010-06-03 21:24:43 +08:00
|
|
|
printf("\n*** Testing some extra stuff.\n");
|
|
|
|
printf("*** Trying to open non-netCDF files of tiny length...");
|
|
|
|
{
|
2016-10-22 01:17:39 +08:00
|
|
|
#define DATA_LEN 32
|
2012-12-08 07:21:27 +08:00
|
|
|
int ncid,openstat;
|
2010-06-03 21:24:43 +08:00
|
|
|
char dummy_data[DATA_LEN];
|
|
|
|
FILE *file;
|
|
|
|
int i;
|
|
|
|
|
2010-11-30 06:23:16 +08:00
|
|
|
/* Appease valgrind by initializing our data. */
|
|
|
|
for (i = 0; i < DATA_LEN; i++)
|
|
|
|
dummy_data[i] = i;
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
for (i = DATA_LEN; i >= 0; i--)
|
|
|
|
{
|
|
|
|
/* Create a small file which is not a netCDF file. */
|
|
|
|
if (!(file = fopen(FILE_NAME, "w+"))) ERR;
|
|
|
|
if (fwrite(dummy_data, 1, i, file) != i) ERR;
|
|
|
|
if (fclose(file)) ERR;
|
2016-10-22 01:17:39 +08:00
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
/* Make sure that netCDF rejects this file politely. */
|
2015-08-16 06:26:35 +08:00
|
|
|
#ifdef TEST_PNETCDF
|
2018-09-23 09:22:34 +08:00
|
|
|
openstat = nc_open_par(FILE_NAME, 0, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
|
2015-08-16 06:26:35 +08:00
|
|
|
#else
|
|
|
|
openstat = nc_open(FILE_NAME, 0, &ncid);
|
|
|
|
#endif
|
2012-12-08 07:21:27 +08:00
|
|
|
/* Some platforms (OSX, buddy) return stat = 2 (file not found)
|
|
|
|
for index i == 2. Not sure why, but this is a work around. */
|
|
|
|
if(openstat != NC_ENOTNC && openstat != 2) ERR;
|
2016-10-22 01:17:39 +08:00
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SUMMARIZE_ERR;
|
The big change for this commit is complete the
disengagement of enable-netcdf4 from enable-hdf5.
That is, with the advent of nczarr, it is possible
to turn off hdf5 but still need netcdf-4 enabled
because nczarr uses libsrc4, but not libhdf5.
This change involves a bunch of things:
1. Modify configure.ac and CMakelist to make enable_hdf5
control if hdf5 support is provided. For back compatibility,
disable-netcdf4 is treated as disable-hdf5. But internally,
netcdf4 support is controlled only by the enabling of formats
that require it.
2. In support of #1, modify .travis.yml to use enable/disable-hdf5
instead of enable/disable-netcdf4.
3. test_common.in is modified to track selected features,
including enable-hdf5 and enable-s3-tests. This is used in
selected tests that mix netcdf-3 and netcdf4 tests.
4. The conflation of USE_HDF5 and USE_NETCDF4 is common in
code, tests, and build files, so all of those had to be weeded out.
5. It turns out that some of the NC4_dim functions really are HDF5 specific,
but are not treated as such. So they are moved from nc4dim.c to
hdf5dim.c or hdf5dispatch.c
6. Some generic functions in libhdf5 can be (and were) moved to libsrc4.
2020-08-13 05:42:50 +08:00
|
|
|
#ifndef USE_HDF5
|
2017-11-13 23:09:15 +08:00
|
|
|
printf("*** Trying to create netCDF-4 file without netCDF-4...");
|
|
|
|
{
|
|
|
|
int ncid;
|
2018-12-07 05:56:42 +08:00
|
|
|
|
2017-11-13 23:09:15 +08:00
|
|
|
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid) != NC_ENOTBUILT)
|
|
|
|
ERR;
|
|
|
|
}
|
|
|
|
SUMMARIZE_ERR;
|
The big change for this commit is complete the
disengagement of enable-netcdf4 from enable-hdf5.
That is, with the advent of nczarr, it is possible
to turn off hdf5 but still need netcdf-4 enabled
because nczarr uses libsrc4, but not libhdf5.
This change involves a bunch of things:
1. Modify configure.ac and CMakelist to make enable_hdf5
control if hdf5 support is provided. For back compatibility,
disable-netcdf4 is treated as disable-hdf5. But internally,
netcdf4 support is controlled only by the enabling of formats
that require it.
2. In support of #1, modify .travis.yml to use enable/disable-hdf5
instead of enable/disable-netcdf4.
3. test_common.in is modified to track selected features,
including enable-hdf5 and enable-s3-tests. This is used in
selected tests that mix netcdf-3 and netcdf4 tests.
4. The conflation of USE_HDF5 and USE_NETCDF4 is common in
code, tests, and build files, so all of those had to be weeded out.
5. It turns out that some of the NC4_dim functions really are HDF5 specific,
but are not treated as such. So they are moved from nc4dim.c to
hdf5dim.c or hdf5dispatch.c
6. Some generic functions in libhdf5 can be (and were) moved to libsrc4.
2020-08-13 05:42:50 +08:00
|
|
|
#endif /* USE_HDF5 undefined */
|
2018-12-07 05:56:42 +08:00
|
|
|
|
2015-08-16 06:26:35 +08:00
|
|
|
#ifdef TEST_PNETCDF
|
|
|
|
MPI_Finalize();
|
|
|
|
#endif
|
2018-12-07 05:56:42 +08:00
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
FINAL_RESULTS;
|
|
|
|
}
|