File: arrays_81.f90

package info (click to toggle)
lfortran 0.58.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 54,512 kB
  • sloc: cpp: 162,179; f90: 68,251; python: 17,476; ansic: 6,278; yacc: 2,334; sh: 1,317; fortran: 892; makefile: 33; javascript: 15
file content (57 lines) | stat: -rw-r--r-- 977 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
47
48
49
50
51
52
53
54
55
56
57
module arrays81sub1
implicit none

contains

subroutine sub(simi, d)
    real, intent(inout) :: simi(:, :)
    real, intent(in) :: d(:)
    real :: simi_jdrop(size(simi, 2))

    simi = outprod(matprod21(simi, d), simi_jdrop)

contains

    function outprod(x, y) result(z)
        implicit none
        real, intent(in) :: x(:)
        real, intent(in) :: y(:)
        real :: z(size(x), size(y))
        real :: sum_x_y

        sum_x_y = sum(x) + sum(y)

        z = sum_x_y

    end function outprod

    function matprod21(x, y) result(z_)
        implicit none
        real, intent(in) :: x(:, :)
        real, intent(in) :: y(:)
        real, allocatable :: z_(:)

        allocate(z_(size(x, 1)))

        z_ = matmul(x, y)

    end function matprod21

end subroutine

end module

program arrays_81
use arrays81sub1

real :: simi1(10, 5)
real :: d(5)

simi1 = 5.0
d = 2.0

call sub(simi1, d)
print *, simi1
if( any(abs(simi1 - 500.0) > 1e-8 ) ) error stop

end program