The syntax for Fortran array-slicing:
print arr-exp(first-exp :last-exp:stride-exp )
Variable |
Description |
Default |
---|---|---|
arr-exp |
Expression that should evaluate to an array type |
|
first-exp |
First element in range, also first element printed |
Lower bound |
last-exp |
Last element in range, but may not be last element printed if stride is greater than 1 |
Upper bound |
stride-exp |
Stride |
1 |
demo% f77 -g -silent ShoSli.f demo% dbx a.out Reading symbolic information for a.out (dbx) list 1,12 1 INTEGER*4 a(3,4), col, row 2 DO row = 1,3 3 DO col = 1,4 4 a(row,col) = (row*10) + col 5 END DO 6 END DO 7 DO row = 1, 3 8 WRITE(*,'(4I3)') (a(row,col),col=1,4) 9 END DO 10 END (dbx) stop at 7 (1) stop at "ShoSli.f":7 (dbx) run Running: a.out stopped in MAIN at line 7 in file "ShoSli.f" 7 DO row = 1, 3
(dbx) print a(3:3,1:4) 'ShoSli'MAIN'a(3:3, 1:4) = (3,1) 31 (3,2) 32 (3,3) 33 (3,4) 34 (dbx)
Print column 4:
(dbx) print a(1:3,4:4) 'ShoSli'MAIN'a(3:3, 1:4) = (1,4) 14 (2,4) 24 (3,4) 34 (dbx)