Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with I/O problem

Status
Not open for further replies.

jtaylor1981

Programmer
Feb 27, 2004
1
0
0
GB
Hi,
I don't have a great deal of experience with fortran and wondered if someone can help me. I have a file with text in and I want to read it character by character not record by record. How do I do this?

Thanks for any help you can give me

Jeremy
 
Hi,
try to use the ADVANCE='NO' option in the READ statement. for example :

Code:
   [blue]CHARACTER(1)[/blue] Car
   .../...
   [blue]OPEN[/blue](10,FILE=.....)
   .../...
   [blue]READ[/blue](10,'(A)',ADVANCE='NO') Car
   .../...
Nevertheless you need to detect the end of the line (by checking the value of Car). You will find more information in the fortran help on the READ instruction.
 
If you wish to read all characters (included LF, CR ..),
open the file as a BINARY file (FORM='BINARY' in the OPEN command.
 
Another alternative is to open the file with FORM='UNFORMATTED'
 
If you are reading a text file, then do NOT use FORM='unformatted' to read the file. That should only be used when reading a file written with FORM='unformatted'. This is due to the fact that the Fortran compiler expects to find record size information as part of a file when using FORM='unformatted'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top