[comp.lang.fortran] Unformatted

andy@syma.sussex.ac.uk (Andy Clews) (07/07/90)

Someone I know (no, it isn't me) wants to run a Fortran program that
produces very large amounts of unformatted/binary output. Rather than send
the output to a file on the host machine, she would like to pipe it
(or redirect it) so as to send the output through the LAN to her
own machine, on which she is running the program via rsh(1).

That is, she is logged into host A; the executable is on host B; she
wants to run it on B and send the output over the LAN to host B, by
doing    rsh B "foo" > foo.output    (foo.output thus appearing on host A).

Machine B has more computing power but not enough disk space to hold the
output.

The problem is that Fortran does not seem to allow unformatted i/o on
the standard channel, stdout. The compiler in use is ATS Fortran on a
Sequent Symmetry S81, running DYNIX 3.0.17. The statements that are
giving the problem are of the form

	write(*) list

We've tried using  write(6)  but no joy.

This seems to me a useful application for Fortran in a UNIX environment;
shame it doesn't seem possible. Rewriting in C is out of the question,
so I am told (existing Fortran program has about 1600 lines of code).

Can anyone advise?

-- 
Andy Clews, Computing Service, Univ. of Sussex, Brighton BN1 9QN, England
JANET: andy@syma.sussex.ac.uk   BITNET: andy%syma.sussex.ac.uk@uk.ac

whit@milton.u.washington.edu (John Whitmore) (07/19/90)

In article <3051@syma.sussex.ac.uk> andy@syma.sussex.ac.uk (Andy Clews) writes:
>Someone I know ...[wants to] send the output through the LAN to her
>own machine, on which she is running the program via rsh(1).
>
>That is, she is logged into host A; the executable is on host B; she
>wants to run it on B and send the output over the LAN to host B, by
>doing    rsh B "foo" > foo.output    (foo.output thus appearing on host A).
>
>The problem is that Fortran does not seem to allow unformatted i/o on
>the standard channel, stdout.  The statements that are
>giving the problem are of the form
>
>	write(*) list
>
>We've tried using  write(6)  but no joy.
>
	Using the always-open I/O unit means... you haven't
formally OPEN'ed it.  Thus, you are at the mercy of some 
implementation mechanic who decided what the OPEN should be...
and he obviously decided it would be FORM='FORMATTED'.
	Use instead an explicitly opened unit; on VMS systems
(which is all I'm familiar with), this would be done as

	OPEN(unit=36, file='SYS$OUTPUT:',form='UNFORMATTED')

after which a 'write(36) list' should give the unformatted output
to the standard output channel.  Because of file access control
for a file opened more than once, you might have to specify
a lot of other things in the OPEN statement... because the
standard output may be written to in the FORMATTED way by other
code (error handlers, for instance, in most large programs).
In particular, 'WRITEONLY' might be a useful addition.


I am known for my brilliance,            John Whitmore
 by those who do not know me well.

jerry@violet.berkeley.edu (Jerry Berkman) (07/29/90)

In article <3051@syma.sussex.ac.uk> andy@syma.sussex.ac.uk (Andy Clews) writes:
>Someone I know (no, it isn't me) wants to run a Fortran program that
>produces very large amounts of unformatted/binary output. Rather than send
>the output to a file on the host machine, she would like to pipe it
>(or redirect it) so as to send the output through the LAN to her
>own machine, on which she is running the program via rsh(1).
>
>That is, she is logged into host A; the executable is on host B; she
>wants to run it on B and send the output over the LAN to host B, by
>doing    rsh B "foo" > foo.output    (foo.output thus appearing on host A).
>
>Machine B has more computing power but not enough disk space to hold the
>output.
>
>The problem is that Fortran does not seem to allow unformatted i/o on
>the standard channel, stdout. The compiler in use is ATS Fortran on a
>Sequent Symmetry S81, running DYNIX 3.0.17. The statements that are
>giving the problem are of the form
>
>	write(*) list
>
>We've tried using  write(6)  but no joy.
>
>Can anyone advise?
>
>-- 
>Andy Clews, Computing Service, Univ. of Sussex, Brighton BN1 9QN, England
>JANET: andy@syma.sussex.ac.uk   BITNET: andy%syma.sussex.ac.uk@uk.ac

First try "open(6,form='unformatted')".  If that doesn't work, you could
try using formatted I/O with "a" format terms.  This has a few problems.
First, you get an unwanted trailing line feed.  Try using "$" at the
end of the format, but then you may overflow your buffers.
Second, I seem to recall a bug in old versions of the f77 libraries in
which nulls are accidentally filtered out during "a" format output.

Another option is to have the program write small temp. files,
"cat" each one to standard output, e.g.:

	call doit
	call doit
	end
	subroutine doit
	dimension x (5)
	open(20,form='unformatted')
	do 10 i=1,5
		x(i) = i
10	continue
	write(20) x
	close(20)
	call system( 'cat fort.20; rm fort.20')
	end

This works on our system (VAX 8650, 4.3 BSD f77).  It might also work
with just a close & rewind.  I would also put know identifiers before and
after the data I wanted to make sure nothing funny is happening, e.g.:
	write(20) 2*31-1, x, 2*30-1

	- Jerry Berkman, U.C. Berkeley
	 jerry@violet.berkeley.edu
	 (415)642-4804

Disclaimer: Views are my own not UCB, ...