This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>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