为什么我在装有 Fedora 的 PC 上出现 Fortran 'End of record' 错误,但在 Macbook 上却没有?
Why do I get Fortran 'End of record' error on PC with Fedora, but not on Macbook?
我有一个程序在使用 Macbook 时运行良好,但是当我在装有 Fedora 28 的 PC 上尝试它时,我收到了这个错误:
At line 107 of file transport.f08
Fortran runtime error: End of record
Error termination. Backtrace:
#0 0x7f2e56fe039a
#1 0x7f2e56fe0f09
#2 0x7f2e56fe1711
#3 0x7f2e571e6818
#4 0x7f2e571f2022
#5 0x7f2e571e97fa
#6 0x7f2e571e9c14
#7 0x403e5a
#8 0x405d0c
#9 0x405e65
#10 0x7f2e5643b1ba
#11 0x400bc9
#12 0xffffffffffffffff
这是第 107 行有问题的代码块:
subroutine outputs(i_out)
integer, intent(in) :: i_out
integer :: iunit, ierr
integer :: i
character(len=8) :: chout
write(chout,fmt='(I0.4)') i_out ! LINE 107
open(newunit=iunit,file="./outputs/Houtput"//trim(chout)//".dat",&
action="write", iostat=ierr)
if( ierr /= 0) then
print *, " > There was an error while opening output file ", i_out
print *, " > Exiting..."
stop
endif
do i=1,Nr
write(iunit,fmt='(20E14.6)') r_cell(i), velocity(i), pressure(i), density(i)
enddo
close(iunit)
end subroutine outputs
正如 francescalus 在评论中指出的那样,我不得不将 i_out 长度降低到 8 位或更少。它解决了错误。
我仍然不知道为什么它以前在 Mac 上起作用,但是解决错误对我来说已经足够了:)
谢谢。
我有一个程序在使用 Macbook 时运行良好,但是当我在装有 Fedora 28 的 PC 上尝试它时,我收到了这个错误:
At line 107 of file transport.f08
Fortran runtime error: End of record
Error termination. Backtrace:
#0 0x7f2e56fe039a
#1 0x7f2e56fe0f09
#2 0x7f2e56fe1711
#3 0x7f2e571e6818
#4 0x7f2e571f2022
#5 0x7f2e571e97fa
#6 0x7f2e571e9c14
#7 0x403e5a
#8 0x405d0c
#9 0x405e65
#10 0x7f2e5643b1ba
#11 0x400bc9
#12 0xffffffffffffffff
这是第 107 行有问题的代码块:
subroutine outputs(i_out)
integer, intent(in) :: i_out
integer :: iunit, ierr
integer :: i
character(len=8) :: chout
write(chout,fmt='(I0.4)') i_out ! LINE 107
open(newunit=iunit,file="./outputs/Houtput"//trim(chout)//".dat",&
action="write", iostat=ierr)
if( ierr /= 0) then
print *, " > There was an error while opening output file ", i_out
print *, " > Exiting..."
stop
endif
do i=1,Nr
write(iunit,fmt='(20E14.6)') r_cell(i), velocity(i), pressure(i), density(i)
enddo
close(iunit)
end subroutine outputs
正如 francescalus 在评论中指出的那样,我不得不将 i_out 长度降低到 8 位或更少。它解决了错误。
我仍然不知道为什么它以前在 Mac 上起作用,但是解决错误对我来说已经足够了:) 谢谢。