Skip to content

Commit b72ced9

Browse files
jcurtis2slayoo
andauthored
Add include and exclude species array optional arguments (incl. new submodule: TartanLlama/optional) (#293)
Co-authored-by: Sylwester Arabas <[email protected]> Co-authored-by: Sylwester Arabas <[email protected]>
1 parent 4e3c402 commit b72ced9

14 files changed

+44146
-5266
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@
5050
path = gitmodules/netcdf-c
5151
url = https://github.com/Unidata/netcdf-c.git
5252
shallow = true
53+
[submodule "gitmodules/optional"]
54+
path = gitmodules/optional
55+
url = https://github.com/TartanLlama/optional.git

CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,19 @@ add_library(partmclib STATIC ${partmclib_SOURCES})
417417
target_compile_definitions(partmclib PRIVATE PMC_USE_SUNDIALS="1")
418418
target_compile_definitions(partmclib PRIVATE PMC_USE_CAMP="1")
419419
add_dependencies(partmclib ${SUNDIALS_items})
420+
421+
string(CONCAT
422+
cmd
423+
"import sys;"
424+
"print(''.join([f'#define {line.split()[3]} {line.split()[5]}\\n' for line in sys.stdin if 'parameter ::' in line]))"
425+
)
426+
include(CheckFunctionExists)
427+
execute_process(
428+
COMMAND ${PYTHON_EXECUTABLE} "-c" "${cmd}"
429+
INPUT_FILE ${CMAKE_SOURCE_DIR}/gitmodules/partmc/src/aero_data.F90
430+
OUTPUT_FILE ${CMAKE_BINARY_DIR}/include/aero_data_parameters.hpp
431+
)
432+
420433
target_include_directories(partmclib PRIVATE
421434
${SUNDIALS_SOURCE_DIR}/include
422435
${CMAKE_BINARY_DIR}/include
@@ -443,10 +456,12 @@ add_subdirectory(gitmodules/pybind11)
443456
pybind11_add_module(_PyPartMC ${PyPartMC_sources})
444457
add_dependencies(_PyPartMC partmclib)
445458
set(PYPARTMC_INCLUDE_DIRS
459+
"${CMAKE_BINARY_DIR}/include;"
446460
"${CMAKE_SOURCE_DIR}/gitmodules/json/include;"
447461
"${CMAKE_SOURCE_DIR}/gitmodules/pybind11_json/include;"
448462
"${CMAKE_SOURCE_DIR}/gitmodules/span/include;"
449463
"${CMAKE_SOURCE_DIR}/gitmodules/string_view-standalone/include;"
464+
"${CMAKE_SOURCE_DIR}/gitmodules/optional/include;"
450465
)
451466
target_include_directories(_PyPartMC PRIVATE ${PYPARTMC_INCLUDE_DIRS})
452467
target_compile_definitions(_PyPartMC PRIVATE VERSION_INFO=${VERSION_INFO})
@@ -492,6 +507,8 @@ foreach(file ${PyPartMC_headers})
492507
unset(CMAKE_REQUIRED_INCLUDES)
493508
if (NOT _header_self_contained_${file})
494509
message(SEND_ERROR "non-self-contained header: ${file}")
510+
file(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log" tmp)
511+
message(FATAL_ERROR ${tmp})
495512
endif()
496513
endforeach()
497514

MANIFEST.in

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ include gitmodules/span/include/tcb/span.hpp
7979
include gitmodules/string_view-standalone/LICENSE
8080
graft gitmodules/string_view-standalone/include/bpstd
8181

82+
include gitmodules/optional/include/tl/optional.hpp
83+
include gitmodules/optional/COPYING
84+
8285
include gitmodules/netcdf-c/COPYRIGHT
8386
include gitmodules/netcdf-c/CMakeLists.txt
8487
include gitmodules/netcdf-c/config.h.cmake.in

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ aero_dist = ppmc.AeroDist(
107107
n_part = 100
108108
aero_state = ppmc.AeroState(aero_data, n_part, "nummass_source")
109109
aero_state.dist_sample(aero_dist)
110-
print(np.dot(aero_state.masses, aero_state.num_concs), "# kg/m3")
110+
print(np.dot(aero_state.masses(), aero_state.num_concs), "# kg/m3")
111111
```
112112

113113
#### Julia
@@ -151,7 +151,7 @@ aero_dist = ppmc.AeroDist(aero_data, (
151151
n_part = 100
152152
aero_state = ppmc.AeroState(aero_data, n_part, "nummass_source")
153153
aero_state.dist_sample(aero_dist)
154-
print(aero_state.masses'aero_state.num_concs, "# kg/m3")
154+
print(aero_state.masses()'aero_state.num_concs, "# kg/m3")
155155
```
156156

157157
#### usage in other projects

examples/particle_simulation.ipynb

+5,638-5,190
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)