Path: utzoo!utgpu!water!watmath!clyde!rutgers!rochester!cornell!calvin!richard From: richard@calvin.EE.CORNELL.EDU (Richard Brittain) Newsgroups: comp.lang.fortran Subject: Re: Forced variable declaration Summary: REAL fortran programmers don't declare variables (unfortunately) Message-ID: <190@calvin.EE.CORNELL.EDU> Date: 28 Jan 88 09:26:45 GMT References: <445@drilex.UUCP> <50500018@uxe.cso.uiuc.edu> Organization: Cornell Space Plasma Physics, Ithaca, NY Lines: 44 In article <50500018@uxe.cso.uiuc.edu>, mcdonald@uxe.cso.uiuc.edu writes: > >I agree. That's why it's a good idea for FORTRAN programmers to include > >the line IMPLICIT LOGICAL (A-Z) or IMPLICIT CHARACTER (A-Z) in each main > >program and subprogram. Even better, many compilers now make an > >IMPLICIT NONE available. > ... One of the original goals > of Fortran was to eliminate the drudge work from progamming, and variable > declaration is one of the worst..... > ... The argument about mispelled variable names is a red > herring that any REAL Fortran scientific programmer would recognize. An > actual mistyped name is easily caught- it doesn't take any 6 hours..... I agree that implicit type declarations are a useful feature, and certainly make for convenience on a "quick hack" and on large projects also. However, I think that "real" fortran programmers are all too often scientists first and programmers second, and it really shows in the style, and hinders understanding and modification later. Granted, old fortran was not an easy language in which to lay out structured, modular code, but that hardly excuses some of the "spaghetti" code one often finds in scientific programs (even code published as part of theses!). I write/use both "system" programs and "scientific" programs, using fortran for both, and I find that my system code looks like C (almost everything declared, very structured, very modular, and lower case). After learning (what I hope are) good programming skills, I became so aware of bad practises in a lot of the old code that I work with, that now I simply don't trust a lot of "working" code until I spend time checking it out. I am spoiled by having a very friendly compiler to work with (allows many structured extensions to f77, like while()...end while, do...until(), loop(n)...end loop etc. (not a goto is sight) but still, even with vanilla f77, I think it would make a big difference to the maintainance and portability of scientific code if the authors learned good programming style. Fortran is still, and will always be my language of choice for numerical work, (although I finally broke down and started learning C recently), but I would love it if some of my scientist colleagues were better programmers. Two books on the subject which made a big difference to me are "The elements of programming style" and "Software Tools" both by Kernighan and Plauger. These have been around for a while but are still worth mentioning. Richard Brittain, Cornell Space Plasma Physics Group ARPA: richard@calvin.ee.cornell.edu