'(*)' and List Directed I/O
- From: Ron Shepard <ron-shepard@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 15 Oct 2005 09:30:22 -0500
One of the things that has always bothered me about formatted I/O in
fortran (from f77 to f2003) is that different read statements are
required for list-directed I/O and I/O with explicit formats. I use
codes that read data files that have the formats intersperced with
the data. For example:
....
(4i4)
1 2 3 4
(5i5)
12345 1234 123 12 1
.....
The codes that read these data files do the obvious thing and read
the format into a character variable, and then use that character
variable to read the data.
When creating or modifying data files like this manually, it would
be convenient to be able to specify list directed I/O. For example,
(*)
12345,1234,123,12,1
Instead of something that requires you to count columns. This would
also allow for repeat counts in the data, arbitrary line breaks, and
so on. Fortran does not allow list directed I/O in this way.
Instead, the programs that read this data must do something like
read(nin,'(a') cfmt
if ( cfmt .eq. '(*)' ) then
read(nin,*) data
else
read(nin,cfmt) data
endif
Is there some reason why Fortran I/O is done the way it is in this
case? Why was list-directed I/O done in the special-case way that
it was rather than the (to me) more obvious and general way? Is
there any reason why it could not be changed now to include the
general way? Is there any chance that this could be submitted to
the J3 committee and it would be included in some future revision of
the language?
$.02 -Ron Shepard
.
- Follow-Ups:
- Re: '(*)' and List Directed I/O
- From: robin
- Re: '(*)' and List Directed I/O
- From: Ken Plotkin
- Re: '(*)' and List Directed I/O
- Prev by Date: Re: Modifying INTENT(IN) arguments using pointers
- Next by Date: Re: '(*)' and List Directed I/O
- Previous by thread: Modifying INTENT(IN) arguments using pointers
- Next by thread: Re: '(*)' and List Directed I/O
- Index(es):
Relevant Pages
|