checkin to test on linux

git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/branches/class@4159 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
Scott R Charlton 2010-03-12 04:05:27 +00:00
parent 9dbdef8437
commit a4e62d3832
13 changed files with 566 additions and 177 deletions

View File

@ -15,6 +15,11 @@ Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "test2", "test2\test2.vfproj
{F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} = {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}
EndProjectSection
EndProject
Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "testf90", "testf90\testf90.vfproj", "{29C3C862-28CA-4BF2-BAF5-A8F8ABF15C12}"
ProjectSection(ProjectDependencies) = postProject
{F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} = {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -46,6 +51,12 @@ Global
{0BF09B12-56BE-42FC-B39E-61AE515D8858}.MemDebug|Win32.Build.0 = MemDebug|Win32
{0BF09B12-56BE-42FC-B39E-61AE515D8858}.Release|Win32.ActiveCfg = Release|Win32
{0BF09B12-56BE-42FC-B39E-61AE515D8858}.Release|Win32.Build.0 = Release|Win32
{29C3C862-28CA-4BF2-BAF5-A8F8ABF15C12}.Debug|Win32.ActiveCfg = Debug|Win32
{29C3C862-28CA-4BF2-BAF5-A8F8ABF15C12}.Debug|Win32.Build.0 = Debug|Win32
{29C3C862-28CA-4BF2-BAF5-A8F8ABF15C12}.MemDebug|Win32.ActiveCfg = Debug|Win32
{29C3C862-28CA-4BF2-BAF5-A8F8ABF15C12}.MemDebug|Win32.Build.0 = Debug|Win32
{29C3C862-28CA-4BF2-BAF5-A8F8ABF15C12}.Release|Win32.ActiveCfg = Release|Win32
{29C3C862-28CA-4BF2-BAF5-A8F8ABF15C12}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -22,6 +22,14 @@
END INTERFACE
INTERFACE
FUNCTION LoadDatabaseString(INPUT)
CHARACTER(LEN=*) :: INPUT
INTEGER(KIND=4) :: LoadDatabaseString
END FUNCTION LoadDatabaseString
END INTERFACE
INTERFACE
SUBROUTINE OutputLastError
END SUBROUTINE OutputLastError
@ -35,30 +43,58 @@
END FUNCTION AccumulateLine
END INTERFACE
INTERFACE
FUNCTION Run(OUTPUT_ON, ERROR_ON, LOG_ON, SELECTED_ON)
LOGICAL(KIND=4) :: OUTPUT_ON
LOGICAL(KIND=4) :: ERROR_ON
LOGICAL(KIND=4) :: LOG_ON
LOGICAL(KIND=4) :: SELECTED_ON
FUNCTION Run()
INTEGER(KIND=4) :: Run
END FUNCTION Run
END INTERFACE
INTERFACE
FUNCTION RunFile(FNAME,OUT_ON,ERR_ON,LOG_ON,SEL_ON)
FUNCTION RunFile(FNAME)
CHARACTER(LEN=*) :: FNAME
LOGICAL(KIND=4) :: OUT_ON
LOGICAL(KIND=4) :: ERR_ON
LOGICAL(KIND=4) :: LOG_ON
LOGICAL(KIND=4) :: SEL_ON
INTEGER(KIND=4) :: RunFile
END FUNCTION RunFile
END INTERFACE
INTERFACE
FUNCTION RunString(INPUT)
CHARACTER(LEN=*) :: INPUT
INTEGER(KIND=4) :: RunString
END FUNCTION RunString
END INTERFACE
INTERFACE
SUBROUTINE SetSelectedOutputOn(SEL_ON)
LOGICAL(KIND=4) :: SEL_ON
END SUBROUTINE SetSelectedOutputOn
END INTERFACE
INTERFACE
SUBROUTINE SetOutputOn(OUT_ON)
LOGICAL(KIND=4) :: OUT_ON
END SUBROUTINE SetOutputOn
END INTERFACE
INTERFACE
SUBROUTINE SetErrorOn(ERR_ON)
LOGICAL(KIND=4) :: ERR_ON
END SUBROUTINE SetErrorOn
END INTERFACE
INTERFACE
SUBROUTINE SetLogOn(LOG_ON)
LOGICAL(KIND=4) :: LOG_ON
END SUBROUTINE SetLogOn
END INTERFACE
INTERFACE
SUBROUTINE OutputLines
END SUBROUTINE OutputLines

View File

@ -36,6 +36,17 @@ int LoadDatabase(const char *filename);
* @return The number of errors encountered.
* @remarks
* Any previous database definitions are cleared.
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* FUNCTION LoadDatabaseString(INPUT)
* CHARACTER(LEN=*), INTENT(IN) :: INPUT
* INTEGER :: LoadDatabaseString
* END FUNCTION LoadDatabaseString
* </PRE>
* </CODE>
* @endhtmlonly
*/
int LoadDatabaseString(const char *input);
@ -80,11 +91,75 @@ void OutputLastError(void);
VRESULT AccumulateLine(const char *line);
/**
* Runs the accumulated input sent to AccumulateLine.
* @param output_on If non-zero turns on output to the <B>phreeqc.out</B> file.
* @param error_on If non-zero turns on output to the <B>phreeqc.err</B> file.
* @param log_on If non-zero turns on output to the <B>phreeqc.log</B> file.
* Sets the selected_output flag on or off
* @param selected_output_on If non-zero turns on output to the <B>SELECTED_OUTPUT</B> (<B>selected.out</B> if unspecified) file.
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* SUBROUTINE SetSelectedOutputOn(SELECTED_ON)
* LOGICAL, INTENT(IN) :: SELECTED_ON
* END SUBROUTINE SetSelectedOutputOn
* </PRE>
* </CODE>
* @endhtmlonly
*/
void SetSelectedOutputOn(int selected_output_on);
/**
* Sets the output flag on or off
* @param output_on If non-zero turns on output to the <B>phreeqc.out</B> file.
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* SUBROUTINE SetOutputOn(OUTPUT_ON)
* LOGICAL, INTENT(IN) :: OUTPUT_ON
* END SUBROUTINE SetOutputOn
* </PRE>
* </CODE>
* @endhtmlonly
*/
void SetOutputOn(int output_on);
/**
* Sets the error flag on or off
* @param error_on If non-zero turns on output to the <B>phreeqc.err</B> file.
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* SUBROUTINE SetErrorOn(ERROR_ON)
* LOGICAL, INTENT(IN) :: ERROR_ON
* END SUBROUTINE SetOutputOn
* </PRE>
* </CODE>
* @endhtmlonly
*/
void SetErrorOn(int error_on);
/**
* Sets the log flag on or off
* @param log_on If non-zero turns on output to the <B>phreeqc.log</B> file.
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* SUBROUTINE SetLogOn(LOG_ON)
* LOGICAL, INTENT(IN) :: LOG_ON
* END SUBROUTINE SetLogOn
* </PRE>
* </CODE>
* @endhtmlonly
*/
void SetLogOn(int error_on);
/**
* Runs the accumulated input sent to AccumulateLine.
* @return The number of errors encountered.
* @remarks
* The accumulated input is cleared upon completion.
@ -93,57 +168,54 @@ VRESULT AccumulateLine(const char *line);
* @htmlonly
* <CODE>
* <PRE>
* FUNCTION Run(OUTPUT_ON, ERROR_ON, LOG_ON, SELECTED_ON)
* LOGICAL, INTENT(IN) :: OUTPUT_ON
* LOGICAL, INTENT(IN) :: ERROR_ON
* LOGICAL, INTENT(IN) :: LOG_ON
* LOGICAL, INTENT(IN) :: SELECTED_ON
* FUNCTION Run()
* INTEGER :: Run
* END FUNCTION Run
* </PRE>
* </CODE>
* @endhtmlonly
*/
int Run(int output_on, int error_on, int log_on, int selected_output_on);
int Run(void);
/**
* Runs the specified phreeqc input file.
* @param filename The name of the phreeqc input file to run.
* @param output_on If non-zero turns on output to the <B>phreeqc.out</B> file.
* @param error_on If non-zero turns on output to the <B>phreeqc.err</B> file.
* @param log_on If non-zero turns on output to the <B>phreeqc.log</B> file.
* @param selected_output_on If non-zero turns on output to the <B>SELECTED_OUTPUT</B> (<B>selected.out</B> if unspecified) file.
* @return The number of errors encountered during the run.
* @pre LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* FUNCTION RunFile(FILENAME,OUTPUT_ON,ERROR_ON,LOG_ON,SELECTED_ON)
* FUNCTION RunFile(FILENAME)
* CHARACTER(LEN=*) :: FILENAME
* LOGICAL, INTENT(IN) :: OUTPUT_ON
* LOGICAL, INTENT(IN) :: ERROR_ON
* LOGICAL, INTENT(IN) :: LOG_ON
* LOGICAL, INTENT(IN) :: SELECTED_ON
* INTEGER :: RunFile
* END FUNCTION RunFile
* </PRE>
* </CODE>
* @endhtmlonly
*/
int RunFile(const char *filename, int output_on, int error_on, int log_on, int selected_output_on);
int RunFile(const char *filename);
/**
* Runs the specified phreeqc input file.
* Runs the specified string as input to phreeqc.
* @param input String containing phreeqc input.
* @param output_on If non-zero turns on output to the <B>phreeqc.out</B> file.
* @param error_on If non-zero turns on output to the <B>phreeqc.err</B> file.
* @param log_on If non-zero turns on output to the <B>phreeqc.log</B> file.
* @param selected_output_on If non-zero turns on output to the <B>SELECTED_OUTPUT</B> (<B>selected.out</B> if unspecified) file.
* @return The number of errors encountered during the run.
* @pre LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* FUNCTION RunString(INPUT)
* CHARACTER(LEN=*) :: INPUT
* INTEGER :: RunString
* END FUNCTION RunString
* </PRE>
* </CODE>
* @endhtmlonly
*/
int RunString(const char *input, int output_on, int error_on, int log_on, int selected_output_on);
int RunString(const char *input);
/**

View File

@ -46,22 +46,46 @@ AccumulateLine(const char *line)
return IPhreeqc::LibraryInstance()->AccumulateLine(line);
}
int
Run(int output_on, int error_on, int log_on, int selected_output_on)
void
SetSelectedOutputOn(int value)
{
return IPhreeqc::LibraryInstance()->Run(output_on, error_on, log_on, selected_output_on);
return IPhreeqc::LibraryInstance()->SetSelectedOutputOn(value != 0);
}
void
SetOutputOn(int value)
{
return IPhreeqc::LibraryInstance()->SetOutputOn(value != 0);
}
void
SetErrorOn(int value)
{
return IPhreeqc::LibraryInstance()->SetErrorOn(value != 0);
}
void
SetLogOn(int value)
{
return IPhreeqc::LibraryInstance()->SetLogOn(value != 0);
}
int
RunFile(const char* filename, int output_on, int error_on, int log_on, int selected_output_on)
Run(void)
{
return IPhreeqc::LibraryInstance()->RunFile(filename, output_on, error_on, log_on, selected_output_on);
return IPhreeqc::LibraryInstance()->Run();
}
int
RunString(const char* input, int output_on, int error_on, int log_on, int selected_output_on)
RunFile(const char* filename)
{
return IPhreeqc::LibraryInstance()->RunString(input, output_on, error_on, log_on, selected_output_on);
return IPhreeqc::LibraryInstance()->RunFile(filename);
}
int
RunString(const char* input)
{
return IPhreeqc::LibraryInstance()->RunString(input);
}
int
@ -114,11 +138,16 @@ IPhreeqc::IPhreeqc(void)
, SelectedOutput(0)
, DatabaseLoaded(false)
, SelectedOutputOn(false)
, OutputOn(false)
, LogOn(false)
, ErrorOn(false)
, DumpOn(false)
, DumpStringOn(false)
{
ASSERT(this->phast == 0);
this->ErrorReporter = new CErrorReporter<std::ostringstream>;
this->SelectedOutput = new CSelectedOutput();
this->Init();
this->init();
this->UnLoadDatabase();
}
@ -622,7 +651,12 @@ int istream_getc(void *cookie)
if (cookie)
{
std::istream* is = (std::istream*)cookie;
return is->get();
int n = is->get();
if (n == 13 && is->peek() == 10)
{
n = is->get();
}
return n;
}
return EOF;
}
@ -705,7 +739,7 @@ int IPhreeqc::open_handler(const int type, const char *file_name)
return n;
}
void IPhreeqc::Init(void)
void IPhreeqc::init(void)
{
int i;
@ -1186,6 +1220,31 @@ void IPhreeqc::Init(void)
return;
}
void IPhreeqc::SetOutputOn(bool bValue)
{
this->OutputOn = bValue;
}
void IPhreeqc::SetSelectedOutputOn(bool bValue)
{
this->SelectedOutputOn = bValue;
}
void IPhreeqc::SetLogOn(bool bValue)
{
this->LogOn = bValue;
}
void IPhreeqc::SetDumpOn(bool bValue)
{
this->DumpOn = bValue;
}
void IPhreeqc::SetErrorOn(bool bValue)
{
this->ErrorOn = bValue;
}
void IPhreeqc::AddSelectedOutput(const char* name, const char* format, va_list argptr)
{
int bInt;
@ -1376,7 +1435,7 @@ VRESULT IPhreeqc::AccumulateLine(const char *line)
return VR_OUTOFMEMORY;
}
int IPhreeqc::Run(int output_on, int error_on, int log_on, int selected_output_on)
int IPhreeqc::Run(void)
{
static const char *sz_routine = "Run";
try
@ -1390,6 +1449,10 @@ int IPhreeqc::Run(int output_on, int error_on, int log_on, int selected_output_o
std::istringstream iss(this->GetAccumulatedLines());
// this may throw
int output_on = this->OutputOn ? 1 : 0;
int error_on = this->ErrorOn ? 1 : 0;
int log_on = this->LogOn ? 1 : 0;
int selected_output_on = this->SelectedOutputOn ? 1 : 0;
this->do_run(sz_routine, &iss, NULL, output_on, error_on, log_on, selected_output_on, NULL, NULL, NULL);
}
catch (PhreeqcStop)
@ -1414,7 +1477,7 @@ int IPhreeqc::Run(int output_on, int error_on, int log_on, int selected_output_o
return this->input_error;
}
int IPhreeqc::RunFile(const char* filename, int output_on, int error_on, int log_on, int selected_output_on)
int IPhreeqc::RunFile(const char* filename)
{
static const char *sz_routine = "RunFile";
try
@ -1436,6 +1499,10 @@ int IPhreeqc::RunFile(const char* filename, int output_on, int error_on, int log
}
// this may throw
int output_on = this->OutputOn ? 1 : 0;
int error_on = this->ErrorOn ? 1 : 0;
int log_on = this->LogOn ? 1 : 0;
int selected_output_on = this->SelectedOutputOn ? 1 : 0;
this->do_run(sz_routine, &ifs, NULL, output_on, error_on, log_on, selected_output_on, NULL, NULL, NULL);
#else
// open file
@ -1449,6 +1516,10 @@ int IPhreeqc::RunFile(const char* filename, int output_on, int error_on, int log
}
// this may throw
int output_on = this->OutputOn ? 1 : 0;
int error_on = this->ErrorOn ? 1 : 0;
int log_on = this->LogOn ? 1 : 0;
int selected_output_on = this->SelectedOutputOn ? 1 : 0;
this->do_run(sz_routine, NULL, f, output_on, error_on, log_on, selected_output_on, NULL, NULL, NULL);
#endif
}
@ -1473,7 +1544,7 @@ int IPhreeqc::RunFile(const char* filename, int output_on, int error_on, int log
return this->input_error;
}
int IPhreeqc::RunString(const char* input, int output_on, int error_on, int log_on, int selected_output_on)
int IPhreeqc::RunString(const char* input)
{
static const char *sz_routine = "RunString";
try
@ -1488,6 +1559,10 @@ int IPhreeqc::RunString(const char* input, int output_on, int error_on, int log_
std::istringstream iss(s);
// this may throw
int output_on = this->OutputOn ? 1 : 0;
int error_on = this->ErrorOn ? 1 : 0;
int log_on = this->LogOn ? 1 : 0;
int selected_output_on = this->SelectedOutputOn ? 1 : 0;
this->do_run(sz_routine, &iss, NULL, output_on, error_on, log_on, selected_output_on, NULL, NULL, NULL);
}
catch (PhreeqcStop)

View File

@ -28,9 +28,17 @@ public:
VRESULT AccumulateLine(const char *line);
int Run(int output_on, int error_on, int log_on, int selected_output_on);
int RunFile(const char* filename, int output_on, int error_on, int log_on, int selected_output_on);
int RunString(const char* input, int output_on, int error_on, int log_on, int selected_output_on);
//{{
void SetDumpOn(bool bValue);
void SetErrorOn(bool bValue);
void SetLogOn(bool bValue);
void SetOutputOn(bool bValue);
void SetSelectedOutputOn(bool bValue);
//}}
int Run(void);
int RunFile(const char* filename);
int RunString(const char* input);
int GetSelectedOutputRowCount(void)const;
int GetSelectedOutputColumnCount(void)const;
@ -69,7 +77,7 @@ public:
void do_run(const char* sz_routine, std::istream* pis, FILE* fp, int output_on, int error_on, int log_on, int selected_output_on, PFN_PRERUN_CALLBACK pfn_pre, PFN_POSTRUN_CALLBACK pfn_post, void *cookie);
protected:
void Init(void);
void init(void);
protected:
// Data
@ -77,9 +85,17 @@ protected:
CSelectedOutput *SelectedOutput;
std::string PunchFileName;
bool DatabaseLoaded;
bool SelectedOutputOn;
std::string StringInput;
bool SelectedOutputOn;
//{{
bool OutputOn;
bool LogOn;
bool ErrorOn;
bool DumpOn;
bool DumpStringOn;
//}}
private:
static IPhreeqc* Instance;
};

View File

@ -2,36 +2,36 @@
#include <stdlib.h> /* malloc */
#include <memory.h> /* memcpy */
#include <assert.h> /* assert */
#include <stdio.h> /* printf */
// COMMENT: {3/11/2010 8:14:05 PM}#include <stdio.h> /* printf */
#include "phrqtype.h"
struct buffer {
char *name;
struct master *master;
LDBLE moles;
LDBLE gfw;
};
// COMMENT: {3/11/2010 8:13:47 PM}struct buffer {
// COMMENT: {3/11/2010 8:13:47 PM} char *name;
// COMMENT: {3/11/2010 8:13:47 PM} struct master *master;
// COMMENT: {3/11/2010 8:13:47 PM} LDBLE moles;
// COMMENT: {3/11/2010 8:13:47 PM} LDBLE gfw;
// COMMENT: {3/11/2010 8:13:47 PM}};
/*
* Routines
*/
extern void add_all_components(void);
extern int build_tally_table(void);
extern int calc_dummy_kinetic_reaction(struct kinetics *kinetics_ptr);
extern int diff_tally_table(void);
extern int elt_list_to_tally_table(struct buffer *buffer_ptr);
extern int entity_exists (char *name, int n_user);
extern int extend_tally_table(void);
extern int free_tally_table(void);
extern int fill_tally_table(int *n_user, int n_buffer);
extern int get_tally_table_rows_columns(int *rows, int *columns);
extern int get_tally_table_column_heading(int column, int *type, char *string);
extern int get_tally_table_row_heading(int column, char *string);
extern int set_reaction_moles(int n_user, LDBLE moles);
extern int store_tally_table(double *array, int row_dim, int col_dim);
extern int warning_msg (const char *err_str);
extern int zero_tally_table(void);
// COMMENT: {3/11/2010 8:13:17 PM}/*
// COMMENT: {3/11/2010 8:13:17 PM} * Routines
// COMMENT: {3/11/2010 8:13:17 PM} */
// COMMENT: {3/11/2010 8:13:17 PM}extern void add_all_components(void);
// COMMENT: {3/11/2010 8:13:17 PM}extern int build_tally_table(void);
// COMMENT: {3/11/2010 8:13:17 PM}extern int calc_dummy_kinetic_reaction(struct kinetics *kinetics_ptr);
// COMMENT: {3/11/2010 8:13:17 PM}extern int diff_tally_table(void);
// COMMENT: {3/11/2010 8:13:17 PM}extern int elt_list_to_tally_table(struct buffer *buffer_ptr);
// COMMENT: {3/11/2010 8:13:17 PM}extern int entity_exists (char *name, int n_user);
// COMMENT: {3/11/2010 8:13:17 PM}extern int extend_tally_table(void);
// COMMENT: {3/11/2010 8:13:17 PM}extern int free_tally_table(void);
// COMMENT: {3/11/2010 8:13:17 PM}extern int fill_tally_table(int *n_user, int n_buffer);
// COMMENT: {3/11/2010 8:13:17 PM}extern int get_tally_table_rows_columns(int *rows, int *columns);
// COMMENT: {3/11/2010 8:13:17 PM}extern int get_tally_table_column_heading(int column, int *type, char *string);
// COMMENT: {3/11/2010 8:13:17 PM}extern int get_tally_table_row_heading(int column, char *string);
// COMMENT: {3/11/2010 8:13:17 PM}extern int set_reaction_moles(int n_user, LDBLE moles);
// COMMENT: {3/11/2010 8:13:17 PM}extern int store_tally_table(double *array, int row_dim, int col_dim);
// COMMENT: {3/11/2010 8:13:17 PM}extern int warning_msg (const char *err_str);
// COMMENT: {3/11/2010 8:13:17 PM}extern int zero_tally_table(void);
#include "IPhreeqc.h"
@ -87,22 +87,38 @@ padfstring(char *dest, const char *src, unsigned int len)
int
LoadDatabaseF(char* filename, unsigned int filename_length)
{
int n;
char* cfilename;
cfilename = f2cstring(filename, filename_length);
if (!cfilename) {
if (!cfilename)
{
AddError("LoadDatabase: Out of memory.\n");
return VR_OUTOFMEMORY;
}
n = LoadDatabase(cfilename);
int n = ::LoadDatabase(cfilename);
free(cfilename);
return n;
}
int
LoadDatabaseStringF(char* input, unsigned int input_length)
{
char* cinput;
cinput = f2cstring(input, input_length);
if (!cinput)
{
AddError("LoadDatabase: Out of memory.\n");
return VR_OUTOFMEMORY;
}
int n = ::LoadDatabaseString(cinput);
free(cinput);
return n;
}
VRESULT
AccumulateLineF(char *line, unsigned int line_length)
{
@ -110,48 +126,91 @@ AccumulateLineF(char *line, unsigned int line_length)
char* cline;
cline = f2cstring(line, line_length);
if (!cline) {
if (!cline)
{
AddError("AccumulateLine: Out of memory.\n");
return VR_OUTOFMEMORY;
}
n = AccumulateLine(cline);
free(cline);
return n;
}
int
RunF(int* output_on, int* error_on, int* log_on, int* selected_output_on)
void
SetSelectedOutputOnF(int* sel_on)
{
return Run(*output_on, *error_on, *log_on, *selected_output_on);
::SetSelectedOutputOn(*sel_on);
}
void
SetOutputOnF(int* output_on)
{
::SetOutputOn(*output_on);
}
void
SetErrorOnF(int* error_on)
{
::SetErrorOn(*error_on);
}
void
SetLogOnF(int* log_on)
{
::SetLogOn(*log_on);
}
int
RunFileF(int* output_on, int* error_on, int* log_on, int* selected_output_on, char* filename, unsigned int filename_length)
RunF(void)
{
char* cline;
return ::Run();
}
cline = f2cstring(filename, filename_length);
if (!cline) {
int
RunFileF(char* filename, unsigned int filename_length)
{
char* cfilename;
cfilename = f2cstring(filename, filename_length);
if (!cfilename)
{
AddError("RunFile: Out of memory.\n");
return (int)VR_OUTOFMEMORY;
}
return RunFile(cline, *output_on, *error_on, *log_on, *selected_output_on);
int n = ::RunFile(cfilename);
free(cfilename);
return n;
}
int
RunStringF(char* input, unsigned int input_length)
{
char* cinput;
cinput = f2cstring(input, input_length);
if (!cinput)
{
AddError("RunString: Out of memory.\n");
return (int)VR_OUTOFMEMORY;
}
int n = ::RunString(cinput);
free(cinput);
return n;
}
int
GetSelectedOutputRowCountF(void)
{
return GetSelectedOutputRowCount();
return ::GetSelectedOutputRowCount();
}
int
GetSelectedOutputColumnCountF(void)
{
return GetSelectedOutputColumnCount();
return ::GetSelectedOutputColumnCount();
}
VRESULT
@ -160,7 +219,7 @@ GetSelectedOutputValueF(int *row, int *col, int *vtype, double* dvalue, char* sv
VRESULT result;
VAR v;
VarInit(&v);
result = GetSelectedOutputValue(*row, *col, &v);
result = ::GetSelectedOutputValue(*row, *col, &v);
switch (v.type) {
case TT_EMPTY:
@ -184,20 +243,20 @@ GetSelectedOutputValueF(int *row, int *col, int *vtype, double* dvalue, char* sv
default:
assert(0);
}
VarClear(&v);
::VarClear(&v);
return result;
}
void
OutputLastErrorF(void)
{
OutputLastError();
::OutputLastError();
}
void
OutputLinesF(void)
{
OutputLines();
::OutputLines();
}
#if defined(__cplusplus)
@ -207,15 +266,18 @@ extern "C" {
int
SystemF(char* command, unsigned int command_length)
{
char* cline;
char* ccommand;
cline = f2cstring(command, command_length);
if (!cline) {
ccommand = f2cstring(command, command_length);
if (!ccommand)
{
AddError("System: Out of memory.\n");
return (int)VR_OUTOFMEMORY;
}
return system(cline);
int n = system(ccommand);
free(ccommand);
return n;
}
#if defined(__cplusplus)
@ -245,13 +307,33 @@ int __stdcall ACCUMULATELINE(char *line, unsigned int len)
{
return AccumulateLineF(line, len);
}
int __stdcall RUN(int *output_on, int *error_on, int *log_on, int *selected_on)
void __stdcall SETSELECTEDOUTPUTON(int *selected_on)
{
return RunF(output_on, error_on, log_on, selected_on);
SetSelectedOutputOnF(selected_on);
}
int __stdcall RUNFILE(char *filename, unsigned int len, int *output_on, int *error_on, int *log_on, int *selected_on)
void __stdcall SETOUTPUTON(int *output_on)
{
return RunFileF(output_on, error_on, log_on, selected_on, filename, len);
SetOutputOnF(output_on);
}
void __stdcall SETERRORON(int *error_on)
{
SetErrorOnF(error_on);
}
void __stdcall SETLOGON(int *log_on)
{
SetLogOnF(log_on);
}
int __stdcall RUN(void)
{
return RunF();
}
int __stdcall RUNFILE(char *filename, unsigned int len)
{
return RunFileF(filename, len);
}
int __stdcall RUNSTRING(char *input, unsigned int len)
{
return RunStringF(input, len);
}
void __stdcall OUTPUTLINES(void)
{

View File

@ -11,15 +11,26 @@ extern "C" {
VRESULT AccumulateLineF(char *line, unsigned int line_length);
int RunF(int* output_on, int* error_on, int* log_on, int* selected_output_on);
int RunF(void);
int RunFileF(char* filename, unsigned int filename_length);
int RunStringF(char* input, unsigned int input_length);
int RunFileF(int* output_on, int* error_on, int* log_on, int* selected_output_on, char* filename, unsigned int filename_length);
int GetSelectedOutputRowCountF(void);
int GetSelectedOutputColumnCountF(void);
VRESULT GetSelectedOutputValueF(int *row, int *col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length);
void SetSelectedOutputOnF(int* selected_output_on);
void SetOutputOnF(int* output_on);
void SetErrorOnF(int* error_on);
void SetLogOnF(int* error_on);
void OutputLastErrorF(void);
void OutputLinesF(void);

View File

@ -22,13 +22,33 @@ int ACCUMULATELINE(char *line, unsigned int len)
{
return AccumulateLineF(line, len);
}
int RUN(int *output_on, int *error_on, int *log_on, int *selected_on)
void SETSELECTEDOUTPUTON(int *selected_on)
{
return RunF(output_on, error_on, log_on, selected_on);
SetSelectedOutputOnF(selected_on);
}
int RUNFILE(char *filename, unsigned int len, int *output_on, int *error_on, int *log_on, int *selected_on)
void SETOUTPUTON(int *output_on)
{
return RunFileF(output_on, error_on, log_on, selected_on, filename, len);
SetOutputOnF(output_on);
}
void SETERRORON(int *error_on)
{
SetErrorOnF(error_on);
}
void SETLOGON(int *log_on)
{
SetLogOnF(log_on);
}
int RUN(void)
{
return RunF();
}
int RUNFILE(char *filename, unsigned int len)
{
return RunFileF(filename, len);
}
int RUNSTRING(char *input, unsigned int len)
{
return RunFileF(input, len);
}
void OUTPUTLINES(void)
{

View File

@ -22,13 +22,33 @@ int accumulateline_(char *line, unsigned int len)
{
return AccumulateLineF(line, len);
}
int run_(int *output_on, int *error_on, int *log_on, int *selected_on)
void setselectedoutputon_(int *selected_on)
{
return RunF(output_on, error_on, log_on, selected_on);
SetSelectedOutputOnF(selected_on);
}
int runfile_(char *filename, unsigned int len, int *output_on, int *error_on, int *log_on, int *selected_on)
void setoutputon_(int *output_on)
{
return RunFileF(output_on, error_on, log_on, selected_on, filename, len);
SetOutputOnF(output_on);
}
void seterroron_(int *error_on)
{
SetErrorOnF(error_on);
}
void setlogon_(int *log_on)
{
SetLogOnF(log_on);
}
int run_(void)
{
return RunF();
}
int runfile_(char *filename, unsigned int len)
{
return RunFileF(filename, len);
}
int runstring_(char *input, unsigned int len)
{
return RunFileF(input, len);
}
void outputlines_(void)
{

View File

@ -23,7 +23,11 @@
CALL EQUILIBRIUM_PHASES('calcite', 0.0, 0.010)
CALL USER_PUNCH('Ca', 10)
!!!! CALL OutputLines
iresult = Run(.FALSE., .FALSE., .FALSE., .TRUE.)
CALL SetOutputOn(.FALSE.)
CALL SetErrorOn(.FALSE.)
CALL SetLogOn(.FALSE.)
CALL SetSelectedOutputOn(.TRUE.)
iresult = Run()
IF (iresult.NE.VR_OK) THEN
CALL OutputLastError
STOP

View File

@ -14,8 +14,11 @@
!! iresult= Runfile('CO2test',
!! & .true.,.true.,.true.,.true.)
iresult= Runfile('tester',
& .true.,.true.,.true.,.true.)
CALL SetOutputOn(.TRUE.)
CALL SetErrorOn(.TRUE.)
CALL SetLogOn(.TRUE.)
CALL SetSelectedOutputOn(.TRUE.)
iresult= Runfile('tester')
IF (iresult.NE.VR_OK) THEN
CALL OutputLastError

View File

@ -171,7 +171,11 @@ void TestInterface::TestRun()
int files_on = 0;
CPPUNIT_ASSERT_EQUAL(0, ::LoadDatabase("phreeqc.dat"));
CPPUNIT_ASSERT_EQUAL(VR_OK, ::AccumulateLine("solution 12"));
CPPUNIT_ASSERT_EQUAL(0, ::Run(files_on, files_on, files_on, files_on));
::SetOutputOn(files_on);
::SetErrorOn(files_on);
::SetLogOn(files_on);
::SetSelectedOutputOn(files_on);
CPPUNIT_ASSERT_EQUAL(0, ::Run());
}
void TestInterface::TestRunWithErrors()
@ -197,8 +201,12 @@ void TestInterface::TestRunWithErrors()
CPPUNIT_ASSERT_EQUAL(VR_OK, ::AccumulateLine("EQUILIBRIUM_PHASES"));
CPPUNIT_ASSERT_EQUAL(VR_OK, ::AccumulateLine(" Fix_H+ -10 HCl 10"));
CPPUNIT_ASSERT_EQUAL(VR_OK, ::AccumulateLine("END"));
CPPUNIT_ASSERT_EQUAL(1, ::Run(files_on, files_on, files_on, files_on));
::SetOutputOn(files_on);
::SetErrorOn(files_on);
::SetLogOn(files_on);
::SetSelectedOutputOn(files_on);
CPPUNIT_ASSERT_EQUAL(1, ::Run());
const char expected[] =
"ERROR: Numerical method failed on all combinations of convergence parameters\n"
@ -226,7 +234,11 @@ void TestInterface::TestRunFile()
CPPUNIT_ASSERT_EQUAL(0, ::LoadDatabase("phreeqc.dat"));
CPPUNIT_ASSERT_EQUAL(1, ::RunFile("conv_fail.in", 0, 0, 0, 0));
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(0);
CPPUNIT_ASSERT_EQUAL(1, ::RunFile("conv_fail.in"));
const char expected[] =
"ERROR: Numerical method failed on all combinations of convergence parameters\n"
@ -248,7 +260,12 @@ void TestInterface::TestGetSelectedOutputRowCount()
CPPUNIT_ASSERT_EQUAL(VR_OK, SOLUTION(1.0, 1.0, 1.0));
CPPUNIT_ASSERT_EQUAL(VR_OK, EQUILIBRIUM_PHASES("calcite", 0.0, 0.010));
CPPUNIT_ASSERT_EQUAL(VR_OK, USER_PUNCH("Ca", max));
CPPUNIT_ASSERT_EQUAL(0, ::Run(0, 0, 0, 1));
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(1);
CPPUNIT_ASSERT_EQUAL(0, ::Run());
//// CPPUNIT_ASSERT_EQUAL(0, ::Run(1, 1, 1, 1));
CPPUNIT_ASSERT_EQUAL(3, ::GetSelectedOutputRowCount()); // rows + header
@ -265,7 +282,11 @@ void TestInterface::TestGetSelectedOutputValue()
CPPUNIT_ASSERT_EQUAL(VR_OK, SOLUTION(1.0, 1.0, 1.0));
CPPUNIT_ASSERT_EQUAL(VR_OK, EQUILIBRIUM_PHASES("calcite", 0.0, 0.010));
CPPUNIT_ASSERT_EQUAL(VR_OK, USER_PUNCH("Ca", max));
CPPUNIT_ASSERT_EQUAL(0, ::Run(0, 0, 0, 0));
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(0);
CPPUNIT_ASSERT_EQUAL(0, ::Run());
/*
EXPECTED selected.out:
@ -919,7 +940,11 @@ void TestInterface::TestRunWithCallback()
void TestInterface::TestRunNoDatabaseLoaded()
{
UnLoadDatabase();
CPPUNIT_ASSERT_EQUAL( 1, ::Run(0, 0, 0, 0) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(0);
CPPUNIT_ASSERT_EQUAL( 1, ::Run() );
const char expected[] =
"ERROR: Run: No database is loaded\n"
@ -932,7 +957,11 @@ void TestInterface::TestRunNoDatabaseLoaded()
void TestInterface::TestRunFileNoDatabaseLoaded()
{
UnLoadDatabase();
CPPUNIT_ASSERT_EQUAL( 1, ::RunFile("dummy", 0, 0, 0, 0) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(0);
CPPUNIT_ASSERT_EQUAL( 1, ::RunFile("dummy") );
const char expected[] =
"ERROR: RunFile: No database is loaded\n"
@ -966,12 +995,20 @@ void TestInterface::TestCase1()
CPPUNIT_ASSERT_EQUAL( VR_OK, SOLUTION(1.0, 1.0, 1.0) );
CPPUNIT_ASSERT_EQUAL( VR_OK, USER_PUNCH("Ca", 10) );
CPPUNIT_ASSERT_EQUAL( 0, ::Run(0, 0, 0, 1) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(1);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( (bool)true, ::FileExists("selected.out") );
CPPUNIT_ASSERT_EQUAL( 62, ::GetSelectedOutputColumnCount() );
CPPUNIT_ASSERT_EQUAL( VR_OK, SOLUTION(1.0, 1.0, 1.0) );
CPPUNIT_ASSERT_EQUAL( 0, ::Run(0, 0, 0, 1) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(1);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( (bool)true, ::FileExists("selected.out") );
CPPUNIT_ASSERT_EQUAL( 62, ::GetSelectedOutputColumnCount() );
}
@ -1005,7 +1042,11 @@ void TestInterface::TestCase2()
CPPUNIT_ASSERT_EQUAL( VR_OK, SOLUTION(1.0, 1.0, 1.0) );
CPPUNIT_ASSERT_EQUAL( VR_OK, USER_PUNCH("Ca", 10) );
CPPUNIT_ASSERT_EQUAL( VR_OK, ::AccumulateLine("-file case2.punch") ); // force have_punch_name to TRUE (see read_selected_ouput)
CPPUNIT_ASSERT_EQUAL( 0, ::Run(0, 0, 0, 1) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(1);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( (bool)false, ::FileExists("selected.out") );
CPPUNIT_ASSERT_EQUAL( (bool)true, ::FileExists("case2.punch") );
CPPUNIT_ASSERT_EQUAL( 62, ::GetSelectedOutputColumnCount() );
@ -1026,7 +1067,11 @@ void TestInterface::TestCase2()
CPPUNIT_ASSERT_EQUAL( VR_OK, SOLUTION(1.0, 1.0, 1.0) );
CPPUNIT_ASSERT_EQUAL( VR_OK, USER_PUNCH("Ca", 10) );
CPPUNIT_ASSERT_EQUAL( 0, ::Run(0, 0, 0, 1) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(1);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( (bool)false, ::FileExists("selected.out") );
CPPUNIT_ASSERT_EQUAL( (bool)true, ::FileExists("case2.punch") );
CPPUNIT_ASSERT_EQUAL( 62, ::GetSelectedOutputColumnCount() );
@ -1066,7 +1111,11 @@ void TestInterface::TestPrintSelectedOutputFalse()
CPPUNIT_ASSERT_EQUAL( VR_OK, ::AccumulateLine("PRINT; -selected_output false \n") );
// run
CPPUNIT_ASSERT_EQUAL( 0, ::Run(0, 0, 0, 1) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(1);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( 0, ::GetSelectedOutputColumnCount() );
CPPUNIT_ASSERT_EQUAL( 0, ::GetSelectedOutputRowCount() );
@ -1088,7 +1137,11 @@ void TestInterface::TestPrintSelectedOutputFalse()
}
// run
CPPUNIT_ASSERT_EQUAL( 0, ::Run(0, 0, 0, 1) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(1);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( 11, ::GetSelectedOutputColumnCount() );
CPPUNIT_ASSERT_EQUAL( 2, ::GetSelectedOutputRowCount() );
@ -1254,7 +1307,11 @@ void TestOnOff(const char* FILENAME, int output_on, int error_on, int log_on, in
}
// run all off
CPPUNIT_ASSERT_EQUAL( 0, ::Run(0, 0, 0, 0) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(0);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( (bool)false, ::FileExists(FILENAME) );
@ -1274,7 +1331,11 @@ void TestOnOff(const char* FILENAME, int output_on, int error_on, int log_on, in
}
// run
CPPUNIT_ASSERT_EQUAL( 0, ::Run(output_on, error_on, log_on, selected_output_on) );
::SetOutputOn(output_on);
::SetErrorOn(error_on);
::SetLogOn(log_on);
::SetSelectedOutputOn(selected_output_on);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( (bool)true, ::FileExists(FILENAME) );
CPPUNIT_ASSERT( ::DeleteFile(FILENAME) );
@ -1295,7 +1356,11 @@ void TestOnOff(const char* FILENAME, int output_on, int error_on, int log_on, in
}
// run
CPPUNIT_ASSERT_EQUAL( 0, ::Run(0, 0, 0, 0) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(0);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( (bool)false, ::FileExists(FILENAME) );
CPPUNIT_ASSERT_EQUAL( 0, ::LoadDatabase("phreeqc.dat") );
@ -1313,7 +1378,11 @@ void TestOnOff(const char* FILENAME, int output_on, int error_on, int log_on, in
}
// run
CPPUNIT_ASSERT_EQUAL( 0, ::Run(output_on, error_on, log_on, selected_output_on) );
::SetOutputOn(output_on);
::SetErrorOn(error_on);
::SetLogOn(log_on);
::SetSelectedOutputOn(selected_output_on);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( (bool)true, ::FileExists(FILENAME) );
CPPUNIT_ASSERT( ::DeleteFile(FILENAME) );
}
@ -1339,7 +1408,11 @@ TestInterface::TestLongHeadings()
oss << "-end" << "\n";
CPPUNIT_ASSERT_EQUAL( VR_OK, ::AccumulateLine(oss.str().c_str()) );
CPPUNIT_ASSERT_EQUAL( 0, ::Run(0, 0, 0, 0) );
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(0);
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL(2, ::GetSelectedOutputRowCount());
CPPUNIT_ASSERT_EQUAL(1, ::GetSelectedOutputColumnCount());

View File

@ -136,7 +136,7 @@
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="&quot;$(DEV_CPPUNIT_1.10)/include&quot;;../include;../src;../src/phreeqcpp;../src/phreeqcpp/phreeqc"
PreprocessorDefinitions="SWIG_SHARED_OBJ;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
PreprocessorDefinitions="SWIG_SHARED_OBJ;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;PHREEQC_CPP;PHREEQC_CLASS;USE_PHRQ_ALLOC"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
@ -478,40 +478,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\global.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
<FileConfiguration
Name="MemDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\IPhreeqc.cpp"
>