File tree 3 files changed +31
-4
lines changed
3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -28,14 +28,14 @@ module subroutine define_partitions(cardinality)
28
28
pure module function first(image_number) result(first_index)
29
29
! ! the result is the first identification number owned by the executing image
30
30
implicit none
31
- integer , intent (in ) :: image_number
31
+ integer , intent (in ), optional :: image_number
32
32
integer first_index
33
33
end function
34
34
35
35
pure module function last(image_number) result(last_index)
36
36
! ! the result is the last identification number owned by the executing image
37
37
implicit none
38
- integer , intent (in ) :: image_number
38
+ integer , intent (in ), optional :: image_number
39
39
integer last_index
40
40
end function
41
41
Original file line number Diff line number Diff line change 14
14
end procedure
15
15
16
16
module procedure first
17
+ integer image
18
+
17
19
call assert( allocated (bin), " data_partition_s(first): allocated(bin)" )
18
- first_index = bin(image_number)% first()
20
+
21
+ if (present (image_number)) then
22
+ image = image_number
23
+ else
24
+ image = this_image()
25
+ end if
26
+ first_index = bin(image)% first()
19
27
end procedure
20
28
21
29
module procedure last
30
+ integer image
31
+
22
32
call assert( allocated (bin), " data_partition_s(last): allocated(bin)" )
23
- last_index = bin(image_number)% last()
33
+
34
+ if (present (image_number)) then
35
+ image = image_number
36
+ else
37
+ image = this_image()
38
+ end if
39
+ last_index = bin(image)% last()
24
40
end procedure
25
41
26
42
module procedure gather_real32_1D_array
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ function results() result(test_results)
32
32
associate( my_first= >partition% first(me), my_last= >partition% last(me) )
33
33
test_results = [ &
34
34
test_result_t(" partitioning data in nearly even blocks" , verify_block_partitioning()), &
35
+ test_result_t(" default image_number is this_image()" , verify_default_image_number()), &
35
36
test_result_t(" partitioning all data across all images without data loss" , verify_all_particles_partitioned()), &
36
37
test_result_t(" gathering a 1D real array onto all images" , verify_all_gather_1D_real_array()), &
37
38
test_result_t(" gathering dimension 1 of 2D real array onto all images witout dim argument" , &
@@ -64,6 +65,16 @@ function verify_block_partitioning() result(test_passes)
64
65
end associate
65
66
end function
66
67
68
+ function verify_default_image_number () result(test_passes)
69
+ ! ! Verify that the first and last functions assume image_number == this_image() if image_number is not present
70
+ type (data_partition_t) partition
71
+ logical test_passes
72
+
73
+ associate( me= >this_image() )
74
+ test_passes = partition% first() == partition% first(me) .and. partition% last() == partition% last(me)
75
+ end associate
76
+ end function
77
+
67
78
function verify_all_particles_partitioned () result(test_passes)
68
79
! ! Verify that the number of particles on each image sums to the
69
80
! ! total number of particles distributed.
You can’t perform that action at this time.
0 commit comments