PREFACE INTRODUCTION Why Study Programming? The Evolution of FORTRAN Why Study FORTRAN? Classical FORTRAN About This Book . Motivation . Audience . Organization . Pedagogical Approach . Typographical Conventions . Computing Environment Dependencies Advice to Instructors About the Author Acknowledgements Disclaimers Exercises HELLO, WORLD! Case Study: A First FORTRAN Program Compiling the Program Running a Program in Unix Omissions Exercises EXPRESSIONS AND ASSIGNMENT STATEMENTS Constants Variables and Variable Names Arithmetic Operators Function References Expressions Assignment Statements READ and PRINT Omissions Exercises CONDITIONALS AND BRANCHING Flowcharting The GO TO Statement The IF-THEN Statement The Logical IF Statement Flowcharting Reconsidered Additional Examples Omissions Exercises SCALAR DATA TYPES Integers Reals Roundoff Errors Type Conversions Case Study: Computing the Sine Other Data Types . Complex Numbers .
Logicals . Bits, and Hexadecimal Numbers Some Special Values Architectural Variations Omissions Exercises ARRAYS AND DO LOOPS Vectors The DO Loop Matrices The Rules of DO Loops Array Dimensioning Case Study: Matrix Multiplication Omissions Exercises SUBPROGRAMS SUBROUTINE Subprograms Call by Reference FUNCTION Subprograms Case Study: Bisection Detecting First Entry FORTRAN, System, and Library Routines . FORTRAN Built-In Functions . Unix System Routines . Subprogram Libraries Conclusion and Omissions Exercises ADJUSTABLE DIMENSIONS AND EXTERNAL Adjustable Dimensions . Assumed-Size Arrays . Passing Leading Dimensions EXTERNAL . Fixed Subprogram Names .
Passing Subprogram Names Summary and Omissions Exercises COMMON Passing Data Through Passing Data Around Alignment . Alignment by Order . Alignment in Memory Formal Parameters and COMMON Arrays in COMMON BLOCK DATA Omissions Exercises INPUT AND OUTPUT READ and WRITE . FORMAT Statements . Cursor Control . End-of-File and Error Conditions Case Study: Descriptive Statistics Implied DO Loops Unit Assignments . Interactive Programs . Attaching Files with GETFIL .
Batch Programs The Case Study Revisited Positioning in Files Unformatted I/O Cautions and Omissions Exercises CHARACTER VARIABLES How Characters Are Stored Writing Out and Reading In CHARACTER Variables Editing Character Strings Object-Time FORMATs Case Study: QUERY CHARACTER Variables in Other Contexts . Reading From and Writing to CHARACTER Variables . Using CHARACTER Variables in OPEN . CHARACTER Functions Character Graphics . X-Y Plots . Contour Plots Omissions Exercises MEMORY MANAGEMENT TECHNIQUES Passing Array Columns Partitioning Workspace Sharing Workspace Sharing Constant Data Storing a Symmetric Matrix Sparse Matrix Techniques . Fixed Pattern . Varying Pattern Linked Lists Omissions and Caveats Exercises DESIGN, DOCUMENTATION, AND CODING STYLE The Craft of Programming Design .
User Interface Design . Program Design Documentation . External Documentation . Internal Documentation Coding Style . Cognitive Complexity . Names . Branching Logic . Exposition .
Typography . Refining the Comments Hand-Checking Testing, Revision, and Maintenance . Testing . Revision and Maintenance Conclusion and Omissions Exercises ARCHAIC, UNUSUAL, AND DANGEROUS USAGES Source Form . Sequence Numbers . Dead Code . Free-Form Source . INCLUDE Files .
The PROGRAM Statement . No STOP Statement . Star and Blank Comments . Other Continuation Characters Expressions and Assignment Statements . Precedence Dependencies . Long Names Conditionals and Transfer of Control . ELSE IF . The Arithmetic IF .
The Computed GO TO . Free Loops Scalar Data Types . Mixed Mode . Generic Functions . IMPLICIT . IMPLICIT NONE . Other Data Types . Other Forms of Type Declaration .
Abuses of EQUIVALENCE Arrays and DO Loops . The DIMENSION Statement . Abuses of DO Loops . Abuses of CONTINUE . DO WHILE Subprograms . Alternate RETURNs . ENTRY . Abuses of Subprogram Arguments .
Call by Value . Functions Without Arguments . Statement Functions . Archaic Names for Built-In Functions Adjustable Dimensions and EXTERNAL . Arrays Dimensioned (1) . Overuse of EXTERNAL COMMON . Indiscriminate Use of COMMON . Extending COMMON by EQUIVALENCE .
References Past the End of an Array . Blank COMMON . Arrays Dimensioned in COMMON Statements Input and Output . Carriage Control . Scale Factors . Hollerith Strings in FORMATs . Printing Leading Zeros . Formatted READs .
Direct-Access I/O . NAMELIST Character Variables . Characters in Variables of Other Types . Arithmetic With Characters . Substrings, Concatenation, and Character Built-Ins Case Study: A Legacy Code . Source Listing . Observations . Cleaning Up the Mess Conclusion and Omissions Exercises UNIX ISSUES Using the Compiler .
Naming the Executable File . Checking Array Subscripts . Other Compiler Options Operating System Services . Current Date and Time . I/O Units and Files . Shell Variables . Command Line Arguments . Issuing Unix Commands .
Setting a Return Code Debugging and dbx . Compile-Time Errors . Run-Time Errors . Debugging with Output Statements . Vanishing Bugs . The dbx Debugger Automatic Compilation with make . Incremental Recompilation . Deciding Which Routines to Recompile Libraries .
Using Libraries . Building Libraries Writing Custom Manual Pages . How the man Command Works . Your man Directory . The Page Template . A Typical Page Definition . Processing the Page Definition . How man Finds Your Custom Pages .
Printing man Pages Omissions Exercises MEASURING AND MAXIMIZING SERIAL EXECUTION SPEED Measuring Serial Execution Speed . The Unix time Command . Statistical Profiling with prof . System Subprograms for Measuring CPU Time . Direct Profiling with TIMER . Operation Counting Tuning FORTRAN Source Code . Algorithm Implementation Details . Variable Typing and Initialization .
Arithmetic Expressions . Exponentiation . Conditionals . Loops and Indices . Memory Reference Patterns and Stride . I/O Considerations . Subprograms . COMMON .
Summary Omissions Exercises VECTOR AND PARALLEL PROCESSING Vector Processing . Scalar Machine Instructions . Vector Machine Instructions . Pipelining . Amdahl''s Law . Vector Compilers and Performance Tuning . Case Study: Tuning Code for Vectorization Parallel Processing . Problem Decomposition .
Message Passing . Case Study: Functional Decomposition . Case Study: Domain Decomposition . Amdahl''s Law Revisited . Deadlocks and Races Omissions Exercises FORTRAN-90 AND HPF FORTRAN-90 . Array Operations . Dynamic Memory Allocation . Other New Features .
Case Study: Matrix Multiplication . Omissions High Performance FORTRAN . Data Parallel Programming . Parallelization by HPF . Distributing Data . Expressing Concurrency . Using Subprograms . Case Study: Integration Again .
Caveats . Omissions The Future of FORTRAN Exercises SOME UTILITY ROUTINES Number-Numeral Conversions . Integer to Numerals . Numerals to Integer String Insertions . Inserting an Integer Into a String . Inserting One String Into Another Attaching a File Arithmetic with Two-Part Values . Addition and Subtraction . Normalization .
Conversion To and From REAL*8 . Scaling Measuring CPU Time . Algorithm . Implementation A Shell Script for Global Edits Caveats and Omissions Exercises BIBLIOGRAPHY Suggested Reading Technical References Other References INDEX.