J3/98-117 Date: 6th February 1998 To: J3 From: Malcolm Cohen Subject: Interpretation Request on Elemental Procedures NUMBER: TITLE: ELEMENTAL procedures with no arguments KEYWORDS: Elemental, procedure DEFECT TYPE: STATUS: Section 12.7.2 of IS 1539-1:1997 seems to assume there is at least one argument to an elemental procedure. The semantics of the following examples do not seem to be clearly specified. Example 1: ELEMENTAL INTEGER FUNCTION f() f = 0 END Example 2: ELEMENTAL INTEGER FUNCTION g(i) INTEGER,INTENT(IN) :: i g = i END Example 3: ELEMENTAL INTEGER FUNCTION h(i,j) INTEGER,INTENT(IN) :: i,j OPTIONAL j h = i/j END ... SUBROUTINE S(JARG) INTEGER IARG,JARG(3) OPTIONAL JARG ... ... H(IARG) ... H(IARG,JARG) Example 4: ELEMENTAL INTEGER FUNCTION h2(i) INTEGER,INTENT(IN),OPTIONAL :: i h = i END Example 5: ELEMENTAL SUBROUTINE s() REAL x,y,z x = 0 y = 0 z = x/y END QUESTION 1: What is the shape of a reference to function F in example 1? Is it scalar or a zero-sized array (and of what dimension)? QUESTION 2: If G() is referenced with a zero-sized array argument, there are no elements corresponding to I in "G = I". Is this ok? Does the reference to I take place? QUESTION 3: In the reference H(IARG), the J argument is not present and so the shape of the reference is that of IARG, i.e. scalar. In the reference H(IARG,JARG), what is the shape if, at runtime, JARG is not present [in the call to S]? QUESTION 4: What is the shape of a reference to H2() if the argument is textually not present? QUESTION 5: Is this example standard-conforming, or may a processor raise a divide-by-zero exception, even though there is no array argument over which to iterate a call? ANSWER: EDIT: SUBMITTED BY: Malcolm Cohen HISTORY: Submitted 9th February 1998 ------------------------------------------------------------------------------- ...........................Malcolm Cohen, NAG Ltd., Oxford, U.K. (malcolm@nag.co.uk)