- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
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?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page