NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

help with too many open files

After calling the write_histogram function below a couple of dozen
times, I get the message:

  ncredef: filename "hcaa8842": Too many open files

Why?  I'm believe that I'm calling ncendef and ncclose in the
appropriate places.  None of the assertions fail.  Any help would be
appreciated.

Thanks,
Charles

----------------------------------------------------------------------
static int write_histogram(char *filename, long *values, long duration_max)
{
  int ncid;
  int status;
  int dur_max_dim;
  int dimids[1], dur_hist_id;
  static long start[] = {0};    /* start writing at index 0 */
  static long count[1];

  ncid = ncopen(filename, NC_WRITE);
  assert(ncid >= 0);

  status = ncredef(ncid);
  assert(status >= 0);
  dur_max_dim = ncdimdef(ncid, "duration_max_frame", duration_max);
  assert(dur_max_dim >= 0);
  dimids[0] = dur_max_dim;
  dur_hist_id = ncvardef(ncid, "duration_histogram", NC_LONG, 1, dimids);
  status = ncendef(ncid);

  count[0] = duration_max;
  status = ncvarput(ncid, dur_hist_id, start, count, values);
  assert(status >= 0);

  status = ncclose(ncid);
  assert(status >= 0);

  return 0;
}


  • 1994 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: