(j3.2006) Is 12.5.2.5p2 really necessary?

Van Snyder Van.Snyder
Mon May 9 18:38:51 EDT 2016


On Mon, 2016-05-09 at 12:13 +0000, Bill Long wrote:
> On May 6, 2016, at 7:10 PM, Van Snyder <Van.Snyder at jpl.nasa.gov>
> wrote:
> 
> > A colleague tried to write a simple routine that would compute the size
> > in bytes of an array (to track memory usage), deallocate it, test the
> > status, and print a message if failure occurred.  Rather than writing
> 
> Rather than trying to do something obtuse why not just use Fortran:
> 
> mysize = storage_size(x)*size(x)
> deallocate(x, stat=is)
> if (is == 0) then
>     used_space = used_space - mysize
> else 
>     print *, ?failure to deallocate array"
> end if

Something you need in hundreds of places is the poster child for
subroutines.

A subroutine that doesn't care about the type or rank of its argument is
the poster child for polymorphism and assumed rank.

> Cheers,
> Bill
> 
> 
> > one for every type and kind, he tried to make the dummy argument
> > unlimited polymorphic.
> > 
> > This fell afoul of 12.5.2.5p2:
> > 
> >        The actual argument shall be polymorphic if and only if the
> >        associated dummy argument is polymorphic, and either both the
> >        actual and dummy arguments shall be unlimited polymorphic, or
> >        the declared type of the actual argument shall be the same as
> >        the declared type of the dummy argument.
> > 
> > Is this paragraph really necessary?  It seems that the object-oriented
> > system ought to work just fine without it, albeit with some more words
> > to describe how a dummy argument can be allocated if the actual
> > argument's declared type is compatible with but not necessarily
> > identical to the dummy argument's declared type.  The result would of
> > necessity be that the dynamic type of the allocated entity is type
> > compatible with the declared type of the actual argument if the actual
> > argument is polymorphic, and the same type if it's not.  If there is no
> > type spec in the allocate statement, the allocated type is the declared
> > type of the actual argument.    Everything else, including deallocation,
> > ought to work without additional explanation.
> > 
> > Processors might endure some complication in creating descriptors to
> > connect polymorphic dummy arguments to nonpolymorphic actual arguments,
> > or actual arguments whose declared types are type compatible rather than
> > identical.  The "type" member of the CFI_cdesc_t struct ought to serve
> > for this purpose.  Because having a polymorphic dummy argument requires
> > an explicit interface, a processor would know where this is required.
> > 
> > 
> > _______________________________________________
> > J3 mailing list
> > J3 at mailman.j3-fortran.org
> > http://mailman.j3-fortran.org/mailman/listinfo/j3
> 
> Bill Long
> longb at cray.com
> Fortran Technical Support  &                                  voice:
> 651-605-9024
> Bioinformatics Software Development                     fax:
> 651-605-9142
> Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
> 
> 





More information about the J3 mailing list