Skip to main content

2018 | Buch

Introduction to Programming with Fortran

insite
SUCHEN

Über dieses Buch

This fourth Edition presents new examples on submodules, derived type i/o, object oriented programming, abstract interfaces and procedure pointers, C interop, sorting and searching, statistics and converting to more modern versions of Fortran.

Key Features

Highlights the core language features of modern Fortran including data typing, array processing, control structures, functions, subroutines, modules and submodules, user defined types, pointers, operator overloading, generic programming, parallel programming, abstract interfaces, procedure pointers

Pinpoints common problems that occur when programming

Illustrates the use of several compilers

Introduction to Programming with Fortran has been written for the complete beginner with little or no programming background as well as existing Fortran programmers and those with programming experience in other languages

Inhaltsverzeichnis

Frontmatter
Chapter 1. Overview

The aims of the chapter are to provide a background to the organisation of the book.

Ian Chivers, Jane Sleightholme
Chapter 2. Introduction to Problem Solving

The aims of this chapter are:To examine some of the ideas and concepts involved in problemProblem solving solving.To introduce the concept of anAlgorithmProblem solvingalgorithm algorithm.To introduce two ways of approaching algorithmic problemProblem solvingalgorithmic problem solving solving.To introduce the ideas involved with systems analysis and design, i.e., to show the need for pencil and paper study before using a computerSystems analysisSystems analysis and designProblem solvingsystems analysis and design system.To introduce the Unified modelling Language - UML, a general purpose modelling language used in the field of softwareProblem solvingUnified Modelling Language (UML)Problem solvingsoftware engineering engineering.

Ian Chivers, Jane Sleightholme
Chapter 3. Introduction to Programming Languages

The primaryProgramming languages aim of this chapter is to provide a short history of program language development and give some idea as to the concepts that have had an impact on Fortran. It concentrates on some but not all of the major milestones of the last 40 years, in roughly chronological order. The secondary aim is to show the breadth of languages available. The chapter concludes with coverage of a small number of more specialised languages.

Ian Chivers, Jane Sleightholme
Chapter 4. Introduction to Programming

The aims of the chapter are:To introduce the idea that there is a wide class of problems that can be solved with a computer and, further, that there is a relationship between the kind of problem to be solved and the choice of programming language that is used.To give some of the reasons for the choice of Fortran.To introduce the fundamental components or kinds of statements to be found in a general purpose programming language.To introduce the three concepts of name, type and value.To illustrate the above with sample programs based on three of the five intrinsic data types:character, integer and real.To introduce some of the formal syntactical rules of Fortran.

Ian Chivers, Jane Sleightholme
Chapter 5. Arithmetic

The aims of this chapter are to introduce.

Ian Chivers, Jane Sleightholme
Chapter 6. Arrays 1: Some Fundamentals

The aims of the chapter are to introduce the fundamental conceptsDo statements of arraysArrays and doDo loops loops, in particular:To introduce the idea of tables of data and some of the formal terms used to describe them:Array.Vector.List and linear list.To discuss the array as a random access structure where any element can be accessed as readily as any other and to note that the data in an array are all of the same type.To introduce the twin concepts of data structure and corresponding control structureControl structure.To introduce the statements necessary in Fortran to support and manipulate these data structures.Data structures

Ian Chivers, Jane Sleightholme
Chapter 7. Arrays 2: Further Examples

The aims of the chapter are to extend the concepts introduced in the previous chapter and in particular:To set an array sizeArray size at run time - allocatableAllocatable arrays arrays.To introduce the idea of an array with more than one dimension and the corresponding control structureControl structure to permit easy manipulation of higher-dimensioned arrays.To introduce an extended form of the dimension attributeDimension attribute declaration, and the corresponding alternative form to the do statement, Do statement to manipulate the array in this new form.To introduce the do loopDo loop as a mechanism for the control of repetition in general, not just for manipulating arrays.To formallyArrayallocatable define the block doArrayvarying the size at run time syntax.

Ian Chivers, Jane Sleightholme
Chapter 8. Whole Array and Additional Array Features

The aims of the chapter are:To look more formally at the terminology required to precisely describe arrays.To introduce ways in which we can manipulate whole arrays and parts of arrays (sections).To introduce the concept of array elementArray elementorderingArray element order and physical and virtual memory.To introduce ways in which we can initialise arrays using array constructors.To introduce the where statement and array masking.To introduce the forall statement and construct.Physical and virtual memoryType declaration statement summary.

Ian Chivers, Jane Sleightholme
Chapter 9. Output of Results

The aims here are to introduce some of the facilities for producing neat output using edit descriptors. Edit descriptor There is also coverage of how to write the results to a file, rather than to the screen.

Ian Chivers, Jane Sleightholme
Chapter 10. Reading in Data

The aims of this chapter are to introduce some of the ideas involved in reading data into a program. In particular, using the following:Reading from filesReading from filesReading integer dataReading integer dataReading real dataReading real dataSkipping columns of data in a fileSkipping columns on inputSkipping lines in a fileSkipping lines on inputReading from several files consecutivelyReading from several filesReading using internal filesReading using internal filesTiming of formatted and unformatted readsTiming formatted readsTiming unformatted reads

Ian Chivers, Jane Sleightholme
Chapter 11. Summary of I/O Concepts

This chapter covers more formally some of the concepts introduced in Chaps. 9 and 10. There is a coverage ofI/O concepts and I/O statementsI/O conceptsI/O statementsFiles, records and streamsFiles, records, streamsSequential, direct and stream accessSequential, direct and stream accessOptions or specifiers on the openstatementOptions on the open statementOptions or specifiers on the closestatementOptions on the close statementOptions or specifiers on the writestatementOptions on the write statementOptions or specifiers on the read statement.Options on the read statement.

Ian Chivers, Jane Sleightholme
Chapter 12. Functions

The aims of this chapter are:To consider some of the reasons for the inclusion of functions in a programming language.To introduce, with examples, some of the predefined functions available inPredefined functions Fortran.To introduce a classification of intrinsic functions, generic, elementalIntrinsic functionFortran intrinsic functionsgenericFortran intrinsic functionselementalFortran intrinsic functionstransformationalElemental functionGeneric functionTransformational functions, transformational.To introduce the concept of a user definedUser defined functions function.To introduce the concept of a recursiveRecursive functions function.To introduce the concept of user defined elemental and purePure functionsElemental functionUser defined elemental functionsUser defined pure functions functions.To briefly look at scope rules in Fortran for variables andScope rules for variables and functions functions.To look at internal user defined functionsInternal user defined functions.

Ian Chivers, Jane Sleightholme
Chapter 13. Control Structures and Execution Control

The aims of this chapter are to introduce:Selection among various courses of action as part of the algorithm.The concepts and statements in Fortran needed to support the above:execution control.executable constructs containing blocks.the associate construct.the block construct.the do construct.the if construct.the select case construct.the select rank construct.the select type construct.Logical expressions and logical operators.One or more blocks of statements.

Ian Chivers, Jane Sleightholme
14. Characters

The aims of this chapter are:To extend the ideas about characters introduced in earlier chapters.To demonstrate that this enables us to solve a whole new range of problems in a satisfactory way.

Ian Chivers, Jane Sleightholme
Chapter 15. Complex

The aims of this chapter are:To introduce the last predefined numeric data type in Fortran.To illustrate with examples how to use this type.

Ian Chivers, Jane Sleightholme
Chapter 16. Logical

The aims of this chapter are:To examine the last predefined type available in FortranLogical data type: logical.To introduce the concepts necessary to use logical expressionsLogical expression effectively:Logical variables.Logical operators.The hierarchy of operations.TruthLogical variableLogical operatorsHierarchy of operationsTruth tables tables.

Ian Chivers, Jane Sleightholme
Chapter 17. Introduction to Derived Types

The aim of this chapter is to introduce the concepts and ideas involved in using the facilities offered in modern Fortran for the construction and use of derived or user defined types;defining our own types.declaring variables to be of a user defined type.manipulating variables of our own types.nesting types withinDefining our own typesDeclaring variables to be of a user defined typeManipulating variables of our own typesNesting types within types types.

Ian Chivers, Jane Sleightholme
Chapter 18. An Introduction to Pointers

The primary aim of the chapter is to introduce some of the key concepts of pointers in Fortran.

Ian Chivers, Jane Sleightholme
Chapter 19. Introduction to Subroutines

The aims of this chapter are:To consider some of the reasons for the inclusion of subroutines in a programming language.To introduce with a concrete example some of the concepts and ideas involved with the definition and use of subroutines.Arguments or parameters.The intent attribute for parameters.The call statement.Scope of variables.Local variables and the save attribute.The use of parameters to report on the status of the action carried out in the subroutine.Module procedures to provide interfaces.

Ian Chivers, Jane Sleightholme
Chapter 20. Subroutines: 2

The aims of this chapter are to extend the ideas in the earlier chapter on subroutines and look in more depth at parameter passing, in particular using a variety of ways of passing arrays.

Ian Chivers, Jane Sleightholme
Chapter 21. Modules

The aims of this chapter are to look at the facilities found in Fortran provided by modules, in particular.The use of a module to aid in the consistent definition of precision throughout a program and subprograms.The use of modules forModules for global data global data.The use of modules for derivedModules for derived data typesDerived data types data types.Modules containingModules containing procedures proceduresA module forTiming module timing programsPublic, private andPublic attributePrivate attributeProtected attribute protected attributesThe use statementUse statementUse statement and extensions and its extensions

Ian Chivers, Jane Sleightholme
Chapter 22. Data Structuring in Fortran

The aims of this chapter are to look at several complete examples illustrating data structuring in Fortran using the followingSingly linked listsLinked listRagged arraysRagged arraysA perfectly balanced treePerfectly balanced treeA date data typeDate data type

Ian Chivers, Jane Sleightholme
Chapter 23. An Introduction to Algorithms and the Big O Notation

The aims of this chapter are to provide an introduction to algorithms and their behaviour. In Computer Science this is normally done using the so called big O notation.

Ian Chivers, Jane Sleightholme
Chapter 24. Operator Overloading

The aims of this chapter are to look at operator overloading in Fortran.

Ian Chivers, Jane Sleightholme
Chapter 25. Generic Programming

This chapter looks at some examples that implement generic programming in Fortran.

Ian Chivers, Jane Sleightholme
Chapter 26. Mathematical and Numerical Examples

The aims of this chapter are to look at several mathematical and numeric examples in Fortran.Using linked listsLinked list for sparse matrix problems.Sparse matrix problemsSparse matricesLinked listsparse matrix problemsThe solution of a system of ordinary differential equations using the Runge–Kutta–Merson method, with the use of a procedure as a parameter, and the use of work arrays.Ordinary differential equationsWork arraysThe use of optional and keyword argumentsKeyword argumentOptional argumentDiagonal extraction of a matrix.Diagonal extract of a matrixThe solution of a system of linear simultaneous equations using Gaussian EliminationSolving a system of linear simultaneous equations using Gaussian EliminationAn elemental e**x functionElemental functionExamples of the relative and absolute errors involved in subtraction with 32 and 64 bit precision

Ian Chivers, Jane Sleightholme
Chapter 27. Parameterised Derived Types (PDTs) in Fortran

The aims of this chapter are to look at some additional data structuring examples in Fortran that use parameterised derived types - PDTs.

Ian Chivers, Jane Sleightholme
Chapter 28. Introduction to Object Oriented Programming

The aims of this chapter are to look at object oriented programming in Fortran.

Ian Chivers, Jane Sleightholme
Chapter 29. Additional Object Oriented Examples

The aim of this chapter are to look at some additional object oriented programmingObject oriented programming examples in Fortran.

Ian Chivers, Jane Sleightholme
Chapter 30. Introduction to Submodules

The aims of this chapter is to provide a short introduction to submodules.

Ian Chivers, Jane Sleightholme
Chapter 31. Introduction to Parallel Programming

The aims of this chapter is to provide a short introduction to parallel programming.

Ian Chivers, Jane Sleightholme
Chapter 32. MPI - Message Passing Interface

The aims of this chapter is to provide a short introduction to MPI programming in Fortran.

Ian Chivers, Jane Sleightholme
Chapter 33. OpenMP

The aims of this chapter is to provide a short introduction to OpenMP programming in Fortran.

Ian Chivers, Jane Sleightholme
Chapter 34. Coarray Fortran

The aims of this chapter is to provide a short introduction to coarray programming in Fortran.

Ian Chivers, Jane Sleightholme
Chapter 35. C Interop

This chapter looks briefly at C interoperability. C is a widely used programming language and there is a considerable amount of software written in C or with a C calling interface. Fortran 2003 introduced a standardised mechanism for interoperating with C. There were limitations to this interoperability and ISO TS 29113 significantly extended the scope of the interoperation facilities. The TS was published in 2012. In this chapter we provide a brief coverage of some of the technical details required for interoperability and then have a look at a couple of examples.

Ian Chivers, Jane Sleightholme
Chapter 36. IEEE Arithmetic

The aims of this chapter are to look in more depth at arithmetic and in particular at the support that Fortran provides for the IEEE 754 and later standards. There is a coverage of:hardware support for arithmetic.integer formats.floating point formats: single and double.special values: denormal, infinity and not a number — nan.exceptions and flags: divide by zero, inexact, invalid, overflow, underflow.

Ian Chivers, Jane Sleightholme
Chapter 37. Derived Type I/O

In this chapter we look at a facility introduced in the Fortran 2003 standard - derived type I/O. The Fortran 2018 standard calls it defined type input/output, and is now widely available in current compilers. When a derived type is encountered in an I/O list, we can arrange to call a Fortran subroutine. For a particular derived type and a particular set of kind type parameter values, there are four possible sets of characteristics for defined input/output procedures; one each forformatted inputformatted outputunformatted inputunformatted output

Ian Chivers, Jane Sleightholme
Chapter 38. Sorting and Searching

We look at a number of sorting and searching examples.

Ian Chivers, Jane Sleightholme
Chapter 39. Handling Missing Data in Statistics Calculations

In this chapter we look at a case study of processing the Met Office historic data files and generating statistics accommodating missing data values. Several steps are involveda program to download and save the data files locally.a sed script to convert the missing values.a modified statistics module that will process and report on missing values.a module that encapsulates the Met Office station data information.a program that actually does the calculations and generates the summary information.a site description module that encapsulates the site information.a program to generate the site information summary data.

Ian Chivers, Jane Sleightholme
Chapter 40. Converting from Fortran 77

This chapter looks at some of the options available when working with older Fortran code.

Ian Chivers, Jane Sleightholme
Chapter 41. Graphics Libraries - Simple Dislin Usage

In science andIntroduction engineering graphics are essential part of the presentation of information.

Ian Chivers, Jane Sleightholme
Chapter 42. Abstract Interfaces and Procedure Pointers

We look at an example that illustrates the use of abstract interfaces and procedure pointers.

Ian Chivers, Jane Sleightholme
43. Correction to: Characters

■■■

Clark Bray, Adrian Butscher, Simon Rubinstein-Salzedo
Backmatter
Metadaten
Titel
Introduction to Programming with Fortran
verfasst von
Ian Chivers
Jane Sleightholme
Copyright-Jahr
2018
Electronic ISBN
978-3-319-75502-1
Print ISBN
978-3-319-75501-4
DOI
https://doi.org/10.1007/978-3-319-75502-1