Fortran sqrt()错误 [英] Fortran sqrt () error

查看:831
本文介绍了Fortran sqrt()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



它显示以下错误:




d = sqrt(bsq \xE2\x80\x93 ac4)
1
错误:参数列表中的语法错误(1)



 程序二次
隐含none
real: :a,b,c,root1,root2
real :: bsq,ac4,d
print *,'请输入系数a,b和c作为实数'
read *如果(bsq d = sqrt(bsq - ac4)$,则a,b,c
bsq = b * b
ac4 = 4 * a * c
b $ b root1 =(-b + d)/(2 * a)
root2 =(-b + d)/(2 * a)
print *,'真正的根是',root1 ,root2
else if(root1 == root2)然后
root1 = root2
print *,'有一个真正的根是'root1
else
print *,'没有真正的根'
结束如果
结束程序二次


解决方案

您需要在 bsq ac4 之间有一个减号,而不是破折号。仔细观察。



减号: -

        破折号: -


I am very new in Fortran and I am stuck with the following program to find roots using quadratic equation.

It is showing the following error:

d = sqrt(bsq \xE2\x80\x93 ac4) 1 Error: Syntax error in argument list at (1)

program quadratic
implicit none 
real :: a, b, c, root1, root2
real :: bsq, ac4, d 
print *, 'Please enter the coefficients a, b, and c as real numbers'
read *, a, b, c
bsq = b*b
ac4 = 4*a*c 
if ( bsq < ac4) then
d = sqrt(bsq – ac4)
root1 = (-b+d)/(2*a)
root2 = (-b+d)/(2*a)
print *, 'The real roots are ', root1, root2
else if ( root1==root2) then
root1 = root2
print *, 'There is one real root which is ', root1
else
print *, 'There are no real roots'
end if
end program quadratic   

解决方案

You need a minus sign between bsq and ac4, not a dash. Look closely.

Minus sign: -
         Dash: –

这篇关于Fortran sqrt()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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