Error opening netCDF file [message #86932] |
Fri, 13 December 2013 14:55  |
dan.westervelt
Messages: 4 Registered: December 2013
|
Junior Member |
|
|
I am attempting to read in about ~100 or so netCDF files in a loop. I'm using ncdf_read.pro ( http://acmg.seas.harvard.edu/gamap/doc/by_alphabet/gamap_n.h tml#NCDF_READ). My code looks like this:
; read in met variables
ncdf_read, result_meteo, filename = dir1+sim4+dir4+dir3+'atmos.' $
+years(n)+'-'+string(fix(years(n))+4,format='(I4)')+'.ann.nc ', $
variables = ['netrad_toa']
; ; assign variables
net_rad_85(*,*)=result_meteo.netrad_toa
Undefine, result_meteo
I am getting this error at the assignment line above:
% Expression must be a structure in this context: RESULT_METEO.
Strangely, if I reset everything, and run again, the code gets a little further in the loop, and more of my 100 or so files are read in. If I repeat it enough times, I can get through the entire program without error, but it can take hours, which is not good.
Each file is about 18M, so I don't think I'm approaching a memory limit? My first guess was memory error or memory leak, but I've tried undefining everything, calling heap_gc, etc, with no luck. Any idea what I'm doing wrong here?
Thanks
Dan
|
|
|
Re: Error opening netCDF file [message #86949 is a reply to message #86932] |
Mon, 16 December 2013 15:58   |
dan.westervelt
Messages: 4 Registered: December 2013
|
Junior Member |
|
|
To follow up, this is with IDL 8.0.1 and netcdf 4.2. I define the net_rad_85 array earlier in the program (not shown) to have the same dimensions as netrad_toa variable in the structure.
On Friday, December 13, 2013 5:55:53 PM UTC-5, Dan Westervelt wrote:
> I am attempting to read in about ~100 or so netCDF files in a loop. I'm using ncdf_read.pro ( http://acmg.seas.harvard.edu/gamap/doc/by_alphabet/gamap_n.h tml#NCDF_READ). My code looks like this:
>
>
>
> ; read in met variables
>
> ncdf_read, result_meteo, filename = dir1+sim4+dir4+dir3+'atmos.' $
>
> +years(n)+'-'+string(fix(years(n))+4,format='(I4)')+'.ann.nc ', $
>
> variables = ['netrad_toa']
>
>
>
> ; ; assign variables
>
> net_rad_85(*,*)=result_meteo.netrad_toa
>
> Undefine, result_meteo
>
>
>
> I am getting this error at the assignment line above:
>
> % Expression must be a structure in this context: RESULT_METEO.
>
>
>
> Strangely, if I reset everything, and run again, the code gets a little further in the loop, and more of my 100 or so files are read in. If I repeat it enough times, I can get through the entire program without error, but it can take hours, which is not good.
>
>
>
> Each file is about 18M, so I don't think I'm approaching a memory limit? My first guess was memory error or memory leak, but I've tried undefining everything, calling heap_gc, etc, with no luck. Any idea what I'm doing wrong here?
>
>
>
> Thanks
>
> Dan
|
|
|
|
|
|
|
Re: Error opening netCDF file [message #86968 is a reply to message #86964] |
Tue, 17 December 2013 13:38  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Dan Westervelt writes:
> Thanks for the suggestion. Just tried this - code crashes at the same point as with NCDF_READ. Pops up a dialog box with NC_ERROR = -31.
>
> Maybe the netCDF files themselves are corrupted somehow?
You can find nCDF_isValidFile here:
http://www.idlcoyote.com/programs/ncdf_isvalidfile.pro
It might shed some light.
; CALLING SEQUENCE:
;
; result = NCDF_IsValidFile(filename)
;
; INPUTS:
;
; filename: The name of a filename to open to see if it is a valid
netCDF file.
;
; RETURN VALUE:
;
; result: A 1 if the file can be opened as a netCDF file. A 0
otherwise.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|