Defining formatting styles for Fortran

Personally, I don’t like aligning, exactly because of the extra work it introduces. Also if some of the dummy variables have additional attributes besides intent, such as pointer, target, save, or contiguous you have to make a decision how to deal with the extra whitespace. But as the old saying goes, de gustibus non disputandum est.

Concerning free-form styles, source code from NAG follows a very distinct style, where Fortran keywords are capitalized. You can see this in their LAPACK examples: LAPACK_Examples/dbdsdc_example.f90 at master · numericalalgorithmsgroup/LAPACK_Examples · GitHub. Other properties of this style include 2-space indentation for nested constructs, and a 4-space empty zone used for format and goto labels. I presume the style can be achieved using the NAG source file polishing tool. (Note: personally I’m not a fan of this style, as I can’t be bothered to capitalize Fortran keywords.)

4 Likes