FPM - failing at the first hurdle

I finally got round to moving away from Make and towards FPM. So I ran

port install fpm

(Yes, I use MacPorts)

carried on following the instructions and executed

fpm new first_steps

then

fpm run

to which my Mac replied

first_steps.f90 compiling…
[ 0%] Compiling…:failed command gfortran -c ././src/first_steps.f90 -Wall -Wextra -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single -fimplicit-none -Werror=implicit-interface -ffree-form -J build/gfortran_87E2AE0597D39913 -Ibuild/gfortran_87E2AE0597D39913 -o build/gfortran_87E2AE0597D39913/first_steps/src_first_steps.f90.o>build/gfortran_87E2AE0597D39913/first_steps/src_first_steps.f90.o.log 2>&1
run:Invalid command line
STOP 1

Which prompted the question - where did all those options for gfortran come from? I can’t find them anywhere in the fpm configuration files.

Oh, yeah, the other question, what went wrong, well I can probably sort that out myself when I figure out a bit more about how fpm is going about its business. And yes, I have pored over the documentation.

Thanks for any help offered.

I guess you have to look into the source code to understand where the flags are coming from. Fpm is coming with two different hard-coded profiles: ‘release’ and ‘debug’.

The flags are found in the fpm_compiler.f90 file. If you want to use you own profile and overwrite the default configuration, you can define a profile in the toml file, see the doc.

name = "my-package"
version = "1.0.0"

[features]
# Release feature with optimization
optim.flags = "-O3"
optim.gfortran.flags = "-funroll-loops"
optim.ifort.flags = "-unroll"
optim.preprocess.cpp.macros = ["NDEBUG"]

[profiles]
optim = ["optim"]

Like this, you can create the profile you want and use it as: fpm run --profile optim

The message is genuinely misleading and it should be fixed imho. what’s gfortran named like on MacPorts? it would look like something like this should work:

fpm run --compiler gfortran-mp-15

or with the env variable:

export FPM_FC=gfortran-mp-15

Thanks Federico

That solved the problem. I do have gfortran aliased to point to gfortran-mp-15 but I guess that fpm is using it’s own ways to find the compiler.

Mark

1 Like

Well, I did think, as I tried to figure this out “Maybe the compiler options are hard-coded into the fpm sources?” and then I thought …

… that would be a really odd design decision, surely not?

Thanks for the input

Mark

1 Like

It does make one wonder why the default options are not exposed in a configuration file. I’ve never developed software like this so I am not here to second guess, but I’m curious.

Fully customizable and named sets of flags are now possible via features / profiles since v0.13.0

I’ll be the first to admit the original design has some friction re compiler/os/customization support: the default flags were effectively baked in, which is exactly the issue you’re running into. That’s part of why I pushed the features/profiles work into 0.13.0: it’s a substantial improvement and should give you the configurability you’re after.

For the historical context behind the original choices, you can look up the repository issues section, e.g.:

1 Like