(hey Zack!)  Have you tried using ?showConnections to see if the files are
not being properly closed?  It could be a bug in ncdf4.  You could also try
?closeAllConnections to try to force close them within your loop.

--j


On Thu, May 23, 2013 at 5:41 PM, Zack Holden <zaholdenfs@gmail.com> wrote:

> Dear list,
> I am extracting data from thousands of NetCDF files, using the raster
> library to read in each file as follows:
>
> nclist <- list.files(nc.dir)
> for(iFile in 1:length(nclist)) {
>   r <- raster(nclist[iFile], varname = "myvar")
>   # extract data here....
> }  # end loop.
>
> I reach the file handler limit at around 1000 and receive the following
> error message:
> error: too many open files.
>
> I then move to the ncdf4 library, using nc_open() to open each file,
> retrieve the data I need, and then use nc_close() when I'm finished.
> However, I see the same error message after approximately 1000 files.
>
> The file handle limit on this system is more than 6 million, so I'm unsure
> why I'm seeing this error.
> Can anyone advise me on why this is occurring, and how I can avoid this
> problem?
>
> thanks in advance for any suggestions.
>
>  R session info:
> R version 3.0 x86_64-redhat-linux-gnu
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn307@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

	[[alternative HTML version deleted]]

