Debian Codegraph @

test cases/fortran/19 fortran_std/std2018.f90

raw
1 program main
2 use, intrinsic :: iso_fortran_env, only : error_unit, sp=>real32, dp=>real64
3 implicit none
4
5 real(sp) :: a32
6 real(dp) :: a64
7
8 real(sp), parameter :: pi32 = 4*atan(1._sp)
9 real(dp), parameter :: pi64 = 4*atan(1._dp)
10
11 if (pi32 == pi64) error stop 'real32 values generally do not exactly equal real64 values'
12
13 call timestwo(a32)
14 call timestwo(a64)
15
16 contains
17
18 elemental subroutine timestwo(a)
19
20 class(*), intent(inout) :: a
21
22 select type (a)
23 type is (real(sp))
24 a = 2*a
25 type is (real(dp))
26 a = 2*a
27 type is (integer)
28 a = 2*a
29 class default
30 error stop 'requires real32, real64 or integer'
31 end select
32
33 end subroutine timestwo
34
35 end program