[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20010418: a netCDF problem



>To: address@hidden
>From: "William D Otto" <address@hidden>
>Subject: a netCDF problem
>Organization: UCAR/Unidata
>Keywords: 200104181931.f3IJVvL00506

Bill,

> I am having a problem with getting a data to write after I have created
> the file. I am using version 3.4 on a SUN. I checked the error flags,
> and there all 0. It a simple array of 91 elements, and I am using the
> call nc_put_var_float. Any ideas on what I am doing wrong. Thanks.

In my previous response, I forgot to mention a simple way to get an
example to work from.

First create a simple CDL file that represents the data you want to
write, for example:

netcdf example1 {
dimensions:
  n = 91;
variables:
  float v(n);
data:
  v = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13;
}

Now if you store this in a file named "example1.cdl", for example,
you can create a C program that will write the file using standard
netCDF calls by running

  ncgen -c example1.cdl > example1.c

The resulting program may contain a little more than is needed for
such a simple example, but it does show the nc_put_var_float() and
nc_close() calls as well as all the error checking ...

--Russ