Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Fortran can I rely in reading tabs-delimited ascii files with list-directed "read"

Tags:

fortran

Is it Fortran-standard compliant to read a tabs-delimited Ascii file like this one:

    0.11 0.12 0.45

(where the space is actually a tab) with list-directed input like this:

    read(11,*) real1,real2,real3
like image 902
Millemila Avatar asked Dec 04 '25 10:12

Millemila


1 Answers

A more interesting question than a first glance might suggest ...

The standard stipulates that blanks are to be recognised as value separators for list-directed input. In Table 3.1 'Special Characters' of (my version of the draft of) the standard a space is denoted Blank character, but there is no further explanation or definition of blank. So a space is definitely a blank inside the source of a Fortran program.

It is well known (??) that the tab character is not part of the Fortran character set, and some compilers will, by default, object to its presence in source files (outside character variable contexts). But I can't see any anyone writing a compiler that would fail to recognise a tab character as a blank for list-directed input of a list of numbers.

I think the answer to the question is

Whether or not a tab character is a value separator for an input list is processor dependent (i.e. it's left up to the compiler writer) so the standard doesn't stipulate that you can absolutely rely on this behaviour.

but I'll be interested to see what the language lawyers have to contribute on this one.

like image 64
High Performance Mark Avatar answered Dec 07 '25 21:12

High Performance Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!