Subroutines using CLASS

Hi all,

I wanted to hear about other users and devs experience on the status of polymorphism with PGF-18.x.

During my current code development I have found several ICEs and PGF runtime segfaults associated to using routines with multiple CLASS declarations. This is inside a somewhat involved OO fortran code, but to give an example of what the offending code looks like:

type foo_class
real :: a
contains
procedure,pass(foo) :: foobar
end

subroutine foobar(foo,bar)
class(foo_class) :: foo
class(bar_class) :: bar
...
end
...
type(foo_class) :: a
type(bar_class) :: b
call a%foobar(b)

I’m not entirely sure about whether this is even valid FORTRAN. In principle, one could use subroutine foobar with any data type inheriting from foo_class or bar_class. And the routine could be used as a type bound routine from either type.

Anyways, calling this type of routine leads to ICEs. Optional arguments also seem to break the code. Keeping only one CLASS declaration seems to get rid of the problem. Additionally, CLASS declarations outside the module where the derived type is declared is also not working well.

We have had issues with classes and polymorphism over the years. We are taking steps to address those issues. If you could provide a complete failing test that we can compile here, we will certainly take a look at it.

  • Brent

Thank you for the response, I will try to extract and post an example. It seems somewhat involved right now, since it’s a large codebase.

If it’s too large to post, please feel free to send the examples to PGI Customer Service (trs@pgroup.com).

-Mat