Re: Writing $00-$FF via Fortran



RadSurfer <RadSurfer@xxxxxxxxx> wrote:

I am in need for an important project to write out simple
unsigned-char values in the range $00 through $FF,
without any extraneous data being added:...

You want the F2003 feature stream I/O. With stream I/O, this is all
pretty straightforward; that's exactly what unformatted stream I/O does.
Just open with access='stream', form='unformatted'. Several f90/f95
compilers have implemented this f2003 feature.

If your compiler doesn't have the f2003 stream I/O feature, it almost
surely does have some simillar functionality, but alas the exact
spelling varies; that's part of why it needed standardizing in f2003.
Although the spelling varies, the functionality is pretty widespread.

If you really want to stick to something that is highly portable to all
f90/f95 (and even f77) compilers with no changes at all, one can use
unformatted direct access, but that's a bit of a pain. It has to use
fixed-size records.You can do your own record management within the
fixed-size blocks, but that can be quite a pain (I well know) and has a
bunch of caveats.

Email to: RadSurfer@xxxxxxxxx

No. I only post newsgroup answers on the newsgroup.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: Formatted stream I/O
    ... understood by my ifort version: ... Stream I/O is a new feature in version 10.1. ... I will report this ...
    (comp.lang.fortran)
  • Re: fseek and unformatted sequential files
    ... access the file using direct access? ... I checked the Lahey web site and the current versions of their compilers do not support Fortran 2003 Stream I/O. ...
    (comp.lang.fortran)
  • Re: fortran code for cp / subroutine file_copy
    ... While trying to implement my file_copy subroutine, ... portability than others, but none are 100%. ... stream I/O is compiler-dependent and the exact spelling ... but most compilers have the functionality one way or another. ...
    (comp.lang.fortran)
  • Re: fortran code for cp / subroutine file_copy
    ... different systems, but of course, the syntax of a copy command varies ... stream I/O is compiler-dependent and the exact spelling ... but most compilers have the functionality one way or another. ...
    (comp.lang.fortran)
  • Re: Suggestions on mimicing fgetc and fseek with F90
    ... > In message, Richard Maine ... >>Come f2003 compilers, I think you'll want to look at stream I/O, but the ... > the F2003 Stream I/O specification in all its glory. ... interest in portability, and having the feature in one or two compilers ...
    (comp.lang.fortran)