- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to use generic interface with same name as derived type, but it does not work with an Intel compiler in some cases. I have read
https://software.intel.com/en-us/forums/topic/283849
https://software.intel.com/en-us/forums/topic/271401
but I am still getting errors. I have originally got the codes list.f90 and link.f90 from
https://www.pgroup.com/lit/samples/list.f90
https://www.pgroup.com/lit/samples/link.f90
to understand
4. Case Study: Data Polymorphic Linked List
https://www.pgroup.com/lit/articles/insider/v3n2a2.htm
I can compile the original codes with
/opt/pgi/linux86-64/13.2/bin/pgf90
but not with
/opt/intel/composer_xe_2013_sp1.2.144/bin/intel64/ifort
Therefore, I have simplified the code to reproduce the error. When I compile the codes link_simple.f90
module link_mod implicit none private public :: link, constructor type link private class(*), pointer :: value => null() ! value stored in link type(link), pointer :: next => null()! next link in list contains procedure :: nextLink ! return next pointer end type link interface link module procedure constructor ! construct/initialize a link end interface contains function nextLink(this) class(link) :: this class(link), pointer :: nextLink nextLink => this%next end function nextLink function constructor(value, next) class(link),pointer :: constructor class(*) :: value class(link), pointer :: next allocate(constructor) constructor%next => next allocate(constructor%value, source=value) end function constructor end module link_mod
and list_simple.f90
module list_mod use link_mod implicit none private public :: list type list private class(link), pointer :: firstLink => null() ! first link in list class(link), pointer :: lastLink => null() ! last link in list contains procedure :: addValue ! add class(*) to linked list end type list contains subroutine addValue(this, value) class(list) :: this class(*) :: value class(link), pointer :: newLink ! newLink => link(value, this%firstLink) ! this works newLink => link(value, this%lastLink%nextLink()) ! this doesn't work ! newLink => constructor(value, this%lastLink%nextLink()) ! this works end subroutine addValue end module list_mod
I get the errors
$ which ifort /opt/apps/intel/13/composer_xe_2013.2.146/bin/intel64/ifort $ ifort -c link_simple.f90 list_simple.f90 list_simple.f90(23): error #6292: The parent type of this field is use associated with the PRIVATE fields attribute [VALUE] newLink => link(value, this%lastLink%nextLink()) ! this doesn't work --------------------^ list_simple.f90(23): error #6292: The parent type of this field is use associated with the PRIVATE fields attribute newLink => link(value, this%lastLink%nextLink()) ! this doesn't work ---------------------------^ list_simple.f90(23): error #6680: A constant is not permitted in this context. newLink => link(value, this%lastLink%nextLink()) ! this doesn't work ---------------^ compilation aborted for list_simple.f90 (code 1)
I can compile the codes when using line 21 or 23, instead of 22, of list_simple.f90.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tested your code using 15.x and still getting errors with the overloaded structure constructor. Hopefully one of the Intel folks will get back to you, because IMHO this is definitely a compiler bug.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(I could not figure out how to edit question, so I am leaving a comment.)
I have just learned that I am supposed to write the versions of compilers as
pgf90 13.2-0 64-bit target on x86-64 Linux -tp sandybridge
and
ifort version 13.1.0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should try using the most up to date compiler, it may have been fixed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I should have known this before asking question, but according to
the most up to date compiler is 15.0.0, which I don't have. I have realized that I can use 14.0.2, but I am still getting the same errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tested your code using 15.x and still getting errors with the overloaded structure constructor. Hopefully one of the Intel folks will get back to you, because IMHO this is definitely a compiler bug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for testing the codes using 15.x.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We'll take a look.

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