home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!ames!haven.umd.edu!mimsy!afterlife!adm!aos!lapoint
- From: lapoint@adios.brl.mil (Claude LaPointe )
- Newsgroups: comp.lang.fortran
- Subject: RE: programming style question
- Message-ID: <982@aos.brl.mil>
- Date: 14 Aug 92 12:25:59 GMT
- Sender: news@aos.brl.mil
- Lines: 42
- Nntp-Posting-Host: adios.brl.mil
-
-
- tholen@galileo.ifa.hawaii.edu (Dave Tholen) writes:
-
-
- > A question about programming style: How many of you explicitly OPEN
- > preconnected units, which nowadays usually mean standard input, standard
- > output, and sometimes standard error (typically units 5, 6, and 0)? In
- > the old days, 5 and 6 were often card reader and printer. I haven't
- > been doing so myself, but the question came up recently because I've
- > ...
-
-
- Given that 0,1,2,5,6 and probably others are highly non-portable
- ways of addressing standard in, out, and error. It is better not to
- use them.
-
- Because the 77 standard didn't much consider the kinds of output
- capabilities now available, it didn't address standard error,
- so there is no choice but to use a unit number - however it should
- be done with the realization that porting may require a change in the
- value. That is, isolate its use as much as possible in a subprogram
- and define it with a parameter statement.
-
- With respect to standard in & out use "*" which must not appear in
- OPEN and CLOSE statements.
-
- Some time ago, an objection was raised to this on the basis that the
- "*" must be present at compile time, and so cannot be passed as an
- argument. Actually, it can, but clumsily. When the intent is to write
- to standard out, set the calling argument not to "*" but to some
- negative integer. Similarly for input.
-
-
- subroutine out (unit)
- integer unit
- ...
- if (unit.lt.0) then
- write (*,...
- else
- write (unit,...
- endif
- ...
-