/* testnetcdf */ /* Tests file to see if it's a valid netcdf file. Exits w/0 if */ /* so, 1 if not, 2 if error in calling prgm (eg, no name of file */ /* to test). Assuming correct # args, relies entirely on nc_open */ /* for what it reports. */ /* Creates text on stdout if improperly called; silent otherwise */ #include #include #include void err(s,t) char *s,*t; { char *ss,*tt; printf ("%s\n%s\n",s,t); exit(2); } int main(argc,argv) char **argv; int argc; { int status; int netcdf_id; char *netcdf_file; if (argc < 2) err("Missing output file name",""); if (argc > 2) err("Too many args. Only requires 1",""); netcdf_file = argv[1]; status = nc_open(netcdf_file,NC_NOWRITE,&netcdf_id); status = (status == NC_NOERR) ? 0 : 1; nc_close(netcdf_id); exit(status); }