1. Do spaces mater in Fortran equations?

No. Spaces are generally added for clarity. Some compilers get upset if you write things like " INTEGERI,J" rather than INTEGER I,J". Simple neatness will keep you out of these problems. Remember that a space is required in column 6 if you aren't continuing from the previous line. The following are all equivalent:

x=x*y**2*sin(x)
x=x * y**2 * sin(x)
x = x * y ** 2 * sin ( x )

2. What is the advantage of an array over a spreadsheet format?

Both can store similar types of information in a neatly labeled and organized way. The advantage lies in where they are used. You have more control over how Fortran arrays are used than how the contents of aspreadsheet are used. In addition for any given operation on an array of numbers, once the Fortran is written, it will do the job much faster than aspreadsheet. On the other hand, when operations are not complex and computer execution time is not a problem using the spreadsheet is probably your best bet.

3. What can we do if our lines wrap around to the next line?

You have to get a feel for the location of the 72nd character position on the screen, or do a lot of counting. Once you hit column 72, you must hit the RETURN key, put some character (I like & or #) in column 6 of the next line then pick up typing where you left off. I usually stop before column 72 at some natural break point between variables:

123456789012345678901234567890123456789012345678901234567890123456789012
IF ( (X.LT.2.0.AND.Y.GT.30.0).OR.(X.GT.1000.0.AND.Y.LT.-40.))
& PRINT *,' CALCULATION IS IN TROUBLE'

Since Fortran tends to ignore blanks, the extra ones in the above 2 lines don't cause problems.

4. Why does not Fortran have intrinsic functions for something as simple as factorial?

Two reasons. Factorial isn't all that common in heavy duty scientific and engineering applications. When it does occur, it almost always in a context where it is more computationally efficient to generate it as you go. You need 2! first then 3!, then 4!, etc. You are basically stuck doing a factorial within the context of a do loop unless you get really good and learn to write "recursive functions", but then you are just fooling yourself and writing another form of do loop. When you are taking the factorial of a large number and don't need an exact answer you can resort to Stirling's Approximation. A Fortran statement that will load the value of this approximation into the variable nfact is.

5. How do we know where various steps go in a Fortran program?

Some commands have special locations, but most are located by the needs of the specific program. The PROGRAM card is always first. Statements giving variable types (INTEGER, REAL, LOGICAL, CHARACTER, ...) should precede "executable" statements. The END card must always be at the end of the program unit.

6. Where can I get a Fortran Compiler for IBM PC?

We can pick up one on the internet from the GNU project, but get a better package from MOC for about \$80.00.

7. How do you use a logical variable? What is stored there?

Most frequently, logical variables are used in association with IF statements. When you want to set a logical variable LVAR to true you use "LVAR=.TRUE.". For false use "LVAR=.FALSE." In practice the computer usually stores an integer 0 in memory for false and integer 1 for true. The normal logical variable occupies 1 byte of space.

8. What directory is used by the compiler for compiling a Fortran Program? Where does f77 live?

For the work in this section, you should assume that everything happens in whatever directory you are in when you type the "f77". Type "pwd" if you don't know the answer to this question. The executable file called "f77" resides both in /bin and /usr/bin on these machines. This is very unsual. To locate an executable file use the "whereis" command (e.g. "whereis f77"). Unfortunately the manual pages on f77 aren't connected properly and are listed under IBM's other name for their compiler, "xlf". Try "man xlf" for more information on the compiler, but don't expect too much. IBM likes to force people to buy manuals and special CD-ROM packages.

9. Why do you put so many lines of empty space in your programs?

I hope the lines aren't totally empty. They should contain a "c" in column one. These "blank" lines are just to make the comments stand out from Fortran code lines or to highlight key blocks of a program.

10. How does Fortran 90 relate to FORTRAN 77?

With a few minor exceptions, Fortran 90 is a superset of X3.9-1978 FORTRAN.

But this does not mean that all "77" codes will port sans changes. Many (if not most) programmers employed constructs beyond the '77 standard, or rely on unspecified behavior (say, assuming that an OPEN of an existing file will position the file pointer to just past the last record already written) which has changed (that is to say, has become specified).