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

An introduction to fortran programming, focusing on its application in scientific computing. It covers the history of fortran, the process of solving scientific problems using fortran, and the basics of writing, compiling, and running a fortran program. It also introduces the reader to the unix operating system and text editors used in the department. Intended for university students in meteorology and climate science who need to use fortran for data analysis, computation, or equation solving.

Typology: Slides

2012/2013

Uploaded on 04/29/2013

arpanay
arpanay 🇮🇳

4.4

(18)

156 documents

1 / 44

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
- INTRODUCTION
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c

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)