Loading...
Searching...
No Matches
nc4cache.c
Go to the documentation of this file.
/* Copyright 2018, University Corporation for Atmospheric
* Research. See COPYRIGHT file for copying and redistribution
* conditions. */
#include "config.h"
#include "nc4internal.h"
int
nc_set_chunk_cache(size_t size, size_t nelems, float preemption)
{
NCglobalstate* gs = NC_getglobalstate();
if (preemption < 0 || preemption > 1)
return NC_EINVAL;
gs->chunkcache.size = size;
gs->chunkcache.nelems = nelems;
gs->chunkcache.preemption = preemption;
return NC_NOERR;
}
int
nc_get_chunk_cache(size_t *sizep, size_t *nelemsp, float *preemptionp)
{
NCglobalstate* gs = NC_getglobalstate();
if (sizep)
*sizep = gs->chunkcache.size;
if (nelemsp)
*nelemsp = gs->chunkcache.nelems;
if (preemptionp)
*preemptionp = gs->chunkcache.preemption;
return NC_NOERR;
}
int
nc_set_chunk_cache_ints(int size, int nelems, int preemption)
{
NCglobalstate* gs = NC_getglobalstate();
if (size <= 0 || nelems <= 0 || preemption < 0 || preemption > 100)
return NC_EINVAL;
gs->chunkcache.size = (size_t)size;
gs->chunkcache.nelems = (size_t)nelems;
gs->chunkcache.preemption = (float)preemption / 100;
return NC_NOERR;
}
int
nc_get_chunk_cache_ints(int *sizep, int *nelemsp, int *preemptionp)
{
NCglobalstate* gs = NC_getglobalstate();
if (sizep)
*sizep = (int)gs->chunkcache.size;
if (nelemsp)
*nelemsp = (int)gs->chunkcache.nelems;
if (preemptionp)
*preemptionp = (int)(gs->chunkcache.preemption * 100);
return NC_NOERR;
}
#ifndef USE_HDF5
/* See definitions in libhd5/hdf5var.c */
/* Make sure they are always defined */
/* Note: if netcdf-4 is completely disabled, then the definitions in
* libdispatch/dfile.c take effect.
*/
int
nc_set_var_chunk_cache_ints(int ncid, int varid, int size, int nelems,
int preemption)
{
return NC_NOERR;
}
int
nc_def_var_chunking_ints(int ncid, int varid, int storage, int *chunksizesp)
{
return NC_NOERR;
}
#endif /*USE_HDF5*/
nc_get_chunk_cache
int nc_get_chunk_cache(size_t *sizep, size_t *nelemsp, float *preemptionp)
Get current netCDF chunk cache settings.
Definition nc4cache.c:95
nc_set_chunk_cache
int nc_set_chunk_cache(size_t size, size_t nelems, float preemption)
Set chunk cache size.
Definition nc4cache.c:66
NC_EINVAL
#define NC_EINVAL
Invalid Argument.
Definition netcdf.h:388
NC_NOERR
#define NC_NOERR
No Error.
Definition netcdf.h:378