fortran 95

Download Fortran 95

Post on 04-Oct-2015

18 views

Category:

Documents

3 download

Embed Size (px)

DESCRIPTION

Fortran 95

TRANSCRIPT

  • Introduction toProgramming

    using

    Fortran 95

    Ed Jorgensen

    October, 2014Version 2.0.6

  • Cover DiagramThe cover image is the plotted output from the chaos game program from chapter 11.The image was plotted with GNUplot.

    CopyrightEd Jorgensen, 2013, 2014

    You are free: to Share to copy, distribute and transmit the work to Remix to adapt the work

    Under the following conditions: Attribution. You must attribute the work to Introduction to Programming using Fortran

    95 (but not in any way that suggests that the authors endorse you or your use of the work).

    Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.

    For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to

    http://creativecommons.org/licenses/by-sa/3.0/ Any of the above conditions can be waived if you get permission from the copyright holder. Nothing in this license impairs or restricts the author's moral rights.

    ii

  • Table of Contents

    1 Introduction........................................................................................................................................ 1 1.1 Why Learn Programming............................................................................................................. 1 1.2 Fortran.......................................................................................................................................... 1 1.3 Complete Fortran 95 Documentation........................................................................................... 1 1.4 What Is A Program....................................................................................................................... 2 1.5 Operating System......................................................................................................................... 2

    2 Computer Organization..................................................................................................................... 3 2.1 Architecture Overview................................................................................................................. 3 2.2 Compiler....................................................................................................................................... 4 2.3 Information Representation.......................................................................................................... 4

    2.3.1 Decimal Numbers................................................................................................................. 4 2.3.2 Binary Numbers.................................................................................................................... 5 2.3.3 Character Representation...................................................................................................... 5

    2.4 Exercises....................................................................................................................................... 5 2.4.1 Quiz Questions...................................................................................................................... 5

    3 Getting Started................................................................................................................................... 7 3.1 Required Skills............................................................................................................................. 7 3.2 Program Formats.......................................................................................................................... 7

    3.2.1 Program Statement................................................................................................................ 7 3.2.2 Comments............................................................................................................................. 7 3.2.3 Simple Output....................................................................................................................... 8 3.2.4 Example First Program...................................................................................................... 8

    3.3 Text Editor.................................................................................................................................... 8 3.4 Compiling..................................................................................................................................... 8 3.5 Executing...................................................................................................................................... 9 3.6 Exercises..................................................................................................................................... 10

    3.6.1 Quiz Questions.................................................................................................................... 10 3.6.2 Suggested Projects.............................................................................................................. 10

    4 Fortran 95 Basic Elements........................................................................................................... 11 4.1 Variables..................................................................................................................................... 11

    4.1.1 Variable Names................................................................................................................... 11 4.1.2 Keywords............................................................................................................................ 12

    4.2 Data Types.................................................................................................................................. 12 4.2.1 Integer................................................................................................................................. 12 4.2.2 Real..................................................................................................................................... 13 4.2.3 Complex.............................................................................................................................. 13 4.2.4 Character............................................................................................................................. 13 4.2.5 Logical................................................................................................................................ 13 4.2.6 Historical Data Typing........................................................................................................ 13

    iii

  • 4.3 Declarations................................................................................................................................ 14 4.3.1 Declaring Variables............................................................................................................. 14 4.3.2 Variable Ranges.................................................................................................................. 14 4.3.3 Type Checking.................................................................................................................... 14 4.3.4 Initialization........................................................................................................................ 15 4.3.5 Constants............................................................................................................................ 15

    4.4 Comments................................................................................................................................... 15 4.5 Continuation Lines..................................................................................................................... 16

    4.5.1 Example.............................................................................................................................. 16 4.6 Declarations, Extended Size Variables....................................................................................... 16

    4.6.1 Integers............................................................................................................................... 16 4.6.2 Real..................................................................................................................................... 17

    4.7 Exercises..................................................................................................................................... 17 4.7.1 Quiz Questions.................................................................................................................... 17 4.7.2 Suggested Projects.............................................................................................................. 18

    5 Expressions....................................................................................................................................... 19 5.1 Literals........................................................................................................................................ 19

    5.1.1 Integer Literals.................................................................................................................... 19 5.1.2 Real Literals........................................................................................................................ 19

    5.1.2.1 E-Notation................................................................................................................... 19 5.1.3 Complex Literals................................................................................................................ 20 5.1

Recommended

View more >