File: nested_vars_01.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 (41 lines) | stat: -rw-r--r-- 1,055 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
module cobylb_mod_nested_vars_01
contains
    subroutine cobylb(amat)
    real, intent(in) :: amat(:, :)
    call evaluate(calcfc_internal)
    contains
        subroutine evaluate(calcfc)
            implicit none
            interface
                subroutine calcfc()
                    implicit none
                end subroutine calcfc
            end interface
            call calcfc()
        end subroutine evaluate

        subroutine calcfc_internal()
            implicit none
            real :: out(5, 5)
            print *, matprod(amat)
            out = matprod(amat)
            if (any(abs(out - 833.340454) > 1e-8)) error stop
            end subroutine calcfc_internal
        end subroutine

        function matprod(y) result(z)
            implicit none
            real, intent(in) :: y(:, :)
            real :: z(size(y,1), size(y, 2))

            z = matmul(y, y)
        end function matprod
end module


program nested_vars_01
use cobylb_mod_nested_vars_01
real :: amat(5, 5)
amat = 12.91
call cobylb(amat)
end program