-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodule-example.f90
More file actions
45 lines (31 loc) · 816 Bytes
/
module-example.f90
File metadata and controls
45 lines (31 loc) · 816 Bytes
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
module square_matrix_operations
implicit none
contains
subroutine set_to(A,n, val)
implicit none
integer, intent(in) :: n
real, dimension(n,n), intent(inout) :: A
real, intent(in) :: val
A = val
end subroutine set_to
subroutine print_matrix(A,n)
implicit none
integer, intent(in) :: n
real, dimension(n,n), intent(in) :: A
integer :: i, j
do i=1, n
print *,( A(i,j), j=1,n)
end do
end subroutine print_matrix
end module square_matrix_operations
program module_example
use square_matrix_operations
implicit none
integer :: n
real, dimension(:,:), allocatable :: A
n = 5
allocate( A(n,n) )
call set_to(A,n,1.0)
call print_matrix(A,n)
deallocate( A )
end program module_example