- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear readers,
I stumbled into the following problem when trying to implement a dynamic array type, similar to the approach in FLIBs vector, but using F2008 objects.
When I use two different vectors in one program unit (e.g. one for integer and one for real numbers), the compiler gets mixed up with names an types.
I reduced the problem to the code below:
!
! RDATA: Define Data Types to be stored in the vectors
!
MODULE RDATA
TYPE REAL_DATA
REAL :: VALUE
END TYPE REAL_DATA
TYPE INT_DATA
INTEGER :: VALUE
END TYPE INT_DATA
END MODULE RDATA
!----------------------------------------
!
! Module V: Define a VECTOR class for REAL_DATA
!
MODULE V
USE RDATA, VECTOR_TYPE => REAL_DATA
!---- (this is the same in V and W and would be INCLUDEd)
PRIVATE
PUBLIC :: VECTOR
TYPE VECTOR
TYPE(VECTOR_TYPE) :: n
CONTAINS ! (TYPE VECTOR)
PROCEDURE, PUBLIC :: put => vector_put
END TYPE VECTOR
CONTAINS
SUBROUTINE vector_put(this, ddd)
CLASS(VECTOR), INTENT(INOUT) :: this
TYPE(VECTOR_TYPE), INTENT(IN) :: ddd
this % n = ddd
END SUBROUTINE vector_put
!----
END MODULE V
!----------------------------------------
!
! Module W: Define a VECTOR class for INT_DATA
!
MODULE W
USE RDATA, VECTOR_TYPE => INT_DATA
!---- (this is the same in V and W and would be INCLUDEd)
PRIVATE
PUBLIC :: VECTOR
TYPE VECTOR
TYPE(VECTOR_TYPE) :: n
CONTAINS ! (TYPE VECTOR)
PROCEDURE, PUBLIC :: put => vector_put
END TYPE VECTOR
CONTAINS
SUBROUTINE vector_put(this, ddd)
CLASS(VECTOR), INTENT(INOUT) :: this
TYPE(VECTOR_TYPE), INTENT(IN) :: ddd
this % n = ddd
END SUBROUTINE vector_put
!----
END MODULE W
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PROGRAM test_vector
USE RDATA
USE W, INTVECTOR => VECTOR ! Import the Integer Vector of W as INTVECTOR
USE V, REALVECTOR => VECTOR ! Import the Real Vector of W as REALVECTOR
IMPLICIT NONE
TYPE (REALVECTOR) :: rv
TYPE (INTVECTOR) :: iv
call rv%put(REAL_DATA(99.0)) ! ERROR. If I USE V first, this line passes and the error occurs on the next one.
call iv%put(INT_DATA(99))
END PROGRAM test_vector
The compilation aborts with the following error
testprog.f90(87): error #6633: The type of the actual argument differs from the type of the dummy argument.
call rv%put(REAL_DATA(99.0))
------------------^
compilation aborted for testprog.f90 (code 1)
If I comment out all references to the integer "vector" (i.e. USE statement, iv definition and the call to iv % put below), the line compiles as it should.
As a Workaround, I can #define a name for VECTOR, #define the data type for the vector and #include the common code .
Compiler Version: ifort (IFORT) 14.0.1 20131008 on a Linux64 system.
Best regards,
Christopher
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, we'll investigate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It looks as if the fix for this is already in what is planned for Update 3, scheduled for late April. I verified that the compilation fails in the current version but passes in our internal build.

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