> Date: Wed, 12 Dec 2001 14:21:26 -0500
> From: "Nofal, Mostafa" <[log in to unmask]>
> Hi all
>
> Which is faster in I/O operation.
Obviously the first one is faster.
Formatted I/O operations require the execution of bulky I/O routines
and an interpreter, and are therefore slow operations.
Doing the reading twice -- as in the second example --
first to read in one line of data and then to process the same
record again, in separate READ operations,
would considerably increase execution time,
perhaps almost double the execution time.
As well, there are overheads in reading in the record as an 80-byte record.
When the record is shorter than 80 characters, the input record
has to be expanded to 80 characters.
> Example
>
> INTEGER :: variable_1, variable_2
> INTEGER :: variable_3(:)
> REAL :: variable_5, variable_6;
> READ(unit, * ) variable_1, variable_2, variable_3, variable_5, variable_6
>
> OR
>
> INTEGER :: variable_1, variable_2
> INTEGER :: variable_3(:)
> REAL :: variable_5, variable_6;
> CHARACTER (LEN = 80 ) :: string
> .
> .
> READ(unit, '(80a)') string
> DO ..
> READ(string(m:n),*) variable_1
> etc.
>
> END DO
>
> -----------
> In other words is reading the whole record and then assign its components to
> the various variables is faster than reading and writing these variables.
>
> Cheers
>
> Mostafa
|