nc_getvar_tmw results in too many open files

Report or discuss software problems and other woes

Moderators: arango, robertson

Post Reply
Message
Author
ebjorkstedt
Posts: 3
Joined: Thu Oct 08, 2009 9:36 pm
Location: NOAA Fisheries SWFSC

nc_getvar_tmw results in too many open files

#1 Unread post by ebjorkstedt »

I'm not sure whether this problem has already been noted and fixed, but various searches didn't yield anything in the forum.

I was attempting to plot a series of sequential plots from a netCDF file of results from a modestly modified version of the upwelling test case using roms_jview.m (in Matlab 2009b). The plots come up exactly as I would expect, but after creating N plots (where N isn't all that large, and is cumulative within a session), Matlab would complain of too many files open and refuse to continue its otherwise cordial collaboration with me. :cry:

The fail appears to occur at line 2 of nc_varget_tmw.m :

Code: Select all

varid=netcdf.inqVarid(ncid,varname);

which rather often does not execute for some reason, leaving the current call of nc_varget_tmw hanging and the file referred to by the existing ncid unclosed.

An apparent fix is substituting

Code: Select all

try
    varid=netcdf.inqVarid(ncid,varname);
catch
    netcdf.close(ncid);
end
for the original line 2 (above) in nc_varget_tmw.m

I'm a bit worried that the problem I'm encountering is not really in Matlab, but something weird in my netCDF files, but note that the same netCDF file is being examined each time. Without the try-catch statement, the code often opens the file numerous times before successfully assigning a varid and moving on through the rest of the code. Then it cycles through a few successes and starts a new sequence of orphaned ncid's...

Any thoughts, reactions, recommendations would be greatly appreciated.

Cheers,
EB

kthyng
Posts: 12
Joined: Fri Oct 19, 2007 1:04 am
Location: Texas A&M

Re: nc_getvar_tmw results in too many open files

#2 Unread post by kthyng »

I just found your solution to this problem. Thank you so much! I am using the same version of Matlab and this has been driving me nuts. I don't know much about netCDF files yet to guess a better solution, so for now I am just happy to stop having to quit out of Matlab continuously.

Thanks again!

Kristen

jevans

Re: nc_getvar_tmw results in too many open files

#3 Unread post by jevans »

Eric,

As keeper of the code for SNCTOOLS, would it be possible for you to get me complete reproduction steps for this? Email me offline at john.g.evans.ne@gmail.com if you want.

Post Reply