File: test_data.c

package info (click to toggle)
netcdf-parallel 1%3A4.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 113,164 kB
  • sloc: ansic: 267,893; sh: 12,869; cpp: 5,822; yacc: 2,613; makefile: 1,813; lex: 1,216; xml: 173; awk: 2
file content (68 lines) | stat: -rw-r--r-- 1,379 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*********************************************************************
 *   Copyright 2016, UCAR/Unidata
 *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
 *********************************************************************/

/**
Test the netcdf-4 data building process.
*/

#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include "netcdf.h"

#undef DEBUG

static void
fail(int code)
{
    if(code != NC_NOERR) {
	fprintf(stderr,"***Fail: %s\n",nc_strerror(code));
	fflush(stderr);
    }
    exit((code==NC_NOERR?EXIT_SUCCESS:EXIT_FAILURE));
}

int
main(int argc, char** argv)
{
    int ret = NC_NOERR;
    char url[4096];
    int ncid;

    /* Skip cmd name */
    argc++;
    argv++;

    if(argc < 2) {
	fprintf(stderr, "too few arguments: t_dmrdata.c <infile> <outfile>\n");
	fail(NC_NOERR);
    }

    /* build the url */
    snprintf(url,sizeof(url),"file://%s#dap4&debug=copy%s%s%s",
	argv[0],
        (argc >= 3 ? "&substratename=" : ""),
        (argc >= 3 ? argv[1] : ""),
#ifdef DEBUG
	"&log"
#else
	""
#endif
	);

#ifdef DEBUG
    fprintf(stderr,"test_data url=%s\n",url);
#endif
  
    /* Use the open/close mechanism */
    if((ret=nc_open(url,NC_NETCDF4,&ncid))) goto done;
    if((ret=nc_close(ncid))) goto done;

done:
#ifdef DEBUG
    fprintf(stderr,"code=%d %s\n",ret,nc_strerror(ret));
#endif
    return (ret ? 1 : 0);
}