Internal compiler error with forall, pack and spread

Here is a valid Fortran 95 program:

program test_pack

  implicit none

  integer, parameter:: iim = 16, jjm = 12, klon = klon = iim * (jjm - 1) + 2
  integer, parameter:: n_plev = 15
  real v1(jjm + 1, 0:n_plev)
  real v2(klon, 0:n_plev)
  integer k
  logical, save:: dyn_phy(iim + 1, jjm + 1)

  !--------------------------------------------

  v1 = 3.

  dyn_phy = .true.
  dyn_phy(2:, 1) = .false.
  dyn_phy(2:, jjm + 1) = .false.
  dyn_phy(iim + 1, 2:jjm) = .false.

  forall (k = 0:n_plev) v2(:, k) = pack(spread(v1(:, k), dim = 1, &
       ncopies = iim + 1), dyn_phy)

end program test_pack

Here is the version of the Fortran compiler I use:

$ 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.

Compilation produces an internal compiler error:

$ pgfortran -Mfree test_pack.f
PGF90-S-0000-Internal compiler error. shape_comm: array expression is not supported     141 (test_pack.f: 21)
PGF90-F-0000-Internal compiler error. convert_subscript: it must be array       0 (test_pack.f: 21)
PGF90/x86-64 Linux 13.10-0: compilation aborted

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

NB : no problem with other compilers, nagfor, gfortran and ifort.

Hi Lionel GUEZ,

I’ve sent this off to our compiler engineers for advice. Given the error message, it appears to be a known limitation, but I want to get more input before deciding the best course of action.

  • Mat