Previous | Table of Contents | Next |
HPF (Koelbel, Loveman, Schreiber, Steele, & Zosel, 1993) is a set of extensions to Fortran to assist in enhancing the performance of Fortran programs, particularly on computers with multiple processors and distributed memory. The most important feature of the language is a set of directives that indicate how data (particularly arrays) are to be distributed among the multiple memories associated with the processors of the system. HPF was developed by a consortium of interested parties, both vendors and users, and it is not a standard adopted by one of the official standards bodies, such as ISO or IEEE. HPF compilers are available for a number of systems.
To give just one simple example, the HPF directives in the following code fragments indicate that if there are eight processors, then jupiter(1:125) is mapped to the first processor, jupiter(126:250) is mapped to the second processor, and so on:
real, dimension (1000) :: jupiter !HPF$ distribute (block) :: jupiter
In the next example, saturn(1:150) is mapped to processor 1, saturn(151:300) is mapped to processor 2, and so on:
real, dimension (1000) :: saturn !HPF$ distribute (block (150)) :: saturn
There must be at least
processors (or seven processors, in this case); if there are eight processors, the seventh has only 100 elements, saturn(901:1000), and the eighth none.
For more information on HPF, go to
http://www.crpc.rice.edu/HPFF/home.html.F (Adams, Brainerd, Martin, & Smith, 1996; Brainerd, Goldberg, & Adams, 1996) is a clean, elegant, but powerful subset of Fortran that contains all the modern features of the language but does not contain older features that have more modern replacements. Also, many redundancies are eliminated, such as one of the two source forms and all but one of the many ways to declare variables. Thus, F is perfect for developing new Fortran code and for teaching programming. Most of the examples in this book conform to F. F books and compilers for most major computing systems are inexpensive and can be purchased from Imagine1, Inc. (http://www.imagine1.com/imagine1).
The remaining sections illustrate the major features of Fortran 95, primarily with the use of examples. In this exposition, there is not sufficient space to discuss the detailed rules about how to use the features. Most of the features discussed are part of the F subset (Brainerd, Goldberg, & Adams, 1996); these are the features that should be learned in programming courses and the features that should be used by professional programmers when writing new code or modifying old code.
The first example is a program that prints the result of an addition:
program calculation_1 print *, 84 + 13 end program calculation_1
The program calculation_1 tells the computer to add the numbers 84 and 13 and then to print the sum, 97.
A Fortran program consists of a sequence of statements; these statements are written on lines that may contain from 0 to 132 characters.
1.2.1.1. Continued Statements
Often a Fortran statement fits on one line, but a statement can be continued onto multiple lines if the last character of the line to be continued is an ampersand (&):
print *, & I hope this is the right answer.
A statement cannot have more than 40 lines.
A statement cannot be broken in the middle of a keyword, a name, or a constant. If it is necessary to break a long character string, use the concatenation operator (//), as shown in the following example:
print *, & This is a line that contains a really, // & really, really, long character string.
The important fact is that, in the absence of a continuation symbol, the end of a line marks the end of a statement.
Each Fortran statement (except the assignment statements) begins with a keyword, such as print, that identifies the kind of statement it is.
1.2.1.2. Significant Blank Characters
Blank characters are significant in a Fortran program. In general, they must not occur within items that normally are not typed with blanks in English text, such as names and numbers. On the other hand, they usually must be used between two items that look like words. For example, in the first line of a program, the keyword program and the name of the program must be separated by one or more blanks, as in
program add_2
Keywords and names such as print and number must contain no blank characters, but keywords consisting of more than one English word may contain blanks between the words, as in the statement
end do
Two or more consecutive blanks are always equivalent to one blank unless they are in a character string.
1.2.1.3. Comments
Any occurrence of the exclamation symbol (!) other than within a character string or a comment marks the beginning of a comment. The comment is terminated by the end of the line. All comments are ignored.
Because comments are ignored, it is permissible to place a comment after the ampersand continuation symbol without impairing the continuation:
real :: x, & ! measured value xbar ! smoothed value
Previous | Table of Contents | Next |