File: common_23.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (31 lines) | stat: -rw-r--r-- 857 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
! Test: Blank (unnamed) COMMON block (F2018 8.10.3.1)
! The blank common block (declared without a name) is a special case that
! provides global storage shared across all program units. Unlike named
! COMMON blocks, blank common cannot be initialized in BLOCK DATA.
program common_23
    implicit none
    integer :: i, j
    real :: x
    common i, j, x  ! Blank common (no name)

    i = 42
    j = 84
    x = 3.14

    call sub_blank_access()
    if (i /= 100) error stop "i should be 100 after subroutine"
    print *, "PASS: common_23"
end program

subroutine sub_blank_access()
    implicit none
    integer :: a, b
    real :: c
    common a, b, c  ! Same blank common

    if (a /= 42) error stop "a should be 42"
    if (b /= 84) error stop "b should be 84"
    if (abs(c - 3.14) > 0.001) error stop "c should be 3.14"

    a = 100
end subroutine