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.
>To: address@hidden >From: address@hidden (Timothy Fredrick) >Subject: netcdf errors (fwd) >Organization: . >Keywords: 199610221507.AA02264 Hi Cindy, > > Date: 21 Oct 1996 15:52:44 -0600 > > From: "Cindy Nevison" <address@hidden> > > Subject: netcdf errors > > To: "Fredrick, Tim" <address@hidden> > > > > Tim: > > > > I've been running a modified version of a routine written by > > Cheryl Craig to read UARS data from the NCAR archive. The program > > runs fine on the ACD IBM when just one input file is read in using > > netcdf routines. However, when I try to read in 2 or more input > > files, I get the following error. "NCOPN: bad flag, did you forget > > to include netcdf.inc?" (I have included netcdf.inc). Cheryl can > > run my program on UARS1, but gets the same error on the ACD IBM. > > > > Cheryl sent me the following message, and suggested I consult with > > you. "I think your problem is ACD. I copied your routines over to > > a new directory in my user area, compiled and ran it, and got the > > same error message. I then copied the program over to uars1, > > compiled and ran it and it ran FINE! I have not stayed on top of > > netCDF, so you will need to check with Tim Fredrick about what may > > have been changed (maybe the library needs a bugfix patch or > > something)." The error message from NCOPN, "bad flag, did you forget to include netcdf.inc?" is trying to be too helpful in suggesting the most common cause of this problem, but I think it still points to a problem with an argument you are giving NCOPN. You are opening an existing netCDF file, say "foo.nc", with a statement something like: NCID = NCOPN('foo.nc', RWMODE, RCODE) where the second argument, RWMODE, must be either NCWRITE, to open the file for writing, or NCNOWRIT, to open the file read-only. NCWRITE and NCNOWRIT are parameters defined in the netcdf.inc file as 1 and 0 respectively. The error message means you are providing some value other than 1 or 0 for the second argument. The most common cause for this error is using NCNOWRIT (or NCWRITE) for the second argument, but not first including the netcdf.inc file that defines these constants, hence the value is some random uninitialized integer and NCOPN issues the error message. Perhaps you are using a variable for the second argument to NCOPN that gets overwritten by something that happens after you open the first file but before opening the second file. To track down the error, I'd advise printing the RWMODE argument before NCOPN is called and if it has some value other than NCWRITE (=1) or NCNOWRIT (=0) figuring out what happened. _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu