gamess-20110811.1.ebuild 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. # Copyright 1999-2013 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=4
  4. inherit eutils fortran-2 flag-o-matic pax-utils toolchain-funcs
  5. DESCRIPTION="A powerful quantum chemistry package"
  6. LICENSE="gamess"
  7. HOMEPAGE="http://www.msg.chem.iastate.edu/GAMESS/GAMESS.html"
  8. SRC_URI="
  9. ${P}.tar.gz
  10. qmmm-tinker? ( tinker.tar.Z )"
  11. SLOT="0"
  12. # NOTE: PLEASE do not stabilize gamess. It does not make sense
  13. # since the tarball has fetch restrictions and upstream only
  14. # provides the latest version. In other words: As soon as a
  15. # new version comes out the stable version will be useless since
  16. # users can not get at the tarball any more.
  17. KEYWORDS="~amd64 ~ppc ~x86"
  18. IUSE="mpi neo pax_kernel qmmm-tinker"
  19. CDEPEND="
  20. app-shells/tcsh
  21. mpi? ( virtual/mpi )
  22. virtual/blas"
  23. DEPEND="${CDEPEND}
  24. virtual/pkgconfig"
  25. RDEPEND="${CDEPEND}
  26. net-misc/openssh"
  27. S="${WORKDIR}/${PN}"
  28. RESTRICT="fetch"
  29. GAMESS_DOWNLOAD="http://www.msg.ameslab.gov/GAMESS/License_Agreement.html"
  30. GAMESS_VERSION="1 AUG 2011 (R1)"
  31. pkg_nofetch() {
  32. echo
  33. elog "Please download ${PN}-current.tar.gz from"
  34. elog "${GAMESS_DOWNLOAD}."
  35. elog "Be sure to select the version ${GAMESS_VERSION} tarball!!"
  36. elog "Then move the tarball to"
  37. elog "${DISTDIR}/${P}.tar.gz"
  38. if use qmmm-tinker ; then
  39. elog "Also download http://www.msg.ameslab.gov/GAMESS/tinker.tar.Z"
  40. elog "and place tinker.tar.Z to ${DISTDIR}"
  41. fi
  42. echo
  43. }
  44. get_fcomp() {
  45. case $(tc-getFC) in
  46. *gfortran* )
  47. FCOMP="gfortran" ;;
  48. ifort )
  49. FCOMP="ifc" ;;
  50. * )
  51. FCOMP=$(tc-getFC) ;;
  52. esac
  53. }
  54. pkg_setup() {
  55. fortran-2_pkg_setup
  56. get_fcomp
  57. # currently amd64 is only supported with gfortran
  58. if [[ "${ARCH}" == "amd64" ]] && [[ ${FCOMP} != *gfortran* ]];
  59. then die "You will need gfortran to compile gamess on amd64"
  60. fi
  61. # note about qmmm-tinker
  62. if use qmmm-tinker; then
  63. einfo "By default MM subsistem is restricted to 1000 atoms"
  64. einfo "if you want larger MM subsystems then you should set"
  65. einfo "QMMM_GAMESS_MAXMM variable to needed value in your make.conf"
  66. einfo "By default maximum number of atom classes types and size of"
  67. einfo "hessian are restricted to 250, 500 and 1000000 respectively"
  68. einfo "If you want larger sizes set:"
  69. einfo "QMMM_GAMESS_MAXCLASS"
  70. einfo "QMMM_GAMESS_MAXCTYP"
  71. einfo "QMMM_GAMESS_MAXHESS"
  72. einfo "in your make.conf"
  73. fi
  74. #note about mpi
  75. if use mpi; then
  76. ewarn ""
  77. ewarn "You should adjust rungms script for your mpi implentation"
  78. ewarn "because deafult one will not work"
  79. ewarn ""
  80. fi
  81. }
  82. src_unpack() {
  83. unpack ${A}
  84. if use qmmm-tinker; then
  85. mv tinker gamess/ || die "failed to move tinker directory"
  86. fi
  87. }
  88. src_prepare() {
  89. tc-export PKG_CONFIG
  90. # apply LINUX-arch patches to gamess makesfiles
  91. epatch "${FILESDIR}/${P}.gentoo.patch"
  92. epatch "${FILESDIR}/${PN}-checktst.patch"
  93. # select arch
  94. # NOTE: please leave lked alone; it should be good as is!!
  95. cd "${S}"
  96. local active_arch;
  97. if [[ "${ARCH}" == "amd64" ]]; then
  98. active_arch="linux64";
  99. else
  100. active_arch="linux32";
  101. fi
  102. # for hardened-gcc let't turn off ssp, since it breakes
  103. # a few routines
  104. if use pax_kernel && [[ ${FCOMP} == g77 ]]; then
  105. FFLAGS="${FFLAGS} -fno-stack-protector-all"
  106. fi
  107. # Enable mpi stuff
  108. if use mpi; then
  109. sed -e "s:set COMM = sockets:set COMM = mpi:g" \
  110. -i ddi/compddi || die "Enabling mpi build failed"
  111. sed -e "s:MPI_INCLUDE_PATH = ' ':MPI_INCLUDE_PATH = '-I/usr/include ':g" \
  112. -i ddi/compddi || die "Enabling mpi build failed"
  113. sed -e "s:MSG_LIBRARIES='../ddi/libddi.a -lpthread':MSG_LIBRARIES='../ddi/libddi.a -lmpi -lpthread':g" \
  114. -i lked || die "Enabling mpi build failed"
  115. fi
  116. # enable NEO
  117. if use neo; then
  118. sed -e "s:NEO=false:NEO=true:" -i compall lked || \
  119. die "Failed to enable NEO code"
  120. else
  121. sed -e "s:NEO=true:NEO=false:" -i compall lked || \
  122. die "Failed to disable NEO code"
  123. fi
  124. # enable GAMESS-qmmm
  125. if use qmmm-tinker; then
  126. epatch "${FILESDIR}/${PN}-qmmm-tinker-fix-idate.patch"
  127. sed -e "s:TINKER=false:TINKER=true:" -i compall lked || \
  128. die "Failed to enable TINKER code"
  129. if [ "x$QMMM_GAMESS_MAXMM" == "x" ]; then
  130. einfo "No QMMM_GAMESS_MAXMM set. Using default value = 1000"
  131. else
  132. einfo "Setting QMMM_GAMESS_MAXMM to $QMMM_GAMESS_MAXMM"
  133. sed -e "s:maxatm=1000:maxatm=$QMMM_GAMESS_MAXMM:g" \
  134. -i tinker/sizes.i \
  135. || die "Setting QMMM_GAMESS_MAXMM failed"
  136. sed -e "s:MAXATM=1000:MAXATM=$QMMM_GAMESS_MAXMM:g" \
  137. -i source/inputb.src \
  138. || die "Setting QMMM_GAMESS_MAXMM failed"
  139. fi
  140. if [ "x$QMMM_GAMESS_MAXCLASS" == "x" ]; then
  141. einfo "No QMMM_GAMESS_MAXMM set. Using default value = 250"
  142. else
  143. sed -e "s:maxclass=250:maxclass=$QMMM_GAMESS_MAXCLASS:g" \
  144. -i tinker/sizes.i \
  145. || die "Setting QMMM_GAMESS_MAXCLASS failed"
  146. fi
  147. if [ "x$QMMM_GAMESS_MAXCTYP" == "x" ]; then
  148. einfo "No QMMM_GAMESS_MAXCTYP set. Using default value = 500"
  149. else
  150. sed -e "s:maxtyp=500:maxtyp=$QMMM_GAMESS_MAXCTYP:g" \
  151. -i tinker/sizes.i \
  152. || die "Setting QMMM_GAMESS_MAXCTYP failed"
  153. fi
  154. if [ "x$QMMM_GAMESS_MAXHESS" == "x" ]; then
  155. einfo "No QMMM_GAMESS_MAXHESS set. Usingdefault value = 1000000"
  156. else
  157. sed -e "s:maxhess=1000000:maxhess=$QMMM_GAMESS_MAXHESS:g" \
  158. -i tinker/sizes.i \
  159. || die "Setting QMMM_GAMESS_MAXHESS failed"
  160. fi
  161. fi
  162. # greate proper activate sourcefile
  163. cp "./tools/actvte.code" "./tools/actvte.f" || \
  164. die "Failed to create actvte.f"
  165. sed -e "s/^\*UNX/ /" -i "./tools/actvte.f" || \
  166. die "Failed to perform UNX substitutions in actvte.f"
  167. # fix GAMESS' compall script to use proper CC
  168. sed -e "s|\$CCOMP -c \$extraflags source/zunix.c|$(tc-getCC) -c \$extraflags source/zunix.c|" \
  169. -i compall || die "Failed setting up compall script"
  170. # insert proper FFLAGS into GAMESS' comp makefile
  171. # in case we're using ifc let's strip all the gcc
  172. # specific stuff
  173. if [[ ${FCOMP} == "ifort" ]]; then
  174. sed -e "s/gentoo-OPT = '-O2'/OPT = '${FFLAGS} -quiet'/" \
  175. -i comp || die "Failed setting up comp script"
  176. elif ! use x86; then
  177. sed -e "s/-malign-double //" \
  178. -e "s/gentoo-OPT = '-O2'/OPT = '${FFLAGS}'/" \
  179. -i comp || die "Failed setting up comp script"
  180. else
  181. sed -e "s/gentoo-OPT = '-O2'/OPT = '${FFLAGS}'/" \
  182. -i comp || die "Failed setting up comp script"
  183. fi
  184. # fix up GAMESS' linker script;
  185. sed -e "s/gentoo-LDOPTS=' '/LDOPTS='${LDFLAGS}'/" \
  186. -i lked || die "Failed setting up lked script"
  187. # fix up GAMESS' ddi TCP/IP socket build
  188. sed -e "s/gentoo-CC = 'gcc'/CC = '$(tc-getCC)'/" \
  189. -i ddi/compddi || die "Failed setting up compddi script"
  190. # Creating install.info
  191. cat > install.info <<-EOF
  192. #!/bin/csh
  193. setenv GMS_PATH $WORKDIR/gamess
  194. setenv GMS_TARGET $active_arch
  195. setenv GMS_FORTRAN $FCOMP
  196. setenv GMS_MATHLIB atlas
  197. setenv GMS_MATHLIB_PATH /usr/$(get_libdir)/atlas
  198. setenv GMS_DDI_COMM sockets
  199. EOF
  200. }
  201. src_compile() {
  202. # build actvte
  203. cd "${S}"/tools
  204. ${FCOMP} -o actvte.x actvte.f || \
  205. die "Failed to compile actvte.x"
  206. # for hardened (PAX) users and ifc we need to turn
  207. # MPROTECT off
  208. if [[ ${FCOMP} == "ifort" ]] && use pax_kernel; then
  209. pax-mark -PemRxS actvte.x
  210. fi
  211. # build gamess
  212. cd "${S}"
  213. ./compall || die "compall failed"
  214. # build the ddi TCP/IP socket stuff
  215. cd ${S}/"ddi"
  216. ./compddi || die "compddi failed"
  217. # finally, link it all together
  218. cd "${S}"
  219. ./lked || die "lked failed"
  220. # for hardened (PAX) users and ifc we need to turn
  221. # MPROTECT off
  222. if [[ ${FCOMP} == "ifort" ]] && use pax_kernel; then
  223. pax-mark -PemRxS ${PN}.00.x
  224. fi
  225. }
  226. src_install() {
  227. # the executables
  228. dobin ${PN}.00.x rungms \
  229. || die "Failed installing binaries"
  230. if use !mpi; then
  231. dobin ddi/ddikick.x \
  232. || die "Failed installing binaries"
  233. fi
  234. # the docs
  235. dodoc *.DOC qmnuc/*.DOC || die "Failed installing docs"
  236. # install ericftm
  237. insinto /usr/share/${PN}
  238. doins auxdata/ericfmt.dat || die "Failed installing ericfmt.dat"
  239. # install mcpdata
  240. insinto /usr/share/${PN}/MCP
  241. doins auxdata/MCP/* || die "Failed installing MCP"
  242. # install BASES
  243. insinto /usr/share/${PN}/BASES
  244. doins auxdata/BASES/* || die "Failed installing BASES"
  245. # install QUANPOL
  246. insinto /usr/share/${PN}/QUANPOL
  247. doins auxdata/QUANPOL/* || die "Failed installing QUANPOL"
  248. # install tinker params in case of qmmm
  249. if use qmmm-tinker ; then
  250. dodoc tinker/simomm.doc || die "Failed installing docs"
  251. insinto /usr/share/${PN}
  252. doins -r tinker/params51 || die "Failed to install Tinker params"
  253. fi
  254. # install the tests the user should run, and
  255. # fix up the runscript; also grab a copy of rungms
  256. # so the user is ready to run the tests
  257. insinto /usr/share/${PN}/tests
  258. insopts -m0644
  259. doins tests/* || die "Failed installing tests"
  260. insopts -m0744
  261. doins runall || die "Failed installing tests"
  262. doins tools/checktst/checktst tools/checktst/chkabs || \
  263. die "Failed to install main test checker"
  264. doins tools/checktst/exam* || \
  265. die "Failed to install individual test files"
  266. insinto /usr/share/${PN}/neotests
  267. insopts -m0644
  268. doins -r qmnuc/neotests/* || die "Failed to install NEO tests"
  269. }
  270. pkg_postinst() {
  271. echo
  272. einfo "Before you use GAMESS for any serious work you HAVE"
  273. einfo "to run the supplied test files located in"
  274. einfo "/usr/share/gamess/tests and check them thoroughly."
  275. einfo "Otherwise all scientific publications resulting from"
  276. einfo "your GAMESS runs should be immediately rejected :)"
  277. einfo "To do so copy the content of /usr/share/gamess/tests"
  278. einfo "to some temporary location and execute './runall'. "
  279. einfo "Then run the checktst script in the same directory to"
  280. einfo "validate the tests."
  281. einfo "Please consult TEST.DOC and the other docs!"
  282. if [[ ${FCOMP} == "ifort" ]]; then
  283. echo
  284. ewarn "IMPORTANT NOTE: We STRONGLY recommend to stay away"
  285. ewarn "from ifc-9.0 for now and use the ifc-8.1 series of"
  286. ewarn "compilers UNLESS you can run through ALL of the "
  287. ewarn "test cases (see above) successfully."
  288. fi
  289. echo
  290. einfo "If you want to run on more than a single CPU"
  291. einfo "you will have to acquaint yourself with the way GAMESS"
  292. einfo "does multiprocessor runs and adjust rungms according to"
  293. einfo "your target network architecture."
  294. echo
  295. }