Path: utzoo!attcan!uunet!world!burley From: burley@world.std.com (James C Burley) Newsgroups: comp.lang.fortran Subject: Re: Fortran 77 Style Guide (long, REPOST) Message-ID: Date: 14 Sep 90 13:46:22 GMT References: <26B89BE1.4349@ics.uci.edu> <59012@lanl.gov> <1794@ccadfa.adfa.oz.au> <1990Sep10.141639.970@maverick.ksu.ksu.edu> <90256.122601BOYDJ@QUCDN.BITNET> Sender: burley@world.std.com (James C Burley) Distribution: na Organization: The World Lines: 51 In-Reply-To: BOYDJ@QUCDN.QueensU.CA's message of 13 Sep 90 16:26:01 GMT In article <90256.122601BOYDJ@QUCDN.BITNET> BOYDJ@QUCDN.QueensU.CA (Jeff Boyd) writes: If you wanted to manage your FORMATs a little more carfully, use PARAMATERs, eg. PARAMETER (UNIT1=10,FMT1=1) 1 FORMAT ( ... ) and later WRITE (UNIT1,FMT1) var_list providing your Fortran allows a named constant in the FMT option. I've worked on some that didn't, but it's handy sometimes for managing odd problems. I don't think the example you give is valid -- but the wording "allows a named constant" at the end suggests you knew what you wanted to do, just got confused typing it. A format specifier may not be a named constant (PARAMETER name). It may be an integer variable to which one has ASSIGNed the desired FORMAT statement (I don't recommend this for this situation). It may also be a character array name or character expression, including a named constant, which is what I think you meant. (It may also be *, but that's list-directed formatting). So your example perhaps should have been something like this: INTEGER UNIT1 CHARACTER*(*) FORMAT1 PARAMETER (UNIT1=10,FORMAT1='(...)') WRITE(UNIT1,FORMAT1) var_list I.e. the FORMAT itself is within the PARAMETER statement. As others have pointed out (and I did in an earlier discussion on this same topic), the advantage of using a named constant for a FORMAT may be outweighed by the disadvantage of having your compiler not syntax-check the FORMAT for correctness to the same extent it does a FORMAT statement and/or the implementation of the program require reinterpretation of the named- constant FORMAT each time it is referenced in an I/O statement at run-time rather than once during compile time. Not all compilers/systems suffer both (or even either) disadvantage, but it can be a performance issue on some. James Craig Burley, Software Craftsperson burley@world.std.com