From 8cf6546b260ad2e2690e34a625ca2fce8c62fa23 Mon Sep 17 00:00:00 2001 From: xiubuzhe Date: Mon, 9 Oct 2023 02:35:22 +0800 Subject: add autodock,cmake,gaussian,gromacs --- lib/sunhpc/commands/soft/autodock/__init__.py | 62 +++++--- lib/sunhpc/commands/soft/cmake/__init__.py | 137 +++++++++++++++++ lib/sunhpc/commands/soft/gaussian/__init__.py | 10 +- lib/sunhpc/commands/soft/gromacs/__init__.py | 209 ++++++++++++++++++++++++++ 4 files changed, 389 insertions(+), 29 deletions(-) create mode 100644 lib/sunhpc/commands/soft/cmake/__init__.py create mode 100644 lib/sunhpc/commands/soft/gromacs/__init__.py (limited to 'lib') diff --git a/lib/sunhpc/commands/soft/autodock/__init__.py b/lib/sunhpc/commands/soft/autodock/__init__.py index 8161f15..4b66cf0 100644 --- a/lib/sunhpc/commands/soft/autodock/__init__.py +++ b/lib/sunhpc/commands/soft/autodock/__init__.py @@ -16,39 +16,45 @@ class command(sunhpc.commands.soft.command): class Command(command): """ - Build the Gaussian software. + Build the AutoDock software. - Specifies the software version. e.g,, version=03/09/16 + Specifies the software version. e.g,, version=4.2.6 Specifies the software install path. + Default: /share/apps/soft/autodock Specifies the software env path. + Default: /share/apps/envs Specifies the software source path. e.g,, /mnt/usb + Default: /mnt/usb - - install the gaussian software. + + install the autodock software. """ def run(self, params, args): (prefix, version, source, envs) = self.fillParams([ - ('prefix', '/share/apps/soft'), + ('prefix', '/share/apps/soft/autodock'), ('version', None), ('source', '/mnt/usb'), ('envs', '/share/apps/envs'), ]) + if len(args): + version = args[0] + if not version: - self.msg('must supply an "Gaussian version" e.g,, version=03/09/16', 'a') + self.msg('must supply an "AutoDock version" e.g,, version=4.2.6', 'a') try: os.makedirs(prefix) @@ -59,37 +65,43 @@ class Command(command): if not os.path.exists(envs): os.makedirs(envs) - softname = 'Gaussian%s' % version - - softdirs = os.path.join(source, 'hpcsoft') - softlist = os.listdir(softdirs) + if version == '4.2.6': + basename = 'autodock-4.2.6' + else: + self.msg('Version error, Try use version number "4.2.6"', 'a') - if 'Gaussian' not in softlist: - self.msg('The "%s" software was not found in the %s directory.' % (softname, softdirs), 'a') + filename = '%s.tar.bz2' % basename - gspathname = os.path.join(softdirs, 'Gaussian', softname, 'Gaussian16-a03.tbz') + softname = os.path.join(source, 'hpcsoft/AutoDock', filename) + if not os.path.exists(softname): + self.msg('The "%s" not found.' % softname, 'a') + destname = os.path.join(prefix, basename) + softlist = os.listdir(prefix) - gaussian = os.path.join(prefix, 'g%s' % version) - if os.path.exists(gaussian): - self.msg('The %s already exists,to reinstall it, remove it first.' % gaussian) + if basename in softlist: + self.msg('The %s already exists,to reinstall it, remove it first.' % basename, 'w') else: - self.msg('Start installing the %s software to the %s directory...' % (softname, prefix)) - os.system('tar -xf %s -C %s' % (gspathname, prefix)) + self.msg('Start installing the %s software to the %s directory...' % (basename, prefix)) + os.system('tar -xf %s -C %s' % (softname, prefix)) - gsenv = os.path.join(envs, 'g16-env.sh') + 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' % gaussian) - f.write('export g%sroot=%s\n' % (version, prefix)) - f.write('source $g%sroot/g%s/bsd/g%s.profile\n\n' % (version, version, version)) - f.write('export GAUSS_SCDIR=~/gstmp\n') + f.write('#\n# %s env config\n#\n\n' % basename) + f.write('export PATH=%s/%s:$PATH\n' % (prefix, basename)) # create shared user and group. - self.msg('Create a shared group to run the %s software.' % softname) + 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/g%s' % (prefix, version)) + self.msg(' 3, chown -R root:public %s/%s' % (prefix, basename)) + self.msg('--------------------------------------------------------') + self.msg('') + self.msg(' source %s' % gsenv) + self.msg('--------------------------------------------------------') diff --git a/lib/sunhpc/commands/soft/cmake/__init__.py b/lib/sunhpc/commands/soft/cmake/__init__.py new file mode 100644 index 0000000..7f39cae --- /dev/null +++ b/lib/sunhpc/commands/soft/cmake/__init__.py @@ -0,0 +1,137 @@ +# +#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 Cmake software. + + + Specifies the software version. e.g,, version=3.26.4 + + + + Specifies the software install path. + Default: /share/apps/soft/cmake + + + + Specifies the software env path. + Default: /share/apps/envs + + + + Specifies the software source path. e.g,, /mnt/usb + Default: /mnt/usb + + + + install the cmake software. + + """ + def run(self, params, args): + + (prefix, version, source, envs) = self.fillParams([ + ('prefix', '/share/apps/soft/cmake'), + ('version', '3.26.4'), + ('source', '/mnt/usb'), + ('envs', '/share/apps/envs'), + ]) + + if len(args): + version = args[0] + + if not version: + self.msg('must supply an "Cmake version" e.g,, version=3.26.4', '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) + + if version == '3.26.4': + basename = 'cmake-%s-linux-x86_64' % version + else: + self.msg('Version error, Try use version number "3.26.4"', 'a') + + filename = '%s.sh' % basename + + softname = os.path.join(source, 'hpcsoft/Cmake', filename) + if not os.path.exists(softname): + self.msg('The "%s" not found.' % softname, 'a') + + destname = os.path.join(prefix, version) + if not os.path.exists(destname): + os.makedirs(destname) + + makename = os.path.join(prefix, version, 'bin', 'cmake') + if os.path.exists(makename): + self.msg('The "cmake" already exists,to reinstall it, remove it first.', 'w') + else: + self.msg('Start installing the cmake software to the %s directory...' % (destname)) + # ./cmake-3.26.4-linux-x86_64.sh --prefix=/share/apps/soft/cmake --skip-license + cmd = 'sh %s --prefix=%s --skip-license' % (softname, destname) + print ('cmd---->', cmd) + os.system('sh %s --prefix=%s --skip-license' % (softname, destname)) + + gsenv = os.path.join(envs, 'cmake-%s-env.sh' % version) + with open(gsenv, 'w') as f: + f.write('#!/bin/sh\n') + f.write('#\n# %s env config\n#\n\n' % basename) + f.write('export PATH=%s/bin:$PATH\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' % prefix) + self.msg('--------------------------------------------------------') + self.msg('') + self.msg(' source %s' % gsenv) + self.msg('--------------------------------------------------------') + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/sunhpc/commands/soft/gaussian/__init__.py b/lib/sunhpc/commands/soft/gaussian/__init__.py index 1be8725..cff01a0 100644 --- a/lib/sunhpc/commands/soft/gaussian/__init__.py +++ b/lib/sunhpc/commands/soft/gaussian/__init__.py @@ -99,8 +99,6 @@ class Command(command): softlist = os.listdir(prefix) - print ('------softlist-----', softlist) - print ('------basename-----', basename) if basename in softlist: self.msg('The %s already exists,to reinstall it, remove it first.' % gaussian) else: @@ -111,17 +109,21 @@ class Command(command): with open(gsenv, 'w') as f: f.write('#!/bin/sh\n') f.write('#\n# %s env config\n#\n\n' % gaussian) - f.write('export g%sroot=%s\n' % (version, prefix)) + f.write('export g%sroot=%s/%s\n' % (version, prefix, basename)) f.write('source $g%sroot/g%s/bsd/g%s.profile\n\n' % (version, version, version)) f.write('export GAUSS_SCDIR=~/gstmp\n') # create shared user and group. - self.msg('Create a shared group to run the %s software.' % softname) + 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/%s' % (prefix, basename)) + self.msg('--------------------------------------------------------') self.msg('') self.msg(' source %s' % gsenv) + self.msg('--------------------------------------------------------') 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. + + + Specifies the software version. e.g,, version=2022.6 + + + + Specifies the software install path. + Default: /share/apps/soft/gromacs + + + + Specifies the software env path. + Default: /share/apps/envs + + + + Specifies the software source path. e.g,, /mnt/usb + Default: /mnt/usb + + + + Enable mpi. Default: No + + + + Enable cuda. Default: No + + + + install the gromacs software. + + """ + 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') + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3