【问题标题】:Compile errors with Fortran90使用 Fortran90 编译错误
【发布时间】:2013-11-08 21:11:02
【问题描述】:

所有,我已经与这些错误作斗争了几个小时,这是我的代码:

program hello
implicit none
integer :: k, n, iterator
integer, dimension(18) :: objectArray

call SetVariablesFromFile()
do iterator = 1, 18
    write(*,*) objectArray(iterator)
end do


contains
subroutine SetVariablesFromFile()
    IMPLICIT NONE
    integer :: status, ierror, i, x

    open(UNIT = 1, FILE = 'input.txt', &
    ACTION = 'READ',STATUS = 'old', IOSTAT = ierror)
    if(ierror /= 0) THEN
        write(*, *) "Failed to open input.txt!"
        stop
    end if

    do i = 1, 18
        objectArray(i) = read(1, *, IOSTAT = status) x
        if (status > 0) then
            write(*,*) "Error reading input file"
            exit
        else if (status < 0) then
            write(*,*) "EOF"
            exit
        end if
    end do
    close(1)

END subroutine SetVariablesFromFile

end program hello

我收到编译错误:

  1. make: * [hello.o] Error1
  2. (1) 处的参数列表中有语法错误

我在网上看到后一个错误可能是由于一长行代码超过 132 个字符,这似乎不是问题。我没有从第一个错误开始的地方...任何帮助都是非常感谢!

【问题讨论】:

    标签: compilation fortran90 gfortran photran


    【解决方案1】:

    这个,

    objectArray(i) = read(1, *, IOSTAT = status) x
    

    不是有效的 Fortran。你需要写成,

    read(1,*,iostat=status) objectArray(i)
    

    以这种正确的形式设置它,我没有收到 ifort 12.1 和 gfortran 4.4.3 的编译器错误

    【讨论】:

    • 很好,现在编译!谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-13
    • 2012-08-26
    • 2016-08-23
    • 1970-01-01
    • 2014-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多