netcdf-c/libsrc4/error4.c
Dennis Heimbigner d62a9e623c Fix the NC_INMEMORY code to work in all cases with HDF5 1.10.
re: github issue https://github.com/Unidata/netcdf-c/issues/1111

One of the less common use cases for the in-memory feature is
apparently failing with HDF5-1.10.x.  The fix is complicated and
requires significant changes to libhdf5/nc4memcb.c. The current
setup is detailed in the file docs/inmeminternal.dox.

Additionally, it was discovered that the program
nc_test/tst_inmemory.c, which is invoked by
nc_test/run_inmemory.sh, actually was failing because of the
above problem. But the failure is not detected since the script
does not return non-zero value.

Other Changes:
1. Fix nc_test_tst_inmemory to return errors correctly.
2. Make ncdap_tests/findtestserver.c and dap4_tests/findtestserver4.c
   be generated from ncdap_test/findtestserver.c.in.
3. Make LOG() print output to stderr instead of stdout to
   avoid contaminating e.g. ncdump output.
4. Modify the handling of NC_INMEMORY and NC_DISKLESS flags
   to properly handle that NC_DISKLESS => NC_INMEMORY. This
   affects a number of code pieces, especially memio.c.
2018-09-04 11:27:47 -06:00

75 lines
1.8 KiB
C

/* Copyright 2003-2018, University Corporation for Atmospheric
Research. See netcdf-4/docs/COPYRIGHT file for copying and
redistribution conditions. */
/**
* @file @internal This file is part of netcdf-4, a netCDF-like
* interface for HDF5, or a HDF5 backend for netCDF, depending on your
* point of view.
*
* This file contains functions relating to logging errors. Also it
* contains the functions nc_malloc, nc_calloc, and nc_free.
*
* @author Ed Hartnett
*/
#include "config.h"
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include <hdf5.h>
/* This contents of this file get skipped if LOGGING is not defined
* during compile. */
#ifdef LOGGING
extern int nc_log_level;
/* This function prints out a message, if the severity of the message
is lower than the global nc_log_level. To use it, do something like
this:
nc_log(0, "this computer will explode in %d seconds", i);
After the first arg (the severity), use the rest like a normal
printf statement. Output will appear on stderr.
This function is heavily based on the function in section 15.5 of
the C FAQ. */
void
nc_log(int severity, const char *fmt, ...)
{
va_list argp;
int t;
/* If the severity is greater than the log level, we don' care to
print this message. */
if (severity > nc_log_level)
return;
/* If the severity is zero, this is an error. Otherwise insert that
many tabs before the message. */
if (!severity)
fprintf(stderr, "ERROR: ");
for (t=0; t<severity; t++)
fprintf(stderr, "\t");
/* Print out the variable list of args with vprintf. */
va_start(argp, fmt);
vfprintf(stderr, fmt, argp);
va_end(argp);
/* Put on a final linefeed. */
fprintf(stderr, "\n");
fflush(stderr);
}
void
nc_log_hdf5(void)
{
H5Eprint(NULL);
}
#endif /* ifdef LOGGING */