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

Malcolm Cohen malcolm at nag-j.co.jp
Fri May 31 07:34:05 UTC 2024


Thinking on this a bit further, removing the "as" in front of the second and third phrases would, I think, make it clearer. Though I'd probably want to reorder it, and remove the inner "if".

Perhaps

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

would be clearer to read? That does have the disadvantage of having the most common and expected thing at the end rather than the beginning, but I think the grammar is a little simpler.

Thoughts?

(If there is general agreement it can be an /EDIT paper for F202y, but if some prefer what is there now perhaps we should leave it alone.)

Cheers,
-- 
..............Malcolm Cohen, NAG Oxford/Tokyo.

-----Original Message-----
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Malcolm Cohen via J3
Sent: Friday, May 31, 2024 9:04 AM
To: 'General J3 interest list' <j3 at mailman.j3-fortran.org>
Cc: Malcolm Cohen <malcolm at nag-j.co.jp>
Subject: Re: [J3] Question about EVENT, LOCK and NOTIFY_TYPE as components

Hi Brad,

Your interesting "alternative interpretation", which would make your examples invalid, does not make sense, because that would make the second and third clauses into trivial consequences of the first clause. So that simply cannot be the case.

When one has two parses of a sentence, and only one makes sense, it is the one that makes sense that is intended.

I note that the fourth compiler compilation errors appear to have nothing to do with the question.

Cheers,
-- 
..............Malcolm Cohen, NAG Oxford/Tokyo.

-----Original Message-----
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Brad Richardson via J3
Sent: Thursday, May 30, 2024 11:26 PM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Brad Richardson <everythingfunctional at protonmail.com>
Subject: [J3] Question about EVENT, LOCK and NOTIFY_TYPE as components

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