#ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #ifdef HAVE_GETOPT_H #include #endif #if defined(_WIN32) && ! defined(__MINGW32__) #include "XGetopt.h" #endif #include #define CHECK(err) {if(err) report(err,__LINE__);} /* Command line options */ struct Options { int debug; enum What {NONE=0, DIM=1, TYPE=2} what; char file[4096]; char var[NC_MAX_NAME+1]; char object[NC_MAX_NAME+1]; } options; /**************************************************/ static void report(int err, int lineno) { fprintf(stderr,"Error: %d: %s\n", lineno, nc_strerror(err)); exit(1); } void usage(void) { fprintf(stderr,"usage: printfqn [-D] [-V] -t|-d -v -f \n"); exit(0); } int get_id_parent(int ncid, int id, int* parentp, enum What what) { int stat = NC_NOERR; int i; int nids; int ids[4096]; /* Does this group have the id we are searching for? */ if(what == TYPE) { if((stat=nc_inq_typeids(ncid,&nids,ids))) goto done; } else if(what == DIM) { if((stat=nc_inq_dimids(ncid,&nids,ids,0))) goto done; } else abort(); assert(nids < 4096); /* Search for this id */ for(i=0;i