2020-07-20 12:58:54 +02:00
|
|
|
{
|
|
|
|
stdenv
|
2020-10-30 15:21:23 +01:00
|
|
|
, mpi ? null
|
|
|
|
, tampi ? null
|
|
|
|
, mcxx ? null
|
|
|
|
, cc
|
2021-01-29 15:33:12 +01:00
|
|
|
, gitBranch ? "garlic/tampi+send+oss+task"
|
|
|
|
, fwiInput
|
2020-07-20 12:58:54 +02:00
|
|
|
}:
|
|
|
|
|
2020-10-30 15:21:23 +01:00
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
assert !(tampi != null && mcxx == null);
|
|
|
|
|
2020-07-20 12:58:54 +02:00
|
|
|
stdenv.mkDerivation rec {
|
2021-01-29 15:33:12 +01:00
|
|
|
inherit gitBranch;
|
2020-12-04 11:17:15 +01:00
|
|
|
name = "fwi";
|
2020-07-20 12:58:54 +02:00
|
|
|
|
|
|
|
src = builtins.fetchGit {
|
2021-03-04 17:51:47 +01:00
|
|
|
url = "ssh://git@bscpm03.bsc.es/garlic/apps/fwi.git";
|
2020-10-30 15:21:23 +01:00
|
|
|
ref = "${gitBranch}";
|
2020-07-20 12:58:54 +02:00
|
|
|
};
|
|
|
|
|
2021-01-29 15:33:12 +01:00
|
|
|
enableParallelBuilding = false;
|
2020-07-20 12:58:54 +02:00
|
|
|
|
|
|
|
buildInputs = [
|
2020-10-30 15:21:23 +01:00
|
|
|
cc
|
|
|
|
]
|
2021-01-29 15:33:12 +01:00
|
|
|
++ optional (mpi != null) mpi
|
2020-10-30 15:21:23 +01:00
|
|
|
++ optional (tampi != null) tampi
|
2021-01-29 15:33:12 +01:00
|
|
|
++ optional (mcxx != null) mcxx;
|
|
|
|
|
|
|
|
# FIXME: Correct this on the Makefile so we can just type "make fwi"
|
|
|
|
# FIXME: Allow multiple MPI implementations
|
|
|
|
postPatch = ''
|
|
|
|
sed -i 's/= OPENMPI$/= INTEL/g' Makefile
|
|
|
|
'';
|
2020-07-20 12:58:54 +02:00
|
|
|
|
2020-07-20 15:32:00 +02:00
|
|
|
# FIXME: This is an ugly hack.
|
|
|
|
# When using _GNU_SOURCE or any other definition used in features.h, we need
|
|
|
|
# to define them before mcc includes nanos6.h from the command line. So the
|
|
|
|
# only chance is by setting it at the command line with -D. Using the DEFINES
|
|
|
|
# below, reaches the command line of the preprocessing stage with gcc.
|
2020-12-04 11:17:15 +01:00
|
|
|
preConfigure = ''
|
2020-07-20 15:32:00 +02:00
|
|
|
export DEFINES=-D_GNU_SOURCE
|
2021-01-29 15:33:12 +01:00
|
|
|
|
|
|
|
make depend
|
|
|
|
|
|
|
|
cp ${fwiInput}/generated_model_params.h src/
|
2020-12-04 11:17:15 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
# We compile the ModelGenerator using gcc *only*, as otherwise it will
|
|
|
|
# be compiled with nanos6, which requires access to /sys to determine
|
|
|
|
# hardware capabilities. So it will fail in the nix-build environment,
|
|
|
|
# as there is no /sys mounted.
|
2020-07-20 15:32:00 +02:00
|
|
|
makeFlags = [
|
2021-01-29 15:33:12 +01:00
|
|
|
#"COMPILER=GNU"
|
|
|
|
#"CC=${cc.cc.CC}"
|
|
|
|
"fwi"
|
2020-07-20 15:32:00 +02:00
|
|
|
];
|
|
|
|
|
2020-07-20 12:58:54 +02:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
2020-12-04 11:17:15 +01:00
|
|
|
cp fwi $out/bin
|
2020-07-20 12:58:54 +02:00
|
|
|
'';
|
2020-10-30 15:21:23 +01:00
|
|
|
|
|
|
|
programPath = "/bin/fwi";
|
2020-07-20 12:58:54 +02:00
|
|
|
}
|