From: lionel@quark.enet.dec.com (Steve Lionel)
Subject: Re: Problems with portable Fortran terminal IO
Date: 4 NOV 93 21:09:39 [thread overview]
Message-ID: <2bcdt7$l52@jac.zko.dec.com> (raw)
In-Reply-To: 2bc6a2$rem@lll-winken.llnl.gov
In article <2bc6a2$rem@lll-winken.llnl.gov>, oberman@ptavv.llnl.gov writes...
>I have hit a surprising Fortran compatability problem, terminal record length.
>
>I have a WRITE to LUN *
> (WRITE *,200)buff
>
>where buff is CHARACTER*1 BUFF(132) and the format includes several header
>lines for a total length of about 250 characters. The FORMAT is quite long, but
>the string, buff is (132A). This fails with a output record overflow on the VAX
>(VMS 5.5-2, Fortran V5.9) but works on every other platform we run the code on.
>These include SunOS, HP-UX, Irix, UniCOS, and several others.
>
>the problem is that the default RECL for sequential formatted output is 133
>bytes. I'm curious why this limit is present. Any clues? Any way that is
>portable to get around this. The only thing I can fine is to explicitly open
>SYS$OUTPUT with a large RECL. And I have not found a "standard" way of doing
>this that will port to other platforms. CSC says I'm stuck.
The "why" is that the RTL allocates a record buffer when the file is
opened. On UNIX systems with stream I/O, this isn't necessary; one can
just write the data as one gets it, but on OpenVMS we have a record I/O
system and we have to buffer the data and write it once per logical
record.
Is there some reason you can't write these header lines as separate
records (in the Fortran sense)? Are you putting your own carriage control
in it? This is inherently non-portable. How about something like this?
WRITE (*,200) buf
200 FORMAT ('1Header line 1........'/
1 ' Header line 2........'/
2 1X,A132,
3 ' Header line 3........')
This will work on OpenVMS and should work everywhere else.
I realize that we could change the RTL to reallocate a larger buffer
when it became necessary. This is something I'll suggest to the
RTL folks as a "wish".
>I should note that for some reason if I do a declaration of CHARACTER*132 BUFF
>and load buff with 132 characters it will work file without a special OPEN. I
>don't understand this, either.
Ah.. you don't show your format, so I can't tell for sure, but if you
were using a CHARACTER*1 array with a format item of A132 or some such then
you'd CERTAINLY have a problem as each element would be taking up 132
bytes! If CHARACTER*132 BUFF works, then that's the way you should
do it. (I'm not sure what the other systems are doing here unless they're
somehow padding with NULs, which is not what the language standard calls
for.)
If you'd like more help with this, feel free to send me mail.
--
Steve Lionel lionel@quark.enet.dec.com
SDT Languages Group
Digital Equipment Corporation
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062 "Free advice is worth every cent"
prev parent reply other threads:[~1993-11-05 2:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-11-04 23:21 Problems with portable Fortran terminal IO oberman
1993-11-05 2:09 ` Steve Lionel [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox