2 ! Tests the patch that implements F2003 automatic allocation and
3 ! reallocation of allocatable arrays on assignment. The tests
4 ! below were generated in the final stages of the development of
7 ! Contributed by Dominique Dhumieres <dominiq@lps.ens.fr>
8 ! and Tobias Burnus <burnus@gcc.gnu.org>
22 ! Check that the bounds are set correctly, when assigning
23 ! to an array that already has the correct shape.
25 real :: a(10) = 1, b(51:60) = 2
26 real, allocatable :: c(:), d(:)
28 if (lbound (c, 1) .ne. lbound(a, 1)) call abort
29 if (ubound (c, 1) .ne. ubound(a, 1)) call abort
31 if (lbound (c, 1) .ne. lbound(b, 1)) call abort
32 if (ubound (c, 1) .ne. ubound(b, 1)) call abort
34 if (lbound (d, 1) .ne. lbound(b, 1)) call abort
35 if (ubound (d, 1) .ne. ubound(b, 1)) call abort
37 if (lbound (d, 1) .ne. lbound(a, 1)) call abort
38 if (ubound (d, 1) .ne. ubound(a, 1)) call abort
42 ! Check that the bounds are set correctly, when making an
43 ! assignment with an implicit conversion. First with a
44 ! non-descriptor variable....
46 integer(4), allocatable :: a(:)
49 if (lbound (a, 1) .ne. lbound(b, 1)) call abort
50 if (ubound (a, 1) .ne. ubound(b, 1)) call abort
54 ! ...and now a descriptor variable.
56 integer(4), allocatable :: a(:)
57 integer(8), allocatable :: b(:)
60 if (lbound (a, 1) .ne. lbound(b, 1)) call abort
61 if (ubound (a, 1) .ne. ubound(b, 1)) call abort
65 ! Check assignments of the kind a = f(...)
67 integer, allocatable :: a(:)
68 integer, allocatable :: c(:)
70 if (any (a .ne. [1, 2, 3, 4])) call abort
73 if (any ((a - 8) .ne. [1, 2, 3, 4])) call abort
76 if (any ((a - 4) .ne. [1, 2, 3, 4])) call abort
79 integer, allocatable, optional :: b(:)
81 if (.not.present (b)) then
83 elseif (.not.allocated (b)) then
92 ! Extracted from rnflow.f90, Polyhedron benchmark suite,
93 ! http://www.polyhedron.com
95 integer, parameter :: ncls = 233, ival = 16, ipic = 17
96 real, allocatable, dimension (:,:) :: utrsft
97 real, allocatable, dimension (:,:) :: dtrsft
98 real, allocatable, dimension (:,:) :: xwrkt
99 allocate (utrsft(ncls, ncls), dtrsft(ncls, ncls))
101 xwrkt = trs2a2 (ival, ipic, ncls)
102 if (any (shape (xwrkt) .ne. [ncls, ncls])) call abort
103 xwrkt = invima (xwrkt, ival, ipic, ncls)
104 if (nglobal .ne. 1) call abort
105 if (sum(xwrkt) .ne. xwrkt(ival, ival)) call abort
107 function trs2a2 (j, k, m)
108 real, dimension (1:m,1:m) :: trs2a2
109 integer, intent (in) :: j, k, m
110 nglobal = nglobal + 1
113 function invima (a, j, k, m)
114 real, dimension (1:m,1:m) :: invima
115 real, dimension (1:m,1:m), intent (in) :: a
116 integer, intent (in) :: j, k
118 invima (j, j) = 1.0 / (1.0 - a (j, j))
121 character(kind=1, len=100), allocatable, dimension(:) :: str
123 if (TRIM(str(1)) .ne. "abc") call abort
124 if (len(str) .ne. 100) call abort
127 character(kind=4, len=100), allocatable, dimension(:) :: str
128 character(kind=4, len=3) :: test = "abc"
130 if (TRIM(str(1)) .ne. test) call abort
131 if (len(str) .ne. 100) call abort
135 integer, allocatable :: a(:)
139 if (any (x%a .ne. [1,2,3])) call abort
141 if (any (x%a .ne. [4])) call abort