File: intrinsics_136.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 (78 lines) | stat: -rw-r--r-- 1,977 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
program intrinsics_136
    integer(4) :: x, y
    integer(8) :: i, j

    integer(4) :: arg_x(5) = [12, -13, 18, 20, 67]
    integer(4) :: arg_y(5) = [1, 2, 3, 4, 5]
    integer(8) :: arg_x2(5) = [103, 87, 88, -95, -134]
    integer(8) :: arg_y2(5) = [11, 12, 4, 0, 10]
    integer(4) :: res_x(5)
    integer(8) :: res_x2(5)

    integer(4), parameter :: res(5) = rshift([12, -13, 18, 20, 67], [1, 2, 3, 4, 5])
    integer(8), parameter :: res2(5) = rshift([103, 87, 88, -95, -134], [11, 12, 4, 0, 10])

    integer(4) :: expected_res(5) = [6, -4, 2, 1, 2]
    integer(8) :: expected_res2(5) = [0, 0, 5, -95, -1]

    integer(4), parameter :: comp1 = rshift(12, 1)
    integer(8), parameter :: comp2 = rshift(103, 11)

    print *, comp1
    if (comp1 /= 6) error stop

    print *, comp2
    if (comp2 /= 0) error stop

    res_x = rshift(arg_x, arg_y)
    res_x2 = rshift(arg_x2, arg_y2)

    do i = 1, size(res)
        print *, res(i)
        if (res(i) /= expected_res(i)) error stop
    end do

    do i = 1, size(res2)
        print *, res2(i)
        if (res2(i) /= expected_res2(i)) error stop
    end do

    do i = 1, size(res_x)
        print *, res_x(i)
        if (res_x(i) /= expected_res(i)) error stop
    end do

    do i = 1, size(res_x2)
        print *, res_x2(i)
        if (res_x2(i) /= expected_res2(i)) error stop
    end do

    x = 16
    y = 2
    i = 8
    j = 4

    print*, rshift(10_4, 0)
    if ( rshift(10_4, 0) /= 10) error stop

    print*, rshift(-10_8, 1)
    if ( rshift(-10_8, 1) /= -5 ) error stop

    print*, rshift(not(10_4), 2)
    if ( rshift(not(10_4), 2) /= -3 ) error stop

    print*, rshift(not(10_8), 3)
    if ( rshift(not(10_8), 3) /= -2 ) error stop

    print*, rshift(-x, y)
    if ( rshift(-x, y) /= -4 ) error stop

    print*, rshift(i, j)
    if ( rshift(i, j) /= 0 ) error stop

    print*, rshift(10, 1)
    if ( rshift(10, 1) /= 5 ) error stop

    print*, rshift(8, 2)
    if ( rshift(8, 2) /= 2 ) error stop
end