Coverage Report

Created: 2023-05-28 06:42

/src/netcdf-c/libnczarr/zdispatch.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright 2005-2018 University Corporation for Atmospheric
2
   Research/Unidata. */
3
4
/**
5
 * @file
6
 * @internal This header file contains prototypes and initialization
7
 * for the ZARR dispatch layer.
8
 *
9
 * @author Dennis Heimbigner, Ed Hartnett
10
 */
11
12
#include "zincludes.h"
13
14
/* Forward */
15
static int NCZ_var_par_access(int ncid, int varid, int par_access);
16
static int NCZ_show_metadata(int ncid);
17
18
static const NC_Dispatch NCZ_dispatcher = {
19
20
    NC_FORMATX_NCZARR,
21
    NC_DISPATCH_VERSION,
22
23
    NCZ_create,
24
    NCZ_open,
25
26
    NCZ_redef,
27
    NCZ__enddef,
28
    NCZ_sync,
29
    NCZ_abort,
30
    NCZ_close,
31
    NCZ_set_fill,
32
    NCZ_inq_format,
33
    NCZ_inq_format_extended,
34
35
    NCZ_inq,
36
    NCZ_inq_type,
37
38
    NCZ_def_dim,
39
    NCZ_inq_dimid,
40
    NCZ_inq_dim,
41
    NCZ_inq_unlimdim,
42
    NCZ_rename_dim,
43
44
    NCZ_inq_att,
45
    NCZ_inq_attid,
46
    NCZ_inq_attname,
47
    NCZ_rename_att,
48
    NCZ_del_att,
49
    NCZ_get_att,
50
    NCZ_put_att,
51
52
    NCZ_def_var,
53
    NCZ_inq_varid,
54
    NCZ_rename_var,
55
    NCZ_get_vara,
56
    NCZ_put_vara,
57
    NCZ_get_vars,
58
    NCZ_put_vars,
59
    NCDEFAULT_get_varm,
60
    NCDEFAULT_put_varm,
61
62
    NCZ_inq_var_all,
63
64
    NCZ_var_par_access,
65
    NCZ_def_var_fill,
66
67
    NCZ_show_metadata,
68
    NCZ_inq_unlimdims,
69
70
    NCZ_inq_ncid,
71
    NCZ_inq_grps,
72
    NCZ_inq_grpname,
73
    NCZ_inq_grpname_full,
74
    NCZ_inq_grp_parent,
75
    NCZ_inq_grp_full_ncid,
76
    NCZ_inq_varids,
77
    NCZ_inq_dimids,
78
    NCZ_inq_typeids,
79
    NCZ_inq_type_equal,
80
    NCZ_def_grp,
81
    NCZ_rename_grp,
82
    NCZ_inq_user_type,
83
    NCZ_inq_typeid,
84
85
    NC_NOTNC4_def_compound,
86
    NC_NOTNC4_insert_compound,
87
    NC_NOTNC4_insert_array_compound,
88
    NC_NOTNC4_inq_compound_field,
89
    NC_NOTNC4_inq_compound_fieldindex,
90
    NC_NOTNC4_def_vlen,
91
    NC_NOTNC4_put_vlen_element,
92
    NC_NOTNC4_get_vlen_element,
93
    NC_NOTNC4_def_enum,
94
    NC_NOTNC4_insert_enum,
95
    NC_NOTNC4_inq_enum_member,
96
    NC_NOTNC4_inq_enum_ident,
97
    NC_NOTNC4_def_opaque,
98
    NCZ_def_var_deflate,
99
    NCZ_def_var_fletcher32,
100
    NCZ_def_var_chunking,
101
    NCZ_def_var_endian,
102
    NCZ_def_var_filter,
103
    NCZ_set_var_chunk_cache,
104
    NC4_get_var_chunk_cache,
105
    NCZ_inq_var_filter_ids,
106
    NCZ_inq_var_filter_info,
107
    NCZ_def_var_quantize,
108
    NCZ_inq_var_quantize,
109
    NCZ_inq_filter_avail,
110
};
111
112
const NC_Dispatch* NCZ_dispatch_table = NULL; /* moved here from ddispatch.c */
113
114
/**
115
 * @internal Initialize the ZARR dispatch layer.
116
 *
117
 * @return ::NC_NOERR No error.
118
 * @author Dennis Heimbigner, Ed Hartnett
119
 */
120
int ncz_initialized = 0; /**< True if initialization has happened. */
121
122
int
123
NCZ_initialize(void)
124
1
{
125
1
    int stat;
126
1
    NCZ_dispatch_table = &NCZ_dispatcher;
127
1
    if (!ncz_initialized)
128
1
        NCZ_initialize_internal();
129
1
    stat = NCZ_provenance_init();
130
1
    if(stat) ncz_initialized = 1;
131
1
    return stat;
132
1
}
133
134
/**
135
 * @internal Finalize the ZARR dispatch layer.
136
 *
137
 * @return ::NC_NOERR No error.
138
 * @author Dennis Heimbigner
139
 */
140
int
141
NCZ_finalize(void)
142
1
{
143
1
    NCZ_finalize_internal();
144
1
    NCZ_provenance_finalize();
145
1
    return NC_NOERR;
146
1
}
147
148
static int
149
NCZ_var_par_access(int ncid, int varid, int par_access)
150
0
{
151
0
    return NC_NOERR; /* no-op */
152
0
}
153
154
static int
155
NCZ_show_metadata(int ncid)
156
0
{
157
0
    return NC_NOERR;
158
0
}
159
160
#ifndef ENABLE_NCZARR_FILTERS
161
int 
162
NCZ_def_var_filter(int ncid, int varid, unsigned int id , size_t n , const unsigned int *params)
163
{
164
    NC_UNUSED(ncid);
165
    NC_UNUSED(varid);
166
    NC_UNUSED(id);
167
    NC_UNUSED(n);
168
    NC_UNUSED(params);
169
    return REPORT(NC_NOERR,"def_var_filter");
170
}
171
172
int 
173
NCZ_inq_var_filter_ids(int ncid, int varid, size_t* nfilters, unsigned int* filterids)
174
{
175
    NC_UNUSED(ncid);
176
    NC_UNUSED(varid);
177
    NC_UNUSED(filterids);
178
    if(nfilters) *nfilters = 0;
179
    return REPORT(NC_NOERR,"inq_var_filter_ids");
180
}
181
182
int
183
NCZ_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t* nparams, unsigned int* params)
184
{
185
    NC_UNUSED(ncid);
186
    NC_UNUSED(varid);
187
    NC_UNUSED(id);
188
    NC_UNUSED(nparams);
189
    NC_UNUSED(params);
190
    return REPORT(NC_ENOFILTER,"inq_var_filter_info");
191
}
192
193
int
194
NCZ_inq_filter_avail(int ncid, unsigned id)
195
{
196
    NC_UNUSED(ncid);
197
    NC_UNUSED(id);
198
    return REPORT(NC_ENOFILTER,"inq_filter_avail");
199
}
200
201
202
#endif /*ENABLE_NCZARR_FILTERS*/
203
204
/**************************************************/
205
/* Following functions call into libsrc4 */
206
207
int
208
NCZ_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
209
0
{
210
0
    int stat = NC_NOERR;
211
0
    ZTRACE(0,"NC4_inq_type(ncid,xtype,name,size)");
212
0
    stat = NC4_inq_type(ncid,xtype,name,size);
213
0
    return ZUNTRACE(stat);
214
0
}
215
216
int
217
NCZ_inq_dimid(int ncid, const char *name, int *idp)
218
0
{
219
0
    int stat = NC_NOERR;
220
0
    ZTRACE(0,"NC4_inq_dimid(ncid,name,idp)");
221
0
    stat = NC4_inq_dimid(ncid,name,idp);
222
0
    return ZUNTRACE(stat);
223
0
}
224
225
int
226
NCZ_inq_unlimdim(int ncid,  int *unlimdimidp)
227
0
{
228
0
    int stat = NC_NOERR;
229
0
    ZTRACE(0,"NC4_inq_unlimdim(ncid,unlimdimidp)");
230
0
    stat = NC4_inq_unlimdim(ncid,unlimdimidp);
231
0
    return ZUNTRACE(stat);
232
0
}
233
234
int
235
NCZ_inq_varid(int ncid, const char* name, int *varidp)
236
0
{
237
0
    int stat = NC_NOERR;
238
0
    ZTRACE(0,"NC4_inq_varid(ncid,name,varidp)");
239
0
    stat = NC4_inq_varid(ncid,name,varidp);
240
0
    return ZUNTRACE(stat);
241
0
}
242
243
int
244
NCZ_inq_ncid(int ncid, const char* name, int* grpidp)
245
0
{
246
0
    int stat = NC_NOERR;
247
0
    ZTRACE(0,"NC4_inq_ncid(ncid,name,grpidp)");
248
0
    stat = NC4_inq_ncid(ncid,name,grpidp);
249
0
    return ZUNTRACE(stat);
250
0
}
251
252
int
253
NCZ_inq_grps(int ncid, int* n, int* ncids)
254
0
{
255
0
    int stat = NC_NOERR;
256
0
    ZTRACE(0,"NC4_inq_grps(ncid,n,ncids)");
257
0
    stat = NC4_inq_grps(ncid,n,ncids);
258
0
    return ZUNTRACE(stat);
259
0
}
260
261
int
262
NCZ_inq_grpname(int ncid, char* name)
263
0
{
264
0
    int stat = NC_NOERR;
265
0
    ZTRACE(0,"NC4_inq_grpname(ncid,name)");
266
0
    stat = NC4_inq_grpname(ncid,name);
267
0
    return ZUNTRACE(stat);
268
0
}
269
270
int
271
NCZ_inq_grpname_full(int ncid, size_t* lenp, char* fullname)
272
0
{
273
0
    int stat = NC_NOERR;
274
0
    ZTRACE(0,"NC4_inq_grpname_full(ncid,lenp,fullname)");
275
0
    stat = NC4_inq_grpname_full(ncid,lenp,fullname);
276
0
    return ZUNTRACE(stat);
277
0
}
278
279
int
280
NCZ_inq_grp_parent(int ncid, int* parentidp)
281
0
{
282
0
    int stat = NC_NOERR;
283
0
    ZTRACE(0,"NC4_inq_grp_parent(ncid,parentidp)");
284
0
    stat = NC4_inq_grp_parent(ncid,parentidp);
285
0
    return ZUNTRACE(stat);
286
0
}
287
288
int
289
NCZ_inq_grp_full_ncid(int ncid, const char* fullname, int* grpidp)
290
0
{
291
0
    int stat = NC_NOERR;
292
0
    ZTRACE(0,"NC4_inq_grp_full_ncid(ncid,fullname,grpidp)");
293
0
    stat = NC4_inq_grp_full_ncid(ncid,fullname,grpidp);
294
0
    return ZUNTRACE(stat);
295
0
}
296
297
int
298
NCZ_inq_varids(int ncid, int* nvars, int* varids)
299
0
{
300
0
    int stat = NC_NOERR;
301
0
    ZTRACE(0,"NC4_inq_varids(ncid,nvars,varids)");
302
0
    stat = NC4_inq_varids(ncid,nvars,varids);
303
0
    return ZUNTRACE(stat);
304
0
}
305
306
int
307
NCZ_inq_dimids(int ncid, int* ndims, int* dimids, int inclparents)
308
0
{
309
0
    int stat = NC_NOERR;
310
0
    ZTRACE(0,"NC4_inq_dimids(ncid,ndims,dimids,inclparents)");
311
0
    stat = NC4_inq_dimids(ncid,ndims,dimids,inclparents);
312
0
    return ZUNTRACE(stat);
313
0
}
314
315
int
316
NCZ_inq_user_type(int ncid, nc_type xtype, char* name, size_t* size, nc_type* basetid, size_t* nfields, int* classp)
317
0
{
318
0
    int stat = NC_NOERR;
319
0
    ZTRACE(0,"NC4_inq_user_type(ncid,xtype,name,size,basetid,nfields,classp)");
320
0
    stat = NC4_inq_user_type(ncid,xtype,name,size,basetid,nfields,classp);
321
0
    return ZUNTRACE(stat);
322
0
}