11:03 PM
0
Kamis 22 Maret 2012, jam 09.00 di teter B jurusan Fisika FMIPA ITS seperti biasa kami kembali kuliah Fisika Komputasi bersama Prof. Bagus Jaya Santosa. Penasaran, bingung, dan berbagai perasaan lain kami rasakan.

Hari ini kami belajar Fortran, Subroutine methode, dan inilah hasilnya:



program Gauss1
real a(4,4),b(4),x(4)
integer er
data a/1,2,3,4,2,3,4,5,3,4,5,6,4,3,2,1/
data b/10,12,13,14/
print *,'Matriks A'
print *,((a(i,j),j=1,4),i=1,4)
print *,'Matriks B'
print *,(b(i),i=1,4)
n=4
tol=1.e-5
call gauss(a,b,n,x,tol,er)
print *,(x(i),i=1,4)
stop
end

subroutine Gauss (a,b,n,x,tol,er)
dimension s(n)
integer er
er = 0
do i = 1,n
s(i) = ABS (a(i,1))
do j = 2,n
if (abs(a(i,j))>S(i)) s(i) = abs(a(i,j))
end do
end do
call eliminate (a,s,n,b,tol,er)
if (er.ne.-1) then
call substitute (a,n,b,x)
end if
return
end

subroutine eliminate (a,s,n,tol,er)
dimension a(n,n), b(n), s(n)
integer er
do k = 1, n-1
call pivot (a,b,s,n,k)
if (abs(a(k,k)/s(k)) big ) then
big=dummy
p=ii
end if
end do

if (p.ne.k) then
do jj = k,n
dummy = a(p,jj)
a(p,jj) = a(k,jj)
a(k,jj) = dummy
end do
dummy = b(p)
b(p) = b(k)
b(k) = dummy
dummy = s(p)
s(p) = s(k)
s(k) = dummy
end if

return
end

Saran dari bapak jika memang program ini tidak jalan, maka cobalah menjalankannya di G-Fortran (selamat mencari program ini)

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Recent Post