#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#define FILE_NAME "simple_xy_nc4.nc"
#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, varid;
int data_in[NX][NY];
int x, y, retval;
ERR(retval);
ERR(retval);
ERR(retval);
for (x = 0; x < NX; x++)
for (y = 0; y < NY; y++)
if (data_in[x][y] != x * NY + y)
return ERRCODE;
ERR(retval);
printf("*** SUCCESS reading example file %s!\n", FILE_NAME);
return 0;
}
EXTERNL int nc_close(int ncid)
Close an open netCDF dataset.
EXTERNL int nc_open(const char *path, int mode, int *ncidp)
Open an existing netCDF file.
EXTERNL int nc_inq_varid(int ncid, const char *name, int *varidp)
Find the ID of a variable, from the name.
int nc_get_var_int(int ncid, int varid, int *ip)
Read an entire variable in one call.
Main header file for the C API.
#define NC_NOWRITE
Set read-only access for nc_open().