Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | ! Copyright 2016-2020 Free Software Foundation, Inc. |
9920b434 BH |
2 | |
3 | ! This program is free software; you can redistribute it and/or modify | |
4 | ! it under the terms of the GNU General Public License as published by | |
5 | ! the Free Software Foundation; either version 3 of the License, or | |
6 | ! (at your option) any later version. | |
7 | ! | |
8 | ! This program is distributed in the hope that it will be useful, | |
9 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | ! GNU General Public License for more details. | |
12 | ! | |
13 | ! You should have received a copy of the GNU General Public License | |
14 | ! along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | program vla_struct | |
17 | type :: one | |
18 | integer, allocatable :: ivla (:, :, :) | |
19 | end type one | |
20 | type :: two | |
21 | integer, allocatable :: ivla1 (:, :, :) | |
22 | integer, allocatable :: ivla2 (:, :) | |
23 | end type two | |
24 | type :: three | |
25 | integer :: ivar | |
26 | integer, allocatable :: ivla (:) | |
27 | end type three | |
28 | type :: four | |
29 | integer, allocatable :: ivla (:) | |
30 | integer :: ivar | |
31 | end type four | |
32 | type :: five | |
33 | type(one) :: tone | |
34 | end type five | |
35 | ||
36 | type(one), target :: onev | |
37 | type(two) :: twov | |
38 | type(three) :: threev | |
39 | type(four) :: fourv | |
40 | type(five) :: fivev | |
8f07e298 BH |
41 | type(five) :: fivearr (2) |
42 | type(five), allocatable :: fivedynarr (:) | |
9920b434 BH |
43 | logical :: l |
44 | integer :: i, j | |
45 | ||
46 | allocate (onev%ivla (11,22,33)) ! before-allocated | |
47 | l = allocated(onev%ivla) | |
48 | ||
49 | onev%ivla(:, :, :) = 1 | |
50 | onev%ivla(1, 2, 3) = 123 | |
51 | onev%ivla(3, 2, 1) = 321 | |
52 | ||
53 | allocate (twov%ivla1 (5,12,99)) ! onev-filled | |
54 | l = allocated(twov%ivla1) | |
55 | allocate (twov%ivla2 (9,12)) | |
56 | l = allocated(twov%ivla2) | |
57 | ||
58 | twov%ivla1(:, :, :) = 1 | |
59 | twov%ivla1(1, 2, 3) = 123 | |
60 | twov%ivla1(3, 2, 1) = 321 | |
61 | ||
62 | twov%ivla2(:, :) = 1 | |
63 | twov%ivla2(1, 2) = 12 | |
64 | twov%ivla2(2, 1) = 21 | |
65 | ||
66 | threev%ivar = 3 ! twov-filled | |
67 | allocate (threev%ivla (20)) | |
68 | l = allocated(threev%ivla) | |
69 | ||
70 | threev%ivla(:) = 1 | |
71 | threev%ivla(5) = 42 | |
72 | threev%ivla(14) = 24 | |
73 | ||
74 | allocate (fourv%ivla (10)) ! threev-filled | |
75 | l = allocated(fourv%ivla) | |
76 | ||
77 | fourv%ivar = 3 | |
78 | fourv%ivla(:) = 1 | |
79 | fourv%ivla(2) = 2 | |
80 | fourv%ivla(7) = 7 | |
81 | ||
82 | allocate (fivev%tone%ivla (10, 10, 10)) ! fourv-filled | |
83 | l = allocated(fivev%tone%ivla) | |
84 | fivev%tone%ivla(:, :, :) = 1 | |
85 | fivev%tone%ivla(1, 2, 3) = 123 | |
86 | fivev%tone%ivla(3, 2, 1) = 321 | |
87 | ||
8f07e298 BH |
88 | allocate (fivearr(1)%tone%ivla (2, 4, 6)) ! fivev-filled |
89 | allocate (fivearr(2)%tone%ivla (12, 14, 16)) | |
90 | fivearr(1)%tone%ivla(:, :, :) = 1 | |
91 | fivearr(1)%tone%ivla(2, 2, 3) = 223 | |
92 | fivearr(2)%tone%ivla(:, :, :) = 2 | |
93 | fivearr(2)%tone%ivla(6, 7, 8) = 678 | |
94 | ||
95 | allocate (fivedynarr(2)) ! fivearr-filled | |
96 | allocate (fivedynarr(1)%tone%ivla (2, 4, 6)) | |
97 | allocate (fivedynarr(2)%tone%ivla (12, 14, 16)) | |
98 | fivedynarr(1)%tone%ivla(:, :, :) = 1 | |
99 | fivedynarr(1)%tone%ivla(2, 2, 3) = 223 | |
100 | fivedynarr(2)%tone%ivla(:, :, :) = 2 | |
101 | fivedynarr(2)%tone%ivla(6, 7, 8) = 678 | |
102 | ||
103 | l = allocated(fivedynarr) ! fivedynarr-filled | |
9920b434 | 104 | end program vla_struct |