From dd058e3bec3f8975979777ee24b8769dd94cdb46 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 25 Aug 2020 12:17:54 -0600 Subject: [PATCH] implemented Get/SetErrorOn --- IPhreeqc.cpp | 15 ++++++++++++++ IPhreeqc.f.inc | 2 ++ IPhreeqc.f90.inc | 17 ++++++++++++++++ IPhreeqc.h | 44 ++++++++++++++++++++++++++++++++++++++++ IPhreeqc.hpp | 19 ++++++++++++++++- IPhreeqcF.f | 21 +++++++++++++++++++ IPhreeqcLib.cpp | 30 +++++++++++++++++++++++++++ IPhreeqc_interface.F90 | 36 ++++++++++++++++++++++++++++++++ IPhreeqc_interface_F.cpp | 12 +++++++++++ IPhreeqc_interface_F.h | 4 ++++ fimpl.h | 8 ++++++++ fwrap.cpp | 12 +++++++++++ fwrap.h | 4 ++++ 13 files changed, 223 insertions(+), 1 deletion(-) diff --git a/IPhreeqc.cpp b/IPhreeqc.cpp index b24c4cb2..426465f5 100644 --- a/IPhreeqc.cpp +++ b/IPhreeqc.cpp @@ -213,9 +213,19 @@ bool IPhreeqc::GetErrorFileOn(void)const return this->ErrorFileOn; } +bool IPhreeqc::GetErrorOn(void)const +{ + return this->Get_error_on(); +} + const char* IPhreeqc::GetErrorString(void) { static const char err_msg[] = "GetErrorString: ErrorStringOn not set.\n"; + static const char err_msg2[] = "GetErrorString: ErrorOn not set.\n"; + if (!this->error_on) + { + return err_msg2; + } if (!this->ErrorStringOn) { return err_msg; @@ -973,6 +983,11 @@ void IPhreeqc::SetErrorFileOn(bool bValue) this->ErrorFileOn = bValue; } +void IPhreeqc::SetErrorOn(bool bValue) +{ + this->Set_error_on(bValue); +} + void IPhreeqc::SetErrorStringOn(bool bValue) { this->ErrorStringOn = bValue; diff --git a/IPhreeqc.f.inc b/IPhreeqc.f.inc index 97ead48c..ebe942f8 100644 --- a/IPhreeqc.f.inc +++ b/IPhreeqc.f.inc @@ -54,6 +54,7 @@ INTEGER(KIND=4) GetDumpStringLineCount LOGICAL(KIND=4) GetDumpStringOn LOGICAL(KIND=4) GetErrorFileOn + LOGICAL(KIND=4) GetErrorOn INTEGER(KIND=4) GetErrorStringLine INTEGER(KIND=4) GetErrorStringLineCount LOGICAL(KIND=4) GetLogFileOn @@ -78,6 +79,7 @@ INTEGER(KIND=4) SetDumpFileOn INTEGER(KIND=4) SetDumpStringOn INTEGER(KIND=4) SetErrorFileOn + INTEGER(KIND=4) SetErrorOn INTEGER(KIND=4) SetErrorStringOn INTEGER(KIND=4) SetLogFileName INTEGER(KIND=4) SetLogFileOn diff --git a/IPhreeqc.f90.inc b/IPhreeqc.f90.inc index 1d6d2ade..77cc6a35 100644 --- a/IPhreeqc.f90.inc +++ b/IPhreeqc.f90.inc @@ -147,6 +147,14 @@ END INTERFACE + INTERFACE + FUNCTION GetErrorOn(ID) + INTEGER(KIND=4), INTENT(IN) :: ID + LOGICAL(KIND=4) :: GetErrorOn + END FUNCTION GetErrorOn + END INTERFACE + + INTERFACE SUBROUTINE GetErrorStringLine(ID,N,LINE) INTEGER(KIND=4), INTENT(IN) :: ID @@ -496,6 +504,15 @@ END INTERFACE + INTERFACE + FUNCTION SetErrorOn(ID,ERR_ON) + INTEGER(KIND=4), INTENT(IN) :: ID + LOGICAL(KIND=4), INTENT(IN) :: ERR_ON + INTEGER(KIND=4) :: SetErrorOn + END FUNCTION SetErrorOn + END INTERFACE + + INTERFACE FUNCTION SetErrorStringOn(ID,ERR_STRING_ON) INTEGER(KIND=4), INTENT(IN) :: ID diff --git a/IPhreeqc.h b/IPhreeqc.h index cf60f878..93adac90 100644 --- a/IPhreeqc.h +++ b/IPhreeqc.h @@ -433,6 +433,25 @@ extern "C" { */ IPQ_DLL_EXPORT int GetErrorFileOn(int id); +/** + * Retrieves the current value of the error on switch. + * @param id The instance id returned from @ref CreateIPhreeqc. + * @return Non-zero if errors are generated, 0 (zero) otherwise. + * @see SetErrorOn + * @par Fortran90 Interface: + * @htmlonly + * + *
+ *  FUNCTION GetErrorOn(ID)
+ *    INTEGER(KIND=4),  INTENT(IN)  :: ID
+ *    LOGICAL(KIND=4)               :: GetErrorOn
+ *  END FUNCTION GetErrorOn
+ *  
+ *
+ * @endhtmlonly + */ + IPQ_DLL_EXPORT int GetErrorOn(int id); + /** * Retrieves the error messages from the last call to @ref RunAccumulated, @ref RunFile, @ref RunString, @ref LoadDatabase, or @ref LoadDatabaseString. @@ -1852,6 +1871,31 @@ Headings */ IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileOn(int id, int error_on); +/** + * Sets the error switch on or off. This switch controls whether or not + * error messages are generated and displayed. The initial setting after calling + * @ref CreateIPhreeqc is on. + * @param id The instance id returned from @ref CreateIPhreeqc. + * @param error_on If non-zero, writes errors to the error file and error string; if zero, no errors are written to the error file or stored in the error string. + * @retval IPQ_OK Success. + * @retval IPQ_BADINSTANCE The given id is invalid. + * @see GetErrorOn, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString + * @par Fortran90 Interface: + * @htmlonly + * + *
+ *  FUNCTION SetErrorOn(ID,ERR_ON)
+ *    INTEGER(KIND=4),  INTENT(IN)  :: ID
+ *    LOGICAL(KIND=4),  INTENT(IN)  :: ERR_ON
+ *    INTEGER(KIND=4)               :: SetErrorOn
+ *  END FUNCTION SetErrorOn
+ *  
+ *
+ * @endhtmlonly + */ + IPQ_DLL_EXPORT IPQ_RESULT SetErrorOn(int id, int error_on); + + /** * Sets the error string switch on or off. This switch controls whether or not the data normally sent * to the error file are stored in a buffer for retrieval. The initial setting after calling diff --git a/IPhreeqc.hpp b/IPhreeqc.hpp index c6111f30..ce668b40 100644 --- a/IPhreeqc.hpp +++ b/IPhreeqc.hpp @@ -193,6 +193,14 @@ public: */ bool GetErrorFileOn(void)const; + /** + * Retrieves the current value of the error switch. + * @retval true Error messages are sent to the error file and to the string buffer + * @retval false No errors are sent. + * @see SetErrorOn + */ + bool GetErrorOn(void)const; + /** * Retrieves the error messages from the last call to @ref RunAccumulated, @ref RunFile, @ref RunString, @ref LoadDatabase, or @ref LoadDatabaseString. * @return A null terminated string containing error messages. @@ -768,12 +776,21 @@ public: /** * Sets the error file switch on or off. This switch controls whether or not * error messages are written to the phreeqc.id.err (where id is obtained from @ref GetId) file. - * The initial setting is false. + * The initial setting is true. * @param bValue If true, writes errors to the error file; if false, no errors are written to the error file. * @see GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString */ void SetErrorFileOn(bool bValue); + /** + * Sets the error switch on or off. This switch controls whether + * error messages are are generated and displayed. + * The initial setting is true. + * @param bValue If true, error messages are sent to the error file and error string buffer; if false, no error messages are generated. + * @see GetErrorOn, GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString + */ + void SetErrorOn(bool bValue); + /** * Sets the error string switch on or off. This switch controls whether or not the data normally sent * to the error file are stored in a buffer for retrieval. The initial setting is true. diff --git a/IPhreeqcF.f b/IPhreeqcF.f index c5586dc6..856700ba 100644 --- a/IPhreeqcF.f +++ b/IPhreeqcF.f @@ -145,6 +145,18 @@ GetErrorFileOn = .TRUE. ENDIF END FUNCTION GetErrorFileOn +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + FUNCTION GetErrorOn(ID) + IMPLICIT NONE + INTEGER(KIND=4) :: ID + LOGICAL(KIND=4) :: GetErrorOn + INTEGER(KIND=4) :: GetErrorOnF + IF (GetErrorOnF(ID).EQ.0) THEN + GetErrorOn = .FALSE. + ELSE + GetErrorOn = .TRUE. + ENDIF + END FUNCTION GetErrorOn !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! GetErrorString !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -536,6 +548,15 @@ INTEGER(KIND=4) :: SetErrorFileOnF SetErrorFileOn = SetErrorFileOnF(ID,ERROR_ON) END FUNCTION SetErrorFileOn +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + FUNCTION SetErrorOn(ID,ERROR_ON) + IMPLICIT NONE + INTEGER(KIND=4) :: ID + LOGICAL(KIND=4) :: ERROR_ON + INTEGER(KIND=4) :: SetErrorOn + INTEGER(KIND=4) :: SetErrorOnF + SetErrorOn = SetErrorOnF(ID,ERROR_ON) + END FUNCTION SetErrorOn !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FUNCTION SetErrorStringOn(ID,ERROR_STRING_ON) IMPLICIT NONE diff --git a/IPhreeqcLib.cpp b/IPhreeqcLib.cpp index 2cd59d89..b57755ab 100644 --- a/IPhreeqcLib.cpp +++ b/IPhreeqcLib.cpp @@ -236,6 +236,24 @@ GetErrorFileOn(int id) return IPQ_BADINSTANCE; } +int +GetErrorOn(int id) +{ + IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); + if (IPhreeqcPtr) + { + if (IPhreeqcPtr->GetErrorOn()) + { + return 1; + } + else + { + return 0; + } + } + return IPQ_BADINSTANCE; +} + const char* GetErrorString(int id) { @@ -884,6 +902,18 @@ SetErrorFileOn(int id, int value) return IPQ_BADINSTANCE; } +IPQ_RESULT +SetErrorOn(int id, int value) +{ + IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); + if (IPhreeqcPtr) + { + IPhreeqcPtr->SetErrorOn(value != 0); + return IPQ_OK; + } + return IPQ_BADINSTANCE; +} + IPQ_RESULT SetErrorStringOn(int id, int value) { diff --git a/IPhreeqc_interface.F90 b/IPhreeqc_interface.F90 index 96ac3cf7..6c726c83 100644 --- a/IPhreeqc_interface.F90 +++ b/IPhreeqc_interface.F90 @@ -289,6 +289,22 @@ LOGICAL FUNCTION GetErrorFileOn(id) return END FUNCTION GetErrorFileOn +LOGICAL FUNCTION GetErrorOn(id) + USE ISO_C_BINDING + IMPLICIT NONE + INTERFACE + INTEGER(KIND=C_INT) FUNCTION GetErrorOnF(id) & + BIND(C, NAME='GetErrorOnF') + USE ISO_C_BINDING + IMPLICIT NONE + INTEGER(KIND=C_INT), INTENT(in) :: id + END FUNCTION GetErrorOnF + END INTERFACE + INTEGER, INTENT(in) :: id + GetErrorOn = (GetErrorOnF(id) .ne. 0) + return +END FUNCTION GetErrorOn + INTEGER FUNCTION GetErrorStringLineCount(id) USE ISO_C_BINDING IMPLICIT NONE @@ -1049,6 +1065,26 @@ INTEGER FUNCTION SetErrorFileOn(id, error_file_on) return END FUNCTION SetErrorFileOn +INTEGER FUNCTION SetErrorOn(id, error_on) + USE ISO_C_BINDING + IMPLICIT NONE + INTERFACE + INTEGER(KIND=C_INT) FUNCTION SetErrorOnF(id, error_on) & + BIND(C, NAME='SetErrorOnF') + USE ISO_C_BINDING + IMPLICIT NONE + INTEGER(KIND=C_INT), INTENT(in) :: id, error_on + END FUNCTION SetErrorOnF + END INTERFACE + INTEGER, INTENT(in) :: id + LOGICAL, INTENT(in) :: error_on + INTEGER :: tf = 0 + tf = 0 + if (error_on) tf = 1 + SetErrorOn = SetErrorOnF(id, tf) + return +END FUNCTION SetErrorOn + INTEGER FUNCTION SetErrorStringOn(id, error_string_on) USE ISO_C_BINDING IMPLICIT NONE diff --git a/IPhreeqc_interface_F.cpp b/IPhreeqc_interface_F.cpp index 8e406e82..ab1125de 100644 --- a/IPhreeqc_interface_F.cpp +++ b/IPhreeqc_interface_F.cpp @@ -145,6 +145,12 @@ GetErrorFileOnF(int *id) return ::GetErrorFileOn(*id); } +int +GetErrorOnF(int *id) +{ + return ::GetErrorOn(*id); +} + /* GetErrorStringF */ @@ -457,6 +463,12 @@ SetErrorFileOnF(int *id, int* error_file_on) return ::SetErrorFileOn(*id, *error_file_on); } +IPQ_RESULT +SetErrorOnF(int *id, int* error_on) +{ + return ::SetErrorOn(*id, *error_on); +} + IPQ_RESULT SetErrorStringOnF(int *id, int* error_string_on) { diff --git a/IPhreeqc_interface_F.h b/IPhreeqc_interface_F.h index 660dcd38..d1c3e2a3 100644 --- a/IPhreeqc_interface_F.h +++ b/IPhreeqc_interface_F.h @@ -25,6 +25,7 @@ #define GetDumpStringOnF FC_FUNC (getdumpstringonf, GETDUMPSTRINGONF) #define GetErrorFileNameF FC_FUNC (geterrorfilenamef, GETERRORFILENAMEF) #define GetErrorFileOnF FC_FUNC (geterrorfileonf, GETERRORFILEONF) +#define GetErrorOnF FC_FUNC (geterroronf, GETERRORONF) #define GetErrorStringLineF FC_FUNC (geterrorstringlinef, GETERRORSTRINGLINEF) #define GetErrorStringLineCountF FC_FUNC (geterrorstringlinecountf, GETERRORSTRINGLINECOUNTF) #define GetErrorStringOnF FC_FUNC (geterrorstringonf, GETERRORSTRINGONF) @@ -66,6 +67,7 @@ #define SetDumpStringOnF FC_FUNC (setdumpstringonf, SETDUMPSTRINGONF) #define SetErrorFileNameF FC_FUNC (seterrorfilenamef, SETERRORFILENAMEF) #define SetErrorFileOnF FC_FUNC (seterrorfileonf, SETERRORFILEONF) +#define SetErrorOnF FC_FUNC (seterroronf, SETERRORONF) #define SetErrorStringOnF FC_FUNC (seterrorstringonf, SETERRORSTRINGONF) #define SetLogFileNameF FC_FUNC (setlogfilenamef, SETLOGFILENAMEF) #define SetLogFileOnF FC_FUNC (setlogfileonf, SETLOGFILEONF) @@ -99,6 +101,7 @@ extern "C" { IPQ_DLL_EXPORT int GetDumpStringOnF(int *id); IPQ_DLL_EXPORT void GetErrorFileNameF(int *id, char* filename, int* filename_length); IPQ_DLL_EXPORT int GetErrorFileOnF(int *id); + IPQ_DLL_EXPORT int GetErrorOnF(int *id); IPQ_DLL_EXPORT void GetErrorStringLineF(int *id, int* n, char* line, int* line_length); IPQ_DLL_EXPORT int GetErrorStringLineCountF(int *id); IPQ_DLL_EXPORT int GetErrorStringOnF(int *id); @@ -144,6 +147,7 @@ extern "C" { IPQ_DLL_EXPORT IPQ_RESULT SetDumpStringOnF(int *id, int* dump_string_on); IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileNameF(int *id, char* fname); IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileOnF(int *id, int* error_file_on); + IPQ_DLL_EXPORT IPQ_RESULT SetErrorOnF(int *id, int* error_on); IPQ_DLL_EXPORT IPQ_RESULT SetErrorStringOnF(int *id, int* error_string_on); IPQ_DLL_EXPORT IPQ_RESULT SetLogFileNameF(int *id, char* fname); IPQ_DLL_EXPORT IPQ_RESULT SetLogFileOnF(int *id, int* log_file_on); diff --git a/fimpl.h b/fimpl.h index e01095f6..de9eb214 100644 --- a/fimpl.h +++ b/fimpl.h @@ -63,6 +63,10 @@ IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(geterrorfileon, GETERRORFILEON, geterr { return GetErrorFileOnF(id); } +IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(geterroron, GETERRORON, geterroron_, GETERRORON_)(int *id) +{ + return GetErrorOnF(id); +} // GetErrorString IPQ_DLL_EXPORT void IPQ_DECL IPQ_CASE_UND(geterrorstringline, GETERRORSTRINGLINE, geterrorstringline_, GETERRORSTRINGLINE_)(int *id, int *n, char* line, size_t line_length) { @@ -232,6 +236,10 @@ IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(seterrorfileon, SETERRORFILEON, seterr { return SetErrorFileOnF(id, error_on); } +IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(seterroron, SETERRORON, seterroron_, SETERRORON_)(int *id, int *error_on) +{ + return SetErrorOnF(id, error_on); +} IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(seterrorstringon, SETERRORSTRINGON, seterrorstringon_, SETERRORSTRINGON_)(int *id, int *error_string_on) { return SetErrorStringOnF(id, error_string_on); diff --git a/fwrap.cpp b/fwrap.cpp index ae23e5dd..2c096f93 100644 --- a/fwrap.cpp +++ b/fwrap.cpp @@ -174,6 +174,12 @@ GetErrorFileOnF(int *id) return ::GetErrorFileOn(*id); } +int +GetErrorOnF(int *id) +{ + return ::GetErrorOn(*id); +} + /* GetErrorStringF */ @@ -539,6 +545,12 @@ SetErrorFileOnF(int *id, int* error_file_on) return ::SetErrorFileOn(*id, *error_file_on); } +IPQ_RESULT +SetErrorOnF(int *id, int* error_on) +{ + return ::SetErrorOn(*id, *error_on); +} + IPQ_RESULT SetErrorStringOnF(int *id, int* error_string_on) { diff --git a/fwrap.h b/fwrap.h index 0f2740f5..c95758d0 100644 --- a/fwrap.h +++ b/fwrap.h @@ -25,6 +25,7 @@ #define GetDumpStringOnF FC_FUNC (getdumpstringonf, GETDUMPSTRINGONF) #define GetErrorFileNameF FC_FUNC (geterrorfilenamef, GETERRORFILENAMEF) #define GetErrorFileOnF FC_FUNC (geterrorfileonf, GETERRORFILEONF) +#define GetErrorOnF FC_FUNC (geterroronf, GETERRORONF) #define GetErrorStringLineF FC_FUNC (geterrorstringlinef, GETERRORSTRINGLINEF) #define GetErrorStringLineCountF FC_FUNC (geterrorstringlinecountf, GETERRORSTRINGLINECOUNTF) #define GetErrorStringOnF FC_FUNC (geterrorstringonf, GETERRORSTRINGONF) @@ -66,6 +67,7 @@ #define SetDumpStringOnF FC_FUNC (setdumpstringonf, SETDUMPSTRINGONF) #define SetErrorFileNameF FC_FUNC (seterrorfilenamef, SETERRORFILENAMEF) #define SetErrorFileOnF FC_FUNC (seterrorfileonf, SETERRORFILEONF) +#define SetErrorOnF FC_FUNC (seterroronf, SETERRORONF) #define SetErrorStringOnF FC_FUNC (seterrorstringonf, SETERRORSTRINGONF) #define SetLogFileNameF FC_FUNC (setlogfilenamef, SETLOGFILENAMEF) #define SetLogFileOnF FC_FUNC (setlogfileonf, SETLOGFILEONF) @@ -98,6 +100,7 @@ extern "C" { int GetDumpStringOnF(int *id); void GetErrorFileNameF(int *id, char* filename, size_t filename_length); int GetErrorFileOnF(int *id); + int GetErrorOnF(int *id); void GetErrorStringLineF(int *id, int* n, char* line, size_t line_length); int GetErrorStringLineCountF(int *id); int GetErrorStringOnF(int *id); @@ -139,6 +142,7 @@ extern "C" { IPQ_RESULT SetDumpStringOnF(int *id, int* dump_string_on); IPQ_RESULT SetErrorFileNameF(int *id, char* fname, size_t fname_length); IPQ_RESULT SetErrorFileOnF(int *id, int* error_file_on); + IPQ_RESULT SetErrorOnF(int *id, int* error_on); IPQ_RESULT SetErrorStringOnF(int *id, int* error_string_on); IPQ_RESULT SetLogFileNameF(int *id, char* fname, size_t fname_length); IPQ_RESULT SetLogFileOnF(int *id, int* log_file_on);