diff --git a/nc_test/CMakeLists.txt b/nc_test/CMakeLists.txt index 08b709068..2d7a7c1d8 100644 --- a/nc_test/CMakeLists.txt +++ b/nc_test/CMakeLists.txt @@ -15,30 +15,14 @@ SET (nc_test_SRC util.c ) -SET (nc_test2_SRC - nc_test2.c - error.c - test_get.c - test_put.c - test_read.c - test_write.c - util.c - ) - ADD_EXECUTABLE(nc_test ${nc_test_SRC}) TARGET_LINK_LIBRARIES(nc_test netcdf ${HAVE_LIBM} ) -ADD_EXECUTABLE(nc_test2 ${nc_test2_SRC}) -TARGET_LINK_LIBRARIES(nc_test2 - netcdf - ${HAVE_LIBM} - ) - # Some extra stand-alone tests -SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta cdf5_gh159_test) +SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta) IF(NOT HAVE_BASH) SET(TESTS ${TESTS} tst_atts3) @@ -83,7 +67,6 @@ FOREACH(CTEST ${TESTS}) ENDFOREACH() ADD_TEST(nc_test ${EXECUTABLE_OUTPUT_PATH}/nc_test) -ADD_TEST(nc_test2 ${EXECUTABLE_OUTPUT_PATH}/nc_test) IF(BUILD_DISKLESS) add_sh_test(nc_test run_diskless) diff --git a/nc_test/cdf5_gh159_test.c b/nc_test/cdf5_gh159_test.c deleted file mode 100644 index f3e5b3e9b..000000000 --- a/nc_test/cdf5_gh159_test.c +++ /dev/null @@ -1,161 +0,0 @@ -#include -#include -#include - -#define RANK_y3 1 -#define RANK_y3d 1 -#define FILENAME "cdf5_test.nc" - -void -check_err(const int stat, const int line, const char *file) { - if (stat != NC_NOERR) { - (void)fprintf(stderr,"[err: %d] line %d of %s: %s\n", stat, line, file, nc_strerror(stat)); - fflush(stderr); - exit(1); - } -} - -int -main() {/* create cdf5_test */ - - int stat; /* return status */ - int ncid; /* netCDF id */ - - /* dimension ids */ - int D3_dim; - - /* dimension lengths */ - size_t D3_len = 3; - - /* variable ids */ - int y3_id; - int y3d_id; - int i = 0; - int y3_dims[RANK_y3]; - int y3d_dims[RANK_y3d]; - - /* Lets do a bit of other - testing here too. */ - { - int xx = 0; - signed char *tp = (signed char*)malloc(sizeof(signed char)*3); - signed char *tph = tp; - unsigned char *xp = (unsigned char *)malloc(sizeof(unsigned char)*3); - unsigned char *xph = xp; - tp[0] = -2; - tp[1] = 255; - tp[2] = -1; - - for(i = 0; i < 3; i++) - *xp++ = (unsigned char)*tp++; - - xx = 1; - } - - /* enter define mode */ - stat = nc_create(FILENAME, NC_CLOBBER | NC_64BIT_DATA, &ncid); - check_err(stat,__LINE__,__FILE__); - - stat = nc_def_dim(ncid, "D3", D3_len, &D3_dim); - check_err(stat,__LINE__,__FILE__); - - /* define variables */ - - //y3_dims[0] = D3_dim; - //stat = nc_def_var(ncid, "y3", NC_UBYTE, RANK_y3, y3_dims, &y3_id); - //check_err(stat,__LINE__,__FILE__); - - y3d_dims[0] = D3_dim; - stat = nc_def_var(ncid, "y3d", NC_UBYTE, RANK_y3d, y3d_dims, &y3d_id); - check_err(stat,__LINE__,__FILE__); - - - /* assign global attributes */ - - { - stat = nc_put_att_text(ncid, NC_GLOBAL, "Gc", 1, "€"); - check_err(stat,__LINE__,__FILE__); - } - - { - static const signed char nc_test_cdf5_Gb_att[2] = {-128, 127} ; - stat = nc_put_att_schar(ncid, NC_GLOBAL, "Gb", NC_BYTE, 2, nc_test_cdf5_Gb_att); - check_err(stat,__LINE__,__FILE__); - } - - { - static const short nc_test_cdf5_Gs_att[3] = {3333, 3333, 3332} ; - stat = nc_put_att_short(ncid, NC_GLOBAL, "Gs", NC_SHORT, 3, nc_test_cdf5_Gs_att); - check_err(stat,__LINE__,__FILE__); - } - - { - static const int nc_test_cdf5_Gi_att[4] = {2222, 2222, 2221, 2223} ; - stat = nc_put_att_int(ncid, NC_GLOBAL, "Gi", NC_INT, 4, nc_test_cdf5_Gi_att); - check_err(stat,__LINE__,__FILE__); - } - - { - static const float nc_test_cdf5_Gf_att[5] = {((float)300), ((float)300), ((float)300), ((float)300), ((float)531)} ; - stat = nc_put_att_float(ncid, NC_GLOBAL, "Gf", NC_FLOAT, 5, nc_test_cdf5_Gf_att); - check_err(stat,__LINE__,__FILE__); - } - - { - static const double nc_test_cdf5_Gd_att[6] = {((double)1000), ((double)1000), ((double)-1), ((double)1), ((double)660), ((double)650)} ; - stat = nc_put_att_double(ncid, NC_GLOBAL, "Gd", NC_DOUBLE, 6, nc_test_cdf5_Gd_att); - check_err(stat,__LINE__,__FILE__); - } - - { - static const unsigned char nc_test_cdf5_Gy_att[7] = {0U, 255U, 255U, 0U, 36U, 38U, 40U} ; - stat = nc_put_att_ubyte(ncid, NC_GLOBAL, "Gy", NC_UBYTE, 7, nc_test_cdf5_Gy_att); check_err(stat,__LINE__,__FILE__); - } - - { - static const unsigned short nc_test_cdf5_Gt_att[8] = {0U, 65535U, 65535U, 0U, 195U, 200U, 205U, 210U} ; - stat = nc_put_att_ushort(ncid, NC_GLOBAL, "Gt", NC_USHORT, 8, nc_test_cdf5_Gt_att); check_err(stat,__LINE__,__FILE__); - } - - { - static const unsigned long long nc_test_cdf5_Gu_att[9] = {0ULL, 4294967295ULL, 4294967295ULL, 0ULL, 2880ULL, 2900ULL, 2920ULL, 2940ULL, 2960ULL} ; - stat = nc_put_att_ulonglong(ncid, NC_GLOBAL, "Gu", NC_UINT64, 9, nc_test_cdf5_Gu_att); check_err(stat,__LINE__,__FILE__); - } - - { - static const signed long long nc_test_cdf5_Gx_att[10] = {-2147483776LL, 2147483775LL, -1LL, 1LL, 2720LL, 2700LL, 2680LL, 2660LL, 2640LL, 2620LL} ; - stat = nc_put_att_longlong(ncid, NC_GLOBAL, "Gx", NC_INT64, 10, nc_test_cdf5_Gx_att); check_err(stat,__LINE__,__FILE__); - } - - { - static const unsigned long long nc_test_cdf5_Gz_att[11] = {0ULL, 4294967423ULL, 18446744073709551615ULL, 1ULL, 2880ULL, 2900ULL, 2920ULL, 2940ULL, 2960ULL, 2980ULL, 3000ULL} ; - stat = nc_put_att_ulonglong(ncid, NC_GLOBAL, "Gz", NC_UINT64, 11, nc_test_cdf5_Gz_att); check_err(stat,__LINE__,__FILE__); - } - - - /* leave define mode */ - stat = nc_enddef (ncid); - check_err(stat,__LINE__,__FILE__); - - /* assign variable data */ - { - double y3d_data[3] = {-2, 255, -1} ; - size_t y3d_startset[1] = {0} ; - size_t y3d_countset[1] = {3}; - nc_put_vara_double(ncid,y3d_id,y3d_startset,y3d_countset,y3d_data); - //stat = nc_put_vara(ncid, y3d_id, y3d_startset, y3d_countset, y3d_data); - check_err(stat,__LINE__,__FILE__); - } - /* - { - double y3_data[3] = {0U, 255U, 255U} ; - size_t y3_startset[1] = {0} ; - size_t y3_countset[1] = {3}; - stat = nc_put_vara_double(ncid, y3_id, y3_startset, y3_countset, y3_data); - check_err(stat,__LINE__,__FILE__); - } - */ - stat = nc_close(ncid); - check_err(stat,__LINE__,__FILE__); - return 0; -} diff --git a/nc_test/nc_test2.c b/nc_test/nc_test2.c deleted file mode 100644 index 9046dc7fb..000000000 --- a/nc_test/nc_test2.c +++ /dev/null @@ -1,379 +0,0 @@ -/********************************************************************* - * Copyright 1996-2005, UCAR/Unidata - * See COPYRIGHT file for copying and redistribution conditions. - * $Id: nc_test.c 2796 2014-10-28 03:40:29Z wkliao $ - *********************************************************************/ - -int numGatts; /* number of global attributes */ -int numVars; /* number of variables */ -int numTypes; /* number of netCDF data types to test */ - -#include "tests.h" - -/* - * Test driver for netCDF-3 interface. This program performs tests against - * the netCDF-3 specification for all user-level functions in an - * implementation of the netCDF library. - * - * Files: - * The read-only tests read files: - * test.nc (see below) - * tests.h (used merely as an example of a non-netCDF file) - * - * The write tests - * read test.nc (see below) - * write scratch.nc (deleted after each test) - * - * The file test.nc is created by running nc_test with the -c (create) option. - * It is described by the following global variables. - */ - -/* - * global variables (defined by function init_gvars) describing file test.nc - */ -char dim_name[NDIMS][3]; -size_t dim_len[NDIMS]; -char var_name[NVARS][2+MAX_RANK]; -nc_type var_type[NVARS]; -size_t var_rank[NVARS]; -int var_dimid[NVARS][MAX_RANK]; -size_t var_shape[NVARS][MAX_RANK]; -size_t var_nels[NVARS]; -size_t var_natts[NVARS]; -char att_name[NVARS][MAX_NATTS][2]; -char gatt_name[NGATTS][3]; -nc_type att_type[NVARS][NGATTS]; -nc_type gatt_type[NGATTS]; -size_t att_len[NVARS][MAX_NATTS]; -size_t gatt_len[NGATTS]; - -/* - * command-line options - */ -int verbose; /* if 1, print details of tests */ -int max_nmpt; /* max. number of messages per test */ - -/* - * Misc. global variables - */ -int nfails; /* number of failures in specific test */ -char testfile[NC_MAX_NAME]; -char scratch[] = "scratch.nc"; /* writable scratch file */ - -#define NC_TEST(func) \ - print( "*** testing " #func " ... ");\ - nfails = 0;\ - test_ ## func();\ - nfailsTotal += nfails;\ - if (verbose) \ - print("\n"); \ - if ( nfails == 0) \ - print( "ok\n");\ - else\ - print( "\n\t### %d FAILURES TESTING %s! ###\n", nfails, #func) - - -#if 1 /* both CRAY MPP and OSF/1 Alpha systems need this */ -#include -#endif /* T90 */ - -/* Test everything for classic and 64-bit offsetfiles. If netcdf-4 is - * included, that means another whole round of testing. */ -#define NUM_FORMATS (5) - -int -main(int argc, char *argv[]) -{ - int i = 5; - int nfailsTotal = 0; /* total number of failures */ - -#ifdef USE_PNETCDF - MPI_Init(&argc, &argv); -#endif - /* Both CRAY MPP and OSF/1 Alpha systems need this. Some of the - * extreme test assignments in this program trigger floating point - * exceptions on CRAY T90 - */ - (void) signal(SIGFPE, SIG_IGN); - - verbose = 1; - max_nmpt = 8; - - /* If you uncomment the nc_set_log_level line, you will get a lot - * of debugging info. If you set the number higher, you'll get - * more. 6 is max, 0 shows only errors. 3 is a good place to - * start. */ - /*nc_set_log_level(3);*/ - - fprintf(stderr, "Testing %d different netCDF formats.\n", NUM_FORMATS); - - /* Go thru formats and run all tests for each of two (for netCDF-3 - * only builds), or 3 (for netCDF-4 builds) different formats. Do - * the netCDF-4 format last, however, because, as an additional - * test, the ../nc_test4/tst_nc_test_file program looks at the - * output of this program. */ - for (i = 5; i <= NUM_FORMATS; i++) - { - numGatts = 6; - numVars = 136; - numTypes = 6; - - switch (i) - { - case NC_FORMAT_CLASSIC: - nc_set_default_format(NC_FORMAT_CLASSIC, NULL); - fprintf(stderr, "\n\nSwitching to netCDF classic format.\n"); - strcpy(testfile, "nc_test_classic.nc"); - break; - case NC_FORMAT_64BIT_OFFSET: - nc_set_default_format(NC_FORMAT_64BIT_OFFSET, NULL); - fprintf(stderr, "\n\nSwitching to 64-bit offset format.\n"); - strcpy(testfile, "nc_test_64bit.nc"); - break; - case NC_FORMAT_CDF5: - nc_set_default_format(NC_FORMAT_CDF5, NULL); - fprintf(stderr, "\n\nSwitching to 64-bit data format.\n"); - strcpy(testfile, "nc_test_cdf5.nc"); - numGatts = NGATTS; - numVars = NVARS; - numTypes = NTYPES; - break; - case NC_FORMAT_NETCDF4_CLASSIC: - case NC_FORMAT_NETCDF4: /* actually it's _CLASSIC. */ -#ifdef USE_NETCDF4 - nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL); - strcpy(testfile, "nc_test_netcdf4.nc"); - fprintf(stderr, "\n\nSwitching to netCDF-4 format (with NC_CLASSIC_MODEL).\n"); - break; -#else - continue; /* loop i */ -#endif - default: - fprintf(stderr, "Unexpected format!\n"); - return 2; - } - - /* Initialize global variables defining test file */ - init_gvars(); - - /* Write the test file, needed for the read-only tests below. */ - write_file(testfile); - - /* delete any existing scratch netCDF file */ - (void) remove(scratch); - - /* Test read-only functions, using pre-generated test-file */ - NC_TEST(nc_strerror); - NC_TEST(nc_open); - NC_TEST(nc_close); - NC_TEST(nc_inq); - NC_TEST(nc_inq_dimid); - NC_TEST(nc_inq_dim); - NC_TEST(nc_inq_dimlen); - NC_TEST(nc_inq_dimname); - NC_TEST(nc_inq_varid); - NC_TEST(nc_inq_var); - NC_TEST(nc_inq_natts); - NC_TEST(nc_inq_ndims); - NC_TEST(nc_inq_nvars); - NC_TEST(nc_inq_unlimdim); - NC_TEST(nc_inq_vardimid); - NC_TEST(nc_inq_varname); - NC_TEST(nc_inq_varnatts); - NC_TEST(nc_inq_varndims); - NC_TEST(nc_inq_vartype); - NC_TEST(nc_get_var_text); - NC_TEST(nc_get_var_uchar); - NC_TEST(nc_get_var_schar); - /* - NC_TEST(nc_get_var_short); - NC_TEST(nc_get_var_int); - NC_TEST(nc_get_var_long); - NC_TEST(nc_get_var_float); - NC_TEST(nc_get_var_double); - NC_TEST(nc_get_var_ushort); - NC_TEST(nc_get_var_uint); - NC_TEST(nc_get_var_longlong); - NC_TEST(nc_get_var_ulonglong); - NC_TEST(nc_get_var1_text); - NC_TEST(nc_get_var1_uchar); - NC_TEST(nc_get_var1_schar); - NC_TEST(nc_get_var1_short); - NC_TEST(nc_get_var1_int); - NC_TEST(nc_get_var1_long); - NC_TEST(nc_get_var1_float); - NC_TEST(nc_get_var1_double); - NC_TEST(nc_get_var1_ushort); - NC_TEST(nc_get_var1_uint); - NC_TEST(nc_get_var1_longlong); - NC_TEST(nc_get_var1_ulonglong); - NC_TEST(nc_get_var1); - NC_TEST(nc_get_vara_text); - NC_TEST(nc_get_vara_uchar); - NC_TEST(nc_get_vara_schar); - NC_TEST(nc_get_vara_short); - NC_TEST(nc_get_vara_int); - NC_TEST(nc_get_vara_long); - NC_TEST(nc_get_vara_float); - NC_TEST(nc_get_vara_double); - NC_TEST(nc_get_vara_ushort); - NC_TEST(nc_get_vara_uint); - NC_TEST(nc_get_vara_longlong); - NC_TEST(nc_get_vara_ulonglong); - NC_TEST(nc_get_vara); - NC_TEST(nc_get_vars_text); - NC_TEST(nc_get_vars_uchar); - NC_TEST(nc_get_vars_schar); - NC_TEST(nc_get_vars_short); - NC_TEST(nc_get_vars_int); - NC_TEST(nc_get_vars_long); - NC_TEST(nc_get_vars_float); - NC_TEST(nc_get_vars_double); - NC_TEST(nc_get_vars_ushort); - NC_TEST(nc_get_vars_uint); - NC_TEST(nc_get_vars_longlong); - NC_TEST(nc_get_vars_ulonglong); - NC_TEST(nc_get_vars); - NC_TEST(nc_get_varm_text); - NC_TEST(nc_get_varm_uchar); - NC_TEST(nc_get_varm_schar); - NC_TEST(nc_get_varm_short); - NC_TEST(nc_get_varm_int); - NC_TEST(nc_get_varm_long); - NC_TEST(nc_get_varm_float); - NC_TEST(nc_get_varm_double); - NC_TEST(nc_get_varm_ushort); - NC_TEST(nc_get_varm_uint); - NC_TEST(nc_get_varm_longlong); - NC_TEST(nc_get_varm_ulonglong); - NC_TEST(nc_get_varm); - NC_TEST(nc_get_att_text); - NC_TEST(nc_get_att_uchar); - NC_TEST(nc_get_att_schar); - NC_TEST(nc_get_att_short); - NC_TEST(nc_get_att_int); - NC_TEST(nc_get_att_long); - NC_TEST(nc_get_att_float); - NC_TEST(nc_get_att_double); - NC_TEST(nc_get_att_ushort); - NC_TEST(nc_get_att_uint); - NC_TEST(nc_get_att_longlong); - NC_TEST(nc_get_att_ulonglong); - NC_TEST(nc_get_att); - NC_TEST(nc_inq_att); - NC_TEST(nc_inq_attname); - NC_TEST(nc_inq_attid); - NC_TEST(nc_inq_attlen); - NC_TEST(nc_inq_atttype); - */ - /* Test write functions */ - //NC_TEST(nc_create); - //NC_TEST(nc_redef); - /* NC_TEST(nc_enddef); *//* redundant */ - /* - NC_TEST(nc_sync); - NC_TEST(nc_abort); - NC_TEST(nc_def_dim); - NC_TEST(nc_rename_dim); - NC_TEST(nc_def_var); - NC_TEST(nc_put_var_text); - NC_TEST(nc_put_var_uchar); - NC_TEST(nc_put_var_schar); - NC_TEST(nc_put_var_short); - NC_TEST(nc_put_var_int); - NC_TEST(nc_put_var_long); - NC_TEST(nc_put_var_float); - NC_TEST(nc_put_var_double); - NC_TEST(nc_put_var_ushort); - NC_TEST(nc_put_var_uint); - NC_TEST(nc_put_var_longlong); - NC_TEST(nc_put_var_ulonglong); - NC_TEST(nc_put_var1_text); - NC_TEST(nc_put_var1_uchar); - NC_TEST(nc_put_var1_schar); - NC_TEST(nc_put_var1_short); - NC_TEST(nc_put_var1_int); - NC_TEST(nc_put_var1_long); - NC_TEST(nc_put_var1_float); - NC_TEST(nc_put_var1_double); - NC_TEST(nc_put_var1_ushort); - NC_TEST(nc_put_var1_uint); - NC_TEST(nc_put_var1_longlong); - NC_TEST(nc_put_var1_ulonglong); - NC_TEST(nc_put_var1); - NC_TEST(nc_put_vara_text); - NC_TEST(nc_put_vara_uchar); - NC_TEST(nc_put_vara_schar); - NC_TEST(nc_put_vara_short); - NC_TEST(nc_put_vara_int); - NC_TEST(nc_put_vara_long); - NC_TEST(nc_put_vara_float); - NC_TEST(nc_put_vara_double); - NC_TEST(nc_put_vara_ushort); - NC_TEST(nc_put_vara_uint); - NC_TEST(nc_put_vara_longlong); - NC_TEST(nc_put_vara_ulonglong); - NC_TEST(nc_put_vara); - NC_TEST(nc_put_vars_text); - NC_TEST(nc_put_vars_uchar); - NC_TEST(nc_put_vars_schar); - NC_TEST(nc_put_vars_short); - NC_TEST(nc_put_vars_int); - NC_TEST(nc_put_vars_long); - NC_TEST(nc_put_vars_float); - NC_TEST(nc_put_vars_double); - NC_TEST(nc_put_vars_ushort); - NC_TEST(nc_put_vars_uint); - NC_TEST(nc_put_vars_longlong); - NC_TEST(nc_put_vars_ulonglong); - NC_TEST(nc_put_vars); - NC_TEST(nc_put_varm_text); - NC_TEST(nc_put_varm_uchar); - NC_TEST(nc_put_varm_schar); - NC_TEST(nc_put_varm_short); - NC_TEST(nc_put_varm_int); - NC_TEST(nc_put_varm_long); - NC_TEST(nc_put_varm_float); - NC_TEST(nc_put_varm_double); - NC_TEST(nc_put_varm_ushort); - NC_TEST(nc_put_varm_uint); - NC_TEST(nc_put_varm_longlong); - NC_TEST(nc_put_varm_ulonglong); - NC_TEST(nc_put_varm); - NC_TEST(nc_rename_var); - NC_TEST(nc_put_att_text); - NC_TEST(nc_put_att_uchar); - NC_TEST(nc_put_att_schar); - NC_TEST(nc_put_att_short); - NC_TEST(nc_put_att_int); - NC_TEST(nc_put_att_long); - NC_TEST(nc_put_att_float); - NC_TEST(nc_put_att_ulonglong); - NC_TEST(nc_put_att_ushort); - NC_TEST(nc_put_att_uint); - NC_TEST(nc_put_att_longlong); - NC_TEST(nc_put_att_ulonglong); - NC_TEST(nc_put_att); - NC_TEST(nc_copy_att); - NC_TEST(nc_rename_att); - NC_TEST(nc_del_att); - NC_TEST(nc_set_default_format); - */ - } - - fprintf(stderr, "\n*** Total number of failures: %d\n", nfailsTotal); - - if (nfailsTotal) - { - fprintf(stderr, "*** nc_test FAILURE!!!\n"); - return 2; - } - else - fprintf(stderr, "*** nc_test SUCCESS!!!\n"); - -#ifdef USE_PNETCDF - MPI_Finalize(); -#endif - exit(0); - return 0; -}