Note that there are some explanatory texts on larger screens.

plurals
  1. POInfinite loop in Fortran
    text
    copied!<p>This is my code in Fortran 90</p> <pre><code>program final implicit none real, dimension(421,422) :: a real :: temp,factor real, dimension (421) :: soln integer :: i, rmax, pivot, row,n, O,P,COL,k,a_j,n2,a_i,t open(unit=177241,file="input_21.txt",status="old") open(unit=20,file="output.txt",status="unknown") do i =1,421 read (177241,*) (a(i,:)) end do do i = 1,421 print *,a(i,13) end do do T=1,421 n=421 a_i=n n2=422 a_j=n2 !pivoting do pivot = T,n-1 print *, 'pivot=',pivot rmax = pivot do row = pivot,a_i if (ABS(a(rmax,pivot)) &lt; ABS(a(row,pivot)) ) then rmax=row end if end do if (rmax /= pivot) then do k=1, a_j temp = a(rmax,k) a(rmax,k) = a(pivot,k) a(pivot,k) = temp end do end if !elimination do row = pivot+1, n if ( a(pivot,pivot) /= 0 ) then factor = (a(row,pivot)) / (a(pivot,pivot)) print *,'factor=',factor do col = 1, n2 a(row, col) = a(row,col) - a(pivot,col) * factor print *,'a=',a(row,col) end do end if end do end do end do !back-substitution soln(n2) = 0 do o=n,1,-1 do p=n2,o+1,-1 a(o,n2) = a(o,n2) - soln(p)*a(o,p) end do soln(o) = a(o,n2) / a(o,o) end do do i=1,n print *,soln(i) write (121,*) soln(i) end do end program final </code></pre> <p>The input file is 441x442 matrix txt file. I think this can read that input file but it's going to be a infinite loop on here</p> <pre><code>if ( a(pivot,pivot) /= 0 ) then factor = (a(row,pivot)) / (a(pivot,pivot)) print *,'factor=',factor do col = 1, n2 a(row, col) = a(row,col) - a(pivot,col) * factor </code></pre> <p>How can I solve this problem?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload