Submodule matching error of declaration

Next bug, again with submodules. This one appears to be a related to the use of the optional and target attributes for an allocatable intent(out) array for a derived type.

The following code results in a compile error:

module tecplotIOMod
  implicit none

  type tecZoneType
     integer :: type
  end type tecZoneType

  interface
     module subroutine readTecFE(outZones)
       type(tecZoneType), dimension(:), allocatable, intent(out), optional, target :: outZones
     end subroutine readTecFE
  end interface
end module tecplotIOMod

submodule(tecplotIOMod) tecplotIOSubMod
  implicit none
contains
  module subroutine readTecFE(outZones)
    type(tecZoneType), dimension(:), allocatable, intent(out), optional, target :: outZones
  end subroutine readTecFE
end submodule tecplotIOSubMod

program main
  use tecplotIOMod
  print *,'Hello World'
end program main

The definition of outZones is exactly the same between the module and submodule definitions, but I still get the compile error:

NVFORTRAN-S-1058-The type of definition argument outzones does not match its declaration type (main.F90: 18)
  0 inform,   0 warnings,   1 severes, 0 fatal for readtecfe

It will compile if remove target attribute. I was able to refactor the code remove the need for target attribute.

Thanks,
Gaetan

Thanks Gaetan. I added a new report , TPR #31660.

Has there been any movement on this bug (TPR #31660)? I’m getting the same error with nvfortran 24.1-0, caused by the target attribute.

Hi brandon!

No sorry, no update and I’m not sure they’ll fix it in nvfortran. They might, but most of engineering’s effort are working on our collaboration with the LLVM community’s “new flang” which will eventually replace nvfortran. The code compiles correctly with flang.

I did miss posting the following work around:

As a work around, they can change the “module subroutine readTecFE(outZones)” form in submodule tecplotIOSubMod to the “module procedure” form (which implies the arguments from the interface in the parent module). For example,

module procedure readTecFE
! procedure code body here
end procedure readTecFE

-Mat

Hi Gaetan and Brandon,

Good news, engineering was able to get this fixed in nvfortran as part of the 24.9 release.

% nvfortran -c test.F90 -V24.7
NVFORTRAN-S-1058-The type of definition argument outzones does not match its declaration type (test.F90: 18)
  0 inform,   0 warnings,   1 severes, 0 fatal for readtecfe
% nvfortran -c test.F90 -V24.9
%

-Mat