File: modules_69.f90

package info (click to toggle)
lfortran 0.61.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 61,892 kB
  • sloc: cpp: 181,767; f90: 92,175; python: 17,616; ansic: 10,170; yacc: 2,377; sh: 1,444; fortran: 892; makefile: 38; javascript: 15
file content (43 lines) | stat: -rw-r--r-- 907 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
module modules_69_m
    implicit none
    type :: t
        integer :: n = 0
    end type t
    interface get_n
        module procedure :: get_n
    end interface
contains
    pure function get_n(s) result(r)
        type(t), intent(in) :: s
        integer :: r
        r = s%n
    end function
end module

module modules_69_m2
    use modules_69_m, only: t, get_n
    implicit none
contains
    subroutine f(x, a)
        type(t), intent(in) :: x
        character, intent(out) :: a(get_n(x))
        integer :: i
        do i = 1, get_n(x)
            a(i) = "x"
        end do
    end subroutine
end module

program modules_69
    use modules_69_m2, only: f
    use modules_69_m, only: t
    implicit none
    type(t) :: x
    character :: a(3)
    x%n = 3
    call f(x, a)
    if (a(1) /= "x") error stop
    if (a(2) /= "x") error stop
    if (a(3) /= "x") error stop
    print *, "PASS"
end program