Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Compilation 使用Fortran90编译错误_Compilation_Fortran90_Gfortran_Photran - Fatal编程技术网

Compilation 使用Fortran90编译错误

Compilation 使用Fortran90编译错误,compilation,fortran90,gfortran,photran,Compilation,Fortran90,Gfortran,Photran,好了,我已经和这些错误斗争了几个小时,下面是我的代码: 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 SetVariablesFro

好了,我已经和这些错误斗争了几个小时,下面是我的代码:

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
程序你好
隐式无
整数::k,n,迭代器
整数,维度(18)::objectArray
调用SetVariablesFromFile()
do迭代器=1,18
写入(*,*)对象数组(迭代器)
结束
包含
子例程SetVariablesFromFile()
隐式无
整数::状态,ierror,i,x
打开(单位=1,文件=input.txt)&
操作='READ',状态='old',IOSTAT=ierror)
如果(ierror/=0),则
写入(*,*)“无法打开input.txt!”
停止
如果结束
i=1,18吗
objectArray(i)=读取(1,*,IOSTAT=status)x
如果(状态>0),则
写入(*,*)“读取输入文件时出错”
出口
否则,如果(状态<0),则
写入(*,*)“EOF”
出口
如果结束
结束
关闭(1)
结束子例程SetVariablesFromFile
结束节目你好
我遇到编译错误:

  • 制造:*[hello.o]错误1
  • 参数列表中(1)处的语法错误
  • 我在网上看到后一个错误可能是由于一个超过132个字符的长代码行,这似乎不是问题。我没有从第一个错误开始。。。任何帮助都将不胜感激

    这个

    objectArray(i) = read(1, *, IOSTAT = status) x
    
    是无效的Fortran。你需要把它写成

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

    以这种正确的形式设置它,我在ifort 12.1和gfortran 4.4.3中都没有收到编译器错误,非常好,现在就编译!非常感谢。