Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program main
- implicit none
- interface
- subroutine read_file(filename, n, Ap, Ai, Ax)
- character(10), intent(in) :: filename
- integer, intent(out) :: n
- integer, allocatable, intent(out) :: Ap(:), Ai(:)
- real(8), allocatable, intent(out) :: Ax(:)
- end subroutine
- subroutine gen_right(n, right)
- integer, intent(in) :: n
- real(8), allocatable, intent(out) :: right(:)
- end subroutine
- real(8) function distdot(n,x,ix,y,iy)
- integer n, ix, iy
- real(8) x(1+(n-1)*ix), y(1+(n-1)*iy)
- end function
- end interface
- !===============================================================================================
- character(10) :: filename
- integer :: n, i
- integer, allocatable :: Ap(:), Ai(:)
- real(8), allocatable :: Ax(:), right(:), result(:)
- integer iwk
- integer lfil
- real(8), allocatable :: alu(:), w(:)
- integer, allocatable :: jlu(:), ju(:), levs(:), jw(:), ierr
- !================================================================================================
- ! INITIALIZATION
- read(*, *) filename
- call read_file(filename, n, Ap, Ai, Ax)
- call gen_right(n, right)
- allocate(result(n))
- iwk = 10 * (Ap(n + 1) - 1)
- lfil = 1
- allocate(alu(iwk), jlu(iwk), ju(n), levs(iwk), w(n), jw(3 * n))
- !================================================================================================
- call iluk(n, Ax, Ai, Ap, lfil, alu, jlu, ju, levs, iwk, w, jw, ierr)
- deallocate(Ap, Ai, Ax, right, result)
- end
- subroutine read_file(filename, n, Ap, Ai, Ax)
- implicit none
- character(10), intent(in) :: filename
- integer, intent(out) :: n
- integer, allocatable, intent(out) :: Ap(:), Ai(:)
- real(8), allocatable, intent(out) :: Ax(:)
- integer i
- open(1, file=filename)
- read(1, *) n
- print*, n
- print*,
- allocate(Ap(n + 1))
- read(1,*) (Ap(i), i = 1, n + 1)
- do i = 1, n + 1
- print*, Ap(i)
- end do
- print*,
- allocate(Ai(Ap(n + 1) - 1))
- read(1,*) (Ai(i), i = 1, Ap(n + 1) - 1)
- do i = 1, Ap(n + 1) - 1
- print*, Ai(i)
- end do
- print*,
- allocate(Ax(Ap(n + 1) - 1))
- read(1,*) (Ax(i), i = 1, Ap(n + 1) - 1)
- do i = 1, Ap(n + 1) - 1
- print*, Ax(i)
- end do
- print*,
- end subroutine
- subroutine gen_right(n, right)
- implicit none
- integer, intent(in) :: n
- real(8), allocatable, intent(out) :: right(:)
- integer i
- allocate(right(n))
- do i = 1, n
- right(i) = sin(real(i, 8))
- end do
- end subroutine
- real(8) function distdot(n,x,ix,y,iy)
- integer n, ix, iy
- real(8) x(1+(n-1)*ix), y(1+(n-1)*iy)
- distdot = sdot(n, x, ix, y, iy)
- end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement