Commit 5810eafb authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Make Warning_ function overridable.

* Also replace calls of xwarning with Warning.
parent 11da735a
......@@ -85,6 +85,9 @@ cdiAbortC_serial(const char *caller, const char *filename,
exit(EXIT_FAILURE);
}
typedef void (*cdiWarningFunc)(const char * caller, const char * fmt,
va_list ap);
void Warning_(const char *caller, const char *fmt, ...)
{
va_list args;
......@@ -93,14 +96,21 @@ void Warning_(const char *caller, const char *fmt, ...)
if ( _Verbose )
{
fprintf(stderr, "Warning (%s) : ", caller);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
cdiWarningFunc cdiWarning_p
= (cdiWarningFunc)namespaceSwitchGet(NSSWITCH_WARNING).func;
cdiWarning_p(caller, fmt, args);
}
va_end(args);
}
void cdiWarning(const char *caller, const char *fmt, va_list ap)
{
fprintf(stderr, "Warning (%s) : ", caller);
vfprintf(stderr, fmt, ap);
fputc('\n', stderr);
}
void Message_(const char *caller, const char *fmt, ...)
{
......
......@@ -19,6 +19,8 @@ extern int _Debug; /* If set to 1, debuggig (default 0) */
void SysError_(const char *caller, const char *fmt, ...);
void Error_(const char *caller, const char *fmt, ...);
void Warning_(const char *caller, const char *fmt, ...);
/* delegate used by Warning_ unless mode is PIO */
void cdiWarning(const char *caller, const char *fmt, va_list ap);
void Message_(const char *caller, const char *fmt, ...);
#if defined WITH_CALLER_NAME
......
......@@ -571,7 +571,7 @@ void gridDefXname(int gridID, const char *xname)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning ("%s", "Operation not executed." );
Warning ("%s", "Operation not executed." );
return;
}
......@@ -603,7 +603,7 @@ void gridDefXlongname(int gridID, const char *xlongname)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning ("%s", "Operation not executed." );
Warning ("%s", "Operation not executed." );
return;
}
......@@ -633,7 +633,7 @@ void gridDefXunits(int gridID, const char *xunits)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......@@ -665,7 +665,7 @@ void gridDefYname(int gridID, const char *yname)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -697,7 +697,7 @@ void gridDefYlongname(int gridID, const char *ylongname)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -729,7 +729,7 @@ void gridDefYunits(int gridID, const char *yunits)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1066,7 +1066,7 @@ void gridDefTrunc(int gridID, int trunc)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1097,7 +1097,7 @@ void gridDefXsize(int gridID, int xsize)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1138,7 +1138,7 @@ void gridDefPrec(int gridID, int prec)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1217,7 +1217,7 @@ void gridDefYsize(int gridID, int ysize)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1290,7 +1290,7 @@ void gridDefNP(int gridID, int np)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning ("%s", "Operation not executed." );
Warning ("%s", "Operation not executed." );
return;
}
......@@ -1345,7 +1345,7 @@ void gridDefRowlon(int gridID, int nrowlon, const int *rowlon)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1414,7 +1414,7 @@ void gridDefMask(int gridID, const int *mask)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1477,7 +1477,7 @@ void gridDefMaskGME(int gridID, const int *mask)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1568,7 +1568,7 @@ void gridDefXvals(int gridID, const double *xvals)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1663,7 +1663,7 @@ void gridDefYvals(int gridID, const double *yvals)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1854,7 +1854,7 @@ void gridDefXpole(int gridID, double xpole)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1906,7 +1906,7 @@ void gridDefYpole(int gridID, double ypole)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -1958,7 +1958,7 @@ void gridDefAngle(int gridID, double angle)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -2007,7 +2007,7 @@ void gridDefGMEnd(int gridID, int nd)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -2055,7 +2055,7 @@ void gridDefGMEni(int gridID, int ni)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -2103,7 +2103,7 @@ void gridDefGMEni2(int gridID, int ni2)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
gridptr = ( grid_t *) reshGetVal ( gridID, &gridOps );
......@@ -2140,7 +2140,7 @@ void gridDefGMEni3(int gridID, int ni3)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -3121,7 +3121,7 @@ void gridDefArea(int gridID, const double *area)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -3192,7 +3192,7 @@ void gridDefNvertex(int gridID, int nvertex)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -3237,7 +3237,7 @@ void gridDefXbounds(int gridID, const double *xbounds)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning ("%s", "Operation not executed.");
Warning ("%s", "Operation not executed.");
return;
}
......@@ -3352,7 +3352,7 @@ void gridDefYbounds(int gridID, const double *ybounds)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -3914,7 +3914,7 @@ void gridDefLCC(int gridID, double originLon, double originLat, double lonParY,
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -4000,7 +4000,7 @@ void gridDefLcc2(int gridID, double earth_radius, double lon_0, double lat_0, do
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -4055,7 +4055,7 @@ void gridDefLaea(int gridID, double earth_radius, double lon_0, double lat_0)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -4107,7 +4107,7 @@ void gridDefComplexPacking(int gridID, int lcomplex)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -4153,7 +4153,7 @@ void gridDefNumber(int gridID, const int number)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -4210,7 +4210,7 @@ void gridDefPosition(int gridID, int position)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -4267,7 +4267,7 @@ void gridDefReference(int gridID, const char *reference)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -4342,7 +4342,7 @@ void gridDefUUID(int gridID, const char *uuid)
if ( reshGetStatus ( gridID, &gridOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......
......@@ -28,6 +28,7 @@ static int activeNamespace = 0;
#define defaultSwitches { \
{ .func = (void (*)()) cdiAbortC_serial }, \
{ .func = (void (*)()) cdiWarning }, \
{ .func = (void (*)()) serializeGetSizeInCore }, \
{ .func = (void (*)()) serializePackInCore }, \
{ .func = (void (*)()) serializeUnpackInCore }, \
......
......@@ -22,6 +22,7 @@ enum namespaceSwitch
{
NSSWITCH_NO_SUCH_SWITCH = -1,
NSSWITCH_ABORT,
NSSWITCH_WARNING,
NSSWITCH_SERIALIZE_GET_SIZE,
NSSWITCH_SERIALIZE_PACK,
NSSWITCH_SERIALIZE_UNPACK,
......
......@@ -722,6 +722,8 @@ pioInit(MPI_Comm commGlob, int nProcsIO, int IOMode,
#ifdef USE_MPI
int sizeGlob;
namespaceSwitchSet(NSSWITCH_WARNING, NSSW_FUNC(cdiPioWarning));
if ( IOMode < PIO_MINIOMODE || IOMode > PIO_MAXIOMODE )
xabort ( "IOMODE IS NOT VALID." );
......
......@@ -42,6 +42,15 @@ cdiAbortC_MPI(const char *caller, const char *filename,
exit(EXIT_FAILURE);
va_end(ap);
}
void cdiPioWarning(const char *caller, const char *fmt, va_list ap)
{
int rank = getMPICommWorldRank();
fprintf(stderr, "pe%d: Warning (%s) : ", rank, caller);
vfprintf(stderr, fmt, ap);
fputc('\n', stderr);
}
#endif
/*****************************************************************************/
......
......@@ -26,6 +26,9 @@ cdiAbortC_MPI(const char * caller, const char * filename,
const char *functionname, int line,
const char * errorString, va_list ap)
__attribute__((noreturn));
void cdiPioWarning(const char *caller, const char *fmt, va_list ap);
#endif
#ifdef USE_MPI
......@@ -84,23 +87,6 @@ getMPICommWorldRank()
}
#endif
#ifdef USE_MPI
#define xwarning(fmt, ...) \
if ( ddebug ){ \
int rank = getMPICommWorldRank(); \
fprintf ( stderr, "WARNING: pe%d in %s, %s, line %d: " fmt "\n", \
rank, __func__, __FILE__, __LINE__, \
__VA_ARGS__ ); \
}
#else
#define xwarning(fmt, ...) \
if ( ddebug ){ \
fprintf ( stderr, "WARNING: %s, %s, line %d: " fmt "\n", \
__func__, __FILE__, __LINE__, \
__VA_ARGS__ ); \
}
#endif
void * pcdiXmalloc ( size_t, const char *, const char *, int );
#define xmalloc(size) pcdiXmalloc ( size, __FILE__, __func__, __LINE__ )
......
......@@ -4,10 +4,11 @@
#include <ctype.h>
#include "dmemory.h"
#include "cdi.h"
#include "cdi_int.h"
#include "cdf.h"
#include "dmemory.h"
#include "error.h"
#include "stream_grb.h"
#include "stream_cdf.h"
#include "stream_srv.h"
......@@ -454,7 +455,7 @@ void streamDefByteorder(int streamID, int byteorder)
if ( reshGetStatus ( streamID, &streamOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -2235,7 +2236,7 @@ void streamDefCompType(int streamID, int comptype)
if ( reshGetStatus ( streamID, &streamOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -2253,7 +2254,7 @@ void streamDefCompLevel(int streamID, int complevel)
if ( reshGetStatus ( streamID, &streamOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......
......@@ -7,6 +7,7 @@
#include "dmemory.h"
#include "cdi.h"
#include "error.h"
#include "taxis.h"
#include "cdi_int.h"
#include "calendar.h"
......@@ -294,7 +295,7 @@ void taxisDefType(int taxisID, int type)
if ( reshGetStatus ( taxisID, &taxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......@@ -375,7 +376,7 @@ void taxisDefRdate(int taxisID, int rdate)
if ( reshGetStatus ( taxisID, &taxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -406,7 +407,7 @@ void taxisDefRtime(int taxisID, int rtime)
if ( reshGetStatus ( taxisID, &taxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -439,7 +440,7 @@ void taxisDefCalendar(int taxisID, int calendar)
if ( reshGetStatus ( taxisID, &taxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -457,7 +458,7 @@ void taxisDefTunit(int taxisID, int unit)
if ( reshGetStatus ( taxisID, &taxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -475,7 +476,7 @@ void taxisDefNumavg(int taxisID, int numavg)
if ( reshGetStatus ( taxisID, &taxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -520,7 +521,7 @@ void taxisDeleteBounds(int taxisID)
if ( reshGetStatus ( taxisID, &taxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -609,7 +610,7 @@ void taxisDefVdateBounds(int taxisID, int vdate_lb, int vdate_ub)
if ( reshGetStatus ( taxisID, &taxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......@@ -670,7 +671,7 @@ void taxisDefVtimeBounds(int taxisID, int vtime_lb, int vtime_ub)
if ( reshGetStatus ( taxisID, &taxisOps ) == CLOSED )
{
xwarning("%s", "Operation not executed.");
Warning("%s", "Operation not executed.");
return;
}
......
......@@ -5,6 +5,7 @@
#include "dmemory.h"
#include "cdi.h"
#include "cdi_int.h"
#include "error.h"
#include "vlist.h"
#include "zaxis.h"
#include "varscan.h"
......@@ -1132,7 +1133,7 @@ void vlistDefNtsteps(int vlistID, int nts)
if ( reshGetStatus ( vlistID, &vlist_ops ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......@@ -1280,7 +1281,7 @@ void vlistDefTaxis(int vlistID, int taxisID)
if ( reshGetStatus ( vlistID, &vlist_ops ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......@@ -1325,7 +1326,7 @@ void vlistDefTable(int vlistID, int tableID)
if ( reshGetStatus ( vlistID, &vlist_ops ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......@@ -1355,9 +1356,7 @@ void vlistDefInstitut(int vlistID, int instID)
if ( reshGetStatus ( vlistID, &vlist_ops ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
xdebug("%s", "");
Warning("%s", "Operation not executed." );
return;
}
......@@ -1403,7 +1402,7 @@ void vlistDefModel(int vlistID, int modelID)
if ( reshGetStatus ( vlistID, &vlist_ops ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......@@ -1507,7 +1506,7 @@ void vlistChangeGridIndex(int vlistID, int index, int gridID)
if ( reshGetStatus ( vlistID, &vlist_ops ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......@@ -1533,7 +1532,7 @@ void vlistChangeGrid(int vlistID, int gridID1, int gridID2)
if ( reshGetStatus ( vlistID, &vlist_ops ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......@@ -1600,7 +1599,7 @@ void vlistChangeZaxisIndex(int vlistID, int index, int zaxisID)
if ( reshGetStatus ( vlistID, &vlist_ops ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......@@ -1640,7 +1639,7 @@ void vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2)
if ( reshGetStatus ( vlistID, &vlist_ops ) == CLOSED )
{
xwarning("%s", "Operation not executed." );
Warning("%s", "Operation not executed." );
return;
}
......
......@@ -12,6 +12,7 @@
#include "cdi_int.h"
#include "vlist.h"
#include "pio_util.h"
#include "error.h"
#include "serialize.h"