Skip to content

Commit 36baede

Browse files
author
Darth Vader
committed
Merge commit '4e0cbe1b4fc5c07f40e5fdde480462152d945bdb'
2 parents 02e3517 + 4e0cbe1 commit 36baede

13 files changed

+152
-76
lines changed

src/phast/PhreeqcRM/.github/workflows/ci.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,15 @@ jobs:
390390
compiler: intel-classic
391391
version: '2021.10'
392392

393-
- name: Unset CC/CXX (Windows)
393+
- name: Set CC/CXX (Windows)
394394
if: runner.os == 'Windows'
395395
shell: bash
396396
run: |
397-
echo "CC=" >> $GITHUB_ENV
398-
echo "CXX=" >> $GITHUB_ENV
397+
echo "CC=cl" >> $GITHUB_ENV
398+
echo "CXX=cl" >> $GITHUB_ENV
399399
400400
- name: Install ninja valgrind (Linux)
401401
if: ${{ runner.os == 'Linux' }}
402-
#run: sudo apt-get install -y ninja-build valgrind libyaml-cpp-dev python3-numpy
403402
run: |
404403
sudo apt-get -y update
405404
sudo apt-get install -y ninja-build valgrind
@@ -437,12 +436,6 @@ jobs:
437436
python -m pip install pytest
438437
# @todo if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
439438
440-
- name: Set up Visual Studio shell (Windows)
441-
if: runner.os == 'Windows'
442-
uses: egor-tensin/vs-shell@v2
443-
with:
444-
arch: x64
445-
446439
- name: Extract tarball
447440
run: tar xvzf phreeqcrm-${{ env.VER_STRING }}.tar.gz
448441

src/phast/PhreeqcRM/.github/workflows/wheels.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ jobs:
4040
- [cp38, v141]
4141
- [cp39, v141]
4242
- [cp310, v141]
43-
- [pp310, v141]
4443
- [cp311, v141]
44+
- [cp312, v142]
4545
- [cp313, v142]
4646
# - [cp313t, v142]
47+
- [pp310, v141]
48+
4749
exclude:
4850
# cp313(i686) on ubuntu-20.04
4951
- buildplat: [ubuntu-20.04, manylinux_i686, i686]
@@ -88,11 +90,19 @@ jobs:
8890
run: |
8991
python --version
9092
93+
# free some space to prevent reaching GHA disk space limits
94+
- name: Clean docker images
95+
if: runner.os == 'Linux'
96+
run: |
97+
docker system prune -a -f
98+
df -h
99+
91100
- name: Setup QEMU
92101
if: runner.os == 'Linux'
93102
uses: docker/setup-qemu-action@v3
94103
with:
95-
platforms: all
104+
image: tonistiigi/binfmt:qemu-v8.1.5
105+
#platforms: all
96106

97107
- name: Build wheels (Linux)
98108
if: ${{ runner.os == 'Linux' }}

src/phast/PhreeqcRM/CMakeLists.txt

+42-24
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,12 @@ if(PHREEQCRM_FORTRAN_TESTING)
3535
enable_language(Fortran)
3636
endif()
3737

38+
# Include FetchContent module
39+
include(FetchContent)
40+
3841
if(DEFINED SKBUILD)
3942
# SKBUILD is defined when scikit-build-core is used to build python wheels (see pyproject.toml)
4043

41-
# Include FetchContent module
42-
include(FetchContent)
43-
44-
# Fetch yaml-cpp
45-
FetchContent_Declare(
46-
yaml-cpp
47-
URL https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz
48-
)
49-
50-
# Make yaml-cpp available
51-
FetchContent_MakeAvailable(yaml-cpp)
52-
53-
5444
# Fetch zlib
5545
FetchContent_Declare(
5646
zlib
@@ -68,10 +58,28 @@ if(DEFINED SKBUILD)
6858
# SKBUILD is defined when scikit-build-core is used to build python wheels (see pyproject.toml)
6959
set(PHREEQCRM_WITH_YAML_CPP ON)
7060
endif()
71-
if(PHREEQCRM_WITH_YAML_CPP AND NOT DEFINED SKBUILD)
61+
if(PHREEQCRM_WITH_YAML_CPP)
62+
# Initialize a static build for yaml-cpp
63+
# w/o the FORCE option the user can override using -DYAML_BUILD_SHARED_LIBS=ON
64+
set(YAML_BUILD_SHARED_LIBS OFF CACHE STRING "")
65+
# w/o the FORCE option the user can override using -DYAML_CPP_INSTALL=OFF
66+
set(YAML_CPP_INSTALL ON CACHE STRING "")
67+
68+
# Fetch yaml-cpp
69+
FetchContent_Declare(
70+
yaml-cpp
71+
URL https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz
72+
OVERRIDE_FIND_PACKAGE
73+
)
74+
75+
# The following will automatically forward through to FetchContent_MakeAvailable()
7276
find_package(yaml-cpp REQUIRED)
7377
if(yaml-cpp_FOUND)
74-
message(STATUS "Found yaml-cpp: TRUE (found version \"${yaml-cpp_VERSION}\")")
78+
if(DEFINED yaml-cpp_VERSION)
79+
message(STATUS "Found yaml-cpp: TRUE (found version \"${yaml-cpp_VERSION}\")")
80+
else()
81+
message(STATUS "Found yaml-cpp: TRUE")
82+
endif()
7583
endif()
7684
endif()
7785

@@ -314,8 +322,8 @@ target_include_directories(PhreeqcRM
314322
include(GenerateExportHeader)
315323
generate_export_header(PhreeqcRM BASE_NAME IRM_DLL)
316324

317-
# c++11
318-
target_compile_features(PhreeqcRM PUBLIC cxx_std_11)
325+
# c++14
326+
target_compile_features(PhreeqcRM PUBLIC cxx_std_14)
319327

320328
# iphreeqc defs
321329
target_compile_definitions(PhreeqcRM PRIVATE SWIG_SHARED_OBJ)
@@ -526,13 +534,23 @@ if(STANDALONE_BUILD EQUAL 1 AND NOT DEFINED SKBUILD)
526534
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PhreeqcRM
527535
)
528536

529-
install(TARGETS PhreeqcRM
530-
EXPORT PhreeqcRMTargets
531-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
532-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
533-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
534-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
535-
)
537+
if(PHREEQCRM_WITH_YAML_CPP AND yaml-cpp_FOUND)
538+
install(TARGETS PhreeqcRM yaml-cpp
539+
EXPORT PhreeqcRMTargets
540+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
541+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
542+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
543+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
544+
)
545+
else()
546+
install(TARGETS PhreeqcRM
547+
EXPORT PhreeqcRMTargets
548+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
549+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
550+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
551+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
552+
)
553+
endif()
536554

537555
install(EXPORT PhreeqcRMTargets
538556
FILE PhreeqcRMTargets.cmake

src/phast/PhreeqcRM/configure.ac

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ AC_PROG_AWK
6969
AC_PROG_CPP
7070
AC_PROG_LN_S
7171

72-
# c++11 is required
73-
AX_CXX_COMPILE_STDCXX(11, [ext], [mandatory])
72+
# c++14 is required
73+
AX_CXX_COMPILE_STDCXX(14, [ext], [mandatory])
7474

7575
# Check if the fortran test should be included
7676
AC_MSG_CHECKING([if Fortran test is added])

src/phast/PhreeqcRM/mamba.environment.yml

-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ dependencies:
88
- python
99
- pyyaml
1010
- swig
11-
- yaml-cpp
1211
- cmake

src/phast/PhreeqcRM/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "scikit_build_core.build"
88

99
[project]
1010
name = "phreeqcrm"
11-
version = "0.0.12"
11+
version = "0.0.14"
1212
description = "A reaction module for transport simulators based on the geochemical model PHREEQC."
1313
readme = "README.md"
1414
requires-python = ">=3.8"

src/phast/PhreeqcRM/src/BMIPhreeqcRM.cpp

+14-6
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ void BMIPhreeqcRM::ClearBMISelectedOutput(void)
149149
assert(this->var_man);
150150
this->var_man->BMISelectedOutput.clear();
151151
}
152-
void BMIPhreeqcRM::Construct(PhreeqcRM::Initializer i)
152+
void BMIPhreeqcRM::Construct()
153153
{
154154
if (constructed) return;
155-
this->PhreeqcRM::Construct(i);
155+
this->PhreeqcRM::Construct();
156156
this->var_man = new VarManager((PhreeqcRM*)this);
157157
#if defined(WITH_PYBIND11)
158158
this->_initialized = true;
@@ -180,13 +180,13 @@ void BMIPhreeqcRM::Initialize(std::string config_file)
180180
std::string keyword = it1++->second.as<std::string>();
181181
if (keyword == "SetGridCellCount")
182182
{
183-
this->initializer.nxyz_arg = it1++->second.as<int>();
183+
set_nxyz(it1++->second.as<int>());
184184
found_nxyz = true;
185185
}
186186
if (keyword == "ThreadCount")
187187
{
188188
#if !defined(USE_MPI)
189-
this->initializer.data_for_parallel_processing = it1++->second.as<int>();
189+
set_data_for_parallel_processing(it1++->second.as<int>());
190190
#endif
191191
found_threads = true;
192192
}
@@ -195,7 +195,7 @@ void BMIPhreeqcRM::Initialize(std::string config_file)
195195
}
196196
#endif
197197

198-
this->Construct(this->initializer);
198+
this->Construct();
199199
constructed = true;
200200
#ifdef USE_YAML
201201
if (config_file.size() != 0)
@@ -1321,6 +1321,14 @@ RMVARS BMIPhreeqcRM::GetEnum(const std::string name)
13211321
return RMVARS::NotFound;
13221322
};
13231323

1324-
//////////////////
1324+
/* ---------------------------------------------------------------------- */
1325+
IRM_RESULT
1326+
BMIPhreeqcRM::LoadDatabase(const std::string& database)
1327+
/* ---------------------------------------------------------------------- */
1328+
{
1329+
// reqd for swig-python
1330+
return this->PhreeqcRM::LoadDatabase(database);
1331+
}
13251332

1333+
//////////////////
13261334

src/phast/PhreeqcRM/src/BMIPhreeqcRM.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,8 @@ class IRM_DLL_EXPORT BMIPhreeqcRM : public bmi::Bmi, public PhreeqcRM
12711271
// std::set<std::string> UpdateMap;
12721272
// std::set<std::string>& GetUpdateMap() { return UpdateMap; }
12731273

1274+
IRM_RESULT LoadDatabase(const std::string& database) override;
1275+
12741276
#if defined(WITH_PYBIND11)
12751277

12761278
py::array BMIPhreeqcRM::get_value(std::string name, py::array arr);
@@ -1297,7 +1299,7 @@ class IRM_DLL_EXPORT BMIPhreeqcRM : public bmi::Bmi, public PhreeqcRM
12971299
#endif
12981300

12991301
protected:
1300-
void Construct(Initializer initializer) override;
1302+
void Construct(void) override;
13011303

13021304
private:
13031305
//friend class RM_interface;

src/phast/PhreeqcRM/src/PhreeqcRM.cpp

+44-9
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@
6969
const MP_TYPE PhreeqcRM::default_data_for_parallel_processing = -1;
7070
#endif
7171

72+
// Pimpl for initialization
73+
class PhreeqcRM::Initializer
74+
{
75+
76+
public:
77+
Initializer() : nxyz_arg(default_nxyz), data_for_parallel_processing(default_data_for_parallel_processing), io(nullptr) {}
78+
Initializer(int nxyz, MP_TYPE data, PHRQ_io *pio) : nxyz_arg(nxyz), data_for_parallel_processing(data), io(pio) {}
79+
80+
public:
81+
int nxyz_arg;
82+
MP_TYPE data_for_parallel_processing;
83+
PHRQ_io *io;
84+
};
7285

7386
//// static PhreeqcRM methods
7487
/* ---------------------------------------------------------------------- */
@@ -169,7 +182,7 @@ PhreeqcRM::PhreeqcRM(int nxyz_arg, MP_TYPE data_for_parallel_processing, PHRQ_io
169182
, mpi_worker_callback_c( nullptr )
170183
, mpi_worker_callback_cookie( nullptr )
171184
, species_save_on( false )
172-
, initializer( nxyz_arg, data_for_parallel_processing, io )
185+
, initializer(std::make_unique<PhreeqcRM::Initializer>(nxyz_arg, data_for_parallel_processing, io))
173186
{
174187
#ifdef USE_MPI
175188
phreeqcrm_comm = data_for_parallel_processing;
@@ -188,24 +201,24 @@ PhreeqcRM::PhreeqcRM(int nxyz_arg, MP_TYPE data_for_parallel_processing, PHRQ_io
188201
#ifdef USE_MPI
189202
if (mpi_myself == 0)
190203
{
191-
this->Construct(this->initializer);
204+
this->Construct();
192205
MpiWorkerBreak();
193206
}
194207
else
195208
{
196209
MpiWorker();
197210
}
198211
#else
199-
this->Construct(this->initializer);
212+
this->Construct();
200213
#endif
201214
}
202215
}
203216

204-
void PhreeqcRM::Construct(PhreeqcRM::Initializer i)
217+
void PhreeqcRM::Construct()
205218
{
206-
int nxyz_arg = i.nxyz_arg;
207-
MP_TYPE data_for_parallel_processing = i.data_for_parallel_processing;
208-
//PHRQ_io *io = i.io;
219+
int nxyz_arg = this->initializer->nxyz_arg;
220+
MP_TYPE data_for_parallel_processing = this->initializer->data_for_parallel_processing;
221+
//PHRQ_io* io = this->initializer->io;
209222
#ifdef USE_MPI
210223
if (mpi_myself == 0)
211224
{
@@ -5631,7 +5644,8 @@ IRM_RESULT PhreeqcRM::InitializeYAML(std::string config)
56315644
if (keyword == "LoadDatabase")
56325645
{
56335646
std::string file = it1++->second.as< std::string >();
5634-
this->LoadDatabase(file);
5647+
// no need to check for initialization just call base class
5648+
this->PhreeqcRM::LoadDatabase(file);
56355649
continue;
56365650
}
56375651
if (keyword == "OpenFiles")
@@ -7035,7 +7049,7 @@ PhreeqcRM::MpiWorker()
70357049
case METHOD_CONSTRUCT:
70367050
if (debug_worker) std::cerr << "METHOD_CONSTRUCT" << std::endl;
70377051
{
7038-
this->Construct(this->initializer);
7052+
this->Construct();
70397053
}
70407054
break;
70417055
case METHOD_CREATEMAPPING:
@@ -13028,6 +13042,27 @@ PhreeqcRM::WarningMessage(const std::string &str)
1302813042
this->phreeqcrm_io->warning_msg(str.c_str());
1302913043
}
1303013044
}
13045+
/* ---------------------------------------------------------------------- */
13046+
void
13047+
PhreeqcRM::set_data_for_parallel_processing(int value)
13048+
/* ---------------------------------------------------------------------- */
13049+
{
13050+
this->initializer->data_for_parallel_processing = value;
13051+
}
13052+
/* ---------------------------------------------------------------------- */
13053+
void
13054+
PhreeqcRM::set_nxyz(int value)
13055+
/* ---------------------------------------------------------------------- */
13056+
{
13057+
this->initializer->nxyz_arg = value;
13058+
}
13059+
/* ---------------------------------------------------------------------- */
13060+
void
13061+
PhreeqcRM::set_io(PHRQ_io *value)
13062+
/* ---------------------------------------------------------------------- */
13063+
{
13064+
this->initializer->io = value;
13065+
}
1303113066

1303213067

1303313068

0 commit comments

Comments
 (0)