system calls - valgrind give error when printing the second line to file -


i'm using valgrind find faults in code. command use

 valgrind --leak-check=yes ./a.out 

and compile code -g code alone. many errors pointing single write line (the 3 printed values initialized , defined).

write (22,*) avlength, stdlength, avenergy 

all conditional jump or move depends on uninitialised value(s) error. said line second line bunch of lines printing single file. @ end of errors, 2 more, 1 pointing line opening file

resstep = int(conf*100/iterate)                if (resstep.lt.10)                   write (resfile, "(a5,i1)") "res00",resstep                elseif (resstep.lt.100)                   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 integer. error syscall param write(buf) points uninitialised byte(s). finally, error address 0x52d83f4 212 bytes inside block of size 8,344 alloc'd when flush file (before closing it).

i can't find logic here. if problem opening file in faulty way, wouldn't error @ first line?

i use f95 compile , gcc version 4.1.2. can't upgrade of it.

wild guess: check data type of resfile. string or unit number?

my fortran 95 beyond rusty try moving call open() before calls write() , pass integer resunit instead of resfile first argument write():

character(len=20):: resfile integer(kind=2)  :: resunit, resstep  resstep = 1 resfile = 'my-results' resunit = 22 open (unit=resunit, file=trim(resfile), status='replace', action='write') write(resunit, "(a5,i1)") "res00", resstep  end 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -