Leanpub Header

Skip to main content

Modern Fortran Programming

From Fundamentals to High-Performance Scientific Computing

Modern Fortran Programming
This book is 100% completeLast updated on 2026-08-26

Modern Fortran is still powering some of the world's toughest scientific problems. This practical guide takes you from the basics to high-performance computing, covering modern language features, parallel programming, numerical reliability and optimization. Learn to write scientific software that is clean, fast and built to last.

Minimum price

$25.00

$35.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
207
Pages
About

About

About the Book

Fortran is more than a relic of computing history. It remains the language of choice for some of the world's most demanding scientific and engineering applications, from weather prediction and climate modeling to computational fluid dynamics and astrophysics. This book takes you from your very first Fortran program through advanced topics like object-oriented design, parallel programming with coarrays, C interoperability, numerical correctness, and high-performance optimization. You will learn not only the syntax of modern Fortran (Fortran 2018 and later) but also the reasoning behind its design, common pitfalls to avoid, and professional practices for building reliable, maintainable, and fast scientific software. Whether you are a scientist new to programming or an experienced developer stepping into the world of high-performance computing, this book provides both a structured learning path and a practical reference you can return to throughout your career.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

From Fundamentals to High-Performance Scientific Computing

Introduction

  1. What You Will Learn
  2. How to Use This Book
  3. A Note on Standards and Compilers
  4. Why Learn Fortran Today?

Chapter 1: The Story of Fortran — History, Evolution, and Modern Relevance

  1. The First Programming Language — FORTRAN I and the Birth of Compilers
  2. Standardization and Survival — From FORTRAN 66 to Fortran 90
  3. The Modern Renaissance — Object-Oriented Features, Parallelism, and Beyond
  4. Why Fortran Today — Supercomputers, Legacy Codebases, and New Projects
  5. How This Book Is Organized — A Roadmap for the Reader

Chapter 2: Your First Fortran Programs — Structure, Compilation, Execution

  1. The Anatomy of a Fortran Program — Source Files and Program Units
  2. Setting Up Your Environment — Compilers and Tools
  3. Hello World and Beyond — Free-Form Source and Basic Structure
  4. Compilation and Linking — From Source to Executable
  5. Common First Errors and How to Fix Them
  6. A Slightly Larger Example — Organizing Code from the Start

Chapter 3: Data, Types, and Numbers — Variables, Kinds, Precision, Literals

  1. Declaring Variables — Types, Names, and Style
  2. The Intrinsic Data Types — Integer, Real, Complex, Logical, Character
  3. Kinds and Numerical Precision — Choosing the Right Representation
  4. Literals, Constants, and Parameters — Exact Values in Code
  5. Operators and Expressions — Arithmetic, Relational, Logical
  6. Summary

Chapter 4: Control Flow and Iteration

  1. Conditional Execution — IF Constructs and SELECT CASE
  2. Looping with DO — Count-Controlled Repetition
  3. Advanced Loop Patterns — WHILE-like Loops, Exit, Cycle, Nested Loops
  4. Structured Programming Discipline — Avoiding GOTO
  5. Algorithmic Examples — Search, Sort, and Iterative Methods
  6. Summary

Chapter 5: Arrays and Array Operations

  1. Declaring Arrays — Shape, Bounds, and Initialization
  2. Multidimensional Arrays — Matrices and Beyond
  3. Array Syntax and Whole-Array Operations — Vectorized Code
  4. Slices, Sections, and Masked Arrays — Selective Access
  5. Memory Layout and Performance — Column-Major Order and Cache Behavior
  6. Summary

Chapter 6: Input and Output

  1. List-Directed I/O — Simple Reading and Writing
  2. Formatted I/O — Edit Descriptors and Precision Control
  3. Internal Files — String Formatting and Parsing
  4. Unformatted and Stream I/O — Binary Data and Portability
  5. Robust Input Handling — Error Checking and User Interaction
  6. Summary

Chapter 7: Procedures and Interfaces

  1. Functions and Subroutines — Designing Reusable Procedures
  2. Argument Passing and Intent Attributes — Clarity and Safety
  3. Optional and Keyword Arguments — Flexible Interfaces
  4. Explicit Interfaces and Interface Blocks — Compile-Time Checking
  5. Generic Interfaces and Operator Overloading — Polymorphic Names
  6. Summary

Chapter 8: Modules and Program Organization

  1. What Modules Are For — Encapsulation and Code Sharing
  2. Module Structure — Public, Private, and USE Associations
  3. Submodules — Separating Interface from Implementation
  4. Scope Rules and Name Resolution — Avoiding Collisions
  5. Organizing Large Projects — Module Architecture Patterns

Chapter 9: Derived Types and Object-Oriented Fortran

  1. Defining Derived Types — Structuring Complex Data
  2. Type-Bound Procedures — Methods in Fortran
  3. Polymorphism and the CLASS Keyword — Dynamic Dispatch
  4. Abstract Types and Type Extension — Inheritance Hierarchies
  5. Design Patterns with Modern Types — When OOP Helps
  6. Summary

Chapter 10: Memory Management — Allocatables, Pointers, and Dynamic Data

  1. Allocatable Variables — Dynamic Sizing and Lifecycle
  2. Allocation Patterns — Arrays, Derived Types, and Error Handling
  3. Pointers and Pointer Semantics — When They Make Sense
  4. Common Memory Pitfalls — Leaks, Dangling References, Double Free
  5. Modern Alternatives — Preferring Allocatables Over Pointers

Chapter 11: Parallel Programming with Coarrays

  1. The Coarray Model — Images, Teams, and Shared Variables
  2. Declaring and Using Coarrays — Basic Syntax
  3. Synchronization — Event-Based Coordination with SYNC
  4. Communication Patterns — Scatter, Gather, Reductions
  5. Practical Parallel Programs — Real Examples and Pitfalls

Chapter 12: Interoperability — Connecting Fortran to the World

  1. Why Interoperate — Ecosystems and Libraries
  2. The ISO_C_BINDING Module — Types, Constants, and Procedures
  3. Calling C from Fortran — Practical Examples
  4. Calling Fortran from C — Exporting Interfaces
  5. Beyond C — Python, Julia, and Other Language Bridges
  6. Summary

Chapter 13: Numerical Correctness and IEEE Floating-Point Facilities

  1. How Floating-Point Works — Representation and Limitations
  2. Precision Selection and Kind Parameters — Getting It Right
  3. IEEE Arithmetic Facilities — Querying and Controlling Behavior
  4. Numerical Stability — Algorithms That Work in Practice
  5. Reproducibility — Making Results Repeatable
  6. Summary

Chapter 14: Performance Optimization and High-Performance Computing

  1. Understanding Compiler Optimizations — Levels and Flags
  2. Writing Vectorizable Code — What Compilers Can Accelerate
  3. Memory Access Patterns — Locality, Stride, and Cache Efficiency
  4. Profiling and Benchmarking — Measuring Real Performance
  5. HPC Considerations — Scaling to Large Systems

Chapter 15: Build Systems, Testing, and Modern Toolchains

  1. The Fortran Package Manager (fpm) — Modern Builds Made Simple
  2. CMake for Fortran Projects — Cross-Platform Build Automation
  3. Traditional Makefiles — When They Still Make Sense
  4. Testing Strategies — Unit Tests and Validation Frameworks
  5. Static Analysis, Linting, and Documentation Tools
  6. Summary

Chapter 16: Professional Practices and Legacy Code

  1. Coding Standards — Naming, Formatting, and Readability
  2. Defensive Programming — Error Handling and Robustness
  3. Resource Management — Cleanup and RAII-Like Patterns
  4. Version Control Conventions — Git Practices for Fortran Projects
  5. Modernizing Legacy Code — Strategies and Tools
  6. Summary

Conclusion: The Future of Fortran

  1. What You Have Learned
  2. Where Fortran Is Heading
  3. Why Fortran Still Matters
  4. Final Advice

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub