GDB调试器会挂在Fortran

GDB调试器会挂在Fortran

本文介绍了从文本文件读取时,GDB调试器会挂在Fortran READ命令上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

这是我的fortran代码(fortcode.for)

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

我使用以下命令将fortran文件编译为可执行文件(fortexec.exe).

I compile the fortran file into an executable (fortexec.exe) using the following command.

gfortran -g -fno-align-commons fortcode.for -o fortexec.exe

然后我通过输入来使用gdb调试器

I then use gdb debugger by typing

gdb fortexec

然后我给它以下文件输入(input.inp)

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

通过键入以下内容

run < input.inp

它开始运行,但随后挂起.

It starts running but then just hangs.

我按Ctrl-C中断它,然后它给我以下结果

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

推荐答案

您可能没有提供正确的输入文件名,您的笔记本电脑上的gfortran设置没有问题.如果我给出不存在的输入,它将冻结,并且在CTRL + C之后,我将收到相同的警告.我将打印读取的内容,以验证其是否正常运行

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

这篇关于从文本文件读取时,GDB调试器会挂在Fortran READ命令上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 11:19