| 1 |
program main |
| 2 |
use, intrinsic :: iso_fortran_env, only : error_unit |
| 3 |
implicit none |
| 4 |
|
| 5 |
! http://fortranwiki.org/fortran/show/Real+precision |
| 6 |
integer, parameter :: sp = selected_real_kind(6, 37) |
| 7 |
integer, parameter :: dp = selected_real_kind(15, 307) |
| 8 |
|
| 9 |
real(sp) :: a32 |
| 10 |
real(dp) :: a64 |
| 11 |
|
| 12 |
real(sp), parameter :: pi32 = 4*atan(1._sp) |
| 13 |
real(dp), parameter :: pi64 = 4*atan(1._dp) |
| 14 |
|
| 15 |
if (pi32 == pi64) stop 1 |
| 16 |
|
| 17 |
call timestwo(a32) |
| 18 |
call timestwo(a64) |
| 19 |
|
| 20 |
contains |
| 21 |
|
| 22 |
elemental subroutine timestwo(a) |
| 23 |
|
| 24 |
class(*), intent(inout) :: a |
| 25 |
|
| 26 |
select type (a) |
| 27 |
type is (real(sp)) |
| 28 |
a = 2*a |
| 29 |
type is (real(dp)) |
| 30 |
a = 2*a |
| 31 |
type is (integer) |
| 32 |
a = 2*a |
| 33 |
end select |
| 34 |
|
| 35 |
end subroutine timestwo |
| 36 |
|
| 37 |
end program |