NetCDF  4.9.2
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. */
13 #include "config.h"
14 #include "nc4internal.h"
15 
65 int
66 nc_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 
94 int
95 nc_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 
124 int
125 nc_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;
131  gs->chunkcache.nelems = nelems;
132  gs->chunkcache.preemption = (float)preemption / 100;
133  return NC_NOERR;
134 }
135 
151 int
152 nc_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 
172 int
173 nc_set_var_chunk_cache_ints(int ncid, int varid, int size, int nelems,
174  int preemption)
175 {
176  return NC_NOERR;
177 }
178 
179 int
180 nc_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:378
#define NC_NOERR
No Error.
Definition: netcdf.h:368