我正在使用valgrind在我的代码中查找错误。我使用的命令是valgrind在将第二行打印到文件时给出错误
,我编译代码单独-g
代码。我得到了很多指向单个写入行的错误(三个打印值被初始化并定义完好)。
write (22,*) avlength, stdlength, avenergy
全部与Conditional jump or move depends on uninitialised value(s)
错误。所述行是从一堆行打印到单个文件的第二行。在错误的结束,我得到两个,一个指向行打开文件
resStep = int(conf*100/iterate)
if (resStep.lt.10) then
write (resFile, "(A5,I1)") "res00",resStep
elseif (ResStep.lt.100) then
write (resFile, "(A4,I2)") "res0",resStep
else
write (resFile, "(A3,I1)") "res",resStep
endif
open (unit=22,file=trim(resFile),status='replace',
c action='write')
resStep
是整数。错误是Syscall param write(buf) points to uninitialised byte(s)
。最后,当我清除文件时(在关闭文件之前)出现错误Address 0x52d83f4 is 212 bytes inside a block of size 8,344 alloc'd
。
我在这里找不到任何逻辑。如果问题是以错误的方式打开文件,是不是会在第一行显示错误?
我用f95编译这个,我的gcc版本是4.1.2。我无法升级任何它。
character(len = 20):: resFile。我的fortran Foo真的很差。我正在更新我的教授代码以满足我的需求。 – Yotam 2013-05-14 14:05:40
@Yotam,尝试在write()之前移动open()并将一个单位而不是一个字符(len = 20)传递给open()。我用一个简短的独立程序更新了我的答案。 – scottt 2013-05-14 14:45:40