Cryptic error message for procedure bound to a type

Janus Weil janus@gcc.gnu.org
Wed Sep 8 15:33:00 GMT 2010


Hi Armelius,

> I have a module that defines a type with a procedure bound to the
> type. When trying to compile with the latest gfortran from nightlies,
> I got the following error message that I don't understand:
>
> -----------
> ]$ gfortran -c UnitValue_Form.f90
> UnitValue_Form.f90:12.15:
>
>      procedure, private, pass :: &
>               1
> Error: Non-polymorphic passed-object dummy argument of 'initialize_mv'
> at (1)
> ----

What exactly don't you understand about this? The 'passed-object dummy
argument' in your case is the argument 'MV'. The error message says
that this one should be polymorphic, i.e. you should declare it as
CLASS(UnitValueForm) instead of TYPE(UnitValueForm).


> Below is the complete output and module file. This module can be
> compiled fine with the Cray's compiler. Thank you for any help.

AFAICS, the above restriction is exactly what is demanded by the F03 &
F08 standard [1], therefore I wonder why Cray doesn't reject your
code. Maybe it does accept it as an extension (gfortran did the same
in version 4.4, when CLASS variables were not supported yet; note that
gfortran 4.4 accepts your code with a warning). Have you tried other
compilers?

Cheers,
Janus



[1] In F08 you find:

C456 The passed-object dummy argument shall be a scalar, nonpointer,
nonallocatable dummy data object
with the same declared type as the type being defined; all of its
length type parameters shall be assumed;
it shall be polymorphic (4.3.1.3) if and only if the type being defined
is extensible (4.5.7). It shall not
have the VALUE attribute.





> ----------------
> ]$ cat UnitValue_Form.f90
> module UnitValue_Form
>
>  implicit none
>  private
>
>  type, public :: UnitValueForm
>    real :: &
>      Number = 1.0
>    character ( 10 ) :: &
>      Unit = ''
>  contains
>      procedure, private, pass :: &
>        Initialize_MV
>    generic :: &
>      Initialize => Initialize_MV
>  end type UnitValueForm
>
> contains
>
>  subroutine Initialize_MV ( MV, Unit, Number )
>
>    type ( UnitValueForm ), intent ( inout ) :: &
>      MV
>    character ( 10 ), intent ( in ) :: &
>      Unit
>    real, intent ( in ) :: &
>      Number
>
>    MV % Number = Number
>    MV % Unit   = Unit
>
>  end subroutine Initialize_MV
>
> end module UnitValue_Form
>
>
> ]$ gfortran -v
> Using built-in specs.
> COLLECT_GCC=gfortran
> COLLECT_LTO_WRAPPER=/usr/local/gcc/trunk/bin/../libexec/gcc/x86_64-
> unknown-linux-gnu/4.6.0/lto-wrapper
> Target: x86_64-unknown-linux-gnu
> Configured with: ../gcc-trunk-source/gcc/configure --enable-
> languages=c,c++,fortran --enable-checking=release --disable-bootstrap
> --disable-libmudflap --enable-libgomp --enable-lto --enable-gold --
> with-plugin-ld=/usr/bin/gold --prefix=/usr/local/gcc-trunk
> Thread model: posix
> gcc version 4.6.0 20100907 (experimental) [trunk revision 163940]
> (GCC)
>



More information about the Fortran mailing list