Universal good practice style guide for fortran

Something which can be enforced automatically, by a code formatting tool.

The rules does not matter, as long as they’re applied consistently on all code.

Every language has one or more code formatting tools.

C++ has clang-format, rust has rust-fmt, go has go-fmt, etc.

Fortran has fprettify: GitHub - fortran-lang/fprettify: auto-formatter for modern fortran source code

For me, fprettify is good enough.

I use the command: fprettify -S -i4 -w1 to format my code.

It has good defaults, that’s why I don’t need to configure too much. -i4 just sets indentation to 4 spaces per tab, and -w1 uses a predefined configuration for white spaces.

1 Like