diff --git a/doc/TOC.hhc b/doc/TOC.hhc index 4b1d9543..d2f9bd0e 100644 --- a/doc/TOC.hhc +++ b/doc/TOC.hhc @@ -39,6 +39,10 @@ +
  • + + +
  • diff --git a/include/IPhreeqc.f.inc b/include/IPhreeqc.f.inc index dd22d9c4..fa70bc62 100644 --- a/include/IPhreeqc.f.inc +++ b/include/IPhreeqc.f.inc @@ -43,6 +43,8 @@ C function prototypes C INTEGER(KIND=4) AccumulateLine + INTEGER(KIND=4) AddError + INTEGER(KIND=4) AddWarning INTEGER(KIND=4) CreateIPhreeqc INTEGER(KIND=4) DestroyIPhreeqc INTEGER(KIND=4) GetComponentCount @@ -63,8 +65,8 @@ C INTEGER(KIND=4) GetWarningStringLineCount INTEGER(KIND=4) LoadDatabase INTEGER(KIND=4) LoadDatabaseString - INTEGER(KIND=4) OutputLastError - INTEGER(KIND=4) OutputLastWarning + INTEGER(KIND=4) OutputErrorString + INTEGER(KIND=4) OutputWarningString INTEGER(KIND=4) OutputAccumulatedLines INTEGER(KIND=4) RunAccumulated INTEGER(KIND=4) RunFile diff --git a/include/IPhreeqc.f90.inc b/include/IPhreeqc.f90.inc index 8358d693..9f9a30cb 100644 --- a/include/IPhreeqc.f90.inc +++ b/include/IPhreeqc.f90.inc @@ -24,6 +24,24 @@ END INTERFACE + INTERFACE + FUNCTION AddError(ID,ERROR_MSG) + INTEGER(KIND=4), INTENT(IN) :: ID + CHARACTER(LEN=*), INTENT(IN) :: ERROR_MSG + INTEGER(KIND=4) :: AddError + END FUNCTION AddError + END INTERFACE + + + INTERFACE + FUNCTION AddWarning(ID,WARN_MSG) + INTEGER(KIND=4), INTENT(IN) :: ID + CHARACTER(LEN=*), INTENT(IN) :: WARN_MSG + INTEGER(KIND=4) :: AddWarning + END FUNCTION AddWarning + END INTERFACE + + INTERFACE FUNCTION CreateIPhreeqc() INTEGER(KIND=4) :: CreateIPhreeqc @@ -209,7 +227,11 @@ END INTERFACE - !!! TODO OutputWarningString + INTERFACE + SUBROUTINE OutputWarningString(ID) + INTEGER(KIND=4), INTENT(IN) :: ID + END SUBROUTINE OutputWarningString + END INTERFACE INTERFACE diff --git a/include/IPhreeqc.h b/include/IPhreeqc.h index e9d1f614..f44c18e8 100644 --- a/include/IPhreeqc.h +++ b/include/IPhreeqc.h @@ -60,12 +60,43 @@ extern "C" { * @returns The current error count if successful; otherwise a negative value indicates an error occured (see \ref IPQ_RESULT). * @par Fortran90 Interface: * @htmlonly - * Not implemented. + * + *
    + *  FUNCTION AddError(ID,ERROR_MSG)
    + *    INTEGER(KIND=4),  INTENT(IN) :: ID
    + *    CHARACTER(LEN=*), INTENT(IN) :: ERROR_MSG
    + *    INTEGER(KIND=4)              :: AddError
    + *  END FUNCTION AddError
    + *  
    + *
    * @endhtmlonly */ IPQ_DLL_EXPORT int AddError(int id, const char* error_msg); +/** + * Appends the given warning message and increments the warning count. + * Internally used to create a warning condition. + * @param id The instance id returned from \ref CreateIPhreeqc. + * @param error_msg The warning message to display. + * @returns The current warning count if successful; otherwise a negative value indicates an error occured (see \ref IPQ_RESULT). + * @par Fortran90 Interface: + * @htmlonly + * + *
    + *  FUNCTION AddWarning(ID,WARN_MSG)
    + *    INTEGER(KIND=4),  INTENT(IN) :: ID
    + *    CHARACTER(LEN=*), INTENT(IN) :: WARN_MSG
    + *    INTEGER(KIND=4)              :: AddWarning
    + *  END FUNCTION AddWarning
    + *  
    + *
    + * @endhtmlonly + */ + IPQ_DLL_EXPORT int AddWarning(int id, const char* warn_msg); + + + /** * Clears the accumulated input buffer. Input buffer is accumulated from calls to \ref AccumulateLine. * @retval IPQ_OK Success. diff --git a/src/IPhreeqcF.f b/src/IPhreeqcF.f index aaa61f9a..42d5aed0 100644 --- a/src/IPhreeqcF.f +++ b/src/IPhreeqcF.f @@ -8,7 +8,23 @@ AccumulateLine = AccumulateLineF(ID,LINE) END FUNCTION AccumulateLine !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! AddError + FUNCTION AddError(ID,ERROR_MSG) + IMPLICIT NONE + INTEGER(KIND=4) :: ID + CHARACTER(LEN=*) :: ERROR_MSG + INTEGER(KIND=4) :: AddError + INTEGER(KIND=4) :: AddErrorF + AddError = AddErrorF(ID,LINE) + END FUNCTION AddError +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + FUNCTION AddWarning(ID,WARN_MSG) + IMPLICIT NONE + INTEGER(KIND=4) :: ID + CHARACTER(LEN=*) :: WARN_MSG + INTEGER(KIND=4) :: AddWarning + INTEGER(KIND=4) :: AddWarningF + AddWarning = AddWarningF(ID,WARN_MSG) + END FUNCTION AddWarning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FUNCTION ClearAccumulatedLines(ID) IMPLICIT NONE diff --git a/src/IPhreeqcLib.cpp b/src/IPhreeqcLib.cpp index 790964cc..d892bdd6 100644 --- a/src/IPhreeqcLib.cpp +++ b/src/IPhreeqcLib.cpp @@ -47,7 +47,16 @@ AddError(int id, const char* error_msg) return IPQ_BADINSTANCE; } -// TODO AddWarning +int +AddWarning(int id, const char* warn_msg) +{ + IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); + if (IPhreeqcPtr) + { + return (int)IPhreeqcPtr->AddWarning(warn_msg); + } + return IPQ_BADINSTANCE; +} IPQ_RESULT ClearAccumulatedLines(int id) diff --git a/src/fwrap.cpp b/src/fwrap.cpp index 15844d5c..e11dee24 100644 --- a/src/fwrap.cpp +++ b/src/fwrap.cpp @@ -54,9 +54,41 @@ AccumulateLineF(int *id, char *line, unsigned int line_length) return n; } -/* -AddErrorF -*/ +int +AddErrorF(int *id, char *error_msg, unsigned int len) +{ + int n; + char* cmsg; + + cmsg = f2cstring(error_msg, len); + if (!cmsg) + { + ::AddError(*id, "AddError: Out of memory.\n"); + return IPQ_OUTOFMEMORY; + } + + n = ::AddError(*id, cmsg); + free(cmsg); + return n; +} + +int +AddWarningF(int *id, char *warn_msg, unsigned int len) +{ + int n; + char* cmsg; + + cmsg = f2cstring(warn_msg, len); + if (!cmsg) + { + ::AddError(*id, "AddWarning: Out of memory.\n"); + return IPQ_OUTOFMEMORY; + } + + n = ::AddWarning(*id, cmsg); + free(cmsg); + return n; +} IPQ_RESULT ClearAccumulatedLinesF(int *id) @@ -379,7 +411,14 @@ IPQ_DLL_EXPORT int __stdcall ACCUMULATELINE(int *id, char *line, unsigned int l { return AccumulateLineF(id, line, len); } -// AddError +IPQ_DLL_EXPORT int __stdcall ADDERROR(int *id, char *error_msg, unsigned int len) +{ + return AddErrorF(id, error_msg, len); +} +IPQ_DLL_EXPORT int __stdcall ADDWARNING(int *id, char *warn_msg, unsigned int len) +{ + return AddWarningF(id, warn_msg, len); +} IPQ_DLL_EXPORT int __stdcall CLEARACCUMULATEDLINES(int *id) { return ClearAccumulatedLinesF(id); diff --git a/src/fwrap.h b/src/fwrap.h index 2f2ad23f..7ece9cd7 100644 --- a/src/fwrap.h +++ b/src/fwrap.h @@ -9,6 +9,8 @@ #if defined(FC_FUNC) #define AccumulateLineF FC_FUNC (accumulatelinef, ACCUMULATELINEF) +#define AddErrorF FC_FUNC (adderrorf, ADDERRORF) +#define AddWarningF FC_FUNC (addwarningf, ADDWARNINGF) #define ClearAccumulatedLinesF FC_FUNC (clearaccumulatedlinesf, CLEARACCUMULATEDLINESF) #define CreateIPhreeqcF FC_FUNC (createiphreeqcf, CREATEIPHREEQCF) #define DestroyIPhreeqcF FC_FUNC (destroyiphreeqcf, DESTROYIPHREEQCF) @@ -51,6 +53,8 @@ extern "C" { #endif IPQ_RESULT AccumulateLineF(int *id, char *line, unsigned int line_length); + int AddErrorF(int *id, char *error_msg, unsigned int len); + int AddWarningF(int *id, char *warn_msg, unsigned int len); IPQ_RESULT ClearAccumulatedLinesF(int *id); int CreateIPhreeqcF(void); int DestroyIPhreeqcF(int *id); diff --git a/src/fwrap2.cpp b/src/fwrap2.cpp index f3f6fe00..13ac5036 100644 --- a/src/fwrap2.cpp +++ b/src/fwrap2.cpp @@ -15,7 +15,14 @@ IPQ_DLL_EXPORT int ACCUMULATELINE(int *id, char *line, unsigned int len) { return AccumulateLineF(id, line, len); } -// AddError +IPQ_DLL_EXPORT int ADDERROR(int *id, char *error_msg, unsigned int len) +{ + return AddErrorF(id, error_msg, len); +} +IPQ_DLL_EXPORT int ADDWARNING(int *id, char *warn_msg, unsigned int len) +{ + return AddWarningF(id, warn_msg, len); +} IPQ_DLL_EXPORT int CLEARACCUMULATEDLINES(int *id) { return ClearAccumulatedLinesF(id); diff --git a/src/fwrap3.cpp b/src/fwrap3.cpp index 62b6ccfd..450cd33a 100644 --- a/src/fwrap3.cpp +++ b/src/fwrap3.cpp @@ -14,7 +14,14 @@ IPQ_DLL_EXPORT int accumulateline_(int *id, char *line, unsigned int len) { return AccumulateLineF(id, line, len); } -// AddError +IPQ_DLL_EXPORT int adderror(int *id, char *error_msg, unsigned int len) +{ + return AddErrorF(id, error_msg, len); +} +IPQ_DLL_EXPORT int addwarning(int *id, char *warn_msg, unsigned int len) +{ + return AddWarningF(id, warn_msg, len); +} IPQ_DLL_EXPORT int clearaccumulatedlines_(int *id) { return ClearAccumulatedLinesF(id);