File: common_26.f90

package info (click to toggle)
lfortran 0.60.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,412 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 37; javascript: 15
file content (50 lines) | stat: -rw-r--r-- 891 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
program common_26
  implicit none

  ! All Fortran standards allow the size of blank common to vary between
  ! program units - from F66 (7.2.1.3) to F2023 (8.10.2.5).

  real :: pi, epsilon, sq2
  common // pi, epsilon, sq2

  pi = 3.1415654
  epsilon = 2.718281828
  sq2 = 1.414213562

  call print_pi ()
  call print_eps ()
  call print_sq2 ()

  print *, "All tests passed"

end program

subroutine print_pi ()
  implicit none

  real :: pi
  common  pi

  if (abs(pi - 3.1415654) > 1.0e-6) error stop "Wrong pi value"

end subroutine

subroutine print_eps ()
  implicit none

  real :: dummy, eps
  common  dummy, eps

  if (abs(eps - 2.718281828) > 1.0e-6) error stop "Wrong epsilon value"

end subroutine

subroutine print_sq2 ()
  implicit none

  real :: dummy(2), sq2
  common  dummy,    sq2

  if (abs(sq2 - 1.414213562) > 1.0e-6) error stop "Wrong sqrt(2) value"

end subroutine