From c092bbaede6b93b03bd281d86a7cb972992665ed Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 10 Aug 2012 21:03:06 +0000 Subject: [PATCH 1/4] Fixed the order of include and library directories when compiling Include directories in the Cantera source tree should be listed first so that they take precedence over headers from other installed copies of Cantera that might end up on the include search path. This was potentially a problem when Cantera was installed in the same location (e.g. /usr/local) as one of its dependencies (e.g. Sundials). The same logic applies to directories on the library link path. --- SConstruct | 2 +- ext/SConscript | 14 +++++++------- src/SConscript | 4 ++-- src/apps/SConscript | 2 +- src/fortran/SConscript | 2 +- src/matlab/SConscript | 4 ++-- src/python/SConscript | 2 +- test/SConscript | 6 +++--- test_problems/SConscript | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/SConstruct b/SConstruct index f0b277312..fd374fa88 100644 --- a/SConstruct +++ b/SConstruct @@ -1007,7 +1007,7 @@ def install(*args, **kwargs): env.SConsignFile() -env.Append(CPPPATH=[], +env.Prepend(CPPPATH=[], LIBPATH=[Dir('build/lib')]) if addInstallActions: diff --git a/ext/SConscript b/ext/SConscript index 7989ef318..f5bd4f088 100644 --- a/ext/SConscript +++ b/ext/SConscript @@ -8,13 +8,13 @@ def prep_default(env): def prep_fortran(env): localenv = env.Clone() - localenv.Append(CPPPATH='#include/cantera/base') # for config.h + localenv.Prepend(CPPPATH='#include/cantera/base') # for config.h return localenv def prep_f2c(env): localenv = env.Clone() - localenv.Append(CPPPATH=Dir('#ext/f2c_libs')) + localenv.Prepend(CPPPATH=Dir('#ext/f2c_libs')) if not localenv['HAS_TIMES_H']: localenv.Append(CPPDEFINES=['USE_CLOCK']) if not localenv['HAS_UNISTD_H']: @@ -37,7 +37,7 @@ def prep_f2c(env): def prep_sundials(env): localenv = env.Clone() - localenv.Append(CPPPATH=Dir('#ext/cvode/include')) + localenv.Prepend(CPPPATH=Dir('#ext/cvode/include')) # Suppress warnings from external code if '-Wall' in localenv['CCFLAGS']: @@ -47,8 +47,8 @@ def prep_sundials(env): def prep_gtest(env): localenv = env.Clone() - localenv.Append(CPPPATH=[Dir('#ext/gtest'), - Dir('#ext/gtest/include')], + localenv.Prepend(CPPPATH=[Dir('#ext/gtest'), + Dir('#ext/gtest/include')], CPPDEFINES={'GTEST_HAS_PTHREAD': 0}) return localenv @@ -132,8 +132,8 @@ for subdir, extensions, prepFunction in libs: localenv = env.Clone() -localenv.Append(CPPPATH=[Dir('#ext/gtest'), - Dir('#ext/gtest/include')], +localenv.Prepend(CPPPATH=[Dir('#ext/gtest'), + Dir('#ext/gtest/include')], CPPDEFINES={'GTEST_HAS_PTHREAD': 0}) build(localenv.Library(pjoin('../lib', 'gtest'), source=['gtest/src/gtest-all.cc'])) diff --git a/src/SConscript b/src/SConscript index 3072f5853..496fb0e94 100644 --- a/src/SConscript +++ b/src/SConscript @@ -39,8 +39,8 @@ libs = [('base', ['cpp'], baseSetup), for subdir, extensions, setup in libs: localenv = env.Clone() - localenv.Append(CPPPATH=Dir('#include')) - localenv.Append(CPPPATH=Dir('#src')) # todo: remove when not needed + localenv.Prepend(CPPPATH=Dir('#include')) + localenv.Prepend(CPPPATH=Dir('#src')) # todo: remove when not needed source = setup(localenv, subdir, extensions) objects = localenv.SharedObject(source) localenv.Depends(objects, localenv['config_h_target']) diff --git a/src/apps/SConscript b/src/apps/SConscript index 9b7f3034d..53b013e98 100644 --- a/src/apps/SConscript +++ b/src/apps/SConscript @@ -2,7 +2,7 @@ from buildutils import * Import('env', 'build', 'install') localenv = env.Clone() -localenv.Append(CPPPATH=['#src', '#include', '#src/apps']) +localenv.Prepend(CPPPATH=['#src', '#include', '#src/apps']) def buildProgram(name, src): prog = build(localenv.Program(target=pjoin('#build/bin', name), diff --git a/src/fortran/SConscript b/src/fortran/SConscript index c2c3b91d0..f84cd4757 100644 --- a/src/fortran/SConscript +++ b/src/fortran/SConscript @@ -3,7 +3,7 @@ from buildutils import * Import('env', 'build', 'install') localenv = env.Clone() -localenv.Append(CPPPATH=['#include', '#src']) +localenv.Prepend(CPPPATH=['#include', '#src']) f90_src = mglob(localenv, '.', 'f90', 'cpp') diff --git a/src/matlab/SConscript b/src/matlab/SConscript index 8513e993d..5e7a628ba 100644 --- a/src/matlab/SConscript +++ b/src/matlab/SConscript @@ -53,8 +53,8 @@ elif os.name == 'posix': linkflags.extend(['-Wl,--no-undefined', '-Wl,--version-script,src/matlab/mexFunction.map']) -localenv.Append(CPPPATH=['#include', '#src', matlab_include], - CPPDEFINES=['MATLAB_MEX_FILE'], +localenv.Prepend(CPPPATH=['#include', '#src', matlab_include]) +localenv.Append(CPPDEFINES=['MATLAB_MEX_FILE'], LIBPATH=[matlab_libs], LINKFLAGS=linkflags) diff --git a/src/python/SConscript b/src/python/SConscript index f96f6d47f..9bb4bad3c 100644 --- a/src/python/SConscript +++ b/src/python/SConscript @@ -31,7 +31,7 @@ make_setup = localenv.SubstFile('#interfaces/python/setup.py', extraArgs = '' if localenv['python_package'] == 'full': - localenv.Append(CPPPATH=['#src', '#include']) + localenv.Prepend(CPPPATH=['#src', '#include']) cantera_libname = 'cantera_shared' if os.name=='nt' else 'cantera' #pylinklibs = [cantera_libname, 'cvode', 'ctmath', 'ctlapack', 'ctblas', 'ctf2c', 'execstream'] diff --git a/test/SConscript b/test/SConscript index dbdc0ac6e..c6b4fb8aa 100644 --- a/test/SConscript +++ b/test/SConscript @@ -4,9 +4,9 @@ import subprocess Import('env','build','install') localenv = env.Clone() -localenv.Append(CPPPATH=['#ext/gtest/include', '#include'], - LIBPATH='#build/lib', - LIBS=['gtest'] + localenv['cantera_libs']) +localenv.Prepend(CPPPATH=['#ext/gtest/include', '#include'], + LIBPATH='#build/lib') +localenv.Append(LIBS=['gtest'] + localenv['cantera_libs']) localenv['ENV']['PYTHONPATH'] = Dir('#interfaces/python').abspath localenv['ENV']['CANTERA_DATA'] = Dir('#data/inputs').abspath diff --git a/test_problems/SConscript b/test_problems/SConscript index fe1539f81..2eb081bb7 100644 --- a/test_problems/SConscript +++ b/test_problems/SConscript @@ -2,7 +2,7 @@ from buildutils import * Import('env','build','install') localenv = env.Clone() -localenv.Append(CPPPATH=['#include', '#src', 'shared']) +localenv.Prepend(CPPPATH=['#include', '#src', 'shared']) os.environ['PYTHONPATH'] = pjoin(os.getcwd(), '..', 'interfaces', 'python') os.environ['CANTERA_DATA'] = pjoin(os.getcwd(), '..', 'data', 'inputs') From ead04df7412034f2b5dffd9b9806b4fa31eca229 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sun, 12 Aug 2012 23:00:14 +0000 Subject: [PATCH 2/4] Updated docs to indicate that blas_lapack_libs is unnecessary on OS X --- doc/sphinx/compiling.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/sphinx/compiling.rst b/doc/sphinx/compiling.rst index 348ddbe76..bb68b84a0 100644 --- a/doc/sphinx/compiling.rst +++ b/doc/sphinx/compiling.rst @@ -201,6 +201,9 @@ OS X CC=clang CXX=clang++ +* The Accelerate framework provides optimized versions of BLAS and LAPACK, so + the ``blas_lapack_libs`` option should generally be left unspecified. + Intel Compilers --------------- * Before compiling Cantera, you may need to set up the appropriate environment From 16462628a79ce229801d4991f35cf7d5be9b36c5 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 15 Aug 2012 15:14:02 +0000 Subject: [PATCH 3/4] Error message printed by Plog::validate now indicates the problematic reaction --- include/cantera/kinetics/RxnRates.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/cantera/kinetics/RxnRates.h b/include/cantera/kinetics/RxnRates.h index 617ac9680..9c3fe5694 100644 --- a/include/cantera/kinetics/RxnRates.h +++ b/include/cantera/kinetics/RxnRates.h @@ -537,7 +537,7 @@ public: Ea2_.resize(maxRates_); if (rdata.validate) { - validate(); + validate(rdata); } } @@ -629,7 +629,7 @@ public: //! temperatures at each interpolation pressure. This is potentially an //! issue when one of the Arrhenius expressions at a particular pressure //! has a negative pre-exponential factor. - void validate() { + void validate(const ReactionData& rdata) { double T[] = {1.0, 10.0, 100.0, 1000.0, 10000.0}; for (pressureIter iter = pressures_.begin(); iter->first < 1000; @@ -643,9 +643,10 @@ public: // message will correctly indicate that the problematic rate // expression is at the higher of the adjacent pressures. throw CanteraError("Plog::validate", - "Invalid rate coefficient at P = " + - fp2str(exp((++iter)->first)) + - ", T = " + fp2str(T[i])); + "Invalid rate coefficient for reaction #" + + int2str(rdata.number) + ":\n" + rdata.equation + "\n" + + "at P = " + fp2str(exp((++iter)->first)) + + ", T = " + fp2str(T[i])); } } } From b26f9f4ee24fe2a8d823a2fde79aae3b33782253 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 15 Aug 2012 15:14:08 +0000 Subject: [PATCH 4/4] Fixed handling of rate coefficient units in ck2cti.py Units specified on the REACTIONS line were not being handled correctly, causing the units(...) directive of the resulting .cti file to always have the default units of 'cal/mol' and 'mol', but without correcting the values. --- interfaces/python/ck2cti.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/interfaces/python/ck2cti.py b/interfaces/python/ck2cti.py index 0977ee7b3..39671c3b7 100755 --- a/interfaces/python/ck2cti.py +++ b/interfaces/python/ck2cti.py @@ -60,6 +60,7 @@ UNIT_OPTIONS = {'CAL/': 'cal/mol', 'MOLEC': 'molec', 'MOLECULES': 'molec'} +PROCESSED_UNITS = False ENERGY_UNITS = 'cal/mol' QUANTITY_UNITS = 'mol' @@ -1220,8 +1221,16 @@ def loadChemkinFile(path, speciesList=None): except IndexError: pass - ENERGY_UNITS = UNIT_OPTIONS[energyUnits] - QUANTITY_UNITS = UNIT_OPTIONS[moleculeUnits] + global PROCESSED_UNITS, ENERGY_UNITS, UNIT_OPTIONS + if not PROCESSED_UNITS: + PROCESSED_UNITS = True + ENERGY_UNITS = UNIT_OPTIONS[energyUnits] + QUANTITY_UNITS = UNIT_OPTIONS[moleculeUnits] + else: + if (ENERGY_UNITS != UNIT_OPTIONS[energyUnits] or + QUANTITY_UNITS != UNIT_OPTIONS[moleculeUnits]): + raise InputParseError("Multiple REACTIONS sections with " + "different units are not supported.") kineticsList = [] commentsList = []