Commit 8da137c7 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Info: check floating-point exceptions.

parent 832c2911
......@@ -3,6 +3,10 @@
* using CDI library version 1.8.0
* Version 1.8.0 release
2017-01-28 Uwe Schulzweida
* Info: check floating-point exceptions
2017-01-25 Uwe Schulzweida
* New operator timrange: time range (timmax-timmin)
......
......@@ -241,6 +241,7 @@ void printMap(int nlon, int nlat, double *array, double missval, double min, dou
void *Info(void *argument)
{
int fpeRaised = 0;
int varID, levelID;
int nrecs;
int nmiss;
......@@ -373,24 +374,13 @@ void *Info(void *argument)
ivals++;
}
}
fpeRaised = 0;
imiss = gridsize - ivals;
nvals = ivals;
}
else
{
arrmean = array[0];
//arrvar = array[0];
arrmin = array[0];
arrmax = array[0];
// #pragma omp parallel for default(none) shared(arrmin, arrmax, array, gridsize) reduction(+:arrmean, arrvar)
// #pragma omp simd reduction(+:arrmean) reduction(min:arrmin) reduction(max:arrmax) aligned(array:16)
for ( int i = 1; i < gridsize; i++ )
{
if ( array[i] < arrmin ) arrmin = array[i];
if ( array[i] > arrmax ) arrmax = array[i];
arrmean += array[i];
// arrvar += array[i]*array[i];
}
fpeRaised = array_minmaxmean_val(array, gridsize, &arrmin, &arrmax, &arrmean);
nvals = gridsize;
}
......@@ -423,6 +413,7 @@ void *Info(void *argument)
nvals_i++;
}
}
fpeRaised = 0;
imiss = gridsize - nvals_r;
......@@ -456,14 +447,14 @@ void *Info(void *argument)
fprintf(stdout, "\n");
if ( imiss != nmiss && nmiss > 0 )
fprintf(stdout, "Found %d of %d missing values!\n", imiss, nmiss);
cdoPrint("Found %d of %d missing values!", imiss, nmiss);
if ( fpeRaised > 0 ) cdoWarning("floating-point exception reported: %s!", fpe_errstr(fpeRaised));
if ( operatorID == MAP )
{
int nlon, nlat;
nlon = gridInqXsize(gridID);
nlat = gridInqYsize(gridID);
{
int nlon = gridInqXsize(gridID);
int nlat = gridInqYsize(gridID);
if ( gridInqType(gridID) == GRID_GAUSSIAN ||
gridInqType(gridID) == GRID_LONLAT ||
......
## Process this file with automake to produce Makefile.in
noinst_LTLIBRARIES = libcdo.la
libcdo_la_SOURCES = \
array.h \
array.c \
cdo_int.h \
compare.h \
cdo_pthread.c \
......
......@@ -102,22 +102,23 @@ CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libcdo_la_LIBADD =
am__dirstamp = $(am__leading_dot)dirstamp
am_libcdo_la_OBJECTS = libcdo_la-cdo_pthread.lo libcdo_la-cdo_vlist.lo \
libcdo_la-cdo_getopt.lo libcdo_la-cdo_task.lo \
libcdo_la-cdo_history.lo libcdo_la-cmortable_parser.lo \
libcdo_la-after_sptrans.lo libcdo_la-after_fctrans.lo \
libcdo_la-after_dvtrans.lo libcdo_la-after_vertint.lo \
libcdo_la-after_namelist.lo libcdo_la-afterburnerlib.lo \
libcdo_la-constants.lo libcdo_la-color.lo \
libcdo_la-commandline.lo libcdo_la-convert_units.lo \
libcdo_la-datetime.lo libcdo_la-ecacore.lo \
libcdo_la-ecautil.lo libcdo_la-exception.lo libcdo_la-expr.lo \
libcdo_la-expr_fun.lo libcdo_la-expr_lex.lo \
libcdo_la-expr_yacc.lo libcdo_la-features.lo \
libcdo_la-field.lo libcdo_la-field2.lo libcdo_la-fieldc.lo \
libcdo_la-fieldmem.lo libcdo_la-fieldmer.lo \
libcdo_la-fieldzon.lo libcdo_la-gradsdeslib.lo \
libcdo_la-grid.lo libcdo_la-grid_area.lo libcdo_la-grid_gme.lo \
am_libcdo_la_OBJECTS = libcdo_la-array.lo libcdo_la-cdo_pthread.lo \
libcdo_la-cdo_vlist.lo libcdo_la-cdo_getopt.lo \
libcdo_la-cdo_task.lo libcdo_la-cdo_history.lo \
libcdo_la-cmortable_parser.lo libcdo_la-after_sptrans.lo \
libcdo_la-after_fctrans.lo libcdo_la-after_dvtrans.lo \
libcdo_la-after_vertint.lo libcdo_la-after_namelist.lo \
libcdo_la-afterburnerlib.lo libcdo_la-constants.lo \
libcdo_la-color.lo libcdo_la-commandline.lo \
libcdo_la-convert_units.lo libcdo_la-datetime.lo \
libcdo_la-ecacore.lo libcdo_la-ecautil.lo \
libcdo_la-exception.lo libcdo_la-expr.lo libcdo_la-expr_fun.lo \
libcdo_la-expr_lex.lo libcdo_la-expr_yacc.lo \
libcdo_la-features.lo libcdo_la-field.lo libcdo_la-field2.lo \
libcdo_la-fieldc.lo libcdo_la-fieldmem.lo \
libcdo_la-fieldmer.lo libcdo_la-fieldzon.lo \
libcdo_la-gradsdeslib.lo libcdo_la-grid.lo \
libcdo_la-grid_area.lo libcdo_la-grid_gme.lo \
libcdo_la-grid_lcc.lo libcdo_la-grid_rot.lo \
libcdo_la-grid_from_name.lo libcdo_la-grid_read.lo \
libcdo_la-grid_read_pingo.lo libcdo_la-grid_print.lo \
......@@ -503,28 +504,28 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = libcdo.la
libcdo_la_SOURCES = cdo_int.h compare.h cdo_pthread.c cdo_vlist.c \
cdo_getopt.c cdo_getopt.h cdo_task.c cdo_task.h cdo_history.c \
cdi_uuid.h cmortable_parser.c after_sptrans.c after_fctrans.c \
after_dvtrans.c after_vertint.c after_vertint.h \
after_namelist.c afterburnerlib.c afterburner.h vct_l191.h \
calendar.h constants.h constants.c color.c color.h \
commandline.c const.h convert_units.c convert_units.h \
counter.h datetime.c datetime.h dmemory.h ecacore.c ecacore.h \
ecautil.c ecautil.h error.h etopo.h temp.h mask.h exception.c \
expr.c expr.h expr_fun.c expr_fun.h expr_lex.c expr_yacc.c \
expr_yacc.h features.c field.c field.h field2.c fieldc.c \
fieldmem.c fieldmer.c fieldzon.c functs.h gradsdeslib.c \
gradsdeslib.h grid.c grid.h grid_area.c grid_gme.c grid_lcc.c \
grid_rot.c grid_from_name.c grid_read.c grid_read_pingo.c \
grid_print.c gridreference.c griddes.c griddes.h griddes_h5.c \
griddes_nc.c hetaeta.c hetaeta.h institution.c interpol.c \
interpol.h job.c juldate.c grid_search.c grid_search.h \
listarray.c listarray.h list.c list.h listbuf.c listbuf.h \
merge_sort2.c merge_sort2.h modules.c modules.h namelist.c \
namelist.h namelist_parser.c normal.c nth_element.c \
nth_element.h operator_help.h par_io.c par_io.h \
parse_literal.c percentiles_hist.c percentiles_hist.h \
libcdo_la_SOURCES = array.h array.c cdo_int.h compare.h cdo_pthread.c \
cdo_vlist.c cdo_getopt.c cdo_getopt.h cdo_task.c cdo_task.h \
cdo_history.c cdi_uuid.h cmortable_parser.c after_sptrans.c \
after_fctrans.c after_dvtrans.c after_vertint.c \
after_vertint.h after_namelist.c afterburnerlib.c \
afterburner.h vct_l191.h calendar.h constants.h constants.c \
color.c color.h commandline.c const.h convert_units.c \
convert_units.h counter.h datetime.c datetime.h dmemory.h \
ecacore.c ecacore.h ecautil.c ecautil.h error.h etopo.h temp.h \
mask.h exception.c expr.c expr.h expr_fun.c expr_fun.h \
expr_lex.c expr_yacc.c expr_yacc.h features.c field.c field.h \
field2.c fieldc.c fieldmem.c fieldmer.c fieldzon.c functs.h \
gradsdeslib.c gradsdeslib.h grid.c grid.h grid_area.c \
grid_gme.c grid_lcc.c grid_rot.c grid_from_name.c grid_read.c \
grid_read_pingo.c grid_print.c gridreference.c griddes.c \
griddes.h griddes_h5.c griddes_nc.c hetaeta.c hetaeta.h \
institution.c interpol.c interpol.h job.c juldate.c \
grid_search.c grid_search.h listarray.c listarray.h list.c \
list.h listbuf.c listbuf.h merge_sort2.c merge_sort2.h \
modules.c modules.h namelist.c namelist.h namelist_parser.c \
normal.c nth_element.c nth_element.h operator_help.h par_io.c \
par_io.h parse_literal.c percentiles_hist.c percentiles_hist.h \
percentiles.c percentiles.h pipe.c pipe.h pmlist.c pmlist.h \
sellist.c sellist.h pragma_omp_atomic_update.h printinfo.h \
process.c process.h pstream.c pstream.h pstream_write.h \
......@@ -1004,6 +1005,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-after_sptrans.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-after_vertint.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-afterburnerlib.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-array.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-cdo_getopt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-cdo_history.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-cdo_pthread.Plo@am__quote@
......@@ -1129,6 +1131,13 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
libcdo_la-array.lo: array.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-array.lo -MD -MP -MF $(DEPDIR)/libcdo_la-array.Tpo -c -o libcdo_la-array.lo `test -f 'array.c' || echo '$(srcdir)/'`array.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-array.Tpo $(DEPDIR)/libcdo_la-array.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='array.c' object='libcdo_la-array.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-array.lo `test -f 'array.c' || echo '$(srcdir)/'`array.c
libcdo_la-cdo_pthread.lo: cdo_pthread.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-cdo_pthread.lo -MD -MP -MF $(DEPDIR)/libcdo_la-cdo_pthread.Tpo -c -o libcdo_la-cdo_pthread.lo `test -f 'cdo_pthread.c' || echo '$(srcdir)/'`cdo_pthread.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-cdo_pthread.Tpo $(DEPDIR)/libcdo_la-cdo_pthread.Plo
......
#include <stdio.h>
#include <float.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS ON
const char *fpe_errstr(int fpeRaised)
{
const char *errstr = NULL;
if ( fpeRaised & FE_INEXACT ) errstr = "inexact result";
else if ( fpeRaised & FE_INVALID ) errstr = "invalid result";
else if ( fpeRaised & FE_DIVBYZERO ) errstr = "division by zero";
else if ( fpeRaised & FE_OVERFLOW ) errstr = "overflow";
else if ( fpeRaised & FE_UNDERFLOW ) errstr = "underflow";
return errstr;
}
int array_minmaxmean_val(const double *array, size_t len, double *rmin, double *rmax, double *rmean)
{
double min = DBL_MAX;
double max = -DBL_MAX;
double mean = 0;
feclearexcept(FE_ALL_EXCEPT);
// #pragma omp parallel for default(none) shared(min, max, array, gridsize) reduction(+:mean)
// #pragma omp simd reduction(+:mean) reduction(min:min) reduction(max:max) aligned(array:16)
for ( size_t i = 0; i < len; ++i )
{
if ( array[i] < min ) min = array[i];
if ( array[i] > max ) max = array[i];
mean += array[i];
}
int fpeRaised = fetestexcept(FE_ALL_EXCEPT);
*rmin = min;
*rmax = max;
*rmean = mean;
return fpeRaised;
}
#ifndef _ARRAY_H
#define _ARRAY_H
const char *fpe_errstr(int fpeRaised);
int array_minmaxmean_val(const double *array, size_t len, double *rmin, double *rmax, double *rmean);
#endif // _ARRAY_H
......@@ -35,6 +35,7 @@
#include "pmlist.h"
#include "listbuf.h"
#include "compare.h"
#include "array.h"
#include "timebase.h"
#include "field.h"
#include "functs.h"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment