5 ! Test VALUE + OPTIONAL
6 ! for integer/real/complex/logical which are passed by value
12 subroutine value_test (ii
, rr
, cc
, ll
, ii2
, rr2
, cc2
, ll2
)
13 integer, optional
:: ii
, ii2
14 real, optional
:: rr
, rr2
15 complex, optional
:: cc
, cc2
16 logical, optional
:: ll
, ll2
17 value
:: ii
, rr
, cc
, ll
19 call int_test (.false
., 0)
20 call int_test (.false
., 0, ii
)
21 call int_test (.false
., 0, ii2
)
22 call int_test (.true
., 0, 0)
23 call int_test (.true
., 2, 2)
25 call real_test (.false
., 0.0)
26 call real_test (.false
., 0.0, rr
)
27 call real_test (.false
., 0.0, rr2
)
28 call real_test (.true
., 0.0, 0.0)
29 call real_test (.true
., 2.0, 2.0)
31 call cmplx_test (.false
., cmplx (0.0))
32 call cmplx_test (.false
., cmplx (0.0), cc
)
33 call cmplx_test (.false
., cmplx (0.0), cc2
)
34 call cmplx_test (.true
., cmplx (0.0), cmplx (0.0))
35 call cmplx_test (.true
., cmplx (2.0), cmplx (2.0))
37 call bool_test (.false
., .false
.)
38 call bool_test (.false
., .false
., ll
)
39 call bool_test (.false
., .false
., ll2
)
40 call bool_test (.true
., .false
., .false
.)
41 call bool_test (.true
., .true
., .true
.)
42 end subroutine value_test
44 subroutine int_test (ll
, val
, x
)
47 integer, value
, optional
:: x
48 if (ll
.neqv
. present(x
)) STOP 1
52 end subroutine int_test
54 subroutine real_test (ll
, val
, x
)
57 real, value
, optional
:: x
58 if (ll
.neqv
. present(x
)) STOP 2
62 end subroutine real_test
64 subroutine cmplx_test (ll
, val
, x
)
67 complex, value
, optional
:: x
68 if (ll
.neqv
. present(x
)) STOP 3
72 end subroutine cmplx_test
74 subroutine bool_test (ll
, val
, x
)
77 logical, value
, optional
:: x
78 if (ll
.neqv
. present(x
)) STOP 4
80 if (x
.neqv
. val
) STOP 4
82 end subroutine bool_test