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

[netCDF #MLP-485355]: How to read a NetCDF data set with Fortran 77...



Miguel,

It's good to know you got it working.  I now see what the problem was.  Te 
example you worked from used simple 1D latitude and longitude coordinate 
variables, but the file you were reading actually had much larger 2D latitude 
and longitude variables in it.  So you had, for example, dimensioned

        real lats(NLATS), lons(NLONS)

to declare fairly small 1D arrays, but then trying to read the large 2D lat 
arrays (with 253*669) values into the lat array that was only dimensioned for 
253 values:

      retval = nf_get_var_real(ncid, lat_varid, lats)

resulted in overwriting all the memory after where the lat variable was stored 
in memory, which may have also overwritten all the program in memory, 
explaining why the program never go beyond this point.  A fix would be to 
either declare large 2D arrays for the lat and lon variables, corresponding to 
what's in the file, not use the netCDF functions that read a whole variable at 
once, or simply comment out those reads, as you have done.

The documentation might be improved by warning that when using this interface, 
the user must be sure to declare a large enough array to hod all the data that 
will be read.

--Russ


Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: MLP-485355
Department: Support netCDF
Priority: Normal
Status: Closed