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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
! { dg-do run }
!
! PR fortran/95331
!
program main_p
implicit none
integer, parameter :: n = 10
integer, parameter :: m = 5
integer, parameter :: b = 3
integer, parameter :: t = n+b-1
integer, parameter :: l = 4
integer, parameter :: u = 7
integer, parameter :: s = 3
integer, parameter :: e = (u-l)/s+1
call test_f()
call test_s()
call test_p()
call test_a()
stop
contains
subroutine test_f()
integer :: x(n,n)
integer :: y(b:t)
integer :: i
x = reshape([(i, i=1,n*n)], [n,n])
y = x(:,m)
call sub_s(x(:,m), y, n)
call sub_s(y, x(:,m), n)
return
end subroutine test_f
subroutine test_s()
integer :: x(n,n)
integer :: v(e)
integer :: i
x = reshape([(i, i=1,n*n)], [n,n])
v = x(l:u:s,m)
call sub_s(v, v, e)
call sub_s(x(l:u:s,m), v, e)
call sub_s(v, x(l:u:s,m), e)
return
end subroutine test_s
subroutine test_p()
integer, target :: x(n,n)
integer, pointer :: p(:)
integer :: v(e)
integer :: i
x = reshape([(i, i=1,n*n)], [n,n])
v = x(l:u:s,m)
p => x(:,m)
call sub_s(p(l:u:s), v, e)
p => x(l:u:s,m)
call sub_s(p, v, e)
p(l:) => x(l:u:s,m)
call sub_s(p, v, e)
p(l:l+e-1) => x(l:u:s,m)
call sub_s(p, v, e)
allocate(p(n))
p(:) = x(:,m)
call sub_s(p(l:u:s), v, e)
deallocate(p)
allocate(p(e))
p(:) = x(l:u:s,m)
call sub_s(p, v, e)
deallocate(p)
allocate(p(l:l+e-1))
p(:) = x(l:u:s,m)
call sub_s(p, v, e)
deallocate(p)
allocate(p(l:l+e-1))
p(l:) = x(l:u:s,m)
call sub_s(p, v, e)
deallocate(p)
allocate(p(l:l+e-1))
p(l:l+e-1) = x(l:u:s,m)
call sub_s(p, v, e)
deallocate(p)
return
end subroutine test_p
subroutine test_a()
integer :: x(n,n)
integer, allocatable :: a(:)
integer :: v(e)
integer :: i
x = reshape([(i, i=1,n*n)], [n,n])
v = x(l:u:s,m)
a = x(:,m)
call sub_s(a(l:u:s), v, e)
deallocate(a)
allocate(a(n))
a(:) = x(:,m)
call sub_s(a(l:u:s), v, e)
deallocate(a)
a = x(l:u:s,m)
call sub_s(a, v, e)
deallocate(a)
allocate(a(e))
a(:) = x(l:u:s,m)
call sub_s(a, v, e)
deallocate(a)
allocate(a(l:l+e-1))
a(:) = x(l:u:s,m)
call sub_s(a, v, e)
deallocate(a)
allocate(a(l:l+e-1))
a(l:) = x(l:u:s,m)
call sub_s(a, v, e)
deallocate(a)
allocate(a(l:l+e-1))
a(l:l+e-1) = x(l:u:s,m)
call sub_s(a, v, e)
deallocate(a)
return
end subroutine test_a
subroutine sub_s(a, b, n)
class(*), intent(in) :: a(:)
integer, intent(in) :: b(:)
integer, intent(in) :: n
integer :: i
if(lbound(a, dim=1)/=1) stop 1001
if(ubound(a, dim=1)/=n) stop 1002
if(any(shape(a)/=[n])) stop 1003
if(size(a, dim=1)/=n) stop 1004
if(size(a)/=size(b)) stop 1005
do i = 1, n
call vrfy(a(i), b(i))
end do
return
end subroutine sub_s
subroutine vrfy(a, b)
class(*), intent(in) :: a
integer, intent(in) :: b
select type (a)
type is (integer)
!print *, a, b
if(a/=b) stop 2001
class default
STOP 2002
end select
return
end subroutine vrfy
end program main_p
|