Skip to content

Instantly share code, notes, and snippets.

@boegel
Created December 4, 2013 09:53
Show Gist options
  • Save boegel/7785016 to your computer and use it in GitHub Desktop.
Save boegel/7785016 to your computer and use it in GitHub Desktop.
EasyBuild support for GAMESS-US
name='GAMESS-US'
version='20100325-r2'
homepage='http://www.msg.ameslab.gov/gamess/'
description="""The General Atomic and Molecular Electronic Structure System (GAMESS)
is a general ab initio quantum chemistry package."""
toolkit={'name':'ictce','version':'3.2.1.015.u4'}
toolkitopts={'usempi':True}
sources=['%s-%s.tar.gz'%(name.lower().split('-')[0],version)]
# the two following values can be set optionally
# if not set, default values are: maxcpus=8 and maxnodes=128
#maxcpus=8
#maxnodes=128
import os, shutil, re, glob, fileinput, sys
from distutils.version import LooseVersion
from easybuild.apps.Application import Application
from easybuild.buildsoft.fileTools import runrun, runqanda, convertName, unpack
class GAMESS_US(Application):
def __init__(self,*args,**kwargs):
"""constructor, overwritten from Application to add extra attributes"""
Application.__init__(self, args,kwargs)
self.cfg.update({'maxcpus':[None,"(default: None)"],
'maxnodes':[None,"(default: None)"],
})
def configure(self):
pass
def make(self):
# 1) compiling the source code activator
actvtecode = os.path.join(self.builddir, 'gamess', 'tools', 'actvte.code')
try:
f = open(actvtecode, 'r')
origcontent = f.readlines()
f.close()
except Exception, err:
self.log.error("Can't read from file %s: %s" % (actvtecode, err))
unxreg = re.compile(r"^\*UNX", re.M)
actvtef = os.path.join(self.builddir, 'gamess', 'tools', 'actvte.f')
try:
f = open(actvtef, 'w')
for line in origcontent:
newline = unxreg.sub(' ', line) + '\n'
f.write(newline)
f.close()
except Exception, err:
self.log.error("Can't write to file %s: %s" % (actvtef, err))
try:
cmd = "ifort -o tools/actvte.x tools/actvte.f"
runrun(cmd, logall=True, simple=True)
except Exception, err:
self.log.error("Something went wrong during compilation of %s" % actvtef)
# 2) creating the install.info file
# timestamp
import datetime
timestamp = datetime.datetime.now()
# machinetype
import platform
machine = platform.machine()
system = platform.system()
if machine == 'x86_64' and system == 'Linux':
machinetype = "linux64"
else:
self.log.error("Unanticipated target machine: %s-%s. You should probably extend the easybuild functionality" % (machine, system))
# compiler and mathematical library (and message passing model) setup
fortrancompiler = os.environ['F77']
self.log.info("The %s fortran compiler will be used for compilation" % fortrancompiler)
if fortrancompiler[:3] == 'mpi':
shortcomp = fortrancompiler[3:]
else:
shortcomp = fortrancompiler
fortranverno = os.environ['SOFTVERSION%s' % shortcomp.upper()].split('.')[0]
self.log.info("Version %s of this fortran compiler will be used for compilation" % fortranverno)
if self.tk.name in ['ictce', 'ismkl']:
mathlib = 'mkl'
# old ictce toolkits (3.1.x, 3.2.x)
#mathlibpath = os.path.join(os.environ['SOFTROOTIMKL'],'lib',mkllibversion)
# new ictce toolkits (4.0.x)
mathlibpath = os.path.join(os.environ['SOFTROOTIMKL'], 'mkl', 'lib', 'intel64')
mklverno = os.environ['SOFTVERSIONIMKL'].split('.')[0]
commtype = 'mpi'
if self.tk.name == 'ictce':
mpilib = 'impi'
mpilibpath = os.environ['SOFTROOTIMPI']
elif self.tk.name == 'ismkl':
mpilib = 'mpich2'
mpilibpath = os.environ['SOFTROOTMPICH2']
else:
self.log.error("Don't know which MPI lib is included in %s toolkit" % self.tk.name)
else:
self.log.error("Unanticipated toolkit: %s. You should probably extend the easybuild functionality" % (self.tk.name))
text = """#!/bin/csh
# compilation configuration for GAMESS
# generated with easybuild
# generated at %(timestamp)s
setenv GMS_PATH %(builddir)s
# machine type
setenv GMS_TARGET %(machinetype)s
# FORTRAN compiler setup
setenv GMS_FORTRAN %(fortrancompiler)s
setenv GMS_IFORT_VERNO %(fortranverno)s
# mathematical library setup
setenv GMS_MATHLIB %(mathlib)s
setenv GMS_MATHLIB_PATH %(mathlibpath)s
setenv GMS_MKL_VERNO %(mklverno)s
# parallel message passing model setup
setenv GMS_DDI_COMM %(commtype)s
setenv GMS_MPI_LIB %(mpilib)s
setenv GMS_MPI_PATH %(mpilibpath)s
"""
installinfo = text % {'timestamp':timestamp,
'builddir':os.path.join(self.builddir, 'gamess'),
'machinetype':machinetype,
'fortrancompiler':fortrancompiler, 'fortranverno':fortranverno,
'mathlib':mathlib, 'mathlibpath':mathlibpath, 'mklverno':mklverno,
'commtype':commtype, 'mpilib':mpilib, 'mpilibpath':mpilibpath}
installinfofile = "install.info"
self.log.info("The install.info script used for this build has the following content:\n%s" % installinfo)
try:
f = open(installinfofile, 'w')
f.write(installinfo)
f.close()
except Exception, err:
self.log.error("Can't write to file %s: %s" % (installinfofile, err))
# 3) adapting and executing the compddi file
maxcpusreg = re.compile(r"^set MAXCPUS.*$", re.M)
if self.getCfg("maxcpus"):
maxcpusrepl = "set MAXCPUS = %s\n" % self.getCfg("maxcpus")
maxnodesreg = re.compile(r"^set MAXNODES.*$", re.M)
if self.getCfg("maxnodes"):
maxnodesrepl = "set MAXNODES = %s\n" % self.getCfg("maxnodes")
ccreg = re.compile(r"'gcc'")
if self.tk.name in ['ictce', 'ismkl']:
ccrepl = "'%s'" % os.getenv('MPICC')
ffreg = re.compile(r"ifort")
if fortrancompiler == 'mpiifort':
ffrepl = "mpiifort"
compddi = os.path.join(self.builddir, 'gamess', 'ddi', 'compddi')
try:
f = open(compddi, 'r')
origcontent = f.read()
f.close()
except Exception, err:
self.log.error("Can't read from file %s: %s" % (compddi, err))
try:
os.remove(compddi)
except Exception, err:
self.log.error("It is not possible to remove the old version of %s" % compddi)
try:
f = open(compddi, 'w')
if self.tk.name in ['ictce', 'ismkl']: origcontent = ccreg.sub(ccrepl, origcontent)
if self.getCfg("maxcpus"):
origcontent = maxcpusreg.sub(maxcpusrepl, origcontent)
if self.getCfg("maxnodes"):
origcontent = maxnodesreg.sub(maxnodesrepl, origcontent)
if fortrancompiler == 'mpiifort': origcontent = ffreg.sub(ffrepl, origcontent)
f.write(origcontent)
f.close()
self.log.info("New version of file %s successfully written" % compddi)
except Exception, err:
self.log.error("Can't write to file %s: %s" % (compddi, err))
try:
os.chmod(compddi, 0755)
self.log.info("The script %s has been made executable" % compddi)
except:
self.log.error('Something went wrong while trying to make %s executable.' % compddi)
try:
cmd = "%s" % compddi
runrun(cmd, logall=True, simple=True)
except Exception, err:
self.log.error("Something went wrong during compilation of %s" % compddi)
newlib = os.path.join(self.builddir, 'gamess', 'ddi', 'libddi.a')
if not os.path.isfile(newlib):
self.log.error("the libddi.a library (%s) was never built" % compddi)
else: self.log.info("the libddi.a library (%s) was successfully built." % compddi)
# 4) Compiling all of the GAMESS source code
compall = os.path.join(self.builddir, 'gamess', 'compall')
comp = os.path.join(self.builddir, 'gamess', 'comp')
try:
f = open(comp, 'r')
origcontent = f.read()
f.close()
except Exception, err:
self.log.error("Can't read from file %s: %s" % (comp, err))
try:
os.remove(comp)
except Exception, err:
self.log.error("It is not possible to remove the old version of %s" % comp)
try:
f = open(comp, 'w')
if fortrancompiler == 'mpiifort': origcontent = ffreg.sub(ffrepl, origcontent)
f.write(origcontent)
f.close()
self.log.info("New version of file %s successfully written" % comp)
except Exception, err:
self.log.error("Can't write to file %s: %s" % (comp, err))
try:
os.chmod(comp, 0755)
self.log.info("The script %s has been made executable" % comp)
except:
self.log.error('Something went wrong while trying to make %s executable.' % comp)
try:
cmd = "%s" % compall
runrun(cmd, logall=True, simple=True)
except Exception, err:
self.log.error("Something went wrong during compilation of %s" % compall)
# 5) Link an executable form of GAMESS
lked = os.path.join(self.builddir, 'gamess', 'lked')
try:
f = open(lked, 'r')
origcontent = f.read()
f.close()
except Exception, err:
self.log.error("Can't read from file %s: %s" % (lked, err))
try:
os.remove(lked)
except Exception, err:
self.log.error("It is not possible to remove the old version of %s" % lked)
try:
f = open(lked, 'w')
if fortrancompiler == 'mpiifort': origcontent = ffreg.sub(ffrepl, origcontent)
f.write(origcontent)
f.close()
self.log.info("New version of file %s successfully written" % lked)
except Exception, err:
self.log.error("Can't write to file %s: %s" % (lked, err))
try:
os.chmod(lked, 0755)
self.log.info("The script %s has been made executable" % lked)
except:
self.log.error('Something went wrong while trying to make %s executable.' % lked)
try:
cmd = "%s gamess mpi" % lked
runrun(cmd, logall=True, simple=True)
except Exception, err:
self.log.error("Something went wrong during compilation of %s" % lked)
executable = os.path.join(self.builddir, 'gamess', 'gamess.mpi.x')
if not os.path.isfile(executable):
self.log.error("the executable (%s) was never built" % executable)
def makeInstall(self):
try:
shutil.copytree(os.path.join(self.builddir, 'gamess', 'tests'), os.path.join(self.installdir, 'tests'))
shutil.copytree(os.path.join(self.builddir, 'gamess', 'graphics'), os.path.join(self.installdir, 'graphics'))
mcpdatadir = os.path.join(self.builddir, 'gamess', 'mcpdata')
if os.path.isdir(mcpdatadir):
shutil.copytree(mcpdatadir, os.path.join(self.installdir, 'mcpdata'))
auxdatadir = os.path.join(self.builddir, 'gamess', 'auxdata')
if os.path.isdir(auxdatadir):
shutil.copytree(auxdatadir, os.path.join(self.installdir, 'auxdata'))
shutil.copytree(os.path.join(self.builddir, 'gamess', 'qmnuc'), os.path.join(self.installdir, 'qmnuc'))
shutil.copytree(os.path.join(self.builddir, 'gamess', 'misc'), os.path.join(self.installdir, 'misc'))
shutil.copytree(os.path.join(self.builddir, 'gamess', 'tools'), os.path.join(self.installdir, 'tools'))
except Exception, err:
self.log.error("Something went wrong during dir copying to installdir: %s" % err)
try:
dst = os.path.join(self.installdir, 'bin')
os.mkdir(dst)
shutil.copy2(os.path.join(self.builddir, 'gamess', 'gamess.mpi.x'), dst)
except:
self.log.error("Copying gamess.mpi.x executable to installation dir %s failed." % dst)
def makeModuleReq(self):
txt = """
setenv GAMESSUSROOT $root\n
prepend-path PATH $root/bin\n
"""
return txt
@boegel
Copy link
Author

boegel commented Aug 27, 2014

easyconfig + TMP patch:

name = 'GAMESS-US'
version = '20130501-R1'

homepage = 'http://www.msg.ameslab.gov/gamess/'
description = """The General Atomic and Molecular Electronic Structure System (GAMESS)
 is a general ab initio quantum chemistry package."""

toolchain = {'name': 'goolf', 'version': '1.5.14-no-OFED'}
toolchainopts = {'usempi': True, 'optarch': False}

# manually download via http://www.msg.chem.iastate.edu/gamess/download.html (requires registration)
sources = ['gamess-%(version)s.tar.gz']
patches = ['gamess_TMP.patch']

maxcpus = 4
maxnodes = 1

moduleclass = 'chem'
--- gamess/compall.orig 2014-06-11 18:37:54.000000000 +0200
+++ gamess/compall  2014-06-11 18:40:44.000000000 +0200
@@ -97,7 +97,7 @@
 #      Debian uses the -m flag, since its -p replies "unknown"
 #      Gentoo uses the -m flag, since its -p gives an unusable multiword reply
 if ($TARGET == linux64) then
-   set chip=(`uname -p`)
+   set chip=(`uname -m`)
    if (${#chip} > 1) set chip=unknown
    if ($chip == unknown) set chip=`uname -m`
    if ($chip == x86_64) set extraflags='-DLINUX64 -m64'
--- gamess/comp.orig    2014-06-11 21:26:28.000000000 +0200
+++ gamess/comp 2014-06-11 21:26:03.000000000 +0200
@@ -1806,6 +1804,8 @@
             breaksw
          case 4.6:
          case 4.7:
+         case 4.8:
+         case 4.9:
             set EXTRAOPT="$EXTRAOPT -fno-whole-file"
             breaksw
          default:
--- gamess/source/zunix.c.orig  2014-06-12 08:52:56.000000000 +0200
+++ gamess/source/zunix.c   2014-06-12 08:53:05.000000000 +0200
@@ -443,7 +443,7 @@
 #ifdef LINUX64

 #include <stdlib.h>
-#include <malloc.h>
+#include <malloc/malloc.h>

 #define FORTINT long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment