-
Notifications
You must be signed in to change notification settings - Fork 3
/
compat.c
143 lines (120 loc) · 3.85 KB
/
compat.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "sacio.h"
#define MAX 2000
int
main() {
char ty[17];
int nlen = 0, max = MAX, nerr = 0, nvhdr = 6;
float y[MAX], x[MAX];
float beg = 0.0, del = 0.0, delta = 0.0;
double delta8 = 0.0;
rsac1("t/test_io_small.sac", y, &nlen, &beg, &del, &max, &nerr, -1);
printf("%d\n", nerr);
assert(nerr == 0);
getfhv("delta", &delta, &nerr, -1);
printf("%d %f\n", nerr, delta);
assert(nerr == 0);
assert(delta == 1.0);
getdhv("delta", &delta8, &nerr, -1);
assert(nerr == 0);
assert(delta8 == 1.0);
getfhv("b", &beg, &nerr, -1);
assert(beg == 0.0);
memset(ty, 0, sizeof(ty));
getihv("iftype", ty, &nerr, -1, 16);
printf("'%s'\n", ty);
assert(strcmp(ty, "ITIME ") == 0);
delta8 = 1.0/3.0;
printf("%.17g\n", delta8);
setdhv("t0", &delta8, &nerr, -1);
assert(nerr == 0);
delta8 = 0.0;
getdhv("t0", &delta8, &nerr, -1);
printf("%.17g\n", delta8);
assert(nerr == 0);
assert(delta8 == (float)(1.0/3.0));
nvhdr = 7;
setnhv("nvhdr", &nvhdr, &nerr, -1);
assert(nerr == 0);
delta8 = 1.0/3.0;
printf("%.17g\n", delta8);
setdhv("t0", &delta8, &nerr, -1);
assert(nerr == 0);
delta8 = 0.0;
getdhv("t0", &delta8, &nerr, -1);
printf("%.17g\n", delta8);
assert(nerr == 0);
assert(delta8 == (1.0/3.0));
nvhdr = 6;
setnhv("nvhdr", &nvhdr, &nerr, -1);
assert(nerr == 0);
getkhv("kstnm", ty, &nerr, -1, 8);
printf("'%s'\n", ty);
assert(strcmp(ty, "sta ") == 0);
getkhv("kevnm", ty, &nerr, -1, 17);
printf("'%s' %d\n", ty, nerr);
assert(strcmp(ty, "FUNCGEN: IMPULSE") == 0);
getnhv("npts", &nlen, &nerr, -1);
//printf("npts: %d\n", nlen);
assert(nlen == 100);
getlhv("leven", &nlen, &nerr, -1);
//printf("leven: %d\n", nlen);
assert(nlen == 1);
float v0 = (float) 10.1;
float v = v0;
setfhv("t0", &v, &nerr, -1);
v = 0.0;
getfhv("t0", &v, &nerr, -1);
assert(v == v0);
int n0 = 1999;
int n = n0;
setnhv("nzyear", &n, &nerr, -1);
n = 0;
getnhv("nzyear", &n, &nerr, -1);
assert(n == n0);
n0 = 0;
n = n0;
setlhv("lpspol", &n, &nerr, -1);
n = 0;
getlhv("lpspol", &n, &nerr, -1);
assert(nerr == 0);
assert(n == n0);
setkhv("kcmpnm", "BHZ", &nerr, -1, 3);
getkhv("kcmpnm", ty, &nerr, -1, 16);
assert(strcmp(ty, "BHZ ") == 0);
setihv("iztype", "IO", &nerr, -1, 2);
getihv("iztype", ty, &nerr, -1, 16);
assert(strcmp(ty, "IO ") == 0);
setkhv("kcmpnm", "", &nerr, -1, -1);
assert(nerr == 0);
getkhv("kcmpnm", ty, &nerr, -1, 16);
assert(nerr == 0);
assert(strcmp(ty, " ") == 0);
rsac1("t/test_io_small.sac", y, &nlen, &beg, &del, &max, &nerr, -1);
printf("nerr: %d\n", nerr);
assert(nerr == 0);
wsac1("t/test_io_small.sac.tmp", y, &nlen, &beg, &del, &nerr, -1);
assert(nerr == 0);
rsac1("t/test_io_big.sac", y, &nlen, &beg, &del, &max, &nerr, -1);
assert(nerr == 0);
wsac1("t/test_io_big.sac.tmp", y, &nlen, &beg, &del, &nerr, -1);
assert(nerr == 0);
rsac2("t/test_uneven_big.sac", y, &nlen, x, &max, &nerr, -1);
assert(nerr == 0);
wsac2("t/test_uneven_big.sac.tmp", y, &nlen, x, &nerr, -1);
assert(nerr == 0);
rsac2("t/test_uneven_small.sac", y, &nlen, x, &max, &nerr, -1);
assert(nerr == 0);
wsac2("t/test_uneven_small.sac.tmp", y, &nlen, x, &nerr, -1);
assert(nerr == 0);
rsac1("t/test_spec_small.sac", y, &nlen, &beg, &del, &max, &nerr, -1);
assert(nerr == 0);
wsac1("t/test_spec_small.sac.tmp", y, &nlen, &beg, &del, &nerr, -1);
assert(nerr == 0);
rsac1("t/test_spec_big.sac", y, &nlen, &beg, &del, &max, &nerr, -1);
assert(nerr == 0);
wsac1("t/test_spec_big.sac.tmp", y, &nlen, &beg, &del, &nerr, -1);
assert(nerr == 0);
}