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

Re: 20020228: Netcdf-C library use (Trouble adding more dimensions to variables)



>To: address@hidden
>From: Naveenta Anand <address@hidden>
>Subject: Re: 20020228: Netcdf-C library use (Trouble adding more dimensions to 
>variables)
>Keywords: 200202282208.g1SM8j809246

Naveenta,

> I am trying to add the dimension through a program interface using C. 
> Regarding your comment:
> 
>  If you are just editing the CDL file, you might need to edit the data
> section, since adding dimensions may require reordering the data.
> It might be relatively easy to add new dimensions if they are
> dimensions that vary more slowly than what you currently have.  We
> would have to see the old CDL file and what you want for the new CDL
> file to see if this could be done easily.
> 
> By CDL file you mean the output out of ncdump, correct?

Yes.  But since you said you are using a C program to try to add a
dimension to the PRES variable, you evidently aren't trying to do it
by editing the CDL file, which would be an easy way to do it if you
only needed to change one file.  In that case you could edit the CDL
file output from ncdump, making sure the data was correct, then
generate the new netCDF file from the CDL file by using the ncgen
utility, as in:

 ncgen -o new_file.nc -b edited_file.cdl

But if you have to do this for many files or there is too much data in
the files for the ncdump/ncgen approach of converting to text files
and back, then a C program is a better approach.

> The variable that is giving the trouble is PRES and right now it has the 
> dimension N_LEVELS but needs to add another dimension N_PROF to it. I am 
> sending you a copy of a CDL file (the OLD is the one that has PRES with 1 
> dimension and the NEW is the one that has PRES with 2 dimensions. Please 
> take a look to see if you can help.  

How did you attempt to add the dimension to the PRES variable, since
there is no netCDF library call that lets you change the shape of a
variable in an existing file?

As far as I know, the only way to do what you want in C is to open the
old file, redefine everything in the new file (including the new
definition for the variable "float PRES(N_PROF, N_LEVELS)"), and then
read all the data from the old file and write it into the new file.
Is this the approach you are using in your C program?

--Russ

P.S. By the way, if you send your questions to
"address@hidden", they will get routed to someone who is
here to answer them, in case I am away from my email.