Issue with real function and parameter statment

I have some code which I am trying to compile with pgfortran 15.1 on 64-bit Linux. However, I am running into a small issue. I’m not sure if it is something I am misunderstanding or what.

In my code I declare a couple of arrays parameters and use them to calculate another parameter. In this calculation, I have to call the real function to convert an array of integers to reals.

However, when the array is declared as a parameter (and initialized inline), the real function call does not iterate through array, but does when the array is without the parameter statement (and initialized in the function).

I’ve written a very simple version of this

program test
    implicit none
    integer, dimension(2,2), parameter :: vals = &
        reshape([ [4, 16], [5, 25] ], [2, 2])
    real, dimension(2,2), parameter :: ones = &
        reshape([ [1., 1.], [1., 1.] ], [2, 2])
    real, dimension(2,2), parameter :: paramarr = ones + real(vals)
    real, dimension(2,2) :: testarr

    testarr = ones + real(vals)

    print *, "Correct output"
    print *, 5., 17. 6., 26.
    print *, "Without parameter statement"
    print *, testarr
    print *, "With parameter statement"
    print *, paramarr

end program test

And the output I get is

 Correct output
    5.000000        17.00000        6.000000        26.00000    
 Without parameter statement
    5.000000        17.00000        6.000000        26.00000    
 With parameter statement
    5.000000        5.000000        5.000000        5.000000

Is this something I am misunderstanding or possibly a bug?

Hi AllyssaLee,

Thanks for the report. This looks like a PGI compiler issues, hence I wrote up a report, TPR#22042, and sent it to our compiler engineers for further investigation.

Best Regards,
Mat

TPR 22042 - UF: User code gets wrong results when initializing a parameter array .

This problem is now fixed in the current 17.7 release.

dave

Thanks for the report. This looks like a PGI compiler issues, hence I wrote up a report, TPR#22042, and sent it to our compiler engineers for further investigation.

Best Regards
Cash for cars los angeles

Yes, the problem reported in 15.1 has been replicated and is fixed in the
17.7 release. If you do not have access to the 17,7 professional releases,
you can wait for the next Community Edition in 17.10, which should be out in October.

dave