NetCDF 4.9.3
Loading...
Searching...
No Matches
nc4cache.c
Go to the documentation of this file.
1/* Copyright 2018, University Corporation for Atmospheric
2 * Research. See COPYRIGHT file for copying and redistribution
3 * conditions. */
12
13#include "config.h"
14#include "nc4internal.h"
15
65int
66nc_set_chunk_cache(size_t size, size_t nelems, float preemption)
67{
68 NCglobalstate* gs = NC_getglobalstate();
69 if (preemption < 0 || preemption > 1)
70 return NC_EINVAL;
71 gs->chunkcache.size = size;
72 gs->chunkcache.nelems = nelems;
73 gs->chunkcache.preemption = preemption;
74 return NC_NOERR;
75}
76
94int
95nc_get_chunk_cache(size_t *sizep, size_t *nelemsp, float *preemptionp)
96{
97 NCglobalstate* gs = NC_getglobalstate();
98 if (sizep)
99 *sizep = gs->chunkcache.size;
100
101 if (nelemsp)
102 *nelemsp = gs->chunkcache.nelems;
103
104 if (preemptionp)
105 *preemptionp = gs->chunkcache.preemption;
106 return NC_NOERR;
107}
108
124int
125nc_set_chunk_cache_ints(int size, int nelems, int preemption)
126{
127 NCglobalstate* gs = NC_getglobalstate();
128 if (size <= 0 || nelems <= 0 || preemption < 0 || preemption > 100)
129 return NC_EINVAL;
130 gs->chunkcache.size = (size_t)size;
131 gs->chunkcache.nelems = (size_t)nelems;
132 gs->chunkcache.preemption = (float)preemption / 100;
133 return NC_NOERR;
134}
135
151int
152nc_get_chunk_cache_ints(int *sizep, int *nelemsp, int *preemptionp)
153{
154 NCglobalstate* gs = NC_getglobalstate();
155 if (sizep)
156 *sizep = (int)gs->chunkcache.size;
157 if (nelemsp)
158 *nelemsp = (int)gs->chunkcache.nelems;
159 if (preemptionp)
160 *preemptionp = (int)(gs->chunkcache.preemption * 100);
161
162 return NC_NOERR;
163}
164
165#ifndef USE_HDF5
166/* See definitions in libhd5/hdf5var.c */
167/* Make sure they are always defined */
168/* Note: if netcdf-4 is completely disabled, then the definitions in
169 * libdispatch/dfile.c take effect.
170 */
171
172int
173nc_set_var_chunk_cache_ints(int ncid, int varid, int size, int nelems,
174 int preemption)
175{
176 return NC_NOERR;
177}
178
179int
180nc_def_var_chunking_ints(int ncid, int varid, int storage, int *chunksizesp)
181{
182 return NC_NOERR;
183}
184
185#endif /*USE_HDF5*/
int nc_get_chunk_cache(size_t *sizep, size_t *nelemsp, float *preemptionp)
Get current netCDF chunk cache settings.
Definition nc4cache.c:95
int nc_set_chunk_cache(size_t size, size_t nelems, float preemption)
Set chunk cache size.
Definition nc4cache.c:66
#define NC_EINVAL
Invalid Argument.
Definition netcdf.h:388
#define NC_NOERR
No Error.
Definition netcdf.h:378