to accompany
Chapman
Fortran 95/2003 for Scientists and Engineers
Third Edition
Stephen J. Chapman
BAE SYSTEMS Australia
i
, TABLE OF CONTENTS
CHAPTER 1. INTRODUCTION TO COMPUTERS AND THE FORTRAN LANGUAGE 9
CHAPTER 2. BASIC ELEMENTS OF FORTRAN 10
CHAPTER 3. PROGRAM DESIGN AND BRANCHING STRUCTURES 24
CHAPTER 4. LOOPS AND CHARACTER MANIPULATION 33
CHAPTER 5. BASIC I/O CONCEPTS 71
CHAPTER 6. INTRODUCTION TO ARRAYS 113
CHAPTER 7. INTRODUCTION TO PROCEDURES 127
CHAPTER 8. ADDITIONAL FEATURES OF ARRAYS 175
CHAPTER 9. ADDITIONAL FEATURES OF PROCEDURES 193
CHAPTER 10. MORE ABOUT CHARACTER VARIABLES 229
CHAPTER 11. ADDITIONAL INTRINSIC DATA TYPES 252
CHAPTER 12. ADDITIONAL DATA TYPES 267
CHAPTER 13. ADVANCED FEATURES OF PROCEDURES AND MODULES 298
CHAPTER 14. ADVANCED I/O CONCEPTS 315
CHAPTER 15. POINTERS AND DYNAMIC DATA STRUCTURES 330
CHAPTER 16. OBJECT ORIENTED PROGRAMMING IN FORTRAN 356
APPENDIX A. LIBRARY PROCEDURE DESCRIPTIONS 357
iii
, Chapter 1. Introduction to Computers and the Fortran Language
1-1 (a) 10102 (b) 1000002 (c) 10011012 (d) 1111112
1-2 (a) 7210 (b) 13710 (b) 25510 (d) 510
1-3 (a) 1273618 and AEF116 (b) 5128 and 14A16 (c) 1578 and 6F16 (d) 37558 and 7ED16
1-4 (a) 111111112 and 25510 (b) 1101010002 and 42410 (c) 10010012 and 7310 (d) 1111111112 and 51110
1-5 A 23-bit mantissa can represent approximately ±222 numbers, or about six significant decimal digits. A 9-bit
exponent can represent multipliers between 2-255 and 2255, so the range is from about 10-76 to 1076.
1-6 46-bit integer: From -245 to -245-1, or -35,184,372,088,832 to 35,184,372,088,831. 64-bit integer: From -263 to
-263-1, or -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
1-7 (a) 1101112 (b) 11111111111110112 (c) 100000000002 (d) 11111100000000002
1-8 The sum of the two’s complement numbers is:
= 936210
11111100111111002 = -77210
00100001100011102 = 859010
The two answers agree with each other.
1-9 011111112 = 12710, and 100000002 = -12810. These results agree with Equations (1-1) and (1-2).
1-10 A 53-bit mantissa can represent approximately ±252 numbers, or about fifteen significant decimal digits. An 11-bit
exponent can represent multipliers between 2-1023 and 21023, so the range of double precision numbers is from about
10-307 to 10307.
9