On 9/2/26 8:39 AM, Mikael Morin wrote:
Le 02/09/2026 à 11:17, Paul Richard Thomas a écrit :
Hello Mikael,
The new team is different to the parent team and so "I'm inclined to
think that they are different teams, and the program should output
(for each image): -1 and 12." is correct.
Thanks.
Then, it's also the expected output with -fcoarray=single, and team_number
shouldn't always return -1 even with -fcoarray=single.
Expanding your example a bit:
program prog
use, intrinsic :: iso_fortran_env, only: team_type
implicit none
type(team_type) :: team1, team2
print *, team_number()
form team (mod (this_image (), 4) +1, team1)
change team(team1)
form team (mod (this_image (), 2) +1, team2)
change team(team2)
print *, team_number(team1), team_number(team2)
end team
end team
end program
Results in:
pault@fedora:~/prs/coarrays$ export GFORTRAN_NUM_IMAGES=8
pault@fedora:~/prs/coarrays$ rm ./a.out;rm
*.original;~/gfc/bin/gfortran -fcoarray=lib -g ../junk.f90
-lcaf_shmem;./a.out
rm: cannot remove '*.original': No such file or directory
-1
-1
-1
-1
-1
-1
-1
-1
3 1
3 2
2 2
2 1
4 2
4 1
1 2
1 1
The other brands do the same.
Yeah, but that case is clearer. My question was more focused on the degenerate
case where all images use the same number, and more specifically the single-
image behaviour.
From my read of the 2023 draft standard.
The two teams are distinct, and the program should print -1 then 12 on
every image.
F2023 11.7.9p2 (FORM TEAM): "Successful execution of a FORM TEAM
statement creates a new team for each unique team-number value
specified by the active images of the current team." There is one
unique team-number value here (12), so exactly one new team is
created; team identity comes from the execution of FORM TEAM, not
from the image set. Nothing makes a new team with identical
membership be its parent.
That a team may contain all images of its parent is explicitly
allowed: 5.3.4p2 says a team is "either the initial team, consisting
of all images, or a subset of a parent team formed by execution of a
FORM TEAM statement" -- a subset, not a proper subset. The
constraint on team-number is only that it be positive (11.7.9p2), so
12 is fine.
TEAM_NUMBER (16.9.207): "The result has the value -1 if the specified
team is the initial team; otherwise, the result value is equal to the
positive integer that identifies the specified team among its sibling
teams." Before FORM TEAM the current team is the initial team, so
-1. Inside the CHANGE TEAM construct the current team is the newly
formed team, whose number is 12, so 12. Note also that -1 is
reserved for the initial team (3.142.5), so a formed team can never
report -1, whatever its membership.
Corollaries that fall out of the same reading:
- after END TEAM the current team is the initial team again, so a
third print would give -1;
- the new team is a full-fledged child: it has its own image index
numbering (11.7.9p3-4, processor dependent without NEW_INDEX=),
its own coarray establishment, and SYNC ALL inside CHANGE TEAM
syncs that team;
- two successive FORM TEAM (12, t1) / FORM TEAM (12, t2) executions
create two distinct teams that both report team number 12, which
would be impossible if "same membership + same number" meant "same
team".
Regarding when -fcoarray=single, the program exits early which is wrong. The
coarray single library is never even called. So that is another bug I am working on.
Hope this helps. Currently with your sample program from earlier, if I add
another print statement:
program prog
use, intrinsic :: iso_fortran_env, only: team_type
implicit none
type(team_type) :: team
print *, team_number()
form team (12, team)
change team(team)
print *, team_number()
end team
print *, team_number()
end program
I get with 8 threads:
$ gfctest teamer.f90 -fcoarray=lib -lcaf_shmem
$ ./a.out
-1
-1
-1
-1
-1
-1
-1
-1
12
12
12
12
12
12
12
12
-1
-1
-1
-1
-1
-1
-1
-1
Best regards,
Jerry