[J3] LOCAL and LOCAL_INIT with procedure pointers

Bader, Reinhold Reinhold.Bader at lrz.de
Sun Mar 10 17:59:24 UTC 2024


Dear Tobias, 

no, this is not valid as of Fortran 2023. The locality spec permits variable-name specs (9.2), and this resolves to 
either a data object designator (9.1) or a function reference with a data pointer result. One could work around this
by creating a derived type with a procedure pointer component.

Cheers, 
Reinhold

> -----Ursprüngliche Nachricht-----
> Von: J3 <j3-bounces at mailman.j3-fortran.org> Im Auftrag von Tobias Burnus
> via J3
> Gesendet: Samstag, 9. März 2024 15:50
> An: J3 <j3 at mailman.j3-fortran.org>
> Cc: Tobias Burnus <burnus at net-b.de>
> Betreff: [J3] LOCAL and LOCAL_INIT with procedure pointers
> 
> Hi all,
> 
> I was wondering whether the following is valid (probably not) and whether it
> should(*) be.
> 
> [(*) It seems as if LOCAL[_INIT] for procedure pointer can be useful and
> seems to be sensible, albeit it does not seem to be a common usage
> pattern.]
> 
> ! ---------------
> interface
>    pure integer function one(x)
>      integer, value :: x
>    end
>    pure integer function two(x)
>      integer, value :: x
>    end
> end interface
> 
> integer :: i, A(10)
> procedure(one), pointer :: f
> A = 0
> do concurrent (i = 1: 10) local(f)
>    if (mod (i, 2) == 0) then
>      f => one
>    else
>      f => two
>    end if
>    A(i) = f(1 + (i-1)/2)
> end do
> end
> ! ---------------
> 
> 
> Tobias

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6777 bytes
Desc: not available
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20240310/f138e577/attachment.p7s>


More information about the J3 mailing list