The overall program structure should be modular. We see that the structure of a function closely resembles that of the main program. The conditional expressions are evaluated in sequence until one is found to be true. For gutorial reason, the data statement is mainly used in the main program and not in subroutines. Finally, note that we have stuck to the convention that matrices have m rows and n columns.
|Published (Last):||28 January 2013|
|PDF File Size:||4.36 Mb|
|ePub File Size:||9.65 Mb|
|Price:||Free* [*Free Regsitration Required]|
Fortran Fortran The most common Fortran version today is still Fortran 77, although Fortran 90 is growing in popularity. Fortran 95 is a revised version of Fortran There are also several versions of Fortran aimed at parallel computers. Users should be aware that most Fortran 77 compilers allow a superset of Fortran 77, i.
Why learn Fortran? It is therefore important for engineering graduates to be able to read and modify Fortran code. From time to time, so-called experts predict that Fortran will rapidly fade in popularity and soon become extinct. These predictions have always failed. Fortran is the most enduring computer programming language in history. One of the main reasons Fortran has survived and will survive is software inertia. Once a company has spent many man-years and perhaps millions of dollars on a software product, it is unlikely to try to translate the software to a different language.
Reliable software translation is a very difficult task. Consequently, if your program is written in ANSI Fortran 77, using nothing outside the standard, then it will run on any computer that has a Fortran 77 compiler. Thus, Fortran programs are portable across machine platforms.
If you want to read some Fortran Standards Documents, click here. The text has to follow a certain structure to be a valid Fortran program. We start by looking at a simple example: program circle real r, area c This program reads a real number r and prints c the area of a circle with radius r.
Originally, all Fortran programs had to be written in all upper-case letters. Most people now write lower-case since this is more legible, and so will we.
You may wish to mix case, but Fortran is not case-sensitive, so "X" and "x" are the same variable. Program organization[ edit ] A Fortran program generally consists of a main program or driver and possibly several subprograms procedures or subroutines.
For now we will place all the statements in the main program; subprograms will be treated later. The structure of a main program is: program name declarations statements stop end In this tutorial, words that are in italics should not be taken as literal text, but rather as a description of what belongs in their place. The stop statement is optional and may seem superfluous since the program will stop when it reaches the end anyway, but it is recommended to always terminate a program with the stop statement to emphasize that the execution flow stops there.
You should note that you cannot have a variable with the same name as the program. Column position rules[ edit ] Fortran 77 is not a free-format language, but has a very strict set of rules for how the source code should be formatted.
The most important rules are the column position rules: Col. Note that many examples in this document have been slightly reformatted to improve their layout in the WIKI environment. A single space character has been added to the beginning of each code line to prevent the wiki framework from interpreting the first character as a markup command. Empty lines terminate formatting of code examples but a single space followed by newline displays as an empty line of code and continues the example.
Annoyingly, another deficiency in the wiki framework is the requirement to tack a closing element tag on to the end of the element content for elements such as pre or code to prevent an additional blank line being added to the output box.
Fortran 77 Tutorial
Mikakinos The reason for this is the way Fortran 77 stores multidimensional arrays see the section on arrays. This will cause great confusion. The reason for this is that only the values of m and n had been copied to the subroutine iswap, and even if a and b were swapped inside the subroutine the new values would not have been passed back to the main program. When a program is more than a few hundred lines long, it gets hard to follow.
F77 TUTORIAL PDF
Fortran Fortran The most common Fortran version today is still Fortran 77, although Fortran 90 is growing in popularity. Fortran 95 is a revised version of Fortran There are also several versions of Fortran aimed at parallel computers. Users should be aware that most Fortran 77 compilers allow a superset of Fortran 77, i. Why learn Fortran? It is therefore important for engineering graduates to be able to read and modify Fortran code.