Fortran: expression in norm2 not allowed

The following program should be valid but does not compile with PGI 19.10 on linux:

program norm2_expression
  
  implicit none
  real, dimension(9,9) :: a,b

  call random_number(a)
  call random_number(b)

  print*, norm2(a-b)

end program norm2_expression

the error is

PGF90-S-0000-Internal compiler error. transform_call:Array Expression can't be here      30  (norm2_expression.f90: 9)
  0 inform,   0 warnings,   1 severes, 0 fatal for norm2_expression

Thanks Martin.

NORM2 was just added in 19.7 and this looks like a compiler issue where it’s not accepting array expressions as an argument. I’ve logged this error as TPR#27996.

The work around would be:

program norm2_expression

  implicit none
  real, dimension(9,9) :: a,b,c

  call random_number(a)
  call random_number(b)

#ifdef WORKS
  c=a-b
  print*, norm2(c)
#else
  print*, norm2(a-b)
#endif

end program norm2_expression

-Mat