Coder Social home page Coder Social logo

equipez / infnan Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 1.0 477 KB

Fortran functions for checking Inf/NaN. They should work even if the compilers are invoked with aggressive optimization flags such as `gfortran -Ofast`.

License: GNU Lesser General Public License v3.0

Makefile 23.42% Fortran 76.58%
floating-point fortran numerical inf nan

infnan's Introduction

infnan

infnan.f90 implements a module that provides some functions for checking Inf/NaN. They aim to work even when compilers are invoked with aggressive optimization flags, including particularly gfortran -Ofast.

Many ways exist to implement functions like is_nan. However, not all of them work with aggressive optimization flags. For example, there are such discussions on StackOverflow and Fotran Discourse.

The ieee_is_nan included in ieee_arithmetic of gfortran 9.3.0 does not work with aggressive optimization flags like -Ofast. Given the fact that -Ofast implies -ffinite-math-only, we cannot blame ieee_arithmetic for the failure. In addition, some compilers (gfortran 9.3.0, ifort 21.0, and nagfor 7.0) may not behave in the most desirable way concerning the return kind of ieee_is_nan when some special compilation flags are imposed, as has been discussed on Fortran Discourse.

My choice of implementation is totally empirical, in the sense that I have not studied in-depth what the aggressive optimization flags really do, but only made some tests and found some implementation that worked correctly. In other words, I do not know why my implementation works but other implementations may not. The story may change when compilers are changed/updated.

The good news is, I have tested the functions using ten compilers with the most aggressive optimization flags that I can figure out, and they all succeeded. In particular, the functions work well with gfortran -Ofast for gfortran 9.3.0 and 10.3.0, but those based on ieee_arithmetic fail. Such a test can be done by

cd test && make clean && make gtest

However, we did observe failures. See the issues for details. I will be very happy to hear your suggestions on how to fix them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.