//-------------------------------------------------------------------------
//
//  This code was generated by cdf2c to read the netCDF data from the 
//  jes2_waypts.cdf file into memory.
//
//  NOTE:  The code creates global variables, but you may move the variable
//         definitions inside the read_netCDF_file procedure if you wish.
//         The code REQUIRES the netCDF C libraries to run, and assumes that
//         netcdf.h is in the common include path.  DON'T FORGET to link with
//         -lnetcdf -lsun when you compile the code.
//
//  This file contains the following routines:
//
//     read_netCDF_file - reads the data from the given netCDF file into memory
//     main - driver for program
//
//  History:
//  Date       Name          Action
//  ---------  ------------  -------------------------------------------------
//  ?? ??? ??  CIDS          Work in Progress.
//
//-------------------------------------------------------------------------

#include <netcdf.h>

// Variable definitions.  The comments contain the dimension names.
long   year[43];                              // waypoint
long   month[43];                             // waypoint
long   date[43];                              // waypoint
float  hour[43];                              // waypoint
float  dd[43];                                // waypoint
float  longitude[43];                         // waypoint
float  latitude[43];                          // waypoint
long   waypoint_no[43];                       // waypoint


void 
read_netCDF_file ()
{
   //# func_description
   //  This routine reads the data from jes2_waypts.cdf into memory.

   int   fd;
   long  start[MAX_NC_VARS];
   long  end[MAX_NC_VARS];

   // Open the netCDF file.
   fd = ncopen("jes2_waypts.cdf", NC_NOWRITE);

   // Initialize start so all elements are zero.
   bzero(start, MAX_NC_VARS * sizeof(long));

   // Read in the variables and their attributes.
   // Read: year.
   end[0] = 43;
   ncvarget(fd, 0, start, end, year);

   // Read: month.
   end[0] = 43;
   ncvarget(fd, 1, start, end, month);

   // Read: date.
   end[0] = 43;
   ncvarget(fd, 2, start, end, date);

   // Read: hour.
   end[0] = 43;
   ncvarget(fd, 3, start, end, hour);

   // Read: dd.
   end[0] = 43;
   ncvarget(fd, 4, start, end, dd);

   // Read: longitude.
   end[0] = 43;
   ncvarget(fd, 5, start, end, longitude);

   // Read: latitude.
   end[0] = 43;
   ncvarget(fd, 6, start, end, latitude);

   // Read: waypoint_no.
   end[0] = 43;
   ncvarget(fd, 7, start, end, waypoint_no);

   // Read in the Global Attributes.
   // Close the netCDF file.
   ncclose(fd);
}


void
main ()
{
   //# func_description
   //  This routine will serve as the driver for all processes affecting
   //  the netCDF data.

   // Read the netCDF data into memory.
   read_netCDF_file();

   // This is were you should begin adding code to act on the data.
}
