本文介绍了(1)中表达式的预期右括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Fortran编译器报告错误
表达式中的期望右括号(1)
$ c
这是什么意思?
程序能量
real :: Es = 0.4,Ep = -0.4,ts = 0.2,tsp = 2.0
integer :: Nx = 100
real :: kx(101)
实际:: ky
kx(1)= - 0.50
do i = 1,Nx
kx(i + 1)= kx(1)+ i *(1.00 / Nx)
end do
print *,'输入值为ky'
read *,ky
do i = 1,101
! 错误在终端
Epos(i)= sqrt(-Es *(Ep + 2 * ts *(cos(kx(i))+ cos(ky))) - ( 2 * TS *(COS(KX(I))+ COS(KY))*(EP-2 * TS *(COS(KX(I))+ COS(KY))))+(4 *茶匙** 2 )*((sin(kx(i)))** 2 +(sin(ky))** 2)))
end do
write(*,*)Epos
结束程序能量
解决方案 ...您可以为 gfortran
指定 -ffree-line-length-0
来移除限制,或者我会更喜欢),使用&
来打破你的界限:
Epos(i)= sqrt(-Es *(Ep + 2 * ts *(cos(kx(i))+ cos(ky)))&
- (2 * ts *(cos(kx ))+ cos(ky))*(Ep-2 * ts *(cos(kx(i))+ cos(ky))))&
+(4 * tsp ** 2)* sin(kx(i)))** 2 +(sin(ky))** 2))
- 一个右括号太多
- 缺少宣布
Epos
The Fortran compiler reports an error
Expected right parenthesis in expression at (1)
What does it mean?
program energy
real::Es=0.4,Ep=-0.4,ts=0.2,tsp=2.0
integer::Nx=100
real::kx(101)
real::ky
kx(1)=-0.50
do i=1,Nx
kx(i+1)=kx(1)+i*(1.00/Nx)
end do
print*, 'Enter value for ky'
read*,ky
do i=1,101
! "The error mentions it in the next line in terminal"
Epos(i)=sqrt(-Es*(Ep+2*ts*(cos(kx(i))+cos(ky)))-(2*ts*(cos(kx(i))+cos(ky))*(Ep-2*ts*(cos(kx(i))+cos(ky))))+(4*tsp**2)*((sin(kx(i)))**2 +(sin(ky))**2)))
end do
write(*,*) Epos
end program energy
解决方案 Your line is too long... You can either specify -ffree-line-length-0
for gfortran
to remove the limit, or (what I would prefer), break your lines using &
:
Epos(i)=sqrt( - Es*(Ep+2*ts*(cos(kx(i))+cos(ky))) &
- (2*ts*(cos(kx(i))+cos(ky))*(Ep-2*ts*(cos(kx(i))+cos(ky)))) &
+ (4*tsp**2)*((sin(kx(i)))**2 +(sin(ky))**2) )
There are two additional issues with your code:
- One right bracket too much
- Missing declaration of
Epos
这篇关于(1)中表达式的预期右括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!