2017-03-09 08:01:10 +08:00
|
|
|
/*********************************************************************
|
2018-12-07 06:36:53 +08:00
|
|
|
* Copyright 2018, UCAR/Unidata
|
2017-03-09 08:01:10 +08:00
|
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
This provides a simple netcdf-4 metadata -> xml printer.
|
|
|
|
Primarily for use in debugging, but could be adapted to
|
|
|
|
create other tools.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "netcdf.h"
|
|
|
|
#include "ncbytes.h"
|
|
|
|
|
2020-09-25 04:33:58 +08:00
|
|
|
EXTERNL int NC4print(NCbytes* buf, int ncid);
|
2017-03-09 08:01:10 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int ret = NC_NOERR;
|
|
|
|
|
|
|
|
if(argc == 1) {
|
|
|
|
fprintf(stderr,"usage: nc4printer <file> <file>...\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
for(i=1;i<argc;i++) {
|
|
|
|
int ncid;
|
|
|
|
char* filename;
|
|
|
|
NCbytes* buf;
|
|
|
|
|
|
|
|
filename = argv[i];
|
|
|
|
buf = ncbytesnew();
|
|
|
|
|
|
|
|
if((ret = nc_open(filename,NC_NETCDF4,&ncid))) goto fail;
|
|
|
|
|
|
|
|
ret = NC4print(buf,ncid);
|
|
|
|
ncbytesnull(buf);
|
|
|
|
fprintf(stderr,"========== %s ==========\n",filename);
|
|
|
|
fprintf(stderr,"%s\n",ncbytescontents(buf));
|
|
|
|
ncbytesfree(buf);
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
fail:
|
|
|
|
fprintf(stderr,"***Fail: (%d) %s\n",ret,nc_strerror(ret));
|
|
|
|
exit(1);
|
|
|
|
}
|