Monday 22 June 2009

Formatted Read Statements again.

Grrr. I'm trying to read in a formatted file of integers such as:
1 1 1
10 10 10
100 100 100
(... three characters wide, one space between each column)
Fortran is giving me junk unless I format my read statement with
10 format(I3,A1,I3,A1,I3)
where I read the single space into a temporary variable declared as:
character(1) :: tmp
This is why I am in a bad mood with Fortran today. I put faith in it, and this is how it repays me. Plus, the fridge has frozen my tomatoes. I wonder if they are in league.

2 comments:

midibu said...

Wrong tool for the job, dear Fishpaste. Why do you scientists have such loyalty to a language which can't simply split an input string by whitespace?

I have written COBOL at work and it also sucks at non-fixed-format data.

Michael

Ali said...

Alas! I know. But still I can't help defending Fortran even so. I hate it but I can't let it go!