PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

ieee_arithmetic use in F77

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Sylvain K



Joined: 13 Oct 2009
Posts: 21

PostPosted: Mon Nov 04, 2013 9:43 am    Post subject: ieee_arithmetic use in F77 Reply with quote

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:
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:

Code:
      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

Code:
      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
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6129
Location: The Portland Group Inc.

PostPosted: Mon Nov 04, 2013 11:35 am    Post subject: Reply with quote

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
Back to top
View user's profile
Sylvain K



Joined: 13 Oct 2009
Posts: 21

PostPosted: Mon Nov 04, 2013 12:19 pm    Post subject: Reply with quote

mkcolg wrote:
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.


Hi Matt,

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

Quote:

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 (R*4 or R*4 or the compiler/linker will adjust), and what man page / doc is correctly describing them.

Thanks - cheers, S.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6129
Location: The Portland Group Inc.

PostPosted: Mon Nov 04, 2013 5:40 pm    Post subject: Reply with quote

Quote:
Thanks - but as is, the code will not build w/ pgfortran ... something I can probably fix.
Something I can help with?

Quote:
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
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group