Dan,
I have also found that 'read (lu,*) string' does not work very well and prefer fmt='(a)'
Have you looked at list directed input, although I doubt it would be better than fmt=(a).
I tried the following simple code example with the following text input and the results are fairly predictable, with <space> or , being a field seperator for read (,*).
character line*80
!
do
read (*,*) line
write (*,*) trim (line)
end do
end
aaa
this is a lot
'this is a lot'
123,33
'this is more'
I have a general numeric field reading routine which
- first reads a line of text into a character string,
- parse the character string by replacing <space>, <tab> or ';' with a ',' and then
- reads using a format statement, such as fmt=(i15,3f15.0), using the ',' as a recognised field seperator. (15 is big and expect ',' to terminate each number)
- for repeated spaces, I only replace the first space
I do this as I do get text input files which use any of <space>, <tab> or ; as well as , for the number field seperator as some of these characters are not recognised by the Fortran Standard. (something worth noting, before you complain too loudly about what read (,*) does or doesn't do!)
Note, if <tab> (<ht>) is expected in the file, then you have to call READ_TABS@(unitno) immediately after the OPEN statement to retain the tab character in the character input field, otherwise they are replaced by any number of spaces.
Further care is required if non standard text fields are expected. (Standard text fields expect to be enclosed as 'string' or 'string'.)
All this can be placed in a subroutine get_line_string to make it more robust.
John