From f5837c00319f6aed4128e18960b390087f882378 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Fri, 10 Dec 2004 19:54:49 +0000 Subject: [PATCH] *** empty log message *** --- Cantera/python/Cantera/num.py | 30 ++++++++++++++++++++++++++++++ Cantera/python/src/pycantera.cpp | 5 +++++ config.h.in | 7 ++++++- config/configure | 20 ++++++++++++++++---- config/configure.in | 9 +++++++++ configure | 7 ++++++- 6 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 Cantera/python/Cantera/num.py diff --git a/Cantera/python/Cantera/num.py b/Cantera/python/Cantera/num.py new file mode 100644 index 000000000..9ac852793 --- /dev/null +++ b/Cantera/python/Cantera/num.py @@ -0,0 +1,30 @@ + +nummodule = None +try: + import numarray + nummodule = numarray +except: + try: + import Numeric + nummodule = Numeric + except: + print """ + + ERROR: numarray / numeric not found! + + Cantera uses a set of numerical extensions to Python, but these do + not appear to be present on your system. To install the required + package, go to http://sourceforge.net/projects/numpy, and install + either the numarray or Numeric package for your system. If you are + using a Windows system, use the binary installer to install the + selected package for you automatically. + + """ + raise "could not import numarray or Numeric" + +zeros = nummodule.zeros +array = nummodule.array +asarray = nummodule.asarray +transpose = nummodule.transpose + + diff --git a/Cantera/python/src/pycantera.cpp b/Cantera/python/src/pycantera.cpp index 8819bdeef..139e3aa93 100644 --- a/Cantera/python/src/pycantera.cpp +++ b/Cantera/python/src/pycantera.cpp @@ -14,7 +14,12 @@ #include "../../../config.h" #include "Python.h" + +#ifdef HAS_NUMERIC #include "Numeric/arrayobject.h" +#else +#include "numarray/arrayobject.h" +#endif #include "ct.h" #include "ctxml.h" diff --git a/config.h.in b/config.h.in index 345f9f94f..db13250b7 100755 --- a/config.h.in +++ b/config.h.in @@ -75,9 +75,14 @@ typedef int ftnlen; // Fortran hidden string length type //--------------------- Python ------------------------------------ // This path to the python executable is created during // Cantera's setup. It identifies the python executable -// used to run Python to process .cti files. +// used to run Python to process .cti files. Note that this is only +// used if environment variable PYTHON_CMD is not set. #undef PYTHON_EXE +// If this is defined, the Cantera Python interface will use the +// Numeric package; otherwise, it will use numarray. +#undef HAS_NUMERIC + //--------------------- Cantera ----------------------------------- #undef CANTERA_ROOT diff --git a/config/configure b/config/configure index 0883fd5ec..0e0f2315b 100755 --- a/config/configure +++ b/config/configure @@ -2006,6 +2006,13 @@ _ACEOF fi +if test "$USE_NUMERIC" = "y"; then +cat >>confdefs.h <<\_ACEOF +#define HAS_NUMERIC 1 +_ACEOF + +fi + # # Matlab Interface # @@ -3483,7 +3490,7 @@ fi # Provide some information about the compiler. -echo "$as_me:3486:" \ +echo "$as_me:3493:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -3660,7 +3667,7 @@ _ACEOF # flags. ac_save_FFLAGS=$FFLAGS FFLAGS="$FFLAGS $ac_verb" -(eval echo $as_me:3663: \"$ac_link\") >&5 +(eval echo $as_me:3670: \"$ac_link\") >&5 ac_f77_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$ac_f77_v_output" >&5 FFLAGS=$ac_save_FFLAGS @@ -3740,7 +3747,7 @@ _ACEOF # flags. ac_save_FFLAGS=$FFLAGS FFLAGS="$FFLAGS $ac_cv_prog_f77_v" -(eval echo $as_me:3743: \"$ac_link\") >&5 +(eval echo $as_me:3750: \"$ac_link\") >&5 ac_f77_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$ac_f77_v_output" >&5 FFLAGS=$ac_save_FFLAGS @@ -4073,7 +4080,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - ac_config_files="$ac_config_files ../Cantera/Makefile ../Cantera/src/Makefile ../Cantera/src/zeroD/Makefile ../Cantera/src/oneD/Makefile ../Cantera/src/converters/Makefile ../Cantera/src/transport/Makefile ../Cantera/clib/src/Makefile ../Cantera/fortran/src/Makefile ../Cantera/fortran/f77demos/f77demos.mak ../Cantera/fortran/f77demos/isentropic.dsp ../Cantera/matlab/Makefile ../Cantera/matlab/setup_matlab.py ../Cantera/matlab/setup_winmatlab.py ../Cantera/python/Makefile ../Cantera/python/setup.py ../Cantera/cxx/Makefile ../Cantera/cxx/src/Makefile ../Cantera/cxx/demos/Makefile ../Cantera/user/Makefile ../Cantera/python/src/Makefile ../ext/lapack/Makefile ../ext/blas/Makefile ../ext/cvode/Makefile ../ext/math/Makefile ../ext/tpx/Makefile ../ext/Makefile ../ext/recipes/Makefile ../ext/f2c_libs/Makefile ../ext/f2c_blas/Makefile ../ext/f2c_lapack/Makefile ../ext/f2c_math/Makefile ../ext/f2c_recipes/Makefile ../examples/Makefile ../examples/cxx/Makefile ../Makefile ../tools/Makefile ../tools/src/Makefile ../tools/src/sample.mak ../tools/src/finish_install.py ../tools/src/package4mac ../tools/templates/f77/demo.mak ../tools/templates/f90/demo.mak ../tools/templates/cxx/demo.mak ../tools/testtools/Makefile ../data/inputs/Makefile ../test_problems/Makefile ../test_problems/cxx_ex/Makefile ../test_problems/silane_equil/Makefile ../test_problems/surfkin/Makefile ../test_problems/diamondSurf/Makefile ../test_problems/ck2cti_test/Makefile ../test_problems/ck2cti_test/runtest ../test_problems/python/Makefile ../bin/install_tsc" + ac_config_files="$ac_config_files ../Cantera/Makefile ../Cantera/src/Makefile ../Cantera/src/zeroD/Makefile ../Cantera/src/oneD/Makefile ../Cantera/src/converters/Makefile ../Cantera/src/transport/Makefile ../Cantera/clib/src/Makefile ../Cantera/fortran/src/Makefile ../Cantera/fortran/f77demos/f77demos.mak ../Cantera/fortran/f77demos/isentropic.dsp ../Cantera/matlab/Makefile ../Cantera/matlab/setup_matlab.py ../Cantera/matlab/setup_winmatlab.py ../Cantera/python/Makefile ../Cantera/python/setup.py ../Cantera/cxx/Makefile ../Cantera/cxx/src/Makefile ../Cantera/cxx/demos/Makefile ../Cantera/user/Makefile ../Cantera/cads/Makefile ../Cantera/cads/src/Makefile ../Cantera/cads/pe/Makefile ../Cantera/cads/Cantf77/Makefile ../Cantera/cads/util_src/Makefile ../Cantera/python/src/Makefile ../ext/lapack/Makefile ../ext/blas/Makefile ../ext/cvode/Makefile ../ext/math/Makefile ../ext/tpx/Makefile ../ext/Makefile ../ext/recipes/Makefile ../ext/f2c_libs/Makefile ../ext/f2c_blas/Makefile ../ext/f2c_lapack/Makefile ../ext/f2c_math/Makefile ../ext/f2c_recipes/Makefile ../examples/Makefile ../examples/cxx/Makefile ../Makefile ../tools/Makefile ../tools/src/Makefile ../tools/src/sample.mak ../tools/src/finish_install.py ../tools/src/package4mac ../tools/templates/f77/demo.mak ../tools/templates/f90/demo.mak ../tools/templates/cxx/demo.mak ../tools/testtools/Makefile ../data/inputs/Makefile ../test_problems/Makefile ../test_problems/cxx_ex/Makefile ../test_problems/silane_equil/Makefile ../test_problems/surfkin/Makefile ../test_problems/diamondSurf/Makefile ../test_problems/ck2cti_test/Makefile ../test_problems/ck2cti_test/runtest ../test_problems/python/Makefile ../bin/install_tsc" test "x$prefix" = xNONE && prefix=$ac_default_prefix @@ -4564,6 +4571,11 @@ do "../Cantera/cxx/src/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Cantera/cxx/src/Makefile" ;; "../Cantera/cxx/demos/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Cantera/cxx/demos/Makefile" ;; "../Cantera/user/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Cantera/user/Makefile" ;; + "../Cantera/cads/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Cantera/cads/Makefile" ;; + "../Cantera/cads/src/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Cantera/cads/src/Makefile" ;; + "../Cantera/cads/pe/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Cantera/cads/pe/Makefile" ;; + "../Cantera/cads/Cantf77/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Cantera/cads/Cantf77/Makefile" ;; + "../Cantera/cads/util_src/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Cantera/cads/util_src/Makefile" ;; "../Cantera/python/src/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Cantera/python/src/Makefile" ;; "../ext/lapack/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../ext/lapack/Makefile" ;; "../ext/blas/Makefile" ) CONFIG_FILES="$CONFIG_FILES ../ext/blas/Makefile" ;; diff --git a/config/configure.in b/config/configure.in index 40aedebd3..b85139fdf 100755 --- a/config/configure.in +++ b/config/configure.in @@ -569,6 +569,10 @@ else AC_DEFINE_UNQUOTED(PYTHON_EXE,"$PYTHON_CMD") fi +if test "$USE_NUMERIC" = "y"; then +AC_DEFINE(HAS_NUMERIC) +fi + # # Matlab Interface # @@ -820,6 +824,11 @@ AC_OUTPUT(../Cantera/Makefile \ ../Cantera/cxx/src/Makefile \ ../Cantera/cxx/demos/Makefile \ ../Cantera/user/Makefile \ + ../Cantera/cads/Makefile \ + ../Cantera/cads/src/Makefile \ + ../Cantera/cads/pe/Makefile \ + ../Cantera/cads/Cantf77/Makefile \ + ../Cantera/cads/util_src/Makefile \ ../Cantera/python/src/Makefile \ ../ext/lapack/Makefile \ ../ext/blas/Makefile \ diff --git a/configure b/configure index fe1a6a36e..145387c41 100755 --- a/configure +++ b/configure @@ -105,7 +105,11 @@ PYTHON_PACKAGE=${PYTHON_PACKAGE:="full"} # different name, set this to the full path to the Python interpreter. PYTHON_CMD=${PYTHON_CMD:="default"} - +# The Cantera Python interface can be built with either the numarray +# or Numeric packages. Set this to "y" to use Numeric, or anything +# else to use numarray. +USE_NUMERIC=${USE_NUMERIC:="y"} + # Set this to 'y' when site packages must be put in system directories # but Cantera tutorials must be put in user space. An alternative to # doing this is to put everything in user space by running this script @@ -421,6 +425,7 @@ export RPFONT export USE_VISUAL_STUDIO export FORTRAN_LIB_DIR export CANTERA_INSTALL_DIR +export USE_NUMERIC cd config chmod +x ./configure