[netcdfgroup] Intermittent NC_EBADID Error

Hey Everyone,

I have an application that is writing consecutive NetCDF files
sequentially (i.e. it's a single-threaded process). I am using NetCDF
4.1.3 on a Windows 7 OS with MSVC 10. Each NetCDF file is written
using the following code:

    // Create NetCDF File
    stat = nc_create(filename, NC_NOCLOBBER, &ncid);
    check_err(stat,__LINE__,__FILE__);

    // Define data dimenssions
    stat=nc_def_dim(ncid,"Radial",alg_par->num_beam[0],&radial_dim);
    check_err(stat,__LINE__,__FILE__);

    ...

>From there, I continue to define my data dimensions and input data
before closing via 'nc_close()'. The process is then repeated a number
of times. I implement check_err() via the suggested format:

void check_err(const int stat, const int line, const char *file)
{
    if(stat!=NC_NOERR) {
        fprintf(stderr,"line %d of %s: %s\n",line,file,nc_strerror(stat));
        fflush(stderr);
        exit(-1);
    }
    return;
}

I am getting an intermittent NC_EBADID error from the first
nc_def_dim() call after the file is created. It always seems to happen
when the NetCDF ID ('ncid' above) is set to zero (ncid == 0).

Has anyone out there seen this? If the nc_create() call returns with
NC_NOERR set, I'm confused as to why the first 'nc_def_dim' call fails
with an error code.

Any suggestions/help is greatly appreciated,

Rob

-- 
Robert A Palumbo
Graduate Student
University of Massachusetts - Amherst
palumr@xxxxxxxxx



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