@@ -43,55 +43,87 @@ function results() result(test_results)
4343 function verify_block_partitioning () result(test_passes)
4444 ! ! Verify that the data is partitioned across images evenly to
4545 ! ! within a difference of one datum between any two images.
46- type (data_partition_t) partition
4746 logical test_passes
48- integer my_particles
4947
48+ #ifndef _CRAYFTN
5049 associate( me= >this_image(), partition = > data_partition_t(cardinality= num_particles))
5150 associate( my_first= >partition% first(me), my_last= >partition% last(me) )
52- my_particles = my_last - my_first + 1
53- associate( ni= >num_images() )
51+ associate( ni= >num_images(), my_particles = > my_last - my_first + 1 )
52+ associate( quotient= >num_particles/ ni, remainder= >mod (num_particles,ni) )
53+ test_passes = quotient + merge (1 , 0 , me<= remainder) == my_particles
54+ end associate
55+ end associate
56+ end associate
57+ end associate
58+ #else
59+ type (data_partition_t) partition
60+
61+ associate(me= >this_image())
62+ partition = data_partition_t(cardinality= num_particles)
63+ associate( my_first= >partition% first(me), my_last= >partition% last(me) )
64+ associate( ni= >num_images(), my_particles = > my_last - my_first + 1 )
5465 associate( quotient= >num_particles/ ni, remainder= >mod (num_particles,ni) )
5566 test_passes = quotient + merge (1 , 0 , me<= remainder) == my_particles
5667 end associate
5768 end associate
5869 end associate
5970 end associate
71+ #endif
6072
6173 end function
6274
6375 function verify_default_image_number () result(test_passes)
6476 ! ! Verify that the first and last functions assume image_number == this_image() if image_number is not present
65- type (data_partition_t) partition
6677 logical test_passes
6778
79+ #ifndef _CRAYFTN
6880 associate( me= >this_image(), partition = > data_partition_t(cardinality= num_particles))
6981 test_passes = partition% first() == partition% first(me) .and. partition% last() == partition% last(me)
7082 end associate
83+ #else
84+ type (data_partition_t) partition
85+
86+ partition = data_partition_t(cardinality= num_particles)
87+ associate( me= >this_image())
88+ test_passes = partition% first() == partition% first(me) .and. partition% last() == partition% last(me)
89+ end associate
90+ #endif
7191 end function
7292
7393 function verify_all_particles_partitioned () result(test_passes)
7494 ! ! Verify that the number of particles on each image sums to the
7595 ! ! total number of particles distributed.
76- type (data_partition_t) partition
7796 logical test_passes
7897 integer particles
7998
80- associate( me= >this_image(), partition = > data_partition_t(cardinality= num_particles))
81- associate( my_first= >partition% first(me), my_last= >partition% last(me) )
99+ #ifndef _CRAYFTN
100+ associate(me = > this_image(), partition = > data_partition_t(cardinality= num_particles))
101+ associate(my_first= >partition% first(me), my_last= >partition% last(me))
102+ particles = my_last - my_first + 1
103+ call co_sum(particles)
104+ test_passes = num_particles == particles
105+ end associate
106+ end associate
107+ #else
108+ type (data_partition_t) partition
109+
110+ partition = data_partition_t(cardinality= num_particles)
111+ associate(me= >this_image())
112+ associate(my_first= >partition% first(me), my_last= >partition% last(me))
82113 particles = my_last - my_first + 1
83114 call co_sum(particles)
84115 test_passes = num_particles == particles
85116 end associate
86117 end associate
118+ #endif
87119 end function
88120
89121 function verify_all_gather_1D_real_array () result(test_passes)
90- type (data_partition_t) partition
91122 logical test_passes
92123 real (real64) :: particle_scalar(num_particles)
93124 real (real64), parameter :: junk=- 12345._real64 , expected= 1._real64
94125
126+ #ifndef _CRAYFTN
95127 associate( me= >this_image(), partition = > data_partition_t(cardinality= num_particles))
96128 associate( first= >partition% first(me), last= >partition% last(me) )
97129 particle_scalar(first:last) = expected ! ! values to be gathered
@@ -101,56 +133,93 @@ function verify_all_gather_1D_real_array() result(test_passes)
101133 test_passes = all (particle_scalar== expected)
102134 end associate
103135 end associate
136+ #else
137+ type (data_partition_t) partition
138+
139+ associate( me= >this_image())
140+ partition = data_partition_t(cardinality= num_particles)
141+ associate( first= >partition% first(me), last= >partition% last(me) )
142+ particle_scalar(first:last) = expected ! ! values to be gathered
143+ particle_scalar(1 :first-1 ) = junk ! ! values to be overwritten by the gather
144+ particle_scalar(last+1 :) = junk ! ! values to be overwritten by the gather
145+ call partition% gather(particle_scalar)
146+ test_passes = all (particle_scalar== expected)
147+ end associate
148+ end associate
149+ #endif
104150 end function
105151
106152 function verify_all_gather_2D_real_array () result(test_passes)
107- type (data_partition_t) partition
108153 logical test_passes
109154 integer , parameter :: vec_space_dim= 3
110155 real (real64) particle_vector(vec_space_dim, num_particles)
111156 real (real64), parameter :: junk=- 12345._real64 , expected= 1._real64
112157
158+ #ifndef _CRAYFTN
113159 associate( me= >this_image(), partition = > data_partition_t(cardinality= num_particles))
114160 associate( first= >partition% first(me), last= >partition% last(me) )
161+ particle_vector(:, first:last) = expected ! ! values to be gathered
162+ particle_vector(:, 1 :first-1 ) = junk ! ! values to be overwritten by the gather
163+ particle_vector(:, last+1 :) = junk ! ! values to be overwritten by the gather
164+ call partition% gather(particle_vector)
165+ test_passes = all (particle_vector== expected)
166+ end associate
167+ end associate
168+ #else
169+ type (data_partition_t) partition
115170
171+ associate( me= >this_image())
172+ partition = data_partition_t(cardinality= num_particles)
173+ associate( first= >partition% first(me), last= >partition% last(me) )
116174 particle_vector(:, first:last) = expected ! ! values to be gathered
117175 particle_vector(:, 1 :first-1 ) = junk ! ! values to be overwritten by the gather
118176 particle_vector(:, last+1 :) = junk ! ! values to be overwritten by the gather
119177 call partition% gather(particle_vector)
120178 test_passes = all (particle_vector== expected)
121179 end associate
122180 end associate
181+ #endif
123182 end function
124183
125184 function verify_all_gather_2D_real_array_dim1 () result(test_passes)
126- type (data_partition_t) partition
127185 logical test_passes
128186 integer , parameter :: vec_space_dim= 3
129187 real (real64) :: vector_transpose(num_particles, vec_space_dim)
130188 real (real64), parameter :: junk=- 12345._real64 , expected= 1._real64
131189
190+ #ifndef _CRAYFTN
132191 associate( me= >this_image(), partition = > data_partition_t(cardinality= num_particles))
133192 associate( first= >partition% first(me), last= >partition% last(me) )
134-
135193 vector_transpose(first:last, :) = expected ! ! values to be gathered
136194 vector_transpose(1 :first-1 , :) = junk ! ! values to be overwritten by the gather
137195 vector_transpose(last+1 :, :) = junk ! ! values to be overwritten by the gather
138-
139196 call partition% gather( vector_transpose, dim= 1 )
140-
141197 test_passes= all (vector_transpose== expected)
198+ end associate
199+ end associate
200+ #else
201+ type (data_partition_t) partition
142202
203+ associate(me= >this_image())
204+ partition = data_partition_t(cardinality= num_particles)
205+ associate( first= >partition% first(me), last= >partition% last(me) )
206+ vector_transpose(first:last, :) = expected ! ! values to be gathered
207+ vector_transpose(1 :first-1 , :) = junk ! ! values to be overwritten by the gather
208+ vector_transpose(last+1 :, :) = junk ! ! values to be overwritten by the gather
209+ call partition% gather( vector_transpose, dim= 1 )
210+ test_passes= all (vector_transpose== expected)
143211 end associate
144212 end associate
213+ #endif
145214 end function
146215
147216 function verify_gather_2D_real_array_dim1 () result(test_passes)
148- type (data_partition_t) partition
149217 logical test_passes
150218 integer , parameter :: vec_space_dim= 3
151219 real (real64) :: vector_transpose(num_particles, vec_space_dim)
152220 real (real64), parameter :: junk=- 12345._real64 , expected= 1._real64
153221
222+ #ifndef _CRAYFTN
154223 associate( me= >this_image(), partition = > data_partition_t(cardinality= num_particles))
155224 associate( first= >partition% first(me), last= >partition% last(me) )
156225
@@ -171,6 +240,31 @@ function verify_gather_2D_real_array_dim1() result(test_passes)
171240
172241 end associate
173242 end associate
243+ #else
244+ type (data_partition_t) partition
245+
246+ associate(me= >this_image())
247+ partition = data_partition_t(cardinality= num_particles)
248+ associate( first= >partition% first(me), last= >partition% last(me) )
249+
250+ vector_transpose(first:last, :) = expected ! ! values to be gathered
251+ vector_transpose(1 :first-1 , :) = junk ! ! values to be overwritten by the gather
252+ vector_transpose(last+1 :, :) = junk ! ! values to be overwritten by the gather
253+
254+ call partition% gather( vector_transpose, result_image= gatherer, dim= 1 )
255+
256+ if (me== gatherer) then
257+ test_passes = all (vector_transpose== expected)
258+ else
259+ test_passes = &
260+ all (vector_transpose(1 :first-1 ,:)==junk) .and. &
261+ all (vector_transpose(first:last,:)==expected) .and. &
262+ all (vector_transpose(last+1 :,:)==junk)
263+ end if
264+
265+ end associate
266+ end associate
267+ #endif
174268 end function
175269
176270end module data_partition_test_m
0 commit comments