I am using the Fortran 11 compiler in Visual Studio from Windows. How can I set real
values to double precision
from project properties? For example, in Fortran Powerstation (4.0) we have the menu option setti开发者_开发知识库ngs->code generation->default real kind
(here we can set the type of the real
data type). Similarly, how can we set double precision
to the real
variable in the Fortran 11 compiler?
Thanks in advance.
Unless you are looking to maintain the code under both compilers, perhaps you would be better off just changing the source code to use real*8's. That would get it behaving consistently when you do ports in the future too.
One other way around is using module iso_fortran_env. Then you can specify the real kind with predefined variables REAL32, REAL64 and REAL128, which are single precision, double precision and quadruple precision, if your compiler supports.
For example:
program main
use iso_fortran_env
implicit none
real(real32) :: a1 ! single precision
real(real64) :: a2 ! double precision
real(real128) :: a4 ! quadruple precision
end program
You can change the project properties to achieve this.
Open the Project Properties Dialog then navigate to ConfigurationProperties->Fortran->Data.
Then choose the drop down beside Default Real KIND and choose "8(/real)size64).
I am sure this is valid from VS2012 and on.
精彩评论