6 Replies Latest reply on Sep 12, 2008 5:48 PM by 807575

    using isnan

    807575
      I want to use isnan() function in a fortran code which I am compiling with mpif77/mpif90 or mpf95. I am getting error message

      mpf95 -c main.F -xO3 -Bstatic -e -Iinclude -I/opt/SUNWhpc/HPC7.1/include -I/home/hpc2073/SPfft/SPfft_32/include

      if (isnan(utau).or.isnan(ubulk)) then
      ^
      "main.F", Line = 190, Column = 14: ERROR: IMPLICIT NONE is specified in the local scope, therefore an explicit type must be specified for function "ISNAN".

      if (isnan(resid)) then
      ^
      "main.F", Line = 2063, Column = 11: ERROR: IMPLICIT NONE is specified in the local scope, therefore an explicit type must be specified for function "ISNAN".

      f90comp: 3810 SOURCE LINES
      f90comp: 2 ERRORS, 0 WARNINGS, 0 OTHER MESSAGES, 0 ANSI
      gmake: *** [main.o] Error 1

      why is it not recognizing isnan() as intrinsic function.
        • 1. Re: using isnan
          807575
          isnan is not a Fortran intrinsic. You should try using the ieee_is_nan function, which is defined in the ieee_arithmetic intrinsic module.
          • 2. Re: using isnan
            807575
            how can I invoke ieee_arithmatic function. I also tried ieee_is_nan() but got the same error message. Do I have to add some thing in my makefile.
            • 3. Re: using isnan
              807575
              You could use the function id_isnan( x )

              You can find the manpage using
              man libm_double
              • 4. Re: using isnan
                807575
                I am having the same problem. I am using ISNAN() on the pc. When I ported my code to the Sun Solaris Fortran I wrote a little function:

                FUNCTION HEC_ISNAN (X)

                LOGICAL HEC_ISNAN
                REAL X
                INTEGER isn

                isn = 0

                isn = IR_ISNAN(X)

                HEC_ISNAN = .FALSE.

                IF (isn /= 0) HEC_ISNAN = .TRUE.

                RETURN

                That worked fine. I copied everything over to a Sun Linux Fortran and now I am getting:


                hec_lib_call.o(.text+0x5b6): In function `hec_isnan_':
                : undefined reference to `ir_isnan_'
                make: *** [steadyx] Error 1

                I tried the above suggestion about using ieee_is_nan,

                FUNCTION HEC_ISNAN (X)

                USE, INTRINSIC :: IEEE_ARITHMETIC, IEEE_EXCEPTIONS
                ~code not shown
                isn = ieee_is_nan(X)

                and I get the following:


                USE, INTRINSIC :: IEEE_ARITHMETIC, IEEE_EXCEPTIONS
                ^
                "hec_lib_call.f", Line = 205, Column = 58: ERROR: Unexpected syntax: "=>" was expected but found "EOS".

                isn = ieee_is_nan(X)
                ^
                "hec_lib_call.f", Line = 218, Column = 12: ERROR: Assignment of a LOGICAL expression to a INTEGER variable is not allowed.

                If I take the USE... statement out, it does not find the ieee_is_nan call. Am I missing something? I'm not familiar with either the Sun or the Linux environment.

                I'm using Sun Studio 12 for Linux.

                Thanks for any help.
                • 5. Re: using isnan
                  807575
                  Under Solaris the functions ir_isnan and id_isnan exist. There
                  they are just wrappers into libm.

                  I don't know how this is handled under linux.

                  The usage of USE, INTRINSIC :: IEEE_ARITHMETIC, IEEE_EXCEPTIONS
                  is fairly new. For some information, see

                  http://developers.sun.com/solaris/articles/f2k.html
                  • 6. Re: using isnan
                    807575
                    Thanks for the link. It looks like the following was supposed to work:


                    USE, INTRINSIC :: IEEE_ARITHMETIC, IEEE_EXCEPTIONS

                    but I kept getting a compile error with this line. After looking at the link you provided, I tried:

                    USE, INTRINSIC :: IEEE_ARITHMETIC
                    USE, INTRINSIC :: IEEE_FEATURES

                    I'm not sure if the problem was that I was putting everything on a single line (like the example I saw) or that I really needed IEEE_FEATURES (I would think that isnan would be an exception), but in any case it worked. It also wasn't immediately clear to me that ieee_is_nan(X) is a logical function (not an integer function). But I look to be up and running. Thanks again for the response.