Skip to content

Default Modern Fortran flags #359

@epagone

Description

@epagone

TL;DR

This proposal aims at collecting and setting up with fpm a modern Fortran environment by default (e.g. no implicit typing, no fixed form, etc...), without requiring any change to the current compilers behaviour or the standard. Packaging of important legacy code (of critical importance for much of the Fortran community but usually requiring special flags regardless) would be supported overriding the mentioned defaults.


As of 2021 no one should reasonably write Fortran

  • in fixed form
  • with implicit typing (thus making implicit none redundant as obvious)
  • using "implicit save" of module variables
  • what else? Please suggest.

I believe that fpm should provide default, overridable compiler flags enforcing the above. In this way, a little bit more dust and rust will be hopefully removed from the perception of the language to potential newcomers. Furthermore, since these changes are difficult to implement into the standard, fpm can be also presented as the only, long-awaited solution (by some practitioners, at least) to these issues.

Packaging of legacy libraries would likely require regardless a tailored fpm.toml thus, it would be a matter of adding a few more specifications to override the above defaults.

In more detail.

Fixed Form

This idea started from this conversation where I dream of reclaiming the .f extension for new code without resorting to the current, Jurassic .f90 to specify free from. The only potential issue that I foresee in this case is that legacy dependencies will be compiled with different flags but, if I understand correctly the logic of fpm, this should not be an issue.

However, it would be really amazing if fpm would be able to autodetect the source code form, as @ivan-pi suggested here, but I guess that it would require quite a lot more work.

Implcit typing

This sounds pretty simple to do, e.g. -fimplicit-none with gfortran or -implicitnone with Intel Fortran.

Implcit save

Is this possible? Googling, I have seen that with gfortran -frecursive might do the trick but I am not sure if it is really the case and if it will trigger some other side-effect undesired in a "default" setup (Intel seems to have -recursive).

What do you think?

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