mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
3db4f013bf
Specific changes: 1. Add dap4 code: libdap4 and dap4_test. Note that until the d4ts server problem is solved, dap4 is turned off. 2. Modify various files to support dap4 flags: configure.ac, Makefile.am, CMakeLists.txt, etc. 3. Add nc_test/test_common.sh. This centralizes the handling of the locations of various things in the build tree: e.g. where is ncgen.exe located. See nc_test/test_common.sh for details. 4. Modify .sh files to use test_common.sh 5. Obsolete separate oc2 by moving it to be part of netcdf-c. This means replacing code with netcdf-c equivalents. 5. Add --with-testserver to configure.ac to allow override of the servers to be used for --enable-dap-remote-tests. 6. There were multiple versions of nctypealignment code. Try to centralize in libdispatch/doffset.c and include/ncoffsets.h 7. Add a unit test for the ncuri code because of its complexity. 8. Move the findserver code out of libdispatch and into a separate, self contained program in ncdap_test and dap4_test. 9. Move the dispatch header files (nc{3,4}dispatch.h) to .../include because they are now shared by modules. 10. Revamp the handling of TOPSRCDIR and TOPBUILDDIR for shell scripts. 11. Make use of MREMAP if available 12. Misc. minor changes e.g. - #include <config.h> -> #include "config.h" - Add some no-install headers to /include - extern -> EXTERNL and vice versa as needed - misc header cleanup - clean up checking for misc. unix vs microsoft functions 13. Change copyright decls in some files to point to LICENSE file. 14. Add notes to RELEASENOTES.md
106 lines
3.2 KiB
C
106 lines
3.2 KiB
C
/* This is part of the netCDF package. Copyright 2005 University
|
|
Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
|
|
conditions of use. See www.unidata.ucar.edu for more info.
|
|
|
|
Create a test file with an opaque type and opaque data for ncdump to read.
|
|
|
|
$Id: tst_opaque_data.c,v 1.7 2009/01/28 18:19:49 russ Exp $
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include <nc_tests.h>
|
|
#include "err_macros.h"
|
|
#include <netcdf.h>
|
|
|
|
#define FILE3_NAME "tst_opaque_data.nc"
|
|
#define TYPE3_NAME "raw_obs_t"
|
|
#define TYPE3_SIZE 11
|
|
#define DIM3_NAME "time"
|
|
#define DIM3_LEN 5
|
|
#define VAR3_NAME "raw_obs"
|
|
#define VAR3_RANK 1
|
|
#define ATT3_NAME "_FillValue"
|
|
#define ATT3_LEN 1
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
int ncid;
|
|
int dimid, varid;
|
|
nc_type typeid;
|
|
char name_in[NC_MAX_NAME+1];
|
|
int class_in;
|
|
size_t size_in;
|
|
|
|
int i;
|
|
|
|
int var_dims[VAR3_RANK];
|
|
unsigned char sensor_data[DIM3_LEN][TYPE3_SIZE] = {
|
|
{1,2,3,4,5,6,7,8,9,10,11},
|
|
{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa},
|
|
{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
|
|
{0xca, 0xfe, 0xba, 0xbe, 0xca, 0xfe, 0xba, 0xbe, 0xca, 0xfe, 0xba},
|
|
{0xcf, 0x0d, 0xef, 0xac, 0xed, 0x0c, 0xaf, 0xe0, 0xfa, 0xca, 0xde}
|
|
};
|
|
unsigned char missing_val[TYPE3_SIZE] = {
|
|
0xca, 0xfe, 0xba, 0xbe, 0xca, 0xfe, 0xba, 0xbe, 0xca, 0xfe, 0xba
|
|
};
|
|
unsigned char val_in[TYPE3_SIZE];
|
|
|
|
printf("\n*** Testing opaque types.\n");
|
|
printf("*** creating opaque test file %s...", FILE3_NAME);
|
|
if (nc_create(FILE3_NAME, NC_CLOBBER | NC_NETCDF4, &ncid)) ERR;
|
|
|
|
/* Create an opaque type. */
|
|
if (nc_def_opaque(ncid, TYPE3_SIZE, TYPE3_NAME, &typeid)) ERR;
|
|
|
|
/* Declare a time dimension */
|
|
if (nc_def_dim(ncid, DIM3_NAME, DIM3_LEN, &dimid)) ERR;
|
|
|
|
/* Declare a variable of the opaque type */
|
|
var_dims[0] = dimid;
|
|
if (nc_def_var(ncid, VAR3_NAME, typeid, VAR3_RANK, var_dims, &varid)) ERR;
|
|
|
|
/* Create and write a variable attribute of the opaque type */
|
|
if (nc_put_att(ncid, varid, ATT3_NAME, typeid, ATT3_LEN, missing_val)) ERR;
|
|
if (nc_enddef(ncid)) ERR;
|
|
/* Store some data of the opaque type */
|
|
if(nc_put_var(ncid, varid, sensor_data)) ERR;
|
|
/* Write the file. */
|
|
if (nc_close(ncid)) ERR;
|
|
|
|
/* Check it out. */
|
|
|
|
/* Reopen the file. */
|
|
if (nc_open(FILE3_NAME, NC_NOWRITE, &ncid)) ERR;
|
|
|
|
/* Get info with the generic inquire for user-defined types */
|
|
if (nc_inq_user_type(ncid, typeid, name_in, &size_in, NULL,
|
|
NULL, &class_in)) ERR;
|
|
if (strcmp(name_in, TYPE3_NAME) ||
|
|
size_in != TYPE3_SIZE ||
|
|
class_in != NC_OPAQUE) ERR;
|
|
/* Get the same info with the opaque-specific inquire function */
|
|
if (nc_inq_opaque(ncid, typeid, name_in, &size_in)) ERR;
|
|
if (strcmp(name_in, TYPE3_NAME) ||
|
|
size_in != TYPE3_SIZE) ERR;
|
|
|
|
if (nc_inq_varid(ncid, VAR3_NAME, &varid)) ERR;
|
|
|
|
if (nc_get_att(ncid, varid, ATT3_NAME, &val_in)) ERR;
|
|
if (memcmp(val_in, missing_val, TYPE3_SIZE) != 0) ERR;
|
|
|
|
for (i = 0; i < DIM3_LEN; i++) {
|
|
size_t index[VAR3_RANK];
|
|
index[0] = i;
|
|
if(nc_get_var1(ncid, varid, index, val_in)) ERR;
|
|
if (memcmp(val_in, sensor_data[i], TYPE3_SIZE) != 0) ERR;
|
|
}
|
|
|
|
if (nc_close(ncid)) ERR;
|
|
|
|
|
|
SUMMARIZE_ERR;
|
|
FINAL_RESULTS;
|
|
}
|