66import os
77import warnings
88
9- def parse_configmk_lines (lines ,label ):
10- cfgvars = dict ()
9+
10+ def parse_configmk_lines (lines , label ):
11+ cfgvars = {}
1112 if "amuse configuration" not in lines [0 ]:
12- raise Exception (
13- f"{ label } is not an amuse configuration file"
14- )
13+ raise Exception (f"{ label } is not an amuse configuration file" )
1514 for line in lines :
1615 if "=" in line :
1716 var , value = line .split ("=" , 1 )
@@ -23,89 +22,93 @@ def parse_configmk_lines(lines,label):
2322 cfgvars [var ] = value .strip ()
2423 return cfgvars
2524
25+
2626def parse_configmk (filename ):
2727 configfile = open (filename , "r" )
2828 lines = configfile .readlines ()
2929 configfile .close ()
3030 return parse_configmk_lines (lines , "file " + filename )
3131
32+
3233try :
3334 configmk = parse_configmk ("config.mk" )
3435except IOError :
35- from .support import get_amuse_root_dir
36- configmk = parse_configmk (
37- os .path .join (get_amuse_root_dir (), "config.mk" )
38- )
39-
40-
41- class interpreters ():
42- python = configmk ["PYTHON" ]
43-
44-
45- class compilers ():
46- cxx = configmk ["CXX" ]
47- cc = configmk ["CC" ]
48- fc = configmk ["FC" ]
49-
50- cxx_flags = configmk ["CXXFLAGS" ]
51- cc_flags = configmk ["CFLAGS" ]
52- fc_flags = configmk ["FCFLAGS" ]
53- ld_flags = configmk ["LDFLAGS" ]
54-
55- found_fftw = configmk ["FOUND_FFTW" ]
56- fftw_flags = configmk ["FFTW_FLAGS" ]
57- fftw_libs = configmk ["FFTW_LIBS" ]
58-
59- found_gsl = configmk ["FOUND_GSL" ]
60- gsl_flags = configmk ["GSL_FLAGS" ]
61- gsl_libs = configmk ["GSL_LIBS" ]
36+ try :
37+ from .support import get_amuse_root_dir
6238
63- gfortran_version = configmk ["GFORTRAN_VERSION" ]
64- ifort_version = configmk ["IFORT_VERSION" ]
39+ configmk = parse_configmk (os .path .join (get_amuse_root_dir (), "config.mk" ))
40+ except :
41+ configmk = {}
6542
66- fc_iso_c_bindings = configmk ["FC_ISO_C_AVAILABLE" ] == 'yes'
67-
68- cython = configmk ["CYTHON" ]
69- pythondev_cflags = configmk ["PYTHONDEV_CFLAGS" ]
70- pythondev_ldflags = configmk ["PYTHONDEV_LDFLAGS" ]
71-
72-
73- class mpi ():
74- is_enabled = configmk ["MPI_ENABLED" ] == 'yes'
75- mpicxx = configmk ["MPICXX" ]
76- mpicc = configmk ["MPICC" ]
77- mpif95 = configmk ["MPIFC" ]
78- mpifc = configmk ["MPIFC" ]
79- mpif90 = configmk ["MPIFC" ]
80- mpiexec = configmk ["MPIEXEC" ]
81-
82- mpi_cflags = configmk ["MPI_CFLAGS" ]
83- mpi_cxxflags = configmk ["MPI_CXXFLAGS" ]
84- mpi_fcflags = configmk ["MPI_FCFLAGS" ]
85- mpi_clibs = configmk ["MPI_CLIBS" ]
86- mpi_cxxlibs = configmk ["MPI_CXXLIBS" ]
87- mpi_fclibs = configmk ["MPI_FCLIBS" ]
88-
89-
90- class java ():
91- is_enabled = configmk ["JAVA_ENABLED" ] == 'yes'
92- java = configmk ["JAVA" ]
93- javac = configmk ["JAVAC" ]
94- jar = configmk ["JAR" ]
95- version = configmk ["JAVA_VERSION" ]
96-
97-
98- class cuda ():
99- is_enabled = configmk ["CUDA_ENABLED" ] == 'yes'
100- compiler = configmk ["NVCC" ]
101- compiler_flags = configmk ["NVCC_FLAGS" ]
102- toolkit_path = configmk ["CUDA_TK" ]
103- sdk_path = "/TOBEFIXED"
104- cuda_libs = configmk ["CUDA_LIBS" ]
105- sapporo_version = configmk ["SAPPORO_VERSION" ]
10643
44+ try :
10745
108- class openmp ():
109- is_enabled = configmk ["OPENMP_ENABLED" ] == 'yes'
110- fcflags = configmk ["OPENMP_FCFLAGS" ]
111- cflags = configmk ["OPENMP_CFLAGS" ]
46+ class interpreters :
47+ python = configmk ["PYTHON" ]
48+
49+ class compilers :
50+ cxx = configmk ["CXX" ]
51+ cc = configmk ["CC" ]
52+ fc = configmk ["FC" ]
53+
54+ cxx_flags = configmk ["CXXFLAGS" ]
55+ cc_flags = configmk ["CFLAGS" ]
56+ fc_flags = configmk ["FCFLAGS" ]
57+ ld_flags = configmk ["LDFLAGS" ]
58+
59+ found_fftw = configmk ["FOUND_FFTW" ]
60+ fftw_flags = configmk ["FFTW_FLAGS" ]
61+ fftw_libs = configmk ["FFTW_LIBS" ]
62+
63+ found_gsl = configmk ["FOUND_GSL" ]
64+ gsl_flags = configmk ["GSL_FLAGS" ]
65+ gsl_libs = configmk ["GSL_LIBS" ]
66+
67+ gfortran_version = configmk ["GFORTRAN_VERSION" ]
68+ ifort_version = configmk ["IFORT_VERSION" ]
69+
70+ fc_iso_c_bindings = configmk ["FC_ISO_C_AVAILABLE" ] == "yes"
71+
72+ cython = configmk ["CYTHON" ]
73+ pythondev_cflags = configmk ["PYTHONDEV_CFLAGS" ]
74+ pythondev_ldflags = configmk ["PYTHONDEV_LDFLAGS" ]
75+
76+ class mpi :
77+ is_enabled = configmk ["MPI_ENABLED" ] == "yes"
78+ mpicxx = configmk ["MPICXX" ]
79+ mpicc = configmk ["MPICC" ]
80+ mpif95 = configmk ["MPIFC" ]
81+ mpifc = configmk ["MPIFC" ]
82+ mpif90 = configmk ["MPIFC" ]
83+ mpiexec = configmk ["MPIEXEC" ]
84+
85+ mpi_cflags = configmk ["MPI_CFLAGS" ]
86+ mpi_cxxflags = configmk ["MPI_CXXFLAGS" ]
87+ mpi_fcflags = configmk ["MPI_FCFLAGS" ]
88+ mpi_clibs = configmk ["MPI_CLIBS" ]
89+ mpi_cxxlibs = configmk ["MPI_CXXLIBS" ]
90+ mpi_fclibs = configmk ["MPI_FCLIBS" ]
91+
92+ class java :
93+ is_enabled = configmk ["JAVA_ENABLED" ] == "yes"
94+ java = configmk ["JAVA" ]
95+ javac = configmk ["JAVAC" ]
96+ jar = configmk ["JAR" ]
97+ version = configmk ["JAVA_VERSION" ]
98+
99+ class cuda :
100+ is_enabled = configmk ["CUDA_ENABLED" ] == "yes"
101+ compiler = configmk ["NVCC" ]
102+ compiler_flags = configmk ["NVCC_FLAGS" ]
103+ toolkit_path = configmk ["CUDA_TK" ]
104+ sdk_path = "/TOBEFIXED"
105+ cuda_libs = configmk ["CUDA_LIBS" ]
106+ sapporo_version = configmk ["SAPPORO_VERSION" ]
107+
108+ class openmp :
109+ is_enabled = configmk ["OPENMP_ENABLED" ] == "yes"
110+ fcflags = configmk ["OPENMP_FCFLAGS" ]
111+ cflags = configmk ["OPENMP_CFLAGS" ]
112+
113+ except KeyError :
114+ print ("config.mk not complete, AMUSE may not work as expected" )
0 commit comments