Add a SConstruct file to compile spec with scons

This commit is contained in:
Sylvain Tricot 2020-03-21 20:54:10 +01:00
parent 1f11a61888
commit fbe1b6917b
1 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,40 @@
from sysconfig import get_config_var
import os
COMP_OPTS = ['-O2', '-ffast-math', '-fno-automatic']
env = Environment(tools=['default', 'gfortran'], FORTRAN='gfortran', FORTRANFLAGS=" ".join(['-fPIC'] + COMP_OPTS))
sources = {
'dim_mod_src' : ['memalloc/dim_mod.f'],
'memalloc_src' : ['memalloc/modules.f', 'memalloc/allocation.f'],
'cluster_gen_src' : Glob('cluster_gen/*.f'),
'common_sub_src' : Glob('common_sub/*.f'),
'renormalization_src' : Glob('renormalization/*.f'),
'phd_se_noso_nosp_nosym_src': Glob('phd_se_noso_nosp_nosym/*.f'),
'phd_mi_noso_nosp_nosym_src': Glob('phd_mi_noso_nosp_nosym/*.f'),
'eig_common_src' : Glob('eig/common/*.f'),
'eig_mi_src' : Glob('eig/mi/*.f'),
'eig_pw_src' : Glob('eig/pw/*.f')}
objects = {}
for k, v in sources.items():
objects[k.replace('_src', '_obj')] = env.Object(sources[k])
Requires(objects['memalloc_obj'], objects['dim_mod_obj'])
suffix = get_config_var('EXT_SUFFIX')
cmd = "f2py3 -I. " + " ".join([str(_) for _ in objects if str(_).endswith('.o')]) + f" -c -m $MODULENAME $SOURCE"
shared_objects = {
'phd_se_noso_nosp_nosym': 'phd_se_noso_nosp_nosym/main.f',
'phd_mi_noso_nosp_nosym': 'phd_mi_noso_nosp_nosym/main.f',
'eig_mi' : 'eig/mi/main.f',
'eig_pw' : 'eig/pw/main.f',}
modules = {}
for k, v in shared_objects.items():
env['MODULENAME'] = k
modules[k] = env.Command(k + suffix, v, cmd)
Requires(modules[k], objects.values())