added googletest and fixed some minor bugs

This commit is contained in:
Charlton, Scott R 2020-08-25 12:27:15 -06:00
parent 1059b78bb4
commit 5c61108b60
26 changed files with 21991 additions and 162 deletions

View File

@ -1,17 +1,17 @@
cmake_minimum_required (VERSION 2.8)
# CMAKE_MSVC_RUNTIME_LIBRARY requires 3.15
cmake_minimum_required(VERSION 3.15)
project (IPhreeqc CXX C)
# check if this is the root project
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(STANDALONE_BUILD 1)
else()
set(STANDALONE_BUILD 0)
endif()
# overide docdir on windows
if(WIN32 AND NOT CMAKE_INSTALL_DOCDIR)
if (WIN32 AND NOT CMAKE_INSTALL_DOCDIR)
set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (doc)")
set(CMAKE_INSTALL_DOCDIR "doc")
endif()
@ -19,33 +19,27 @@ endif()
# set standard directory locations
include(GNUInstallDirs)
# Fortran
option (IPHREEQC_ENABLE_MODULE "Enable Fortran module" ON)
if (STANDALONE_BUILD EQUAL 1)
if (NOT IPHREEQC_FORTRAN_TESTING)
if (NOT CMAKE_Fortran_COMPILER OR CMAKE_Fortran_COMPILER STREQUAL "CMAKE_Fortran_COMPILER-NOTFOUND")
option (IPHREEQC_FORTRAN_TESTING "Build Fortran test" OFF)
else()
option (IPHREEQC_FORTRAN_TESTING "Build Fortran test" ON)
endif()
else()
if (IPHREEQC_FORTRAN_TESTING)
enable_language(Fortran)
endif()
if (STANDALONE_BUILD AND MSVC)
option (IPHREEQC_STATIC_RUNTIME "Build with a static runtime" OFF)
if (IPHREEQC_STATIC_RUNTIME)
# compile with static runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
# Disable deprecation warnings for standard C and STL functions in VS2005
# and later
if(MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif(MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400)
add_definitions(-DSWIG_SHARED_OBJ)
add_definitions(-DUSE_PHRQ_ALLOC)
# Fortran
option (IPHREEQC_ENABLE_MODULE "Enable Fortran module" ON)
if (STANDALONE_BUILD)
if (IPHREEQC_FORTRAN_TESTING)
enable_language(Fortran)
else()
if (CMAKE_Fortran_COMPILER)
option (IPHREEQC_FORTRAN_TESTING "Build Fortran test" ON)
else()
option (IPHREEQC_FORTRAN_TESTING "Build Fortran test" OFF)
endif()
endif()
endif()
SET(IPhreeqc_SOURCES
src/CSelectedOutput.cpp
@ -202,12 +196,11 @@ src/Version.h
)
# compile Var.c as c++
SET_SOURCE_FILES_PROPERTIES(src/Var.c PROPERTIES LANGUAGE CXX)
set_source_files_properties(src/Var.c PROPERTIES LANGUAGE CXX)
# fwrap files
if (NOT IPHREEQC_ENABLE_MODULE)
add_definitions(-DIPHREEQC_NO_FORTRAN_MODULE)
SET(IPhreeqc_SOURCES
set(IPhreeqc_SOURCES
${IPhreeqc_SOURCES}
src/fimpl.h
src/fwrap.cpp
@ -216,39 +209,84 @@ if (NOT IPHREEQC_ENABLE_MODULE)
src/fwrap3.cpp
src/fwrap4.cpp
src/fwrap5.cpp
src/fwrap6.cpp
src/fwrap6.cpp
src/fwrap7.cpp
src/fwrap8.cpp
src/fwrap8.cpp
)
endif()
# setup include directories
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/src")
include_directories("${PROJECT_SOURCE_DIR}/src/phreeqcpp")
include_directories("${PROJECT_SOURCE_DIR}/src/phreeqcpp/common")
include_directories("${PROJECT_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords")
if (STANDALONE_BUILD EQUAL 1)
if (STANDALONE_BUILD)
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
set(LIB_TYPE STATIC)
endif()
if (BUILD_SHARED_LIBS)
set(LIB_TYPE SHARED)
if (STANDALONE_BUILD EQUAL 1)
if (STANDALONE_BUILD)
if (MSVC)
option(BUILD_CLR_LIBS "Build CLR Libraries" OFF)
endif()
endif()
endif()
add_library(IPhreeqc ${LIB_TYPE} ${IPhreeqc_SOURCES})
# target_include_directories(IPhreeqc PUBLIC "${PROJECT_SOURCE_DIR}/src")
# target_include_directories(IPhreeqc PUBLIC "${PROJECT_SOURCE_DIR}/src/phreeqcpp")
# target_include_directories(IPhreeqc PUBLIC "${PROJECT_SOURCE_DIR}/src/phreeqcpp/common")
# target_include_directories(IPhreeqc PUBLIC "${PROJECT_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords")
# # target_include_directories(IPhreeqc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)
# # target_include_directories(IPhreeqc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/phreeqcpp>)
# # target_include_directories(IPhreeqc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/phreeqcpp/common>)
# # target_include_directories(IPhreeqc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords>)
# # target_include_directories(IPhreeqc PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# target_include_directories(IPhreeqc
# PUBLIC
# "${PROJECT_SOURCE_DIR}/src"
# "${PROJECT_SOURCE_DIR}/src/phreeqcpp"
# "${PROJECT_SOURCE_DIR}/src/phreeqcpp/common"
# "${PROJECT_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords"
# )
target_include_directories(IPhreeqc
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/phreeqcpp>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/phreeqcpp/common>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# target_include_directories(IPhreeqc
# PUBLIC
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
# $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
# )
target_compile_definitions(IPhreeqc PRIVATE "SWIG_SHARED_OBJ")
target_compile_definitions(IPhreeqc PRIVATE "USE_PHRQ_ALLOC")
if (NOT IPHREEQC_ENABLE_MODULE)
target_compile_definitions(IPhreeqc PUBLIC "IPHREEQC_NO_FORTRAN_MODULE")
endif()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
target_compile_options(IPhreeqc PRIVATE /wd4251 /wd4275 /wd4793)
endif()
# Disable deprecation warnings for standard C and STL functions in VS2005
# and later
if (MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400)
target_compile_definitions(IPhreeqc PUBLIC "_CRT_SECURE_NO_DEPRECATE")
target_compile_definitions(IPhreeqc PUBLIC "_SCL_SECURE_NO_WARNINGS")
endif(MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400)
set_target_properties(IPhreeqc PROPERTIES DEBUG_POSTFIX "d")
set_target_properties(IPhreeqc PROPERTIES MINSIZEREL_POSTFIX "msr")
set_target_properties(IPhreeqc PROPERTIES RELWITHDEBINFO_POSTFIX "rwdi")
set_target_properties(IPhreeqc PROPERTIES RELWITHDEBINFO_POSTFIX "rwd")
SET(IPhreeqc_Headers
set(IPhreeqc_Headers
${PROJECT_SOURCE_DIR}/src/IPhreeqc.h
${PROJECT_SOURCE_DIR}/src/IPhreeqc.hpp
${PROJECT_SOURCE_DIR}/src/IPhreeqcCallbacks.h
@ -258,78 +296,104 @@ ${PROJECT_SOURCE_DIR}/src/Var.h
)
if (IPHREEQC_ENABLE_MODULE)
SET(IPhreeqc_SRC
set(IPhreeqc_SRC
${PROJECT_SOURCE_DIR}/src/IPhreeqc_interface.F90
${PROJECT_SOURCE_DIR}/src/README.Fortran
)
else()
# always install README.Fortran
SET(IPhreeqc_SRC
set(IPhreeqc_SRC
${PROJECT_SOURCE_DIR}/src/README.Fortran
)
# install old fortran include files
SET(IPhreeqc_Headers
set(IPhreeqc_Headers
${IPhreeqc_Headers}
${PROJECT_SOURCE_DIR}/src/IPhreeqc.f.inc
${PROJECT_SOURCE_DIR}/src/IPhreeqc.f90.inc
)
endif()
# Setup references for /CLR
if (MSVC AND BUILD_SHARED_LIBS AND BUILD_CLR_LIBS)
set_target_properties(IPhreeqc PROPERTIES VS_DOTNET_REFERENCES "System;System.Drawing;System.Windows.Forms;${CMAKE_CURRENT_SOURCE_DIR}/src/phreeqcpp/ZedGraph.dll")
# Remove /EHsc from CMAKE_CXX_FLAGS
STRING(REPLACE " /EHsc" " /EHa /clr" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# Remove /RTC1 from CMAKE_CXX_FLAGS_DEBUG
STRING(REPLACE " /RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
if (MSVC10)
# turn off warnings on VS2010
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4793 /wd4945")
endif()
if (MSVC_VERSION LESS 1600)
message(FATAL_ERROR "CLR options must be set manually for versions prior to Visual Studio 2010")
endif()
ADD_DEFINITIONS(-DMULTICHART)
endif()
# install
if (WIN32)
if (BUILD_CLR_LIBS)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
SET(CMAKE_INSTALL_LIBDIR "clrx64")
else()
SET(CMAKE_INSTALL_LIBDIR "clr")
endif()
else()
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
if (BUILD_SHARED_LIBS)
SET(CMAKE_INSTALL_LIBDIR "dllx64")
else()
SET(CMAKE_INSTALL_LIBDIR "libx64")
endif()
else()
if (BUILD_SHARED_LIBS)
SET(CMAKE_INSTALL_LIBDIR "dll")
else()
SET(CMAKE_INSTALL_LIBDIR "lib")
endif()
endif()
endif()
set_target_properties(IPhreeqc PROPERTIES VS_DOTNET_REFERENCES "System;System.Drawing;System.Windows.Forms;${CMAKE_CURRENT_SOURCE_DIR}/src/phreeqcpp/ZedGraph.dll")
set_target_properties(IPhreeqc PROPERTIES COMMON_LANGUAGE_RUNTIME "")
target_compile_definitions(IPhreeqc PRIVATE "MULTICHART")
endif()
# install
if (STANDALONE_BUILD EQUAL 1)
install(TARGETS IPhreeqc DESTINATION ${CMAKE_INSTALL_LIBDIR})
# if (WIN32)
# if (BUILD_CLR_LIBS)
# if ("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
# SET(CMAKE_INSTALL_LIBDIR "clrx64")
# else()
# SET(CMAKE_INSTALL_LIBDIR "clr")
# endif()
# else()
# if ("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
# if (BUILD_SHARED_LIBS)
# SET(CMAKE_INSTALL_LIBDIR "dllx64")
# else()
# SET(CMAKE_INSTALL_LIBDIR "libx64")
# endif()
# else()
# if (BUILD_SHARED_LIBS)
# SET(CMAKE_INSTALL_LIBDIR "dll")
# else()
# SET(CMAKE_INSTALL_LIBDIR "lib")
# endif()
# endif()
# endif()
# endif()
# install
if (STANDALONE_BUILD)
# install(TARGETS IPhreeqc DESTINATION ${CMAKE_INSTALL_LIBDIR})
#{{
include(CMakePackageConfigHelpers)
configure_package_config_file(IPhreeqcConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/IPhreeqcConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IPhreeqc
)
write_basic_package_version_file("IPhreeqcConfigVersion.cmake"
VERSION 3.2.0
COMPATIBILITY SameMajorVersion
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/IPhreeqcConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/IPhreeqcConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IPhreeqc
)
install(TARGETS IPhreeqc
EXPORT IPhreeqcTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT IPhreeqcTargets
FILE IPhreeqcTargets.cmake
NAMESPACE IPhreeqc::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IPhreeqc
)
##}}
install(FILES ${IPhreeqc_Headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (WIN32)
install(FILES ${IPhreeqc_SRC} DESTINATION src)
else()
install(FILES ${IPhreeqc_SRC} DESTINATION ${CMAKE_INSTALL_DOCDIR}/src)
endif()
if (BUILD_CLR_LIBS)
install(FILES "${PROJECT_SOURCE_DIR}/src/phreeqcpp/ZedGraph.dll" DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
# if (WIN32)
# install(FILES ${IPhreeqc_SRC} DESTINATION src)
# else()
# install(FILES ${IPhreeqc_SRC} DESTINATION ${CMAKE_INSTALL_DOCDIR}/src)
# endif()
# if (BUILD_CLR_LIBS)
# install(FILES "${PROJECT_SOURCE_DIR}/src/phreeqcpp/ZedGraph.dll" DESTINATION ${CMAKE_INSTALL_LIBDIR})
# endif()
endif()
##IF(MSVC)
@ -350,54 +414,74 @@ endif()
## )
##ENDIF(MSVC)
if (STANDALONE_BUILD EQUAL 1 AND MSVC)
option (IPHREEQC_STATIC_RUNTIME "Build with a static runtime" OFF)
if (IPHREEQC_STATIC_RUNTIME)
# compile with static runtime
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
)
foreach(CompilerFlag ${CompilerFlags})
if(${CompilerFlag} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endif()
endforeach()
set(FortranCompilerFlags
CMAKE_Fortran_FLAGS
)
foreach(FortranCompilerFlags ${FortranCompilerFlags})
if(${FortranCompilerFlags} MATCHES "/libs:dll")
string(REGEX REPLACE "/libs:dll" "/libs:static" ${FortranCompilerFlags} "${${FortranCompilerFlags}}")
endif()
endforeach()
endif()
if (BUILD_CLR_LIBS AND IPHREEQC_STATIC_RUNTIME)
message(FATAL_ERROR "BUILD_CLR_LIBS and IPHREEQC_STATIC_RUNTIME are mutually exclusive")
endif()
if (STANDALONE_BUILD EQUAL 1)
# tests
enable_testing()
if (EXISTS "${PROJECT_SOURCE_DIR}/CTestConfig.cmake")
# enable dashboard scripting
include (CTest)
endif()
if (STANDALONE_BUILD)
add_subdirectory(database)
add_subdirectory(doc)
add_subdirectory(examples)
add_subdirectory(tests)
if (EXISTS "${PROJECT_SOURCE_DIR}/CTestConfig.cmake")
# enable dashboard scripting
include (CTest)
if (BUILD_TESTING)
add_subdirectory(tests)
endif()
if (BUILD_TESTING)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/release-1.8.1.tar.gz
URL_HASH MD5=2e6fbeb6a91310a16efe181886c59596
)
mark_as_advanced(
FETCHCONTENT_BASE_DIR
FETCHCONTENT_FULLY_DISCONNECTED
FETCHCONTENT_QUIET
FETCHCONTENT_SOURCE_DIR_GOOGLETEST
FETCHCONTENT_UPDATES_DISCONNECTED
FETCHCONTENT_UPDATES_DISCONNECTED_GOOGLETEST
)
# Prevent GoogleTest from overriding our compiler/linker options
# when building with Visual Studio
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(BUILD_GTEST ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
set(INSTALL_GMOCK OFF CACHE BOOL "" FORCE)
mark_as_advanced(
BUILD_GTEST
BUILD_GMOCK
INSTALL_GTEST
INSTALL_GMOCK
gmock_build_tests
gtest_build_tests
gtest_build_samples
gtest_disable_pthreads
gtest_force_shared_crt
gtest_hide_internal_symbols
)
FetchContent_GetProperties(googletest)
if (NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
endif()
add_subdirectory(gtest)
endif()
# enable distribution creation

4
IPhreeqcConfig.cmake.in Normal file
View File

@ -0,0 +1,4 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/IPhreeqcTargets.cmake")
check_required_components("IPhreeqc")

View File

@ -1,3 +1,27 @@
if (EXISTS ${CMAKE_SOURCE_DIR}/.git)
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/doc/html)
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/doc/html)
endif()
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/doc/NOTICE)
file(COPY ${CMAKE_SOURCE_DIR}/phreeqc3-doc/NOTICE.TXT
DESTINATION ${CMAKE_SOURCE_DIR}/doc)
file(RENAME ${CMAKE_SOURCE_DIR}/doc/NOTICE.TXT ${CMAKE_SOURCE_DIR}/doc/NOTICE)
endif()
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/doc/README)
file(COPY ${CMAKE_SOURCE_DIR}/phreeqc3-doc/README.IPhreeqc.TXT
DESTINATION ${CMAKE_SOURCE_DIR}/doc)
file(RENAME ${CMAKE_SOURCE_DIR}/doc/README.IPhreeqc.TXT ${CMAKE_SOURCE_DIR}/doc/README)
endif()
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/doc/RELEASE)
file(COPY ${CMAKE_SOURCE_DIR}/phreeqc3-doc/RELEASE.TXT
DESTINATION ${CMAKE_SOURCE_DIR}/doc)
file(RENAME ${CMAKE_SOURCE_DIR}/doc/RELEASE.TXT ${CMAKE_SOURCE_DIR}/doc/RELEASE)
endif()
endif()
SET(IPhreeqc_Docs
IPhreeqc.pdf
NOTICE
@ -6,5 +30,6 @@ Phreeqc_3_2013_manual.pdf
README
RELEASE
)
install(FILES ${IPhreeqc_Docs} DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(DIRECTORY html/ DESTINATION ${CMAKE_INSTALL_DOCDIR}/html)

View File

@ -0,0 +1,20 @@
# set minimum cmake version
cmake_minimum_required(VERSION 3.10)
# set project name along with language
project(cmake-example CXX)
# copy necessary files into build directory
configure_file(phreeqc.dat phreeqc.dat COPYONLY)
configure_file(ex2 ex2 COPYONLY)
# find IPhreeqc export package
# set CMAKE_PREFIX_PATH or IPhreeqc_DIR to the
# location of the IPhreeqcConfig.cmake file
find_package(IPhreeqc)
# add executable target
add_executable(example main.cpp)
# set link libraries as well as include paths
target_link_libraries(example IPhreeqc::IPhreeqc)

View File

@ -0,0 +1,18 @@
Example usage
Configure, build and install IPhreeqc
1. cd iphreeqc-3.6.2-15100
2. mkdir _build
3. cd _build
4. cmake -DCMAKE_INSTALL_PREFIX:PATH=c:/Users/charlton/iphreeqc ..
5. cmake --build . --config release
6. ctest .
6. cmake --build . --config release --target install
Build example:
1. cd c:\Users\charlton\iphreeqc\examples\using-cmake
2. mkdir _build
3. cmake -DCMAKE_PREFIX_PATH:PATH=c:/Users/charlton/iphreeqc/lib/cmake/IPhreeqc ..
4. cmake --build . --config release

26
examples/using-cmake/ex2 Normal file
View File

@ -0,0 +1,26 @@
TITLE Example 2.--Temperature dependence of solubility
of gypsum and anhydrite
SOLUTION 1 Pure water
pH 7.0
temp 25.0
EQUILIBRIUM_PHASES 1
Gypsum 0.0 1.0
Anhydrite 0.0 1.0
REACTION_TEMPERATURE 1
25.0 75.0 in 51 steps
SELECTED_OUTPUT
-file ex2.sel
-temperature
-si anhydrite gypsum
USER_GRAPH 1 Example 2
-headings Temperature Gypsum Anhydrite
-chart_title "Gypsum-Anhydrite Stability"
-axis_scale x_axis 25 75 5 0
-axis_scale y_axis auto 0.05 0.1
-axis_titles "Temperature, in degrees celsius" "Saturation index"
-initial_solutions false
-start
10 graph_x TC
20 graph_y SI("Gypsum") SI("Anhydrite")
-end
END

View File

@ -0,0 +1,18 @@
#include <IPhreeqc.hpp>
#include <iostream>
int main (void)
{
IPhreeqc iphreeqc;
if (iphreeqc.LoadDatabase("phreeqc.dat") != 0)
{
std::cout << iphreeqc.GetErrorString();
return EXIT_FAILURE;
}
if (iphreeqc.RunFile("ex2") != 0)
{
std::cout << iphreeqc.GetErrorString();
return EXIT_FAILURE;
}
return 0;
}

File diff suppressed because it is too large Load Diff

166
gtest/CMakeLists.txt Normal file
View File

@ -0,0 +1,166 @@
project(unit)
add_executable(TestCVar TestCVar.cpp)
target_link_libraries(TestCVar IPhreeqc gtest gtest_main)
add_executable(TestVar TestVar.cpp)
target_link_libraries(TestVar IPhreeqc gtest gtest_main)
add_executable(TestIPhreeqcLib TestIPhreeqcLib.cpp FileTest.cpp)
target_link_libraries(TestIPhreeqcLib IPhreeqc gtest gtest_main)
add_executable(TestIPhreeqc TestIPhreeqc.cpp FileTest.cpp)
target_link_libraries(TestIPhreeqc IPhreeqc gtest gtest_main)
add_executable(TestSelectedOutput TestSelectedOutput.cpp)
target_link_libraries(TestSelectedOutput IPhreeqc gtest gtest_main)
add_test(TestCVar TestCVar)
add_test(TestVar TestVar)
add_test(TestIPhreeqc TestIPhreeqc)
add_test(TestIPhreeqcLib TestIPhreeqcLib)
add_test(TestSelectedOutput TestSelectedOutput)
if (MSVC AND BUILD_SHARED_LIBS)
# copy dlls
add_custom_command(TARGET TestCVar POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:IPhreeqc> $<TARGET_FILE_DIR:TestCVar>
)
add_custom_command(TARGET TestCVar POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:gtest> $<TARGET_FILE_DIR:TestCVar>
)
add_custom_command(TARGET TestCVar POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:gtest_main> $<TARGET_FILE_DIR:TestCVar>
)
endif()
# databases
configure_file(
../unit/phreeqc.dat.old
phreeqc.dat.old
COPYONLY
)
configure_file(
../database/phreeqc.dat
phreeqc.dat
COPYONLY
)
configure_file(
../database/pitzer.dat
pitzer.dat
COPYONLY
)
configure_file(
../database/wateq4f.dat
wateq4f.dat
COPYONLY
)
configure_file(
../database/Amm.dat
Amm.dat
COPYONLY
)
configure_file(
../database/frezchem.dat
frezchem.dat
COPYONLY
)
configure_file(
../database/iso.dat
iso.dat
COPYONLY
)
configure_file(
../unit/llnl.dat.old
llnl.dat.old
COPYONLY
)
configure_file(
../database/llnl.dat
llnl.dat
COPYONLY
)
configure_file(
../database/minteq.dat
minteq.dat
COPYONLY
)
configure_file(
../database/minteq.v4.dat
minteq.v4.dat
COPYONLY
)
configure_file(
../database/sit.dat
sit.dat
COPYONLY
)
configure_file(
../database/ColdChem.dat
ColdChem.dat
COPYONLY
)
configure_file(
../database/core10.dat
core10.dat
COPYONLY
)
configure_file(
../database/Tipping_Hurley.dat
Tipping_Hurley.dat
COPYONLY
)
configure_file(
missing_e.dat
missing_e.dat
COPYONLY
)
# misc files
configure_file(
conv_fail.in
conv_fail.in
COPYONLY
)
configure_file(
dump
dump
COPYONLY
)
configure_file(
multi_punch
multi_punch
COPYONLY
)
configure_file(
multi_punch_no_set
multi_punch_no_set
COPYONLY
)
configure_file(
kinn20140218
kinn20140218
COPYONLY
)

153
gtest/FileTest.cpp Normal file
View File

@ -0,0 +1,153 @@
#include "FileTest.h"
#if defined(_WIN32) || defined(__CYGWIN32__)
#include <windows.h>
#else
#include <stdio.h>
#endif
#if defined(_WIN32) || defined(__CYGWIN32__)
bool FileExists(const char *szPathName)
{
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
HANDLE fileHandle = ::CreateFile(szPathName, GENERIC_READ, 0, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
bool retValue;
if (fileHandle == INVALID_HANDLE_VALUE)
{
char buffer[100];
sprintf(buffer, "Could not open file (error %d)\n", GetLastError());
retValue = false;
}
else
{
retValue = true;
::CloseHandle(fileHandle);
}
return retValue;
}
#else
bool FileExists(const char *szPathName)
{
FILE* fp;
fp = fopen(szPathName, "r");
if (fp == NULL) {
return false;
} else {
fclose(fp);
return true;
}
}
#endif
#if defined(_WIN32) || defined(__CYGWIN32__)
// DeleteFile defined in <windows.h>
#else
int DeleteFile(const char* szPathName)
{
if (remove(szPathName) == 0)
{
return 1;
}
return 0; // failure
}
#endif
#if defined(_WIN32) || defined(__CYGWIN32__)
size_t FileSize(const char *szPathName)
{
HANDLE hFile = ::CreateFile(
szPathName, // file to open
GENERIC_READ, // open for reading
FILE_SHARE_READ, // share for reading
NULL, // default security
OPEN_EXISTING, // existing file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
if (hFile != INVALID_HANDLE_VALUE)
{
// read file size
LARGE_INTEGER liFileSize;
::GetFileSizeEx(hFile, &liFileSize);
::CloseHandle(hFile);
return (size_t) liFileSize.QuadPart;
}
return 0;
}
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
size_t FileSize(const char *szPathName)
{
struct stat s;
stat(szPathName, &s);
return (size_t) s.st_size;
}
#endif
FileTest::FileTest(std::string fn) : _fn(fn)
{
}
FileTest::~FileTest(void)
{
int max_tries = 100;
while(::FileExists(_fn.c_str()) && --max_tries)
{
::DeleteFile(_fn.c_str());
}
}
std::string FileTest::GetName(void)
{
return _fn;
}
bool FileTest::RemoveExisting(void)
{
int max_tries = 100;
while(::FileExists(_fn.c_str()) && --max_tries)
{
::DeleteFile(_fn.c_str());
}
return !::FileExists(_fn.c_str());
}
bool FileTest::VerifyMissing(void)
{
int max_tries = 100;
while(::FileExists(_fn.c_str()) && --max_tries);
return !::FileExists(_fn.c_str());
}
bool FileTest::VerifyExists(void)
{
int max_tries = 100;
while(!::FileExists(_fn.c_str()) && --max_tries);
return ::FileExists(_fn.c_str());
}
bool FileTest::Exists(void)
{
return ::FileExists(_fn.c_str());
}
int FileTest::Delete(void)
{
if (::FileExists(_fn.c_str()))
{
return ::DeleteFile(_fn.c_str());
}
return 1;
}
size_t FileTest::Size(void)
{
return ::FileSize(_fn.c_str());
}

33
gtest/FileTest.h Normal file
View File

@ -0,0 +1,33 @@
#if !defined(FILETEST_H_INCLUDED)
#define FILETEST_H_INCLUDED
#include <string>
#if defined(_WIN32) || defined(__CYGWIN32__)
// DeleteFile defined in <windows.h>
#else
int DeleteFile(const char* szPathName);
#endif
bool FileExists(const char *szPathName);
size_t FileSize(const char *szPathName);
class FileTest
{
public:
FileTest(std::string fn);
~FileTest(void);
std::string GetName(void);
bool RemoveExisting(void);
bool VerifyMissing(void);
bool VerifyExists(void);
bool Exists(void);
int Delete(void);
size_t Size(void);
protected:
std::string _fn;
};
#endif // FILETEST_H_INCLUDED

9
gtest/TestCVar.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <gtest/gtest.h>
#include "../src/CVar.hxx"
TEST(TestCVar, CVarCtor)
{
CVar v;
ASSERT_EQ(TT_EMPTY, v.type);
}

4742
gtest/TestIPhreeqc.cpp Normal file

File diff suppressed because it is too large Load Diff

4606
gtest/TestIPhreeqcLib.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,669 @@
#include <gtest/gtest.h>
#include "../src/CSelectedOutput.hxx"
#include "IPhreeqc.hpp"
#include "Phreeqc.h"
#if defined(_WIN32)
#define strdup _strdup
#endif
TEST(TestSelectedOutput, TestEmpty)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
}
TEST(TestSelectedOutput, TestSinglePushBack)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
CVar v(7.0);
ASSERT_EQ(0, co.PushBack("pH", v));
ASSERT_EQ((size_t)1, co.GetColCount());
// row count doesn't change until EndRow is called
ASSERT_EQ((size_t)1, co.GetRowCount());
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
#if defined(_DEBUG)
co.Dump("TestSinglePushBack");
#endif
}
TEST(TestSelectedOutput, TestMultiplePushBack)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
CVar v1(7.0);
ASSERT_EQ(0, co.PushBack("pH", v1));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)1, co.GetRowCount());
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v2(8.0);
ASSERT_EQ(0, co.PushBack("pH", v2));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)3, co.GetRowCount());
#if defined(_DEBUG)
co.Dump("TestMultiplePushBack");
#endif
}
TEST(TestSelectedOutput, TestNewHeadingsPushBack)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
CVar v1(7.0);
ASSERT_EQ(0, co.PushBack("pH", v1));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)1, co.GetRowCount());
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v2(8.0);
ASSERT_EQ(0, co.PushBack("pH", v2));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v3(9.0);
ASSERT_EQ(0, co.PushBack("user_pH", v3));
ASSERT_EQ((size_t)2, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)2, co.GetColCount());
ASSERT_EQ((size_t)3, co.GetRowCount());
#if defined(_DEBUG)
co.Dump("TestNewHeadingsPushBack");
#endif
}
TEST(TestSelectedOutput, TestPushBackDouble)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ(0, co.PushBackDouble("pH", 7.0));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)1, co.GetRowCount()); // heading
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v;
ASSERT_EQ(TT_EMPTY, v.type);
ASSERT_EQ(VR_OK, co.Get(0, 0, &v));
ASSERT_EQ(TT_STRING, v.type);
ASSERT_EQ(std::string("pH"), std::string(v.sVal));
CVar vval;
ASSERT_EQ(TT_EMPTY, vval.type);
ASSERT_EQ(VR_OK, co.Get(1, 0, &vval));
ASSERT_EQ(TT_DOUBLE, vval.type);
ASSERT_EQ(7.0, vval.dVal);
}
TEST(TestSelectedOutput, TestPushBackLong)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ(0, co.PushBackLong("Sim", 2));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)1, co.GetRowCount()); // heading plus first row
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v;
ASSERT_EQ(TT_EMPTY, v.type);
ASSERT_EQ(VR_OK, co.Get(0, 0, &v));
ASSERT_EQ(TT_STRING, v.type);
ASSERT_EQ(std::string("Sim"), std::string(v.sVal));
CVar vval;
ASSERT_EQ(TT_EMPTY, vval.type);
ASSERT_EQ(VR_OK, co.Get(1, 0, &vval));
ASSERT_EQ(TT_LONG, vval.type);
ASSERT_EQ(2l, vval.lVal);
}
TEST(TestSelectedOutput, TestPushBackString)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ(0, co.PushBackString("state", "i_soln"));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)1, co.GetRowCount()); // heading
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v;
ASSERT_EQ(TT_EMPTY, v.type);
ASSERT_EQ(VR_OK, co.Get(0, 0, &v));
ASSERT_EQ(TT_STRING, v.type);
ASSERT_EQ(std::string("state"), std::string(v.sVal));
CVar vval;
ASSERT_EQ(TT_EMPTY, vval.type);
ASSERT_EQ(VR_OK, co.Get(1, 0, &vval));
ASSERT_EQ(TT_STRING, vval.type);
ASSERT_EQ(std::string("i_soln"), std::string(vval.sVal));
}
TEST(TestSelectedOutput, TestPushBackEmpty)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ(0, co.PushBackEmpty("Empty"));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)1, co.GetRowCount()); // heading
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v;
ASSERT_EQ(TT_EMPTY, v.type);
ASSERT_EQ(VR_OK, co.Get(0, 0, &v));
ASSERT_EQ(TT_STRING, v.type);
ASSERT_EQ(std::string("Empty"), std::string(v.sVal));
CVar vval;
ASSERT_EQ(TT_EMPTY, vval.type);
ASSERT_EQ(VR_OK, co.Get(1, 0, &vval));
ASSERT_EQ(TT_EMPTY, vval.type);
}
TEST(TestSelectedOutput, TestDuplicateHeadings)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ(0, co.PushBackDouble("pH", 7.0));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)1, co.GetRowCount()); // heading
// overwrite pH with 8.0
//
ASSERT_EQ(0, co.PushBackDouble("pH", 8.0));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)1, co.GetRowCount()); // heading
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v;
ASSERT_EQ(TT_EMPTY, v.type);
ASSERT_EQ(VR_OK, co.Get(0, 0, &v));
ASSERT_EQ(TT_STRING, v.type);
ASSERT_EQ(std::string("pH"), std::string(v.sVal));
CVar vval;
ASSERT_EQ(TT_EMPTY, vval.type);
ASSERT_EQ(VR_OK, co.Get(1, 0, &vval));
ASSERT_EQ(TT_DOUBLE, vval.type);
ASSERT_EQ(8.0, vval.dVal);
}
TEST(TestSelectedOutput, TestEndRow)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ(0, co.PushBackDouble("pH", 7.0));
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)1, co.GetRowCount()); // heading
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v;
ASSERT_EQ(TT_EMPTY, v.type);
ASSERT_EQ(VR_OK, co.Get(0, 0, &v));
ASSERT_EQ(TT_STRING, v.type);
ASSERT_EQ(std::string("pH"), std::string(v.sVal));
CVar vval;
ASSERT_EQ(TT_EMPTY, vval.type);
ASSERT_EQ(VR_OK, co.Get(1, 0, &vval));
ASSERT_EQ(TT_DOUBLE, vval.type);
ASSERT_EQ(7.0, vval.dVal);
ASSERT_EQ(0, co.PushBackDouble("pH", 8.0));
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)3, co.GetRowCount());
CVar vval3;
ASSERT_EQ(TT_EMPTY, vval3.type);
ASSERT_EQ(VR_OK, co.Get(1, 0, &vval3));
ASSERT_EQ(TT_DOUBLE, vval3.type);
ASSERT_EQ(7.0, vval3.dVal);
CVar vval2;
ASSERT_EQ(TT_EMPTY, vval2.type);
ASSERT_EQ(VR_OK, co.Get(2, 0, &vval2));
ASSERT_EQ(TT_DOUBLE, vval2.type);
ASSERT_EQ(8.0, vval2.dVal);
}
TEST(TestSelectedOutput, TestEndRow2)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ(0, co.PushBackDouble("pH", 6.0));
ASSERT_EQ(0, co.PushBackDouble("pH", 7.0));
ASSERT_EQ(0, co.PushBackDouble("pH", 8.0));
ASSERT_EQ(0, co.PushBackDouble("pH", 9.0));
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v;
ASSERT_EQ(TT_EMPTY, v.type);
ASSERT_EQ(VR_OK, co.Get(0, 0, &v));
ASSERT_EQ(TT_STRING, v.type);
ASSERT_EQ(std::string("pH"), std::string(v.sVal));
CVar vval;
ASSERT_EQ(TT_EMPTY, vval.type);
ASSERT_EQ(VR_OK, co.Get(1, 0, &vval));
ASSERT_EQ(TT_DOUBLE, vval.type);
ASSERT_EQ(9.0, vval.dVal); // dups get overwritten
ASSERT_EQ(0, co.PushBackDouble("pH", 8.0));
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)3, co.GetRowCount());
CVar vval3;
ASSERT_EQ(TT_EMPTY, vval3.type);
ASSERT_EQ(VR_OK, co.Get(1, 0, &vval3));
ASSERT_EQ(TT_DOUBLE, vval3.type);
ASSERT_EQ(9.0, vval3.dVal);
CVar vval2;
ASSERT_EQ(TT_EMPTY, vval2.type);
ASSERT_EQ(VR_OK, co.Get(2, 0, &vval2));
ASSERT_EQ(TT_DOUBLE, vval2.type);
ASSERT_EQ(8.0, vval2.dVal);
}
TEST(TestSelectedOutput, TestTooManyHeadings)
{
// COMMENT: {8/26/2013 4:12:03 PM} IPhreeqc p;
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ((size_t)0, p.PtrSelectedOutput->GetColCount());
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ((size_t)0, p.PtrSelectedOutput->GetRowCount());
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} p.PtrSelectedOutput->Clear();
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ((size_t)0, p.PtrSelectedOutput->GetColCount());
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ((size_t)0, p.PtrSelectedOutput->GetRowCount());
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} // USER_PUNCH
// COMMENT: {8/26/2013 4:12:03 PM} // -headings 1.name 1.type 1.moles
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} p.PhreeqcPtr->n_user_punch_index = 0;
// COMMENT: {8/26/2013 4:12:03 PM} p.PhreeqcPtr->UserPunch_map[1] = UserPunch();
// COMMENT: {8/26/2013 4:12:03 PM} p.PhreeqcPtr->current_user_punch = &(p.PhreeqcPtr->UserPunch_map[1]);
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} std::vector< std::string > headings;
// COMMENT: {8/26/2013 4:12:03 PM} headings.push_back("1.name");
// COMMENT: {8/26/2013 4:12:03 PM} headings.push_back("1.type");
// COMMENT: {8/26/2013 4:12:03 PM} headings.push_back("1.moles");
// COMMENT: {8/26/2013 4:12:03 PM} p.PhreeqcPtr->UserPunch_map[1].Set_headings(headings);
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(0, p.EndRow());
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ((size_t)3, p.PtrSelectedOutput->GetColCount());
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ((size_t)2, p.PtrSelectedOutput->GetRowCount());
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM}#if defined(_DEBUG)
// COMMENT: {8/26/2013 4:12:03 PM} p.PtrSelectedOutput->Dump("TestTooManyHeadings");
// COMMENT: {8/26/2013 4:12:03 PM}#endif
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} // clean up headings
// COMMENT: {8/26/2013 4:12:03 PM} p.PhreeqcPtr->UserPunch_map[1].Get_headings().empty();
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} CVar head0, head1, head2;
// COMMENT: {8/26/2013 4:12:03 PM} CVar val0, val1, val2;
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(VR_OK, p.PtrSelectedOutput->Get(0, 0, &head0));
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(VR_OK, p.PtrSelectedOutput->Get(0, 1, &head1));
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(VR_OK, p.PtrSelectedOutput->Get(0, 2, &head2));
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(VR_OK, p.PtrSelectedOutput->Get(1, 0, &val0));
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(VR_OK, p.PtrSelectedOutput->Get(1, 1, &val1));
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(VR_OK, p.PtrSelectedOutput->Get(1, 2, &val2));
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(TT_STRING, head0.type);
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(TT_STRING, head1.type);
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(TT_STRING, head2.type);
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(TT_EMPTY, val0.type);
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(TT_EMPTY, val1.type);
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(TT_EMPTY, val2.type);
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(std::string("1.name"), std::string(head0.sVal));
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(std::string("1.type"), std::string(head1.sVal));
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(std::string("1.moles"), std::string(head2.sVal));
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(0, p.PtrSelectedOutput->PushBackLong("sim", 1));
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(0, p.PtrSelectedOutput->PushBackString("state", "i_soln"));
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(0, p.PtrSelectedOutput->PushBackLong("soln", 22));
// COMMENT: {8/26/2013 4:12:03 PM}
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ(0, p.PtrSelectedOutput->EndRow());
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ((size_t)6, p.PtrSelectedOutput->GetColCount());
// COMMENT: {8/26/2013 4:12:03 PM} ASSERT_EQ((size_t)3, p.PtrSelectedOutput->GetRowCount());
// COMMENT: {8/26/2013 4:12:03 PM}#if defined(_DEBUG)
// COMMENT: {8/26/2013 4:12:03 PM} p.PtrSelectedOutput->Dump("TestTooManyHeadings");
// COMMENT: {8/26/2013 4:12:03 PM}#endif
}
TEST(TestSelectedOutput, TestNotEnoughHeadings)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
// USER_PUNCH
// -headings 1.name 1.type 1.moles
ASSERT_EQ(0, co.PushBackLong("sim", 1));
ASSERT_EQ(0, co.PushBackString("state", "i_soln"));
ASSERT_EQ(0, co.PushBackLong("soln", 22));
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)3, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
#if defined(_DEBUG)
co.Dump("TestNotEnoughHeadings");
#endif
ASSERT_EQ(0, co.PushBackLong("sim", 2));
ASSERT_EQ(0, co.PushBackString("state", "react"));
ASSERT_EQ(0, co.PushBackLong("soln", 23));
ASSERT_EQ(0, co.PushBackEmpty("no_heading_1"));
ASSERT_EQ(0, co.PushBackEmpty("no_heading_2"));
ASSERT_EQ(0, co.PushBackEmpty("no_heading_3"));
#if defined(_DEBUG)
co.Dump("TestNotEnoughHeadings");
#endif
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)6, co.GetColCount());
ASSERT_EQ((size_t)3, co.GetRowCount());
CVar head0, head1, head2, head3, head4, head5;
CVar val0, val1, val2, val3, val4, val5;
ASSERT_EQ(VR_OK, co.Get(0, 0, &head0));
ASSERT_EQ(VR_OK, co.Get(0, 1, &head1));
ASSERT_EQ(VR_OK, co.Get(0, 2, &head2));
ASSERT_EQ(VR_OK, co.Get(0, 3, &head3));
ASSERT_EQ(VR_OK, co.Get(0, 4, &head4));
ASSERT_EQ(VR_OK, co.Get(0, 5, &head5));
ASSERT_EQ(VR_OK, co.Get(1, 0, &val0));
ASSERT_EQ(VR_OK, co.Get(1, 1, &val1));
ASSERT_EQ(VR_OK, co.Get(1, 2, &val2));
ASSERT_EQ(VR_OK, co.Get(1, 3, &val3));
ASSERT_EQ(VR_OK, co.Get(1, 4, &val4));
ASSERT_EQ(VR_OK, co.Get(1, 5, &val5));
ASSERT_EQ(TT_STRING, head0.type);
ASSERT_EQ(TT_STRING, head1.type);
ASSERT_EQ(TT_STRING, head2.type);
ASSERT_EQ(TT_STRING, head3.type);
ASSERT_EQ(TT_STRING, head4.type);
ASSERT_EQ(TT_STRING, head5.type);
ASSERT_EQ(TT_LONG, val0.type);
ASSERT_EQ(TT_STRING, val1.type);
ASSERT_EQ(TT_LONG, val2.type);
ASSERT_EQ(TT_EMPTY, val3.type);
ASSERT_EQ(TT_EMPTY, val4.type);
ASSERT_EQ(TT_EMPTY, val5.type);
ASSERT_EQ(std::string("sim"), std::string(head0.sVal));
ASSERT_EQ(std::string("state"), std::string(head1.sVal));
ASSERT_EQ(std::string("soln"), std::string(head2.sVal));
ASSERT_EQ(std::string("no_heading_1"), std::string(head3.sVal));
ASSERT_EQ(std::string("no_heading_2"), std::string(head4.sVal));
ASSERT_EQ(std::string("no_heading_3"), std::string(head5.sVal));
ASSERT_EQ(1l, val0.lVal);
ASSERT_EQ(std::string("i_soln"), std::string(val1.sVal));
ASSERT_EQ(22l, val2.lVal);
}
TEST(TestSelectedOutput, TestInvalidRow)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
CVar v;
ASSERT_EQ(VR_INVALIDROW, co.Get(0, 0, &v));
ASSERT_EQ(TT_ERROR, v.type);
ASSERT_EQ(VR_INVALIDROW, v.vresult);
ASSERT_EQ(VR_INVALIDROW, co.Get(-1, -1, &v));
ASSERT_EQ(TT_ERROR, v.type);
ASSERT_EQ(VR_INVALIDROW, v.vresult);
ASSERT_EQ(0, co.PushBackEmpty("heading"));
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
ASSERT_EQ(VR_OK, co.Get(0, 0, &v));
ASSERT_EQ(TT_STRING, v.type);
ASSERT_EQ(std::string("heading"), std::string(v.sVal));
ASSERT_EQ(VR_OK, co.Get(1, 0, &v));
ASSERT_EQ(TT_EMPTY, v.type);
ASSERT_EQ(VR_INVALIDROW, co.Get(2, 0, &v));
ASSERT_EQ(TT_ERROR, v.type);
ASSERT_EQ(VR_INVALIDROW, v.vresult);
}
TEST(TestSelectedOutput, TestInvalidCol)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
CVar v;
ASSERT_EQ(VR_INVALIDROW, co.Get(0, 0, &v));
ASSERT_EQ(TT_ERROR, v.type);
ASSERT_EQ(VR_INVALIDROW, v.vresult);
ASSERT_EQ(VR_INVALIDROW, co.Get(-1, -1, &v));
ASSERT_EQ(TT_ERROR, v.type);
ASSERT_EQ(VR_INVALIDROW, v.vresult);
ASSERT_EQ(0, co.PushBackEmpty("heading"));
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
ASSERT_EQ(VR_OK, co.Get(0, 0, &v));
ASSERT_EQ(TT_STRING, v.type);
ASSERT_EQ(std::string("heading"), std::string(v.sVal));
ASSERT_EQ(VR_OK, co.Get(1, 0, &v));
ASSERT_EQ(TT_EMPTY, v.type);
ASSERT_EQ(VR_INVALIDCOL, co.Get(0, 1, &v));
ASSERT_EQ(TT_ERROR, v.type);
ASSERT_EQ(VR_INVALIDCOL, v.vresult);
ASSERT_EQ(VR_INVALIDCOL, co.Get(0, -1, &v));
ASSERT_EQ(TT_ERROR, v.type);
ASSERT_EQ(VR_INVALIDCOL, v.vresult);
}
TEST(TestSelectedOutput, TestGet)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ(0, co.PushBackEmpty("heading"));
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v0 = co.Get(0, 0);
ASSERT_EQ(TT_STRING, v0.type);
ASSERT_EQ(std::string("heading"), std::string(v0.sVal));
CVar v1 = co.Get(1, 0);
ASSERT_EQ(TT_EMPTY, v1.type);
}
TEST(TestSelectedOutput, TestLongHeadings)
{
CSelectedOutput co;
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
co.Clear();
ASSERT_EQ((size_t)0, co.GetColCount());
ASSERT_EQ((size_t)0, co.GetRowCount());
ASSERT_EQ(0, co.PushBackEmpty("heading890123456789012345678901234567890123456789"));
ASSERT_EQ(0, co.EndRow());
ASSERT_EQ((size_t)1, co.GetColCount());
ASSERT_EQ((size_t)2, co.GetRowCount());
CVar v0 = co.Get(0, 0);
ASSERT_EQ(TT_STRING, v0.type);
ASSERT_EQ(std::string("heading890123456789012345678901234567890123456789"), std::string(v0.sVal));
CVar v1 = co.Get(1, 0);
ASSERT_EQ(TT_EMPTY, v1.type);
}

10
gtest/TestVar.cpp Normal file
View File

@ -0,0 +1,10 @@
#include <gtest/gtest.h>
#include "../src/Var.h"
TEST(TestVar, VarInit)
{
VAR v;
::VarInit(&v);
ASSERT_EQ(TT_EMPTY, v.type);
}

11
gtest/conv_fail.in Normal file
View File

@ -0,0 +1,11 @@
SOLUTION 1
pH 7
Na 1
PHASES
Fix_H+
H+ = H+
log_k 0
EQUILIBRIUM_PHASES
Fix_H+ -10 HCl 10
##SELECTED_OUTPUT
END

42
gtest/dump Normal file
View File

@ -0,0 +1,42 @@
database ../database/Amm.dat
solution 0
units mol/kgw
-water 0.4
pH 7 charge
Na 1
solution 101
units mol/kgw
-water 0.2
pH 7 charge
solution 1-100
units mol/kgw
pH 7 charge
-water 0.2
Amm 1
GAS_PHASE 1-100
-fixed_volume
-volume 1
-temperature 30
Amm(g) 0.1
N2(g) 0.9
#---------------- OUTPUT and TRANSPORT ----------------#
KNOBS
-logfile true
transport
-cells 100
-shifts 100
-lengths 0.1
-time_step 0.1
-flow_direction diffusion
-bc 1 1
-dump dump.phrq
-dump_frequency 10
-dump_restart 0
-print_frequency 50
end

7231
gtest/iso.dat Normal file

File diff suppressed because it is too large Load Diff

349
gtest/kinn20140218 Normal file
View File

@ -0,0 +1,349 @@
#
#*** PhreePlot 1 (Win32) *** 20:14:59 13 Feb 2014
# Incorporating the PHREEQC library by DL Parkhurst, SR Charlton (USGS),
# & CAJ Appelo (Amsterdam)
# Hunt & Track by DG Kinniburgh, and DM Cooper, CEH (NERC)
# Fitting by MJD Powell (University of Cambridge)
# Postscript plotting by KE Kohler
#
#Input filename: C:\PhreePlot\unittests\custom\contouring\As3_logNaVspH.ppi.
#
#Calculating... 1
PRINT
-selected_output false
PHASES
Fix_H+
H+ = H+
log_k 0
SOLUTION_MASTER_SPECIES
[N5] [N5]O3- 0 14 14
Perchlorate Perchlorate- 0 35 35
SOLUTION_SPECIES
[N5]O3- = [N5]O3-
log_k 0
Perchlorate- = Perchlorate-
log_k 0
SURFACE_MASTER_SPECIES
Goe_uni Goe_uniOH1.5
Goe_tri Goe_triOH0.5
SURFACE_SPECIES
Goe_triOH0.5 = Goe_triOH0.5
-cd_music 0 0 0 0 0
log_k 0
Goe_triOH0.5 = Goe_triO-0.5 + 0.5H+
-cd_music -0.5 0 0 0 0
log_k 10
Goe_triO-0.5 + H+ = Goe_triOH+0.5
-cd_music 1 0 0 0 0
log_k 9.20
Goe_triO-0.5 + Li+ = Goe_triOLi+0.5
-cd_music 0 1 0 0 0
log_k 0.10
Goe_triO-0.5 + Na+ = Goe_triONa+0.5
-cd_music 0 1 0 0 0
log_k -0.60
Goe_triO-0.5 + K+ = Goe_triOK+0.5
-cd_music 0 1 0 0 0
log_k -1.61
Goe_triO-0.5 + H+ + NO3- = Goe_triOHNO3-0.5
-cd_music 1 -1 0 0 0
log_k 8.52
Goe_triO-0.5 + H+ + [N5]O3- = Goe_triOH[N5]O3-0.5
-cd_music 1 -1 0 0 0
log_k 8.52
Goe_triO-0.5 + H+ + Cl- = Goe_triOHCl-0.5
-cd_music 1 -1 0 0 0
log_k 8.75
Goe_uniOH1.5 = Goe_uniOH1.5
-cd_music 0 0 0 0 0
log_k 0
Goe_uniOH1.5 = Goe_uniOH-0.5 + 0.5H+
-cd_music -0.5 0 0 0 0
log_k 10
Goe_uniOH-0.5 + H+ = Goe_uniOH2+0.5
-cd_music 1 0 0 0 0
log_k 9.20
Goe_uniOH-0.5 + Li+ = Goe_uniOHLi+0.5
-cd_music 0 1 0 0 0
log_k 0.10
Goe_uniOH-0.5 + Na+ = Goe_uniOHNa+0.5
-cd_music 0 1 0 0 0
log_k -0.60
Goe_uniOH-0.5 + K+ = Goe_uniOHK+0.5
-cd_music 0 1 0 0 0
log_k -1.61
Goe_uniOH-0.5 + H+ + NO3- = Goe_uniOH2NO3-0.5
-cd_music 1 -1 0 0 0
log_k 8.52
Goe_uniOH-0.5 + H+ + [N5]O3- = Goe_uniOH2[N5]O3-0.5
-cd_music 1 -1 0 0 0
log_k 8.52
Goe_uniOH-0.5 + H+ + Cl- = Goe_uniOH2Cl-0.5
-cd_music 1 -1 0 0 0
log_k 8.75
Goe_uniOH-0.5 + Ca+2 = Goe_uniOHCa+1.5
log_k 2.85
-cd_music 0.0 2.0 0 0 0
Goe_triO-0.5 + Ca+2 = Goe_triOCa+1.5
log_k 2.85
-cd_music 0.0 2.0 0 0 0
Goe_uniOH-0.5 + Ca+2 = Goe_uniOHCa+1.5
log_k 3.69
-cd_music 0.32 1.68 0 0 0
Goe_uniOH-0.5 + Ca+2 + H2O = Goe_uniOHCaOH+0.5 + H+
log_k -9.17
-cd_music 0.32 0.68 0 0 0
2Goe_uniOH-0.5 + Mg+2 = (Goe_uniOH)2Mg+1
log_k 4.89
-cd_music 0.71 1.29 0 0 0
2Goe_uniOH-0.5 + Mg+2 + H2O = (Goe_uniOH)2MgOH + H+
log_k -6.44
-cd_music 0.71 0.29 0 0 0
2Goe_uniOH-0.5 + Cu+2 = (Goe_uniOH)2Cu+1
log_k 9.18
-cd_music 0.84 1.16 0 0 0
2Goe_uniOH-0.5 + Cu+2 + H2O = (Goe_uniOH)2CuOH + H+
log_k 3.60
-cd_music 0.84 0.16 0 0 0
2Goe_uniOH-0.5 + 2Cu+2 + 2H2O = (Goe_uniOH)2Cu2(OH)2+1 + 2H+
log_k 3.65
-cd_music 0.84 1.16 0 0 0
2Goe_uniOH-0.5 + 2Cu+2 + 3H2O = (Goe_uniOH)2Cu2(OH)3 + 3H+
log_k -3.10
-cd_music 0.84 0.16 0 0 0
Goe_uniOH-0.5 + 2H+ + AsO4-3 = Goe_uniOAsO2OH-1.5 + H2O
log_k 26.60
-cd_music 0.30 -1.30 0 0 0
2Goe_uniOH-0.5 + 2H+ + AsO4-3 = (Goe_uniO)2AsO2-2 + 2H2O
log_k 29.77
-cd_music 0.47 -1.47 0 0 0
2Goe_uniOH-0.5 + 3H+ + AsO4-3 = (Goe_uniO)2AsOOH- + 2H2O
log_k 33.00
-cd_music 0.58 -0.58 0 0 0
Goe_uniOH-0.5 + H3AsO3 = Goe_uniOAs(OH)2-0.5 + H2O
log_k 4.91
-cd_music 0.16 -0.16 0 0 0
2Goe_uniOH-0.5 + H3AsO3 = (Goe_uniO)2AsOH-1 + 2H2O
log_k 7.26
-cd_music 0.34 -0.34 0 0 0
Goe_uniOH-0.5 + 2H+ + PO4-3 = Goe_uniOPO2OH-1.5 + H2O
log_k 27.65
-cd_music 0.28 -1.28 0 0 0
2Goe_uniOH-0.5 + 2H+ + PO4-3 = (Goe_uniO)2PO2-2 + 2H2O
log_k 29.77
-cd_music 0.46 -1.46 0 0 0
2Goe_uniOH-0.5 + 2H+ + CO3-2 = (Goe_uniO)2CO- + 2H2O
log_k 22.33
-cd_music 0.68 -0.68 0 0 0
Goe_uniOH-0.5 + H+ + SO4-2 = Goe_uniOSO3-1.5 + H2O
log_k 9.37
-cd_music 0.5 -1.5 0 0 0
Goe_uniOH-0.5 + H+ + SO4-2 = Goe_uniOSO3-1.5 + H2O
log_k 11.06
-cd_music 1 -1.84 -0.16 0 0
2Goe_uniOH-0.5 + H4SiO4 = (Goe_uniO)2Si(OH)2-1 + 2H2O
log_k 5.85
-cd_music 0.29 -0.29 0 0 0
2Goe_uniOH-0.5 + 4H4SiO4 = (Goe_uniO)2SiOHOSi3O2(OH)7-1 + 5H2O
log_k 13.98
-cd_music 0.29 -0.29 0 0 0
2Goe_uniOH-0.5 + 4H4SiO4 = (Goe_uniO)2SiOHOSi3O3(OH)6-2 + 5H2O + H+
log_k 7.47
-cd_music 0.29 -1.29 0 0 0
SURFACE_MASTER_SPECIES
Fhy_unie Fhy_unieOH1.5
Fhy_unic Fhy_unicOH1.5
Fhy_tri Fhy_triOH0.5
SURFACE_SPECIES
Fhy_triOH0.5 = Fhy_triOH0.5
-cd_music 0 0 0 0 0
log_k 0
Fhy_triOH0.5 = Fhy_triO-0.5 + 0.5H+
-cd_music -0.5 0 0 0 0
log_k 10
Fhy_triO-0.5 + H+ = Fhy_triOH+0.5
-cd_music 1 0 0 0 0
log_k 8.06
Fhy_triO-0.5 + Na+ = Fhy_triONa+0.5
-cd_music 0 1 0 0 0
log_k -0.60
Fhy_triO-0.5 + H+ + NO3- = Fhy_triOHNO3-0.5
-cd_music 1 -1 0 0 0
log_k 7.38
Fhy_triO-0.5 + H+ + [N5]O3- = Fhy_triOH[N5]O3-0.5
-cd_music 1 -1 0 0 0
log_k 7.38
Fhy_triO-0.5 + H+ + Cl- = Fhy_triOHCl-0.5
-cd_music 1 -1 0 0 0
log_k 7.61
Fhy_triO-0.5 + H+ + Perchlorate- = Fhy_triOHPerchlorate-0.5
-cd_music 1 -1 0 0 0
log_k 6.36
Fhy_unieOH1.5 = Fhy_unieOH1.5
-cd_music 0 0 0 0 0
log_k 0
Fhy_unieOH1.5 = Fhy_unieOH-0.5 + 0.5H+
-cd_music -0.5 0 0 0 0
log_k 10
Fhy_unieOH-0.5 + H+ = Fhy_unieOH2+0.5
-cd_music 1 0 0 0 0
log_k 8.06
Fhy_unieOH-0.5 + Na+ = Fhy_unieOHNa+0.5
-cd_music 0 1 0 0 0
log_k -0.60
Fhy_unieOH-0.5 + H+ + NO3- = Fhy_unieOH2NO3-0.5
-cd_music 1 -1 0 0 0
log_k 7.38
Fhy_unieOH-0.5 + H+ + [N5]O3- = Fhy_unieOH2[N5]O3-0.5
-cd_music 1 -1 0 0 0
log_k 7.38
Fhy_unieOH-0.5 + H+ + Cl- = Fhy_unieOH2Cl-0.5
-cd_music 1 -1 0 0 0
log_k 7.61
Fhy_unieOH-0.5 + H+ + Perchlorate- = Fhy_unieOH2Perchlorate-0.5
-cd_music 1 -1 0 0 0
log_k 6.36
Fhy_unicOH1.5 = Fhy_unicOH1.5
-cd_music 0 0 0 0 0
log_k 0
Fhy_unicOH1.5 = Fhy_unicOH-0.5 + 0.5H+
-cd_music -0.5 0 0 0 0
log_k 10
Fhy_unicOH-0.5 + H+ = Fhy_unicOH2+0.5
-cd_music 1 0 0 0 0
log_k 8.06
Fhy_unicOH-0.5 + Na+ = Fhy_unicOHNa+0.5
-cd_music 0 1 0 0 0
log_k -0.60
Fhy_unicOH-0.5 + H+ + NO3- = Fhy_unicOH2NO3-0.5
-cd_music 1 -1 0 0 0
log_k 7.38
Fhy_unicOH-0.5 + H+ + [N5]O3- = Fhy_unicOH2[N5]O3-0.5
-cd_music 1 -1 0 0 0
log_k 7.38
Fhy_unicOH-0.5 + H+ + Cl- = Fhy_unicOH2Cl-0.5
-cd_music 1 -1 0 0 0
log_k 7.61
Fhy_unicOH-0.5 + H+ + Perchlorate- = Fhy_unicOH2Perchlorate-0.5
-cd_music 1 -1 0 0 0
log_k 6.36
2Fhy_unicOH-0.5 + 2H+ + CO3-2 = Fhy_unic2O2CO- + 2H2O
-cd_music 0.62 -0.62 0 0 0
log_k 21.50
2Fhy_unieOH-0.5 + UO2+2 = Fhy_unie2(OH)2UO2+
-cd_music 0.9 1.1 0 0 0
log_k 9.0
2Fhy_unieOH-0.5 + UO2+2 + H2O = Fhy_unie2(OH)2UO2OH + H+
-cd_music 0.9 0.1 0 0 0
log_k 3.30
2Fhy_unieOH-0.5 + UO2+2 + 2H2O = Fhy_unie2(OH)2UO2(OH)2- + 2H+
-cd_music 0.9 -0.9 0 0 0
log_k -5.3
2Fhy_unieOH-0.5 + UO2+2 + CO3-2 + H2O = Fhy_unie2(OH)2UO2CO3(OH)-2 + H+
-cd_music 0.9 -1.9 0 0 0
log_k 10.49
Fhy_unicOH-0.5 + UO2+2 + 3CO3-2 + H+ = Fhy_unic(OCO2)UO2(CO3)2-3.5 + H2O
-cd_music 0.33 -3.33 0 0 0
log_k 36.63
Fhy_unieOH-0.5 + UO2+2 + 3CO3-2 + H+ = Fhy_unie(OCO2)UO2(CO3)2-3.5 + H2O
-cd_music 0.33 -3.33 0 0 0
log_k 36.63
2Fhy_unieOH-0.5 + 3UO2+2 + 6H2O = Fhy_unie2(OH)2(UO2)3(OH)6- + 6H+
-cd_music 0.9 -0.9 0 0 0
log_k -15.8
2Fhy_unieOH-0.5 + 3UO2+2 + CO3-2 + 3H2O = Fhy_unie2(OH)2(UO2)3(OH)3CO3 + 3H+
-cd_music 0.9 0.1 0 0 0
log_k 14.6
END
SOLUTION 1
Temp 20
pH 3.8
units mol/kgw
Na 0.001
Cl 0.001
EQUILIBRIUM_PHASES 1
Fix_H+ -4 NaOH
-force_equality true
O2(g) -70
SURFACE 1
Goe_uniOH1.5 3.5 98 0.1
Goe_triOH0.5 2.7
-cd_music
-sites_units density
-cap 0.85 0.75
SAVE surface 2
END
use surface 2
SOLUTION 1
Temp 20
pH 3.8
units mol/kgw
Na 0.001
Cl 0.001
REACTION
Na2HAsO4 1
0.0001 in 1 step
PRINT
-selected_output true
SELECTED_OUTPUT
-reset false
-high_precision false
USER_PUNCH
-headings logNa pH I dissAs
10 IF (TOT("As") > 0) THEN dissas = TOT("As") ELSE dissas = -99999
20 totna = TOT("Na")
30 IF (totna > 0) THEN logna = LOG10(totna) ELSE logna = -99999
40 PUNCH logna, -la("H+"), mu, dissas
50 PRINT "NaT = ", totna
EQUILIBRIUM_PHASES 1
Fix_H+ -4 NaOH
-force_equality true
O2(g) -70
END
SOLUTION 1
Temp 20
pH 3.8
units mol/kgw
Na 0.00215443469
Cl 0.00215443469
EQUILIBRIUM_PHASES 1
Fix_H+ -4 NaOH
-force_equality true
O2(g) -70
SURFACE 1
Goe_uniOH1.5 3.5 98 0.1
Goe_triOH0.5 2.7
-cd_music
-sites_units density
-cap 0.85 0.75
SAVE surface 2
END
use surface 2
SOLUTION 1
Temp 20
pH 3.8
units mol/kgw
Na 0.00215443469
Cl 0.00215443469
REACTION
Na2HAsO4 1
0.0001 in 1 step
PRINT
-selected_output true
SELECTED_OUTPUT
-reset false
-high_precision false
USER_PUNCH
-headings logNa pH I dissAs
10 IF (TOT("As") > 0) THEN dissas = TOT("As") ELSE dissas = -99999
20 totna = TOT("Na")
30 IF (totna > 0) THEN logna = LOG10(totna) ELSE logna = -99999
40 PUNCH logna, -la("H+"), mu, dissas
50 PRINT "NaT = ", totna
EQUILIBRIUM_PHASES 1
Fix_H+ -4 NaOH
-force_equality true
O2(g) -70
END

1556
gtest/missing_e.dat Normal file

File diff suppressed because it is too large Load Diff

105
gtest/multi_punch Normal file
View File

@ -0,0 +1,105 @@
SOLUTION 1
pH 7 charge
Na 1
Cl 1
Ca 1
C 2
END
CALCULATE_VALUES
TOTAL_C
-start
10 save TOT("C")
-end
END
EQUILIBRIUM_PHASES 1
CO2(g) -2
Dolomite 0
END
REACTION 1
HCl 1
0.1 mmol
END
GAS_PHASE
-fixed_volume
N2(g) 1.2
END
KINETICS
Calcite
-tol 1e-8
-m0 3.e-3
-m 3.e-3
-parms 50 0.6
END
SOLID_SOLUTION
Sulfate
-comp Anhydrite 1.0
-comp Barite 1.0
END
RUN_CELLS
-cell 1
SELECTED_OUTPUT
-file multi_punch_1.sel
-reset false
-sim
-state
-solution
-dist
-time
-step
-pH
-pe
-reaction
-temperature
-alkalinity
-ionic_strength
-water
-charge_balance
-percent_error
-totals Na Ca
-molalities Na+ HCO3-
-activities Ca+2 CO3-2
-equilibrium_phases CO2(g) dolomite
-saturation_indices Halite
-gases N2(g)
-kinetics Calcite
-solid_solutions Anhydrite Barite
-calculate_values TOTAL_C
-inverse false
SELECTED_OUTPUT 2
-file multi_punch_2.sel
-si Halite Calcite
USER_PUNCH 20
-heading Dummy
10 PUNCH "Dummy"
END
USER_PUNCH 2
-heading DUMMY_1 DUMMY_2
10 PUNCH "Dummy1", "Dummy2"
RUN_CELLS
-cell 1
SELECTED_OUTPUT 1
-active false
END
RUN_CELLS
-cell 1
SELECTED_OUTPUT 1
-active true
END
SOLUTION 2
pH 7 charge
END
SOLUTION 3
pH 7 charge
Na 1
Cl 1
END
INVERSE_MODELING
-solution 2 3
-phases
Halite
SELECTED_OUTPUT 3
-reset false
-file multi_punch_3.sel
END
RUN_CELLS
-cell 1

102
gtest/multi_punch_no_set Normal file
View File

@ -0,0 +1,102 @@
SOLUTION 1
pH 7 charge
Na 1
Cl 1
Ca 1
C 2
END
CALCULATE_VALUES
TOTAL_C
-start
10 save TOT("C")
-end
END
EQUILIBRIUM_PHASES 1
CO2(g) -2
Dolomite 0
END
REACTION 1
HCl 1
0.1 mmol
END
GAS_PHASE
-fixed_volume
N2(g) 1.2
END
KINETICS
Calcite
-tol 1e-8
-m0 3.e-3
-m 3.e-3
-parms 50 0.6
END
SOLID_SOLUTION
Sulfate
-comp Anhydrite 1.0
-comp Barite 1.0
END
RUN_CELLS
-cell 1
SELECTED_OUTPUT
-reset false
-sim
-state
-solution
-dist
-time
-step
-pH
-pe
-reaction
-temperature
-alkalinity
-ionic_strength
-water
-charge_balance
-percent_error
-totals Na Ca
-molalities Na+ HCO3-
-activities Ca+2 CO3-2
-equilibrium_phases CO2(g) dolomite
-saturation_indices Halite
-gases N2(g)
-kinetics Calcite
-solid_solutions Anhydrite Barite
-calculate_values TOTAL_C
-inverse false
SELECTED_OUTPUT 2
-si Halite Calcite
USER_PUNCH 20
-heading Dummy
10 PUNCH "Dummy"
END
USER_PUNCH 2
-heading DUMMY_1 DUMMY_2
10 PUNCH "Dummy1", "Dummy2"
RUN_CELLS
-cell 1
SELECTED_OUTPUT 1
-active false
END
RUN_CELLS
-cell 1
SELECTED_OUTPUT 1
-active true
END
SOLUTION 2
pH 7 charge
END
SOLUTION 3
pH 7 charge
Na 1
Cl 1
END
INVERSE_MODELING
-solution 2 3
-phases
Halite
SELECTED_OUTPUT 3
-reset false
END
RUN_CELLS
-cell 1

View File

@ -15,7 +15,13 @@
#include <vector>
#include "CVar.hxx"
class CSelectedOutput
#if defined(_WINDLL)
#define IPQ_DLL_EXPORT __declspec(dllexport)
#else
#define IPQ_DLL_EXPORT
#endif
class IPQ_DLL_EXPORT CSelectedOutput
{
public:
CSelectedOutput(void);

View File

@ -44,8 +44,8 @@ public:
static void safe_close(std::ostream **stream_ptr);
static void safe_close(FILE **file_ptr);
void close_ostreams(void);
void Set_io_error_count(int i) {this->io_error_count = i;};
int Get_io_error_count(void) {return this->io_error_count;};
void Set_io_error_count(int i) {this->io_error_count = i;};
int Get_io_error_count(void)const {return this->io_error_count;};
// istreams
@ -65,7 +65,7 @@ public:
void Set_output_ostream(std::ostream * out) {this->output_ostream = out;};
std::ostream *Get_output_ostream(void) {return this->output_ostream;};
void Set_output_on(bool tf) {this->output_on = tf;};
bool Get_output_on(void) {return this->output_on;};
bool Get_output_on(void)const {return this->output_on;};
// log_ostream
virtual bool log_open(const char *file_name, std::ios_base::openmode mode = std::ios_base::out);
@ -75,7 +75,7 @@ public:
void Set_log_ostream(std::ostream * out) {this->log_ostream = out;}
std::ostream *Get_log_ostream(void) {return this->log_ostream;}
void Set_log_on(bool tf) {this->log_on = tf;}
bool Get_log_on(void) {return this->log_on;}
bool Get_log_on(void)const {return this->log_on;}
// punch_ostream
virtual bool punch_open(const char *file_name, std::ios_base::openmode mode = std::ios_base::out, int n_user = 1);
@ -94,19 +94,19 @@ public:
void error_close(void);
virtual void error_msg(const char * str, bool stop=false);
void Set_error_ostream(std::ostream * out) {this->error_ostream = out;}
std::ostream *Get_error_ostream(void) {return this->error_ostream;}
std::ostream *Get_error_ostream(void)const {return this->error_ostream;}
void Set_error_on(bool tf) {this->error_on = tf;}
bool Get_error_on(void) {return this->error_on;}
bool Get_error_on(void)const {return this->error_on;}
virtual void warning_msg(const char *err_str);
#else
virtual bool error_open(const char *file_name, const char * mode = "w");
void error_flush(void);
void error_close(void);
virtual void error_msg(const char * str, bool stop=false);
void Set_error_file(FILE * out) {this->error_file = out;}
FILE *Get_error_file(void) {return this->error_file;}
void Set_error_file(FILE * out) {this->error_file = out;}
FILE *Get_error_file(void)const {return this->error_file;}
void Set_error_on(bool tf) {this->error_on = tf;}
bool Get_error_on(void) {return this->error_on;}
bool Get_error_on(void)const {return this->error_on;}
virtual void warning_msg(const char *err_str);
#endif
@ -118,7 +118,7 @@ public:
void Set_dump_ostream(std::ostream * out) {this->dump_ostream = out;};
std::ostream *Get_dump_ostream(void) {return this->dump_ostream;};
void Set_dump_on(bool tf) {this->dump_on = tf;};
bool Get_dump_on(void) {return this->dump_on;};
bool Get_dump_on(void)const {return this->dump_on;};
// fpunchf
virtual void fpunchf(const char *name, const char *format, double d);
@ -130,17 +130,17 @@ public:
virtual void screen_msg(const char * str);
void Set_screen_on(bool tf) {this->screen_on = tf;};
bool Get_screen_on(void) {return this->screen_on;};
bool Get_screen_on(void)const {return this->screen_on;};
// input methods
virtual int getc(void);
virtual LINE_TYPE get_line(void);
virtual LINE_TYPE get_logical_line(void);
bool check_key(std::string::iterator begin, std::string::iterator end);
std::string & Get_m_line() {return m_line;}
std::string & Get_m_line_save() {return m_line_save;}
std::string & Get_accumulated() {return accumulated;}
LINE_TYPE Get_m_line_type() {return m_line_type;};
std::string & Get_m_line() {return m_line;}
std::string & Get_m_line_save() {return m_line_save;}
std::string & Get_accumulated() {return accumulated;}
LINE_TYPE Get_m_line_type()const {return m_line_type;};
void Set_accumulate(bool tf)
{
if (tf)
@ -149,7 +149,7 @@ public:
}
this->accumulate = tf;
}
Keywords::KEYWORDS Get_m_next_keyword() const {return m_next_keyword;}
Keywords::KEYWORDS Get_m_next_keyword() const {return m_next_keyword;}
// echo
enum ECHO_OPTION
@ -158,16 +158,16 @@ public:
ECHO_OUTPUT
};
virtual void echo_msg(const char * str);
void Set_echo_on(bool tf) {this->echo_on = tf;};
bool Get_echo_on(void) {return this->echo_on;};
void Set_echo_destination(ECHO_OPTION eo) {this->echo_destination = eo;};
ECHO_OPTION Get_echo_destination(void) {return this->echo_destination;};
void Set_echo_on(bool tf) {this->echo_on = tf;};
bool Get_echo_on(void)const {return this->echo_on;};
void Set_echo_destination(ECHO_OPTION eo) {this->echo_destination = eo;};
ECHO_OPTION Get_echo_destination(void)const {return this->echo_destination;};
// data
protected:
std::ostream *output_ostream;
std::ostream *log_ostream;
std::ostream *punch_ostream;
std::ostream *output_ostream;
std::ostream *log_ostream;
std::ostream *punch_ostream;
#ifdef ERROR_OSTREAM
std::ostream *error_ostream;
#else

View File

@ -15,10 +15,17 @@
program test_f90
implicit none
INTEGER(KIND=4),PARAMETER :: EXIT_SUCCESS = 0
INTEGER(KIND=4),PARAMETER :: EXIT_FAILURE = 1
integer(KIND=4) F_MAIN
integer(KIND=4) I
I = F_MAIN()
end program test_f90
if (I .NE. EXIT_SUCCESS) then
STOP EXIT_FAILURE
endif
end program test_f90