1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
! { dg-do run }
!
! Test the behavior of lbound, ubound of shape with assumed rank arguments
! in an array context (without DIM argument).
!
program test
integer :: a(2:4,-2:5)
integer, allocatable :: b(:,:)
integer, pointer :: c(:,:)
character(52) :: buffer
call foo(a)
allocate(b(2:4,-2:5))
call foo(b)
call bar(b)
allocate(c(2:4,-2:5))
call foo(c)
call baz(c)
contains
subroutine foo(arg)
integer :: arg(..)
!print *, lbound(arg)
!print *, id(lbound(arg))
if (any(lbound(arg) /= [1, 1])) call abort
if (any(id(lbound(arg)) /= [1, 1])) call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) lbound(arg)
if (buffer /= ' 1 1') call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) id(lbound(arg))
if (buffer /= ' 1 1') call abort
!print *, ubound(arg)
!print *, id(ubound(arg))
if (any(ubound(arg) /= [3, 8])) call abort
if (any(id(ubound(arg)) /= [3, 8])) call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) ubound(arg)
if (buffer /= ' 3 8') call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) id(ubound(arg))
if (buffer /= ' 3 8') call abort
!print *, shape(arg)
!print *, id(shape(arg))
if (any(shape(arg) /= [3, 8])) call abort
if (any(id(shape(arg)) /= [3, 8])) call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) shape(arg)
if (buffer /= ' 3 8') call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) id(shape(arg))
if (buffer /= ' 3 8') call abort
end subroutine foo
subroutine bar(arg)
integer, allocatable :: arg(:,:)
!print *, lbound(arg)
!print *, id(lbound(arg))
if (any(lbound(arg) /= [2, -2])) call abort
if (any(id(lbound(arg)) /= [2, -2])) call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) lbound(arg)
if (buffer /= ' 2 -2') call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) id(lbound(arg))
if (buffer /= ' 2 -2') call abort
!print *, ubound(arg)
!print *, id(ubound(arg))
if (any(ubound(arg) /= [4, 5])) call abort
if (any(id(ubound(arg)) /= [4, 5])) call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) ubound(arg)
if (buffer /= ' 4 5') call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) id(ubound(arg))
if (buffer /= ' 4 5') call abort
!print *, shape(arg)
!print *, id(shape(arg))
if (any(shape(arg) /= [3, 8])) call abort
if (any(id(shape(arg)) /= [3, 8])) call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) shape(arg)
if (buffer /= ' 3 8') call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) id(shape(arg))
if (buffer /= ' 3 8') call abort
end subroutine bar
subroutine baz(arg)
integer, pointer :: arg(..)
!print *, lbound(arg)
!print *, id(lbound(arg))
if (any(lbound(arg) /= [2, -2])) call abort
if (any(id(lbound(arg)) /= [2, -2])) call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) lbound(arg)
if (buffer /= ' 2 -2') call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) id(lbound(arg))
if (buffer /= ' 2 -2') call abort
!print *, ubound(arg)
!print *, id(ubound(arg))
if (any(ubound(arg) /= [4, 5])) call abort
if (any(id(ubound(arg)) /= [4, 5])) call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) ubound(arg)
if (buffer /= ' 4 5') call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) id(ubound(arg))
if (buffer /= ' 4 5') call abort
!print *, shape(arg)
!print *, id(shape(arg))
if (any(shape(arg) /= [3, 8])) call abort
if (any(id(shape(arg)) /= [3, 8])) call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) shape(arg)
if (buffer /= ' 3 8') call abort
buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
write(buffer,*) id(shape(arg))
if (buffer /= ' 3 8') call abort
end subroutine baz
elemental function id(arg)
integer, intent(in) :: arg
integer :: id
id = arg
end function id
end program test
|