添加/删除PRINT语句会更改变量 [英] Adding/removing a PRINT statement changes variables
问题描述
我有一些编写fortran代码的经验,但我从未见过类似的东西。
我正在使用一个大型的HPC代码(约10K行),我正在修改一个子程序。我使用打印语句来验证一切正确,并在必要时进行调试。当我用我使用的最后一个 PRINT
语句运行我的代码时,代码在任何地方都给出了实际的数字。一旦我评论这最后一个 PRINT
语句,代码给我 NaN
是我的一些变量。由于我的代码太大,我显然无法在这里发布,但我会发布 PRINT
语句:
PRINT *,outletBC up1,SUM(ABS(up(nptsx,:,:)))
其中 up
是某个速度数组。
问题:
这怎么可能? PRINT
语句如何影响任何变量?
I have some experience writing fortran codes but I have never seen something like this.
I am using a large HPC code (~10K lines) in which I am modifying a subroutine. I used print statements to verify that everything was done correctly and debug if necessary. When I run my code with the last PRINT
statement I used, the code is giving me real numbers everywhere. Once I comment this last PRINT
statement, the code is giving me NaN
is some of my variables. Since my code is too big, I obviously can't post it here, but I'll post the PRINT
statement:
PRINT*, "outletBC up1 ", SUM(ABS(up(nptsx,:,:)))
where up
is some velocity array.
QUESTION:
How is that possible? How can a PRINT
statement possibly affect any variable?
I think this is indicative of some other errors in the code (e.g. memory corruption). I am not sure what debug flags you used. However, try compilation flag "-check all" (for intel fortran compiler). This flag checks for multiple possible errors. For more details, you can refer to https://software.intel.com/sites/default/files/m/f/8/5/8/0/6366-ifort.txt
这篇关于添加/删除PRINT语句会更改变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!