Fpm building projects with serial, mpi and coarray parts

Dear all,

I am trying to build a project (the Fortuno unit testing framework) with fpm. The project contains serial, MPI-parallelized and coarray-parallelized code. In order to allow for a proper build, I need the following build features:

  • a way to specify, that only certain files should be included into the build (e.g. if the consumer does not have MPI, all MPI-related stuff should be left out), and

  • a way to specify, that different parts of the project need different compiler flags (e.g. the serial and the MPI-part should be compiled without the -coarray option, while the coarray part would need it).

I was able to set that up with CMake, but I would be very interested to enable also an fpm-build. Does anybody have suggestions, how to achieve something similar with fpm?

1 Like

For the second point, we need to finish the compiler profiles feature, which would allow you to specify per file flags. For the first point, we need a “package options” type of feature (see how Rust does this). Very little preliminary work has been done on this.

For point 1. you might be able to do something with build-script or using some other type of custom build script written for example in Python, which is cross platform, that tries to compile some MPI code and creates a file with a preprocessor macro to be included and then calling fpm, but that is as hacky as it gets. It shouldn’t be that difficult to accomplish this.

Maybe we can get a student this summer to finalise the profiles PR and get started on the adding package options.

Thanks a lot! I would like to avoid applying a “hacky” solution, I think a unit testing framework should also serve as a demonstration, how to set up a Fortran project properly, and not being a template for hacky workarounds. :wink:

I am considering to generate 3 different archives at deployment (serial, MPI, coarray), so that all files and the same flags can be used within one archive. Can fpm use a .tar.gz archive (or something similar) as dependency? So far, I have only seen git repositories as dependencies in the examples.

2 Likes

You can specify local dependencies with the path “argument”.

Thanks, I was not aware of the path argument.

Unfortunately, what I would wish for, is to download a dependency, other than from a git repository. I my git repository, I have the mixed (serial, MPI, coarray) sources. I would like to avoid to create and maintain 3 different repositories (or even 3 different branches within one repository). But what I could probably easily do is to create 3 different archive files at every release. So, if people wanted to depend on any of these, they should be able to specify a remote dependency, which is an archive, not a git repository. But I guess, that is not possible in fpm yet. (And if not, are there any plans to include it? Or any principal objections against it?)

3 Likes

I think it’s exactly the kind of feature that will come along with the official registry. It will be downloading tarballs from there, so you should be able to specify your own url for that. We haven’t quite worked out the exact syntax I think, but will probably look at Cargo for inspiration.

2 Likes