1313
1414 associate( ni = > num_images() )
1515
16- call assert( ni<= cardinality, " sufficient data for distribution across images" )
16+ call assert( ni<= cardinality, " sufficient data for distribution across images" , cardinality )
1717
1818 allocate (first_datum(ni), last_datum(ni))
1919
@@ -54,7 +54,39 @@ pure function overflow(im, excess) result(extra_datum)
5454 last_index = last_datum( image_number )
5555 end procedure
5656
57- module procedure gather_real_1D_array
57+ module procedure gather_real32_1D_array
58+
59+ if (present (dim)) call assert (dim== 1 , " dimensioned partitioned == 1" )
60+
61+ associate( me = > this_image() )
62+ if (verbose) then
63+ write (6 ,* ) ' gather_real_1D_array(): executing on image' , me
64+ flush(6 )
65+ end if
66+ associate( first= >first(me), last= >last(me) )
67+ if (.not. present (result_image)) then
68+ a(1 :first-1 ) = 0 .
69+ a(last+1 :) = 0 .
70+ call co_sum(a)
71+ else
72+ block
73+ real (real32), allocatable , dimension (:) :: a_lower, a_upper
74+ a_lower = a(1 :first-1 )
75+ a_upper = a(last+1 :)
76+ a(1 :first-1 ) = 0 .
77+ a(last+1 :) = 0 .
78+ call co_sum(a, result_image= result_image)
79+ if (result_image /= me) then
80+ a(1 :first-1 ) = a_lower
81+ a(last+1 :) = a_upper
82+ end if
83+ end block
84+ end if
85+ end associate
86+ end associate
87+ end procedure
88+
89+ module procedure gather_real64_1D_array
5890
5991 if (present (dim)) call assert (dim== 1 , " dimensioned partitioned == 1" )
6092
@@ -86,7 +118,72 @@ pure function overflow(im, excess) result(extra_datum)
86118 end associate
87119 end procedure
88120
89- module procedure gather_real_2D_array
121+ module procedure gather_real32_2D_array
122+
123+ integer dim_
124+ if (present (dim)) then
125+ dim_ = dim
126+ else
127+ dim_ = 2
128+ end if
129+
130+ associate( me = > this_image() )
131+ if (verbose) then
132+ write (6 ,* ) ' gather_real32_2D_array(): executing on image' , me
133+ flush(6 )
134+ end if
135+ associate( first = > first(me), last = > last(me) )
136+ if (.not. present (result_image)) then
137+ select case (dim_)
138+ case (1 )
139+ a(1 :first-1 , :) = 0 .
140+ a(last+1 :, :) = 0 .
141+ case (2 )
142+ a(:, 1 :first-1 ) = 0 .
143+ a(:, last+1 :) = 0 .
144+ case default
145+ error stop " gather_real32_2D_array: invalid dim argument"
146+ end select
147+ call co_sum(a)
148+ else
149+ block
150+ real (real32), allocatable , dimension (:,:) :: a_lower, a_upper
151+ select case (dim_)
152+ case (1 )
153+ a_lower = a(1 :first-1 , :)
154+ a_upper = a(last+1 :, :)
155+ a(1 :first-1 , :) = 0 .
156+ a(last+1 :, :) = 0 .
157+ case (2 )
158+ a_lower = a(:, 1 :first-1 )
159+ a_upper = a(:, last+1 :)
160+ a(:, 1 :first-1 ) = 0 .
161+ a(:, last+1 :) = 0 .
162+ case default
163+ error stop " gather_real32_2D_array: invalid dim argument"
164+ end select
165+
166+ call co_sum(a, result_image= result_image)
167+
168+ if (result_image /= me) then
169+ select case (dim_)
170+ case (1 )
171+ a(1 :first-1 , :) = a_lower
172+ a(last+1 :, :) = a_upper
173+ case (2 )
174+ a(:, 1 :first-1 ) = a_lower
175+ a(:, last+1 :) = a_upper
176+ case default
177+ error stop " gather_real32_2D_array: invalid dim argument"
178+ end select
179+ end if
180+ end block
181+ end if
182+ end associate
183+ end associate
184+ end procedure
185+
186+ module procedure gather_real64_2D_array
90187
91188 integer dim_
92189 if (present (dim)) then
@@ -97,7 +194,7 @@ pure function overflow(im, excess) result(extra_datum)
97194
98195 associate( me = > this_image() )
99196 if (verbose) then
100- write (6 ,* ) ' gather_real_2D_array (): executing on image' , me
197+ write (6 ,* ) ' gather_real64_2D_array (): executing on image' , me
101198 flush(6 )
102199 end if
103200 associate( first = > first(me), last = > last(me) )
@@ -110,7 +207,7 @@ pure function overflow(im, excess) result(extra_datum)
110207 a(:, 1 :first-1 ) = 0 .
111208 a(:, last+1 :) = 0 .
112209 case default
113- error stop " gather_real_2D_array : invalid dim argument"
210+ error stop " gather_real64_2D_array : invalid dim argument"
114211 end select
115212 call co_sum(a)
116213 else
@@ -128,7 +225,7 @@ pure function overflow(im, excess) result(extra_datum)
128225 a(:, 1 :first-1 ) = 0 .
129226 a(:, last+1 :) = 0 .
130227 case default
131- error stop " gather_real_2D_array : invalid dim argument"
228+ error stop " gather_real64_2D_array : invalid dim argument"
132229 end select
133230
134231 call co_sum(a, result_image= result_image)
@@ -142,7 +239,7 @@ pure function overflow(im, excess) result(extra_datum)
142239 a(:, 1 :first-1 ) = a_lower
143240 a(:, last+1 :) = a_upper
144241 case default
145- error stop " gather_real_2D_array : invalid dim argument"
242+ error stop " gather_real64_2D_array : invalid dim argument"
146243 end select
147244 end if
148245 end block
0 commit comments