File: submodule_43.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 (46 lines) | stat: -rw-r--r-- 1,209 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
! Test: pass_array_by_data with nested internal subroutines in a
! submodule that call each other with derived-type assumed-shape arrays.
module submodule_43_m
    implicit none
    type :: t
        integer :: val
    end type
    interface
        module subroutine my_sort(array)
            type(t), intent(inout) :: array(0:)
        end subroutine
    end interface
end module

submodule(submodule_43_m) submodule_43_s
    implicit none
contains
    module subroutine my_sort(array)
        type(t), intent(inout) :: array(0:)
        call b(array)
    contains
        subroutine a(array)
            type(t), intent(inout) :: array(0:)
            integer :: tmp
            tmp = array(0)%val
            array(0)%val = array(1)%val
            array(1)%val = tmp
        end subroutine
        subroutine b(array)
            type(t), intent(inout) :: array(0:)
            call a(array)
        end subroutine
    end subroutine
end submodule

program submodule_43
    use submodule_43_m
    implicit none
    type(t) :: arr(0:1)
    arr(0)%val = 10
    arr(1)%val = 20
    call my_sort(arr)
    if (arr(0)%val /= 20) error stop
    if (arr(1)%val /= 10) error stop
    print *, "PASS"
end program