|
3 | 3 |
|
4 | 4 | contains
|
5 | 5 |
|
| 6 | +#ifndef _CRAYFTN |
6 | 7 | module procedure construct
|
7 | 8 |
|
8 | 9 | select rank(array)
|
|
59 | 60 |
|
60 | 61 | end procedure
|
61 | 62 |
|
| 63 | + pure function one_allocated_component(self) result(one_allocated) |
| 64 | + type(intrinsic_array_t), intent(in) :: self |
| 65 | + logical one_allocated |
| 66 | + one_allocated = count( & |
| 67 | + [ allocated(self%complex_1D), allocated(self%complex_double_1D), allocated(self%integer_1D), allocated(self%logical_1D), & |
| 68 | + allocated(self%real_1D), allocated(self%complex_2D), allocated(self%complex_double_2D), allocated(self%integer_2D), & |
| 69 | + allocated(self%logical_2D), allocated(self%real_2D), allocated(self%complex_3D), allocated(self%complex_double_3D), & |
| 70 | + allocated(self%integer_3D), allocated(self%logical_3D), allocated(self%real_3D) & |
| 71 | + ]) |
| 72 | + end function |
| 73 | + |
62 | 74 | module procedure as_character
|
63 | 75 | integer, parameter :: single_number_width=32
|
64 | 76 |
|
65 |
| - if (1 /= count( & |
66 |
| - [ allocated(self%complex_1D), allocated(self%complex_double_1D), allocated(self%integer_1D), & |
67 |
| - allocated(self%logical_1D), allocated(self%real_1D), & |
68 |
| - allocated(self%complex_2D), allocated(self%complex_double_2D), allocated(self%integer_2D), & |
69 |
| - allocated(self%logical_2D), allocated(self%real_2D), & |
70 |
| - allocated(self%complex_3D), allocated(self%complex_double_3D), allocated(self%integer_3D), & |
71 |
| - allocated(self%logical_3D), allocated(self%real_3D) & |
72 |
| - ])) error stop "intrinsic_array_t as_character: ambiguous component allocation status." |
| 77 | + if (.not. one_allocated_component(self)) error stop "intrinsic_array_s(as_character): invalid number of allocated components" |
73 | 78 |
|
74 | 79 | if (allocated(self%complex_1D)) then
|
75 | 80 | character_self = repeat(" ", ncopies = single_number_width*size(self%complex_1D))
|
|
130 | 135 | character_self = trim(adjustl(character_self))
|
131 | 136 | end procedure
|
132 | 137 |
|
| 138 | +#else |
| 139 | + |
| 140 | + module procedure complex_array |
| 141 | + |
| 142 | + select rank(array) |
| 143 | + rank(1) |
| 144 | + allocate(intrinsic_array%complex_1D, source = array) |
| 145 | + rank(2) |
| 146 | + allocate(intrinsic_array%complex_2D, source = array) |
| 147 | + rank(3) |
| 148 | + allocate(intrinsic_array%complex_3D, source = array) |
| 149 | + rank default |
| 150 | + error stop "intrinsic_array_t complex_array: unsupported rank" |
| 151 | + end select |
| 152 | + |
| 153 | + end procedure |
| 154 | + |
| 155 | + module procedure integer_array |
| 156 | + |
| 157 | + select rank(array) |
| 158 | + rank(1) |
| 159 | + allocate(intrinsic_array%integer_1D, source = array) |
| 160 | + rank(2) |
| 161 | + allocate(intrinsic_array%integer_2D, source = array) |
| 162 | + rank(3) |
| 163 | + allocate(intrinsic_array%integer_3D, source = array) |
| 164 | + rank default |
| 165 | + error stop "intrinsic_array_t integer_array: unsupported rank" |
| 166 | + end select |
| 167 | + |
| 168 | + end procedure |
| 169 | + |
| 170 | + module procedure logical_array |
| 171 | + |
| 172 | + select rank(array) |
| 173 | + rank(1) |
| 174 | + allocate(intrinsic_array%logical_1D, source = array) |
| 175 | + rank(2) |
| 176 | + allocate(intrinsic_array%logical_2D, source = array) |
| 177 | + rank(3) |
| 178 | + allocate(intrinsic_array%logical_3D, source = array) |
| 179 | + rank default |
| 180 | + error stop "intrinsic_array_t logical_array: unsupported rank" |
| 181 | + end select |
| 182 | + |
| 183 | + end procedure |
| 184 | + |
| 185 | + module procedure real_array |
| 186 | + |
| 187 | + select rank(array) |
| 188 | + rank(1) |
| 189 | + allocate(intrinsic_array%real_1D, source = array) |
| 190 | + rank(2) |
| 191 | + allocate(intrinsic_array%real_2D, source = array) |
| 192 | + rank(3) |
| 193 | + allocate(intrinsic_array%real_3D, source = array) |
| 194 | + rank default |
| 195 | + error stop "intrinsic_array_t real_array: unsupported rank" |
| 196 | + end select |
| 197 | + |
| 198 | + end procedure |
| 199 | + |
| 200 | + module procedure double_precision_array |
| 201 | + |
| 202 | + select rank(array) |
| 203 | + rank(1) |
| 204 | + allocate(intrinsic_array%double_precision_1D, source = array) |
| 205 | + rank(2) |
| 206 | + allocate(intrinsic_array%double_precision_2D, source = array) |
| 207 | + rank(3) |
| 208 | + allocate(intrinsic_array%double_precision_3D, source = array) |
| 209 | + rank default |
| 210 | + error stop "intrinsic_array_t double_precision_array: unsupported rank" |
| 211 | + end select |
| 212 | + |
| 213 | + end procedure |
| 214 | + |
| 215 | +#endif |
| 216 | + |
133 | 217 | end submodule intrinsic_array_s
|
0 commit comments