File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Expand file tree Collapse file tree 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)
2828 pure module function first(image_number) result(first_index)
2929 ! ! the result is the first identification number owned by the executing image
3030 implicit none
31- integer , intent (in ) :: image_number
31+ integer , intent (in ), optional :: image_number
3232 integer first_index
3333 end function
3434
3535 pure module function last(image_number) result(last_index)
3636 ! ! the result is the last identification number owned by the executing image
3737 implicit none
38- integer , intent (in ) :: image_number
38+ integer , intent (in ), optional :: image_number
3939 integer last_index
4040 end function
4141
Original file line number Diff line number Diff line change 1414 end procedure
1515
1616 module procedure first
17+ integer image
18+
1719 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()
1927 end procedure
2028
2129 module procedure last
30+ integer image
31+
2232 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()
2440 end procedure
2541
2642 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)
3232 associate( my_first= >partition% first(me), my_last= >partition% last(me) )
3333 test_results = [ &
3434 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()), &
3536 test_result_t(" partitioning all data across all images without data loss" , verify_all_particles_partitioned()), &
3637 test_result_t(" gathering a 1D real array onto all images" , verify_all_gather_1D_real_array()), &
3738 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)
6465 end associate
6566 end function
6667
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+
6778 function verify_all_particles_partitioned () result(test_passes)
6879 ! ! Verify that the number of particles on each image sums to the
6980 ! ! total number of particles distributed.
You can’t perform that action at this time.
0 commit comments