File: intrinsics_46.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 (122 lines) | stat: -rw-r--r-- 3,065 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
program intrinsics_46

    implicit none
    ! Compile_time
    integer :: i, j, c
    integer(8) :: li_1, lj_1, li_2, lj_2
    integer(8) :: int_res(4)
    integer, parameter :: dp = kind(0d0)
    character(len=1) :: c_1 = 'b'
    character(len = 1) :: a = 'a'
    character(len = 1) :: b = 'b'
    character(len = 1) :: d = '#'
    character(len=1) :: e(3)
    integer :: x(3)
    integer, parameter :: i1 = ichar('a')
    integer(8), parameter :: i2 = ichar('a', kind=8)
    integer, parameter :: ar1(3) = ichar(['a', '$', '%'])
    integer(8), parameter :: ar2(3) = ichar(['a', '$', '%'], 8)
    character(1) :: arr1(3) = ['a', 'A', '@']

    print *, i1
    if (i1 /= 97) error stop
    print *, i2
    if (i2 /= 97) error stop
    print *, ar1
    if (any(ar1 /= [97, 36, 37])) error stop
    print *, ar2
    if (any(ar2 /= [97, 36, 37])) error stop

    print *, ichar(arr1)
    if (any(ichar(arr1) /= [97, 65, 64])) error stop

    i = ichar(' ')
    j = iachar(' ')
    li_1 = ichar('A', 8)
    lj_1 = iachar('a', 8)
    li_2 = ichar('Z', kind=8)
    lj_2 = iachar('z', kind=8)
    c_1 = char(100);
    e = ["a", "b", "c"]
    x = [97, 98, 99]

    if (i /= 32) error stop
    if (j /= 32) error stop
    if (li_1 /= 65) error stop
    if (lj_1 /= 97) error stop
    if (li_2 /= 90) error stop
    if (lj_2 /= 122) error stop

    ! Compile time with broadcasting
    int_res = ichar([' ', 'c', 'd', 'e'], kind=8)
    if (int_res(1) /= 32) error stop
    if (kind(int_res(1)) /= dp) error stop
    if (int_res(2) /= 99) error stop
    if (kind(int_res(2)) /= dp) error stop
    if (int_res(3) /= 100) error stop
    if (kind(int_res(3)) /= dp) error stop
    if (int_res(4) /= 101) error stop
    if (kind(int_res(4)) /= dp) error stop

    ! Run_time
    c = ichar(c_1)
    if (c /= 100) error stop
    if (char(c) /= 'd') error stop

    c = 100
    c_1 = achar(100)
    if (c_1 /= "d") error stop
    c_1 = achar(c)
    if (c_1 /= "d") error stop
    c_1 = char(100)
    if (c_1 /= "d") error stop
    c_1 = char(c)
    if (c_1 /= "d") error stop

    c_1 = "e"
    c = iachar("e")
    if (c /= 101) error stop
    c = iachar(c_1)
    if (c /= 101) error stop
    c = ichar("e")
    if (c /= 101) error stop
    c = ichar(c_1)
    if (c /= 101) error stop

    print *, ichar(a)
    if(ichar(a) /= 97) error stop

    print *, ichar(b)
    if(ichar(b) /= 98) error stop

    print *, ichar(d)
    if(ichar(d) /= 35) error stop

    print *, ichar('a')
    if(ichar('a') /= 97) error stop

    print *, ichar('b')
    if(ichar('b') /= 98) error stop

    print *, ichar('C')
    if(ichar('C') /= 67) error stop

    print *, ichar('#')
    if(ichar('#') /= 35) error stop

    print *, kind(ichar(a))
    if(kind(ichar(a)) /= 4) error stop

    print *, kind(ichar(a, 8))
    if(kind(ichar(a, 8)) /= 8) error stop

    print *, kind(ichar('a'))
    if(kind(ichar('a')) /= 4) error stop

    print *, kind(ichar('a', 8))
    if(kind(ichar('a', 8)) /= 8) error stop

    print *, ichar(e)
    if (any(ichar(e) /= x)) error stop

end program intrinsics_46