KEMBAR78
Introduction To Programming With Fortran Sleightholme | PDF | Computer Science | Software Development
0% found this document useful (0 votes)
18 views10 pages

Introduction To Programming With Fortran Sleightholme

Introduction to Programming With Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (3rd Edition) Sleightholme

Uploaded by

appen.jeetsu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views10 pages

Introduction To Programming With Fortran Sleightholme

Introduction to Programming With Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (3rd Edition) Sleightholme

Uploaded by

appen.jeetsu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (

ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90

Ian Chivers · Jane Sleightholme

Introduction to
Programming
with Fortran
With Coverage of Fortran 90, 95, 2003,
2008 and 77
Third Edition

This Book is Available on YakiBooki.com


ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (
Introduction to Programming with Fortran

ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90

This Book is Available on YakiBooki.com


ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (
Ian Chivers Jane Sleightholme

ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90

Introduction to Programming
with Fortran
With Coverage of Fortran 90, 95, 2003,
2008 and 77
Third Edition

123
This Book is Available on YakiBooki.com
ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (
Ian Chivers Jane Sleightholme
Rhymney Consulting Fortranplus
London London
UK UK

ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90

ISBN 978-3-319-17700-7 ISBN 978-3-319-17701-4 (eBook)


DOI 10.1007/978-3-319-17701-4

Library of Congress Control Number: 2015939803

Springer Cham Heidelberg New York Dordrecht London


© Springer International Publishing Switzerland 2006, 2012, 2015
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar
methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this
publication does not imply, even in the absence of a specific statement, that such names are exempt from
the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this
book are believed to be true and accurate at the date of publication. Neither the publisher nor the
authors or the editors give a warranty, express or implied, with respect to the material contained herein or
for any errors or omissions that may have been made.

Printed on acid-free paper

Springer International Publishing AG Switzerland is part of Springer Science+Business Media


(www.springer.com)

This Book is Available on YakiBooki.com


ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (

ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90

The Yorkshire connection dedicates


the book to Steve, Mark and Jonathan.
The Welsh connection dedicates the book
to Joan, Martin and Jenny.

This Book is Available on YakiBooki.com


ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (
Acknowledgments

ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90

The material in the book has evolved firstly


• from our combined experience of working in Computing Services within the
University of London at
– King’s College, IDC (1986–2002) and JS (1985–2008)
– Chelsea College, JS (1978–1985)
– Imperial College, IDC (1978–1986)
in the teaching, advice and support of Fortran and related areas, and secondly
• in the provision of commercial training courses. The following are some of the
organisations we have provided training for:
– AMEC, Warrington.
– Aveva, Cambridge.
– AWE, Aldermaston.
– Centre for Ecology and Hydrology, Wallingford.
– DTU—Danish Technical University.
– Environment Agency, Worthing.
– Esso Petroleum, Fawley.
– JET—Joint European Torus.
– The Met Office, Bracknell and Exeter.
– National Nuclear Laboratory.
– Natural Resources Canada, Ottowa.
– Petroleum Geo-Services (PGS), Houston and Weybridge.
– QinetiQ, Farnborough.
– RAF Waddington.
– Ricardo Software.
– Risk Management Solutions.
– Rolls Royce, Derby.
– SHMU, Slovak Hydrometeorological Institute, Bratislava, Slovakia.
– University of Ulster, Jordanstown, Northern Ireland.

vii
This Book is Available on YakiBooki.com
viii Acknowledgments
ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (
– VCS, Germany.
– Veritas DGC Ltd., Crawley.
– Westland Helicopters, Yeovil.
The examples in the book are based on what will work with compilers that
support the Fortran 2008 standard.
ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90
Thanks are due to:
• The staff and students at King’s College, Chelsea College and Imperial College.
• The people who have attended the commercial courses. It has been great fun
teaching you and things have been very lively at times.
• The people on the Fortran 90 list and comp.lang.fortran. Access to the expertise
of several hundred people involved in the use and development of Fortran on a
daily basis across a wide range of disciplines is inestimable.
• The people at NAG for the provision of beta test versions of their Fortran
compilers and technical help and support.
• The people at Intel for the provision of beta test versions of their Fortran
compilers and technical help and support.
• The people running the Archer service for their help.
• The people at Oracle who helped with the C Interop examples.
• The staff and facilities at PTR Associates. It is a pleasure training there.
• Helmut Michels at the Max-Planck-Institut for permission to use the dislin
library.
• The patience of our families during the time required to develop the courses
upon which this book is based and whilst preparing the camera-ready copy.
• Helen Desmond and James Robinson at Springer for their enthusiasm and
encouragement when things were going wrong!
Our Fortran home page is:
http://www.fortranplus.co.uk/

All of the program examples can be found there.


If you would like to contact us our email addresses are:
Ian Chivers: ian@rhymneyconsulting.co.uk
Jane Sleightholme: jane@fortranplus.co.uk
The manuscript was produced using Springer’s LaTeX style sheet. We used
proTeXt, MiKTeX and TeXnicCentre on the Windows platform. The graphs and
plots were produced using the dislin graphics library. We started using TeX at
Imperial College on several CDC systems in the 1980s. TeX and LaTeX have come
a long way since then and plain TeX seems a distant memory.

This Book is Available on YakiBooki.com


ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (
Contents

ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90

1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Program Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Web Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Introduction to Problem Solving . . . . . . . . . . . . . . . . . . . . . . . . . 5


2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Natural Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Artificial Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.1 Notations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4 Resume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.5 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5.1 Top-Down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5.2 Bottom-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5.3 Stepwise Refinement . . . . . . . . . . . . . . . . . . . . . . 9
2.6 Modular Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.7 Object Oriented Programming. . . . . . . . . . . . . . . . . . . . . . . 10
2.8 Systems Analysis and Design . . . . . . . . . . . . . . . . . . . . . . . 10
2.8.1 Problem Definition . . . . . . . . . . . . . . . . . . . . . . . 10
2.8.2 Feasibility Study and Fact Finding. . . . . . . . . . . . . 11
2.8.3 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.8.4 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.8.5 Detailed Design. . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.8.6 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.8.7 Evaluation and Testing. . . . . . . . . . . . . . . . . . . . . 12
2.8.8 Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.9 Unified Modeling Language—UML . . . . . . . . . . . . . . . . . . 13
2.10 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.11 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

ix
This Book is Available on YakiBooki.com
x Contents
ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (
3
Introduction to Programming Languages. . . . . . . . . . . . . . . . . . . 17
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 Some Early Theoretical Work . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 What Is a Programming Language? . . . . . . . . . . . . . . . . . . . 18
3.4 Program Language Development and Engineering . . . . . . . . . 18
ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90
3.5 The Early Days. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.5.1 Fortran’s Origins . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.5.2 Fortran 77 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.5.3 Cobol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.5.4 Algol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.6 Chomsky and Program Language Development. . . . . . . . . . . 20
3.7 Lisp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.8 Snobol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.9 Second-Generation Languages. . . . . . . . . . . . . . . . . . . . . . . 22
3.9.1 PL/1 and Algol 68. . . . . . . . . . . . . . . . . . . . . . . . 22
3.9.2 Simula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.9.3 Pascal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.9.4 APL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.9.5 Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.9.6 C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.10 Some Other Strands in Language Development . . . . . . . . . . . 24
3.10.1 Abstraction, Stepwise Refinement and Modules. . . . 24
3.10.2 Structured Programming . . . . . . . . . . . . . . . . . . . . 24
3.10.3 Data Structuring and Procedural Programming . . . . 25
3.10.4 Standardisation . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.11 Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.12 Modula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.13 Modula 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.14 Other Language Developments . . . . . . . . . . . . . . . . . . . . . . 27
3.14.1 Logo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.14.2 Postscript, TEX and LATEX . . . . . . . . . . . . . . . . . 28
3.14.3 Prolog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.14.4 SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.14.5 ICON. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.15 Object Oriented Programming. . . . . . . . . . . . . . . . . . . . . . . 29
3.15.1 Simula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.15.2 Smalltalk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.15.3 Oberon and Oberon 2 . . . . . . . . . . . . . . . . . . . . . 30
3.15.4 Eiffel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.15.5 C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.15.6 Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.15.7 C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

This Book is Available on YakiBooki.com


Contents xi
ing with Fortran (With Coverage of Fortran 90, 95, 2003, 2008 and 77) (
3.16
Back to Fortran! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.16.1 Fortran 90 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.16.2 Fortran 95 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.16.3 ISO Technical Reports TR15580 and TR15581 . . . . 35
3.16.4 Fortran 2003 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
ad/introduction-to-programming-with-fortran-with-coverage-of-fortran-90
3.16.5 DTR 19767 Enhanced Module Facilities. . . . . . . . . 37
3.16.6 Fortran 2008 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.16.7 TS 29113 Further Interoperability
of Fortran with C . . . . . . . . . . . . . . . . . . . . . . . . 37
3.16.8 Fortran 2015 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.17 Fortran Discussion Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.18 ACM Fortran Forum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.19 Other Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.20 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4 Introduction to Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.2 Language Strengths and Weaknesses . . . . . . . . . . . . . . . . . . 48
4.3 Elements of a Programming Language . . . . . . . . . . . . . . . . . 48
4.3.1 Data Description Statements . . . . . . . . . . . . . . . . . 49
4.3.2 Control Structures . . . . . . . . . . . . . . . . . . . . . . . . 49
4.3.3 Data-Processing Statements. . . . . . . . . . . . . . . . . . 49
4.3.4 Input and Output (I/O) Statements . . . . . . . . . . . . . 49
4.4 Example 1: Simple Text I/O . . . . . . . . . . . . . . . . . . . . . . . . 50
4.5 Variables—Name, Type and Value . . . . . . . . . . . . . . . . . . . 51
4.6 Example 2: Simple Numeric I/O and Arithmetic . . . . . . . . . . 52
4.7 Some More Fortran Rules . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.8 Fortran Character Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.9 Good Programming Guidelines . . . . . . . . . . . . . . . . . . . . . . 55
4.10 Compilers Used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.11 Compiler Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.11.1 Gfortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.11.2 IBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.11.3 Intel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.11.4 Nag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.11.5 Oracle/Sun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.12 Program Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.13 Reference Text for the Fortran 2003 Standard . . . . . . . . . . . . 61
4.14 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

5 Arithmetic . . . . . . . . . . . . . ... ......................... 63


5.1 Introduction . . . . . . . ... ......................... 64
5.2 The Fortran Operators and the Arithmetic Assignment
Statement . . . . . . . . . ... ......................... 64

This Book is Available on YakiBooki.com

You might also like