Modern Fortran
eBook - ePub

Modern Fortran

Building efficient parallel applications

Milan Curcic

Share book
  1. 416 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Modern Fortran

Building efficient parallel applications

Milan Curcic

Book details
Book preview
Table of contents
Citations

About This Book

Modern Fortran teaches you to develop fast, efficient parallel applications using twenty-first-century Fortran. In this guide, you'll dive into Fortran by creating fun apps, including a tsunami simulator and a stock price analyzer. Filled with real-world use cases, insightful illustrations, and hands-on exercises, Modern Fortran helps you see this classic language in a whole new light. Summary
Using Fortran, early and accurate forecasts for hurricanes and other major storms have saved thousands of lives. 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. 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.. About the technology
For over 60 years Fortran has been powering mission-critical scientific applications, and it isn't slowing down yet! Rock-solid reliability and new support for parallel programming make Fortran an essential language for next-generation high-performance computing. Simply put, the future is in parallel, and Fortran is already there.Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the book
Modern Fortran teaches you to develop fast, efficient parallel applications using twenty-first-century Fortran. In this guide, you'll dive into Fortran by creating fun apps, including a tsunami simulator and a stock price analyzer. Filled with real-world use cases, insightful illustrations, and hands-on exercises, Modern Fortran helps you see this classic language in a whole new light. What's inside Fortran's place in the modern world
Working with variables, arrays, and functions
Module development
Parallelism with coarrays, teams, and events
Interoperating Fortran with C About the reader
For developers and computational scientists. No experience with Fortran required. About the author
Milan Curcic is a meteorologist, oceanographer, and author of several general-purpose Fortran libraries and applications. Table of Contents PART 1 - GETTING STARTED WITH MODERN FORTRAN1 Introducing Fortran2 Getting started: Minimal working appPART 2 - CORE ELEMENTS OF FORTRAN3 Writing reusable code with functions and subroutines4 Organizing your Fortran code using modules5 Analyzing time series data with arrays6 Reading, writing, and formatting your dataPART 3 - ADVANCED FORTRAN USE7 Going parallel with Fortan coarrays8 Working with abstract data using derived types9 Generic procedures and operators for any data type10 User-defined operators for derived typesPART 4 - THE FINAL STRETCH11 Interoperability with C: Exposing your app to the web12 Advanced parallelism with teams, events, and collectives

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Modern Fortran an online PDF/ePUB?
Yes, you can access Modern Fortran by Milan Curcic in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Lenguajes de programación. We have over one million books available in our catalogue for you to explore.

Information

Publisher
Manning
Year
2020
ISBN
9781638350057

Part 1. Getting started with Modern Fortran

In this part, you’ll get a taste of Fortran and a gentle introduction into the language.
In chapter 1, we’ll discuss the design and features of Fortran, and the kinds of problems for which Fortran is suitable. You’ll learn why parallel programming is important and when you should use it.
In chapter 2, we’ll build a minimal working example of the tsunami simulator that we’ll be working on throughout the book. This example will give you a taste of the Fortran essentials: variable declaration, data types, arrays, loops, and branches.
If you’re new to Fortran, this is the place to start. At the end of this part of the book, you’ll be able to write simple yet useful Fortran programs. More importantly, you’ll be ready to learn about Fortran essentials in more depth.

1 Introducing Fortran

This chapter covers
  • What is Fortran and why learn it?
  • Fortran’s strengths and weaknesses
  • Thinking in parallel
  • Building a parallel simulation app from scratch
This is a book about Fortran, one of the first high-level programming languages in history. It will teach you the language by guiding you step-by-step through the development of a fully featured, parallel physics simulation app. Notice the emphasis on parallel. Parallel programming allows you to break your problem down into pieces and let multiple processors each work on only part of the problem, thus reaching the solution in less time. By the end, you’ll be able to recognize problems that can be parallelized, and use modern Fortran techniques to solve them.
This book is not a comprehensive reference manual for every Fortran feature--I’ve omitted significant parts of the language on purpose. Instead, I focus on the most practical features that you’d use to build a real-world Fortran application. As we work on our app chapter by chapter, we’ll apply modern Fortran features and software design techniques to make our app robust, portable, and easy to use and extend. This isn’t just a book about Fortran; it’s a book about building robust, parallel software using modern Fortran.

1.1 What is Fortran?

I don’t know what the language of the year 2000 will look like, but I know it will be called Fortran.
--Tony Hoare, winner of the 1980 Turing Award
Fortran is a general-purpose, parallel programming language that excels in scientific and engineering applications. Originally called FORTRAN (FORmula TRANslation) in 1957, it has evolved over decades to become a robust, mature, and high perfomance-oriented programming language. Today, Fortran keeps churning under the hood of many systems that we take for granted:
  • Numerical weather, ocean, and surf prediction
  • Climate science and prediction
  • Computational fluid dynamics software used in mechanical and civil engineering
  • Aerodynamics solvers for designing cars, airplanes, and spacecraft
  • Fast linear algebra libraries used by machine learning frameworks
  • Benchmarking the fastest supercomputers in the world (https://top500.org)
Here’s a specific example. In my work, I develop numerical models of weather, ocean surface waves, and deep ocean circulation. Talking about it over the years, I found that most people didn’t know where weather forecasts came from. They had the idea that meteorologists would get together and draw a chart of what the weather would be like tomorrow, next week, or a month from now. This is only partly true. In reality, we use sophisticated numerical models that crunch a huge amount of numbers on computers the size of a warehouse. These models simulate the atmosphere to create an educated guess about what the weather will be like in the future. Meteorologists use the output of these models to create a meaningful weather map, like the one shown in figure 1.1. This map shows just a sliver of all the data that this model produces. The output size of a weather forecast like this is counted in hundreds of gigabytes.
Figure 1.1 A forecast of Hurricane Irma on September 10, 2017, computed by an operational weather prediction model written in Fortran. Shading and barbs show surface wind speed in meters per second, and contours are isolines of sea-level pressure. A typical weather forecast is computed in parallel using hundreds or thousands of CPUs. (Data provided by the NOAA National Center for Environmental Prediction [NCEP])
The most powerful Fortran applications run in parallel on hundreds or thousands of CPUs. Development of the Fortran language and its libraries has been largely driven by the need to solve extremely large computational problems in physics, engineering, and biomedicine. To access even more computational power than what the most powerful single computer at the time could offer, in the late 20th century we started connecting many computers with high-bandwidth networks and let them each work on a piece of the problem. The result is the supercomputer, a massive computer made up of thousands of commodity CPUs (figure 1.2). Supercomputers are similar to modern server farms hosted by Google or Amazon, except that the network infrastructure in supercomputers is designed to maximize bandwidth and minimize latency between the servers themselves, rather than between them and the outside world. As a result, the CPUs in a supercomputer act like one giant processor with distributed-memory access that’s nearly as fast as local memory access. To this day, Fortran remains the dominant language used for such massive-scale parallel computations.
Figure 1.2 The MareNostrum 4 supercomputer at the Barcelona Supercomputing Center. The computer is housed inside the Torre Girona Chapel in Barcelona, Catalonia, Spain. A high-speed network connects all of the cabinets to each another. With 153,216 Intel Xeon cores, MareNostrum 4 is the fastest supercomputer in Spain, and the 37th fastest in the world as of June 2020. (https://www.top500.org/lists/2020/06). It’s used for many scientific applications, from astrop...

Table of contents