Internal compiler error with array-valued function

Hello. Here is a test Fortran program:

module regr12_conserv_m
  implicit none
contains
  subroutine regr12_conserv(xt, vt)
    real, intent(in):: xt(:)
    real, intent(in):: vt(:)
    integer n2
    n2 = 4
    print *, mean_lin(3.)
  contains
    function mean_lin(a)
      real, intent(in):: a
      real mean_lin(n2)
      mean_lin = 1.
    end function mean_lin
  end subroutine regr12_conserv
end module regr12_conserv_m

I am confident that this code is valid in Fortran 95. The internal function is array-valued. Its shape is explicit. Its size is given by a variable from the host program unit.

With the following version of pgfortran:

$ pgfortran -V

pgfortran 13.10-0 64-bit target on x86-64 Linux -tp istanbul
The Portland Group - PGI Compilers and Tools
Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.

here is the result of trying to compile this test code:

$ pgfortran -Mfree -c regr12_conserv.f
PGF90-F-0000-Internal compiler error. interf:new_symbol_and_link, symbol not found 608 (regr12_conserv.f: 8)
PGF90/x86-64 Linux 13.10-0: compilation aborted

Please note that there is no problem with the other compilers I have access to: ifort, nagfor, gfortran.

I think this is a bug of the compiler. Is it corrected in more recent versions of the compiler?

Hi Lionel GUEZ,

Thanks for the report. We have not seen this error before and it does still occur in our current (15.10) compiler version. It looks like it’s a very specific problem only occurring when the function result variable is an automatic array and the size of the array is a local variable in the parent. If you declare “n2” as a module variable, pass “n2” as an argument to “mean_lin”, or declare “mean_lin” with a fixed size, then the compilation error goes away.

I added a problem report (TPR#22237) and sent it on to our compiler engineers for further investigation.

Best regards,
Mat

Lionel,

In January, you sent a problem logged as

TPR 22237 - UF: ICE “interf:new_symbol_and_link, symbol not found 608” when using a contained function

This problem is fixed in the current 16.4 release.


thanks,
dave