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?
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
V(R) values in an input file, along with the
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@example.com).
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 firstname.lastname@example.org.
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.