diff --git a/Cantera/cxx/demos/Makefile.in b/Cantera/cxx/demos/Makefile.in index 107a4e992..a00f5ee62 100644 --- a/Cantera/cxx/demos/Makefile.in +++ b/Cantera/cxx/demos/Makefile.in @@ -8,11 +8,11 @@ ############################################################################# # the name of the executable program to be created -PROG_NAME = kinetics1@EXE_EXT@ +PROG_NAME = demos@EXE_EXT@ # the object files to be linked together. List those generated from Fortran # and from C/C++ separately -OBJS = kinetics1.o +OBJS = demos.o # additional flags to be passed to the linker. If your program # requires other external libraries, put them here @@ -62,7 +62,7 @@ $(PROGRAM): $(OBJS) $(CANTERA_LIBDIR)/libcantera.a test: @MAKE@ $(PROGRAM) - ./runtest + echo 100 | $(PROGRAM) > $(PROGRAM).out install: @INSTALL@ -d @ct_demodir@/cxx diff --git a/Cantera/cxx/demos/demos.cpp b/Cantera/cxx/demos/demos.cpp index 9cd73a3f7..244af345d 100644 --- a/Cantera/cxx/demos/demos.cpp +++ b/Cantera/cxx/demos/demos.cpp @@ -8,48 +8,66 @@ #include "flamespeed.cpp" #include "kinetics1.cpp" -typedef int (*exfun)(); +#include + +typedef int (*exfun)(int, void*); -int run_example(int n, exfun f, int job = 2) { - cout << "\n\n\n\n>>>>> example " << n+1 << "\n\nDescription: "; - int i = f(job); - showErrors(cout); - return i; -} - // array of demo functions -exfun fex[] = {kinetics1, rankine, flamespeed}; +exfun fex[] = {kinetics1, openRankine, flamespeed}; string demostr[] = {"zero-D kinetics ", "open Rankine cycle ", "flamespeed "}; +int np[] = {0, 0, 1}; +double p[] = {0, 0, 0.9}; + #define NDEMOS 3 -main() { +int mainmenu() { int i, idemo; + cout << "C++ Demo Programs " << endl; for (i = 0; i < NDEMOS; i++) { - cout << i << ") " << demostr[i] << endl; + cout << " " << i+1 << ") " << demostr[i] << endl; } - cout << i << ")" << "run all demos" << endl; - cout << "Enter demo number: " << endl; + cout << " " << i+1 << ")" << " run all demos" << endl; + cout << "Enter demo number (or 0 to quit): "; cin >> idemo; + if (idemo <= 0) return -99; + int iout = 0; try { - if (idemo > 0 && idemo < NDEMOS) { - return fex[idemo](); + if (idemo > 0 && idemo < NDEMOS+1) { + clock_t t0 = clock(); + iout = fex[idemo-1](0, 0); + clock_t t1 = clock(); + cout << endl << "elapsed time: " + << 1.0*(t1 - t0)/CLOCKS_PER_SEC << " s " << endl; + return idemo; } - else if (idemo == NDEMOS) { - int iout = 0; + else if (idemo >= NDEMOS+1) { + clock_t t0 = clock(); for (i = 0; i < NDEMOS; i++) - iout = fex[i](); + iout = fex[i](np[i], &p[i]); + clock_t t1 = clock(); + cout << "time: " << 1.0*(t1 - t0)/CLOCKS_PER_SEC << " s " << endl; return iout; } + return 0; } catch (CanteraError) { showErrors(cerr); - appDelete(); return -1; } } + +int main() { + int i; + while (1 > 0) { + i = mainmenu(); + appdelete(); + if (i == -99) break; + } + return 0; +} diff --git a/Cantera/cxx/demos/flamespeed.cpp b/Cantera/cxx/demos/flamespeed.cpp index 4589a6ee1..6a3272710 100644 --- a/Cantera/cxx/demos/flamespeed.cpp +++ b/Cantera/cxx/demos/flamespeed.cpp @@ -17,7 +17,7 @@ using namespace Cantera; -int demo() { +int flamespeed(int np, void* p) { try { int i; IdealGasMix gas("gri30.cti","gri30_mix"); @@ -32,9 +32,12 @@ int demo() { vector_fp x; x.resize(nsp); - doublereal phi=1.1; - cout << "Enter phi: "; - cin >> phi; + double phi = 0.0; + if (np > 0) phi = *(double*)(p); + if (phi == 0.0) { + cout << "Enter phi: "; + cin >> phi; + } doublereal C_atoms=1.0; doublereal H_atoms=4.0; @@ -65,9 +68,9 @@ int demo() { doublereal Tad=gas.temperature(); cout << phi<<' '<> ch; +#ifndef CXX_DEMO + cout << "press any key to end" << endl; + char ch; + cin >> ch; #endif +#endif + return 0; } - + #ifndef CXX_DEMO int main() { try { - openRankine(); + return openRankine(0, 0); } catch (CanteraError) { showErrors(cout); + return -1; } } #endif diff --git a/Cantera/src/config.h b/Cantera/src/config.h index 9cc9f7918..3adbbe92d 100755 --- a/Cantera/src/config.h +++ b/Cantera/src/config.h @@ -1,86 +1,90 @@ -/* ../config.h. Generated by configure. */ -// -// Run the 'configure' script to generate 'config.h' from this input file. -// -#ifndef CT_CONFIG_H -#define CT_CONFIG_H - - -//------------------------ Development flags ------------------// -// -// These flags turn on or off features that are still in -// development and are not yet stable. - -#undef DEV_EQUIL - - -//------------------------ Fortran settings -------------------// - - -// define types doublereal, integer, and ftnlen to match the -// corresponding Fortran data types on your system. The defaults -// are OK for most systems - -typedef double doublereal; // Fortran double precision -typedef int integer; // Fortran integer -typedef int ftnlen; // Fortran hidden string length type +#include "../../config.h" -// Fortran compilers pass character strings in argument lists by -// adding a hidden argement with the length of the string. Some -// compilers add the hidden length argument immediately after the -// CHARACTER variable being passed, while others put all of the hidden -// length arguments at the end of the argument list. Define this if -// the lengths are at the end of the argument list. This is usually the -// case for most unix Fortran compilers, but is (by default) false for -// Visual Fortran under Windows. -#define STRING_LEN_AT_END +// /* ../config.h. Generated by configure. */ +// // +// // Run the 'configure' script to generate 'config.h' from this input file. +// // +// #ifndef CT_CONFIG_H +// #define CT_CONFIG_H -// Define this if Fortran adds a trailing underscore to names in object files. -// For linux and most unix systems, this is the case. -#define FTN_TRAILING_UNDERSCORE +// //------------------------ Development flags ------------------// +// // +// // These flags turn on or off features that are still in +// // development and are not yet stable. + +// #undef DEV_EQUIL -//-------- LAPACK / BLAS --------- - -// Define if you are using LAPACK and BLAS from the Intel Math Kernel -// Library -/* #undef HAVE_INTEL_MKL */ - -#define LAPACK_FTN_STRING_LEN_AT_END -#define LAPACK_NAMES_LOWERCASE -#define LAPACK_FTN_TRAILING_UNDERSCORE +// //------------------------ Fortran settings -------------------// -//--------- operating system -------------------------------------- +// // define types doublereal, integer, and ftnlen to match the +// // corresponding Fortran data types on your system. The defaults +// // are OK for most systems -// The configure script defines this if the operatiing system is Mac -// OS X, This used to add some Mac-specific directories to the default -// data file search path. -#define DARWIN 0 -/* #undef HAS_SSTREAM */ +// typedef double doublereal; // Fortran double precision +// typedef int integer; // Fortran integer +// typedef int ftnlen; // Fortran hidden string length type -// Identify whether the operating system is cygwin's overlay of -// windows, with gcc being used as the compiler. -/* #undef CYGWIN */ -// Identify whether the operating system is windows based, with -// microsoft vc++ being used as the compiler -#define WINMSVC -//--------- Fonts for reaction path diagrams ---------------------- -#define RXNPATH_FONT "Helvetica" +// // Fortran compilers pass character strings in argument lists by +// // adding a hidden argement with the length of the string. Some +// // compilers add the hidden length argument immediately after the +// // CHARACTER variable being passed, while others put all of the hidden +// // length arguments at the end of the argument list. Define this if +// // the lengths are at the end of the argument list. This is usually the +// // case for most unix Fortran compilers, but is (by default) false for +// // Visual Fortran under Windows. +// #define STRING_LEN_AT_END -//--------------------- Python ------------------------------------ -// If this is defined, the Cantera Python interface will use the -// Numeric package; otherwise, it will use numarray. -/* #define HAS_NUMERIC 1 */ -#define INCL_PURE_FLUIDS 1 +// // Define this if Fortran adds a trailing underscore to names in object files. +// // For linux and most unix systems, this is the case. +// #define FTN_TRAILING_UNDERSCORE -//--------------------- compile options ---------------------------- -/* #define USE_PCH 1 */ -#endif +// //-------- LAPACK / BLAS --------- + +// // Define if you are using LAPACK and BLAS from the Intel Math Kernel +// // Library +// /* #undef HAVE_INTEL_MKL */ + +// #define LAPACK_FTN_STRING_LEN_AT_END +// #define LAPACK_NAMES_LOWERCASE +// #define LAPACK_FTN_TRAILING_UNDERSCORE + + +// //--------- operating system -------------------------------------- + +// // The configure script defines this if the operatiing system is Mac +// // OS X, This used to add some Mac-specific directories to the default +// // data file search path. +// #define DARWIN 0 +// /* #undef HAS_SSTREAM */ + +// // Identify whether the operating system is cygwin's overlay of +// // windows, with gcc being used as the compiler. +// /* #undef CYGWIN */ + +// // Identify whether the operating system is windows based, with +// // microsoft vc++ being used as the compiler +// #define WINMSVC + +// //--------- Fonts for reaction path diagrams ---------------------- +// #define RXNPATH_FONT "Helvetica" + +// //--------------------- Python ------------------------------------ +// // If this is defined, the Cantera Python interface will use the +// // Numeric package; otherwise, it will use numarray. +// /* #define HAS_NUMERIC 1 */ + +// #define INCL_PURE_FLUIDS 1 + +// //--------------------- compile options ---------------------------- +// /* #define USE_PCH 1 */ + +// #endif diff --git a/Cantera/src/misc.cpp b/Cantera/src/misc.cpp index a5b34175a..3544d2284 100755 --- a/Cantera/src/misc.cpp +++ b/Cantera/src/misc.cpp @@ -359,7 +359,7 @@ namespace Cantera { // // add a default data location for Mac OS X // - if (DARWIN == 1) + if (DARWIN > 0) dirs.push_back("/Applications/Cantera/data"); #endif diff --git a/Makefile.in b/Makefile.in index 594514252..83c2a1f07 100755 --- a/Makefile.in +++ b/Makefile.in @@ -279,6 +279,7 @@ docs: depends: cd Cantera; @MAKE@ depends cd tools; @MAKE@ depends + cd ext; @MAKE@ depends ifeq ($(build_particles),1) cd Cantera/cads; @MAKE@ depends endif diff --git a/configure b/configure index bf65ccb09..ddf198d26 100755 --- a/configure +++ b/configure @@ -323,7 +323,7 @@ F77=${F77:=g77} # Fortran 77 compiler flags. Note that the Fortran compiler flags must be set # to produce object code compatible with the C/C++ compiler you are using. -FFLAGS=${FFLAGS:='-O2'} +FFLAGS=${FFLAGS:='-O2 -g'} # the additional Fortran flags required for linking, if any. Leave commented # out if no additional flags are required. diff --git a/ext/tpx/.depends b/ext/tpx/.depends index 8d1c8b69c..beaa3571b 100755 --- a/ext/tpx/.depends +++ b/ext/tpx/.depends @@ -1 +1,11 @@ - +HFC134a.o: HFC134a.cpp HFC134a.h sub.h +Hydrogen.o: Hydrogen.cpp Hydrogen.h Sub.h +Methane.o: Methane.cpp Methane.h Sub.h +Nitrogen.o: Nitrogen.cpp Nitrogen.h Sub.h +Oxygen.o: Oxygen.cpp Oxygen.h Sub.h +RedlichKwong.o: RedlichKwong.cpp RedlichKwong.h Sub.h +Sub.o: Sub.cpp Sub.h +Water.o: Water.cpp Water.h Sub.h +lk.o: lk.cpp lk.h Sub.h +utils.o: utils.cpp subs.h HFC134a.h sub.h Hydrogen.h Methane.h Nitrogen.h \ + Oxygen.h Water.h RedlichKwong.h utils.h diff --git a/ext/tpx/utils.cpp b/ext/tpx/utils.cpp index 93b2d4365..3c272b3f8 100755 --- a/ext/tpx/utils.cpp +++ b/ext/tpx/utils.cpp @@ -26,6 +26,8 @@ namespace tpx { return new HFC134a; else if (lcname == "rk") return new RedlichKwong; + else + return 0; } Substance * GetSub(int isub) { diff --git a/tools/bin/erase b/tools/bin/erase index 89ca5c097..efa4d2eee 100755 --- a/tools/bin/erase +++ b/tools/bin/erase @@ -1,9 +1,9 @@ #!/bin/sh if test $# = 0; then echo 'usage: erase ' -fi +else file=$1 erased_dir=$HOME/erased mv -f $file erased_dir cvs remove $file - +fi