-Msave broken in CE19.10

The -Msave flag is no longer working properly. This used to work in CE19.4 and prior. The little program below illustrates the problem. The value of ‘j’ in sub1 is not preserved call to call.

! pgf90 -g -Msave -o pgi_msave_bug.exe pgi_msave_bug.f90
program msave_bug

  i = 0
  print *,'i = ',i
  call sub1(i)
  i = 2
  print *,'i = ',i
  call sub1(i)
end program msave_bug

subroutine sub1(i)

  if(i.lt.1)j=555

  print *,'j should equal 555, j = ',j
end subroutine sub1

pgf90 19.10-0 LLVM 64-bit target on x86-64 Linux -tp nehalem
centos7 3.10.0-514.el7.x86_64

Hi MikeS,

Thanks for the report. I was able to recreate the issue here and have filed a problem report (TPR #28164) and sent it to our compiler engineers for further investigation. Looks to be a new problem with 19.10.

As a work-around, you can explicitly declare “j” with the save attribute. i.e. “integer, save :: j”.

-Mat

Do you happen to know which versions of the compiler this happens for? I want to inform my user base of the problem and which compiler versions to be concerned about. Is it just 19.10 and up?

I wish a simple SAVE command was all I had to do. The simulation code base I work with has hundred plus files that this affects.

I want to inform my user base of the problem and which compiler versions to be concerned about. Is it just 19.10 and up?

Correct, your example works with 19.9 but fails with 19.10 and 20.1.

% pgfortran -Msave save.F90 -V19.9; a.out
 i =             0
 j should equal 555, j =           555
 i =             2
 j should equal 555, j =           555
% pgfortran -Msave save.F90 -V19.10 ; a.out
 i =             0
 j should equal 555, j =           555
 i =             2
 j should equal 555, j =             0
% pgfortran -Msave save.F90 -V20.1 ; a.out
 i =             0
 j should equal 555, j =           555
 i =             2
 j should equal 555, j =             0

Should be corrected in the HPC SDK 20.5 EA