如何解决无法编译Fortran程序
当我使用hello.f90
运行程序时,它工作正常,但是当我尝试运行hello.f
时,程序显示以下错误。如何解决这个问题?
3 | real :: Pounds,Kilograms,Feet,Meters,Fahrenheit,Celcius
| 1
错误:语句标签处(1)的非数字字符 hello.f:4:5:
4 | integer :: input,shouldEnd
| 1
错误:语句标签处(1)的非数字字符 hello.f:5:5:
5 | shouldEnd = 1
| 1
错误:语句标签处(1)的非数字字符 hello.f:7:5:
7 | do while ( shouldEnd .ne. 0)
| 1
错误:语句标签处(1)的非数字字符 你好:f:8:5: `
我的程序看起来像这样
program hello
real :: Pounds,Kilograms
integer :: input,shouldEnd
shouldEnd = 1
do while ( shouldEnd .ne. 0)
print *,"Enter a conversion option (1-2 or 0 to exit):"
print *,"--------------------------"
print *,"(1) Pounds to Kilograms"
print *,"(2) Kilograms to Pounds"
print *,"(0) Exit this program"
print *,"--------------------------"
Read *,input
if(input == 1) then
print *,"Enter the number in pounds to convert to Kilograms"
read *,Pounds
Kilograms = (Pounds / 2.205)
print *,Pounds,'Pounds in Kilogram is',Kilograms
end if
if (input == 2) then
print *,"Enter the number in kilograms to convert to Pounds"
read *,Kilograms
Pounds = Kilograms * 2.205
print *,'Kilogram to Pounds is',Pounds
end if
if (input == 0) then
print *,'Thank you !'
shouldEnd = 0
end if
end do
end program hello
谢谢
解决方法
我更正了我的错误。我不知道我们需要在每行开头保留6位数字的空间。错误是编写格式,当我更正我的代码格式时,它开始正常工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。