source: CIVL/mods/dev.civl.abc/examples/fortran/f77_standard/arrays.f

main
Last change on this file was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.5 KB
Line 
1c Fortran 77 Standard Sec. 5, Arrays and Substrings
2c This uses subscript triplets (a.k.a. array slices) that were only introduced
3c in Fortran 90.
4 program p
5 implicit none
6 integer a(6), b(0:5), c(-3:2), d(10:10,6)
7 logical h(6)
8 complex f(2,3,4,5,6,7)
9 h = (/.true., .true., .true., .false., .false., .false./)
10c$ civl assert(all(h(1:3)))
11c$ civl assert(any(h(3:6)))
12c$ civl assert(.not. all(h(1:4)))
13c$ civl assert(.not. any(h(4:6)))
14
15 a = (/ 1, 2, 3, 4, 5, 6 /)
16 b = a
17c$ civl assert(all(a .eq. b))
18 c = 0
19 c(-3:-1) = a(1:3)
20c$ civl assert(all(c .eq. a .eqv. h))
21 c(0:) = b(3:5)
22c$ civl assert(c(1) .eq. a(5))
23 d(10,:) = a
24c$ civl assert(sum(d(10,1:2)) .eq. sum(a(1:2)))
25 f(2,3,4,5,6,7) = (1,-2)
26c$ civl assert(imag(f(2,3,4,5,6,7)) .eq. -2.0)
27
28c$ civl assert(all(a(::2) .eq. (/1,3,5/)))
29c$ civl assert(all(a(2:6:2) .eq. (/2,4,6/)))
30
31 a = a + 6
32c$ civl assert(all(a .eq. (/6,7,8,9,10,11,12/)))
33 a = 2 * b + a
34c$ civl assert(all(a .eq. (/8,11,14,17,20,23,26/)))
35
36c N692 Sec. 6.2.2.4.1 "a subscript in a subscript triplet need not be within
37c the declared bounds for that dimension if all values used in selecting the
38c array elements are within the declared bounds."
39c$ civl assert(all(a(2:7:2) .eq. (/2,4,6/)))
40
41c "When the stride is negative, the sequence begins with the first subscript
42c and proceeds in increments of the stride down to the smallest such integer
43c equal to or greater than the second subscript"
44c$ civl assert(all(a(6:1:-2) .eq. (/6,4,2/)))
45 end program
Note: See TracBrowser for help on using the repository browser.