Skip to content

Use fortran linter for formatting? #482

@mnlevy1981

Description

@mnlevy1981

Much like #425 highlights formatting inconsistencies in the python code, there is lots of the same in the Fortran code as well. @briandobbins mentioned fortitude at a recent meeting -- it's in active development, though it hasn't hit v1.0 yet so typical beta software warnings apply.

One issue I ran into is that the pip installer requires python 3.10, while our old version of Sphinx requires 3.9 or older... I was able to use the standalone installer instructions, which then needed to be added to $PATH. I'm sure this is a solvable :)


As for the actual output, it does highlight quite a few potential formatting issues:

$ fortitude check --preview --file-extensions=F90 --line-length 132 --statistics
2806	S241  	[*] single-quote-string
 269	MOD021	[*] deprecated-relational-operator
 113	S231  	[*] keywords-missing-space
  64	MOD011	[*] old-style-array-literal
  60	C152  	[*] misleading-inline-if-continuation
  43	C003  	[ ] implicit-external-procedures
  24	C072  	[ ] assumed-size-character-intent
  12	C082  	[ ] pointer-initialisation-in-declaration
  10	C011  	[ ] missing-default-case
   7	C101  	[ ] missing-default-pointer-initalisation
   2	C061  	[ ] missing-intent
   2	C081  	[ ] initialisation-in-declaration
   2	C121  	[ ] use-all
   1	C131  	[ ] missing-accessibility-statement
   1	S061  	[*] unnamed-end-statement
fortitude: 43 files scanned.
Number of errors: 3416

I definitely want to get #464 merged in before doing anything with this, though it looks pretty good. For example, the 2 missing-intent flags point to the constructor / destructor of the column_sinking_particle_type and marbl_surface_flux_share_destructor has an unnamed end subroutine (both of these are in marbl_interface_private_types.F90). @klindsay28 this might finally get rid of the Fortran-77 logical operators!

We should probably skip C003, it complains about implicit none not having an external and Brian says that's part of the F2018 standard (would be really nice to have a --standard 2008 flag or something!) I'd also vote for keeping the assumed-size-character-intent, at least for now (I need to read up on why it is recommended to avoid that construct and what other options are available)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions