- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could anybody tell me how I can use quadruple precision in fortran90/95 code?
Is there also any special treatment such as 1.0D0 for double precision?
Also, if there are any special ways to compile the file, please let me know that too.
Please assume I am a very beginner of fortran90/95.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you can. Declare variables as REAL(16). For example:
REAL(16) :: Q
For constants, use a suffix _16 such as 1.0_16.
Better, actually, would be to declare a named constant for the quad precision kind like this:
INTEGER, PARAMETER :: QUAD = SELECTED_REAL_KIND(32)
and then use QUAD instead of 16. For example:
REAL(QUAD) :: Q
Q = 3.14_QUAD
When calling intrinsic functions such as SQRT and SIN, just use the generic name and don't try to use a kind-specific name such as QSQRT.
Please note that quad precision arithmetic is performed using software and not the CPU directly, so it will be much slower than single or double precision. You may want to use quad precision only in those parts of the algorithm that need the extra precision.
REAL(16) :: Q
For constants, use a suffix _16 such as 1.0_16.
Better, actually, would be to declare a named constant for the quad precision kind like this:
INTEGER, PARAMETER :: QUAD = SELECTED_REAL_KIND(32)
and then use QUAD instead of 16. For example:
REAL(QUAD) :: Q
Q = 3.14_QUAD
When calling intrinsic functions such as SQRT and SIN, just use the generic name and don't try to use a kind-specific name such as QSQRT.
Please note that quad precision arithmetic is performed using software and not the CPU directly, so it will be much slower than single or double precision. You may want to use quad precision only in those parts of the algorithm that need the extra precision.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
Thanks.
Let me ask another question.
When I want to use some integers with quadruple precision value, how should I treat the integer?
For instance, when I 'm using double precision, we can do...
dx = 2.0D0/DBLE(n)
Is there anything like"DBLE" for Quadruple precision?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use REAL(N,QUAD) - this converts the argument N to a REAL of kind QUAD. (Assumes you have defined the PARAMETER constant QUAD.)

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