本文介绍了意外的数据声明声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写LU分解代码,我不知道如何修复第8行指向的意外数据声明语句(我声明了一个数组,请参阅代码片段)。为什么会出乎意料?

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))
!


推荐答案

此语句

This statement

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

在错误的地方。在Fortran程序单元(程序,子程序,函数)中 - 当然没有新的ASSOCIATE和BLOCK结构 - 所有的声明必须在所有可执行语句之前。

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.

这篇关于意外的数据声明声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:07