stdout access='STREAM'

Steve Kargl sgk@troutmask.apl.washington.edu
Sun Jun 7 04:14:00 GMT 2015


(cc'd fortran@gcc.gnu.org)


On Sat, Jun 06, 2015 at 09:09:35PM -0500, George Wyche wrote:
> 
> Yes, I've read the list of instructions and compared them with the 2003
> standard, in about the same way as one "reads the bible". I quite
> understand that we don't have official "how to", and I don't expect to be
> among those volunteers who might write such a thing anytime soon.

The answer you seek is in the documentation.  You need
to set an environmental variable to switch pre-connected
units from buffered to unbuffered IO.

> I apologize for whining in the previous email. What I am looking for is
> what I first mentioned. I don't like trying to make examples that are
> almost, but not quite, on target. So far when I try to "bend" those to do
> what printf("%s", byte_string) does it dead ends. I think that it must be
> some hard won knowledge of steps through the swamp that is fraught with
> special cases for different OSes (or something). I have found no chatty
> article warning the unwary (me) about "you might think you could do X, but

Assuming a UNIX-like environment,

% setenv GFORTRAN_UNBUFFERED_PRECONNECTED yes
% cat foo.f
       program foo
       character*10 s
       s = 'oh my'
       write(*,'(A)') a
       end program foo

> Many, like me, inherited f77 code that was married to c i/o, and then I

If you're trying to interleave Fortran IO and C IO in one program,
good luck.  <hint>You'll need to flush after every IO statement.</hint>

> The documentation of the standard for 2003 is effusive about the
> advantages of ACCESS='STREAM', and other references spend a good deal of
> time explaining how to open a file and use the scheme.

Yes, they do.  There are also many references to preconnected units.

-- 
Steve



More information about the Fortran mailing list