意外的数据声明语句 [英] Unexpected data declaration statement

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

问题描述

我正在编写用于 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))
!

推荐答案

本声明

  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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆