andy@syma.sussex.ac.uk (Andy Clews) (07/20/90)
A short time ago I posted a question about sending unformatted or binary output to the standard output channel of a Fortran program; the principal requirement being to pipe the output over a network. Quite a number of people sent me ideas and a summary of most of them appears below. I regret that I have lost some of the replies, but Thank You to all those who took the trouble to email me. From James C Burley <burley@world.std.com> If computing power is the issue, rewriting (especially transforming) into C certainly wouldn't be a good answer even if it were easy. If the program source is available and the program can be rebuilt, perhaps a solution would be to use a different unit number (say 7) and, at the beginning of the program, use OPEN(UNIT=7,FILE='filename', FORM='UNFORMATTED') (I'm not sure about the FORM= offhand; look it up to make sure). I'm assuming that you can come up with a name for filename that either explicitly says "write me to system A" via a UNIX pathname or that specifies some kind of mappable connection. I'm not a UNIX person (yet) so I can't say for sure, but very likely OPEN can solve the problems. From Peter Montgomery <pmontgom@math.ucla.edu> If your compiler supports the A format on non-character data, then try using it (e.g., write each real*4 using an A4 format). This may or may not work (e.g., when reading, there may be data erroneously interpreted as end of line). Also check the documentation for OPEN on your system. In any case, be sure your data types have identical binary representations on the sending and receiving machines. From dd horsfall x-4622 <ddh@hare.udev.cdc.com> I suggest checking to see if your compiler preconnects (internal OPENs) a few files for you. Probably, the run-time-library has done you this favor, and pre-opened certain unit numbers ( some use 5,6, and 0 for stdin, stdout, and stderr, respectively), and the mode would be 'FORMATTED' by default. Without knowing details of your particular implementation, it is likely that "all you gotta do is" CLOSE and re-OPEN the file, specifying FORM='UNFORMATTED'. From David Levine <levine@crimee.ics.uci.edu> Message-Id: <9007190931.aa13429@PARIS.ICS.UCI.EDU> Sender: levine%edu.uci.ics.crimee@paris.ics.uci.edu Status: RO > I wonder if one could open "/dev/tty" (which automatically refers to your > login terminal) as a file - that would mean you wouldn't need to keep Yes, that should work! From Larry Jones <scjones%sdrc%thor@uunet.uu.net> > 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). One possibility would be to use f2c to automatically translate the fortran into c: Archive-name: f2c/03-Feb-90 Original-posting-by: mwm@a.gp.cs.cmu.edu (Mark Maimone) Original-subject: Re: free fortran to C translator Archive-site: research.att.com [192.20.225.2] Archive-directory: dist/f2c Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti) Source for f2c, the Fortran to C translator introduced a few days ago, is now available via both anonymous FTP and email. To find out about getting the source via email, send this message to netlib@research.att.com (or UUCP address research!netlib) send index from f2c To get it using anonymous FTP, ftp research.att.com and cd to directory dist/f2c. All files are stored in compressed format, you will need to uncompress(1) them on your system. From karish%mindcrf@ames.arc.nasa.gov >Rewriting in C is out of the question, >so I am told (existing Fortran program has about 1600 lines of code). How about rewriting to the extent of changing write(*) to vwrite(<arguments>), and linking against a variable-argument-list C function that spits out the data? -- 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