#!/usr/bin/env modbuild 

pbuild::set_download_url "http://ftp.gromacs.org/pub/$P/$P-${V_PKG}.tar.gz"

pbuild::add_to_group 'MPI'

if (( V_MAJOR <= 2018 )); then
  pbuild::install_docfiles ACKNOWLEDGMENTS COPYING MANIFEST README.txt
else
  pbuild::install_docfiles AUTHORS COPYING README
fi

pbuild::pre_configure() {
  pbuild::add_configure_args "-DCMAKE_BUILD_TYPE=RELEASE"
  pbuild::add_configure_args "-DGMX_MPI=on"

  if pbuild::use_flag dp ; then
    pbuild::add_configure_args "-DGFMX_DOUBLE=on"
  else # pbuild::use_flag sp
    pbuild::add_configure_args "-DGFMX_DOUBLE=off"
  fi

  if pbuild::use_flag "gpu"; then
 	pbuild::add_configure_args "-DGMX_GPU=on"
  else
 	pbuild::add_configure_args "-DGMX_GPU=off"
  fi

  # For GMX_SIMD the lowest instruction number you think might work on all nodes
  #   |- Available numbers: http://manual.gromacs.org/documentation/2020/install-guide/index.html#simd-support
  #   |- AVX_512 is only for newest Intel processors (Xeon Scalable Gold, Core i9, etc.)
  #      AVX_512 will not work on old GPUs, this is why we chood AVX2_256 which are processors from 2013
  pbuild::add_configure_args "-DGMX_SIMD=AVX2_256"
  pbuild::add_configure_args "-DGMX_BUILD_OWN_FFTW=on"
}
