File: nc4print.c

package info (click to toggle)
netcdf-parallel 1%3A4.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 105,352 kB
  • sloc: ansic: 229,114; sh: 11,180; yacc: 2,561; makefile: 1,390; lex: 1,173; xml: 173; awk: 2
file content (53 lines) | stat: -rw-r--r-- 1,210 bytes parent folder | download | duplicates (2)
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
/*********************************************************************
 *   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"

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);
}