(j3.2006) polymorphic arguments of intrinsic operators and procedures

Robert Corbett robert.corbett
Wed Jan 26 03:37:14 EST 2011


The Fortran standard explicitly indicates that a few intrinsic
functions (EXTENDS_TYPE_OF, SAME_TYPE_AS, and STORAGE_SIZE)
accept polymorphic arguments.  Beyond those few functions, the
standard does not clearly indicate which intrinsic operators
accept polymorphic operands and which intrinsic procedures
accept polymorphic arguments.  The members of Oracle's Fortran
team agree that the only intrinsic operators that should accept
polymorphic operands are intrinsic assignments and pointer
assignments.  The members also agree that the procedures
defined in clauses 13.8.2, 14, and 15 should not accept
polymorphic arguments.  The members of Oracle's Fortran team
disagree about which intrinsic procedures should accept
polymorphic arguments.

The members of Oracle's Fortran team agree that intrinsic
subroutines that take one or more arguments of "any type"
should accept polymorphic arguments.  The members also agree
that intrinsic functions that take one or more arguments of
"any type" and whose result type does not depend on the type(s)
of the arguments should take polymorphic arguments.  The list
of intrinsic procedures that satisfy these criteria are

      ALLOCATED        ASSOCIATED        EXTENDS_TYPE_OF
      IMAGE_INDEX      IS_CONTIGUOUS     LBOUND
      LCOBOUND         MOVE_ALLOC        PRESENT
      SAME_TYPE_AS     SHAPE             SIZE
      STORAGE_SIZE     THIS_IMAGE        UBOUND
      UCOBOUND

The members also agree that the intrinsic function NULL should
accept a polymorphic argument.  If such an argument is
specified, the return type should be the declared type of the
argument.

The members of Oracle's Fortran team disagree about whether any
intrinsic functions should return polymorphic results.  One side
argues that the only functions that return allocatable or
pointer results should return polymorphic results.  User-defined
functions are subject to that restriction.  The only additional
function that this side thinks should accept polymorphic
arguments is TRANSFER and that the result type should be the
declared type of the MOLD argument.

The other side argues that intrinsic functions that take arguments
of "any type" and return results that are the same type as one
or more of the arguments should accept polymorphic arguments and
return polymorphic results.  The declared type of the result
should match the declared type of the argument, and the dynamic
type of the result should match the dynamic type of the argument.
This side thinks the following additional functions should accept
polymorphic arguments

      CSHIFT       EOSHIFT       MERGE      PACK
      RESHAPE      SHAPE         SIZE       SPREAD
      TRANSFER     TRANSPOSE     UNPACK

In other implmentations, which intrinsic procedures accept
polymorphic arguments?  By what rationale were these procedures
chosen?  Is there language in the standard that specifies which
intrinsic procedures accept polymorphic arguments that the
members of Oracle's Fortran team missed?  Which of the schemes
described above is more appealing?

Robert Corbett



More information about the J3 mailing list