예제 #1
0
def run_install(location):
    os.chdir(location)
    cwd = os.getcwd()
    if cwd.endswith("/"):
        cwd = cwd[:-1]

    if os.path.exists("packmol"):
        print("Packmol folder already exists, so will not re-install")
    else:
        os.system("git clone https://github.com/mcubeg/packmol")
        os.chdir("packmol")
        os.system("./configure")
        os.system("make")
        os.chdir("../")

    packmol_mod_file = '''help([[
For detailed instructions, go to:
    http://m3g.iqm.unicamp.br/packmol/home.shtml
    https://github.com/mcubeg/packmol
]])
whatis("Version: unknown")
whatis("Keywords: Packmol")
whatis("URL: http://m3g.iqm.unicamp.br/packmol/home.shtml")
whatis("Description: Packmol")

prepend_path("PATH",    "$CWD/packmol")
'''
    while "$CWD" in packmol_mod_file:
        packmol_mod_file = packmol_mod_file.replace("$CWD", cwd)
    save_module(packmol_mod_file, "packmol")

    return cwd + "/packmol/packmol"
예제 #2
0
def run_install(location, python_path):

    NAME = "NLOpt"
    FOLDER = "nlopt-2.5.0"
    TARFILE = "v2.5.0.tar.gz"
    URL = "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
    HASH = "ada08c648bf9b52faf8729412ff6dd6d"
    HELPURL = "https://nlopt.readthedocs.io/en/latest/"
    VERSION = "2.5.0"

    os.chdir(location)
    cwd = os.getcwd()
    if cwd.endswith("/"):
        cwd = cwd[:-1]
    if not os.path.exists(FOLDER):
        os.system("mkdir %s" % FOLDER)
        os.system("mkdir %s/build" % FOLDER)
        download_file(cwd, URL, HASH)
        os.system("tar -C %s/ -xzf %s" % (FOLDER, TARFILE))
        os.system("mv %s/%s %s/src" % (FOLDER, FOLDER, FOLDER))
        os.mkdir("%s/src/build" % FOLDER)
        os.chdir("%s/src/build" % FOLDER)

        # Specific Install Instructions
        os.system(
            "cmake .. -DCMAKE_INSTALL_PREFIX=%s/nlopt-2.5.0/build -DPYTHON_EXECUTABLE=%s"
            % (cwd, python_path))
        os.system("make; make install")
        ###############################

        os.chdir("../../../")
    else:
        print("%s folder already exists, so will not re-install." % NAME)

    mod_file = '''help([[
    For detailed instructions, go to:
        $HELPURL$
    
    ]])
whatis("Version: $VERSION$")
whatis("Keywords: $NAME$")
whatis("URL: $HELPURL$")
whatis("Description: $NAME$")

prepend_path("PATH",               "$CWD$/$FOLDER$/build/bin")
prepend_path("LD_LIBRARY_PATH",    "$CWD$/$FOLDER$/build/lib64")
prepend_path("PYTHONPATH",         "$CWD$/$FOLDER$/build/lib/python2.7/site-packages")
'''
    rep = {
        "$CWD$": cwd,
        "$FOLDER$": FOLDER,
        "$NAME$": NAME,
        "$VERSION$": VERSION,
        "$HELPURL$": HELPURL
    }
    for identifier, word in rep.items():
        while identifier in mod_file:
            mod_file = mod_file.replace(identifier, str(word))

    save_module(mod_file, FOLDER)
예제 #3
0
def run_install(location):

    NAME = "swig"
    FOLDER = "swig-3.0.12"
    TARFILE = "swig-3.0.12.tar.gz"
    URL = "http://prdownloads.sourceforge.net/swig/swig-3.0.12.tar.gz"
    HASH = "82133dfa7bba75ff9ad98a7046be687c"
    HELPURL = "https://www.swig.org"
    VERSION = "3.0.12"

    os.chdir(location)
    cwd = os.getcwd()
    if cwd.endswith("/"):
        cwd = cwd[:-1]
    if not os.path.exists(FOLDER):
        os.system("mkdir %s" % FOLDER)
        os.system("mkdir %s/build" % FOLDER)
        download_file(cwd, URL, HASH)
        # Untar the folder and make it into the build src ideal
        os.system("tar -C %s/ -xzf %s" % (FOLDER, TARFILE))
        os.system("mv %s/%s %s/src" % (FOLDER, FOLDER, FOLDER))
        # Go into the src directory
        os.chdir("%s/src" % FOLDER)

        # Specific Install Instructions
        os.system("./configure --prefix=%s/%s/build" % (cwd, FOLDER))
        os.system("make; make install")
        ###############################

        os.chdir("../../")
    else:
        print("%s folder already exists, so will not re-install." % NAME)
    
    mod_file = '''help([[
    For detailed instructions, go to:
        $HELPURL$
    
    ]])
whatis("Version: $VERSION$")
whatis("Keywords: $NAME$")
whatis("URL: $HELPURL$")
whatis("Description: $NAME$")

prepend_path("PATH",               "$CWD$/$FOLDER$/build/bin")
'''
    rep = {
        "$CWD$": cwd,
        "$FOLDER$": FOLDER,
        "$NAME$": NAME,
        "$VERSION$": VERSION,
        "$HELPURL$": HELPURL
    }
    for identifier, word in rep.items():
        while identifier in mod_file:
            mod_file = mod_file.replace(identifier, str(word))

    save_module(mod_file, FOLDER)
예제 #4
0
def _squid_setup(anaconda_path, default_modules, lmp_path, packmol_path,
                 orca_path, orca4_path, vmd_path, ovito_path, queueing_system,
                 orca_sub_flag, env_vars, orca_env_vars, orca4_env_vars,
                 lmp_env_vars, mpi_preface, python_path, text_editor_path,
                 g09_formchk, g09_cubegen, mpirun_path, default_queue,
                 use_orca4, sandbox_orca, cwd, HOMEDIR, MODULEDIR):
    '''
    This function will setup the squid sysconst file and module.
    '''
    opls_path = cwd + '/forcefield_parameters/oplsaa.prm'
    vars_to_include = [
        orca_path, orca4_path, vmd_path, ovito_path, opls_path, packmol_path,
        lmp_path, queueing_system, orca_sub_flag, env_vars, orca_env_vars,
        orca4_env_vars, lmp_env_vars, mpi_preface, python_path,
        text_editor_path, g09_formchk, g09_cubegen, mpirun_path, default_queue
    ]

    s_vars_to_include = [
        "orca_path", "orca4_path", "vmd_path", "ovito_path", "opls_path",
        "packmol_path", "lmp_path", "queueing_system", "orca_sub_flag",
        "env_vars", "orca_env_vars", "orca4_env_vars", "lmp_env_vars",
        "mpi_preface", "python_path", "TEXT_EDITOR_PATH", "g09_formchk",
        "g09_cubegen", "mpirun_path", "default_queue"
    ]

    exports_and_aliases = """
--------------------------------------------------------------------------
---------           Squid Exports and Aliases v 0.0.1            ---------
--------------------------------------------------------------------------

help([[
For detailed instructions, go to:
   https://clancylab.github.io/squid/squid.html

]])
whatis("Version: 1.2")
whatis("Keywords: Squid, Clancy")
whatis("URL: https://clancylab.github.io/squid/squid.html")
whatis("Description: Clancy Lab Codebase")

prepend_path( "PYTHONPATH",     "$CWD")

-- Load all dependencies
""" + default_modules

    swap_with_this = [("$CWD", cwd), ("$PYTHON_PATH", python_path)]
    for k, v in swap_with_this:
        while k in exports_and_aliases:
            exports_and_aliases = exports_and_aliases.replace(k, v)

    for s, v in zip(s_vars_to_include, vars_to_include):
        ss = "$" + s.upper()
        while ss in exports_and_aliases:
            exports_and_aliases = exports_and_aliases.replace(ss, v)

    save_module(exports_and_aliases.strip() + "\n", "squid", MODULEDIR)
예제 #5
0
def _setup_openmpi(orca_path, orca4_path, MODULEDIR):
    if isvalid(orca4_path):
        # If orca4 is a file, point to folder instead
        if os.path.isfile(orca4_path) and orca4_path.endswith("/orca"):
            orca4_path = orca4_path[:-5]

        if "4.1." in orca4_path:
            ompi_v = "3.1.3"
        elif "4.0." in orca4_path:
            ompi_v = "2.0.2"
        run_install_openmpi("./", ompi_v, MODULEDIR)
        orca_mod_file = '''help([[
For detailed instructions, go to:
    https://orcaforum.cec.mpg.de/

    ]])
whatis("Version: $VERSION$")
whatis("Keywords: Orca 4")
whatis("URL: https://orcaforum.cec.mpg.de/")
whatis("Description: Orca 4")

load("openmpi/$VERSION$")

prepend_path("PATH",               "$ORCA$")
prepend_path("LD_LIBRARY_PATH",    "$ORCA$")
'''
        swap_with_this = [("$ORCA$", orca4_path), ("$VERSION$", ompi_v)]
        for k, v in swap_with_this:
            while k in orca_mod_file:
                orca_mod_file = orca_mod_file.replace(k, v)
        save_module(orca_mod_file, "orca-4", MODULEDIR)
    if isvalid(orca_path):
        # If orca4 is a file, point to folder instead
        if os.path.isfile(orca_path) and orca_path.endswith("/orca"):
            orca_path = orca_path[:-5]
        run_install_openmpi("./", "1.6.5", MODULEDIR)
        orca_mod_file = '''help([[
For detailed instructions, go to:
    https://orcaforum.cec.mpg.de/

    ]])
whatis("Version: $VERSION$")
whatis("Keywords: Orca 3")
whatis("URL: https://orcaforum.cec.mpg.de/")
whatis("Description: Orca 3")

load("openmpi/$VERSION$")

prepend_path("PATH",               "$ORCA$")
prepend_path("LD_LIBRARY_PATH",    "$ORCA$")
'''
        swap_with_this = [("$ORCA$", orca_path), ("$VERSION$", "1.6.5")]
        for k, v in swap_with_this:
            while k in orca_mod_file:
                orca_mod_file = orca_mod_file.replace(k, v)
        save_module(orca_mod_file, "orca-3", MODULEDIR)
예제 #6
0
def run_install(location, MODULEDIR):
    os.chdir(location)
    cwd = os.getcwd()
    if cwd.endswith("/"):
        cwd = cwd[:-1]

    if os.path.exists("packmol"):
        print("Packmol folder already exists, so will not re-install")
    else:
        os.system("git clone https://github.com/mcubeg/packmol")
        os.chdir("packmol")
        os.system("./configure")

        BAD_MARCC_FORTRAN = "FORTRAN=/software/centos7/bin/gfortran"
        GOOD_MARCC_FORTRAN = "FORTRAN=/software/apps/compilers/gcc/6.4.0/bin/gfortran"
        # On MARCC, if the FORTRAN attempted to use is BAD_MARCC_FOTRAN, then
        # switch to GOOD_MARCC_FORTRAN
        makefile = open("Makefile", 'r').read()
        if BAD_MARCC_FORTRAN in makefile:
            makefile = makefile.replace(BAD_MARCC_FORTRAN, GOOD_MARCC_FORTRAN)
            fptr = open("Makefile", 'w')
            fptr.write(makefile)
            fptr.close()

        os.system("make")
        os.chdir("../")

    packmol_mod_file = '''help([[
For detailed instructions, go to:
    http://m3g.iqm.unicamp.br/packmol/home.shtml
    https://github.com/mcubeg/packmol
]])
whatis("Version: unknown")
whatis("Keywords: Packmol")
whatis("URL: http://m3g.iqm.unicamp.br/packmol/home.shtml")
whatis("Description: Packmol")

prepend_path("PATH",    "$CWD/packmol")
'''
    while "$CWD" in packmol_mod_file:
        packmol_mod_file = packmol_mod_file.replace("$CWD", cwd)

    save_module(packmol_mod_file, "packmol", MODULEDIR)

    return cwd + "/packmol/packmol"
예제 #7
0
def run_install(anaconda_path):
    homedir = os.path.expanduser("~")
    potential_anaconda_install_dirs = [
        homedir + "/anaconda",
        homedir + "/anaconda2",
        "/software/apps/anaconda/5.2/python/2.7"
    ]
    if anaconda_path is not None:
        potential_anaconda_install_dirs += [anaconda_path]
    for folder in potential_anaconda_install_dirs:
        if os.path.exists(folder):
            print("Found anaconda at %s" % folder)
            anaconda_path = folder
            break

    if anaconda_path is not None and anaconda_path.strip() not in ["", "None"]:
        if anaconda_path.endswith("/"):
            anaconda_path = anaconda_path[:-1]
    else:
        print("Could not find anaconda, so will install it.")
        download_file(
            homedir,
            "https://repo.continuum.io/archive/Anaconda2-5.2.0-Linux-x86_64.sh",
            "5c034a4ab36ec9b6ae01fa13d8a04462"
        )
        os.system('bash ~/Anaconda2-5.2.0-Linux-x86_64.sh -fb')
        anaconda_path = homedir + "/anaconda2"

    anaconda_module = '''
help([[
For detailed instructions, go to:
    http://www.anaconda.com
    ]])
whatis("Version: Anaconda 5.2.0, Python 2.7")
whatis("Description: Anaconda, Python")

prepend_path("PATH",            "$ANACONDA/bin")
prepend_path("LD_LIBRARY_PATH", "$ANACONDA/lib")
'''.replace("$ANACONDA", anaconda_path).replace("$ANACONDA", anaconda_path)
    save_module(anaconda_module, "anaconda-2.7")

    return anaconda_path
예제 #8
0
def run_install(location,
                VERSION,
                SFFX,
                name,
                extra_lammps_packages=[],
                smrff_path=None,
                MODULEDIR=None,
                compiler="mpicxx"):

    LAMMPS_MAKEFILE = '''
# mpi = MPI with its default compiler

SHELL = /bin/sh

# ---------------------------------------------------------------------
# compiler/linker settings
# specify flags and libraries needed for your compiler

CC =        $CC$
# Wall and Wextra simply print additional warnings
# m64 compiles for 64 bit memory
# static-libgcc and static-libstdc++ are to make the final binary as
#     portable as possible
# g means to compile this with debugging flags
CCFLAGS =  -std=c++11 -g -O3 -m64 -static-libgcc -static-libstdc++ -Wall -Wextra
SHFLAGS =   -fPIC
DEPFLAGS =  -M

LINK =      $CC$
LINKFLAGS = -std=c++11 -g -O3 -m64 -static-libgcc -static-libstdc++ -Wall -Wextra
LIB =
SIZE =      size

ARCHIVE =   ar
ARFLAGS =   -rc
SHLIBFLAGS =    -shared

# ---------------------------------------------------------------------
# LAMMPS-specific settings, all OPTIONAL
# specify settings for LAMMPS features you will use
# if you change any -D setting, do full re-compile after "make clean"

# LAMMPS ifdef settings
# see possible settings in Section 2.2 (step 4) of manual

LMP_INC =   -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64

# MPI library
# see discussion in Section 2.2 (step 5) of manual
# MPI wrapper compiler/linker can provide this info
# can point to dummy MPI library in src/STUBS as in Makefile.serial
# use -D MPICH and OMPI settings in INC to avoid C++ lib conflicts
# INC = path for mpi.h, MPI compiler settings
# PATH = path for MPI library
# LIB = name of MPI library

MPI_INC =       $MPIINC$ -I$PYTHON_DIR$/include/python3.7m
MPI_PATH =      $MPIPATH$ -L$PYTHON_DIR$/lib
MPI_LIB =       $MPILIB$ -lpython3.7m

# FFT library
# see discussion in Section 2.2 (step 6) of manual
# can be left blank to use provided KISS FFT library
# INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings
# PATH = path for FFT library
# LIB = name of FFT library

FFT_INC =
FFT_PATH =
FFT_LIB =

# JPEG and/or PNG library
# see discussion in Section 2.2 (step 7) of manual
# only needed if -DLAMMPS_JPEG or -DLAMMPS_PNG listed with LMP_INC
# INC = path(s) for jpeglib.h and/or png.h
# PATH = path(s) for JPEG library and/or PNG library
# LIB = name(s) of JPEG library and/or PNG library

JPG_INC =
JPG_PATH =
JPG_LIB =

# ---------------------------------------------------------------------
# build rules and dependencies
# do not edit this section

include Makefile.package.settings
include Makefile.package

EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC)
EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH)
EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB)
EXTRA_CPP_DEPENDS = $(PKG_CPP_DEPENDS)
EXTRA_LINK_DEPENDS = $(PKG_LINK_DEPENDS)

# Path to src files

vpath %.cpp ..
vpath %.h ..

# Link target

$(EXE): $(OBJ) $(EXTRA_LINK_DEPENDS)
\t$(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE)
\t$(SIZE) $(EXE)

# Library targets

lib:    $(OBJ) $(EXTRA_LINK_DEPENDS)
\t$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)

shlib:  $(OBJ) $(EXTRA_LINK_DEPENDS)
\t$(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
\t\t$(OBJ) $(EXTRA_LIB) $(LIB)

# Compilation rules

%.o:%.cpp
\t$(CC) $(CCFLAGS) $(SHFLAGS) $(EXTRA_INC) -c $<

# Individual dependencies

depend : fastdep.exe $(SRC)
\t@./fastdep.exe $(EXTRA_INC) -- $^ > .depend || exit 1

fastdep.exe: ../DEPEND/fastdep.c
\tcc -O -o $@ $<

sinclude .depend
'''

    mpi_inc = "-DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1"
    mpi_path = ""
    mpi_lib = ""
    serial_inc = "-I../STUBS"
    serial_path = "-L../STUBS"
    serial_lib = "-lmpi_stubs"

    python_path = sys.executable

    PYTHON_DIR = python_path.split("/bin")[0]
    while "$PYTHON_DIR$" in LAMMPS_MAKEFILE:
        LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$PYTHON_DIR$", PYTHON_DIR)
    while "$CC$" in LAMMPS_MAKEFILE:
        LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$CC$", compiler)

    assert SFFX in ["serial", "mpi"],\
        "Error - SFFX should be either serial or mpi.  It was %s." % SFFX

    if SFFX == "mpi":
        LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPIINC$", mpi_inc)
        LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPIPATH$", mpi_path)
        LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPILIB$", mpi_lib)
    elif SFFX == "serial":
        LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPIINC$", serial_inc)
        LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPIPATH$", serial_path)
        LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPILIB$", serial_lib)

    # Error Handling
    VERSION = str(VERSION)

    NAME = "LAMMPs"
    FOLDER = "lammps/" + name
    TARFILE = "lammps-%s.tar.gz" % VERSION
    URL = "https://lammps.sandia.gov/tars/lammps-%s.tar.gz" % VERSION
    lammps_hashes = {"16Mar18": "8059f1cac17ac74c099ba6c5a5e3a558"}
    if VERSION not in lammps_hashes:
        lammps_hashes[VERSION] = ""
        print(
            "For future reference, please store the lammps hash of this .tar.gz file."
        )
    HASH = lammps_hashes[VERSION]

    HELPURL = "https://lammps.sandia.gov"

    os.chdir(location)
    cwd = os.getcwd()
    if cwd.endswith("/"):
        cwd = cwd[:-1]

    MODULE_LOADERS = ""

    if not os.path.exists(FOLDER):
        os.system("mkdir -p %s" % FOLDER)
        download_file(cwd, URL, HASH)
        # Untar the file to the folder openmpi/openmpi-VERSION
        os.system("tar -xzf %s -C %s" % (TARFILE, FOLDER))
        # Now we have lammps/version/lammps-version/src
        # So, we mv it back
        os.system("mv %s/lammps-%s %s/.." % (FOLDER, VERSION, FOLDER))
        os.system("rm -rf %s" % FOLDER)
        os.system("mv lammps/lammps-%s %s" % (VERSION, FOLDER))
        # Change into src, configure, and make
        os.chdir("%s/src" % FOLDER)

        if smrff_path is not None and os.path.exists(smrff_path):
            print("Will install smrff into this lammps install.")
            if VERSION != "16Mar18":
                print(
                    "WARNING! SMRFF is only guaranteed to work for lammps version 16Mar18.  Will compile anyways, but good luck."
                )
            os.system("cp -rf %s/lammps/lammps-16Mar18/src/* ." % smrff_path)

        fptr = open("MAKE/Makefile.%s" % SFFX, 'w')
        fptr.write(LAMMPS_MAKEFILE)
        fptr.close()

        for pkg in extra_lammps_packages:
            os.system("make yes-%s" % pkg)

        # Setup stubs if serial
        if SFFX == "serial":
            os.chdir("STUBS")
            os.system("make")
            os.chdir("../")

        # Bug fix before compiling
        fname = "python_impl.cpp"
        possibly_buggy_file = open(fname, 'r').read().strip()
        bad_line = " char *pystr = PY_STRING_AS_STRING(pValue);"
        good_line = " const char *pystr = PY_STRING_AS_STRING(pValue);"
        if bad_line in possibly_buggy_file:
            fptr = open(fname, 'w')
            fptr.write(possibly_buggy_file.replace(bad_line, good_line))
            fptr.close()

        os.system("make %s -j 4" % SFFX)
        os.system("make %s -j 4 mode=shlib" % SFFX)
        ###############################
        os.chdir("../../../")
        print("CURRENT DIR = %s" % os.getcwd())
    else:
        print("%s folder already exists, so will not re-install." % NAME)

    mod_file = '''help([[
For detailed instructions, go to:
    $HELPURL$

This version of LAMMPS was compiled with the following packages:

    ''' + "\n    ".join(extra_lammps_packages) + '''
''' + ("    SMRFF" if smrff_path is not None else "") + '''
]])
whatis("Version: $VERSION$")
whatis("Keywords: $NAME$")
whatis("URL: $HELPURL$")
whatis("Description: $NAME$")

prepend_path("PATH",               "$CWD$/$FOLDER$/src")
prepend_path("PYTHONPATH",         "$CWD$/$FOLDER$/python")
prepend_path("LD_LIBRARY_PATH",    "$CWD$/$FOLDER$/src")

$MODULE_LOADERS$
'''
    rep = {
        "$CWD$": cwd,
        "$FOLDER$": FOLDER,
        "$NAME$": NAME,
        "$VERSION$": VERSION,
        "$HELPURL$": HELPURL,
        "$MODULE_LOADERS$": MODULE_LOADERS,
    }
    for identifier, word in rep.items():
        while identifier in mod_file:
            mod_file = mod_file.replace(identifier, str(word))

    HOMEDIR = os.path.expanduser("~")
    if MODULEDIR is None:
        MODULEDIR = HOMEDIR + "/.modules"

    if not os.path.exists("%s/lammps" % MODULEDIR):
        os.makedirs("%s/lammps" % MODULEDIR, exist_ok=True)

    save_module(mod_file, FOLDER, MODULEDIR)

    return cwd + "/" + FOLDER + "/src/lmp_" + SFFX
예제 #9
0
def _squid_setup(anaconda_path,
                 default_modules,
                 lmp_path,
                 packmol_path,
                 orca_path, orca4_path,
                 vmd_path, ovito_path,
                 queueing_system,
                 orca_sub_flag,
                 env_vars, orca_env_vars, orca4_env_vars,
                 lmp_env_vars, mpi_preface, python_path,
                 text_editor_path, g09_formchk, g09_cubegen,
                 mpirun_path, default_queue,
                 use_orca4, sandbox_orca,
                 cwd, HOMEDIR):
    '''
    This function will setup the squid sysconst file and module.
    '''
    opls_path = cwd + '/forcefield_parameters/oplsaa.prm'
    vars_to_include = [
        orca_path, orca4_path, vmd_path, ovito_path, opls_path, packmol_path,
        lmp_path, queueing_system, orca_sub_flag, env_vars,
        orca_env_vars, orca4_env_vars, lmp_env_vars, mpi_preface, python_path,
        text_editor_path, g09_formchk, g09_cubegen, mpirun_path, default_queue]

    s_vars_to_include = [
        "orca_path", "orca4_path", "vmd_path", "ovito_path", "opls_path",
        "packmol_path", "lmp_path", "queueing_system",
        "orca_sub_flag", "env_vars", "orca_env_vars", "orca4_env_vars",
        "lmp_env_vars", "mpi_preface", "python_path", "TEXT_EDITOR_PATH",
        "g09_formchk", "g09_cubegen", "mpirun_path", "default_queue"]

    sysconst_file_string = """# System Constants. This includes paths to where things are installed
orca_path = "$ORCA_PATH"
orca4_path = "$ORCA4_PATH"
use_orca4 = """ + str(use_orca4) + """
sandbox_orca = """ + str(sandbox_orca) + """

g09_formchk = "$G09_FORMCHK"
g09_cubegen = "$G09_CUBEGEN"
vmd_path = "$VMD_PATH"
ovito_path = "$OVITO_PATH"
opls_path = "$OPLS_PATH"
packmol_path = "$PACKMOL_PATH"
lmp_path = "$LMP_PATH"
python_path = "$PYTHON_PATH"

mpirun_path = "$MPIRUN_PATH"

queueing_system = "$QUEUEING_SYSTEM" # nbs, pbs, slurm
default_queue = "$DEFAULT_QUEUE"
slurm_default_allocation = None
nbs_ssh = None
nbs_bin_path = ""

# Default modules to load in pysub submission.
default_pysub_modules = ["squid"]

# Submission flags for queueing system
orca_sub_flag = "$ORCA_SUB_FLAG"

# A list of all paths/environment variables needed for queue submission
env_vars = '''$ENV_VARS'''
orca_env_vars = '''$ORCA_ENV_VARS'''
orca4_env_vars = '''$ORCA4_ENV_VARS'''
lmp_env_vars = '''$LMP_ENV_VARS'''

# Mpi preface for job submission
mpi_preface = "$MPI_PREFACE"
"""

    for s, v in zip(s_vars_to_include, vars_to_include):
        ss = "$" + s.upper()
        while ss in sysconst_file_string:
            sysconst_file_string = sysconst_file_string.replace(
                "$%s" % s.upper(), str(v)
            )

    fptr_sysconst = open("squid/sysconst.py", 'w')
    fptr_sysconst.write(sysconst_file_string)
    fptr_sysconst.close()

    exports_and_aliases = """
--------------------------------------------------------------------------
---------           Squid Exports and Aliases v 0.0.1            ---------
--------------------------------------------------------------------------

help([[
For detailed instructions, go to:
   https://clancylab.github.io/squid/squid.html

]])
whatis("Version: 1.2")
whatis("Keywords: Squid, Clancy")
whatis("URL: https://clancylab.github.io/squid/squid.html")
whatis("Description: Clancy Lab Codebase")

prepend_path( "PYTHONPATH",     "$CWD")

-- Aliases
set_alias('chkDFT','python $CWD/console_scripts/chkDFT.py')
set_alias('scanDFT','python $CWD/console_scripts/scanDFT.py')
set_alias('chko','function _chko() { chkDFT $1 -dft orca $@ ; } ; _chko')
set_alias('viewo','function _viewo() { chkDFT $1 -dft orca -v $@ ; } ; _viewo')
set_alias('otail','function _otail() { tail orca/$1/$1.out $2 $3 ; } ; _otail')
set_alias('tailo','otail')
set_alias('otxt','function _otxt() {  orca/$1/$1.out & ; } ; _otxt')
set_alias('txto','otxt')
set_alias('get_ext_list','$PYTHON_PATH $CWD/console_scripts/get_ext_list.py')
set_alias('pysub','$CWD/console_scripts/pysub.py $PWD/')
set_alias('procrustes','$CWD/console_scripts/procrustes.py $PWD/')
set_alias('view_lmp','function _view_lmp() { $PYTHON_PATH $CWD/console_scripts/view_lmp.py $1 $@ ; } ; _view_lmp')
set_alias('vmd_lmp','function _vmd_lmp() { $PYTHON_PATH $CWD/console_scripts/vmd_lmp.py $1 $@ ; } ; _vmd_lmp')

-- Load all dependencies
""" + default_modules

    swap_with_this = [
        ("$CWD", cwd),
        ("$PYTHON_PATH", python_path)
    ]
    for k, v in swap_with_this:
        while k in exports_and_aliases:
            exports_and_aliases = exports_and_aliases.replace(k, v)

    for s, v in zip(s_vars_to_include, vars_to_include):
        ss = "$" + s.upper()
        while ss in exports_and_aliases:
            exports_and_aliases = exports_and_aliases.replace(ss, v)

    save_module(exports_and_aliases.strip() + "\n", "squid")
예제 #10
0
def run_install(location, version, MODULEDIR):

    # Error Handling
    version = str(version)
    assert version.count(".") == 2, VERSION_ERROR
    MAIN_VERSION = ".".join(version.split(".")[:-1])
    VERSION = str(version)

    NAME = "OpenMPI"
    FOLDER = "openmpi/" + str(version)
    TARFILE = "openmpi-" + VERSION + ".tar.gz"
    URL = "https://download.open-mpi.org/release/open-mpi/v" +\
          MAIN_VERSION +\
          "/openmpi-" + VERSION +\
          ".tar.gz"
    HASH = {
        "3.1.4": "ee6d8b66c967a38aa74e3d52a9f52ec0",
        "3.1.3": "121bab028a16ba50e27ab0952bf99e11",
        "2.1.5": "6918dc76ca4f0ba0f41fe44dfd5a976b",
        "2.0.2": "886698becc5bea8c151c0af2074b8392",
        "1.6.5": "d7e98ac8ae1a27a0e37a68b6588c3d97",
    }
    HELPURL = "https://www.open-mpi.org"

    os.chdir(location)
    cwd = os.getcwd()
    if cwd.endswith("/"):
        cwd = cwd[:-1]
    if not os.path.exists(FOLDER):
        os.system("mkdir -p %s/build" % FOLDER)
        download_file(cwd, URL, HASH)
        # Untar the file to the folder openmpi/openmpi-VERSION
        os.system("tar -xzf %s -C %s" % (TARFILE, FOLDER))
        # Move that new folder to be named src
        os.system("mv %s/openmpi-%s %s/src" % (FOLDER, VERSION, FOLDER))
        # Change into src, configure, and make
        os.chdir("%s/src" % FOLDER)
        os.system("./configure --prefix=%s/%s/build" % (cwd, FOLDER))
        os.system("make -j 4")
        os.system("make install")
        ###############################
        os.chdir("../../../")
    else:
        print("%s folder already exists, so will not re-install." % NAME)

    mod_file = '''help([[
    For detailed instructions, go to:
        $HELPURL$

    ]])
whatis("Version: $VERSION$")
whatis("Keywords: $NAME$")
whatis("URL: $HELPURL$")
whatis("Description: $NAME$")

prepend_path("PATH",               "$CWD$/$FOLDER$/build/bin")
prepend_path("LD_LIBRARY_PATH",    "$CWD$/$FOLDER$/build/lib")
'''
    rep = {
        "$CWD$": cwd,
        "$FOLDER$": FOLDER,
        "$NAME$": NAME,
        "$VERSION$": VERSION,
        "$HELPURL$": HELPURL
    }
    for identifier, word in rep.items():
        while identifier in mod_file:
            mod_file = mod_file.replace(identifier, str(word))

    HOMEDIR = os.path.expanduser("~")
    if MODULEDIR is None:
        MODULEDIR = HOMEDIR + "/.modules"

    if not os.path.exists("%s/openmpi" % MODULEDIR):
        os.makedirs("%s/openmpi" % MODULEDIR, exist_ok=True)
    save_module(mod_file, FOLDER, MODULEDIR)
예제 #11
0
def run_install(location, version):

    # Error Handling
    version = str(version)
    assert version.count(".") == 2, VERSION_ERROR
    MAIN_VERSION = ".".join(version.split(".")[:-1])
    VERSION = str(version)

    NAME = "OpenMPI"
    FOLDER = "openmpi/" + str(version)
    TARFILE = "openmpi-" + VERSION + ".tar.gz"
    URL = "https://download.open-mpi.org/release/open-mpi/v" +\
          MAIN_VERSION +\
          "/openmpi-" + VERSION +\
          ".tar.gz"
    HASH = {
        "2.1.5": "X",
        "2.0.2": "X",
        "1.6.5": "X",
    }
    HELPURL = "https://www.open-mpi.org"

    os.chdir(location)
    cwd = os.getcwd()
    if cwd.endswith("/"):
        cwd = cwd[:-1]
    if not os.path.exists(FOLDER):
        os.system("mkdir -p %s/build" % FOLDER)
        download_file(cwd, URL, HASH)
        # Untar the file to the folder openmpi/openmpi-VERSION
        os.system("tar -xzf %s -C %s" % (TARFILE, FOLDER))
        # Move that new folder to be named src
        os.system("mv %s/openmpi-%s %s/src" % (FOLDER, VERSION, FOLDER))
        # Change into src, configure, and make
        os.chdir("%s/src" % FOLDER)
        os.system("./configure --prefix=%s/%s/build" % (cwd, FOLDER))
        os.system("make -j 4")
        os.system("make install")
        ###############################
        os.chdir("../../../")
    else:
        print("%s folder already exists, so will not re-install." % NAME)

    mod_file = '''help([[
    For detailed instructions, go to:
        $HELPURL$

    ]])
whatis("Version: $VERSION$")
whatis("Keywords: $NAME$")
whatis("URL: $HELPURL$")
whatis("Description: $NAME$")

prepend_path("PATH",               "$CWD$/$FOLDER$/build/bin")
prepend_path("LD_LIBRARY_PATH",    "$CWD$/$FOLDER$/build/lib")
'''
    rep = {
        "$CWD$": cwd,
        "$FOLDER$": FOLDER,
        "$NAME$": NAME,
        "$VERSION$": VERSION,
        "$HELPURL$": HELPURL
    }
    for identifier, word in rep.items():
        while identifier in mod_file:
            mod_file = mod_file.replace(identifier, str(word))

    HOMEDIR = os.path.expanduser("~")
    if not os.path.exists("%s/.modules" % HOMEDIR):
        os.mkdir("%s/.modules" % HOMEDIR)
    if not os.path.exists("%s/.modules/openmpi" % HOMEDIR):
        os.mkdir("%s/.modules/openmpi" % HOMEDIR)
    save_module(mod_file, FOLDER)
예제 #12
0
def run_install(location, VERSION, MODULEDIR):

    NAME = "NLOpt"
    FOLDER = "nlopt/%s" % VERSION
    TARFILE = "v%s.tar.gz" % VERSION
    URL = "https://github.com/stevengj/nlopt/archive/v%s.tar.gz" % VERSION
    HASH = {
        "2.5.0": "ada08c648bf9b52faf8729412ff6dd6d",
        "2.6.1": "108eeca31ec184f955b3c26d016fe3fa",
    }[VERSION]
    HELPURL = "https://nlopt.readthedocs.io/en/latest/"

    python_path = sys.executable

    os.chdir(location)
    cwd = os.getcwd()
    if cwd.endswith("/"):
        cwd = cwd[:-1]
    if not os.path.exists(FOLDER):
        os.makedirs("%s/build" % FOLDER, exist_ok=True)
        download_file(cwd, URL, HASH)
        os.system("tar -C %s/ -xzf %s" % (FOLDER, TARFILE))
        os.system("mv %s/nlopt-%s %s/src" % (FOLDER, VERSION, FOLDER))
        os.makedirs("%s/src/build" % FOLDER, exist_ok=True)
        os.chdir("%s/src/build" % FOLDER)

        # Specific Install Instructions
        os.system(
            "cmake .. -DCMAKE_INSTALL_PREFIX=%s/%s/build -DPYTHON_EXECUTABLE=%s"
            % (cwd, FOLDER, python_path))
        os.system("make; make install")
        ###############################

        os.chdir("../../../")
    else:
        print("%s folder already exists, so will not re-install." % NAME)

    mod_file = '''help([[
For detailed instructions, go to:
    $HELPURL$

This version of nlopt was compiled with python 3.7.

]])
whatis("Version: $VERSION$")
whatis("Keywords: $NAME$")
whatis("URL: $HELPURL$")
whatis("Description: $NAME$")

prepend_path("PATH",               "$CWD$/$FOLDER$/build/bin")
prepend_path("LD_LIBRARY_PATH",    "$CWD$/$FOLDER$/build/lib")
prepend_path("LD_LIBRARY_PATH",    "$CWD$/$FOLDER$/build/lib64")
prepend_path("PYTHONPATH",         "$CWD$/$FOLDER$/build/lib/python3.7/site-packages")
'''
    rep = {
        "$CWD$": cwd,
        "$FOLDER$": FOLDER,
        "$NAME$": NAME,
        "$VERSION$": VERSION,
        "$HELPURL$": HELPURL
    }
    for identifier, word in rep.items():
        while identifier in mod_file:
            mod_file = mod_file.replace(identifier, str(word))

    HOMEDIR = os.path.expanduser("~")
    if MODULEDIR is None:
        MODULEDIR = HOMEDIR + "/.modules"

    if not os.path.exists("%s/nlopt" % MODULEDIR):
        os.makedirs("%s/nlopt" % MODULEDIR, exist_ok=True)

    save_module(mod_file, FOLDER, MODULEDIR)