/* This example program is part of Unidata's netCDF library for scientific data access. How about a short, but meaningful, netCDF program? Ed Hartnett, 6/19/4 $Id: simple.c,v 1.1 2004/07/26 14:04:42 ed Exp $ */ #include #include #include /* This macro handles errors by outputting a message to stdout and then exiting. */ #define NC_EXAMPLE_ERROR 2 /* This is the exit code for failure. */ #define BAIL(e) do { \ printf("Bailing out in file %s, line %d, error:%s.\n", \ __FILE__, __LINE__, nc_strerror(e)); \ return NC_EXAMPLE_ERROR; \ } while (0) #define NUMDIMS 2 #define NUMVARS 1 #define CELSIUS "celsius" #define LAT_LEN 3 #define LON_LEN 2 int main() { int ncid, temp_varid, dimids[NUMDIMS]; float temp[LAT_LEN][LON_LEN], *fp; int i, res; /* Create a bunch of phoney data so we have something to write in the example file. */ for (fp=(float *)temp, i=0; i