codekingpro/portable-devtools
114k
1
2subroutine foo(a, n, m, b)
3 implicit none
4
5 real, intent(in) :: a(n, m)
6 integer, intent(in) :: n, m
7 real, intent(out) :: b(size(a, 1))
8
9 integer :: i
10
11 do i = 1, size(b)
12 b(i) = sum(a(i,:))
13 enddo
14end subroutine
15
16subroutine trans(x,y)
17 implicit none
18 real, intent(in), dimension(:,:) :: x
19 real, intent(out), dimension( size(x,2), size(x,1) ) :: y
20 integer :: N, M, i, j
21 N = size(x,1)
22 M = size(x,2)
23 DO i=1,N
24 do j=1,M
25 y(j,i) = x(i,j)
26 END DO
27 END DO
28end subroutine trans
29
30subroutine flatten(x,y)
31 implicit none
32 real, intent(in), dimension(:,:) :: x
33 real, intent(out), dimension( size(x) ) :: y
34 integer :: N, M, i, j, k
35 N = size(x,1)
36 M = size(x,2)
37 k = 1
38 DO i=1,N
39 do j=1,M
40 y(k) = x(i,j)
41 k = k + 1
42 END DO
43 END DO
44end subroutine flatten
45 