#include <stdlib.h>
#include <stdio.h>
#define FILE_NAME "simple_xy_nc4.nc"
#define NDIMS 2
#define NX 6
#define NY 12
#define ERRCODE 2
#define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}
int
main()
{
int ncid, x_dimid, y_dimid, varid;
int dimids[NDIMS];
size_t chunks[NDIMS];
int shuffle, deflate, deflate_level;
int data_out[NX][NY];
int x, y, retval;
deflate = 1;
deflate_level = 1;
for (x = 0; x < NX; x++)
for (y = 0; y < NY; y++)
data_out[x][y] = x * NY + y;
ERR(retval);
if ((retval =
nc_def_dim(ncid,
"x", NX, &x_dimid)))
ERR(retval);
if ((retval =
nc_def_dim(ncid,
"y", NY, &y_dimid)))
ERR(retval);
dimids[0] = x_dimid;
dimids[1] = y_dimid;
chunks[0] = NX/4;
chunks[1] = NY/4;
dimids, &varid)))
ERR(retval);
ERR(retval);
deflate_level)))
ERR(retval);
ERR(retval);
ERR(retval);
printf("*** SUCCESS writing example file simple_xy_nc4.nc!\n");
return 0;
}
EXTERNL int nc_close(int ncid)
Close an open netCDF dataset.
EXTERNL int nc_create(const char *path, int cmode, int *ncidp)
Create a new netCDF file.
EXTERNL int nc_def_dim(int ncid, const char *name, size_t len, int *idp)
Define a new dimension.
EXTERNL int nc_def_var_deflate(int ncid, int varid, int shuffle, int deflate, int deflate_level)
Set the zlib compression and shuffle settings for a variable in an netCDF/HDF5 file.
int nc_put_var_int(int ncid, int varid, const int *op)
Write an entire variable with one call.
EXTERNL int nc_def_var(int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp)
Define a new variable.
EXTERNL int nc_def_var_chunking(int ncid, int varid, int storage, const size_t *chunksizesp)
Define storage and, if chunked storage is used, chunking parameters for a variable.
Main header file for the C API.
#define NC_NETCDF4
Use netCDF-4/HDF5 format.
#define NC_INT
signed 4 byte integer
#define NC_SHUFFLE
Control the HDF5 shuffle filter.