2 Getting started: Minimal working app

 

This chapter covers

  • Compiling and running your first Fortran program
  • Data types, declaration, arithmetic, and control flow
  • Building and running your first simulation app

In this chapter, we’ll implement the minimal working version of the tsunami simulator. For simplicity, we’ll start by simulating the movement of water in space due to background flow, without changing its shape. This problem is sufficiently complex to introduce basic elements of Fortran: numeric data types, declaration, arithmetic expressions and assignment, and control flow. Once we successfully simulate the movement of an object in this chapter, we’ll refactor the code to add other physics processes in chapters 3 and 4, which will allow the simulated water to flow more realistically. Implementing the other processes will be easier because we’ll be able to reuse much of the code that we’ll write in this chapter.

We’ll start off by compiling, linking, and running your first Fortran program. Then I’ll introduce the physical problem that we want to solve and show you how to express it in the form of a computer program. We’ll then dive into the essential elements of Fortran: data types, declaration, arithmetic, and control flow. At the end of the chapter, you’ll have the working knowledge to write basic, yet useful, Fortran programs.

2.1 Compiling and running your first program

 
 

2.2 Simulating the motion of an object

 
 
 

2.2.1 What should our app do?

 
 
 

2.2.2 What is advection?

 
 
 

2.3 Implementing the minimal working app

 
 

2.3.1 Implementation strategy

 
 
 
 

2.3.2 Defining the main program

 
 
 

2.3.3 Declaring and initializing variables

 
 
 
 

2.3.4 Numeric data types

 
 

2.3.5 Declaring the data to use in our app

 

2.3.6 Branching with an if block

 
 
 

2.3.7 Using a do loop to iterate

 
 
 

2.3.8 Setting the initial water height values

 
 

2.3.9 Predicting the movement of the object

 

2.3.10 Printing results to the screen

 

2.3.11 Putting it all together

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest