Click the table of contents to start reading.
Using Fortran, early and accurate forecasts for hurricanes and other major storms have saved thousands of lives.
If I've would had this book when writing my master thesis in astrophysics I would have spared a lot of time in learning how to write the code for my calculations.
Using Fortran, better designs for ships, planes, and automobiles have made travel safer, more efficient, and less expensive than ever before.
Using Fortran, low-level machine learning and deep learning libraries provide incredibly easy, fast, and insightful analysis of massive data for science, business, and industry.
Fortran is an amazingly powerful and flexible programming language that forms the foundation of high performance computing for research, science, and industry. And it's come a long, long way since starting life on IBM mainframes in 1956. Modern Fortran is natively parallel, so it's uniquely suited for efficiently handling problems like complex simulations, long-range predictions, and ultra-precise designs. If you're working on tasks where speed, accuracy, and efficiency matter, it's time to discover—or re-discover—Fortran.
Part 1: Getting started with modern Fortran
1 Introducing Fortran
1.1 What is Fortran?
1.2 Fortran features
1.3 Why learn Fortran?
1.4 Advantages and disadvantages
1.4.1 Side-by-side comparison with Python
1.5 The parallel Fortran mental model
1.6 What will you learn in this book?
1.7 Think parallel!
1.7.1 Copying an array from one processor to another
1.8 A Partitioned Global Address Space language
1.9 Running example: A parallel tsunami simulator
1.9.1 Why tsunami simulator?
1.9.2 Shallow water equations
1.9.3 What we want our app to do
2 Getting started: Minimal working app
2.1 Compiling and running your first program
2.2 A minimal working app: Moving a blob in space
2.2.1 What should our app do?
2.2.2 What is advection?
2.2.3 Implementation strategy
2.2.4 Defining the main program
2.2.5 Declaring and initializing variables
2.2.6 Numeric data types
2.2.7 Declaring variables
2.2.8 Declaring constants
2.2.9 Declaring arrays
2.2.10 Portable data types with
2.2.11 Using a
do-loop to iterate
2.2.12 Setting initial conditions for the blob
2.2.13 Predicting the movement of the blob
2.2.14 Writing to screen
2.2.15 Putting it all together
2.3 Going forward
2.4 New Fortran elements, at a glance
3 Writing reusable code with procedures and modules
3.1 Toward higher app complexity
3.1.1 Adding terms to the tsunami simulator
3.2 An overview of Fortran program units
3.3 Revisiting the cold front problem
3.4 Don’t repeat yourself, use procedures!
3.5 Using pure procedures to avoid side effects
3.5.1 What is a pure procedure?
3.5.2 Some restrictions on pure procedures
3.5.3 Why are pure functions important?
3.6 Writing procedures that operate on both scalars and arrays
3.7 Storing globally accessible data and procedures in modules
3.7.1 Defining a module
3.7.2 Accessing procedures and variables in a module
3.7.3 Controlling the visibility and access to variables and procedures
3.8 Incorporating modules and procedures in the Tsunami app
3.8.1 Refactoring the minimal working app with modules and functions
3.8.2 Toward realistic wave simulations
3.9 Answer key
3.9.1 Exercise 1: Calculating the temperature due to cold front passage
3.9.2 Exercise 2: Cold front solution using an external function.
3.9.3 Exercise 3: Modifying state with a subroutine
3.9.4 Exercise 4: Writing an elemental function that operates on both scalars and arrays
4 Analyzing time series data with arrays
4.1 Analyzing stock prices with Fortran arrays
4.1.1 Objectives for this exercise
4.1.2 About the data
4.1.3 Getting the data and code
4.2 Finding the best and worst performing stocks
4.2.1 Declaring arrays
4.2.2 Array constructors
4.2.3 Reading stock data from files
4.2.4 Allocating arrays of certain size or range
4.2.5 Allocating an array from another array
4.2.6 Cleaning up after use
4.2.7 Checking for allocation status
4.2.8 Catching allocation and deallocation errors
4.2.9 Implementing the CSV reader subroutine
4.2.10 Indexing and slicing arrays
4.3 Identifying risky stocks
4.4 Finding good times to buy and sell
4.5 Answer Key
4.5.1 Exercise 1: Convenience (de)allocator subroutines
4.5.2 Exercise 2: Reversing an array
4.5.3 Exercise 3: Computing the moving average over custom time period.
5 Reading, writing, and formatting your data
5.1 Your first I/O: Input from keyboard and output to screen
5.1.1 The simplest I/O
5.1.2 Reading and writing multiple variables at once
5.1.3 Standard input, output, and error
5.2 Formatting numbers and text
5.2.1 Designing the aircraft dashboard
5.2.2 Formatting strings, broken down
5.2.3 Format statements in legacy Fortran code
5.3 Writing to files on disk: A minimal note-taking app
5.3.1 Opening a file and writing to it
5.3.2 Opening a file
5.3.3 Writing to a file
5.3.4 Appending to a file
5.3.5 Opening files in read-only or write-only mode
5.3.6 Checking if a file exists
5.3.7 Error handling and closing the file
5.4 Answer Key
5.4.1 Exercise: Redirect stdout and stderr to files
5.5 New Fortran elements, at a glance
Part 2: Advanced Fortran use
6 Going parallel with Fortran coarrays
6.1 Why write parallel programs
6.2 Processing real-world weather buoy data
6.2.1 About the data
6.2.2 Getting the data and code
6.2.4 Serial implementation of the program
6.3 Parallel processing with images and coarrays
6.3.1 Fortran images
6.3.2 Getting information about the images
6.3.3 Telling images what to do
6.3.4 Gathering all data to a single image
6.4 Coarrays and synchronization, explained
6.4.1 Declaring coarrays
6.4.2 Allocating dynamic coarrays
6.4.3 Sending and receiving data
6.4.4 Controlling the order of image execution
6.5 Toward the parallel Tsunami simulator
6.5.1 Implementation strategy
6.5.2 Finding the indices of neighbor images
6.5.3 Allocating the coarrays
6.5.4 The main time loop
6.6 Answer key
6.6.1 Exercise 1: Finding the array sub-ranges on each image.
6.6.2 Exercise 2: Writing a function that returns the indices of neighbor images
7 Working with abstract data using derived types
7.1 Recasting the tsunami simulator with derived types
7.2 Defining, declaring, and initializing derived types
7.2.1 Defining a derived type
7.2.2 Instantiating a derived type
7.2.3 Accessing derived type components
7.2.4 Positional vs. keyword arguments in derived type constructors
7.2.5 Providing default values for derived type components
7.2.6 Writing a custom type constructor
7.2.7 Custom type constructor for the
7.3 Binding procedures to a derived type
7.3.1 Your first type-bound method
7.3.2 Type-bound methods for the
7.3.3 Controlling access to type components and methods
7.3.4 Bringing it all together
7.4 Extending tsunami to two dimensions
7.4.1 Going from 1-d to 2-d arrays
7.4.2 Updating the equation set
7.4.3 Finite differences in x and y
7.4.4 Passing a class instance to
7.4.5 Derived type implementation of the tsunami solver
7.5 Answer Key
7.5.1 Exercise 1: Working with private components
7.5.2 Exercise 2: Invoking a type-bound method from an array of instances
7.5.3 Exercise 3: Computing finite difference in y-direction.
8 Generic procedures and operators for any data type
8.1 Analyzing weather data of different types
8.1.1 About the data
8.1.3 Strategy for this exercise
8.2 Type systems and generic procedures
8.2.1 Static versus strong typing
8.3 Writing your first generic procedure
8.3.1 The problem with strong typing
8.3.2 Writing the specific functions
8.3.3 Writing the generic interface
8.3.4 Results and complete program
8.4 Getting into Fortran’s operators
8.4.1 What’s an operator?
8.4.2 Things to do with operators
8.4.3 Fortran’s built-in operators
8.4.4 Operator precedence
8.4.5 Writing custom operators
8.4.6 Overloading intrinsic operators
8.5 Generic procedures and operators in the tsunami simulator
8.5.1 Overloading operators for the
8.6 Answer key
8.6.1 Exercise 1: Specific
average function for a derived type
8.6.2 Exercise 2: Overloading the string concatenation operator
9 Overloading operators for derived types
9.1 Happy Birthday! A countdown app
9.1.1 Some basic specification
9.1.2 Implementation strategy
9.2 Getting user input and current time
9.2.1 Your first datetime class
9.2.2 Reading user input
9.2.3 Getting current date and time
9.3 Calculating the difference between two times
9.3.1 Modeling a time interval
9.3.2 Overloading the subtraction operator
9.3.3 Time difference algorithm
9.3.4 The complete program
9.4 Overloading operators in the Tsunami simulator
9.4.1 A refresher on the
9.4.2 Implementing the arithmetic for the
9.4.3 Syncing parallel images on assignment
9.5 Answer key
9.5.1 Exercise 1: Validating user input
9.5.2 Exercise 2: Leap year in the Gregorian calendar
9.5.3 Exercise 3: Implementing a type-bound method to overload the
+ operator for two
9.6 New Fortran elements, at a glance
Part 3: The final stretch
Advanced parallelism with teams and events
Interoperability with C: Exposing your app to the web
Appendix A: Setting up the Fortran development environment
A.1 Editing Fortran source files
A.2 Setting up the compiler and libraries
A.2.1 Setting up the Fortran compiler
A.2.2 Setting up the MPI library
A.2.3 Setting up OpenCoarrays
Appendix B: From calculus to code
B.1 The advection equation explained
B.1.1 Discretizing the derivatives
B.1.2 Casting the derivatives into code
Appendix C: Glossary
About the Technology
Fortran is a general-purpose programming language that is dominant in engineering and scientific computing applications. It’s the leading language used in high performance (HPC) and parallel programming. While Fortran is the oldest high-level programming language, it is constantly improving. The most recent major revision of the standard, Fortran 2008, added native support for parallel programming on shared-and distributed-memory architectures, and will be one of few languages used for next-generation exascale HPC applications. Fortran 2018 will include additional parallel features and improve interoperability with C.
A few Fortran facts:
- If you read or listened to the weather forecast this morning, you used Fortran.
- You’ll find Fortran at the lowest levels of most popular data analysis and machine learning frameworks
- Fortran is the reference benchmark language used to measure the performance of the fastest supercomputers in the world (https://top500.org)
- Fortran is the only natively-parallel programming language steered by an International Standards Committee with scientists and engineers as its target audience
- Fortran is the dominant language of the High Performance Computing, spanning industries from applied mathematics, fluid and aerodynamics, to weather, ocean, and climate prediction
Simply put, the future is in parallel, and Fortran is already there.
About the bookModern Fortran: Building Efficient Parallel Applications teaches you how to develop fast, efficient parallel applications with Fortran. To warm up, you'll start by building a simple application in modern Fortran, with a focus on reusable modules, functions, and subroutines. Next, you'll dive into Fortran's unique approach to parallel programming with coarrays. As you work through this practical guide, you'll systematically explore all the really interesting stuff: how to overload operators and generic functions, work with a variety of different inputs and outputs, and much more. Finally, you'll take on advanced parallelism with teams and events, interoperability with C, and even publishing your finished app.
Packed with practical examples, tasks to practice, cookbook-style recipes, Modern Fortran is guaranteed to make you see this powerful language in a new light.
- Fortran’s place in the modern world
- Parallel programming from the ground up
- Working with variables and types
- Module development in Fortran
- Fortran with C, C++, and Python
- Object-oriented and functional programming styles
About the readerWritten for developers, engineers, and computational scientists. No prior experience with Fortran in needed.
About the authorMilan Curcic is a meteorologist and oceanographer. A Fortran programmer since 2006, he has worked with teams from United States Navy and NASA on developing and improving Earth system prediction models. Milan has authored two general-purpose Fortran libraries and is currently working on a startup porting Fortran to the cloud for weather and ocean prediction.
placing your order...Don't refresh or navigate away from the page.