mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
Merge branch 'gtest' into 'master'
Updated cmake build See merge request coupled/iphreeqc!16
This commit is contained in:
commit
19a4576e67
705
CMakeLists.txt
705
CMakeLists.txt
@ -1,17 +1,33 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
# CMAKE_MSVC_RUNTIME_LIBRARY requires 3.15
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
project (IPhreeqc CXX C)
|
||||
project (
|
||||
IPhreeqc
|
||||
VERSION 3.6.3
|
||||
LANGUAGES 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()
|
||||
|
||||
if (STANDALONE_BUILD)
|
||||
# Set a default build type if none was specified
|
||||
set(default_build_type "Release")
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||
STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
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,308 +35,326 @@ 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
|
||||
src/CSelectedOutput.hxx
|
||||
src/CVar.hxx
|
||||
src/Debug.h
|
||||
src/ErrorReporter.hxx
|
||||
src/IPhreeqc.cpp
|
||||
src/IPhreeqc.h
|
||||
src/IPhreeqc.hpp
|
||||
src/IPhreeqc_interface_F.cpp
|
||||
src/IPhreeqcCallbacks.h
|
||||
src/IPhreeqcLib.cpp
|
||||
src/phreeqcpp/advection.cpp
|
||||
src/phreeqcpp/basicsubs.cpp
|
||||
src/phreeqcpp/ChartHandler.cpp
|
||||
src/phreeqcpp/ChartHandler.h
|
||||
src/phreeqcpp/ChartObject.cpp
|
||||
src/phreeqcpp/ChartObject.h
|
||||
src/phreeqcpp/cl1.cpp
|
||||
src/phreeqcpp/common/Parser.cxx
|
||||
src/phreeqcpp/common/Parser.h
|
||||
src/phreeqcpp/common/PHRQ_base.cxx
|
||||
src/phreeqcpp/common/PHRQ_base.h
|
||||
src/phreeqcpp/common/PHRQ_io.cpp
|
||||
src/phreeqcpp/common/PHRQ_io.h
|
||||
src/phreeqcpp/common/phrqtype.h
|
||||
src/phreeqcpp/common/Utils.cxx
|
||||
src/phreeqcpp/common/Utils.h
|
||||
src/phreeqcpp/CurveObject.cpp
|
||||
src/phreeqcpp/CurveObject.h
|
||||
src/phreeqcpp/cvdense.cpp
|
||||
src/phreeqcpp/cvdense.h
|
||||
src/phreeqcpp/cvode.cpp
|
||||
src/phreeqcpp/cvode.h
|
||||
src/phreeqcpp/cxxKinetics.cxx
|
||||
src/phreeqcpp/cxxKinetics.h
|
||||
src/phreeqcpp/cxxMix.cxx
|
||||
src/phreeqcpp/cxxMix.h
|
||||
src/phreeqcpp/dense.cpp
|
||||
src/phreeqcpp/dense.h
|
||||
src/phreeqcpp/Dictionary.cpp
|
||||
src/phreeqcpp/Dictionary.h
|
||||
src/phreeqcpp/dumper.cpp
|
||||
src/phreeqcpp/dumper.h
|
||||
src/phreeqcpp/Exchange.cxx
|
||||
src/phreeqcpp/Exchange.h
|
||||
src/phreeqcpp/ExchComp.cxx
|
||||
src/phreeqcpp/ExchComp.h
|
||||
src/phreeqcpp/GasComp.cxx
|
||||
src/phreeqcpp/GasComp.h
|
||||
src/phreeqcpp/gases.cpp
|
||||
src/phreeqcpp/GasPhase.cxx
|
||||
src/phreeqcpp/GasPhase.h
|
||||
src/phreeqcpp/global_structures.h
|
||||
src/phreeqcpp/input.cpp
|
||||
src/phreeqcpp/integrate.cpp
|
||||
src/phreeqcpp/inverse.cpp
|
||||
src/phreeqcpp/ISolution.cxx
|
||||
src/phreeqcpp/ISolution.h
|
||||
src/phreeqcpp/ISolutionComp.cxx
|
||||
src/phreeqcpp/ISolutionComp.h
|
||||
src/phreeqcpp/isotopes.cpp
|
||||
src/phreeqcpp/kinetics.cpp
|
||||
src/phreeqcpp/KineticsComp.cxx
|
||||
src/phreeqcpp/KineticsComp.h
|
||||
src/phreeqcpp/mainsubs.cpp
|
||||
src/phreeqcpp/model.cpp
|
||||
src/phreeqcpp/NA.h
|
||||
src/phreeqcpp/NameDouble.cxx
|
||||
src/phreeqcpp/NameDouble.h
|
||||
src/phreeqcpp/NumKeyword.cxx
|
||||
src/phreeqcpp/NumKeyword.h
|
||||
src/phreeqcpp/nvector.cpp
|
||||
src/phreeqcpp/nvector.h
|
||||
src/phreeqcpp/nvector_serial.cpp
|
||||
src/phreeqcpp/nvector_serial.h
|
||||
src/phreeqcpp/parse.cpp
|
||||
src/phreeqcpp/PBasic.cpp
|
||||
src/phreeqcpp/PBasic.h
|
||||
src/phreeqcpp/phqalloc.cpp
|
||||
src/phreeqcpp/phqalloc.h
|
||||
src/phreeqcpp/Phreeqc.cpp
|
||||
src/phreeqcpp/Phreeqc.h
|
||||
src/phreeqcpp/PhreeqcKeywords/Keywords.cpp
|
||||
src/phreeqcpp/PhreeqcKeywords/Keywords.h
|
||||
src/phreeqcpp/PHRQ_io_output.cpp
|
||||
src/phreeqcpp/pitzer.cpp
|
||||
src/phreeqcpp/pitzer_structures.cpp
|
||||
src/phreeqcpp/PPassemblage.cxx
|
||||
src/phreeqcpp/PPassemblage.h
|
||||
src/phreeqcpp/PPassemblageComp.cxx
|
||||
src/phreeqcpp/PPassemblageComp.h
|
||||
src/phreeqcpp/prep.cpp
|
||||
src/phreeqcpp/Pressure.cxx
|
||||
src/phreeqcpp/Pressure.h
|
||||
src/phreeqcpp/print.cpp
|
||||
src/phreeqcpp/Reaction.cxx
|
||||
src/phreeqcpp/Reaction.h
|
||||
src/phreeqcpp/read.cpp
|
||||
src/phreeqcpp/ReadClass.cxx
|
||||
src/phreeqcpp/readtr.cpp
|
||||
src/phreeqcpp/runner.cpp
|
||||
src/phreeqcpp/runner.h
|
||||
src/phreeqcpp/SelectedOutput.cpp
|
||||
src/phreeqcpp/SelectedOutput.h
|
||||
src/phreeqcpp/Serializer.cxx
|
||||
src/phreeqcpp/Serializer.h
|
||||
src/phreeqcpp/sit.cpp
|
||||
src/phreeqcpp/smalldense.cpp
|
||||
src/phreeqcpp/smalldense.h
|
||||
src/phreeqcpp/Solution.cxx
|
||||
src/phreeqcpp/Solution.h
|
||||
src/phreeqcpp/SolutionIsotope.cxx
|
||||
src/phreeqcpp/SolutionIsotope.h
|
||||
src/phreeqcpp/spread.cpp
|
||||
src/phreeqcpp/SS.cxx
|
||||
src/phreeqcpp/SS.h
|
||||
src/phreeqcpp/SSassemblage.cxx
|
||||
src/phreeqcpp/SSassemblage.h
|
||||
src/phreeqcpp/SScomp.cxx
|
||||
src/phreeqcpp/SScomp.h
|
||||
src/phreeqcpp/step.cpp
|
||||
src/phreeqcpp/StorageBin.cxx
|
||||
src/phreeqcpp/StorageBin.h
|
||||
src/phreeqcpp/StorageBinList.cpp
|
||||
src/phreeqcpp/StorageBinList.h
|
||||
src/phreeqcpp/structures.cpp
|
||||
src/phreeqcpp/sundialsmath.cpp
|
||||
src/phreeqcpp/sundialsmath.h
|
||||
src/phreeqcpp/sundialstypes.h
|
||||
src/phreeqcpp/Surface.cxx
|
||||
src/phreeqcpp/Surface.h
|
||||
src/phreeqcpp/SurfaceCharge.cxx
|
||||
src/phreeqcpp/SurfaceCharge.h
|
||||
src/phreeqcpp/SurfaceComp.cxx
|
||||
src/phreeqcpp/SurfaceComp.h
|
||||
src/phreeqcpp/System.cxx
|
||||
src/phreeqcpp/System.h
|
||||
src/phreeqcpp/tally.cpp
|
||||
src/phreeqcpp/Temperature.cxx
|
||||
src/phreeqcpp/Temperature.h
|
||||
src/phreeqcpp/tidy.cpp
|
||||
src/phreeqcpp/transport.cpp
|
||||
src/phreeqcpp/Use.cpp
|
||||
src/phreeqcpp/Use.h
|
||||
src/phreeqcpp/UserPunch.cpp
|
||||
src/phreeqcpp/UserPunch.h
|
||||
src/phreeqcpp/utilities.cpp
|
||||
src/thread.h
|
||||
src/Var.c
|
||||
src/Var.h
|
||||
src/Version.h
|
||||
src/CSelectedOutput.cpp
|
||||
src/CSelectedOutput.hxx
|
||||
src/CVar.hxx
|
||||
src/Debug.h
|
||||
src/ErrorReporter.hxx
|
||||
src/IPhreeqc.cpp
|
||||
src/IPhreeqc.h
|
||||
src/IPhreeqc.hpp
|
||||
src/IPhreeqc_interface_F.cpp
|
||||
src/IPhreeqcCallbacks.h
|
||||
src/IPhreeqcLib.cpp
|
||||
src/phreeqcpp/advection.cpp
|
||||
src/phreeqcpp/basicsubs.cpp
|
||||
src/phreeqcpp/ChartHandler.cpp
|
||||
src/phreeqcpp/ChartHandler.h
|
||||
src/phreeqcpp/ChartObject.cpp
|
||||
src/phreeqcpp/ChartObject.h
|
||||
src/phreeqcpp/cl1.cpp
|
||||
src/phreeqcpp/common/Parser.cxx
|
||||
src/phreeqcpp/common/Parser.h
|
||||
src/phreeqcpp/common/PHRQ_base.cxx
|
||||
src/phreeqcpp/common/PHRQ_base.h
|
||||
src/phreeqcpp/common/PHRQ_exports.h
|
||||
src/phreeqcpp/common/PHRQ_io.cpp
|
||||
src/phreeqcpp/common/PHRQ_io.h
|
||||
src/phreeqcpp/common/phrqtype.h
|
||||
src/phreeqcpp/common/Utils.cxx
|
||||
src/phreeqcpp/common/Utils.h
|
||||
src/phreeqcpp/CurveObject.cpp
|
||||
src/phreeqcpp/CurveObject.h
|
||||
src/phreeqcpp/cvdense.cpp
|
||||
src/phreeqcpp/cvdense.h
|
||||
src/phreeqcpp/cvode.cpp
|
||||
src/phreeqcpp/cvode.h
|
||||
src/phreeqcpp/cxxKinetics.cxx
|
||||
src/phreeqcpp/cxxKinetics.h
|
||||
src/phreeqcpp/cxxMix.cxx
|
||||
src/phreeqcpp/cxxMix.h
|
||||
src/phreeqcpp/dense.cpp
|
||||
src/phreeqcpp/dense.h
|
||||
src/phreeqcpp/Dictionary.cpp
|
||||
src/phreeqcpp/Dictionary.h
|
||||
src/phreeqcpp/dumper.cpp
|
||||
src/phreeqcpp/dumper.h
|
||||
src/phreeqcpp/Exchange.cxx
|
||||
src/phreeqcpp/Exchange.h
|
||||
src/phreeqcpp/ExchComp.cxx
|
||||
src/phreeqcpp/ExchComp.h
|
||||
src/phreeqcpp/GasComp.cxx
|
||||
src/phreeqcpp/GasComp.h
|
||||
src/phreeqcpp/gases.cpp
|
||||
src/phreeqcpp/GasPhase.cxx
|
||||
src/phreeqcpp/GasPhase.h
|
||||
src/phreeqcpp/global_structures.h
|
||||
src/phreeqcpp/input.cpp
|
||||
src/phreeqcpp/integrate.cpp
|
||||
src/phreeqcpp/inverse.cpp
|
||||
src/phreeqcpp/ISolution.cxx
|
||||
src/phreeqcpp/ISolution.h
|
||||
src/phreeqcpp/ISolutionComp.cxx
|
||||
src/phreeqcpp/ISolutionComp.h
|
||||
src/phreeqcpp/isotopes.cpp
|
||||
src/phreeqcpp/kinetics.cpp
|
||||
src/phreeqcpp/KineticsComp.cxx
|
||||
src/phreeqcpp/KineticsComp.h
|
||||
src/phreeqcpp/mainsubs.cpp
|
||||
src/phreeqcpp/model.cpp
|
||||
src/phreeqcpp/NA.h
|
||||
src/phreeqcpp/NameDouble.cxx
|
||||
src/phreeqcpp/NameDouble.h
|
||||
src/phreeqcpp/NumKeyword.cxx
|
||||
src/phreeqcpp/NumKeyword.h
|
||||
src/phreeqcpp/nvector.cpp
|
||||
src/phreeqcpp/nvector.h
|
||||
src/phreeqcpp/nvector_serial.cpp
|
||||
src/phreeqcpp/nvector_serial.h
|
||||
src/phreeqcpp/parse.cpp
|
||||
src/phreeqcpp/PBasic.cpp
|
||||
src/phreeqcpp/PBasic.h
|
||||
src/phreeqcpp/phqalloc.cpp
|
||||
src/phreeqcpp/phqalloc.h
|
||||
src/phreeqcpp/Phreeqc.cpp
|
||||
src/phreeqcpp/Phreeqc.h
|
||||
src/phreeqcpp/PhreeqcKeywords/Keywords.cpp
|
||||
src/phreeqcpp/PhreeqcKeywords/Keywords.h
|
||||
src/phreeqcpp/PHRQ_io_output.cpp
|
||||
src/phreeqcpp/pitzer.cpp
|
||||
src/phreeqcpp/pitzer_structures.cpp
|
||||
src/phreeqcpp/PPassemblage.cxx
|
||||
src/phreeqcpp/PPassemblage.h
|
||||
src/phreeqcpp/PPassemblageComp.cxx
|
||||
src/phreeqcpp/PPassemblageComp.h
|
||||
src/phreeqcpp/prep.cpp
|
||||
src/phreeqcpp/Pressure.cxx
|
||||
src/phreeqcpp/Pressure.h
|
||||
src/phreeqcpp/print.cpp
|
||||
src/phreeqcpp/Reaction.cxx
|
||||
src/phreeqcpp/Reaction.h
|
||||
src/phreeqcpp/read.cpp
|
||||
src/phreeqcpp/ReadClass.cxx
|
||||
src/phreeqcpp/readtr.cpp
|
||||
src/phreeqcpp/runner.cpp
|
||||
src/phreeqcpp/runner.h
|
||||
src/phreeqcpp/SelectedOutput.cpp
|
||||
src/phreeqcpp/SelectedOutput.h
|
||||
src/phreeqcpp/Serializer.cxx
|
||||
src/phreeqcpp/Serializer.h
|
||||
src/phreeqcpp/sit.cpp
|
||||
src/phreeqcpp/smalldense.cpp
|
||||
src/phreeqcpp/smalldense.h
|
||||
src/phreeqcpp/Solution.cxx
|
||||
src/phreeqcpp/Solution.h
|
||||
src/phreeqcpp/SolutionIsotope.cxx
|
||||
src/phreeqcpp/SolutionIsotope.h
|
||||
src/phreeqcpp/spread.cpp
|
||||
src/phreeqcpp/SS.cxx
|
||||
src/phreeqcpp/SS.h
|
||||
src/phreeqcpp/SSassemblage.cxx
|
||||
src/phreeqcpp/SSassemblage.h
|
||||
src/phreeqcpp/SScomp.cxx
|
||||
src/phreeqcpp/SScomp.h
|
||||
src/phreeqcpp/step.cpp
|
||||
src/phreeqcpp/StorageBin.cxx
|
||||
src/phreeqcpp/StorageBin.h
|
||||
src/phreeqcpp/StorageBinList.cpp
|
||||
src/phreeqcpp/StorageBinList.h
|
||||
src/phreeqcpp/structures.cpp
|
||||
src/phreeqcpp/sundialsmath.cpp
|
||||
src/phreeqcpp/sundialsmath.h
|
||||
src/phreeqcpp/sundialstypes.h
|
||||
src/phreeqcpp/Surface.cxx
|
||||
src/phreeqcpp/Surface.h
|
||||
src/phreeqcpp/SurfaceCharge.cxx
|
||||
src/phreeqcpp/SurfaceCharge.h
|
||||
src/phreeqcpp/SurfaceComp.cxx
|
||||
src/phreeqcpp/SurfaceComp.h
|
||||
src/phreeqcpp/System.cxx
|
||||
src/phreeqcpp/System.h
|
||||
src/phreeqcpp/tally.cpp
|
||||
src/phreeqcpp/Temperature.cxx
|
||||
src/phreeqcpp/Temperature.h
|
||||
src/phreeqcpp/tidy.cpp
|
||||
src/phreeqcpp/transport.cpp
|
||||
src/phreeqcpp/Use.cpp
|
||||
src/phreeqcpp/Use.h
|
||||
src/phreeqcpp/UserPunch.cpp
|
||||
src/phreeqcpp/UserPunch.h
|
||||
src/phreeqcpp/utilities.cpp
|
||||
src/thread.h
|
||||
src/Var.c
|
||||
src/Var.h
|
||||
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
|
||||
${IPhreeqc_SOURCES}
|
||||
src/fimpl.h
|
||||
src/fwrap.cpp
|
||||
src/fwrap1.cpp
|
||||
src/fwrap2.cpp
|
||||
src/fwrap3.cpp
|
||||
src/fwrap4.cpp
|
||||
src/fwrap5.cpp
|
||||
src/fwrap6.cpp
|
||||
src/fwrap7.cpp
|
||||
src/fwrap8.cpp
|
||||
)
|
||||
set(IPhreeqc_SOURCES
|
||||
${IPhreeqc_SOURCES}
|
||||
src/fimpl.h
|
||||
src/fwrap.cpp
|
||||
src/fwrap1.cpp
|
||||
src/fwrap2.cpp
|
||||
src/fwrap3.cpp
|
||||
src/fwrap4.cpp
|
||||
src/fwrap5.cpp
|
||||
src/fwrap6.cpp
|
||||
src/fwrap7.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 (MSVC)
|
||||
option(BUILD_CLR_LIBS "Build CLR Libraries" OFF)
|
||||
endif()
|
||||
if (STANDALONE_BUILD)
|
||||
if (MSVC)
|
||||
option(BUILD_CLR_LIBS "Build CLR Libraries" OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set(LIB_TYPE SHARED)
|
||||
endif()
|
||||
add_library(IPhreeqc ${LIB_TYPE} ${IPhreeqc_SOURCES})
|
||||
|
||||
target_include_directories(IPhreeqc
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src>
|
||||
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src/phreeqcpp>
|
||||
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src/phreeqcpp/common>
|
||||
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords>
|
||||
$<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()
|
||||
|
||||
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
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc.h
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc.hpp
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqcCallbacks.h
|
||||
${PROJECT_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords/Keywords.h
|
||||
${PROJECT_SOURCE_DIR}/src/phreeqcpp/common/PHRQ_io.h
|
||||
${PROJECT_SOURCE_DIR}/src/Var.h
|
||||
)
|
||||
set(IPhreeqc_Headers
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc.h
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc.hpp
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqcCallbacks.h
|
||||
${PROJECT_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords/Keywords.h
|
||||
${PROJECT_SOURCE_DIR}/src/phreeqcpp/common/PHRQ_exports.h
|
||||
${PROJECT_SOURCE_DIR}/src/phreeqcpp/common/PHRQ_io.h
|
||||
${PROJECT_SOURCE_DIR}/src/Var.h
|
||||
)
|
||||
|
||||
if (IPHREEQC_ENABLE_MODULE)
|
||||
SET(IPhreeqc_SRC
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc_interface.F90
|
||||
${PROJECT_SOURCE_DIR}/src/README.Fortran
|
||||
)
|
||||
set(IPhreeqc_SRC
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc_interface.F90
|
||||
${PROJECT_SOURCE_DIR}/src/README.Fortran
|
||||
)
|
||||
else()
|
||||
# always install README.Fortran
|
||||
SET(IPhreeqc_SRC
|
||||
${PROJECT_SOURCE_DIR}/src/README.Fortran
|
||||
)
|
||||
set(IPhreeqc_SRC
|
||||
${PROJECT_SOURCE_DIR}/src/README.Fortran
|
||||
)
|
||||
# install old fortran include files
|
||||
SET(IPhreeqc_Headers
|
||||
${IPhreeqc_Headers}
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc.f.inc
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc.f90.inc
|
||||
)
|
||||
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()
|
||||
|
||||
set_target_properties(IPhreeqc PROPERTIES
|
||||
VERSION "${IPhreeqc_VERSION}"
|
||||
SOVERSION "${IPhreeqc_VERSION_MAJOR}"
|
||||
)
|
||||
|
||||
# install
|
||||
if (STANDALONE_BUILD EQUAL 1)
|
||||
install(TARGETS IPhreeqc DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
if (STANDALONE_BUILD)
|
||||
|
||||
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 ${IPhreeqc_VERSION}
|
||||
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)
|
||||
@ -328,80 +362,89 @@ if (STANDALONE_BUILD EQUAL 1)
|
||||
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})
|
||||
install(FILES "${PROJECT_SOURCE_DIR}/src/phreeqcpp/ZedGraph.dll" DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
##IF(MSVC)
|
||||
## message("PROJECT_BINARY_DIR = ${PROJECT_BINARY_DIR}")
|
||||
## INSTALL(
|
||||
## DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
## DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
## CONFIGURATIONS Debug
|
||||
## FILES_MATCHING
|
||||
## PATTERN "*.pdb"
|
||||
## )
|
||||
## INSTALL(
|
||||
## FILES
|
||||
## ${LIBRARY_OUTPUT_PATH}/Debug/${target_prefix}${target_name}.pdb
|
||||
## DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
## DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
## CONFIGURATIONS Debug
|
||||
## )
|
||||
##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()
|
||||
if (BUILD_CLR_LIBS)
|
||||
if (NOT BUILD_SHARED_LIBS)
|
||||
message(FATAL_ERROR "BUILD_CLR_LIBS requires that BUILD_SHARED_LIBS be set")
|
||||
endif()
|
||||
|
||||
set(FortranCompilerFlags
|
||||
CMAKE_Fortran_FLAGS
|
||||
)
|
||||
|
||||
foreach(FortranCompilerFlags ${FortranCompilerFlags})
|
||||
if(${FortranCompilerFlags} MATCHES "/libs:dll")
|
||||
string(REGEX REPLACE "/libs:dll" "/libs:static" ${FortranCompilerFlags} "${${FortranCompilerFlags}}")
|
||||
endif()
|
||||
endforeach()
|
||||
if (IPHREEQC_STATIC_RUNTIME)
|
||||
message(FATAL_ERROR "BUILD_CLR_LIBS and IPHREEQC_STATIC_RUNTIME are mutually exclusive")
|
||||
endif()
|
||||
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) # may need to add MSVC version check
|
||||
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
|
||||
)
|
||||
|
||||
# enable distribution creation
|
||||
set(CPACK_PACKAGE_VERSION "3.2.0")
|
||||
set(CPACK_PACKAGE_VENDOR "USGS")
|
||||
include (CPack)
|
||||
# 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()
|
||||
endif()
|
||||
|
||||
# get_cmake_property(_variableNames VARIABLES)
|
||||
# list (SORT _variableNames)
|
||||
# foreach (_variableName ${_variableNames})
|
||||
# message(STATUS "${_variableName}=${${_variableName}}")
|
||||
# endforeach()
|
||||
|
||||
4
IPhreeqcConfig.cmake.in
Normal file
4
IPhreeqcConfig.cmake.in
Normal file
@ -0,0 +1,4 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/IPhreeqcTargets.cmake")
|
||||
check_required_components("IPhreeqc")
|
||||
@ -2,6 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
|
||||
EXTRA_DIST =\
|
||||
CMakeLists.txt\
|
||||
INSTALL\
|
||||
IPhreeqcConfig.cmake.in\
|
||||
IPhreeqc.rc\
|
||||
resource.h
|
||||
SUBDIRS = src tests examples doc database
|
||||
|
||||
@ -168,6 +168,7 @@ PSRC = \
|
||||
$(DEST)/Phreeqc.h \
|
||||
$(DEST)/PHRQ_base.cpp \
|
||||
$(DEST)/PHRQ_base.h \
|
||||
$(DEST)/PHRQ_exports.h \
|
||||
$(DEST)/PHRQ_io.cpp \
|
||||
$(DEST)/PHRQ_io.h \
|
||||
$(DEST)/PHRQ_io_output.cpp \
|
||||
@ -503,6 +504,9 @@ $(DEST)/PHRQ_base.cpp : $(SRC)/common/PHRQ_base.cxx
|
||||
$(DEST)/PHRQ_base.h : $(SRC)/common/PHRQ_base.h
|
||||
$(CP) $< $@
|
||||
|
||||
$(DEST)/PHRQ_exports.h : $(SRC)/common/PHRQ_exports.h
|
||||
$(CP) $< $@
|
||||
|
||||
$(DEST)/PHRQ_io.cpp : $(SRC)/common/PHRQ_io.cpp
|
||||
$(CP) $< $@
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -8,3 +8,4 @@ add_subdirectory(c)
|
||||
add_subdirectory(com)
|
||||
add_subdirectory(cpp)
|
||||
add_subdirectory(fortran)
|
||||
add_subdirectory(using-cmake)
|
||||
|
||||
@ -9,7 +9,13 @@ EXTRA_DIST =\
|
||||
cpp/CMakeLists.txt\
|
||||
cpp/advect/CMakeLists.txt\
|
||||
fortran/CMakeLists.txt\
|
||||
fortran/advect/CMakeLists.txt
|
||||
fortran/advect/CMakeLists.txt\
|
||||
using-cmake/CMakeLists.txt\
|
||||
using-cmake/CMakeLists.txt.in\
|
||||
using-cmake/ex2\
|
||||
using-cmake/main.cpp\
|
||||
using-cmake/phreeqc.dat\
|
||||
using-cmake/README.txt
|
||||
|
||||
EXAMPLES_DIR = $(docdir)/examples
|
||||
|
||||
|
||||
23
examples/using-cmake/CMakeLists.txt
Normal file
23
examples/using-cmake/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
||||
# configure_file(ex2 ex2 COPYONLY)
|
||||
# configure_file(main.cpp main.cpp COPYONLY)
|
||||
# configure_file(phreeqc.dat phreeqc.dat COPYONLY)
|
||||
# configure_file(README.txt README.txt COPYONLY)
|
||||
|
||||
configure_file(CMakeLists.txt.in CMakeLists.txt)
|
||||
|
||||
#
|
||||
SET(example_FILES
|
||||
${IPhreeqc_BINARY_DIR}/examples/using-cmake/CMakeLists.txt
|
||||
ex2
|
||||
main.cpp
|
||||
phreeqc.dat
|
||||
README.txt
|
||||
)
|
||||
|
||||
# install directory
|
||||
SET(example_DIR ${EXAMPLES_DIR}/using-cmake)
|
||||
|
||||
# install
|
||||
install(FILES ${example_FILES} DESTINATION ${example_DIR})
|
||||
|
||||
|
||||
21
examples/using-cmake/CMakeLists.txt.in
Normal file
21
examples/using-cmake/CMakeLists.txt.in
Normal file
@ -0,0 +1,21 @@
|
||||
# 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 3 REQUIRED)
|
||||
|
||||
# add executable target
|
||||
add_executable(example main.cpp)
|
||||
|
||||
# set link libraries as well as include paths
|
||||
#target_link_libraries(example PUBLIC IPhreeqc::IPhreeqc)
|
||||
target_link_libraries(example IPhreeqc::IPhreeqc)
|
||||
38
examples/using-cmake/README.txt
Normal file
38
examples/using-cmake/README.txt
Normal file
@ -0,0 +1,38 @@
|
||||
Example usage
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
Windows
|
||||
--------------------------------------------------------------------------------------
|
||||
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 .
|
||||
7. 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
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
Linux/macOS
|
||||
--------------------------------------------------------------------------------------
|
||||
Configure, build and install IPhreeqc
|
||||
1. cd iphreeqc-3.6.2-15100
|
||||
2. mkdir _build
|
||||
3. cd _build
|
||||
4. cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/charlton/iphreeqc ..
|
||||
5. cmake --build .
|
||||
6. ctest .
|
||||
7. cmake --build . --target install
|
||||
|
||||
Build example:
|
||||
1. cd /home/charlton/iphreeqc/share/doc/IPhreeqc/examples/using-cmake
|
||||
2. mkdir _build
|
||||
3. cd _build
|
||||
4. cmake -DCMAKE_PREFIX_PATH:PATH=/home/charlton/iphreeqc ..
|
||||
5. cmake --build .
|
||||
26
examples/using-cmake/ex2
Normal file
26
examples/using-cmake/ex2
Normal 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
|
||||
20
examples/using-cmake/main.cpp
Normal file
20
examples/using-cmake/main.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <IPhreeqc.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
IPhreeqc iphreeqc;
|
||||
if (iphreeqc.LoadDatabase("phreeqc.dat") != 0)
|
||||
{
|
||||
std::cout << iphreeqc.GetErrorString();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
iphreeqc.SetOutputFileOn(true);
|
||||
iphreeqc.SetOutputFileName("ex2.out");
|
||||
if (iphreeqc.RunFile("ex2") != 0)
|
||||
{
|
||||
std::cout << iphreeqc.GetErrorString();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
1837
examples/using-cmake/phreeqc.dat
Normal file
1837
examples/using-cmake/phreeqc.dat
Normal file
File diff suppressed because it is too large
Load Diff
165
gtest/CMakeLists.txt
Normal file
165
gtest/CMakeLists.txt
Normal file
@ -0,0 +1,165 @@
|
||||
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
153
gtest/FileTest.cpp
Normal 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
33
gtest/FileTest.h
Normal 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
9
gtest/TestCVar.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "../src/CVar.hxx"
|
||||
|
||||
TEST(TestCVar, CVarCtor)
|
||||
{
|
||||
CVar v;
|
||||
ASSERT_EQ(TT_EMPTY, v.type);
|
||||
}
|
||||
4748
gtest/TestIPhreeqc.cpp
Normal file
4748
gtest/TestIPhreeqc.cpp
Normal file
File diff suppressed because it is too large
Load Diff
4606
gtest/TestIPhreeqcLib.cpp
Normal file
4606
gtest/TestIPhreeqcLib.cpp
Normal file
File diff suppressed because it is too large
Load Diff
669
gtest/TestSelectedOutput.cpp
Normal file
669
gtest/TestSelectedOutput.cpp
Normal 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
10
gtest/TestVar.cpp
Normal 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
11
gtest/conv_fail.in
Normal 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
42
gtest/dump
Normal 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
7231
gtest/iso.dat
Normal file
File diff suppressed because it is too large
Load Diff
349
gtest/kinn20140218
Normal file
349
gtest/kinn20140218
Normal 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
1556
gtest/missing_e.dat
Normal file
File diff suppressed because it is too large
Load Diff
105
gtest/multi_punch
Normal file
105
gtest/multi_punch
Normal 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
102
gtest/multi_punch_no_set
Normal 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
|
||||
@ -15,7 +15,9 @@
|
||||
#include <vector>
|
||||
#include "CVar.hxx"
|
||||
|
||||
class CSelectedOutput
|
||||
#include "PHRQ_exports.h"
|
||||
|
||||
class IPQ_DLL_EXPORT CSelectedOutput
|
||||
{
|
||||
public:
|
||||
CSelectedOutput(void);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION GetErrorOn(ID)
|
||||
* INTEGER(KIND=4), INTENT(IN) :: ID
|
||||
* LOGICAL(KIND=4) :: GetErrorOn
|
||||
* END FUNCTION GetErrorOn
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @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
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* 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
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @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
|
||||
|
||||
@ -14,11 +14,7 @@
|
||||
#include "Var.h" /* VRESULT */
|
||||
#include "PHRQ_io.h"
|
||||
|
||||
#if defined(_WINDLL)
|
||||
#define IPQ_DLL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define IPQ_DLL_EXPORT
|
||||
#endif
|
||||
#include "PHRQ_exports.h"
|
||||
|
||||
class Phreeqc;
|
||||
class IErrorReporter;
|
||||
@ -193,6 +189,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 +772,21 @@ public:
|
||||
/**
|
||||
* Sets the error file switch on or off. This switch controls whether or not
|
||||
* error messages are written to the <B><I>phreeqc.id.err</I></B> (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.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -48,6 +48,7 @@ libiphreeqc_la_SOURCES=\
|
||||
phreeqcpp/common/Parser.h\
|
||||
phreeqcpp/common/PHRQ_base.cxx\
|
||||
phreeqcpp/common/PHRQ_base.h\
|
||||
phreeqcpp/common/PHRQ_exports.h\
|
||||
phreeqcpp/common/PHRQ_io.cpp\
|
||||
phreeqcpp/common/PHRQ_io.h\
|
||||
phreeqcpp/common/phrqtype.h\
|
||||
|
||||
@ -6,11 +6,7 @@
|
||||
#ifndef __VAR_H_INC
|
||||
#define __VAR_H_INC
|
||||
|
||||
#if defined(_WINDLL)
|
||||
#define IPQ_DLL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define IPQ_DLL_EXPORT
|
||||
#endif
|
||||
#include "PHRQ_exports.h"
|
||||
|
||||
#if defined(R_SO) || defined(NO_NAMELESS_UNION)
|
||||
#define VAR_UNION_NAME u
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -24,6 +24,7 @@ phreeqc_SOURCES=\
|
||||
common/Parser.h\
|
||||
common/PHRQ_base.cxx\
|
||||
common/PHRQ_base.h\
|
||||
common/PHRQ_exports.h\
|
||||
common/PHRQ_io.cpp\
|
||||
common/PHRQ_io.h\
|
||||
common/phrqtype.h\
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
#if !defined(NAMEDOUBLE_H_INCLUDED)
|
||||
#define NAMEDOUBLE_H_INCLUDED
|
||||
|
||||
#if defined(_WINDLL)
|
||||
#define IPQ_DLL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define IPQ_DLL_EXPORT
|
||||
#endif
|
||||
#include "PHRQ_exports.h"
|
||||
|
||||
#include <cassert> // assert
|
||||
#include <map> // std::map
|
||||
|
||||
@ -3,11 +3,7 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#if defined(_WINDLL)
|
||||
#define IPQ_DLL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define IPQ_DLL_EXPORT
|
||||
#endif
|
||||
#include "PHRQ_exports.h"
|
||||
|
||||
class PHRQ_io;
|
||||
class IPQ_DLL_EXPORT PHRQ_base
|
||||
|
||||
14
src/phreeqcpp/common/PHRQ_exports.h
Normal file
14
src/phreeqcpp/common/PHRQ_exports.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef INC_PHRQ_EXPORTS_H
|
||||
#define INC_PHRQ_EXPORTS_H
|
||||
|
||||
#if defined(_WINDLL)
|
||||
# ifdef IPhreeqc_EXPORTS
|
||||
# define IPQ_DLL_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define IPQ_DLL_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define IPQ_DLL_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // INC_PHRQ_EXPORTS_H
|
||||
@ -1,11 +1,7 @@
|
||||
#ifndef _PHRQIO_H
|
||||
#define _PHRQIO_H
|
||||
|
||||
#if defined(_WINDLL)
|
||||
#define IPQ_DLL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define IPQ_DLL_EXPORT
|
||||
#endif
|
||||
#include "PHRQ_exports.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
@ -44,8 +40,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 +61,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 +71,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 +90,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 +114,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 +126,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 +145,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 +154,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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
typedef int (*getFunc)(int);
|
||||
typedef IPQ_RESULT (*setFunc)(int, int);
|
||||
int TestGetSet(int, getFunc, setFunc);
|
||||
int TestGetSetInitOn(int, getFunc, setFunc);
|
||||
|
||||
int
|
||||
main(int argc, const char* argv[])
|
||||
@ -30,12 +31,18 @@ main(int argc, const char* argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Error */
|
||||
/* Error file */
|
||||
if (TestGetSet(id, GetErrorFileOn, SetErrorFileOn))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Error */
|
||||
if (TestGetSetInitOn(id, GetErrorOn, SetErrorOn))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Log */
|
||||
if (TestGetSet(id, GetLogFileOn, SetLogFileOn))
|
||||
{
|
||||
@ -113,3 +120,29 @@ TestGetSet(int id, getFunc gf, setFunc sf)
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
TestGetSetInitOn(int id, getFunc gf, setFunc sf)
|
||||
{
|
||||
if (!gf(id))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (sf(id, 0) != IPQ_OK)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (gf(id))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (sf(id, 1) != IPQ_OK)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -38,6 +38,30 @@ public:
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int TestInitOn(void)
|
||||
{
|
||||
if (!(*_p.*_get)())
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
(*_p.*_set)(false);
|
||||
|
||||
if ((*_p.*_get)())
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
(*_p.*_set)(true);
|
||||
|
||||
if (!(*_p.*_get)())
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
@ -59,13 +83,21 @@ main(int argc, const char* argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Error
|
||||
TTestGetSet<IPhreeqc> testError(&iphreeqc, &IPhreeqc::GetErrorFileOn, &IPhreeqc::SetErrorFileOn);
|
||||
if (testError.Test() != EXIT_SUCCESS)
|
||||
// Error file
|
||||
TTestGetSet<IPhreeqc> testErrorFile(&iphreeqc, &IPhreeqc::GetErrorFileOn, &IPhreeqc::SetErrorFileOn);
|
||||
if (testErrorFile.Test() != EXIT_SUCCESS)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Error
|
||||
TTestGetSet<IPhreeqc> testError(&iphreeqc, &IPhreeqc::GetErrorOn, &IPhreeqc::SetErrorOn);
|
||||
if (testError.TestInitOn() != EXIT_SUCCESS)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// Log
|
||||
TTestGetSet<IPhreeqc> testLog(&iphreeqc, &IPhreeqc::GetLogFileOn, &IPhreeqc::SetLogFileOn);
|
||||
if (testLog.Test() != EXIT_SUCCESS)
|
||||
|
||||
@ -16,6 +16,7 @@ FUNCTION F_MAIN()
|
||||
|
||||
INTEGER(KIND=4) F_MAIN
|
||||
INTEGER(KIND=4) TestGetSet
|
||||
INTEGER(KIND=4) TestGetSetInitOn
|
||||
INTEGER(KIND=4) TestGetSetName
|
||||
|
||||
INTEGER(KIND=4),PARAMETER :: EXIT_SUCCESS = 0
|
||||
@ -57,12 +58,18 @@ FUNCTION F_MAIN()
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
! Error
|
||||
! Error file
|
||||
IF (TestGetSet(id,GetErrorFileOn,SetErrorFileOn).NE.0) THEN
|
||||
F_MAIN = EXIT_FAILURE
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
|
||||
! Error
|
||||
IF (TestGetSetInitOn(id,GetErrorOn,SetErrorOn).NE.0) THEN
|
||||
F_MAIN = EXIT_FAILURE
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
! Log
|
||||
IF (TestGetSet(id,GetLogFileOn,SetLogFileOn).NE.0) THEN
|
||||
F_MAIN = EXIT_FAILURE
|
||||
@ -157,41 +164,104 @@ FUNCTION TestGetSet(id,getFunc,setFunc)
|
||||
END INTERFACE
|
||||
INTEGER(KIND=4),PARAMETER :: EXIT_SUCCESS = 0
|
||||
INTEGER(KIND=4),PARAMETER :: EXIT_FAILURE = 1
|
||||
|
||||
|
||||
IF (getFunc(id)) THEN
|
||||
TestGetSet = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
|
||||
IF (setFunc(id,.TRUE.).NE.IPQ_OK) THEN
|
||||
TestGetSet = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
|
||||
IF (.NOT.getFunc(id)) THEN
|
||||
TestGetSet = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
|
||||
IF (setFunc(id,.FALSE.).NE.IPQ_OK) THEN
|
||||
TestGetSet = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
IF (getFunc(id)) THEN
|
||||
TestGetSet = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
TestGetSet = EXIT_SUCCESS
|
||||
RETURN
|
||||
|
||||
END FUNCTION TestGetSet
|
||||
|
||||
|
||||
FUNCTION TestGetSetInitOn(id,getFunc,setFunc)
|
||||
#ifndef IPHREEQC_NO_FORTRAN_MODULE
|
||||
USE IPhreeqc
|
||||
#endif
|
||||
|
||||
IMPLICIT NONE
|
||||
#ifdef IPHREEQC_NO_FORTRAN_MODULE
|
||||
INCLUDE 'IPhreeqc.f90.inc'
|
||||
#endif
|
||||
INTEGER(KIND=4) id
|
||||
INTEGER(KIND=4) TestGetSetInitOn
|
||||
INTERFACE
|
||||
FUNCTION getFunc(id)
|
||||
INTEGER(KIND=4), INTENT(in) :: id
|
||||
LOGICAL(KIND=4) getFunc
|
||||
END FUNCTION getFunc
|
||||
END INTERFACE
|
||||
INTERFACE
|
||||
FUNCTION setFunc(id,flag)
|
||||
INTEGER(KIND=4), INTENT(in) :: id
|
||||
LOGICAL(KIND=4), INTENT(in) :: flag
|
||||
INTEGER(KIND=4) setFunc
|
||||
END FUNCTION setFunc
|
||||
END INTERFACE
|
||||
INTEGER(KIND=4),PARAMETER :: EXIT_SUCCESS = 0
|
||||
INTEGER(KIND=4),PARAMETER :: EXIT_FAILURE = 1
|
||||
|
||||
IF (.NOT.(getFunc(id))) THEN
|
||||
TestGetSetInitOn = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
TestGetSet = EXIT_SUCCESS
|
||||
|
||||
IF (setFunc(id,.TRUE.).NE.IPQ_OK) THEN
|
||||
TestGetSetInitOn = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
IF (.NOT.getFunc(id)) THEN
|
||||
TestGetSetInitOn = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
IF (setFunc(id,.FALSE.).NE.IPQ_OK) THEN
|
||||
TestGetSetInitOn = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
IF (getFunc(id)) THEN
|
||||
TestGetSetInitOn = EXIT_FAILURE
|
||||
WRITE(*,*) "FAILURE"
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
TestGetSetInitOn = EXIT_SUCCESS
|
||||
RETURN
|
||||
|
||||
END FUNCTION TestGetSet
|
||||
|
||||
END FUNCTION TestGetSetInitOn
|
||||
|
||||
|
||||
FUNCTION TestGetSetName(id,getFuncName,setFuncName)
|
||||
|
||||
@ -59,6 +59,7 @@ unit_SOURCES=\
|
||||
../src/phreeqcpp/Phreeqc.h\
|
||||
../src/phreeqcpp/PHRQ_base.cxx\
|
||||
../src/phreeqcpp/PHRQ_base.h\
|
||||
../src/phreeqcpp/PHRQ_export.h\
|
||||
../src/phreeqcpp/PHRQ_io.cpp\
|
||||
../src/phreeqcpp/PHRQ_io.h\
|
||||
../src/phreeqcpp/Phreeqc_class.h\
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user