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

Re: Yet, another question



> Organization: NOAA/FSL
> Keywords: 199403112221.AA14335

Hi Barry,

> I am trying to use the FORTRAN interface for writing a hyperslab
> of values to an existing netCDF file and I can't get it to work.
 ...
>
> I am creating my own data that I want to write to a netCDF file.
> I create the file exactly as you recommended by making a system call
> to ncgen and then a call to ncvpt. I get a return code of 5, which
> according to netcdf.inc is trying to write to a file that is
> not available for writing. Oh, yes, I do make a call to NCOPN
> with the parameter NCWRITE which is suppose to open the file
> for writing. The NCID is zero, which seems normal and my call to ncvid
> returns the correct variable number for the variable I am trying
> to write to (the 7th in the file).

A return code of 5 is supposed to mean that you tried to write the file, but
had not opened it for writing.  Check that when in your NCOPN call you
opened it using NCWRITE as the second argument, NCWRITE has a nonzero value.
For example if netcdf.inc were not included, NCWRITE might just be an
uninitialized integer with a zero value instead of a parameter with the
value 1, which would be stating your intent to open the file for reading
only, and would see an error return of 5 on the first write, no matter what
the file permissions.  Otherwise I can't explain why 5 is returned on the
first write.
 
> I have done an NCDUMP and see the CDL at the top and all the variables
> with the fill values, so I know that the file is created with the
> call system(' ncgen.....')
> 
> My call to ncvpt looks like this:
> 
>            call ncvpt(ncid,niceid,starto,counto,icing,rcode)
> 
> where ncid =0 from call to ncopn of the netCDF file created by call to
> ncgen, niceid=7 from call to ncvid [niceid=ncvid(ncid,'icing',rcode)]
> starto and counto is an integer array of size 3
> (start(1),start(2),start(3)=1 and count(1),count(2),count(3) are the
> dimensions of the variable (I checked in the debugger and these vvalues
> are correct), icing is a 3 dimension array with the dimensions defined
> in count.

Another guess is that you might be depending on the CDL or the output of
ncdump for the correct order of the dimensions of the variable, but both CDL
and ncdump use the C order (most slowly varying dimension first) rather than
the Fortran order (most slowly varying last).  The Fortran interface
reverses dimensions and indices before calling the C interface to make
things work right, but make sure that if the CDL has a declaration like

    dimensions:
            m = 10;
            n = 20;
            p = 30;
    variables:
            float icing(m,n,p);

that your Fortran program uses the opposite order of declaration for
dimensions:

        REAL ICING(30,20,10);

The COUNT array should follow the FORTRAN order for the dimensions, e.g.
COUNT(1) = 30, COUNT(2) = 20, COUNT(3) = 10.

If neither of these suggestions pan out, there may be a bug in the FORTRAN
interface for netCDF on your machine.  But you might also try filling in
some values for the icing variable in the CDL and calling "ncgen -f" on the
CDL file to see what netcdf Fortran code is generated for the NCVPT call,
just to make sure you are doing it right.  If this still leads nowhere, feel
free to give me a call.

--Russ

__________________________________________________________________________
                      
Russ Rew                                              UCAR Unidata Program
address@hidden                                        P.O. Box 3000
(303)497-8645                                 Boulder, Colorado 80307-3000