Fortran is the most widely used programming language in the world for numerical applications. It has achieved this position partly by being on the scene earlier than any of the other major languages and partly because it seems gradually to have evolved the features which its users, especially scientists and engineers, found most useful. In order to retain compatibility with old programs, Fortran has advanced mainly by adding new features rather than by removing old ones. The net result is, of course, that some parts of the language are, by present standards, rather archaic: some of these can be avoided easily, others can still be a nuisance. This section gives a brief history of the language, outlines its future prospects, and summarises its strengths and weaknesses.
In the interests of simplicity, the problems which these solve are hardly beyond the range of a good pocket calculator, and the programs shown here do not include various refinements that would usually be present in professional software. They are, however, complete working programs which you can try out for yourself if you have access to a Fortran system. If not, it is still worth reading through them to see how the basic elements of Fortran can be put together into complete programs.
This section describes the steps required to turn a Fortran program from a piece of text into executable form. The main operation is that of translating the original Fortran source code into the appropriate machine code. On a typical Fortran system this is carried out in two separate stages. This section explains how this works in more detail.
A complete Fortran program is composed of a number of separate program units. Each of these can contain both statements and comment lines. Statements are formed from items such as keywords and symbolic names. These in turn consist of characters.
All the information processed by a digital computer is held internally in the form of binary digits or bits. Suitable collections of bits can be used to represent many different types of data including numbers and strings of characters. It is not necessary to know how the information is represented internally in order to write Fortran programs, only that there is a different representation for each type of data. The data type of each item also determines what operations can be carried out on it: thus arithmetic operations can be carried out on numbers, whereas character strings can be split up or joined together. The data type of each item is fixed when the program is written.
Contents
1 What Is Fortran?
- 1.1 EarlyDevelopment
1.2 Standardization
1.3 StrengthsandWeaknesses
1.4 Precautions
2 Basic Fortran Concepts
- 2.1 Statements
2.2 Expressions and Assignments
2.3 IntegerandRealDataTypes
2.4 DO Loops
2.5 FormattedOutput
2.6 Functions
2.7 IF-blocks
2.8 Arrays
3 Fortran in Practice
- 3.1 TheFortranSystem
3.2 CreatingtheSourceCode
3.3 Compiling
3.4 Linking
3.5 ProgramDevelopment
4 Program Structure and Layout
- 4.1 TheFortranCharacterSet
4.2 StatementsandLines
4.3 ProgramUnits
4.4 StatementTypesandOrder
4.5 SymbolicNames
4.6 PROGRAM Statement
4.7 END Statement
5 Constants, Variables, and Arrays
- 5.1 DataTypes
5.2 Constants
5.3 SpecifyingDataType
5.4 NamedConstants
5.5 Variables
5.6 Arrays
6 Arithmetic
- 6.1 ArithmeticExpressions
6.2 ArithmeticIntrinsicFunctions
6.3 Arithmetic Assignment Statements
7 Character Handling and Logic
- 7.1 CharacterFacilities
7.2 CharacterSubstrings
7.3 CharacterExpressions
7.4 Character Assignment Statements
7.5 CharacterIntrinsicFunctions
7.6 RelationalExpressions
7.7 Logical Expressions
7.8 LogicalAssignmentStatements
8 Control Statements
- 8.1 Control Structures
8.2 IF-Blocks
8.3 DO-Loops
8.4 Logical-IFStatement
8.5 Unconditional GO TO Statement
8.6 Computed GO TO Statement
8.7 STOP Statement
9 Procedures
- 9.1 IntrinsicFunctions
9.2 StatementFunctions
9.3 External Procedures
9.4 ArgumentsofExternalProcedures
9.5 VariablesasDummyArguments
9.6 ArraysasArguments
9.7 ProceduresasArguments
9.8 Subroutine and Call Statements
9.9 RETURN Statement
9.10 FUNCTION Statement
9.11 SAVE Statement
9.12 EXTERNAL and INTRINSIC Statements
10 Input/Output Facilities
- 10.1 Files,I/OUnits,andRecords
10.2 ExternalFiles
10.3 InternalFiles
10.4 Pre-Connected Files
10.5 ErrorandEnd-Of-FileConditions
10.6 FormatSpecifications
10.7 Format Edit Descriptors
10.8 Format Data Descriptors A, E, F, G, I, L
10.9 FormatControlDescriptors
10.10 List-DirectedFormatting
10.11 Carriage-ControlandPrinting
10.12 Input/OutputStatementsandKeywords
10.13 OPEN Statement
10.14 CLOSE Statement
10.15 INQUIRE Statement
10.16 READ and WRITE Statements
10.17 REWIND and BACKSPACE Statements
11 DATA Statement
- 11.1 DefinedandUndefinedValues
11.2 InitialisingVariables
11.3 InitialisingArrays
11.4 DATA StatementsinProcedures
11.5 GeneralRules
12 Common Blocks
- 12.1 UsingCommonBlocks
12.2 BlankCommonBlocks
12.3 COMMON Statement
12.4 BLOCK DATA ProgramUnits
13 Obsolete and Deprecated Features
- 13.1 Storage of Character Strings in Non-character Items
13.2 Arithmetic IF Statement
13.3 ASSIGN and assigned GO TO Statements
13.4 PAUSE Statement
13.5 Alternate RETURN
13.6 ENTRY Statement
13.7 EQUIVALENCE Statement
13.8 SpecificNamesofIntrinsicFunctions
13.9 PRINT Statement and simplified READ
13.10 END FILE Statement
13.11 ObsoleteFormatDescriptors
14 Common Extensions to the Fortran Standard
- 14.1 MIL-STD-1753Extensions
A List of Intrinsic Functions
B Specific Names of Generic Functions
C GNU Free Documentation Licence
- C.0 PREAMBLE
C.1 APPLICABILITY AND DEFINITIONS
C.2 VERBATIMCOPYING
C.3 COPYINGINQUANTITY
C.4 MODIFICATIONS
C.5 COMBININGDOCUMENTS
C.6 COLLECTIONSOFDOCUMENTS
C.7 AGGREGATION WITH INDEPENDENT WORKS
C.8 TRANSLATION
C.9 TERMINATION
C.10 FUTURE REVISIONS OF THIS LICENSE
D Acknowkedgement
