[J3] Question about EVENT, LOCK and NOTIFY_TYPE as components

Brad Richardson everythingfunctional at protonmail.com
Thu May 30 14:25:58 UTC 2024


Hi all,

This question arose when trying to determine if examples like those
shown below are valid. Specifically, constraints C1605, C1609 and C1613
(which all read nearly identically). I.e.

> An event variable shall not appear in a variable definition context
except as the event-variable in an EVENT POST or EVENT WAIT statement,
as an allocate-object, or as an actual argument in a reference to a
procedure with an explicit interface if the corresponding dummy
argument has INTENT (INOUT).

Is this to be read as:

An event variable shall not appear:
 * in a variable definition context except as the event-variable in an
EVENT POST or EVENT WAIT statement
 * as an allocate-object
 * as an actual argument in a reference to a procedure with an explicit
interface if the corresponding dummy argument has INTENT (INOUT)

which would make the following examples invalid, or instead as:

An event variable shall not appear in a variable definition context
except as:
 * the event-variable in an EVENT POST or EVENT WAIT statement
 * an allocate-object
 * an actual argument in a reference to a procedure with an explicit
interface if the corresponding dummy argument has INTENT (INOUT)

which would make the following examples valid. My instinct is the
latter is what was intended, but the grammar here seemed ambiguous.

The examples:

program example
    use iso_fortran_env
    implicit none

    type :: t
        type(event_type), allocatable :: events(:)
    end type

    type(t) :: obj[*]

    allocate(obj%events(1))
    sync all
    if (this_image() == 1) then
        event post (obj[2]%events(1))
    end if
    if (this_image() == 2) then
        event wait (obj%events(1))
        print *, "hello"
    end if
end program


program example
    use iso_fortran_env
    implicit none

    type :: t
        type(event_type), pointer :: event
    end type

    type :: u
        type(event_type) :: event
    end type

    type(t) :: a[*]
    type(u), target :: b[*]

    a%event => b%event
    sync all
    if (this_image() == 1) then
        event post (a[2]%event)
    end if
    if (this_image() == 2) then
        event wait (a%event)
        print *, "hello"
    end if
end program

I will note that 3 of 4 compilers compiled and executed these examples
"correctly", but that the 4th rejected them with the following errors:

example.f90:6:50:

    6 |         type(event_type), allocatable :: events(:)
      |                                                  1
Error: Allocatable component events at (1) of type EVENT_TYPE must have
a codimension
example.f90:17:20:

   17 |         event wait (obj%events(1))
      |                    1
Error: Event variable argument at (1) must be a coarray but not
coindexed

pointer.f90:6:42:

    6 |         type(event_type), pointer :: event
      |                                          1
Error: Component event at (1) of type EVENT_TYPE must have a
codimension or be a subcomponent of a coarray, which is not possible as
the component has the pointer attribute
pointer.f90:16:4:

   16 |     a%event => b%event
      |    1
Error: LOCK_EVENT in variable definition context (pointer assignment)
at (1)
pointer.f90:22:20:

   22 |         event wait (a%event)
      |                    1
Error: Event variable argument at (1) must be a coarray but not
coindexed


Thanks in advance for any help.

Regards,
Brad



More information about the J3 mailing list