PDA

View Full Version : file read and output problem


robelee
04-04-2004, 03:51 PM
Hi
I kindly wonder if anyone could see what's wrong with this program. It only writes rubbish to the screen. The object is to read a file and search for a word in a file and then outputs all the lines in file that does not contain the word.

Any help appreciated...


program uppgift3

character :: file, word

file='wordfile'
word='exam'

call remove(file, word)

end program uppgift3

subroutine remove(file word)

character :: file, word
character (80) :: line
integer :: i, j

open(10, file='file')

read(10, '(a)', iostat=i)line

if (index(rad, word)==0) print*, line
if (i<0) return

end subroutine remove

tzeis
04-05-2004, 08:01 PM
It seems like the error messages generated by the compiler accurately point out the problems in the code:

2005-W: "remove.f90", line 22: 'rad' is used but never set.
2005-W: "remove.f90", line 22: 'word' is used but never set.
2206-S: "remove.f90", line 22, column 5: Invalid type, attribute, or value of actual argument for intrinsic function 'INDEX'.