File: equiv_init_1.f90

package info (click to toggle)
gcc-arm-none-eabi 15%3A12.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 959,712 kB
  • sloc: cpp: 3,275,382; ansic: 2,061,766; ada: 840,956; f90: 208,513; makefile: 76,132; asm: 73,433; xml: 50,448; exp: 34,146; sh: 32,436; objc: 15,637; fortran: 14,012; python: 11,991; pascal: 6,787; awk: 4,779; perl: 3,054; yacc: 338; ml: 285; lex: 201; haskell: 122
file content (94 lines) | stat: -rw-r--r-- 1,720 bytes parent folder | download | duplicates (3)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
! Program to test initialization of equivalence blocks.  PR13742.
! Some forms are not yet implemented.  These are indicated by !!$

subroutine test0s
  character*10 :: x = "abcdefghij" 
  character*10 :: y
  equivalence (x,y)

  character*10 :: xs(10) 
  character*10 :: ys(10)
  equivalence (xs,ys)
  data xs /10*"abcdefghij"/

  if (y.ne."abcdefghij") STOP 1
  if (ys(1).ne."abcdefghij") STOP 2
  if (ys(10).ne."abcdefghij") STOP 3
end
  
subroutine test0
  integer :: x = 123
  integer :: y
  equivalence (x,y)
  if (y.ne.123) STOP 4
end

subroutine test1
  integer :: a(3)
  integer :: x = 1
  integer :: y
  integer :: z = 3
  equivalence (a(1), x)
  equivalence (a(3), z)
  if (x.ne.1) STOP 5
  if (z.ne.3) STOP 6
  if (a(1).ne.1) STOP 7
  if (a(3).ne.3) STOP 8
end

subroutine test2
  integer :: x
  integer :: z
  integer :: a(3) = 123
  equivalence (a(1), x)
  equivalence (a(3), z)
  if (x.ne.123) STOP 9
  if (z.ne.123) STOP 10
end

subroutine test3
  integer :: x
!!$  integer :: y = 2
  integer :: z
  integer :: a(3)
  equivalence (a(1),x), (a(2),y), (a(3),z)
  data a(1) /1/, a(3) /3/
  if (x.ne.1) STOP 11
!!$  if (y.ne.2) STOP 12
  if (z.ne.3) STOP 13
end

subroutine test4
  integer a(2)
  integer b(2)
  integer c
  equivalence (a(2),b(1)), (b(2),c)
  data a/1,2/
  data c/3/
  if (b(1).ne.2) STOP 14
  if (b(2).ne.3) STOP 15
end

!!$subroutine test5
!!$  integer a(2)
!!$  integer b(2)
!!$  integer c
!!$  equivalence (a(2),b(1)), (b(2),c)
!!$  data a(1)/1/
!!$  data b(1)/2/
!!$  data c/3/
!!$  if (a(2).ne.2) STOP 16
!!$  if (b(2).ne.3) STOP 17
!!$  print *, "Passed test5"
!!$end
  
program main
  call test0s
  call test0
  call test1
  call test2
  call test3
  call test4
!!$  call test5
end