Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
660 views
in Technique[技术] by (71.8m points)

fortran - Unexpected data declaration statement

I'm writing a code for LU decomposition and I don't know how to fix the "unexpected data declaration statement" pointed at line 8 (where I'm declaring an array. See the code fragment). Why is it unexpected?

!Decomposi??o LU
!-----------------------------------------------------------
      PROGRAM LUdecomp
      IMPLICIT INTEGER (I-K,N), REAL (A-H, L-M,O-Z)
      INTEGER, PARAMETER :: N=3
      REAL, DIMENSION (N,N) :: A,L,U    
      A = reshape((/3.,1.,4.,4.,2.,0.,3.,2.,3./),(/3,3/))   !exemplo do Bortoli*******
      REAL, DIMENSION(3) :: B=(/9.,3.,-2./),Z,X     
      OPEN(1,file = 'LUFACTOR.out')
!
!          FORALL (I = 1:N, J = 1:N) A(I,J) = 1.0/REAL(I+J-1)
!-------Fazendo a fatora??o A = LU-----------------------------
        CALL LU(N, A, L, U)
        DO I=1,N
           WRITE(*,10)(L(I,J), J=1,N), (U(I,J), J=1,N)
        END DO
   10   FORMAT(3(F8.4), 7x, 3(F8.4))
!
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This statement

  REAL, DIMENSION(3) :: B=(/9.,3.,-2./),Z,X     

is in the wrong place. In a Fortran program-unit (program, subroutine, function) -- certainly one without the new ASSOCIATE and BLOCK constructs -- all declarations have to precede all executable statements.

Move the misplaced statement ahead of the first executable statement.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...