Print

Print


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