Fortran: allocatable derived types in submodules

The following code in a submodule does not link with PGI 19.10 on Linux:

submodule(moduleA) submoduleA
  implicit none
  type :: tType
    integer :: i
  end type tType

  type(tType), allocatable, dimension(:) :: x
  type(tType)                            :: y
  real,        allocatable, dimension(:) :: z


subroutine submoduleA_init
  print*, 'submoduleA_init'
  allocate(x(5))                     ! this does not work
  x(1)%i = 1
  y%i = 1
end subroutine submoduleA_init

end submodule submoduleA

The error is

/usr/bin/ld: CMakeFiles/main.dir/submoduleA.f90.o: in function `modulea__submodulea_submodulea_init_':
/home/m/Desktop/PGI_error/submodule-allocate-type/src/submoduleA.f90:15: undefined reference to `modulea__submodulea_ttype_td_'
/usr/bin/ld: /home/m/Desktop/PGI_error/submodule-allocate-type/src/submoduleA.f90:15: undefined reference to `modulea__submodulea_ttype_td_'

I’ve created a minimal working example (consists of several files, including a shell script for compilation) and uploaded it to
If someone from PGI has downloaded it or if you are not interested, please let me know because I want to delete the link

Thanks Martin. I’ve download the files so please feel free to delete the link.

I was able to reproduce the issue and have added a problem report (TPR#27994).

Submodules are a new feature so there are likely some issues still to address.


many thanks!

Fixed with PGI 20.3