Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program main
  2.     implicit none
  3.     interface
  4.  
  5.         subroutine read_file(filename, n, Ap, Ai, Ax)
  6.             character(10),          intent(in)  :: filename
  7.             integer,                intent(out) :: n
  8.             integer, allocatable,   intent(out) :: Ap(:), Ai(:)
  9.             real(8), allocatable,   intent(out) :: Ax(:)
  10.         end subroutine
  11.  
  12.         subroutine gen_right(n, right)
  13.             integer, intent(in)             :: n
  14.             real(8), allocatable, intent(out)  :: right(:)
  15.         end subroutine
  16.  
  17.         real(8) function distdot(n,x,ix,y,iy)
  18.              integer n, ix, iy
  19.              real(8) x(1+(n-1)*ix), y(1+(n-1)*iy)
  20.         end function
  21.  
  22.     end interface
  23.  
  24. !===============================================================================================
  25.  
  26.     character(10)           :: filename
  27.     integer                 :: n, i
  28.     integer, allocatable    :: Ap(:), Ai(:)
  29.     real(8), allocatable    :: Ax(:), right(:), result(:)
  30.  
  31.     integer iwk
  32.     integer lfil
  33.  
  34.     real(8), allocatable :: alu(:), w(:)
  35.     integer, allocatable :: jlu(:), ju(:), levs(:), jw(:), ierr
  36.  
  37.  
  38. !================================================================================================
  39.  
  40.     ! INITIALIZATION
  41.     read(*, *) filename
  42.     call read_file(filename, n, Ap, Ai, Ax)
  43.     call gen_right(n, right)
  44.     allocate(result(n))
  45.  
  46.     iwk = 10 * (Ap(n + 1) - 1)
  47.     lfil = 1
  48.  
  49.     allocate(alu(iwk), jlu(iwk), ju(n), levs(iwk), w(n), jw(3 * n))
  50.  
  51. !================================================================================================
  52.  
  53.     call iluk(n, Ax, Ai, Ap, lfil, alu, jlu, ju, levs, iwk, w, jw, ierr)
  54.  
  55.     deallocate(Ap, Ai, Ax, right, result)
  56.  
  57. end
  58.  
  59. subroutine read_file(filename, n, Ap, Ai, Ax)
  60.     implicit none
  61.     character(10),          intent(in)  :: filename
  62.     integer,                intent(out) :: n
  63.     integer, allocatable,   intent(out) :: Ap(:), Ai(:)
  64.     real(8), allocatable,   intent(out) :: Ax(:)
  65.     integer i
  66.  
  67.     open(1, file=filename)
  68.  
  69.     read(1, *) n
  70.     print*, n
  71.     print*,
  72.  
  73.     allocate(Ap(n + 1))
  74.     read(1,*) (Ap(i), i = 1, n + 1)
  75.  
  76.     do i = 1, n + 1
  77.         print*, Ap(i)
  78.     end do
  79.     print*,
  80.  
  81.     allocate(Ai(Ap(n + 1) - 1))
  82.     read(1,*) (Ai(i), i = 1, Ap(n + 1) - 1)
  83.  
  84.     do i = 1, Ap(n + 1) - 1
  85.         print*, Ai(i)
  86.     end do
  87.     print*,
  88.  
  89.     allocate(Ax(Ap(n + 1) - 1))
  90.     read(1,*) (Ax(i), i = 1, Ap(n + 1) - 1)
  91.  
  92.     do i = 1, Ap(n + 1) - 1
  93.         print*, Ax(i)
  94.     end do
  95.     print*,
  96.  
  97. end subroutine
  98.  
  99. subroutine gen_right(n, right)
  100.     implicit none
  101.     integer, intent(in)                 :: n
  102.     real(8), allocatable, intent(out)   :: right(:)
  103.     integer i
  104.  
  105.     allocate(right(n))
  106.     do i = 1, n
  107.         right(i) = sin(real(i, 8))
  108.     end do
  109. end subroutine
  110.  
  111. real(8) function distdot(n,x,ix,y,iy)
  112.     integer n, ix, iy
  113.     real(8) x(1+(n-1)*ix), y(1+(n-1)*iy)
  114.     distdot = sdot(n, x, ix, y, iy)
  115. end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement