4 ! Test VALUE + OPTIONAL for integer/real/...
5 ! in the presence of non-optional character dummies
15 call test4 (w
='123',x
=42)
19 function testoptional (w
, x
) result(t
)
20 character, intent(in
) :: w
21 integer, intent(in
), value
, optional
:: x
23 print *, 'present(x) is', present(x
)
25 if (present (x
)) stop 1
26 end function testoptional
28 subroutine test2 (w
, x
)
29 character, intent(in
) :: w
30 integer, intent(in
), value
, optional
:: x
31 print*, 'present(x) is', present(x
)
32 if (present (x
)) stop 2
35 subroutine test3 (w
, x
)
36 character, intent(in
), optional
:: w
37 integer, intent(in
), value
, optional
:: x
38 print *, 'present(w) is', present(w
)
39 print *, 'present(x) is', present(x
)
40 if (.not
. present (w
)) stop 3
41 if (present (x
)) stop 4
44 subroutine test4 (r
, w
, x
)
45 real, value
, optional
:: r
46 character(*), intent(in
), optional
:: w
47 integer, value
, optional
:: x
48 print *, 'present(r) is', present(r
)
49 print *, 'present(w) is', present(w
)
50 print *, 'present(x) is', present(x
)
51 if (present (r
)) stop 5
52 if (.not
. present (w
)) stop 6
53 if (.not
. present (x
)) stop 7
55 print *, 'len(w)=', len(w
)
56 if (len(w
) /= 3) stop 8