File: array_04_pack.f90

package info (click to toggle)
lfortran 0.61.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 61,892 kB
  • sloc: cpp: 181,767; f90: 92,175; python: 17,616; ansic: 10,170; yacc: 2,377; sh: 1,444; fortran: 892; makefile: 38; javascript: 15
file content (17 lines) | stat: -rw-r--r-- 498 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
program array_04_pack
implicit none
integer :: dims(2)
integer, dimension(4) :: perm, dim_range = [1, 2, 3, 4]

dims = [2, 3]

! pack() with a runtime-dependent mask: the result size is unknown at compile time.
! The array constructor [dims, pack(...)] should have size 4, matching perm.
perm = [dims, pack(dim_range, dim_range /= dims(1) .and. dim_range /= dims(2))]

if (perm(1) /= 2) error stop
if (perm(2) /= 3) error stop
if (perm(3) /= 1) error stop
if (perm(4) /= 4) error stop

end program