无法编译Fortran程序

时间:2020-08-25 17:39:29

标签: ubuntu fortran do-while

当我使用hello.f90运行程序时,它工作正常,但是当我尝试运行hello.f时,程序显示以下错误。如何解决这个问题?

错误:(1)的语句标签中的非数字字符 hello.f:3:5:

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 *, Kilograms, 'Kilogram to Pounds is', Pounds
   end if
    if (input == 0) then
        print * , 'Thank you !'
        shouldEnd = 0
    end if
    end do
    end program hello

谢谢

1 个答案:

答案 0 :(得分:0)

我更正了我的错误。我不知道我们需要在每行开头保留6位数字的空间。错误是编写格式,当我更正我的代码格式时,它开始正常工作。