错误:此名称没有类型,并且必须具有显式类型

时间:2012-06-04 19:20:35

标签: fortran

这是我的代码:

Program Fortran_Project1

IMPLICIT NONE

INTEGER:: i
REAL*4:: NORM
INTEGER,PARAMETER:: N=5
REAL*4,DIMENSION(N)::X0,NORM_X0

WRITE(*,*) 'parametrhaye matrix X0 ra vared konid'

NORM=0

Do i=1,N
 READ(*,*) X0(i)
 NORM=NORM + X0(i)**2
EndDo

NORM=SQRT(NORM)
NORM_X0(:)=1.0d0

Do i=1,N
 NORM_X0(i)=X(i)/NORM
EndDo

WRITE(*,'(A,\)') 'X0='
WRITE(*,'(F,\)') (X0(i),i=1,N-1)
WRITE(*,'(F)') X(N)
WRITE(*,'(A5,x,F)') 'NORM_X0=',NORM
WRITE(*,'(A7,\)') 'NORM_X0='

Do i=1,N-1
 WRITE(*,'(2x,F8.6,\)') NORM_X0
EndDo

WRITE(*,'(2x,F8.6)') NORM_X0

ENDPROGRAM Fortran_Project1

错误:

--------------------Configuration: F5 - Win32 Debug--------------------
Compiling Fortran...
C:\FORTRAN\F5\F5.F90
C:\FORTRAN\F5\F5.F90(16) : Error: This name does not have a type, and must have an explicit type.   [X]
 NORM_X0(i)=X(i)/NORM
-------------------^
Error executing df.exe.

F5.OBJ - 1 error(s), 0 warning(s)

来自compaq编译器。我需要帮助,如何修复此错误?

2 个答案:

答案 0 :(得分:4)

你有两次“Program Fortran_Project1 / IMPLICIT NONE”,这让编译器感到困惑。几个非标准的语法项。变量x未声明。

答案 1 :(得分:0)

Program Fortran_Project1
implicit none
INTEGER:: i
REAL*4:: NORM
INTEGER,PARAMETER:: N=5
REAL*4,DIMENSION(N)::A0,NORM_A0
WRITE(*,*) 'parametrhaye matrix A0 ra vared konid'
NORM=0
Do i=1,N
    READ(*,*) A0(i)
    NORM=NORM + A0(i)**2
EndDo
NORM=SQRT(NORM)
NORM_A0(:)=1.0
Do i=1,N
    NORM_A0(i)=A0(i)/NORM
EndDo
WRITE(*,'(A,\)') 'A0='
WRITE(*,'(F,\)') (A0(i),i=1,N-1)
WRITE(*,'(F)') A0(N)
WRITE(*,'(A8)') 'NORM_A0='
WRITE(*,'(3x,(F,\))') (NORM_A0(i),i=1,N-1)
WRITE(*,'(F)') NORM_A0(N)
ENDPROGRAM Fortran_Project1