File: class_90.f90

package info (click to toggle)
lfortran 0.59.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 56,736 kB
  • sloc: cpp: 168,052; f90: 74,272; python: 17,537; ansic: 7,705; yacc: 2,345; sh: 1,334; fortran: 895; makefile: 37; javascript: 15
file content (29 lines) | stat: -rw-r--r-- 832 bytes parent folder | download | duplicates (3)
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
program class_90
    implicit none
    integer :: x(3)
    x = [1, 2, 3]
    call print_any(x)

contains

    subroutine print_any(val)
        class(*) :: val(:)
        select type(val)
        type is (integer)
            call print_any2(val)
            print *, "After modification in print_any2:", val(1), val(2), val(3)
            if (val(1) /= 10 .or. val(2) /= 20 .or. val(3) /= 30) error stop "Modification not reflected"
        end select
    end subroutine print_any

    subroutine print_any2(val)
        integer :: val(:)
        print *, "Integer array:", val
        if (size(val) /= 3) error stop "Size mismatch"
        if (val(1) /= 1 .or. val(2) /= 2 .or. val(3) /= 3) error stop "Value mismatch"
        val(1) = 10
        val(2) = 20
        val(3) = 30
    end subroutine print_any2

end program class_90