File: tst_utils.h

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 (92 lines) | stat: -rw-r--r-- 2,449 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef TST_UTILS_H
#define TST_UTILS_H

#include "netcdf.h"

#define ERR(e) report(e,__LINE__)

typedef enum Op {None, Read, Write, Wholechunk, Odom} Op;

/* Bit mask of defined options; powers of 2*/
#define HAS_DIMLENS (1<<0)
#define HAS_CHUNKS (1<<1)
#define HAS_STRIDE (1<<2)
#define HAS_START (1<<3)
#define HAS_STOP (1<<4)
#define HAS_COUNT (1<<5)
#define HAS_MAX (1<<6)

/* Options */

typedef struct Options {
    unsigned debug;
    unsigned wdebug;
    int optimize;
    int wholechunk;
    Op op;
    int mode;
    int formatx;
    int rank;
    char file[1024];
    unsigned flags; 
    size_t dimlens[NC_MAX_VAR_DIMS];
    size_t chunks[NC_MAX_VAR_DIMS];
    size_t stride[NC_MAX_VAR_DIMS];
    size_t start[NC_MAX_VAR_DIMS];
    size_t stop[NC_MAX_VAR_DIMS];
    size_t count[NC_MAX_VAR_DIMS];
    size_t max[NC_MAX_VAR_DIMS];
} Options;

typedef struct Metadata {
    int ncid;
    int varid;
    int dimids[NC_MAX_VAR_DIMS];
    int fill;
} Metadata;

typedef struct Odometer {
  size_t rank; /*rank */
  size_t start[NC_MAX_VAR_DIMS];
  size_t stop[NC_MAX_VAR_DIMS];
  size_t stride[NC_MAX_VAR_DIMS];
  size_t max[NC_MAX_VAR_DIMS]; /* max size of ith index */
  size_t count[NC_MAX_VAR_DIMS];
  size_t index[NC_MAX_VAR_DIMS]; /* current value of the odometer*/
} Odometer;

EXTERNL Odometer* odom_new(size_t rank, const size_t* start, const size_t* stop, const size_t* stride, const size_t* max);
EXTERNL void odom_free(Odometer* odom);
EXTERNL int odom_more(Odometer* odom);
EXTERNL int odom_next(Odometer* odom);
EXTERNL size_t* odom_indices(Odometer* odom);
EXTERNL size_t odom_offset(Odometer* odom);
EXTERNL const char* odom_print1(Odometer* odom, int isshort);
EXTERNL const char* odom_print(Odometer* odom);
EXTERNL const char* odom_printshort(Odometer* odom);

EXTERNL int parsevector(const char* s0, size_t* vec);
EXTERNL const char* filenamefor(const char* f0);
EXTERNL const char* printvector(int rank, const size_t* vec);
EXTERNL const char* printvector64(int rank, const size64_t* vec);

EXTERNL int getoptions(int* argcp, char*** argvp);
EXTERNL int getmetadata(int create);
EXTERNL void cleanup(void);

EXTERNL int nc__testurl(const char*,char**);

EXTERNL const char* ncz_gets3testurl(void);

static void
report(int err, int lineno)
{
    fprintf(stderr,"Error: %d: %s\n", lineno, nc_strerror(err));
    exit(1);
}

EXTERNL Options* options;
EXTERNL Metadata* meta;
EXTERNL NClist* capture;

#endif /*TST_UTILS_H*/