about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/science/chemistry/ergoscf
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/science/chemistry/ergoscf')
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/ergoscf/default.nix47
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/ergoscf/math-constants.patch19
2 files changed, 66 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/science/chemistry/ergoscf/default.nix b/nixpkgs/pkgs/applications/science/chemistry/ergoscf/default.nix
new file mode 100644
index 000000000000..3ee33cf19b74
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/ergoscf/default.nix
@@ -0,0 +1,47 @@
+{ lib, stdenv, fetchurl, blas, lapack } :
+
+stdenv.mkDerivation rec {
+  pname = "ergoscf";
+  version = "3.8.2";
+
+  src = fetchurl {
+    url = "http://www.ergoscf.org/source/tarfiles/ergo-${version}.tar.gz";
+    sha256 = "sha256-U0NVREEZ8HI0Q0ZcbwvZsYA76PWMh7bqgDG1uaUc01c=";
+  };
+
+  buildInputs = [ blas lapack ];
+
+  patches = [ ./math-constants.patch ];
+
+  postPatch = ''
+    patchShebangs ./test
+  '';
+
+  configureFlags = [
+    "--enable-linalgebra-templates"
+    "--enable-performance"
+  ] ++ lib.optional stdenv.isx86_64 "--enable-sse-intrinsics";
+
+  LDFLAGS = "-lblas -llapack";
+
+  enableParallelBuilding = true;
+
+  OMP_NUM_THREADS = 2; # required for check phase
+
+  # With "fortify3", there are test failures, such as:
+  # Testing cnof CAMB3LYP/6-31G using FMM
+  # *** buffer overflow detected ***: terminated
+  # ./test_fmm_camb3lyp.sh: line 81: 1061289 Aborted                 (core dumped) ./ergo <<EOINPUT > /dev/null
+  hardeningDisable = [ "fortify3" ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Quantum chemistry program for large-scale self-consistent field calculations";
+    mainProgram = "ergo";
+    homepage = "http://www.ergoscf.org";
+    license = licenses.gpl3Plus;
+    maintainers = [ maintainers.markuskowa ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/ergoscf/math-constants.patch b/nixpkgs/pkgs/applications/science/chemistry/ergoscf/math-constants.patch
new file mode 100644
index 000000000000..62209f1a3d84
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/ergoscf/math-constants.patch
@@ -0,0 +1,19 @@
+diff --git a/source/dft/functionals.h b/source/dft/functionals.h
+index fde49ba..f7a61fc 100644
+--- a/source/dft/functionals.h
++++ b/source/dft/functionals.h
+@@ -59,6 +59,14 @@
+ #define EXTERN_C
+ #endif
+ 
++#ifndef M_PI
++#define M_PI 3.14159265358979323846
++#endif
++
++#ifndef M_SQRT2
++#define M_SQRT2        1.41421356237309504880
++#endif
++
+ typedef ergo_real real;
+ 
+ #if defined(FUNC_PRECISION) && FUNC_PRECISION == 1