mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 00:28:23 +01:00
working on documentation examples
git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/branches/ErrorHandling@6096 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
8b97d9d7ef
commit
fb0ec4984f
60
doc/examples/F90GetErrorStringLine.f90
Normal file
60
doc/examples/F90GetErrorStringLine.f90
Normal file
@ -0,0 +1,60 @@
|
||||
PROGRAM example
|
||||
INCLUDE "IPhreeqc.f90.inc"
|
||||
INTEGER(KIND=4) :: id
|
||||
INTEGER(KIND=4) :: i
|
||||
CHARACTER(LEN=80) :: line
|
||||
|
||||
id = CreateIPhreeqc()
|
||||
IF (id.LT.0) THEN
|
||||
STOP
|
||||
END IF
|
||||
|
||||
IF (SetErrorStringOn(id, .TRUE.).NE.IPQ_OK) THEN
|
||||
CALL OutputErrorString(id)
|
||||
STOP
|
||||
END IF
|
||||
|
||||
IF (AccumulateLine(id, "SOLUTION 1 Pure water").NE.IPQ_OK) THEN
|
||||
CALL OutputErrorString(id)
|
||||
STOP
|
||||
END IF
|
||||
|
||||
IF (AccumulateLine(id, "EQUILIBRIUM_PHASES 1").NE.IPQ_OK) THEN
|
||||
CALL OutputErrorString(id)
|
||||
STOP
|
||||
END IF
|
||||
|
||||
IF (AccumulateLine(id, " Calcite 0 10").NE.IPQ_OK) THEN
|
||||
CALL OutputErrorString(id)
|
||||
STOP
|
||||
END IF
|
||||
|
||||
IF (AccumulateLine(id, "SAVE solution 1").NE.IPQ_OK) THEN
|
||||
CALL OutputErrorString(id)
|
||||
STOP
|
||||
END IF
|
||||
|
||||
IF (AccumulateLine(id, "SAVE equilibrium_phases 1").NE.IPQ_OK) THEN
|
||||
CALL OutputErrorString(id)
|
||||
STOP
|
||||
END IF
|
||||
|
||||
WRITE(*,*) "Input:"
|
||||
CALL OutputAccumulatedLines(id)
|
||||
|
||||
IF (RunAccumulated(id).NE.0) THEN
|
||||
CALL OutputErrorString(id)
|
||||
STOP
|
||||
END IF
|
||||
|
||||
WRITE(*,*) "Error:"
|
||||
DO i=1,GetErrorStringLineCount(id)
|
||||
CALL GetErrorStringLine(id, i, line)
|
||||
WRITE(*,*) TRIM(line)
|
||||
END DO
|
||||
|
||||
IF (DestroyIPhreeqc(id).NE.IPQ_OK) THEN
|
||||
CALL OutputErrorString(id)
|
||||
STOP
|
||||
END IF
|
||||
END PROGRAM example
|
||||
45
doc/examples/GetErrorString.c
Normal file
45
doc/examples/GetErrorString.c
Normal file
@ -0,0 +1,45 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <IPhreeqc.h>
|
||||
|
||||
#define TRUE 1
|
||||
|
||||
const char input[] =
|
||||
"SOLUTION 1 Pure water \n"
|
||||
"EQUILIBRIUM_PHASES 1 \n"
|
||||
" Calcite 0 10 \n"
|
||||
"SAVE solution 1 \n"
|
||||
"SAVE equilibrium_phases 1 \n"
|
||||
"DUMP \n"
|
||||
" -solution 1 \n"
|
||||
" -equilibrium_phases 1\n"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int id;
|
||||
|
||||
id = CreateIPhreeqc();
|
||||
if (id < 0) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (SetErrorStringOn(id, TRUE) != IPQ_OK) {
|
||||
OutputErrorString(id);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (RunString(id, input) != 0) {
|
||||
OutputErrorString(id);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("Error:\n");
|
||||
printf("%s\n", GetErrorString(id));
|
||||
|
||||
if (DestroyIPhreeqc(id) != IPQ_OK) {
|
||||
OutputErrorString(id);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@ -420,6 +420,10 @@ extern "C" {
|
||||
* @see GetErrorFileOn, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString, SetErrorFileOn
|
||||
* @par Fortran90 Interface:
|
||||
* Not implemented. (see \ref GetErrorStringLineCount, \ref GetErrorStringLine, \ref OutputErrorString)
|
||||
*
|
||||
* \anchor GetErrorString_c
|
||||
* @par C Example:
|
||||
* \include GetErrorString.c
|
||||
*/
|
||||
IPQ_DLL_EXPORT const char* GetErrorString(int id);
|
||||
|
||||
@ -443,6 +447,10 @@ extern "C" {
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*
|
||||
* \anchor GetErrorStringLine_f90
|
||||
* @par Fortran90 Example:
|
||||
* \include F90GetErrorStringLine.f90
|
||||
*/
|
||||
IPQ_DLL_EXPORT const char* GetErrorStringLine(int id, int n);
|
||||
|
||||
@ -537,9 +545,9 @@ extern "C" {
|
||||
* @par Fortran90 Interface:
|
||||
* Not implemented. (see \ref GetLogStringLineCount, \ref GetLogStringLine)
|
||||
*
|
||||
* \anchor GetOutputString_c
|
||||
* \anchor GetLogString_c
|
||||
* @par C Example:
|
||||
* \include GetOutputString.c
|
||||
* \include GetLogString.c
|
||||
*/
|
||||
IPQ_DLL_EXPORT const char* GetLogString(int id);
|
||||
|
||||
@ -1484,7 +1492,7 @@ Headings
|
||||
* to the error file are stored in a buffer for retrieval. The initial setting after calling
|
||||
* \ref CreateIPhreeqc is on.
|
||||
* @param id The instance id returned from \ref CreateIPhreeqc.
|
||||
* @param output_string_on If non-zero, captures the error output into a string buffer;
|
||||
* @param error_string_on If non-zero, captures the error output into a string buffer;
|
||||
* if zero, error output is not captured to a string buffer.
|
||||
* @retval IPQ_OK Success.
|
||||
* @retval IPQ_BADINSTANCE The given id is invalid.
|
||||
@ -1563,7 +1571,7 @@ Headings
|
||||
* to the log file are stored in a buffer for retrieval. The initial setting after calling
|
||||
* \ref CreateIPhreeqc is off.
|
||||
* @param id The instance id returned from \ref CreateIPhreeqc.
|
||||
* @param output_string_on If non-zero, captures the log output into a string buffer;
|
||||
* @param log_string_on If non-zero, captures the log output into a string buffer;
|
||||
* if zero, log output is not captured to a string buffer.
|
||||
* @retval IPQ_OK Success.
|
||||
* @retval IPQ_BADINSTANCE The given id is invalid.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user