- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RHEL 5.4, 64-bit. Compiler version 12.0.3.
I have a derived type, which is used to pass an argument from a program to a subroutine.
Here is the definition of the derived type, which resides in x.crd
type x_t
integer*4 i
end type
The subroutine, in s.for, is:
subroutine s(x)
implicit none
include 'x.crd'
type(x_t)::x
type *, x
end
And the main program, in m.for, is
program m
implicit none
include 'x.crd'
type(x_t)::x
call s(x)
end
I have IFORTCFG set to nothing. I run these commands, and get the error shown:
$ ifort -c -warn interface s.for
$ifort -c -warn interface m.for
m.for(5): error #6633: The type of the actual argument differs from the type of the dummy argument.
call s(x)
---------------^
compilation aborted for m.for (code 1)
Here is the generated interface block, from s__genmod.f90
!COMPILER-GENERATED INTERFACE MODULE: Tue May 10 14:25:57 2011
MODULE S__genmod
INTERFACE
SUBROUTINE S(X)
TYPE X_T
INTEGER(KIND=4) :: I
END TYPE X_T
TYPE (X_T) :: X
END SUBROUTINE S
END INTERFACE
END MODULE S__genmod
What is the compiler complaining about?
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Section 5.1.1.1 of the standard says:
8 Where a data entity is declared explicitly using the TYPE type specifier, the specified derived type shall
9 have been defined previously in the scoping unit or be accessible there by use or host association.
That may seem to shed little light on the issue, so consider this reinterpretation in Metcalf, Reid and Cohen's book, 'Fortran 95/2003 Explained':
Different declarations of a TYPE, even if the declarations are identical, do not create argument-compatible types (with few exceptions). That is why it is necessary to create a single definition, in a module if necessary, and USE that definition wherever it is needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page