Skip to content
Snippets Groups Projects
Commit bced0c3a authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

compilation works with installed package

parent c00c01d8
No related branches found
No related tags found
No related merge requests found
......@@ -31,11 +31,16 @@ try:
if not here.startswith(os.path.join(dist_loc, 'bfps')):
# not installed, but there is another version that *is*
raise DistributionNotFound
header_dir = _dist.location
lib_dir = header_dir
except DistributionNotFound:
#__version__ = 'Please install this project with setup.py'
import subprocess
__version__ = 'git revision ' + subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip()
header_dir = './src'
lib_dir = './lib'
else:
__version__ = _dist.version
from .code import code
......@@ -83,7 +83,7 @@ class code(base):
"""
return None
def write_src(self):
with open('src/' + self.name + '.cpp', 'w') as outfile:
with open(self.name + '.cpp', 'w') as outfile:
outfile.write(self.version_message)
outfile.write(self.includes)
outfile.write(self.variables)
......@@ -92,15 +92,34 @@ class code(base):
outfile.write(self.main)
outfile.write(self.main_end)
return None
def compile_code(self):
# compile code
local_install_dir = '/scratch.local/chichi/installs'
include_dirs = [bfps.header_dir,
'/usr/lib64/mpi/gcc/openmpi/include',
os.path.join(local_install_dir, 'include')]
libraries = ['fftw3_mpi',
'fftw3',
'fftw3f_mpi',
'fftw3f',
'bfps']
command_strings = ['mpicxx']
for idir in include_dirs:
command_strings += ['-I{0}'.format(idir)]
command_strings += ['-L' + os.path.join(local_install_dir, 'lib')]
command_strings.append('-L' + bfps.lib_dir)
for libname in libraries:
command_strings += ['-l' + libname]
command_strings += [self.name + '.cpp', '-o', self.name]
print command_strings
# print sum(command_strings)
return subprocess.call(command_strings)
def run(self,
ncpu = 2,
simname = 'test',
iter0 = 0):
# compile code and run
if subprocess.call(['make',
'-f',
'~/repos/bfps/makefile',
self.name + '.elf']) == 0:
if self.compile_code():
current_dir = os.getcwd()
if not os.path.isdir(self.work_dir):
os.mkdir(self.work_dir)
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment