I assume that your file has no subgroups. 1. Get the list of variable ids int status; int nvars; int* varids; /* Get # of variables */ status = nc_inq_varids(ncid, &nvars, NULL); if(nvars == 0) return status; varids = malloc(sizeof(int)*nvars); if(varids == NULL) {status = NC_ENOMEM; return status;} /* repeat to get the variable ids */ status = nc_inq_varids(ncid, &nvars, varids); 2. Iterate over the variable ids to get the names int i; for(i=0;i<nvars;i++) { char name[NC_MAX_NAME+1]; status = nc_inq_varname(ncid,varids[i],name); if(status != NC_NOERR) return status; fprintf("varid=%d varname=%s\n",varids[i],name); } > Full Name: Ilkka Karasalo > Email Address: address@hidden > Organization: KTH > Package Version: 4.5.1 > Operating System: Ubuntu 15.04 > Hardware: > Description of problem: > > How do I get a list of the names of all variables in an unknown netcdf > file using the inq-... functions in the C interface (nc_open, nc_inq, > etc) ? > > =Dennis Heimbigner Unidata Ticket Details =================== Ticket ID: JCY-709704 Department: Support netCDF Priority: Normal Status: Open =================== NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.