This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
------- Forwarded Message Date: Thu, 03 Apr 2003 11:36:06 -0700 From: Russ Rew <address@hidden> To: Youlong Xia <address@hidden> Subject: Re: multiple open and close >To: address@hidden >From: Youlong Xia <address@hidden> >Subject: Re: 20030328: multiple open and close >Organization: Institute for Geophysics, University of Texas >Keywords: Hi Youlong, > recently I used an optimized algorithm to estimate uncertainty of a > numerical model. This algorithm will make 100,000 runs using similar > data. Therefore Netcdf open and close will need the same times > because these data are netcdf format. When my program makes 100 > wrap_open and wrap_close, program stops and shows the error: too > many NETCDF opens. Could you please tell me how many open and close > can be done for single netcdf file? Can you tell me some ideas to > fix it or give me some information how to solve this problem? Many > thanks in advance. If the error is really "too many NETCDF opens", then it's not coming from the netCDF library but from some program or software that uses netCDF, such as IDL or MATLAB. In that case, I can't be of any help. The only similar error from the netCDF library is "Too many netCDF files open". That only occurs when the netCDF library gets a system error on trying to open a file and cannot open it because the operating system won't permit more open files. There is no limit in the netCDF library on the number of files that can be simultaneously open, despite the existence of the MAX_NC_OPEN macro in the netcdf.h header file, which was for a much earlier version of netCDF: /* * Avoid use of this meaningless macro * Use sysconf(_SC_OPEN_MAX). */ #ifndef MAX_NC_OPEN #define MAX_NC_OPEN 32 #endif The only limit is the number of files that the operating system lets you open simultaneously (returned by sysconf(_SC_OPEN_MAX) on Unix systems). Other operating systems have different limits and different ways of letting users change these limits. I suggest that you make sure "wrap_close" (whatever that is) calls nc_close() on netCDF IDs of files that don't need to be open. If that doesn't solve the problem, find out how to increase the number of simultaneously open files you are permitted in your operating system. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://my.unidata.ucar.edu ------- End of Forwarded Message