#include <stdlib.h>
#include <stdio.h>
#define FILE_NAME "simple_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, varid1, varid2, grp1id, grp2id;
unsigned long long data_in[NX][NY];
int x, y, retval;
struct s1
{
int i1;
int i2;
};
struct s1 compound_data[NX][NY];
ERR(retval);
ERR(retval);
ERR(retval);
ERR(retval);
ERR(retval);
ERR(retval);
if ((retval =
nc_get_var(grp2id, varid2, &compound_data[0][0])))
ERR(retval);
for (x = 0; x < NX; x++)
for (y = 0; y < NY; y++)
{
if (data_in[x][y] != x * NY + y ||
compound_data[x][y].i1 != 42 ||
compound_data[x][y].i2 != -42)
return ERRCODE;
}
ERR(retval);
printf("*** SUCCESS reading example file %s!\n", FILE_NAME);
return 0;
}