GRVY-0.38.0
Floating Point Error Detection using Fortran API

An illustrative code example in F90 using the available inf/nan tests is shown below (and is also available in the examples directory from a top-level install).

!!-----------------------------------------------------------------------bl-
!!--------------------------------------------------------------------------
!!
!! libGRVY - a utility library for scientific computing.
!!
!! Copyright (C) 2008-2013,2018-2022 The PECOS Development Team
!! Additional Copyright (C) 2018 individual authors
!!
!! This library is free software; you can redistribute it and/or
!! modify it under the terms of the Version 2.1 GNU Lesser General
!! Public License as published by the Free Software Foundation.
!!
!! This library is distributed in the hope that it will be useful,
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
!! Lesser General Public License for more details.
!!
!! You should have received a copy of the GNU Lesser General Public
!! License along with this library; if not, write to the Free Software
!! Foundation, Inc. 51 Franklin Street, Fifth Floor,
!! Boston, MA 02110-1301 USA
!!
!!-----------------------------------------------------------------------el-
!!
!! math.f90: Fortran example illustrating inf/nan math tests.
!!
!!--------------------------------------------------------------------------
!!--------------------------------------------------------------------------
program test_isnan_isinf
use grvy
implicit none
real*8 :: should_be_nan
real*8 :: should_be_inf
real*8 :: m_one, one, zero
integer :: is_nan, is_inf
m_one = -1.d0
one = 1.d0
zero = 0.d0
should_be_nan = sqrt(m_one)
should_be_inf = one/zero
call grvy_double_isnan( should_be_nan, is_nan )
if( is_nan .eq. 1 )then
write(*,*) "NaN detected"
endif
call grvy_double_isinf( should_be_inf, is_inf )
if( is_inf .eq. 1 )then
write(*,*) "Inf detected"
endif
call grvy_double_isnan( 5.d0, is_nan )
if( is_nan .eq. 1 )then
write(*,*) "NaN detected"
endif
call grvy_double_isinf( 1.d0, is_inf )
if( is_inf .eq. 1 )then
write(*,*) "Inf detected"
endif
return
end program test_isnan_isinf
grvy_double_isnan
int grvy_double_isnan(double *value)
Check if input double value is not a number (NaN)
grvy_double_isinf
int grvy_double_isinf(double *vauel)
Check if input double value is infinite (Inf)

Generated on Wed Jul 12 2023 16:53:23 for GRVY-0.38.0 by  doxygen 1.8.17