FAB: Open source build system for Fortran and C Projects

I just learned about this project that had a v1.0 release recently:

FAB: An open source build system for Fortran and C projects. Initially designed to build the Met Office’s major scientific applications, LFRic and the UM.

It appears to have some overlap with fpm in terms of motivation and functionality, but with more extensibility for custom build steps since the configuration file is a Python script.

More information in the documentation:
https://metomi.github.io/fab/features.html

Has anyone got experience with using this tool?

No real experience at all, played with it once and meant to look more; never did.
Had rough edges, worked with just ifort and gfortran. Was most interested in how it did file-specific rules for building. Did not do it justice, but found a few notes – it scatters files around
and builds in $HOME if you do not set $FAB_WORKSPACE; is very agressive at least by default in find files, so I would start out with a little project like the default one “fpm new” creates; and unless you start configuring it make sure you have a very clean set of files to build. On my machine if I was building any .F90 or .F files that went through cpp/fpp I think I had to set $CPP or make a mini config file to get cpp to not write the comment block that it could not handle.
Minimal info, but otherwise you have to read the docs to get started :slight_smile:

The trivial script left over from looking at it with a few notes… (hopefully somone gave it a bigger workover but if not, this might save you a little grief starting out):

#!/bin/bash
cd /tmp
fpm new Fab
cd Fab
(
exec 2>&1
env FAB_WORKSPACE=/tmp/fab-workspace fab
)|tee fab.out
echo look in /tmp/fab-workspace
exit
################################################################################
# install
pip install sci-fab
################################################################################
# docs
cygstart https://metomi.github.io/fab/index.html
################################################################################
cygstart is like cygwin command and looks for commands like 
  cygstart $name    # CygWin
  start $name       # MSWindows
  xdg-open $name    # Linux
  gnome-open $name  # GNOME
  open $name        # darwin
  konquerer
  nautilus
################################################################################
Impressions:

Do not put fab-workspace in the project directory, make sure FAB_WORKSPACE
is set.

No obvious built-in help, no obvious man-pages

Very aggressive finding files, so unused directories and build/ directory
need removed or need to learn how to skip directories.

Seemed confused by multiple main programs with procedures with the same
name in them

lots of files left in /tmp from errors, maybe always there

lots of fparser errors with little explanation

cannot process comments from cpp properly with my version, does not
supress them

errors are long confusing python traces

not totally intuitive where results are and what to look for; builds
but does not appear to easily allow running or calling test applications

1 Like

Thanks for the notes! Interesting to see the similarities and differences with fpm. It seems the two projects both have advantages and disadvantages - the ability to specify custom build steps would make FAB very powerful and flexible I expect. FAB also appears to track dependencies between non-module subroutines, which fpm cannot do. I recall some issues using fparser in the past, so I’m not surprised to hear about errors there. Perhaps the two projects can learn from each other.

It describes itself as a build system not a package manager, so comparing it to all the fpm features (external dependencies, running, testing, and installing, …) is not fair; but fpm is often used as a build package. Comparing them at that level it does have more flexibility more like CMake than fpm currently has; and there are lessons and approaches there that are interesting.
There are also a lot of infrastructure dependencies, and that made it unappealing to me, but I think it is great to see additional Fortran-centric or Fortran-inclusive projects like this.

I need to move builds to various platforms, some of which are not on the WWW so a favorite feature of fpm for me is that I can get it running with a single file (source or binary); so that was
a big negative for me but will not be for many others. It was very easy to install on a little unsecured laptop with just a single command.

I wish them the best, it just did not fit my needs. For a nice clean set of directories containing just code it auto-built nicely. Some ability to create something automatically as an example for using external dependencies and custom build options (one of its strengths) would have been nice. It goes from very easy (just enter “fab”) to needing a lot more information pretty quickly when setting up for MPI, X11, … dependencies; but so does pretty much everything else.

1 Like