source:
CIVL/mods/dev.civl.abc/examples/fortran/commonblock/common_preservation.f
| Last change on this file was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 372 bytes | |
| Line | |
|---|---|
| 1 | ! Variables in the nameless comon block stay in scope between |
| 2 | ! calls to SUB |
| 3 | PROGRAM MAIN |
| 4 | REAL X |
| 5 | X = 1.0 |
| 6 | CALL SUB(X,1) |
| 7 | CALL SUB(X,2) |
| 8 | WRITE(*,*) X |
| 9 | END |
| 10 | |
| 11 | SUBROUTINE SUB(X,FLAG) |
| 12 | INTEGER FLAG |
| 13 | REAL X |
| 14 | COMMON Y |
| 15 | IF(FLAG .eq. 1) THEN |
| 16 | Y = X * 2 |
| 17 | ELSE |
| 18 | X = Y |
| 19 | ENDIF |
| 20 | END |
Note:
See TracBrowser
for help on using the repository browser.
