Skip to content

Commit

Permalink
Merge pull request #2098 from DennisHeimbigner/fortcache.dmh
Browse files Browse the repository at this point in the history
Make the fortran cache API always be defined.
  • Loading branch information
WardF authored Sep 7, 2021
2 parents 8eb7129 + 424ba45 commit 0a4f4e1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
32 changes: 32 additions & 0 deletions libdispatch/dvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,5 +1331,37 @@ nc_get_var_chunk_cache(int ncid, int varid, size_t *sizep, size_t *nelemsp,
return ncp->dispatch->get_var_chunk_cache(ncid, varid, sizep,
nelemsp, preemptionp);
}

#ifndef USE_NETCDF4
/* Make sure the fortran API is defined, even if it only returns errors */

int
nc_set_chunk_cache_ints(int size, int nelems, int preemption)
{
return NC_ENOTBUILT;
}

int
nc_get_chunk_cache_ints(int *sizep, int *nelemsp, int *preemptionp)
{
return NC_ENOTBUILT;
}

int
nc_set_var_chunk_cache_ints(int ncid, int varid, int size, int nelems,
int preemption)
{
return NC_ENOTBUILT;
}

int
nc_get_var_chunk_cache_ints(int ncid, int varid, int *sizep,
int *nelemsp, int *preemptionp)
{
return NC_ENOTBUILT;
}

#endif /*USE_NETCDF4*/

/** @} */
/** @} */
2 changes: 2 additions & 0 deletions libhdf5/hdf5var.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ NC4_def_var_chunking(int ncid, int varid, int storage, const size_t *chunksizesp
/**
* @internal Define chunking stuff for a var. This is called by
* the fortran API.
* Note: see libsrc4/nc4cache.c for definition when HDF5 is disabled
*
* @param ncid File ID.
* @param varid Variable ID.
Expand Down Expand Up @@ -2147,6 +2148,7 @@ NC4_HDF5_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems,
/**
* @internal A wrapper for NC4_set_var_chunk_cache(), we need this
* version for fortran. Negative values leave settings as they are.
* Note: see libsrc4/nc4cache.c for definition when HDF5 is disabled
*
* @param ncid File ID.
* @param varid Variable ID.
Expand Down
26 changes: 26 additions & 0 deletions libsrc4/nc4cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ nc_get_chunk_cache(size_t *sizep, size_t *nelemsp, float *preemptionp)
* but with integers instead of size_t, and with an integer preemption
* (which is the float preemtion * 100). This was required for fortran
* to avoid size_t issues.
* Note: if netcdf-4 is completely disabled, then the definitions in
* libdispatch/dfile.c take effect.
*
* @param size Cache size.
* @param nelems Number of elements.
Expand All @@ -139,6 +141,8 @@ nc_set_chunk_cache_ints(int size, int nelems, int preemption)
* nc_get_chunk_cache() but with integers instead of size_t, and with
* an integer preemption (which is the float preemtion * 100). This
* was required for fortran to avoid size_t issues.
* Note: if netcdf-4 is completely disabled, then the definitions in
* libdispatch/dfile.c take effect.
*
* @param sizep Pointer that gets cache size.
* @param nelemsp Pointer that gets number of elements.
Expand All @@ -159,3 +163,25 @@ nc_get_chunk_cache_ints(int *sizep, int *nelemsp, int *preemptionp)

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*/

0 comments on commit 0a4f4e1

Please sign in to comment.