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.
Karen, > Is there another possible source of this error? Yes, the runtime error NCAPTC: NETCDF: Variable not found. means you are trying to create an attribute and give it a value, but the variable ID you are providing to the NCAPTC function to identify to which netCDF variable the attribute is assigned is invalid. Possible causes include: - the argument list to NCAPTC is wrong; the second argument must be a netCDF variable ID, as returned from either a previous call to the NCVID function, the NCVDEF function, or the constant NCGLOBAL for a global attribute (not assigned to any specific variable) - the second argument you are providing to NCAPTC has been overwritten or corrupted by a bug in your program, so it no longer contains a variable ID - you have multiple netCDF files open, and you are using a variable ID from a different file than the one identified by the first argument to NCAPTC - you are providing a variable ID that you think should be right (e.g. 10 for the tenth variable in the file) without actually verifying that the open file has that many variables and lots of other possibilities I can't think of. Try printing out the variable ID you are providing to see if it is a small integer between 1 and the number of variables, or -1 for a global attribute. You can determine the number of variables by running ncdump on the file or by calling NCINQ. By the way, from the function names I see you are using the netCDF version 2 Fortran-77 interface, documented in this 1996 Users Guide: http://www.unidata.ucar.edu/software/netcdf/guide_toc.html That's still supported, but there are advantages to using the newer netCDF version 3 Fortran-77 or Fortran-90 interfaces, documented here: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f77.html http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html and there's a netCDF-2 to netCDF-3 transition guide that explains the differences, in case you're interested: http://www.unidata.ucar.edu/software/netcdf/guidef/guidef-20.html#HEADING20-0 There's also a Fortran-77 to Fortran-90 transition guide: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html#FORTRAN-77-to-Fortran-90-Transition-Guide --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: KOT-304711 Department: Support netCDF Priority: Normal Status: Closed