ieee_arithmetic use in F77

I have some legacy F77 code, that test for NAN and infinite of real*8

I can link the code, using pgf77, if I use isnanf() and isinff() - but these two routines are not documented in the PGI manuals.

The modern routines would be ieee_is_nan() and ieee_is_finite(), but I can’t figure out how to include them in vanilla F77. In short, can I rewrite the F90 code:

program test
  use, intrinsic::ieee_arithmetic
  real *8 value
  logical y
  
  value=1.
  y = ieee_is_nan(value)
  print *, 'NAN(',v,')=', y
end program test

as something like:

      program test

      real *8 value
      logical y

      value=1.
      y = ieee_is_nan(value)
      print *, 'NAN(',v,')=', y
      end

but this gives me:

% pgf77 -c testx.f
% pgf77 -o testx testx.o
testx.o: In function test': /tmp/./testx.f:7: undefined reference to ieee_is_nan_’

pgf77 croakes on a USE statement, like

      USE, INTRINSIC :: IEEE_ARITHMETIC

% pgf77 -c testx-ifort.f
PGFTN-S-0034-Syntax error at or near , (testx-ifort.f: 2)
0 inform, 0 warnings, 1 severes, 0 fatal for test
PGFTN/x86-64 Linux 13.9-0: compilation completed with severe errors

while ifort will compile and link

% ifort -c testx-ifort.f
% ifort -o testx-ifort testx-ifort.o

PS: I use pgf77 13.9

Hi Sylvain,

Unlike ifort, pgf77 is strictly a F77 compiler and doesn’t allow F90 or later constructs. Though, since F2003 is a superset of F77 (barring obsolete features), you can use pgfortran to compile this code.

The “isnanf” and “isinff” routines are not Fortran, rather they are C99 or are non-standard compiler extensions. You certainly can use them but moving to the F2003 ieee_arithmetic routines would be standard compliant method.

  • Mat

Hi Matt,

Thanks - but as is, the code will not build w/ pgfortran … something I can probably fix.

The “isnanf” and “isinff” routines are not Fortran, rather they are C99 or are non-standard compiler extensions. You certainly can use them but moving to the F2003 ieee_arithmetic routines would be standard compliant method.

  • Mat

Do you know if the argument of “isnanf” and “isinff” is a float or a double (R4 or R4 or the compiler/linker will adjust), and what man page / doc is correctly describing them.

Thanks - cheers, S.

Thanks - but as is, the code will not build w/ pgfortran … something I can probably fix.

Something I can help with?

Do you know if the argument of “isnanf” and “isinff” is a float or a double

They are single precision. “isnan” and “isinf” are the double precision.

I thought a bit more about these functions and think you might have some issues. In some cases, these routines are C macros so you many not have anything to link against.

  • Mat