【发布时间】:2018-06-22 13:33:58
【问题描述】:
当我运行下面给出的代码时,它总是给我以下错误:
bash: cannot execute binary file exec format error fortran
此外,文件“file”并未在代码中提到的位置创建。我有一个 64 位处理器和 64 位版本的 Ubuntu 16.04,所以这似乎不是问题。谁能指出我错在哪里?
program sandpile_model
implicit none
integer, parameter :: len = 20
integer, dimension(len,len) :: square
!real, dimension(len,len) :: blah
!open(unit=1,file="\\home\\sandpile\\fortran\\file")
!dummy variables
integer :: i,j,d
do i=1,len
do j=1,len
square(i,j)=2
end do
end do
do d=1,10000
square((len/2)-1,(len/2)-1)=square((len/2)-1,(len/2)-1)+1
if(square((len/2)-1,(len/2)-1)>3) then
call toppling((len/2)-1,(len/2)-1)
end if
end do
!open(unit=1,file="\\home\\sandpile\\fortran\\file")
do i=1,len
do j=1,len
write(1,*), i,'\t',j,'\t',square(i,j)
end do
print*, '\n'
end do
end program sandpile_model
!This subroutine specifies the evolution rules of the model
recursive subroutine toppling(x,y)
!implicit none
integer, parameter :: len = 20
integer, dimension(len,len) :: square
!real, dimension(len,len) :: blah
integer, intent(in) :: x,y
square(x,y)=square(x,y)-4
square(x+1,y)=square(x+1,y)+1
if(square(x+1,y)>3) then
call toppling(x+1,y)
end if
square(x-1,y)=square(x-1,y)+1
if(square(x-1,y)>3) then
call toppling(x-1,y)
end if
square(x,y+1)=square(x,y+1)+1
if(square(x,y+1)>3) then
call toppling(x,y+1)
end if
square(x,y-1)=square(x,y-1)+1
if(square(x,y-1)>3) then
call toppling(x,y-1)
end if
end subroutine toppling
【问题讨论】:
-
你是如何运行你的代码的,即你给出了哪些命令。
-
by "./try.o" try.o是可执行文件
-
你是如何创建
try.o的? -
"gfortran -c try.f90"
-
这是创建一个对象而不是可执行文件。在这种情况下尝试
gfortran try.f90