8 integer, allocatable
:: a
9 integer, allocatable
:: b
12 if(.not
. allocated(a
)) call abort()
13 if (a
/= 5) call abort()
16 if (a
/= 7) call abort()
19 if(allocated(a
)) call abort()
21 if(.not
. allocated(a
)) call abort()
22 if(a
/= 6874) call abort()
24 if(.not
. allocated(a
)) call abort()
25 if(a
/= -478) call abort()
29 call checkOptional(.false
.,.true
., 7482)
30 if (b
/= 7482) call abort()
31 call checkOptional(.true
., .true
., 7482, b
)
32 if (b
/= 46) call abort()
35 integer, allocatable
, intent(out
) :: a
36 if(allocated(a
)) call abort()
42 integer, allocatable
, intent(inout
) :: a
43 if(.not
. allocated(a
)) call abort()
44 if (a
/= 5) call abort()
49 integer, allocatable
, intent(inout
) :: a
50 if(allocated(a
)) call abort()
56 integer, allocatable
, intent(inout
) :: a
57 if(.not
.allocated(a
)) call abort()
58 if (a
/= 6874) call abort
60 if(allocated(a
)) call abort()
62 if(.not
.allocated(a
)) call abort()
66 subroutine checkOptional(prsnt
, alloc
, val
, x
)
67 logical, intent(in
) :: prsnt
, alloc
68 integer, allocatable
, optional
:: x
69 integer, intent(in
) :: val
70 if (present(x
) .neqv
. prsnt
) call abort()
72 if (allocated(x
) .neqv
. alloc
) call abort()
75 if (allocated(x
)) then
76 if (x
/= val
) call abort()
79 call checkOptional2(x
)
81 if (.not
. allocated(x
)) call abort()
82 if (x
/= -6784) call abort()
86 end subroutine checkOptional
87 subroutine checkOptional2(x
)
88 integer, allocatable
, optional
, intent(out
) :: x
90 if (allocated(x
)) call abort()
94 end subroutine checkOptional2