Re: file reading problem
- From: *** Hendrickson <***.hendrickson@xxxxxxx>
- Date: Fri, 09 Sep 2005 16:06:10 GMT
Bart Vandewoestyne wrote:
I feel silly... i must have been staring at this for too long but i cannot see the problem... I am trying to read the first line of a text file to do some processing on it... I'm doing something like the following:
...
character(len=*), intent(in) :: pointset_file ... integer(kind=i4b), parameter :: max_chars = 100 integer(kind=i4b) :: my_unit character(len=max_chars) :: line integer(kind=i4b) :: ios
...
call get_unit(my_unit) open(unit=my_unit, file=pointset_file, iostat=ios, status="old", & access="sequential", action="read") if (ios == 0) then
Maybe I'm misunderstanding you here, but ios will be zero if there NO problems. Maybe you want ios /= 0 ?
*** Hendrickson
write(unit=*, fmt="(A)") "ERROR: could not open file "//pointset_file end if
read (unit=my_unit, fmt="(A)", iostat=ios) line if (ios /= 0) then print *, "ERROR" end if print *, "line = ", line
...
Opening the file goes without problems, but reading the first line of the file and trying to put the content in `line' always seems to give errors because `ios' is nonzero and the content of `line' is not the first line of my file.
What am i overlooking here? I've been staring at this for too long now...
Regards, Bart
.
- Follow-Ups:
- Re: file reading problem
- From: Arjen Markus
- Re: file reading problem
- References:
- file reading problem
- From: Bart Vandewoestyne
- file reading problem
- Prev by Date: file reading problem
- Next by Date: Re: collective nouns -- Re: Optimal programming advice
- Previous by thread: RE: file reading problem
- Next by thread: Re: file reading problem
- Index(es):