Docsity

Fortran Programming for Scientific Computing: A Beginner's Guide, Slides of Mechanical Engineering

Partial preview of the text

Download Fortran Programming for Scientific Computing: A Beginner's Guide and more Slides Mechanical Engineering in PDF only on Docsity!

  • INTRODUCTION

History of Fortran…

1. 1 st^ version: 1950’s…IBM

2. Fortran 66…

3. Fortran 77…

4. Fortran 90…fairly big changes but…

Fortran

Fortran

  • Usually much harder
    • example: weather forecasting (numerical weather prediction, NWP)
    • Involves simultaneous solution of multiple equations at multiple locations in the atmosphere at multiple times to get a forecast
  • Solving a scientific/engineering problem

ALWAYS involves many steps.

  • Many of these steps do not involve Fortran!!!
  • So we will learn much more than just Fortran

in this class!

  • The first step is to do as much work as

possible on paper

  • make sure you have defined the problem properly
  • make sure you have as much information as possible
  • Example: Suppose we wish to calculate how

much kinetic energy is in hurricane Irene.

  • Think first about how you would do this with pen and pencil.
  • Recall that kinetic energy is defined as:

(speed)^2 /

  • Now we can take real wind data (e.g., from research aircraft, forecast models etc.) and compute “K” using our formula.
  • Computers are VERY good at these tasks.
    • Note that wind speed could be both horizontal winds (“large” numbers) and vertical winds (“small” numbers)
  • The next step is to break the calculation down

into small bite-sized pieces.

  • Typically we do this on paper (or in your head

when the problem is easy AND you have lots

of experience)

  • In our KE example…
  • And now - translate each step in the list above

into Fortran!

  • This is like translating into Spanish.
  • You need to know two things:
    • Vocabulary
      • Words like: IF, STOP, GO TO, PRINT » They all look pretty obvious!
    • Rules
      • Things like: the commands “STOP” and “END” must appear in your program.
  • Computers are very smart!
    • They can do many things
      • they can remember lots of stuff (via memory)
      • they are VERY fast
  • Once you have your Fortran program written,

the next step is to present the program to a

computer!

  • If you are on a laptop with Fortran software

installed, this will be straightforward.

  • If you are on a department machine (including

laptop), there are extra steps…see later.

  • Computers are very dumb!
    • They don’t know what Fortran is!
    • They have to translate your Fortran program into a low-level machine language. - Fortran is machine-independent. - Machine language is machine-dependent.
  • The compiler digests this and produces an executable file – a file called program.exe
  • This is what then “runs” on the computer to solve your problem (e.g., make a forecast)

Putting it all together…

  • With a computer that has Fortran software

installed, you would:

  • Open up the Fortran software (just like opening up Word)
  • Type in your Fortran code using a text editor
    • MS Word is a very fancy text editor; we use simpler ones (see later)