Compiler error message: PGF90-S-0087-Non-constant expression

Dear all,

I’m getting from the pgf90 compiler the error message:
PGF90-S-0087-Non-constant expression where constant expression required
(bb.f90: 1)
PGF90-S-0081-Illegal selector - KIND parameter has unknown value for
data type (bb.f90: 1)

This error message comes from the line:
real(prec) function bb
it looks like the real(prec) is evaluated before the declaration of of the variables in the body of the function or the variables in the use statements are evaluated.
When I declare the return type inside the body of the function the function compiles (see cc.f90).
I’ve below the commands + generated output as well as the used source files.

Is this a bug in the pgf90 compiler (version 11.1) ? As other compilers don’t complain.

Best Regards,

Albert

=============== compiler commands and results =======
$ pgf90 aa.f90 -c
$ pgf90 bb.f90 -c
PGF90-S-0087-Non-constant expression where constant expression required
(bb.f90: 1)
PGF90-S-0081-Illegal selector - KIND parameter has unknown value for
data type (bb.f90: 1)
0 inform, 0 warnings, 2 severes, 0 fatal for bb

$ pgf90 -c cc.f90

================ aa.f90 ======================
module aa
INTEGER, parameter :: prec = kind(1.0D0)
end module
================ bb.f90 ======================
real(prec) function bb
use aa

bb = 7.3D1
end function
================ cc.f90 ======================
function bb
use aa
real(prec) bb

bb = 7.3D1
end function

Hi Albert,

We are aware of the issue, though, it’s not really a bug. The standard’s a bit contradictory here. It states that when variables found in external modules are accessed, the ‘use’ statement must precede the actual use. However, it also seems to have relaxed this criteria for this one case. We are looking into how to support this feature but no firm date when it will be available.

Best Regards,
Mat