%if 0%{?el6}
# Error: No Package found for mpich-devel on el6
ExcludeArch: ppc64
%endif
%if 0%{?el6}
%global mpich mpich
%global mpich_load %_mpich_load
%global mpich_unload %_mpich_unload
%else
%global mpich mpich
%global mpich_load %_mpich_load
%global mpich_unload %_mpich_unload
%endif
%if 0%{?fedora} >= 21 || 0%{?el7} || 0%{?el6}
%global blacs_libs 'mpiblacs'
%else
%global blacs_libs 'mpiblacsCinit', 'mpiblacs'
%endif
Name: gpaw
Version: 0.10.0.11364
Release: 11%{?dist}
Summary: A grid-based real-space PAW method DFT code
License: GPLv3+
URL: https://wiki.fysik.dtu.dk/gpaw/
Source0: https://wiki.fysik.dtu.dk/gpaw-files/%{name}-%{version}.tar.gz
# link satlas if available (fixed in svn 11436)
Patch0: %{name}.config.py.satlas.patch
# arm support (fixed in svn 11437)
Patch1: %{name}.config.py.arm.patch
# hdf5 (fixed in svn 11471)
Patch2: %{name}.hdf5.patch
BuildRequires: time
%ifarch %arm
BuildRequires: atlas-devel
%else
%ifarch aarch64
BuildRequires: atlas-devel
%else
%ifarch ppc64
BuildRequires: atlas-devel
%else
BuildRequires: openblas-devel
%endif
%endif
%endif
BuildRequires: libxc-devel
BuildRequires: hdf5-devel
BuildRequires: python2-devel
# no scipy on el6 ppc64
%if 0%{?el6}
%ifarch ppc64
%{nil}
%else
BuildRequires: scipy
%endif
%endif
BuildRequires: python-ase
Requires: python-ase
BuildRequires: %{name}-setups
Requires: %{name}-common = %{version}-%{release}
%global desc_base \
GPAW is a density-functional theory (DFT) Python code based\
on the projector-augmented wave (PAW) method and the\
atomic simulation environment (ASE). It uses real-space uniform grids and\
multigrid methods or atom-centered basis-functions.
%description
%{desc_base}
%package openmpi
Summary: %{name} - openmpi version
BuildRequires: openssh-clients
BuildRequires: openmpi-devel
BuildRequires: scalapack-openmpi-devel
BuildRequires: blacs-openmpi-devel
BuildRequires: hdf5-openmpi-devel
Requires: openmpi
Requires: scalapack-openmpi
Requires: blacs-openmpi
Requires: hdf5-openmpi
Requires: %{name}-common = %{version}-%{release}
%description openmpi
%{desc_base}
This package contains the openmpi version.
%package %{mpich}
Summary: %{name} - %{mpich} version
BuildRequires: %{mpich}-devel
BuildRequires: scalapack-%{mpich}-devel
BuildRequires: blacs-%{mpich}-devel
BuildRequires: hdf5-%{mpich}-devel
Requires: %{mpich}
Requires: scalapack-%{mpich}
Requires: blacs-%{mpich}
Requires: hdf5-%{mpich}
Requires: %{name}-common = %{version}-%{release}
%description %{mpich}
%{desc_base}
This package contains the %{mpich} version.
%package common
Summary: %{name} - common files
Requires: %{name}-setups
BuildArch: noarch
%description common
%{desc_base}
This package contains the common data files.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p0
%patch1 -p0
%patch2 -p0
# bundled cblas.h (fixed in svn 11425)
rm -rf c/cblas.h
# ppc (fixed in svn 12167)
sed -i "s#machine == 'x86_64'#machine in \['x86_64', 'ppc64'\]#" config.py
# script-without-shebang (fixed in svn 11423)
sed -i '1i#!/usr/bin/env python' tools/gpaw-mapfile-bgp
# non-executable-script (fixed in svn 11424)
for f in `find gpaw -name '*.py*'`;
do
echo sed -i '/env python/d' $f
sed -i '/env python/d' $f
done
# do not link lapack when linking to openblas
sed -i "s/'openblas', 'lapack'/'openblas'/" config.py
# fail with old scalapack: disable - some features are untested!
sed -i "s|'parallel/ut_hsblacs\.py',|#'parallel/ut_hsblacs.py', # disabled by rpmbuild|" gpaw/test/__init__.py
sed -i "s|'pw/fulldiagk\.py',|#'pw/fulldiagk.py', # disabled by rpmbuild|" gpaw/test/__init__.py
sed -i "s|'parallel/lcao_complicated\.py',|#'parallel/lcao_complicated.py', # disabled by rpmbuild|" gpaw/test/__init__.py
# hangs on Rawhide (21) on 4 cores
sed -i "s|'pw/mgo_hybrids\.py',|#'pw/mgo_hybrids.py', # disabled by rpmbuild|" gpaw/test/__init__.py
# http://listserv.fysik.dtu.dk/pipermail/gpaw-developers/2014-April/004501.html
sed -i "s|'excited_state\.py',|#'excited_state.py', # disabled by rpmbuild|" gpaw/test/__init__.py
# Many other tests fail with numpy 1.4.1 on el6:
# FloatingPointError: invalid value encountered in isfinite
# https://github.com/numpy/numpy/issues/2169
%build
# To avoid replicated code define a macro
%global dobuild() \
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build && \
mv build build$MPI_SUFFIX && \
%{__python} setup.py clean
# build serial version (_gpaw.so/_gpaw_hdf5.so will be taken from it)
# disable scalapack
sed -i 's/scalapack =.*/scalapack = False/' customize.py
# enable hdf5
sed -i "s/.*hdf5 =.*/hdf5 = True; libraries += ['hdf5']/" customize.py
echo "extra_compile_args += ['-fPIC']" >> customize.py
MPI_SUFFIX=_serial %dobuild
# build openmpi version
%{_openmpi_load}
# enable scalapack
sed -i 's/scalapack =.*/scalapack = True/' customize.py
sed -i "s/\['scalapack'\]/[%{blacs_libs}, 'scalapack']/" customize.py
# enable parallel hdf5
sed -i "s|.*hdf5 =.*|hdf5 = True; import os; extra_link_args += [os.path.join(os.environ['MPI_LIB'], 'libhdf5.so')]|" customize.py
# force mpicc
sed -i 's/#compiler =.*/compiler = "mpicc"/' customize.py
%dobuild
%{_openmpi_unload}
# build mpich version
%{mpich_load}
# enable scalapack
sed -i 's/scalapack =.*/scalapack = True/' customize.py
sed -i "s/\['scalapack'\]/[%{blacs_libs}, 'scalapack']/" customize.py
# enable parallel hdf5
sed -i "s|.*hdf5 =.*|hdf5 = True; import os; extra_link_args += [os.path.join(os.environ['MPI_LIB'], 'libhdf5.so')]|" customize.py
# force mpicc
sed -i 's/#compiler =.*/compiler = "mpicc"/' customize.py
%dobuild
%{mpich_unload}
%install
# install serial version
mv build_serial build
# disable scalapack
sed -i 's/scalapack =.*/scalapack = False/' customize.py
# disable mpicc
sed -i 's/compiler = "mpicc"/#compiler = "mpicc"/' customize.py
# disable hdf5
sed -i "s|.*hdf5 =.*|#hdf5 = True|" customize.py
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py install --skip-build \
--root $RPM_BUILD_ROOT
# Fedora complains about permissions of _gpaw.so
chmod 0755 $RPM_BUILD_ROOT%{python_sitearch}/_%{name}.so
chmod 0755 $RPM_BUILD_ROOT%{python_sitearch}/_%{name}_hdf5.so
# copy parallel binaries
%global doinstall() \
mkdir -p $RPM_BUILD_ROOT/$MPI_BIN; \
install -p -m 755 build$MPI_SUFFIX/bin.*/%{name}-python $RPM_BUILD_ROOT/$MPI_BIN/%{name}-python$MPI_SUFFIX
# install openmpi version
%{_openmpi_load}
%doinstall
%{_openmpi_unload}
# install mpich version
%{mpich_load}
%doinstall
%{mpich_unload}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}
%check
export NPROC=4 # test on 4 cores (scalapack test need that)
%global GPAW_PLATFORM %(%{__python} -c "from distutils import util, sysconfig; print util.get_platform()+'-'+sysconfig.get_python_version()")
export PYTHONPATH=`pwd`/build/lib.%{GPAW_PLATFORM}; \
export PATH=`pwd`/tools:${PATH}; \
# To avoid replicated code define a macro
%global docheck() \
time $GPAW_EXECUTABLE `which gpaw-test` --range='gemm_complex.py,gemm.py' --debug 2>&1 | tee gpaw-test${NPROC}$MPI_SUFFIX.log
# check serial version
MPI_SUFFIX="" GPAW_EXECUTABLE="python" %docheck
# check openmpi version
%{_openmpi_load}
GPAW_EXECUTABLE="mpiexec -np ${NPROC} build$MPI_SUFFIX/bin.%{GPAW_PLATFORM}/%{name}-python" %docheck
%{_openmpi_unload}
# this will fail for mpich2 on el6 - mpd would need to be started ...
# check mpich version
%{mpich_load}
GPAW_EXECUTABLE="mpiexec.hydra -np ${NPROC} build$MPI_SUFFIX/bin.%{GPAW_PLATFORM}/%{name}-python" %docheck
%{mpich_unload}
%files
%{_bindir}/%{name}*
%{python_sitearch}/_%{name}.so
%{python_sitearch}/_%{name}_hdf5.so
%{python_sitearch}/%{name}
%{python_sitearch}/%{name}-%{version}-py*.egg-info
%files common
%doc LICENSE
%files openmpi
%{_libdir}/openmpi%{?_opt_cc_suffix}/bin/%{name}*_openmpi
%files %{mpich}
%{_libdir}/%{mpich}%{?_opt_cc_suffix}/bin/%{name}*_%{mpich}
%changelog
* Sun May 17 2015 Orion Poplawski <orion@cora.nwra.com> - 0.10.0.11364-11
- Rebuild for hdf5 1.8.15
* Sun May 3 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 0.10.0.11364-10
- Rebuild for changed mpich
* Wed Jan 07 2015 Orion Poplawski <orion@cora.nwra.com> - 0.10.0.11364-9
- Rebuild for hdf5 1.8.14
* Thu Nov 20 2014 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.10.0.11364-8
- new style of linking blacs on EL6
* Thu Oct 23 2014 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.10.0.11364-7
- mpich version 3 in EL6
- use atlas on aarch64
- ppc64 on EL7
* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.10.0.11364-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Sat Jun 07 2014 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.10.0.11364-5
- explicit Requires
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.10.0.11364-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Thu May 22 2014 Marcin Dulak <Marcin.Dulak@gmail.com> 0.10.0.11364-3
- consistent usage of RPM_BUILD_ROOT/RPM_OPT_FLAGS
- hdf5 enabled
- blacs-2.0.2 on fedora >= 21
* Fri May 2 2014 Marcin Dulak <Marcin.Dulak@gmail.com> 0.10.0.11364-2
- %%arm and ppc64 added
- more explicit globs in %%files
- gcc BR removed
- permissions of _gpaw.so fixed
* Tue Apr 8 2014 Marcin Dulak <Marcin.Dulak@gmail.com> 0.10.0.11364-1
- initial version for Fedora