summaryrefslogtreecommitdiffstats
path: root/lib/sunhpc/commands/soft/gromacs/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sunhpc/commands/soft/gromacs/__init__.py')
-rw-r--r--lib/sunhpc/commands/soft/gromacs/__init__.py209
1 files changed, 209 insertions, 0 deletions
diff --git a/lib/sunhpc/commands/soft/gromacs/__init__.py b/lib/sunhpc/commands/soft/gromacs/__init__.py
new file mode 100644
index 0000000..0a02525
--- /dev/null
+++ b/lib/sunhpc/commands/soft/gromacs/__init__.py
@@ -0,0 +1,209 @@
+#
+#coding:utf-8
+#
+#Author : QCSun
+#Email : qcsun@sunhpc.com
+#Times : 2023-04-14 05:21:02
+#WebSite : https://www.sunhpc.com
+
+import os
+import sys
+import sunhpc
+import shutil
+
+class command(sunhpc.commands.soft.command):
+ pass
+
+class Command(command):
+ """
+ Build the Gromacs software.
+
+ <arg type="string" name="version">
+ Specifies the software version. e.g,, version=2022.6
+ </arg>
+
+ <param type="path" name="prefix">
+ Specifies the software install path.
+ Default: /share/apps/soft/gromacs
+ </param>
+
+ <param type="path" name="envs">
+ Specifies the software env path.
+ Default: /share/apps/envs
+ </param>
+
+ <param type="path" name="source">
+ Specifies the software source path. e.g,, /mnt/usb
+ Default: /mnt/usb
+ </param>
+
+ <param type="Bool" name="mpi">
+ Enable mpi. Default: No
+ </param>
+
+ <param type="Bool" name="cuda">
+ Enable cuda. Default: No
+ </param>
+
+ <example cmd='soft gromacs prefix=/share/apps/soft/gromacs version=2022.6'>
+ install the gromacs software.
+ </example>
+ """
+ def run(self, params, args):
+
+ (prefix, version, source, envs, mpistatus, cudastatus) = self.fillParams([
+ ('prefix', '/share/apps/soft/gromacs'),
+ ('version', None),
+ ('source', '/mnt/usb'),
+ ('envs', '/share/apps/envs'),
+ ('mpi', None),
+ ('cuda', None),
+ ])
+
+ if len(args):
+ version = args[0]
+
+ if not version:
+ self.msg('must supply an "Gromacs version" e.g,, version=2022.6, 2023, 2023.2', 'a')
+
+ try:
+ os.makedirs(prefix)
+ self.msg("The %s directory does not exist,and it will be created." % prefix, 'w')
+ except FileExistsError:
+ pass
+
+ if not os.path.exists(envs):
+ os.makedirs(envs)
+
+ basename = 'gromacs-%s' % version
+ filename = '%s.tar.gz' % basename
+
+ softname = os.path.join(source, 'hpcsoft/Gromacs', filename)
+ if not os.path.exists(softname):
+ self.msg('The "%s" not found.' % softname, 'a')
+
+ destname = os.path.join(prefix, version)
+ self.msg('Start decompress the %s software to the /tmp directory...' % basename)
+
+ tmpdir = os.path.join(os.sep, 'tmp', basename)
+ #if os.path.exists(tmpdir):
+ # os.system('rm -rf /tmp/%s' % basename)
+ #os.system('tar -xf %s -C /tmp' % softname)
+
+ # chdir to /tmp/gromacs-version
+ os.chdir(tmpdir)
+ cwd = os.getcwd()
+
+ cmake = shutil.which('cmake')
+ try:
+ os.makedirs('build/src/external/build-fftw/fftwBuild-prefix/src')
+ except FileExistsError:
+ pass
+
+ # copy fftw to src dirs
+ srcfile = os.path.join(source, 'hpcsoft', 'fftw', 'fftw-3.3.8.tar.gz')
+ dstfile = 'build/src/external/build-fftw/fftwBuild-prefix/src/fftw-3.3.8.tar.gz'
+ shutil.copyfile(srcfile, dstfile)
+
+
+ regname = 'regressiontests-%s' % version
+ regfile = os.path.join(source, 'hpcsoft', 'Gromacs', '%s.tar.gz' % regname)
+ regpath = os.path.join(tmpdir, 'build', regname)
+ if os.path.exists(regpath):
+ shutil.rmtree(regpath)
+
+ os.system('tar -xf %s -C build/' % regfile)
+ os.chdir('build')
+
+ self.build_serial(destname, regname)
+ if mpistatus:
+ mpirun = shutil.which('mpirun')
+ if not mpirun:
+ self.msg('mpirun command not found.please install an mpirun software.', 'a')
+ self.build_mpirun(destname, regname)
+
+ if cudastatus:
+ if not cudapath:
+ self.msg('must supply an CUDA Path. e.g,, cuda=/usr/local/cuda', 'a')
+ self.build_nvidia(destname, regname, cudapath)
+
+
+ gsenv = os.path.join(envs, '%s-env.sh' % basename)
+ with open(gsenv, 'w') as f:
+ f.write('#!/bin/sh\n')
+ f.write('#\n# %s env config\n#\n\n' % basename)
+ f.write('source %s/bin/GMXRC\n' % destname)
+
+ # create shared user and group.
+ self.msg('')
+ self.msg('--------------------------------------------------------')
+ self.msg('Create a shared group to run the %s software.' % basename)
+ self.msg(' 1, groupadd -g 888 public ')
+ self.msg(' 2, usermod -G public dell ')
+ self.msg(' 3, chown -R root:public %s' % destname))
+ self.msg('--------------------------------------------------------')
+ self.msg('')
+ self.msg(' source %s' % gsenv)
+ self.msg('--------------------------------------------------------')
+
+ os.system('source %s' % gsenv)
+ os.system('gmx -version')
+
+ def build_serial(self, destname, regname):
+ query = 'cmake .. -DCMAKE_INSTALL_PREFIX=%s ' % destname
+ query += '-DGMX_BUILD_OWN_FFTW=ON '
+ query += '-DREGRESSIONTEST_PATH=%s' % regname
+ os.system(query)
+ os.system('make && make check && make install')
+
+ def build_mpirun(self, destname, regname):
+ query = 'cmake .. -DCMAKE_INSTALL_PREFIX=%s ' % destname
+ query += '-DGMX_BUILD_OWN_FFTW=ON '
+ query += '-DGMX_MPI=ON '
+ query += '-DREGRESSIONTEST_PATH=%s' % regname
+ os.system(query)
+ os.system('make && make check && make install')
+
+ def build_nvidia(self, destname, regname, cudapath):
+ query = 'cmake .. -DCMAKE_INSTALL_PREFIX=%s ' % destname
+ query += '-DGMX_BUILD_OWN_FFTW=ON '
+ query += '-DGMX_GPU=CUDA ' # NVIDIA CUDA support enabled
+ query += '-DCUDA_TOOLKIT_ROOT_DIR=%s' % cudapath
+ #query += '-DGMX_GPU=OpenCL ' # OpenCL support enabled
+ #query += '-DGMX_GPU=SYCL ' # using Intel oneAPI DPC++ by default.
+ #query += '-DGMX_SYCL_HIPSYCL=ON '
+ #query += '-DGMX_DOUBLE=on '
+ #query += '-DGMX_SIMD=xxx ' # specify the level of SIMD support
+ #query += '-DBUILD_SHARED_LIBS=off '
+ query += '-DREGRESSIONTEST_PATH=%s' % regname
+ os.system(query)
+ os.system('make && make check && make install')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+