What are some good textbooks or online resources to improve my skills in C++, C and Fortran, specifically for computational chemistry.

For example, I am interested in learning about parallelisation with openMP or MPI, depending on the algorithm/task at hand.


3 Answers 3


My Story

As an undergrad doing my first computational research project, I was told that I would be programming in FORTRAN. I remember being very nervous about this because I had never touched FORTRAN before, and neither had anyone that I knew (including people much older than me), plus I had heard horror stories about it, such as "indentation matters" (which is ironically no longer true since Fortran 90, yet it's true for Python which is one of the most popular languages in 2022).

I was also a perfectionist when it came to academia, and I had enormous respect for my soon-to-be research supervisor, so I certainly wanted to impress him. I went to the library and borrowed a couple beginner-level books about FORTRAN, and hoped to actually be useful on day 1 of the job. I don't think I got past the first page of either of those books though, and the books basically sat on my desk collecting dust all the way until the last day of the summer job.

So how did I learn FORTRAN?

By doing.

I remember being quite relieved when I learned that the project would involve more of "running" programs than "writing" programs, but in the final weeks when my supervisor asked me to write some programs, and I remember it being a daunting task at first since I had no idea where to begin, and I had told my supervisor that I had programming experience, and didn't quite realize that this doesn't mean I'm expected to know FORTRAN. I can't recall using the books much (if at all) though.

The first FORTRAN program I can recall writing was actually a stand-alone program that my supervisor wanted me to write, to obtain the long-range tails of potential energy curves at various distances in a transformed coordinate system, after being given the R and V(R) values in an input file, along with the C3,C6,C8,C10 for the long-range potential, and another input parameter to tell the program what type of transformation the user would like the program to make on the data. The END statement was on line 127 and about 44 lines of whitespace or comments.

The basis for me writing this program was whatever little I could find on the internet back then. I got my supervisor to help me get the program running, because I thought that I couldn't do it myself, but I was quite amazed in the end, when we got it running the first time. I don't ever recall looking at a FORTRAN book since then. I then wrote more and more complicated programs, often requiring me to use other people's programs as a subroutine to mine, and often requiring me to interface my program within much larger programs. I also went into other people's programs and modified them or corrected them on many occasions. My guidance throughout all this time was the internet, not books.

What I recommend for anyone

If you want to get better at Fortran or C++, I would recommend to just get involved in a project in one of those languages, and learn as you go (referring to the world-wide-web as often as you need). OpenMolcas is written in FORTRAN and is open-source, allowing you to go through this issues list and work on something of your choice. This would be the best way to learn Fortran in my opinion. Psi4 uses a lot of C++ and you can similarly volunteer to help on their issues list too.

As with me, having a supervisor, or just someone with more experience in the language, working with you (or just readily available to answer any questions) can be immensely useful in terms of saving time when you're stuck. If you want me to help you in this way for learning Fortran, there's plenty of OpenMolcas projects we can work on together (you can email me at [email protected]).

Learning more advanced features

The technique to learn more advanced features (you mentioned OpenMP and MPI) surprisingly is the same! When you want to do something, just look it up online! It can help to have an already-parallelized Fortran program like OpenMolcas or NECI to use as a template. An undergrad student of mine (David Wilkins) had no Fortran experience and yet wrote an OpenMP paralellized hierarchical equations of motion program in Fortran without my help, within one week (believe it or not, I'm not exaggerating!).

I've also taken free crash courses / workshops on OpenMP and MPI from SHARCNET, which seemed to be helpful since we did hands-on exercises in which we actually wrote parallel programs using OpenMP/MPI, but in the end almost all of the OpenMP/MPI coding I did was either based on using existing codes as templates, or based on help I found online. Occasionally I got help from extremely highly skilled IT support staff at supercomputing centres (essentially the people who teach courses like the SHARCNET ones I mentioned earlier in this paragraph).

Since you asked, here's some resources:

From the SHARNET tutorials I mentioned in the previous section, here's some resources you can use if you prefer to learn this way (i.e. learning "in advance" rather than by "doing"):


I can't really recommend books for programming anymore! Even when I was an undergrad student, I found whatever existed online back then to be "infinitely" more useful than the programming books that I did borrow from the library.

In order of effectiveness, I recommend:

  • "doing" projects (and searching online when you get stuck),
  • in-person workshops like the SHARCNET one I mentioned in the previous section,
  • Youtube videos or PDF online tutorials like the SHARCNET ones I mentioned in the previous section

SHARCNET regularly offers free beginner, intermediate, and advanced-level workshops in parallel computing and Fortran/C/C++/Python/etc. These are available to all of my group members (for example), and if you're interested in attending one of these, you can let me know at [email protected].


After writing this answer, I wanted to share your question with the Fortran King to try to attract more attention to your question, and while doing so I discovered that a similar question was asked on MMSE before: How to master Fortran with minimal effort? and some books were recommended there.

  • $\begingroup$ Note Fortran is officially spelt lower case, and has been since the 1990 standard. $\endgroup$
    – Ian Bush
    Commented Dec 4, 2022 at 9:58
  • $\begingroup$ Even when talking about F77? $\endgroup$ Commented Dec 4, 2022 at 10:04
  • $\begingroup$ For F77 and earlier it wasn't defined what the spelling was, the upper case is purely "traditional". But except when talking history F77 and legacy code shouldn't be relevant nowadays, certainly nobody should be learning it. Even f95 is dated nowadays. $\endgroup$
    – Ian Bush
    Commented Dec 4, 2022 at 11:10
  • $\begingroup$ @NikeDattani really thanks for the answer. The SHARNET lectures are great, this is something I have overlooked sometime, ago. Thanks again for drawing back my attention to them. I am actually looking for ways to improve on my novice skills and I guess getting someone to review my code is the way to go. I will try to look for some issues in some qchem repos on github. $\endgroup$
    – Fracton
    Commented Dec 5, 2022 at 13:39
  • $\begingroup$ youtu.be/t32BNi3NEYA $\endgroup$ Commented May 31, 2023 at 12:08

Dr. Victor Eijkhout at Texas Advanced Computing Center (TACC) has some excellent resources at his website The Art of HPC, including freely available textbooks on

  • Introduction to High-Performance Scientific Computing
  • Parallel Programming for Science and Engineering
  • Introduction to Scientific Programming
  • HPC Carpentry

Of these, Parallel Programming for Science and Engineering is the one that introduces MPI and OpenMP, with examples in C, C++, Fortran, and (for MPI only) Python. However, for a first introduction to the topics his slides for one-day training sessions may be more accessible. You can find them here.

  • $\begingroup$ +1, I was hoping someone would complement my answer with some examples of books, since it's something that my answer was lacking! $\endgroup$ Commented Dec 3, 2022 at 19:23

Just to complement previous and more detailed answers by @Nike Dattani and @Anyon. I found a very useful reference to review Modern Fortran and paralellization the book by Milan Curcic: Milan Curcic, Modern Fortran: Building Efficient Parallel Applications, Manning (2020)

I found the book very readable and oriented to learning by doing. The code in the book is accesible in GitHub and probably you can get an electronic copy if you need it.

  • 1
    $\begingroup$ +1. Welcome to the community! I see you've been around for a while, thanks for writing your first answer :) Hopefully the first of many! $\endgroup$ Commented Dec 6, 2022 at 22:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .