File: selected_int_kind_01.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (52 lines) | stat: -rw-r--r-- 1,605 bytes parent folder | download | duplicates (2)
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
subroutine test_selected_int_kind(R, expected_value)
    integer :: R, expected_value
    print *, "selected_int_kind(R) = ", selected_int_kind(R)
    if (selected_int_kind(R) /= expected_value) error stop
end subroutine

subroutine test_compile_time_selected_int_kind()
    print *, selected_int_kind(1)
    if (selected_int_kind(1) /= 1) error stop
    print *, selected_int_kind(2)
    if (selected_int_kind(2) /= 1) error stop
    print *, selected_int_kind(3)
    if (selected_int_kind(3) /= 2) error stop
    print *, selected_int_kind(4)
    if (selected_int_kind(4) /= 2) error stop
    print *, selected_int_kind(5)
    if (selected_int_kind(5) /= 4) error stop
    print *, selected_int_kind(6)
    if (selected_int_kind(6) /= 4) error stop
    print *, selected_int_kind(7)
    if (selected_int_kind(7) /= 4) error stop
    print *, selected_int_kind(8)
    if (selected_int_kind(8) /= 4) error stop
    print *, selected_int_kind(9)
    if (selected_int_kind(9) /= 4) error stop
    print *, selected_int_kind(10)
    if (selected_int_kind(10) /= 8) error stop
    print *, selected_int_kind(11)
    if (selected_int_kind(11) /= 8) error stop
end subroutine

program selected_int_kind_01
    integer :: x
    x = 1
    do while (x < 3)
        call test_selected_int_kind(x, 1)
        x = x + 1
    end do

    do while (x < 5)
        call test_selected_int_kind(x, 2)
        x = x + 1
    end do

    do while (x < 10)
        call test_selected_int_kind(x, 4)
        x = x + 1
    end do

    call test_selected_int_kind(x, 8)
    call test_compile_time_selected_int_kind()
end  program