Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
dd859362
Commit
dd859362
authored
Jun 26, 2008
by
Uwe Schulzweida
Browse files
DBL_IS_EQUAL: check NaN with isnan
parent
cceb78ed
Changes
9
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
dd859362
...
...
@@ -7,6 +7,7 @@
* cdfInqContents: skip time variable with type = NC_CHAR
* grbDefGrid: add warning for curvilinear grids
* ptaxisCopy: don't overwrite item 'self' (bug fix)
* DBL_IS_EQUAL: check NaN with isnan
* Version 1.2.0 released
2008-04-08 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
...
...
app/cdi.c
View file @
dd859362
#if defined (HAVE_CONFIG_H)
# include "../src/config.h"
#endif
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdarg.h>
...
...
@@ -9,13 +13,17 @@
#include
"cdi.h"
#ifndef DBL_IS_EQUAL
#if defined (HAVE_ISNAN)
# define DBL_IS_EQUAL(x,y) (isnan(x)||isnan(y)?(isnan(x)&&isnan(y)?1:0):!(fabs(x - y) > 0))
#else
/*
#define DBL_IS_EQUAL(x,y) (fabs(x - y) <= 2.0*(y*DBL_EPSILON + DBL_MIN))
#
define DBL_IS_EQUAL(x,y) (fabs(x - y) <= 2.0*(y*DBL_EPSILON + DBL_MIN))
*/
#define DBL_IS_EQUAL(x,y) (!(fabs(x - y) > 0))
#
define DBL_IS_EQUAL(x,y) (!(fabs(x - y) > 0))
#endif
#endif
void
decode_date
(
int
date
,
int
*
year
,
int
*
month
,
int
*
day
);
void
decode_time
(
int
time
,
int
*
hour
,
int
*
minute
);
...
...
configure
View file @
dd859362
...
...
@@ -5556,6 +5556,102 @@ _ACEOF
fi
# Checks for the availability of ANSI-C99 functions
for
ac_func
in
isnan
do
as_ac_var
=
`
echo
"ac_cv_func_
$ac_func
"
|
$as_tr_sh
`
{
echo
"
$as_me
:
$LINENO
: checking for
$ac_func
"
>
&5
echo
$ECHO_N
"checking for
$ac_func
...
$ECHO_C
"
>
&6
;
}
if
{
as_var
=
$as_ac_var
;
eval
"test
\"\$
{
$as_var
+set}
\"
= set"
;
}
;
then
echo
$ECHO_N
"(cached)
$ECHO_C
"
>
&6
else
cat
>
conftest.
$ac_ext
<<
_ACEOF
/* confdefs.h. */
_ACEOF
cat
confdefs.h
>>
conftest.
$ac_ext
cat
>>
conftest.
$ac_ext
<<
_ACEOF
/* end confdefs.h. */
/* Define
$ac_func
to an innocuous variant, in case <limits.h> declares
$ac_func
.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define
$ac_func
innocuous_
$ac_func
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char
$ac_func
(); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef
$ac_func
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char
$ac_func
();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_
$ac_func
|| defined __stub___
$ac_func
choke me
#endif
int
main ()
{
return
$ac_func
();
;
return 0;
}
_ACEOF
rm
-f
conftest.
$ac_objext
conftest
$ac_exeext
if
{
(
ac_try
=
"
$ac_link
"
case
"((
$ac_try
"
in
*
\"
*
|
*
\`
*
|
*
\\
*
)
ac_try_echo
=
\$
ac_try
;;
*
)
ac_try_echo
=
$ac_try
;;
esac
eval
"echo
\"\$
as_me:
$LINENO
:
$ac_try_echo
\"
"
)
>
&5
(
eval
"
$ac_link
"
)
2>conftest.er1
ac_status
=
$?
grep
-v
'^ *+'
conftest.er1
>
conftest.err
rm
-f
conftest.er1
cat
conftest.err
>
&5
echo
"
$as_me
:
$LINENO
:
\$
? =
$ac_status
"
>
&5
(
exit
$ac_status
)
;
}
&&
{
test
-z
"
$ac_c_werror_flag
"
||
test
!
-s
conftest.err
}
&&
test
-s
conftest
$ac_exeext
&&
$as_test_x
conftest
$ac_exeext
;
then
eval
"
$as_ac_var
=yes"
else
echo
"
$as_me
: failed program was:"
>
&5
sed
's/^/| /'
conftest.
$ac_ext
>
&5
eval
"
$as_ac_var
=no"
fi
rm
-f
core conftest.err conftest.
$ac_objext
conftest_ipa8_conftest.oo
\
conftest
$ac_exeext
conftest.
$ac_ext
fi
ac_res
=
`
eval echo
'${'
$as_ac_var
'}'
`
{
echo
"
$as_me
:
$LINENO
: result:
$ac_res
"
>
&5
echo
"
${
ECHO_T
}
$ac_res
"
>
&6
;
}
if
test
`
eval echo
'${'
$as_ac_var
'}'
`
=
yes
;
then
cat
>>
confdefs.h
<<
_ACEOF
#define `echo "HAVE_
$ac_func
" |
$as_tr_cpp
` 1
_ACEOF
fi
done
# ----------------------------------------------------------------------
# Compile interface with internal GRIB library
#
...
...
configure.ac
View file @
dd859362
...
...
@@ -32,6 +32,9 @@ AC_CHECK_LIB(malloc, mallinfo)
# Checks for structures.
AC_CHECK_MEMBERS([struct stat.st_blksize])
# Checks for the availability of ANSI-C99 functions
AC_CHECK_FUNCS(isnan)
# ----------------------------------------------------------------------
# Compile interface with internal GRIB library
#
...
...
src/config.h.in
View file @
dd859362
...
...
@@ -9,6 +9,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `isnan' function. */
#undef HAVE_ISNAN
/* Define to 1 for EXTRA interface */
#undef HAVE_LIBEXTRA
...
...
src/grid.c
View file @
dd859362
...
...
@@ -2105,7 +2105,8 @@ static void grid_check_cyclic(GRID *gridptr)
xinc
=
xvals
[
1
]
-
xvals
[
0
];
x0
=
2
*
xvals
[
xsize
-
1
]
-
xvals
[
xsize
-
2
]
-
360
;
if
(
!
DBL_IS_EQUAL
(
xvals
[
0
],
xvals
[
xsize
-
1
])
)
if
(
DBL_IS_EQUAL
(
x0
,
xvals
[
0
])
)
gridptr
->
isCyclic
=
TRUE
;
if
(
fabs
(
x0
-
xvals
[
0
])
<
1.e-4
)
gridptr
->
isCyclic
=
TRUE
;
/* if ( DBL_IS_EQUAL(x0, xvals[0]) ) gridptr->isCyclic = TRUE; */
}
}
else
if
(
gridptr
->
type
==
GRID_CURVILINEAR
)
...
...
src/stream_cdf.c
View file @
dd859362
...
...
@@ -2834,7 +2834,6 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
if
(
vlistInqVarMissvalUsed
(
vlistID
,
varID
)
==
TRUE
)
{
missval
=
vlistInqVarMissval
(
vlistID
,
varID
);
for
(
i
=
0
;
i
<
gridsize
;
i
++
)
if
(
DBL_IS_EQUAL
(
data
[
i
],
missval
)
)
*
nmiss
+=
1
;
}
...
...
src/stream_grb.c
View file @
dd859362
...
...
@@ -1857,7 +1857,7 @@ void grbDefGrid(int *isec1, int *isec2, int gridID)
if
(
lwarn
)
{
lwarn
=
FALSE
;
Warning
(
func
,
"Curvilinear grids are unsupported in GRIB format! Create wrong GDS!"
);
Warning
(
func
,
"Curvilinear grids are unsupported in GRIB format! Create
d
wrong GDS!"
);
}
gridtype
=
GRID_LONLAT
;
}
...
...
src/stream_int.h
View file @
dd859362
...
...
@@ -58,10 +58,14 @@ char *strdup(const char *s);
#endif
#ifndef DBL_IS_EQUAL
#if defined (HAVE_ISNAN)
# define DBL_IS_EQUAL(x,y) (isnan(x)||isnan(y)?(isnan(x)&&isnan(y)?1:0):!(fabs(x - y) > 0))
#else
/*
#define DBL_IS_EQUAL(x,y) (fabs(x - y) <= 2.0*(y*DBL_EPSILON + DBL_MIN))
#
define DBL_IS_EQUAL(x,y) (fabs(x - y) <= 2.0*(y*DBL_EPSILON + DBL_MIN))
*/
#define DBL_IS_EQUAL(x,y) (!(fabs(x - y) > 0))
# define DBL_IS_EQUAL(x,y) (!(fabs(x - y) > 0))
#endif
#endif
#ifndef INT
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment