Coverage Report

Created: 2025-10-28 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/netcdf-c/libnczarr/zdispatch.c
Line
Count
Source
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
#include "zplugins.h"
14
15
/* Forward */
16
static int NCZ_var_par_access(int ncid, int varid, int par_access);
17
static int NCZ_show_metadata(int ncid);
18
19
static const NC_Dispatch NCZ_dispatcher = {
20
21
    NC_FORMATX_NCZARR,
22
    NC_DISPATCH_VERSION,
23
24
    NCZ_create,
25
    NCZ_open,
26
27
    NCZ_redef,
28
    NCZ__enddef,
29
    NCZ_sync,
30
    NCZ_abort,
31
    NCZ_close,
32
    NCZ_set_fill,
33
    NCZ_inq_format,
34
    NCZ_inq_format_extended,
35
36
    NCZ_inq,
37
    NCZ_inq_type,
38
39
    NCZ_def_dim,
40
    NCZ_inq_dimid,
41
    NCZ_inq_dim,
42
    NC4_inq_unlimdim,
43
    NCZ_rename_dim,
44
45
    NCZ_inq_att,
46
    NCZ_inq_attid,
47
    NCZ_inq_attname,
48
    NCZ_rename_att,
49
    NCZ_del_att,
50
    NCZ_get_att,
51
    NCZ_put_att,
52
53
    NCZ_def_var,
54
    NCZ_inq_varid,
55
    NCZ_rename_var,
56
    NCZ_get_vara,
57
    NCZ_put_vara,
58
    NCZ_get_vars,
59
    NCZ_put_vars,
60
    NCDEFAULT_get_varm,
61
    NCDEFAULT_put_varm,
62
63
    NCZ_inq_var_all,
64
65
    NCZ_var_par_access,
66
    NCZ_def_var_fill,
67
68
    NCZ_show_metadata,
69
    NC4_inq_unlimdims,
70
71
    NCZ_inq_ncid,
72
    NCZ_inq_grps,
73
    NCZ_inq_grpname,
74
    NCZ_inq_grpname_full,
75
    NCZ_inq_grp_parent,
76
    NCZ_inq_grp_full_ncid,
77
    NCZ_inq_varids,
78
    NCZ_inq_dimids,
79
    NCZ_inq_typeids,
80
    NCZ_inq_type_equal,
81
    NCZ_def_grp,
82
    NCZ_rename_grp,
83
    NCZ_inq_user_type,
84
    NCZ_inq_typeid,
85
86
    NC_NOTNC4_def_compound,
87
    NC_NOTNC4_insert_compound,
88
    NC_NOTNC4_insert_array_compound,
89
    NC_NOTNC4_inq_compound_field,
90
    NC_NOTNC4_inq_compound_fieldindex,
91
    NC_NOTNC4_def_vlen,
92
    NC_NOTNC4_put_vlen_element,
93
    NC_NOTNC4_get_vlen_element,
94
    NC_NOTNC4_def_enum,
95
    NC_NOTNC4_insert_enum,
96
    NC_NOTNC4_inq_enum_member,
97
    NC_NOTNC4_inq_enum_ident,
98
    NC_NOTNC4_def_opaque,
99
    NCZ_def_var_deflate,
100
    NCZ_def_var_fletcher32,
101
    NCZ_def_var_chunking,
102
    NCZ_def_var_endian,
103
    NCZ_def_var_filter,
104
    NCZ_set_var_chunk_cache,
105
    NC4_get_var_chunk_cache,
106
    NCZ_inq_var_filter_ids,
107
    NCZ_inq_var_filter_info,
108
    NCZ_def_var_quantize,
109
    NCZ_inq_var_quantize,
110
    NCZ_inq_filter_avail,
111
};
112
113
const NC_Dispatch* NCZ_dispatch_table = NULL; /* moved here from ddispatch.c */
114
115
/**
116
 * @internal Initialize the ZARR dispatch layer.
117
 *
118
 * @return ::NC_NOERR No error.
119
 * @author Dennis Heimbigner, Ed Hartnett
120
 */
121
int ncz_initialized = 0; /**< True if initialization has happened. */
122
123
int
124
NCZ_initialize(void)
125
1
{
126
1
    int stat;
127
1
    NCZ_dispatch_table = &NCZ_dispatcher;
128
1
    if (!ncz_initialized)
129
1
        NCZ_initialize_internal();
130
1
    stat = NCZ_provenance_init();
131
1
    if(stat) ncz_initialized = 1;
132
1
    return stat;
133
1
}
134
135
/**
136
 * @internal Finalize the ZARR dispatch layer.
137
 *
138
 * @return ::NC_NOERR No error.
139
 * @author Dennis Heimbigner
140
 */
141
int
142
NCZ_finalize(void)
143
1
{
144
1
    NCZ_finalize_internal();
145
1
    NCZ_provenance_finalize();
146
1
    return NC_NOERR;
147
1
}
148
149
static int
150
NCZ_var_par_access(int ncid, int varid, int par_access)
151
0
{
152
0
    return NC_NOERR; /* no-op */
153
0
}
154
155
static int
156
NCZ_show_metadata(int ncid)
157
0
{
158
0
    return NC_NOERR;
159
0
}
160
161
#ifndef NETCDF_ENABLE_NCZARR_FILTERS
162
int 
163
NCZ_def_var_filter(int ncid, int varid, unsigned int id , size_t n , const unsigned int *params)
164
0
{
165
0
    NC_UNUSED(ncid);
166
0
    NC_UNUSED(varid);
167
0
    NC_UNUSED(id);
168
0
    NC_UNUSED(n);
169
0
    NC_UNUSED(params);
170
0
    return REPORT(NC_NOERR,"def_var_filter");
171
0
}
172
173
int 
174
NCZ_inq_var_filter_ids(int ncid, int varid, size_t* nfilters, unsigned int* filterids)
175
0
{
176
0
    NC_UNUSED(ncid);
177
0
    NC_UNUSED(varid);
178
0
    NC_UNUSED(filterids);
179
0
    if(nfilters) *nfilters = 0;
180
0
    return REPORT(NC_NOERR,"inq_var_filter_ids");
181
0
}
182
183
int
184
NCZ_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t* nparams, unsigned int* params)
185
0
{
186
0
    NC_UNUSED(ncid);
187
0
    NC_UNUSED(varid);
188
0
    NC_UNUSED(id);
189
0
    NC_UNUSED(nparams);
190
0
    NC_UNUSED(params);
191
0
    return REPORT(NC_ENOFILTER,"inq_var_filter_info");
192
0
}
193
194
int
195
NCZ_inq_filter_avail(int ncid, unsigned id)
196
0
{
197
0
    NC_UNUSED(ncid);
198
0
    NC_UNUSED(id);
199
0
    return REPORT(NC_ENOFILTER,"inq_filter_avail");
200
0
}
201
202
#endif /*NETCDF_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
}