回 帖 发 新 帖 刷新版面

主题:新手请教,请问这个程序中的问题如何改正?

subroutine ssor(a,n,b,x,eps,om,ii)
parameter(imax=200)
real a(n,n),b(n),x(n)
integer i,j,ii
real r,rx
do i=1,n
   r=1/a(i,i)
   b(i)=b(i)*r
   do j=1,n
      a(i,j)=a(i,j)*r
    end do
end do
do ii=1,imax
   rx=0.0
   do i=1,n
      r=b(i)
      do j=1,n
         r=r-a(i,j)*x(j)
      enddo
      if (abs(r)>rx)rx=abs(r)
         x(i)=x(i)+om*r
      enddo
      if(om*rx<=eps) return 
 enddo
pause 'too many iterations'
end subroutine ssor


 program dir12
 ! drive program for routine ssor
 parameter(n=99,eps=1.e-4,om=1.3)
 dimension a(n,n),c(n,n),r(n),b(n),x(n)

 do i=1,n
 a(i,i)=-(1+v*cos((i+1/2)*u))**3-(1+v*cos((i-1/2)*u))**3
 enddo
 do i=1,n-1
 a(i,i+1)=(1+v*cos((i+1/2)*u))**3
 a(i+1,i)=(1+v*cos((i-1/2)*u))**3
 enddo

 do i=1,n
     b(i)=3*v*u*(cos((i+1/2)*u)-cos((i-1/2)*u))
   enddo

 do i=1,n
    do j=1,n
    c(i,j)=a(i,j)
    enddo
enddo
do l=1,n
   r(l)=b(l)
   x(l)=0.0
enddo
call ssor(c,n,r,x,eps,om,ii)
write(*,*) 'solution vector'
write(*,'(1x,5f12.6)') (x(l) l=1,n)
!test results with original matrix
write(*,*) 'right-hand side vector'
write(*,'(1x,5f12.6)') (b(l) l=1,n)
write(*,*) 'result of matrix applied to sol' 'n vector'
do l=1,n
   b(l)=0.0
   do j=1,n
     b(l)=b(l)+a(l,j)*x(j)
    enddo
enddo
write(*,'(1x,5f12.6)') (b(l) l=1,n)
write(*,*) 'iteration times=',ii
end

回复列表 (共2个回复)

沙发


你不说问题所在,让大家读你程序啊!!!

板凳

这就是问题
--------------------Configuration: Text10 - Win32 Debug--------------------
Compiling Fortran...
E:\R_K Method\Text10.f90
E:\R_K Method\Text10.f90(57) : Error: Syntax error, found IDENTIFIER 'L' when expecting one of: ( * :: , <END-OF-STATEMENT> ; : ) (/ [ + - . % ] /) . ' ** / > ...
write(*,'(1x,5f12.6)') (x(l) l=1,n)
-----------------------------^
E:\R_K Method\Text10.f90(60) : Error: Syntax error, found IDENTIFIER 'L' when expecting one of: ( * :: , <END-OF-STATEMENT> ; : ) (/ [ + - . % ] /) . ' ** / > ...
write(*,'(1x,5f12.6)') (b(l) l=1,n)
-----------------------------^
E:\R_K Method\Text10.f90(61) : Error: Syntax error, found CHARACTER_CONSTANT 'n vector' when expecting one of: ( * :: , <END-OF-STATEMENT> ; : ) (/ [ + - . ] /) ** / > // .LT. ...
write(*,*) 'result of matrix applied to sol' 'n vector'
---------------------------------------------^
E:\R_K Method\Text10.f90(68) : Error: Syntax error, found IDENTIFIER 'L' when expecting one of: ( * :: , <END-OF-STATEMENT> ; : ) (/ [ + - . % ] /) . ' ** / > ...
write(*,'(1x,5f12.6)') (b(l) l=1,n)
-----------------------------^
E:\R_K Method\Text10.f90(61) : Error: This Hollerith or character constant is too long and cannot be used in the current numeric context.   ['result of matrix applied to sol']
write(*,*) 'result of matrix applied to sol' 'n vector'
-----------^
E:\R_K Method\Text10.f90(61) : Error: This Hollerith or character constant is too long and cannot be used in the current numeric context.   ['n vector']
write(*,*) 'result of matrix applied to sol' 'n vector'
---------------------------------------------^
Error executing df.exe.

Text10.exe - 6 error(s), 0 warning(s)

我来回复

您尚未登录,请登录后再回复。点此登录或注册