lol
1{
2 stdenv,
3 lib,
4 fetchFromBitbucket,
5 fetchzip,
6 gfortran,
7 mpi,
8 petsc,
9 blas,
10 lapack,
11 parmetis,
12 hdf5-fortran-mpi,
13 mpiCheckPhaseHook,
14 python312Packages,
15}:
16
17let
18 /*
19 Upstream petsc has lots of fortran api change since 3.22.0
20 We will keep using older version until pflotran supports the latest petsc.
21 Pflotran also requires Parmetis support in Petsc to have actual parmetis support.
22 */
23 petsc' =
24 (petsc.overrideAttrs rec {
25 version = "3.21.4";
26 src = fetchzip {
27 url = "https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-${version}.tar.gz";
28 hash = "sha256-l7v+ASBL9FLbBmBGTRWDwBihjwLe3uLz+GwXtn8u7e0=";
29 };
30 }).override
31 {
32 withMetis = true;
33 withParmetis = true;
34 python3Packages = python312Packages;
35 };
36in
37stdenv.mkDerivation (finalAttrs: {
38 pname = "PFLOTRAN";
39 version = "6.0.1";
40
41 src = fetchFromBitbucket {
42 owner = "pflotran";
43 repo = "pflotran";
44 rev = "v${finalAttrs.version}";
45 hash = "sha256-AZXzay6GWbnxONB8Slg8gV0KN1CxGCXbJ45ZeWL1034=";
46 };
47
48 patches = [ ./make.patch ];
49
50 nativeBuildInputs = [ gfortran ];
51
52 buildInputs = [
53 petsc'
54 blas
55 lapack
56 hdf5-fortran-mpi
57 parmetis
58 ];
59
60 propagatedBuildInputs = [ mpi ];
61 propagatedUserEnvPkgs = [ mpi ];
62 passthru = { inherit mpi; };
63
64 enableParallelBuilding = true;
65
66 /*
67 Pflotran does not use a "real" autotools configure script, but a simple bash
68 script, that is merely named configure. Consequently, many common mechanism
69 don't work. Thus, we need to help make to figure out some include and library
70 paths.
71 */
72 preConfigure = ''
73 substituteInPlace src/pflotran/makefile \
74 --subst-var-by "HDF5_FORTRAN_LIBS" "${lib.getLib hdf5-fortran-mpi}/lib" \
75 --subst-var-by "HDF5_FORTRAN_INCLUDE" "${lib.getDev hdf5-fortran-mpi}/include"
76 '';
77
78 meta = with lib; {
79 description = "Parallel, multi-physics simulation code for subsurface flow and transport";
80 homepage = "https://pflotran.org/";
81 license = licenses.lgpl3Only;
82 maintainers = [ maintainers.sheepforce ];
83 };
84})