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

Re: Another question



> Organization: NOAA/FSL
> Keywords: 199403092222.AA26053

Hi Barry,

> I need to write a netcdf file. I know that if you have a CDL file, ncgen
> will generate code to write the file; however, it will only generate
> code to open the file and define the variables and attributes. What does
> one do if they not only want to do what ncgen will do for them, but to
> follow with the actual data values. I know there are netcdf routines to
> write (put) routines, but this makes me wonder why ncgen exists at all
> if it can't write the data. I was going to write a fortran pgm that
> calls the system to use ncgen and try to append to the file the put
> commands that "writes" the data and close the file. Is there a better
> way and is it a good idea, in your opinion, to write a netcdf file
> (do it all from scratch, so to speak?)

Actually, ncgen also generates code to write the data, if the data are in
the CDL file.

I think it is a good idea to invoke ncgen on a CDL file from a system call
to generate the skeleton of a netCDF file, including some of the data that
doesn't change.  I do this in a decoder program and it works well.  After
the netCDF file is created, I open it and write more data into it, but the
variables and dimensions are all there already, so I've saved doing a lot of
work in the program.

My decoder actually first tries to see if the desired netCDF file already
exists.  If not, if creates it by calling system() to invoke ncgen; if so,
it assumes it has been generated with a previous call and just writes into
it.

--Russ