In this simple example, ipr1 never gets set to the right value.
2 read *,ipr
go to 2
ipr1=ipr2 ! never gets executed
However, the problem goes away when I use a DATA statement to initialize ipr2.
Is this something in the compiler ?
IPR2 in the subroutine is a local variable. By default, it is not saved, and it becomes undefined whenever the subroutine is entered. The program is invalid because it uses the undefined value. For the same reason, in this case there is no "right value".
Adding a DATA statement to the subroutine gives the variable IPR2 the SAVE attribute. The program now is, as a result, predictable and standard conforming.
The compiler will help you catch this bug at run time if you use the /check option.
The comment "never gets executed" is not correct. You can step through the program using the debugger to verify that, after compiling with /debug or /Zi.