[patch,fortran] PR25828 F2003 Stream I/O
Jerry DeLisle
jvdelisle@verizon.net
Thu Aug 3 06:03:00 GMT 2006
:ADDPATCH fortran:
The attached patch adds STREAM I/O capability to gfortran. The implementation
uses the dtp->rec variable to keep track of the file position for reads and
writes. This is done to maintain compatibility with current library data
structures. Formatted and unformatted STREAM I/O are handled using existing
lower level functions by adding appropriate condition checks.
Not all INQUIRE functionality is implemented yet and can be added as a separate
patch. INQUIRE(unit=xyzzy, ACCESS=astring) works. "POS=" is not implemented
yet in INQUIRE.
I would like to extend thanks to Janne Blomqvist and Steve Kargl for off-list
reviews.
Current plan is to commit this to 4.3 when approved and then back patch to 4.2.
I think the patch is safe enough for 4.2 now if consensus dictates doing so now.
I would appreciate all the testing that folks can find time for. This has been
tested and regression checked on i686-linux-pc-gnu. Other platforms would be
greatly appreciated.
Those of you who are advanced Fortran gurus, please feel free to try this out.
I am very interested in identifying any corner cases I missed.
Finally, front-end gurus: I would appreciate input on how to INQUIRE dtp->rec
from the st_parameter_dt structure. It is not so obvious to me.
Also included with the patch are several initial test cases.
Ready to commit?
Regards,
Jerry
2006-08-02 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/25828
* io.c: Add new IO tag for file position.
(match_dt_element): Match the new tag.
(gfc_resolve_dt): Resolve the new tag.
2006-08-02 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/25828
* io/file_pos.c (st_backspace): Ignore if access=STREAM.
(st_rewind): Handle case of access=STREAM.
* io/open.c (access_opt): Add STREAM_ACCESS.
(edit_modes): Set current_record to zero only if not STREAM.
(new_unit): Initialize maxrec and recl for STREAM.
* io/read.c (read_x): Advance file position for STREAM.
* io/inquire.c (inquire_via_unit): Add text for access = "STREAM".
* io/io.h (enum unit_access): Add ACCESS_STREAM.
Add prototype for is_stream_io () function.
* io/unit.c (is_stream_io): New function to return true if access =
STREAM.
* io/transfer.c (file_mode): Add modes for unformatted stream and
formatted stream. (current_mode): Return appropriate file mode based
on access flags.
(read_block): Handle formatted stream reads.
(read_block_direct): Handle unformatted stream reads.
(write_block): Handle formatted stream writes.
(write_buf): Handle unformatted stream writes.
(pre_position): Position file for STREAM access.
(data_transfer_init): Initialize for stream access, skip irrelevent
error checks.
(next_record_r),(next_record_w), and (next_record): Do nothing for
stream I/O.
(finalize_transfer): Flush when all done if stream I/O.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr25828-0.diff
Type: text/x-patch
Size: 27382 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060803/91e70a0c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamio_1.f90
Type: text/x-fortran
Size: 454 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060803/91e70a0c/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamio_2.f90
Type: text/x-fortran
Size: 475 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060803/91e70a0c/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamio_3.f90
Type: text/x-fortran
Size: 552 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060803/91e70a0c/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamio_4.f90
Type: text/x-fortran
Size: 961 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060803/91e70a0c/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamio_5.f90
Type: text/x-fortran
Size: 689 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060803/91e70a0c/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamio_6.f90
Type: text/x-fortran
Size: 1057 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060803/91e70a0c/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamio_7.f90
Type: text/x-fortran
Size: 629 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060803/91e70a0c/attachment-0007.bin>
More information about the Fortran
mailing list