Fortran was the first widely used high-level language, released by IBM in 1957, and it remains a workhorse for weather prediction, computational physics and engineering simulation. Modern Fortran, from the 1990 standard onward, is far friendlier than the punch-card code people imagine: it has free-form source, modules, whole-array operations, dynamic memory and built-in parallel features. Its strength is that arrays are first-class, so numerical code reads close to the math. Learnr teaches Fortran through short lessons and coding exercises tuned to what you want to compute.
How to learn Fortran, step by step
- Start with modern Fortran, not FORTRAN 77. Install gfortran and write free-form .f90 files. Put implicit none at the top of every program and module, because without it, variables beginning with I through N silently become integers and typos turn into new variables.
- Think in whole arrays. Practice expressions like a = b + 2.0 * c and slices such as x(2:n-1) instead of writing loops for everything. Learn that indexing starts at 1 by default and that arrays are stored column by column.
- Package code into modules. Move procedures into modules so the compiler checks argument types for you. Declare intent(in), intent(out) or intent(inout) on every dummy argument, which catches a whole class of bugs at compile time.
- Get floating point precision right. Use kind parameters from iso_fortran_env, such as real64, rather than real*8 or bare real. Write literals as 1.0_dp so constants are not silently computed in single precision.
- Build a small simulation. Implement something concrete, like heat diffusion on a grid or an orbit integrator, and write results to a file you plot elsewhere. A project forces you to combine arrays, modules, I/O and loops.
- Learn the performance tools. Compile with -O2 and bounds checking during development, profile the hot loops, then add OpenMP directives or call BLAS and LAPACK. Keep loops ordered so the first index changes fastest.
What you'll learn
- Write free-form modern Fortran programs with implicit none and explicit types
- Use whole-array operations, slicing and intrinsic functions like matmul and sum
- Organize code into modules with procedures that declare argument intent
- Manage dynamic memory with allocatable arrays
- Compile, link and parallelize a numerical program with gfortran and OpenMP
How long does it take to learn Fortran?
Programmers coming from Python or C can write useful modern Fortran in 3 to 6 weeks at a few hours a week. Beginners to programming should allow 2 to 4 months. Reading large legacy codes with COMMON blocks and fixed-form source takes extra time.
What you need before you start
Basic algebra is enough to start, and some calculus or linear algebra helps for the scientific examples. Prior programming experience shortens the learning curve but is not required.
Common mistakes to avoid
- Forgetting implicit none, so a misspelled variable compiles as a new, uninitialized one and quietly corrupts results.
- Looping over arrays in row-major order out of C or Python habit, which wastes cache. Let the leftmost index vary fastest in nested loops.
- Mixing single and double precision literals, such as writing 0.1 instead of 0.1_dp, which leaks rounding error into otherwise double precision code.
How Learnr builds your course
Type your topic
Tell Learnr you want to learn Fortran, or get as specific as you like.
Get a personalized course
Learnr instantly builds a full Fortran course tailored to your goal and skill level.
Learn and level up
Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.
Fortran questions, answered
Is Fortran still used today?
Yes. Many weather, climate, nuclear, aerospace and computational chemistry codes are written in Fortran, and it is a standard language on supercomputers. The language is actively maintained, with standards published in 2018 and 2023.
Should I learn Fortran or C++ for scientific computing?
It depends on the codes you will work with. Fortran is simpler for array-heavy numerical work and dominant in some fields, while C++ is broader. If your lab or employer maintains Fortran, learn Fortran first.
Which Fortran compiler should a beginner use?
gfortran, part of the GNU Compiler Collection, is free and runs on all major systems. Intel ifx is also free to download. Code that follows the standard compiles on both.
Explore more courses
More programming and tech courses
- Learn Erlang
- Learn OCaml
- Learn Common Lisp
- Learn Prolog
- Learn SwiftUI
- Learn Jetpack Compose
- Learn NestJS
- Learn Nuxt
See all programming and tech courses
Ready to learn Fortran?
Start your free, personalized Fortran course in seconds. It will be typed in and ready when you get there.
Start learning FortranFree to start. No credit card.