关于Fortran中write语句的位置
题目
关于Fortran中write语句的位置
有个Fortran的函数如下:
SUBROUTINE EXCOR_DER_PARA(RHO, NDER, EXCA, LEXCHG, TREL)
USE prec
USE constant
IMPLICIT NONE
LOGICAL TREL
INTEGER LEXCHG ! type of gradient corrected func.
INTEGER NDER ! number of derivative
REAL(q) RHO
REAL(q) EXCA(4),EXCA_(4)
REAL(q) RHOT,EXC0,EXC2,EXCD0,EXCD2,EPS
! this is the best compromise for densities between 1000 and 0.1
REAL(q),PARAMETER :: DELTA=1E-3_q
WRITE(*,*)"######" 《++++这一行是我后来加入的
CALL EXCOR_PARA(RHO,EXCA(1),EXCA(2),LEXCHG,TREL)
IF (NDER>0) THEN
EPS=DELTA*RHO
RHOT=RHO-EPS
CALL EXCOR_PARA(RHOT,EXC0,EXCD0,LEXCHG,TREL)
RHOT=RHO+EPS
CALL EXCOR_PARA(RHOT,EXC2,EXCD2,LEXCHG,TREL)
! 1st and 2nd derivative of energy
EXCA_(2)=(EXC2-EXC0)/ (2*EPS)
EXCA_(3)=(EXC2+EXC0-2*EXCA(1))/ (EPS*EPS)
! 2nd and 3nd derivative of potential=
! 1st and 2nd derivative of energy
EXCA(3)=(EXCD2-EXCD0)/ (2*EPS)
EXCA(4)=(EXCD2+EXCD0-2*EXCA(2))/ (EPS*EPS)
! WRITE(*,'(5E14.7)') EXCA(2),EXCA_(2),EXCA(3),EXCA_(3),EXCA(4)
ENDIF
END SUBROUTINE
本来里面是没有上面标注的那一行write的,编译也没有问题,但是当我加入那一行WRITE(*,*)"######"之后,就报错:
error #6404: This name does not have a type, and must have an explicit type. [DELTA]
EPS=DELTA*RHO
-------------^
说Delta变量没有类型
请问这是为什么呢?
答案
两个方法可能可以解决你的问题:1.去掉语句中的IMPLICIT NONE.2.在程序中你的确没有定义delta,你可以定义一下.
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
最新试题
热门考点