How do you actually “get good” at Fortran?

Hi guys,

Sorry I know this is a really basic thing to ask you about but I’ve been thinking recently about expanding my programming skills.

I was hoping to maybe get into Fortran but I have to admit it’s very daunting trying to find good materials to start learning. My biggest issue is dedicating myself and being consistent so if there’s maybe a way to reward hack myself with coding exercises that would also be good

Are there any resources you’d personally suggest as a good starting point? I don’t mind books, courses or websites really. I have a general preference for good quality textbooks so I can use them as desk references etc so if you had any suggestions that would be great.

Thanks

1 Like

Hi @Oppenheimer welcome to the discourse, we’re glad you’re here.

Getting into anything new is daunting. I would suggest you start at the Fortran lang website, it has a couple of very nice tutorials. There’s some books that are good to get started, see Modern Fortran by Milan Curcic.

There’s some nice youtube tutorials, but we don’t have as much content as there might be for C/C++.

Also, what type of applications are you thinking on going into? Depending on that there might be some resources that are better than others.

A great book is Modern Fortran Expained but this one is like a reference book, not exactly a textbook.

Then the next best thing is to look at some youtube videos that cover very new and cool things in the language.

You can look at people’s open source projects. If you’re into chemistry let me know.

1 Like

I asked AI and it pretty much agrees. In general most Fortran programmers start with a problem they want to solve, typically requiring primarily numeric computation and then apply Fortran as a tool to solve the problem, although Fortran is used more generally as well, particularly since the C/Fortran interface was standardized. In addition to the following AI-generated description, which has much in common with the previous reply, the Fortran Wikis are a useful resource.,

Simon says …

To get good at Fortran, you must
actively practice by building projects, studying existing code, and engaging with the community, focusing exclusively on modern Fortran standards (2008, 2018, and beyond). Learning is a skill-building process that requires consistent effort, not memorization.

Foundational Steps

  • Learn Modern Fortran: Avoid tutorials or books that focus on older standards like Fortran 77, as they use outdated practices that can hinder learning modern programming concepts.
  • Use the Right Resources:
    • Start with the quickstart guide and tutorials on the official fortran-lang.org website.
    • For a comprehensive reference, the book Modern Fortran Explained: Incorporating Fortran 2018 by Metcalf, Reid, and Cohen is recommended.
    • Online playgrounds like dev.lfortran.org and godbolt.org allow you to test snippets of code immediately without installing anything.
    • Video tutorials, such as the Fortran 90 beginners tutorial or the short course from the Our Coding Club, can also be helpful.
  • Set Up Your Environment: Install a modern Fortran compiler like GFortran (part of the GNU Compiler Collection) on your local system, which is available on Linux, macOS, and Windows (via Cygwin).

Practice and Application

  • Practice by Doing: The most effective way to learn a programming language is to practice. Start with small, standalone programs (e.g., a program to compute prime numbers or simulate a simple physical problem) to build confidence.
  • Build Personal Projects: Take a problem you’ve solved in another language (like Python) and implement it in Fortran to understand the syntax and semantic differences.
  • Read Other People’s Code: Look at the source code of existing Fortran programs from various sources (university departments, GitHub, etc.) to see how others have solved problems and pick up on established practices. Be aware that much academic code may not follow the best software engineering practices.
  • Join a Community: Engage with other programmers on forums like the Fortran-lang Discourse or the Fortran subreddit. These communities are valuable for getting help, discussing performance tips, and finding project inspiration.
  • Work with Legacy Code: Given Fortran’s extensive use in scientific computing, you will likely encounter large, older codebases. Learning to understand and modernize this code is a key skill for a professional Fortran programmer.

Ultimately, mastery comes from consistent effort, problem-solving, and a deep understanding of the underlying mathematics and algorithms, not just the language syntax itself

3 Likes

I don’t have much to add to @jorgeg’s and @urbanjost’s excellent replies (and the previous discourse replies the LLM likely relied on), but would add recommendations for environments and tools:

  • You can conveniently use conda for setting up your environments. You can get LFortran, fpm, FORD (documentation tool) and other great fortran tool from conda-forge.
  • Using fpm makes building and running your projects simpler/faster.
  • Explore stdlib’s functionality to help get your projects off the ground faster. (Yes, you can learn from re-implementing everything, but doing that can also take the fun out of learning and ultimately make you abandon your learning journey).

Then, find projects you are enthusiastic about (existing or new) and just go for it (with the recommended references to help you)!

Other really useful tools:

  • fortls that can do things like code completion and display documentation for functions, as well as help you navigate projects through jump to definition and find references
  • Fortitude can help catch and fix bugs, obsolete code, and style violations

Both of these can integrate with your code editor (VS Code, vim, Emacs and so on)