allocation of a fortran classes array

Dear PGI, i have some problems with the following code, the result is
Segmentation fault: 11

When c_process array is declared outside the simulation type it works.

threads and thread_id are set to one but in the real code it is controlled by openmp.

Other problem, i can’t toggle on the notification when somebody answers
to my post. The message is
“Sorry, but this e-mail address is invalid.
The current password you supplied does not match that stored in the database.”
But there is no place to fill in email or password.

module m_process

implicit none

type, abstract :: c_process
  real :: t
  procedure(process_execution),  pass(self), deferred :: run
end type c_process

abstract interface
  subroutine process_execution(self, dt)
    import c_process
    class(c_process)    :: self
    real,    intent(in) :: dt
  end subroutine process_execution
end interface

type, extends(c_process) :: t_process
  procedure :: init => init_process
  procedure :: run  => run_process
end type t_process


subroutine init_process(self)
  class(t_process) :: self
  self%t = 0.0
end subroutine init_process

subroutine run_process(self, dt)
  class(t_process)     :: self
  real, intent(in)    :: dt
  self%t = self%t + dt
end subroutine run_process

end module m_process


module m_simulation

use m_process

implicit none

type :: t_simulation
  class(c_process), pointer :: process(:)
  integer                   :: np
  procedure :: init => init_simulation
  procedure :: run  => run_simulation
end type t_simulation


subroutine init_simulation(self, np)
  class(t_simulation) :: self
  integer, intent(in) :: np

  self%np = np
  allocate( t_process :: self%process(np))

end subroutine init_simulation

subroutine run_simulation(self, n)
  class(t_simulation) :: self
  integer, intent(in) :: n

  integer :: i, ip
  real    :: dt = 0.2

  do ip = 1, self%np
    do i = 1, n
      call self%process(ip)%run(dt)
    end do
  end do

  print*, self%process%t

end subroutine run_simulation

end module m_simulation


program test
use m_process
use m_simulation

implicit none

type(t_simulation) :: sim

integer :: nthreads, thread_id

nthreads  = 1
thread_id = 1

call sim%init(nthreads)

select type ( p => sim%process(thread_id) )
type is ( t_process )
call p%init()
end select

call sim%run(5)

end program test

replicated and logged as TPR 23787. The failure occurs with
call sim%run(5) at line 108.


TPR 23787 - OpenMP program segfaults “call sim%run(5)”

has been fixed in the current 17.9 release.