Scientists like myself are famously bad at software engineering. I have a code I need to use with a horrible custom build system written in Perl. ![]()
I want to start a new project. I come here seeking advice on some of the initial decisions to try to start the project on the right foot. I’m going to write an OpenACC + MPI code that compiles to CPU or GPU, and I want to make it easy to build / use / maintain.
(1) As a build system, should I use fpm (“Fortran Package Manager”) or Meson? Or something else? I have experience with neither. What’s easy?
(2) There will be optional modules. What’s a good way to turn modules on or off? My baseline plan is to recompile the code and use the cpp preprocessor that most compilers have to decide which modules get included. Does that sound like a good option?
(3) I’m going to need FFT, Linear Algebra, random numbers, etc. I could use CUDA libs when I compile to GPU and stdlib when I compile to CPU.
- Does that sound like a good idea?
- How mature is stdlib? Should I use it?
- What is the best way to switch between CUDA and stdlib? Should I use preprocessor macros and conditional compilation?
I’m also thinking about how these choices intersect. For example, stdlib doesn’t work with nvfortran. Ok. No problem; nvfortran can be just for GPU when I use CUDA. But… one of the features of fpm is that you can mark dependencies. If I say that stdlib is a dependency, will that prevent me from compiling with nvfortran CUDA?
Oh, and would fpm limit my ability to change the compilation options? Like with the optional modules I mentioned in (2)?
(4) I’m going to need config files. I’m thinking of using TOML (Tom’s Obvious Minimal Language). There is a Fortran library for TOML. I see options to “build with fpm” or “integrate TOML Fortran in your meson project”. Let me know if you have any thoughts about that.
Thanks for the help. Feel free to give any advice that you have in mind, or rant about the horrible code you’re forced to maintain so I can avoid making the same mistakes.
Thanks!