Re: [Patch, fortran] PR126205 - A coarray allocated in a team is not being automatically deallocated

Paul Richard Thomas <[email protected]> Sun, 26 Jul 2026 08:54:46 +0100
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <CAGkQGi+3h1383O8eWYJZwtef0ps+KMp6N4HVaotjni=GMOv24Q@mail.gmail.com>
--000000000000052b7806577eec0e
Content-Type: text/plain; charset="UTF-8"

Hi Andre,

The shmem library was the first place that I went to:

I found that _gfortran_caf_end_team calls _gfortran_caf_deregister, which
takes the alloc_free_memory_with_id branch for these allocatable coarrays.
Then something doesn't happen, which should! I gave up in the end but will
go back to it, having learned a lot in my failed attempt and the posted
patch.

Regards

Paul

On Fri, 24 Jul 2026 at 17:01, Andre Vehreschild <[email protected]> wrote:

> Hi Paul,
>
> interesting issue, because the caf-libraries have a list of coarrays
> allocated
> for each team and free them, when the team is left.
>
> - Andre
>
> On Fri, 24 Jul 2026 16:18:57 +0100
> Paul Richard Thomas <[email protected]> wrote:
>
> > Hello All,
> > From John Reid's "Summary_of_Fortran_2018":
> >
> > 3.5 Coarrays allocated in teams
> >
> > ....snip....
> >
> > In Fortran 2018, synchronization is now across the team, of course.
> > Symmetric memory is maintained within teams by requiring that
> >
> > 1. any allocatable coarray that is allocated before entry to a change
> team
> > construct remains allocated during the execution of the construct and
> > 2. any allocatable coarray that becomes allocated within a change team
> > construct and is still allocated when the construct is left is
> > automatically deallocated, even if it has the save attribute.
> >
> > ....more snips....
> >
> > Requirement 2 is not yet implemented in gfortran. The attachment does the
> > job.
> >
> > Regression tested on FC44/x86_64 - OK for mainline and eventual
> backporting
> > to 16-branch?
> >
> > Paul
>
>
> --
> Andre Vehreschild * Email: vehre ad gmx dot de
>

--000000000000052b7806577eec0e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">Hi Andre,<div><br></div><div>The shmem li=
brary was the first place that I went to:</div><div><br></div><div>I found =
that _gfortran_caf_end_team calls _gfortran_caf_deregister, which takes the=
 alloc_free_memory_with_id branch for these allocatable=C2=A0coarrays. Then=
 something doesn&#39;t happen, which should! I gave up in the end but will =
go back to it, having learned a lot in my failed attempt and the posted pat=
ch.</div><div><br></div><div>Regards</div><div><br></div><div>Paul</div></d=
iv><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On =
Fri, 24 Jul 2026 at 17:01, Andre Vehreschild &lt;<a href=3D"mailto:vehre@gm=
x.de" target=3D"_blank">[email protected]</a>&gt; wrote:<br></div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid=
 rgb(204,204,204);padding-left:1ex">Hi Paul,<br>
<br>
interesting issue, because the caf-libraries have a list of coarrays alloca=
ted<br>
for each team and free them, when the team is left.<br>
<br>
- Andre<br>
<br>
On Fri, 24 Jul 2026 16:18:57 +0100<br>
Paul Richard Thomas &lt;<a href=3D"mailto:[email protected]" ta=
rget=3D"_blank">[email protected]</a>&gt; wrote:<br>
<br>
&gt; Hello All,<br>
&gt; From John Reid&#39;s &quot;Summary_of_Fortran_2018&quot;:<br>
&gt; <br>
&gt; 3.5 Coarrays allocated in teams<br>
&gt; <br>
&gt; ....snip....<br>
&gt; <br>
&gt; In Fortran 2018, synchronization is now across the team, of course.<br=
>
&gt; Symmetric memory is maintained within teams by requiring that<br>
&gt; <br>
&gt; 1. any allocatable coarray that is allocated before entry to a change =
team<br>
&gt; construct remains allocated during the execution of the construct and<=
br>
&gt; 2. any allocatable coarray that becomes allocated within a change team=
<br>
&gt; construct and is still allocated when the construct is left is<br>
&gt; automatically deallocated, even if it has the save attribute.<br>
&gt; <br>
&gt; ....more snips....<br>
&gt; <br>
&gt; Requirement 2 is not yet implemented in gfortran. The attachment does =
the<br>
&gt; job.<br>
&gt; <br>
&gt; Regression tested on FC44/x86_64 - OK for mainline and eventual backpo=
rting<br>
&gt; to 16-branch?<br>
&gt; <br>
&gt; Paul<br>
<br>
<br>
-- <br>
Andre Vehreschild * Email: vehre ad gmx dot de <br>
</blockquote></div>
</div>

--000000000000052b7806577eec0e--