| 1 |
! Program to test the COUNT intrinsic |
| 2 |
program intrinsic_count |
| 3 |
implicit none |
| 4 |
logical(kind=4), dimension (3, 5) :: a |
| 5 |
integer(kind=4), dimension (3) :: b |
| 6 |
integer i |
| 7 |
character(len=10) line |
| 8 |
|
| 9 |
a = .false. |
| 10 |
if (count(a) .ne. 0) STOP 1 |
| 11 |
a = .true. |
| 12 |
if (count(a) .ne. 15) STOP 2 |
| 13 |
a(1, 1) = .false. |
| 14 |
a(2, 2) = .false. |
| 15 |
a(2, 5) = .false. |
| 16 |
if (count(a) .ne. 12) STOP 3 |
| 17 |
write (line, 9000) count(a) |
| 18 |
read (line, 9000) i |
| 19 |
if (i .ne. 12) STOP 4 |
| 20 |
|
| 21 |
b(1:3) = count(a, 2); |
| 22 |
if (b(1) .ne. 4) STOP 5 |
| 23 |
if (b(2) .ne. 3) STOP 6 |
| 24 |
if (b(3) .ne. 5) STOP 7 |
| 25 |
b = 0 |
| 26 |
write (line, 9000) count(a,2) |
| 27 |
read (line, 9000) b |
| 28 |
if (b(1) .ne. 4) STOP 8 |
| 29 |
if (b(2) .ne. 3) STOP 9 |
| 30 |
if (b(3) .ne. 5) STOP 10 |
| 31 |
|
| 32 |
9000 format(3I3) |
| 33 |
|
| 34 |
end program |