File: intrinsics_148.f90

package info (click to toggle)
lfortran 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 46,332 kB
  • sloc: cpp: 137,068; f90: 51,260; python: 6,444; ansic: 4,277; yacc: 2,285; fortran: 806; sh: 524; makefile: 30; javascript: 15
file content (42 lines) | stat: -rw-r--r-- 1,059 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
program intrinsics_148
integer :: array(3, 4)
logical :: mask(3, 4)
integer :: vector(13)
integer :: res(13)
integer :: out

real :: array_3(3, 4, 5)
logical :: mask_3(3, 4, 5)
real :: vector_3(60)
real :: res_3(60)

array = reshape([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 4])
mask = .false.
mask(1, 1) = .true.
vector = [114, 2414, 3142, 4626, 575, 633, 71, 89, 9123, 1011, 1112, 1213, 1314]

print *, pack(array, .true., vector)
print *, sum(pack(array, .true., vector))
out = sum(pack(array, .true., vector))
if (out /= 1392) error stop

print *, pack(array, mask, vector)
print *, sum(pack(array, mask, vector))
out = sum(pack(array, mask, vector))
if (out /= 25324) error stop

print *, pack(array, mask)
print *, sum(pack(array, mask))
out = sum(pack(array, mask))
if (out /= 1) error stop

array_3 = 12.141
mask_3 = .false.
mask_3(1, 1, 1) = .true.

vector_3 = -12.141
print *, pack(array_3, mask_3, vector_3)
print *, sum(pack(array_3, mask_3, vector_3))
if (abs(sum(pack(array_3, mask_3, vector_3)) + 704.177734) > 1e-6) error stop

end program