- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am writing a self contained function for which Iwill not provide a dsp file. I do not want to write d0 after all constants, but I want them all to interpreted as real*8. This I normally do by using /fpconstant, but this is stored in the dsp file - is there an equivalent compiler directive I can use?
Adrian
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, that's not what /fpconstant does. That switch makes the datatype of constants dependent on their context.
There is not a directive for /fpconstant, nor for /real_size:64, which does make single-precision constants double precision.
My advice is to specify the D0 or use an explicit kind specifier.
There is not a directive for /fpconstant, nor for /real_size:64, which does make single-precision constants double precision.
My advice is to specify the D0 or use an explicit kind specifier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess I'm a little confused then.
In Project -> Settings -> Fortran -> Fortran Data, selecting "Extend Precision of Single Precision Constants" (which is what I interpret to mean "turn 2.0 into 2.0d0") toggles the /fpconstant compiler argument.
On the other hand, selecting 8 for the Default Real Kind is the one that turns on /real_size:64 (and this I had interpreted to mean "interpret the variable declaration'real xdata' as 'real*8 xdata' " ). I see that there is a compiler directive for this one - !DEC $REAL:8.
This interpretation works for me, so I'm not sure what is wrong with this interpretation.
Adrian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
/fpconstant affects a case such as this:
REAL(8) PI
PI = 3.1415926535897
In Fortran 90/95. the constant is single precision, and then gets extended with binary zeroes to double precision. With /fpconstant, real constants are held, internally, in REAL(8) until they are used and then converted if necessary.
/real_size:64 makes everything that is "default real kind" REAL(8): variables, constants and intrinsics, so it has a much broader effect than /fpconstant.
Ah - I forgot about !DEC$ REAL. We picked that one up from Microsoft. Perhaps that will work for you?
REAL(8) PI
PI = 3.1415926535897
In Fortran 90/95. the constant is single precision, and then gets extended with binary zeroes to double precision. With /fpconstant, real constants are held, internally, in REAL(8) until they are used and then converted if necessary.
/real_size:64 makes everything that is "default real kind" REAL(8): variables, constants and intrinsics, so it has a much broader effect than /fpconstant.
Ah - I forgot about !DEC$ REAL. We picked that one up from Microsoft. Perhaps that will work for you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, that's how I understood it. But, to get the double version of the constant into PI, Ineed to eithercompile your codewith /fpconstant, or append a d0 to the constant.
I don't want to rely on the latter, since I am not in control of the dsp file that my code will be used in. And I really wanted to know whether I could avoid adding numerous d0's to all my constants, by using a suitable compiler directive. Unfortunately, a quick test on !DEC $REAL:8 shows it doesn't do it.
Adrian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why exactly do you not want to add D0? Or better, something like this:
This is the "proper" F90 way to do it.
However, !DEC$ REAL:8 works for me:
integer, parameter :: dp = selected_real_kind(15)
real(dp) pi
pi = 3.141592653589723_dp
This is the "proper" F90 way to do it.
However, !DEC$ REAL:8 works for me:
>type t.f90
!DEC$ REAL:8
REAL PI
PI = 3.141592653589723
write (*,*) PI
end
>ifort t.f90
Intel Fortran Compiler for 32-bit applications, Version 8.1 Build 20040923Z Package ID: w_fc_pc_8.1.021
Copyright (C) 1985-2004 Intel Corporation. All rights reserved.
Microsoft Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
-out:t.exe
-subsystem:console
-entry:mainCRTStartup
t.obj
>t.exe
3.14159265358972
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, !DEC$ REAL:8 does actually work, I had a typo - !DEC $REAL:8 - which compiles OK, but doesn't do the same thing...
Adrian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Right - if there is a space after the DEC, it is not recognized as a directive and is just a comment.

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