EE EGuide to Fortran 2003 Programming
Guide to Fortran 2003
Programming
Walter S. Brainerd
Walter S. Brainerd
Fortran Company
6025 N. Wilmot Road
USA
ISBN 978-1-84882-542-0 e-ISBN 978-1-84882-543-7
DOI 10.1007/978-1-84882-543-7
Springer Dordrecht Heidelberg London New York
A catalogue record for this book is available from the British Library
Library of Congress Control Number: 2009926289
Copyright © Walter S. Brainerd 2009.
Published by Springer-Verlag London Ltd. 2009. All Rights Reserverd.
stored or transmitted, in any form or by any means, with the prior permission in writing of the
publishers, or in the case of reprographic reproduction in accordance with the terms of licenses issued
by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be
sent to the publishers. The use of registered names, trademarks, etc., in this publication does not imply,
even in the absence of a specific statement, that such names are exempt from the relevant laws and
regulations and therefore free for general use.
The publisher makes no representation, express or implied, with regard to the accuracy of the information
contained in this book and cannot accept any legal responsibility or liability for any errors or omissions
that may be made.
Printed on acid-free paper
Springer is part of Springer Science+Business Media (www.springer.com)
British Library Cataloguing in Publication Data
Tucson AZ 85750
Apart from any fair dealing for the purposes of research or private study, or criticism or review, as
permitted under the Copyright, Designs and Patents Act. 1988, this publication may only be reproduced,
Cover design: KuenkelLopka GmbH
walt@fortran.com
Preface
Fortran has been the premier language for scientific computing since its introduction in
1957. Fortran originally was designed to allow programmers to evaluate formu-
las—FORmula TRANslation—easily on large computers. Fortran compilers are now
available on all sizes of machines, from small desktop computers to huge multiproces-
sors.
The Guide to Fortran 2003 Programming is an informal, tutorial introduction to the
most important features of Fortran 2003 (also known as Fortran 03), the latest standard
version of Fortran. Fortran has many modern features that will assist the programmer
in writing efficient, portable, and maintainable programs that are useful for everything
from “hard science” to text processing.
Target Audience
This book is intended for anyone who wants to learn Fortran 03, including those famil-
iar with programming language concepts but unfamiliar with Fortran. Experienced
Fortran 95 programmers will be able to use this volume to assimilate quickly those fea-
tures in Fortran 03 that are not in Fortran 95 (Fortran 03 contains all of the features of
Fortran 95). This guide is not a complete reference work for the entire Fortran lan-
guage; it covers the basic features needed to be a good Fortran programmer and an in-
troduction to the important new features of Fortran 03. Many older error-prone
features have been omitted and some of the more esoteric features that are new to For-
tran 03 also are not discussed. To understand some of the features used in old Fortran
programs, other sources should be consulted after learning the best basic collection of
features for writing new codes or enhancing old ones.
Guide to Fortran 2003 Programming is organized so that it may be read from begin-
ning to end, but it also is organized so that particular topics may be studied by reading
some chapters before previous ones are mastered. To a reasonable extent, all the mate-
rial about one topic is presented together, making the book suitable as a reference
work, as well as a tutorial.
Examples and Case Studies
Most of the important features of the Fortran programming language are covered with
examples, beginning with the simplest constructs. The book concentrates to some ex-
tent on the newer features of the Fortran 03 programming language, because they often
provide the best facilities to accomplish a particular programming task. Both the style
of the many example programs and the selection of topics discussed in detail guide the
vi Preface
reader toward acquiring programming skills to produce Fortran programs that are
readable, maintainable, and efficient.
Case studies are used to illustrate the practical use of features of Fortran 03 and to
show how complete programs are put together. There are also simple problems to en-
able the reader to exercise knowledge of the topics learned.
Style of the Programming Examples
To illustrate the author’s opinion of good Fortran programming style, the program-
ming examples do not illustrate the wide variety of styles that might be used. There are
certainly many other good programming styles, but it is important to use a style con-
sistently within a programming project. The style notes also reflect opinions of the au-
thor and reflect but one possible good style to use.
Most of the program examples have been run on either the Numerical Algorithms
Group NAGWare Fortran 03 compiler (
nag.com) or the free g95 compiler (g95.org).
Organization of the Content
An unusual feature of the book is that the first chapter contains a complete discussion
of all the basic features needed to write complete Fortran programs: the form of For-
tran programs, data types, simple expressions and assignment, and simple input and
output. Subsequent chapters contain detailed discussions of control constructs, mod-
ules, procedures, arrays, character strings, data structures and derived types, pointer
variables, and object-oriented programming.
Module-oriented programming is a very important part of Fortran programming
and the topic of modules is introduced earlier to provide the framework for organizing
data and procedures for a Fortran program.
From the beginning, Fortran has had extensive facilities for input and output; how-
ever, this is a topic that is not explored fully in many books because it is a little more
difficult than other features and perhaps just not as interesting as some features. The
use of these facilities is very important in production programs, so this book contains,
in Chapter 11, an extensive discussion of the excellent input/output facilities in Fortran.
Appendix A lists the many intrinsic procedures. Appendix B provides a brief infor-
mal syntax specification for the language.
There still will be occasions when more details about the language must be
learned. In these cases it will be necessary to consult the official standard, published by
the International Standards Organization or the reference work The Fortran 2003 Hand-
book, by Adams, Brainerd, Hendrickson, Maine, Martin, and Smith, Springer, 2009.
Many suggestions made by Brian Smith improved the book significantly.
Tucson, Arizona, USA Walter S. Brainerd
评论0