Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected data declaration statement

Tags:

fortran

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))
!
like image 351
awel.llwyd Avatar asked Dec 06 '22 07:12

awel.llwyd


1 Answers

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.

like image 183
High Performance Mark Avatar answered Dec 31 '22 00:12

High Performance Mark