Having the compiler reject this example seems reasonable. But is it an acceptable implementation for the compiler to presume that the length type parameter values are assumed from the caller even if they are not explicitly specified as * by the programmer? (I.e. accept both versions of the example, with identical effect).
Cheers,
Bill
> On Aug 17, 2017, at 10:16 PM, Malcolm Cohen <[log in to unmask]> wrote:
>
> I agree with the compiler rejection. Fortran 2003 (and onwards) have a constraint that all length type parameters of a passed-object dummy argument must be assumed.
>
> Cheers,
>
> -----Original Message----- From: Anton Shterenlikht
> Sent: Thursday, August 17, 2017 11:36 PM
> To: [log in to unmask]
> Subject: [COMP-FORTRAN-90] type-bound procedure, length type parameter with default value
>
> I think this module is conforming:
>
> module m
> type :: t( l )
> integer, len :: l=30
> contains
> procedure :: s
> end type t
> contains
> subroutine s( a )
> class( t ) :: a
> end subroutine s
> end module m
>
> One compiler rejects it with:
>
> All length type parameters of the passed object dummy argument must be assumed. [A]
> subroutine s( a )
> ----------------^
>
> Indeed I can change
> class( t ) :: a
> to
> class( t( l=*) ) :: a
> and this makes the compiler happy,
> but I think this is unnecessary given
> that type t gives length parameter l
> a default value.
>
> Also, if I remove a type-bound procedure:
>
> module m
> type :: t( l )
> integer, len :: l=30
> ! contains
> ! procedure :: s
> end type t
> contains
> subroutine s( a )
> class( t ) :: a
> end subroutine s
> end module m
>
> then this is acceptable to the compiler too.
>
> Am I wrong?
> Are there different rules
> for dummy arguments of derived types with
> length type parameters, for type-bound and
> non type-bound procedures?
>
> Anton
Bill Long [log in to unmask]
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
|