main
| Line | |
|---|
| 1 | ! Variables in named common blocks drop out of scope
|
|---|
| 2 | ! (become undefined) at the END statement, unless they
|
|---|
| 3 | ! are still referenced somewhere else. See F77 Sec 15.8.4
|
|---|
| 4 | ! The second call therefore reads an uninitialized variable.
|
|---|
| 5 | PROGRAM MAIN
|
|---|
| 6 | REAL X
|
|---|
| 7 | X = 1.0
|
|---|
| 8 | CALL SUB(X,1)
|
|---|
| 9 | CALL SUB(X,2)
|
|---|
| 10 | WRITE(*,*) X
|
|---|
| 11 | END
|
|---|
| 12 |
|
|---|
| 13 | SUBROUTINE SUB(X,FLAG)
|
|---|
| 14 | INTEGER FLAG
|
|---|
| 15 | REAL X
|
|---|
| 16 | COMMON /MC/ Y
|
|---|
| 17 | IF(FLAG .eq. 1) THEN
|
|---|
| 18 | Y = X * 2
|
|---|
| 19 | ELSE
|
|---|
| 20 | X = Y
|
|---|
| 21 | ENDIF
|
|---|
| 22 | END
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.