Blame view

fvn_test/test_sparse.f90 972 Bytes
27d3b84d6   daniau   git-svn-id: https...
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
  program test_sparse
  use fvn
  implicit none
  integer(4), parameter :: nz=12
  integer(4), parameter :: n=5
  real(8),dimension(nz) :: A
  real(8),dimension(n,n) :: As
  integer(4),dimension(nz) :: Ti,Tj
  real(8),dimension(n) :: B,x
  integer(4) :: status,i
  ! Description of the matrix in triplet form
  A = (/ 2.,3.,3.,-1.,4.,4.,-3.,1.,2.,2.,6.,1. /)
  B = (/ 8., 45., -3., 3., 19./)
  Ti = (/ 1,2,1,3,5,2,3,4,5,3,2,5 /)
  Tj = (/ 1,1,2,2,2,3,3,3,3,4,5,5 /)
  
  ! Reconstruction of the matrix in standard form
  ! just needed for printing the matrix here
  As=0.
  do i=1,nz
      As(Ti(i),Tj(i))=A(i)
  end do
  write(*,*) "Matrix in standard representation :"
  do i=1,5
      write(*,'(5f8.4)') As(i,:)
  end do
  write(*,*)
  write(*,'("Right hand side :",5f8.4)') B
  
  !specific routine that will be used here
  !call fvn_di_sparse_solve(n,nz,A,Ti,Tj,B,x,status)
59ae88e06   daniau   git-svn-id: https...
32
  call fvn_di_sparse_solve(n,nz,A,Ti,Tj,B,x,status)
27d3b84d6   daniau   git-svn-id: https...
33
34
35
  write(*,'("Solution :",5f8.4)') x
  write(*,'("Product matrix Solution :",5f8.4)') matmul(As,x)
  end program