Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

real(kind=8)

john_lord
Novice
1,323 Views
Is real*8 and real(kind=8) always equivalent? Or is the kind parameter for double precision implementation dependent? Is real*4 deprecated in Fortran 90/95?

I am writing a module to perform some vector operations and want to provide support for single, double and mixed precision. Which form of declaration is most appropriate and portable?
0 Kudos
1 Reply
Steven_L_Intel1
Employee
1,323 Views
The syntax REAL*n is an extension - it has never been standard Fortran. Most Fortran implementations use the same numbers for the *n syntax and (KIND=n) syntax, but not all. Compaq and Intel do.

The usual portable approach is to create a module that defines named constants which you then use throughout the application, based on the either the SELECTED_REAL_KIND intrinsic or the KIND intrinsic. For example:

integer, parameter :: sp = KIND(1.0)
integer, parameter :: dp = KIND(1.0D0)

Then you could use real(sp) in your declarations and 1.0_sp in your constants. The alternative is something like this:

integer, parameter :: sp = SELECTED_REAL_KIND(6)
integer, parameter :: dp = SELECTED_REAL_KIND(12)

Read the documentation about SELECTED_REAL_KIND for more details.

Steve
0 Kudos
Reply