diff --git a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp index ca6b39952..789e1b69f 100644 --- a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp +++ b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp @@ -42,6 +42,7 @@ using namespace std; namespace VCSnonideal { + vcs_MultiPhaseEquil::vcs_MultiPhaseEquil() : m_vprob(0), m_mix(0), @@ -710,7 +711,9 @@ namespace VCSnonideal { plogf("------------------------------------------" "-------------------\n"); if (printLvl > 2) { - plogf("Total time = %12.6e seconds\n", te); + if (m_vsolvePtr->m_timing_print_lvl > 0) { + plogf("Total time = %12.6e seconds\n", te); + } } } return iSuccess; diff --git a/Cantera/src/equil/vcs_MultiPhaseEquil.h b/Cantera/src/equil/vcs_MultiPhaseEquil.h index a0c7ab9c9..3d2750473 100644 --- a/Cantera/src/equil/vcs_MultiPhaseEquil.h +++ b/Cantera/src/equil/vcs_MultiPhaseEquil.h @@ -182,6 +182,7 @@ namespace Cantera { namespace VCSnonideal { + class VCS_PROB; class VCS_SOLVE; diff --git a/Cantera/src/equil/vcs_internal.h b/Cantera/src/equil/vcs_internal.h index 077e44817..e914b6b63 100644 --- a/Cantera/src/equil/vcs_internal.h +++ b/Cantera/src/equil/vcs_internal.h @@ -32,6 +32,15 @@ namespace VCSnonideal { */ #define plogf Cantera::writelogf + //! Global hook for turning on and off time printing. + /*! + * Default is to allow printing. But, you can assign this to zero + * globally to turn off all time printing. + * This is helpful for test suite purposes where you are interested + * in differences in text files. + */ + extern int vcs_timing_print_lvl; + /* * Forward references */ diff --git a/Cantera/src/equil/vcs_report.cpp b/Cantera/src/equil/vcs_report.cpp index 0fe699661..868b56fec 100644 --- a/Cantera/src/equil/vcs_report.cpp +++ b/Cantera/src/equil/vcs_report.cpp @@ -348,11 +348,17 @@ int VCS_SOLVE::vcs_report(int iconv) */ plogf("\n"); plogf("\nCounters: Iterations Time (seconds)\n"); - plogf(" vcs_basopt: %5d %11.5E\n", - m_VCount->Basis_Opts, m_VCount->Time_basopt); - plogf(" vcs_TP: %5d %11.5E\n", - m_VCount->Its, m_VCount->Time_vcs_TP); - + if (m_timing_print_lvl > 0) { + plogf(" vcs_basopt: %5d %11.5E\n", + m_VCount->Basis_Opts, m_VCount->Time_basopt); + plogf(" vcs_TP: %5d %11.5E\n", + m_VCount->Its, m_VCount->Time_vcs_TP); + } else { + plogf(" vcs_basopt: %5d %11s\n", + m_VCount->Basis_Opts," NA "); + plogf(" vcs_TP: %5d %11s\n", + m_VCount->Its," NA " ); + } print_line("-", 80); print_line("-", 80); @@ -373,7 +379,7 @@ int VCS_SOLVE::vcs_report(int iconv) /*****************************************************************************/ /*****************************************************************************/ -void VCS_SOLVE::vcs_TCounters_report(void) +void VCS_SOLVE::vcs_TCounters_report(int timing_print_lvl) /************************************************************************** * @@ -382,15 +388,26 @@ void VCS_SOLVE::vcs_TCounters_report(void) * Print out the total Its and time counters to standard output ***************************************************************************/ { - plogf("\nTCounters: Num_Calls Total_Its Total_Time (seconds)\n"); - plogf(" vcs_basopt: %5d %5d %11.5E\n", - m_VCount->T_Basis_Opts, m_VCount->T_Basis_Opts, m_VCount->T_Time_basopt); - plogf(" vcs_TP: %5d %5d %11.5E\n", - m_VCount->T_Calls_vcs_TP, m_VCount->T_Its, m_VCount->T_Time_vcs_TP); - plogf(" vcs_inest: %5d %11.5E\n", - m_VCount->T_Calls_Inest, m_VCount->T_Time_inest); - plogf(" vcs_TotalTime: %11.5E\n", + plogf("\nTCounters: Num_Calls Total_Its Total_Time (seconds)\n"); + if (timing_print_lvl > 0) { + plogf(" vcs_basopt: %5d %5d %11.5E\n", + m_VCount->T_Basis_Opts, m_VCount->T_Basis_Opts, " NA "); + plogf(" vcs_TP: %5d %5d %11.5E\n", + m_VCount->T_Calls_vcs_TP, m_VCount->T_Its, " NA "); + plogf(" vcs_inest: %5d %11.5E\n", + m_VCount->T_Calls_Inest, " NA "); + plogf(" vcs_TotalTime: %11.5E\n", m_VCount->T_Time_vcs); + } else { + plogf(" vcs_basopt: %5d %5d %11s\n", + m_VCount->T_Basis_Opts, m_VCount->T_Basis_Opts," NA "); + plogf(" vcs_TP: %5d %5d %11s\n", + m_VCount->T_Calls_vcs_TP, m_VCount->T_Its," NA "); + plogf(" vcs_inest: %5d %11s\n", + m_VCount->T_Calls_Inest, " NA "); + plogf(" vcs_TotalTime: %11s\n", + " NA "); + } } /*****************************************************************************/ diff --git a/Cantera/src/equil/vcs_solve.cpp b/Cantera/src/equil/vcs_solve.cpp index 69cb28d8a..96c931e85 100644 --- a/Cantera/src/equil/vcs_solve.cpp +++ b/Cantera/src/equil/vcs_solve.cpp @@ -29,6 +29,8 @@ using namespace std; namespace VCSnonideal { + int VCSnonideal::vcs_timing_print_lvl = 1; + VCS_SOLVE::VCS_SOLVE() : NSPECIES0(0), NPHASE0(0), @@ -52,9 +54,8 @@ namespace VCSnonideal { Vol(0.0), Faraday_dim(1.602e-19 * 6.022136736e26), m_VCount(0), -#ifdef DEBUG_MODE vcs_debug_print_lvl(0), -#endif + m_timing_print_lvl(1), m_VCS_UnitsFormat(VCS_UNITS_UNITLESS) { } @@ -211,7 +212,10 @@ namespace VCSnonideal { m_VCount = new VCS_COUNTERS(); vcs_counters_init(1); - + if (vcs_timing_print_lvl == 0) { + m_timing_print_lvl = 0; + } + return; } @@ -281,23 +285,22 @@ namespace VCSnonideal { * * @param maxit Maximum number of iterations for the algorithm * - * @param iprintTime Printing of time information. Default = -1, - * implies printing if other printing is turned on. - * * Output: * * @return * nonzero value: failure to solve the problem at hand. * zero : success */ - int VCS_SOLVE::vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit, - int iprintTime) { + int VCS_SOLVE::vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit) { int retn = 0; int iconv = 0, nspecies0, nelements0, nphase0; Cantera::clockWC tickTock; - if (iprintTime == -1) { - iprintTime = MAX(ipr, ip1); + + int iprintTime = MAX(ipr, ip1); + if (m_timing_print_lvl < iprintTime) { + iprintTime = m_timing_print_lvl ; } + if (ifunc < 0 || ifunc > 2) { plogf("vcs: Unrecognized value of ifunc, %d: bailing!\n", ifunc); @@ -414,7 +417,7 @@ namespace VCSnonideal { double te = tickTock.secondsWC(); m_VCount->T_Time_vcs += te; if (iprintTime > 0) { - vcs_TCounters_report(); + vcs_TCounters_report(m_timing_print_lvl); } /* * Now, destroy the private data, if requested to do so diff --git a/Cantera/src/equil/vcs_solve.h b/Cantera/src/equil/vcs_solve.h index 239b4dd62..3e3039df6 100644 --- a/Cantera/src/equil/vcs_solve.h +++ b/Cantera/src/equil/vcs_solve.h @@ -90,18 +90,13 @@ public: * * @param maxit Maximum number of iterations for the algorithm * - * @param iprintTime Printing of time information. Default = -1, - * implies printing if other printing is turned - * on. - * * Output: * * @return * nonzero value: failure to solve the problem at hand. * zero : success */ - int vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit, - int iprintTime = -1); + int vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit); int vcs_solve_TP(int, int, int); @@ -324,7 +319,7 @@ private: */ void vcs_counters_init(int ifunc); - void vcs_TCounters_report(void); + void vcs_TCounters_report(int timing_print_lvl = 1); public: //! value of the number of species used to malloc data structures @@ -781,6 +776,13 @@ public: int vcs_debug_print_lvl; + //! printing level of timing information + /*! + * 1 allowing printing of timing + * 0 do not allow printing of timing -> everything is a zero. + */ + int m_timing_print_lvl; + //! Units for the chemical potential data: /*! * VCS_UnitsFormat = Units for the chemical potential data: