Unformatted(binary) Fortran standard output

Jerry Berkman jerry at violet.berkeley.edu
Mon Jul 30 02:59:00 AEST 1990


In article <3051 at syma.sussex.ac.uk> andy at 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 at syma.sussex.ac.uk   BITNET: andy%syma.sussex.ac.uk at 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 at violet.berkeley.edu
	 (415)642-4804

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



More information about the Comp.unix.questions mailing list