Problem with Selected_Real_Kind
Tim Prince
n8tm@aol.com
Thu Aug 6 22:10:00 GMT 2009
RadSurfer wrote:
> 1 program test
> 2 implicit none
> 3
> 4 integer x
> 5 logical, dimension(3) :: a
> 6 real, parameter :: DP=selected_real_kind(9,99)
> 7 real (kind(dp)) :: u,v,w;
> 8
> 9 u = 2 * 3.1415_DP
> 10
> 11 write(*,*) 3.1415_(kind(dp))
> 12 write(*,*) 3.1415_DP
> 13
> 14 end program test
>
> line 7 seems to differ from syntax most books suggest,
> also
> why is line 9 rejected? I have tried DOZENS of different possibilities
> and it appears gfortran does not permit what most fortran books and
> online references say should work! What gives here?
>
> RadSurfer@yahoo.com
>
> //Rich//
>
>
Chances are your compiler considers dp and DP to be the same.
Line 6 doesn't make much sense, as KIND values are integer, and setting
DP as a default real surely conflicts with your lines 9 and 12 and
should cause the compiler to find errors there.
Line 7, if it works, declares default real kind (the same kind you set
for DP).
line 11, of course, shows a context where the KIND intrinsic should not
be accepted.
More information about the Fortran
mailing list