Fortran 77调试器以检查数组范围 [英] Fortran 77 debugger to check array bounds

查看:160
本文介绍了Fortran 77调试器以检查数组范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍然不愿意调试F77,并且在数组范围方面遇到了一些问题.我最近修改了一个冗长的代码,以具有新的数组大小.一切似乎都还不错,直到我注意到改变一个数组的方法,改变了另一个数组的方法.我认为在这段代码中的某个地方,赋值超出范围,正在写入其他数组.

I am still green to debugging F77 and am having some problems with array bounds. I recently modified a lengthy code to have new array sizes. Everything 'seemed' okay until I noticed methods to alter one array, altered another. Somewhere in this code, I assume, an assignment is out of bounds and writing to the other arrays.

Linux环境中是否有一个调试器/工具会捕获"越界异常?

Is there a debugger/tool in the linux environment that will 'catch' the out of bounds exception?

我当前正在使用gfortran

I am currently using gfortran

推荐答案

有一个标志,用于gfortran插入检查是否超出范围

There is a flag for gfortran to insert checks for out of bounds

-fbounds-check 启用对阵列的运行时检查的生成 下标和反对声明的 最小值和最大值.它也是 检查数组索引是否假定和 延迟形状数组 实际分配的范围.将来 这也可能包括其他形式的 检查,例如检查子串 参考.

-fbounds-check Enable generation of run-time checks for array subscripts and against the declared minimum and maximum values. It also checks array indices for assumed and deferred shape arrays against the actual allocated bounds. In the future this may also include other forms of checking, eg. checking substring references.

http://linux.die.net/man/1/gfortran

输出是所需的:

At line 2153 of file src/cdtm0402.f
Fortran runtime error: Array reference out of bounds for array 'wv1mp', upper bound of dimension 1 exceeded (78 > 77)

Backtrace for this error:
  + function coefdp (0x448BC3)
    at line 2153 of file cdtm0402.f
  + in the main program
    at line 371 of file cdtm0402.f
  + /lib64/libc.so.6(__libc_start_main+0xfd) [0x7ffff703da7d]

这篇关于Fortran 77调试器以检查数组范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆