diff --git a/local/pkgs/default.nix b/local/pkgs/default.nix index 3ef68dea..15637d50 100644 --- a/local/pkgs/default.nix +++ b/local/pkgs/default.nix @@ -10,10 +10,11 @@ misskey = callPackage ./misskey {}; mk-meili-mgn = callPackage ./mk-meili-mgn {}; phonon-unfolding = callPackage ./phonon-unfolding {}; - vasp = callPackage ./vasp - { - stdenv = pkgs.lmix-pkgs.intel21Stdenv; - intel-mpi = pkgs.lmix-pkgs.intel-oneapi-mpi_2021_9_0; - ifort = pkgs.lmix-pkgs.intel-oneapi-ifort_2021_9_0; - }; + # vasp = callPackage ./vasp + # { + # stdenv = pkgs.lmix-pkgs.intel21Stdenv; + # intel-mpi = pkgs.lmix-pkgs.intel-oneapi-mpi_2021_9_0; + # ifort = pkgs.lmix-pkgs.intel-oneapi-ifort_2021_9_0; + # }; + vasp = callPackage ./vasp { openmp = llvmPackages.openmp; }; } diff --git a/local/pkgs/vasp/default.nix b/local/pkgs/vasp/default.nix index c6fc2ca8..435f3752 100644 --- a/local/pkgs/vasp/default.nix +++ b/local/pkgs/vasp/default.nix @@ -1,8 +1,46 @@ +# { +# stdenv, requireFile, config, rsync, intel-mpi, ifort, +# mkl +# }: +# stdenv.mkDerivation rec +# { +# pname = "vasp"; +# version = "6.4.0"; +# # nix-store --query --hash $(nix store add-path ./vasp-6.4.0) +# src = requireFile +# { +# name = "${pname}-${version}"; +# sha256 = "189i1l5q33ynmps93p2mwqf5fx7p4l50sls1krqlv8ls14s3m71f"; +# hashMode = "recursive"; +# message = "Source file not found."; +# }; +# VASP_TARGET_CPU = if config ? oneapiArch then "-x${config.oneapiArch}" else ""; +# MKLROOT = mkl; +# makeFlags = "DEPS=1"; +# enableParallelBuilding = true; +# buildInputs = [ mkl intel-mpi ifort ]; +# nativeBuildInputs = [ rsync ]; +# configurePhase = +# '' +# cp arch/makefile.include.intel makefile.include +# echo "CPP_OPTIONS += -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj" >> makefile.include +# echo "OBJECTS_LIB += getshmem.o" >> makefile.include +# mkdir -p bin +# ''; +# installPhase = +# '' +# mkdir -p $out/bin +# for i in std gam ncl; do +# cp bin/vasp_$i $out/bin/vasp-cpu-${version}-$i +# done +# ''; +# doStrip = false; +# doFixup = false; +# } { - stdenv, requireFile, config, rsync, intel-mpi, ifort, - mkl + stdenvNoCC, requireFile, rsync, blas, scalapack, openmpi, openmp, gfortran, gcc, fftwMpi }: -stdenv.mkDerivation rec +stdenvNoCC.mkDerivation rec { pname = "vasp"; version = "6.4.0"; @@ -14,15 +52,17 @@ stdenv.mkDerivation rec hashMode = "recursive"; message = "Source file not found."; }; - VASP_TARGET_CPU = if config ? oneapiArch then "-x${config.oneapiArch}" else ""; - MKLROOT = mkl; + # VASP_TARGET_CPU = if config ? oneapiArch then "-x${config.oneapiArch}" else ""; + # MKLROOT = mkl; makeFlags = "DEPS=1"; enableParallelBuilding = true; - buildInputs = [ mkl intel-mpi ifort ]; + buildInputs = [ blas scalapack openmpi openmp gfortran gfortran.cc gcc fftwMpi.dev fftwMpi ]; nativeBuildInputs = [ rsync ]; + FFTW_ROOT = fftwMpi.dev; configurePhase = '' - cp arch/makefile.include.intel makefile.include + cp ${./makefile.include/${version}-gnu} makefile.include + chmod +w makefile.include echo "CPP_OPTIONS += -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj" >> makefile.include echo "OBJECTS_LIB += getshmem.o" >> makefile.include mkdir -p bin @@ -31,7 +71,7 @@ stdenv.mkDerivation rec '' mkdir -p $out/bin for i in std gam ncl; do - cp bin/vasp_$i $out/bin/vasp-cpu-${version}-$i + cp bin/vasp_$i $out/bin/vasp-gnu-${version}-$i done ''; } diff --git a/local/pkgs/vasp/makefile.include/6.4.0-gnu b/local/pkgs/vasp/makefile.include/6.4.0-gnu new file mode 100644 index 00000000..776a43a8 --- /dev/null +++ b/local/pkgs/vasp/makefile.include/6.4.0-gnu @@ -0,0 +1,94 @@ +# Default precompiler options +CPP_OPTIONS = -DHOST=\"LinuxGNU\" \ + -DMPI -DMPI_BLOCK=8000 -Duse_collective \ + -DscaLAPACK \ + -DCACHE_SIZE=4000 \ + -Davoidalloc \ + -Dvasp6 \ + -Duse_bse_te \ + -Dtbdyn \ + -Dfock_dblbuf \ + -D_OPENMP + +CPP = gcc -E -C -w $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS) + +FC = mpif90 -fopenmp +FCL = mpif90 -fopenmp + +FREE = -ffree-form -ffree-line-length-none + +FFLAGS = -w -ffpe-summary=none + +OFLAG = -O3 +OFLAG_IN = $(OFLAG) +DEBUG = -O0 + +OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o +OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o +OBJECTS_O2 += fft3dlib.o + +# For what used to be vasp.5.lib +CPP_LIB = $(CPP) +FC_LIB = $(FC) +CC_LIB = gcc +CFLAGS_LIB = -O +FFLAGS_LIB = -O1 +FREE_LIB = $(FREE) + +OBJECTS_LIB = linpack_double.o + +# For the parser library +CXX_PARS = g++ +LLIBS = -lstdc++ + +## +## Customize as of this point! Of course you may change the preceding +## part of this file as well if you like, but it should rarely be +## necessary ... +## + +# When compiling on the target machine itself, change this to the +# relevant target when cross-compiling for another architecture +# VASP_TARGET_CPU ?= -march=native +# FFLAGS += $(VASP_TARGET_CPU) + +# For gcc-10 and higher (comment out for older versions) +FFLAGS += -fallow-argument-mismatch + +# BLAS and LAPACK (mandatory) +# OPENBLAS_ROOT ?= /path/to/your/openblas/installation +# BLASPACK = -L$(OPENBLAS_ROOT)/lib -lopenblas +BLASPACK = -lblas + +# scaLAPACK (mandatory) +# SCALAPACK_ROOT ?= /path/to/your/scalapack/installation +# SCALAPACK = -L$(SCALAPACK_ROOT)/lib -lscalapack +SCALAPACK = -lscalapack + +LLIBS += $(SCALAPACK) $(BLASPACK) + +# FFTW (mandatory) +# FFTW_ROOT ?= /path/to/your/fftw/installation +# LLIBS += -L$(FFTW_ROOT)/lib -lfftw3 -lfftw3_omp +LLIBS += -lfftw3 -lfftw3_omp +INCS += -I$(FFTW_ROOT)/include + +# HDF5-support (optional but strongly recommended) +#CPP_OPTIONS+= -DVASP_HDF5 +#HDF5_ROOT ?= /path/to/your/hdf5/installation +#LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran +#INCS += -I$(HDF5_ROOT)/include + +# For the VASP-2-Wannier90 interface (optional) +#CPP_OPTIONS += -DVASP2WANNIER90 +#WANNIER90_ROOT ?= /path/to/your/wannier90/installation +#LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier + +# For the fftlib library (recommended) +CPP_OPTIONS+= -Dsysv +FCL += fftlib.o +CXX_FFTLIB = g++ -fopenmp -std=c++11 -DFFTLIB_THREADSAFE +# INCS_FFTLIB = -I./include -I$(FFTW_ROOT)/include +INCS_FFTLIB = -I./include +LIBS += fftlib +LLIBS += -ldl