# Maintainer: Evgeniy "arcanis" Alekseev <esalexeev@gmail.com>

pkgname=quantum-espresso-gpu-svn
pkgver=216
_qever=5.0.2
pkgrel=1
pkgdesc="Quantum ESPRESSO is an integrated suite of computer codes for electronic-structure calculations and materials modeling at the nanoscale. Version with GPU acceleration"
arch=('i686' 'x86_64')
url="http://qe-forge.org/gf/project/q-e-gpu/"
license=('GPLv2')
makedepends=('gcc-fortran' 'blas' 'lapack' 'fftw' 'cuda')
depends=('quantum-espresso')

# because needed authorization
svn import --username=anonymous --password=""
source=(http://qe-forge.org/gf/download/frsrelease/116/403/espresso-${_qever}.tar.gz
        http://qe-forge.org/gf/download/frsrelease/135/453/QE-GPU-r${pkgver}.tar.gz
        http://qe-forge.org/gf/download/frsrelease/142/452/QE-${_qever}_GPU-r${pkgver}.patch)
md5sums=('d8b0d7ac3ddbfe0a656ec1501a2a4688'
         '8fdff7841ed54c6ff1a5f501d2b0ca8f'
         'fc74bc210db6c2d88fd8a5f444aab447')

prepare()
{
  cp -rf "GPU" "espresso-${_qever}/GPU"
}

build()
{
  # build qe
  cd "espresso-${_qever}"
  ./configure
  make all
  
  patch -p1 -i "${srcdir}/QE-${_qever}_GPU-r${pkgver}.patch"
  # build qe-gpu
  cd "GPU"
  ./configure --enable-parallel --enable-openmp --enable-cuda --with-gpu-arch=35 \
              --with-cuda-dir=/opt/cuda --with-phigemm --with-magma
  cd ..
  sed -i "s/python/python2/g" Makefile.gpu
  make -f Makefile.gpu all-gpu
}

package()
{
  msg "done"
}

