Skip to content

Commit 1411741

Browse files
committed
Adding Robert's test case
1 parent aed2b81 commit 1411741

File tree

1 file changed

+195
-0
lines changed

1 file changed

+195
-0
lines changed
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
Program test
2+
! Test created by Robert C. Singleterry <[email protected]>
3+
!
4+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5+
! Test program to CO_BROADCAST two user defined types
6+
! 1) Allocatable, dimensioned user type
7+
! 2) Scalre user type
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
!
10+
Implicit None
11+
!
12+
Integer ,Parameter :: C1 = 1, C2 = 2
13+
Integer :: i, j, k, N0, me, number_images
14+
!
15+
Type L2_Data
16+
Integer :: N2
17+
Integer ,Allocatable ,Dimension(:) :: A2
18+
End Type L2_Data
19+
!
20+
Type L1_Data
21+
Integer :: N1
22+
Integer ,Allocatable ,Dimension(:) :: B1
23+
Type ( L2_Data ) ,Allocatable ,Dimension(:) :: L2
24+
End Type L1_Data
25+
!
26+
Type L_Data
27+
Integer :: N0
28+
Type ( L1_Data ) ,Allocatable ,Dimension(:) :: L1
29+
End type L_Data
30+
!
31+
Type ( L1_Data ) ,Allocatable ,Dimension(:) :: L1
32+
Type ( L_Data ) :: L
33+
!
34+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35+
! Setting image data
36+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37+
!
38+
number_images = num_images()
39+
me = this_image()
40+
!
41+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42+
! Setting L1 Data
43+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
44+
!
45+
If ( me .eq. C1 ) Then
46+
Write (*,*) 'L1 Data on image ', me
47+
N0 = 2
48+
Allocate ( L1(N0) )
49+
Write (*,*) 'L1: i,j,k,N = ', -1, -1, -1, N0, ' = ', 2
50+
Do i = 1, N0
51+
L1(i)%N1 = 3
52+
Write (*,*) 'L1: i,j,k,N = ', i, -1, -1, L1(i)%N1, ' = ', 3
53+
Allocate ( L1(i)%B1(L1(i)%N1) )
54+
Do j = 1, L1(i)%N1
55+
L1(i)%B1(j) = j
56+
Write (*,*) 'L1: i,j,k,B = ', i, j, -1, L1(i)%B1(j), ' = ', j
57+
End Do
58+
Allocate ( L1(i)%L2(L1(i)%N1) )
59+
Do j = 1, L1(i)%N1
60+
L1(i)%L2(j)%N2 = 4
61+
Write (*,*) 'L1: i,j,k,N = ', i, j, -1, L1(i)%L2(j)%N2, ' = ', 4
62+
Allocate ( L1(i)%L2(j)%A2(L1(i)%L2(j)%N2) )
63+
Do k = 1, L1(i)%L2(j)%N2
64+
L1(i)%L2(j)%A2(k) = 10*k
65+
Write (*,*) 'L1: i,j,k,A = ', i, j, k, L1(i)%L2(j)%A2(k), ' = ', 10*k
66+
End Do
67+
End Do
68+
End Do
69+
Write (*,*) 'Calling CO_BROADCAST for L1 Data'
70+
End If
71+
!
72+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
73+
! Setting L Data
74+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
75+
!
76+
If ( me .eq. C2 ) Then
77+
Write (*,*) 'L Data on image ', me
78+
L%N0 = 2
79+
Allocate ( L%L1(L%N0) )
80+
Write (*,*) 'L: i,j,k,N = ', -1, -1, -1, L%N0, ' = ', 2
81+
Do i = 1, L%N0
82+
L%L1(i)%N1 = 3
83+
Write (*,*) 'L: i,j,k,N = ', i, -1, -1, L%L1(i)%N1, ' = ', 3
84+
Allocate ( L%L1(i)%B1(L%L1(i)%N1) )
85+
Do j = 1, L%L1(i)%N1
86+
L%L1(i)%B1(j) = 10*j
87+
Write (*,*) 'L: i,j,k,B = ', i, j, -1, L%L1(i)%B1(j), ' = ', 10*j
88+
End Do
89+
Allocate ( L%L1(i)%L2(L%L1(i)%N1) )
90+
Do j = 1, L%L1(i)%N1
91+
L%L1(i)%L2(j)%N2 = 4
92+
Write (*,*) 'L: i,j,k,N = ', i, j, -1, L%L1(i)%L2(j)%N2, ' = ', 4
93+
Allocate ( L%L1(i)%L2(j)%A2(L%L1(i)%L2(j)%N2) )
94+
Do k = 1, L%L1(i)%L2(j)%N2
95+
L%L1(i)%L2(j)%A2(k) = 100*k
96+
Write (*,*) 'L: i,j,k,A = ', i, j, k, L%L1(i)%L2(j)%A2(k), ' = ', 100*k
97+
End Do
98+
End Do
99+
End Do
100+
Write (*,*) 'Calling CO_BROADCAST for L Data'
101+
End If
102+
!
103+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
104+
! CO_BROADCASTing L1 Data
105+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
106+
!
107+
Call CO_BROADCAST ( N0, C1 )
108+
If ( me .ne. C1 ) Then
109+
Allocate ( L1(N0) )
110+
End If
111+
Do i = 1, N0
112+
Call CO_BROADCAST ( L1(i)%N1, C1 )
113+
If ( me .ne. C1 ) Then
114+
Allocate ( L1(i)%B1(L1(i)%N1) )
115+
Allocate ( L1(i)%L2(L1(i)%N1) )
116+
End If
117+
Do j = 1, L1(i)%N1
118+
Call CO_BROADCAST ( L1(i)%L2(j)%N2, C1 )
119+
If ( me .ne. C1 ) Then
120+
Allocate ( L1(i)%L2(j)%A2(L1(i)%L2(j)%N2) )
121+
End If
122+
End Do
123+
End Do
124+
Call CO_BROADCAST ( L1, C1 )
125+
!
126+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
127+
! CO_BROADCASTing L Data
128+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
129+
!
130+
Call CO_BROADCAST ( L%N0, C2 )
131+
If ( me .ne. C2 ) Then
132+
Allocate ( L%L1(L%N0) )
133+
End If
134+
Do i = 1, L%N0
135+
Call CO_BROADCAST ( L%L1(i)%N1, C2 )
136+
If ( me .ne. C2 ) Then
137+
Allocate ( L%L1(i)%B1(L%L1(i)%N1) )
138+
Allocate ( L%L1(i)%L2(L%L1(i)%N1) )
139+
End If
140+
Do j = 1, L%L1(i)%N1
141+
Call CO_BROADCAST ( L%L1(i)%L2(j)%N2, C2 )
142+
If ( me .ne. C2 ) Then
143+
Allocate ( L%L1(i)%L2(j)%A2(L%L1(i)%L2(j)%N2) )
144+
End If
145+
End Do
146+
End Do
147+
Call CO_BROADCAST ( L, C2 )
148+
!
149+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
150+
! Writting L1 Data
151+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
152+
!
153+
If ( me .ne. C1 ) Then
154+
Write (*,*) 'L1 Data on image ', me
155+
Write (*,*) 'L1: i,j,k,N = ', -1, -1, -1, N0, ' = ', 2
156+
Do i = 1, N0
157+
Write (*,*) 'L1: i,j,k,N = ', i, -1, -1, L1(i)%N1, ' = ', 3
158+
Do j = 1, L1(i)%N1
159+
Write (*,*) 'L1: i,j,k,B = ', i, j, -1, L1(i)%B1(j), ' = ', j
160+
End Do
161+
Do j = 1, L1(i)%N1
162+
Write (*,*) 'L1: i,j,k,N = ', i, j, -1, L1(i)%L2(j)%N2, ' = ', 4
163+
Do k = 1, L1(i)%L2(j)%N2
164+
Write (*,*) 'L1: i,j,k,A = ', i, j, k, L1(i)%L2(j)%A2(k), ' = ', 10*k
165+
End Do
166+
End Do
167+
End Do
168+
End If
169+
!
170+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
171+
! Writting L Data
172+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
173+
!
174+
If ( me .ne. C2 ) Then
175+
Write (*,*) 'L Data on image ', me
176+
Write (*,*) 'L: i,j,k,N = ', -1, -1, -1, L%N0, ' = ', 2
177+
Do i = 1, L%N0
178+
Write (*,*) 'L: i,j,k,N = ', i, -1, -1, L%L1(i)%N1, ' = ', 3 ! Program dying here, L%L1(1)%N1 is not allocated? See line 131 (allocate) and line 134 (broadcast)
179+
Do j = 1, L%L1(i)%N1
180+
Write (*,*) 'L: i,j,k,B = ', i, j, -1, L%L1(i)%B1(j), ' = ', 10*j
181+
End Do
182+
Do j = 1, L%L1(i)%N1
183+
Write (*,*) 'L: i,j,k,N = ', i, j, -1, L%L1(i)%L2(j)%N2, ' = ', 4
184+
Do k = 1, L%L1(i)%L2(j)%N2
185+
Write (*,*) 'L: i,j,k,A = ', i, j, k, L%L1(i)%L2(j)%A2(k), ' = ', 100*k
186+
End Do
187+
End Do
188+
End Do
189+
End If
190+
!
191+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
192+
! End of program
193+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
194+
!
195+
End Program test

0 commit comments

Comments
 (0)