Added GETCOMPONENTCOUNT and GETCOMPONENT fortran routines

git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/branches/class@4174 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
Scott R Charlton 2010-03-19 00:57:37 +00:00
parent 745917b89d
commit 9ce16bc323
8 changed files with 76 additions and 6 deletions

View File

@ -169,3 +169,18 @@
CHARACTER(LEN=*) :: LINE
END SUBROUTINE
END INTERFACE
INTERFACE
FUNCTION GetComponentCount()
INTEGER(KIND=4) :: GetComponentCount
END FUNCTION GetComponentCount
END INTERFACE
INTERFACE
SUBROUTINE GetComponent(N,COMP)
INTEGER(KIND=4) :: N
CHARACTER(LEN=*) :: COMP
END SUBROUTINE
END INTERFACE

View File

@ -167,6 +167,18 @@ GetErrorLineF(int* n, char* line, unsigned int line_length)
padfstring(line, ::GetErrorLine((*n) - 1), line_length);
}
int
GetComponentCountF(void)
{
return ::GetComponentCount();
}
void
GetComponentF(int *n, char* line, unsigned int line_length)
{
padfstring(line, ::GetComponent((*n) - 1), line_length);
}
int
RunF(void)
{
@ -353,6 +365,14 @@ void __stdcall GETERRORLINE(int *n, char* line, unsigned int line_length)
{
GetErrorLineF(n, line, line_length);
}
int __stdcall GETCOMPONENTCOUNT(void)
{
return GetComponentCountF();
}
void __stdcall GETCOMPONENT(int *n, char* line, unsigned int line_length)
{
GetComponentF(n, line, line_length);
}
int __stdcall RUN(void)
{
return RunF();

View File

@ -43,6 +43,10 @@ extern "C" {
void GetErrorLineF(int* n, char* line, unsigned int line_length);
int GetComponentCountF(void);
void GetComponentF(int* n, char* line, unsigned int line_length);
void OutputLastErrorF(void);
void OutputLinesF(void);

View File

@ -62,6 +62,14 @@ void GETERRORLINE(int *n, char* line, unsigned int line_length)
{
GetErrorLineF(n, line, line_length);
}
int GETCOMPONENTCOUNT(void)
{
return GetComponentCountF();
}
void GETCOMPONENT(int *n, char* line, unsigned int line_length)
{
GetComponentF(n, line, line_length);
}
int RUN(void)
{
return RunF();

View File

@ -62,6 +62,14 @@ void geterrorline_(int *n, char* line, unsigned int line_length)
{
GetErrorLineF(n, line, line_length);
}
int getcomponentcount_(void)
{
return GetComponentCountF();
}
void getcomponent_(int *n, char* line, unsigned int line_length)
{
GetComponentF(n, line, line_length);
}
int run_(void)
{
return RunF();

View File

@ -7,6 +7,8 @@
INTEGER i, j, k, rows, cols
INTEGER vtype
CHARACTER(30) svalue
CHARACTER(30) comp
INTEGER n
INTEGER len
REAL*8 dvalue
@ -79,6 +81,14 @@
40 CONTINUE
!!!!45 CONTINUE
!! test ListComponents
n = GetComponentCount()
DO i = 1, n
CALL GetComponent(i, comp)
WRITE (*, *) trim(comp)
END DO
50 FORMAT(A15,A,$)
60 FORMAT(1PG15.7E2,A,$)
END PROGRAM DRIVER

View File

@ -4,6 +4,9 @@
INCLUDE '..\include\IPhreeqc.f90.inc'
INTEGER iresult
INTEGER rows, cols
CHARACTER(30) comp
INTEGER n
INTEGER i
iresult = LoadDatabase
&('wateq4f.dat')
@ -30,6 +33,7 @@
PRINT*,'Rows= ',rows
PRINT*,'Cols= ',cols
STOP 'Ok'

View File

@ -1723,24 +1723,25 @@ TestInterface::TestGetComponent(void)
CPPUNIT_ASSERT_EQUAL( VR_OK, SOLUTION(1.0, 1.0, 1.0) );
// run
::SetOutputOn(1);
::SetOutputOn(0);
::SetErrorOn(0);
::SetLogOn(0);
::SetSelectedOutputOn(0);
::SetDumpOn(0);
::SetDumpStringOn(0);
std::cout << "\n";
::OutputLines();
std::cout << "\n";
CPPUNIT_ASSERT_EQUAL( 0, ::Run() );
CPPUNIT_ASSERT_EQUAL( 4, ::GetComponentCount() );
CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(::GetComponent(-2)) );
CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(::GetComponent(-1)) );
CPPUNIT_ASSERT_EQUAL( std::string("Ca"), std::string(::GetComponent(0)) );
CPPUNIT_ASSERT_EQUAL( std::string("H"), std::string(::GetComponent(1)) );
CPPUNIT_ASSERT_EQUAL( std::string("Na"), std::string(::GetComponent(2)) );
CPPUNIT_ASSERT_EQUAL( std::string("O"), std::string(::GetComponent(3)) );
CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(::GetComponent(4)) );
CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(::GetComponent(5)) );
}