JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  August 2017

COMP-FORTRAN-90 August 2017

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Misuse of same_type_as intrinsic?

From:

Vipul Parekh <[log in to unmask]>

Reply-To:

Fortran 90 List <[log in to unmask]>

Date:

Tue, 1 Aug 2017 11:46:01 -0400

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (271 lines)

On Mon, Jul 31, 2017 at 1:36 PM, Steve Lionel wrote:
> I submitted a bug report (02976306) on this to Intel. I agree with Malcolm
> that ifort's behavior does not match the standard. But I also agree with
> Vipul that it would be helpful if there was a note (either in SAME_TYPE_AS,
> or maybe under Dynamic Type) indicating that type parameters are not
> considered where the standard references only "dynamic type".


Thanks much, Steve, for your follow-up with Intel as well as your comments.

A clarifying note in the standard, as suggested by Steve, will be
useful, if nothing else is done on this.  Such a note likely would
have helped Intel developers "get it right the first time" and
possibly assist other implementations too.

However, I suggest the matter be considered and at least discussed a
bit further for a possible enhancement i.e., why not revise the very
definition in the standard for "dynamic type" to also include type
parameters?

Instead of immediately dismissing it as "no, that is not possible",
can readers consider a thought exercise where, say, the "dynamic type"
is defined as "type and type parameters of a data entity at a
particular point during execution of a program"?  Will this not help
realize some simplification to language semantics as well as bring
some additional value for coders?  The latter because it will then be
aligned, IMO, with coders' intuition on what constitutes a dynamic
type in relevant situations such as deallocation and finalization,
procedure binding, etc.

If I read through N2123 committee draft toward Fortran 2015 and
consider where "dynamic type" is referenced, I find it will either
simplify the standard text and consequently the language semantics or
it will have no impact.  For the sake of some brevity (!!), I list
below the first 16 instances where "dynamic type" is mentioned in
N2123 where numbered phrases 1), 2), 3), etc. for each occurrence of
"dynamic type" in N2123 are shown along with my observations on what
such a change would yield.

---------------------------------------------
1) No change needed
   3.110
   polymorphic
   (data entity) able to be of differing dynamic types during program
execution (7.3.2.3)

2) Include type parameters
   3.147.4
   dynamic type
   type and type parameters of a data entity at a particular point
during execution of a program (7.3.2.3, 10.1.9)

3) No change needed
   3.152
   unlimited polymorphic
   able to have any dynamic type during program execution (7.3.2.3)

4) Simplify: no need to repeat type parameters
   7.3.2.2 TYPE type specifier
   ..
   3 An entity that is declared using the TYPE(*) type specifier is
assumed-type and is an unlimited polymorphic
     entity. It is not declared to have a type, and is not considered
to have the same declared type as any other entity,
     including another unlimited polymorphic entity. Its dynamic type
is assumed from its effective argument.
     >> note: N2123 Fortran 2015 draft says "Its dynamic type and type
parameters are assumed from its effective argument"

5) No change needed
   7.3.2.3 CLASS type specifier
   ..
   7 The dynamic type of an allocated allocatable polymorphic object
is the type with which it was allocated. The
     dynamic type of an associated polymorphic pointer is the dynamic
type of its target. The dynamic type of a
     nonallocatable nonpointer polymorphic dummy argument is the
dynamic type of its effective argument. The
     dynamic type of an unallocated allocatable object or a
disassociated pointer is the same as its declared type. The
     dynamic type of an entity identified by an associate name
(11.1.3) is the dynamic type of the selector with which
     it is associated. The dynamic type of an object that is not
polymorphic is its declared type.

6) Simplify: no need to include kind type parameters, it is implied
from the definition of dynamic type
   7.5.6.2 The finalization process
   ..
   12 Only finalizable entities are finalized. When an entity is
finalized, the following steps are carried out in sequence.
      (1) If the dynamic type of the entity has a final subroutine
whose dummy argument has the same rank as the entity
          being finalized, it is called with the entity as an actual argument.
          >> note: N2123 2015 draft says "whose dummy argument has the
same kind type parameters and rank"

7) No change needed
   NOTE 7.51
   The DEFERRED attribute (7.5.5) defers the implementation of a
type-bound procedure to extensions of
   the type; it can appear only in an abstract type. The dynamic type
of an object cannot be abstract;
   therefore, a deferred type-bound procedure cannot be invoked. An
extension of an abstract type need not
   be abstract if it has no deferred type-bound procedures.

8) Simplify: no need to repeat type parameters
   7.5.8 Derived-type values
   1 The component value of
     * a pointer component is its pointer association,
     * an allocatable component is its allocation status and, if it is
allocated, its dynamic type, bounds and value, and
     * a nonpointer nonallocatable component is its value.
     >> note: N2123 Fortran 2015 draft says "its dynamic type and type
parameters"

9) No change needed
   7.5.10 Construction of derived-type values
   ..
   7 If the component is allocatable and the expression is an
allocatable entity, the corresponding component of the
     constructor has the same allocation status as that allocatable
entity. If it is allocated, it has the same bounds;
     if a length parameter of the component is deferred, its value is
the same as the corresponding parameter of the
     expression. If the component is polymorphic, it has the same
dynamic type and value; otherwise, it has the value
     converted, if necessary, to the declared type of the component.

   8 If the component is allocatable and the expression is not an
allocatable entity, the component has an allocation
     status of allocated and the same bounds as the expression; if a
length parameter of the component is deferred,
     its value is the same as the corresponding parameter of the
expression. If the component is polymorphic, it has
     the same dynamic type and value; otherwise, it has the value
converted, if necessary, to the declared type of the
     component.

10) No change needed
    7.8 Construction of array values
    ..
    4 The dynamic type of an array constructor is the same as its declared type.

11) Simplify: no need to repeat type parameters
    8.5.19 VOLATILE attribute
    ..
    1 The VOLATILE attribute specifies that an object may be
referenced, defined, or become undefined, by means
      not specified by the program. A pointer with the VOLATILE
attribute may additionally have its association
      status, dynamic type, and array bounds changed by means not
specified by the program.
      An allocatable object with the VOLATILE attribute may
additionally have its allocation status, dynamic type
      and *deferred* type parameters, and array bounds changed by
means not specified by the program.
     >> note: N2123 Fortran 2015 draft says "dynamic type and type parameters"

12) Simplify: no need to repeat type parameters
    9.7.1 ALLOCATE statement
    ..
    11 If type-spec is specified, each allocate-object is allocated
with the specified dynamic type;
       if source-expr is specified, each allocate-object is allocated
with the dynamic type of source-expr;
       otherwise, each allocate-object is allocated with its dynamic
type the same as its declared
       type.

13) Simplify: no need to repeat type parameters
    9.7.1.2 Execution of an ALLOCATE statement
    ..
    3 If an allocation specifies a coarray, its dynamic type shall be
the same on every active image in the current team.
      The values of corresponding bounds and corresponding cobounds
shall be the same on those images. If the coarray
      is a dummy argument, its ultimate argument (15.5.2.3) shall be
the same coarray on those images.

14) No change needed
    NOTE 9.21
    When a NULLIFY statement is applied to a polymorphic pointer
(7.3.2.3), its dynamic type becomes the
    same as its declared type.

15) Simplify: no need to repeat type parameters
    9.7.3.3 Deallocation of pointer targets
    ..
    2 If a pointer appears in a DEALLOCATE statement, it shall be
associated with the whole of an object that was
      created by allocation. The pointer shall have the same dynamic
type as the allocated object,
      and if the allocated object is an array the pointer shall be an
array whose elements are the same as those of the
      allocated object in array element order. Deallocating a pointer
target causes the pointer association status of any
      other pointer that is associated with the target or a portion of
the target to become undefined.
      >> note: N2123 Fortran 2015 draft says "The pointer shall have
the same dynamic type and type parameters as the allocated object"

16) Simplify: remove bullet 4) altogether from paragraph 2
    10.1.6 Defined operations
    10.1.6.1 Definitions
    2 A function defines the unary operation op x2 if
      (1) the function is specified with a FUNCTION (15.6.2.2) or
ENTRY (15.6.2.6) statement that specifies one
          dummy argument d2,
      (2) either
          (a) a generic interface (15.4.3.2) provides the function
with a generic-spec of OPERATOR (op),
          or
          (b) there is a generic binding (7.5.5) in the declared type
of x2 with a generic-spec of OPERATOR (op)
          and there is a corresponding binding to the function in the
dynamic type of x2,
      (3) the type of d2 is compatible with the dynamic type of x2,
      (4) either
          (a) the rank of x2 matches that of d2 or
          (b) the function is elemental and there is no other function
that defines the operation.
      >> note: N2123 Fortran 2015 draft has bullet (4) that says
              "the type parameters, if any, of d2 match the
corresponding type parameters of x2, and"

---------------------------------------------

There are additional 25 or so instances where "dynamic type" appears
in the standard text, but I feel the theme is the same as captured
above i.e., one can either simplify the standard text and not have to
spike out the "and type parameters" bit or that no change to the text
is needed.

To elaborate further, please consider item 15) above where under
9.7.3.3 Deallocation of pointer targets, N2123 Fortran 2015 draft says
"The pointer shall have the same dynamic type and type parameters as
the allocated object".  Or 16) above where the additional definition
of what the function for an unary operation does has to be included
for type parameters in a separate bullet.

The above two instances 15) and 16) in essence show the point I'm
trying to make which is that when dealing with a dynamic type, the
type parameters go along with the type just like horse and carriage.
So why not state as such in the very definition of "dynamic type"?

Sure all this can be quite a bit to digest and even come across as
counter-intuitive, but I will appreciate greatly if some readers,
including a few on the standard committee, will at least take a look
at this and see if it can be brought up for consideration, say, for a
future revision to the standard

Coming back to the top of this thread with SAME_TYPE_AS intrinsic, my
hope is ultimately the standard-conforming behavior will be how Intel
Fortran works today with derived types (as well as intrinsic types but
more on this later), for it is what I think is most useful for coders.

And a further point I would suggest for readers is the arguments that
these are of marginal usefulness or that it is a waste of time are not
healthy in the long term for Fortran.  Anything that has the potential
to simplify the standard text and make it easier for compiler
implementations and coders to absorb and work with the language
semantics is of immeasurable value, the benefits accrue over time and
they can prove priceless.  And it helps when Fortranners are open to
discussing ideas and options to improve the language and to foster an
open, collaborative environment.

Thanks much for your attention,
Vipul Parekh

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager