Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28446 Discussions

coarray /= coarray[this_image()] for coarrays allocated inside teams

th_fort
Beginner
666 Views

I am having problems when trying to access an allocatable coarray that was allocated while inside a team block. Specifically, when trying to access a value at image n in the same team by 'coarray[n]', it gives the value from another image or results in an illegal coindex error. Furthermore, coarray == coarray[this_image()] is not always true for such coarrays. So far, this problem only occured on images whose coindex inside the team is different from their original coindex.

Below is a minimal working example - images on team 1, whose coindex is identical to their original coindex, give the expected result of coarray == coarray[this_image()] being true, while the same statement results in an illegal coindex error for team 2.

program team_coindex_debug
    
use iso_fortran_env, only: input_unit, output_unit, error_unit, team_type

integer, parameter :: team_1 = 1
integer, parameter :: team_2 = 2
type(team_type) :: main_team
integer :: team_num
integer, allocatable :: team_coarray[:]

if(this_image() <= num_images()/2) then
    team_num = team_1
else
    team_num = team_2
end if
form team(team_num, main_team)
    
change team(main_team)
    allocate(team_coarray[*])
    team_coarray = this_image()
    write (*, '(a)', advance = 'no') 'Team '
    write (*, '(i0)', advance = 'no') team_number()
    write (*, '(a)', advance = 'no') ', image '
    write (*, '(i0)', advance = 'no') this_image()
    write (*, '(a)', advance = 'no') ': team_coarray == team_coarray[this_image()] = '
    write (*, '(l)', advance = 'yes') team_coarray == team_coarray[this_image()]
end team

end program team_coindex_debug

I have also attached the output from the above program on my machine, compiled using ifort 2021.5.0 Build 20211109_000000 on an Intel Core i9-9900k running Windows 10 (10.0.19044) with the following options:

/nologo /debug:full /Od /Qcoarray:shared /Qcoarray-config-file:"mpi_config.txt" /Qcoarray-num-images:8 /warn:interfaces /module:"x64\Debug\\" /object:"x64\Debug\\" /Fd"x64\Debug\vc160.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c

 The mpi configuration file, mpi_config.txt:

-genvall -genv I_MPI_DEBUG=5 -genv I_MPI_FABRICS=shm -genv I_MPI_SILENT_ABORT=0 -genv I_MPI_FAULT_CONTINUE=0 C:\path\to\executable.exe

Using that configuration, I would expect the following output from the program:

 

Team 1, image 1: team_coarray == team_coarray[this_image()] =  T
Team 1, image 2: team_coarray == team_coarray[this_image()] =  T
Team 1, image 3: team_coarray == team_coarray[this_image()] =  T
Team 1, image 4: team_coarray == team_coarray[this_image()] =  T
Team 2, image 1: team_coarray == team_coarray[this_image()] =  T
Team 2, image 2: team_coarray == team_coarray[this_image()] =  T
Team 2, image 3: team_coarray == team_coarray[this_image()] =  T
Team 2, image 4: team_coarray == team_coarray[this_image()] =  T

 

 

Labels (2)
0 Kudos
0 Replies
Reply