本文介绍了Fortran运行时错误“固定”通过编写输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用英特尔Fortran编译器进行编译时遇到了一些用于研究的旧代码的问题。在特定的子程序中,除非添加输出循环索引值的 write 语句,否则会出现段错误。

  do j = 1,ne 

某些东西

写(*,*)'j =',j

end

什么可能导致我的错误,我的分段错误? (注意:j被声明为一个整数)

谢谢,
keely

解决方案


  1. 经典的导致这种类型的错误的方法是通过插入写入语句来固定在数组的末尾走动 - 使用你的编译器打开边界检查和调试选项来检查这个;


  2. 提供给参数的参数之间不一致子计划和争论。再次,如果可能的话,使用你的编译器,否则你的眼睛。




  3. 赔率是5比1,其中一个是原因。


    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
    

    What could be causing my error such that this write statement would fix my segmentation fault? (Note: j is declared as an integer)

    thanks,keely

    解决方案

    Classic ways of causing this type of error which is 'fixed' by inserting write statements:

    1. walking off the end of an array -- use your compiler to switch on bounds-checking and debugging options to check for this;

    2. disagreement between arguments provided to a sub-program and arguments expected. Again, use your compiler if possible, your eyes otherwise.

    Odds are 5-to-1 that one of these is the cause.

    这篇关于Fortran运行时错误“固定”通过编写输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 12:42