Fpm free-form long lines

Dear all,

I will go crazy probably … apparently I did something and now when I fpm run --profile release it complains about too long lines in my source code.

Which I definitely have in many places, I would like to keep and I would like to pass --ffree-line-length-280 to the compiler. The code was working last week; I suspect I mistakenly deleted a line either in my toml (or somewhere), or switched the option in another place.

GhatGPT suggest

[build]
flags = ["-ffree-line-length-200"]

Which does not work (Key profile is not allowed in package file)

Thanks in advance

That check says that somewhere in your fpm.toml you have a [profile] table. That is not accepted, the correct one is [profiles] ([profiles] was always tolerated but not used in fpm<0.13. Since fpm>=0.13 they’re used and they’re lists of features). in your case, you could have a per-compiler feature allowing long lines:

[features]
longlines.gfortran.flags = "-ffree-line-length-280"

[profiles]
default = ["longlines"] # add to all builds

or, just run with the profile/feature combination you wish to use:

fpm run --features release,longlines
1 Like

Thanks, my fpm version is 0.13.0alpha.

How could I broke things during the WE? I could mistakenly delete a line in vim … but I don’t remember I had anything similar to this (at least not [features])

The Discourse answer is essentially correct for the newer fpm 0.13 development versions, but there is an even simpler way if your immediate goal is just to compile long free-form Fortran lines.

For gfortran, try:

fpm run --profile release --flag "-ffree-line-length-280"

Or, if you don’t want a practical limit:

fpm run --profile release --flag "-ffree-line-length-none"

fpm supports passing Fortran compiler flags with --flag, and FPM_FFLAGS is the corresponding environment variable.

So you could also do:

export FPM_FFLAGS="-ffree-line-length-none"
fpm run --profile release

Why it may suddenly have changed

The important clue is:

fpm version is 0.13.0alpha

You’re using a development/alpha fpm, and the profile/feature mechanism has changed. That makes it quite plausible that the project didn’t actually lose a line from fpm.toml; an fpm upgrade or changed profile handling could have altered which compiler options are being supplied.

The old-looking configuration

[build]
flags = ["-ffree-line-length-200"]

is not the right solution for current fpm.

For the newer feature system shown in the discussion, the intended form is:

[features]
longlines.gfortran.flags = "-ffree-line-length-none"

[profiles]
default = ["longlines"]

Then:

fpm run

should activate it through the default profile, or you can explicitly select the feature:

fpm run --features release,longlines

One detail worth checking first is exactly which build you’re running:

fpm --version
gfortran --version
fpm run --profile release --verbose

The verbose output should reveal the actual gfortran command line. That will tell you whether -ffree-line-length-* used to be supplied and has disappeared.

For GNU Fortran, I’d use -ffree-line-length-none rather than 280: it removes the artificial line-length problem altogether while retaining your existing source formatting.

1 Like

Thanks, it works also with a command-line argument.

With a --verbose to the fpm it shows all the options, and now the ‘free-line-length-none’ is there… Probably update of the fpm should be my main suspect; but I did not update it (by intention) recently.

It was very nervous to to discover suddenly, that a program which I just tested and which was working last week just stopped to compile.

Hi @sshestov, the profile/feature capability in v0.13.0 was made fully backward compatible with all previous versions (default release/debug profiles don’t change), but if you find / track down any issues, do not hesitate to open them on the fpm github repository