(j3.2006) How to assign to the declared-type part of a polymorphic allocatable array?

Clune, Thomas L. GSFC-6101 thomas.l.clune
Fri Sep 23 16:13:14 EDT 2016


On Sep 23, 2016, at 2:37 PM, Van Snyder <Van.Snyder at jpl.nasa.gov<mailto:Van.Snyder at jpl.nasa.gov>> wrote:

On Fri, 2016-09-23 at 17:55 +0900, Cohen Malcolm wrote:
<<<
Is there a way to assign to the declared-type part of a polymorphic
allocatable array, other than one component at a time?


Yes, use a procedure, for example:

Elemental Subroutine assign_t_only(a,b)
 Type(t),Intent(Out) :: a
 Type(t),Intent(In) :: b
 a = b
End Subroutine

That handles things with a declared type of T whether polymorphic or not, to
handle things with a declared type that is an extension of T you need only
use the additional procedure:

Elemental Subroutine assign_t_only_e(aa,bb)
 Class(t),Intent(InOut) :: aa
 Class(t),Intent(In) :: bb
 Call assign_t_only(aa,bb)
End Subroutine

(This second one could be a type-bound procedure of T, and the first could
be an internal procedure of the second.)

The first can't be type-bound if it has a passed-object dummy argument.

Precisely.  That?s why Malcolm suggested the combination that he did.  Not perfect, perhaps, but certainly reasonable.

- Tom





Cheers,


_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org<mailto:J3 at mailman.j3-fortran.org>
http://mailman.j3-fortran.org/mailman/listinfo/j3

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20160923/e57e6377/attachment.html 



More information about the J3 mailing list