Is there a go-to code formatter for Fortran?

I cannot live without a formatter anymore and I think it is neccesary that a software project has a consistent formatting style.

lfortran is one of my favorite projects in Fortran space, but I think it is a very sophisticated tool for the purpose of just indentation and I had a case when it mangled my code (unfortunately I did not distill a bug report and now I do not remember which file caused the issue). Since then i stick to findent, maybe it is stupid but I really feel safer when my formatter just takes care of just whitespaces.

Regarding some of the closed-source tools mentioned here, consider this my personal opinion but I think that “if it is not free software it does not matter” – any software which may not be freely downloaded or modified effectively is out of the picture when it comes to widespread adoption. For small and frequently used tools like code formatters, this is especially true. (One of the reason I keep my code compatible with gfortran, as much pain as it might cause – otherwise I would restrict the freedom of an end-user to use my software).

3 Likes