问题
This is my fortran code (fortcode.for)
CHARACTER TITLE*80
COMMON IN
COMMON TITLE
PARAMETER (MAXTIT=20)
20 FORMAT (A80)
C*****FORTRAN LOGICAL UNIT NUMBER OF INPUT FILE
IN = 5
DO 1665 I=1, MAXTIT
READ (IN,20) TITLE
1665 CONTINUE
CLOSE (IN)
END
I compile the fortran file into an executable (fortexec.exe) using the following command.
gfortran -g -fno-align-commons fortcode.for -o fortexec.exe
I then use gdb debugger by typing
gdb fortexec
I then give it the following file input (input.inp)
testx testy testz
testx testy testz
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
testk tety
By typing the following
run < input.inp
It starts running but then just hangs.
I type Ctrl-C to interrupt it, and then it gives me the following result
[New Thread 10804.0x5b6c]
[New Thread 10804.0x4974]
[New Thread 10804.0x3c24]
[New Thread 10804.0x4ae8]
At line 11 of file fortcode.for (unit = 5, file = 'stdin')
Fortran runtime error: [New Thread 10804.0x48e8]
End of file
Error termination. Backtrace:
Program received signal SIGINT, Interrupt.
[Switching to Thread 10804.0x48e8]
0x765b1985 in KERNELBASE!CtrlRoutine () from
C:\WINDOWS\SysWOW64\KernelBase.dll
Any ideas how to stop it hanging, and make it debug with the file input? Thanks
回答1:
you probably did not give proper input file name, your setup ran no problem with gfortran on my laptop. if I give unexisting input it freezes and after CTRL+C I get the same warning.I would print what is read just to verify that it is working properly
来源:https://stackoverflow.com/questions/57859014/gdb-debugger-hangs-on-fortran-read-command-when-reading-from-a-text-file