-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathnc4print.c
54 lines (44 loc) · 1.2 KB
/
nc4print.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*********************************************************************
* Copyright 2018, UCAR/Unidata
* 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"
#include "ncpathmgr.h"
extern int NC4print(NCbytes* buf, int ncid);
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);
}