Fortran 运行时错误“已修复"通过写输出 [英] Fortran runtime error "fixed" by writing output
问题描述
我在使用一些用于研究的旧代码时遇到问题,我想使用英特尔 Fortran 编译器进行编译.在一个特定的子例程中,我会遇到分段错误,除非我添加一个只输出循环索引值的 write
语句.
I've having trouble with some old code used for research that I would like to compile using the Intel Fortran compiler. In a particular subroutine, I get segmentation faults unless I add in a write
statement that just outputs the value of the loop index.
do j=1,ne
SOME STUFF
write(*,*) 'j=', j
end
什么可能导致我的错误,以至于这个写语句可以修复我的分段错误?(注:j 声明为整数)
What could be causing my error such that this write statement would fix my segmentation fault? (Note: j is declared as an integer)
谢谢,凯利
推荐答案
导致此类错误的经典方法,通过插入 write 语句修复":
Classic ways of causing this type of error which is 'fixed' by inserting write statements:
离开数组的末尾——使用你的编译器打开边界检查和调试选项来检查这个;
walking off the end of an array -- use your compiler to switch on bounds-checking and debugging options to check for this;
提供给子程序的参数与预期的参数不一致.同样,如果可能,请使用您的编译器,否则请使用您的眼睛.
disagreement between arguments provided to a sub-program and arguments expected. Again, use your compiler if possible, your eyes otherwise.
其中之一是原因的可能性是 5 比 1.
Odds are 5-to-1 that one of these is the cause.
这篇关于Fortran 运行时错误“已修复"通过写输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!