Skip to content

Commit 4544030

Browse files
slayoojcurtis2
andauthored
bump PartMC submodule version to >v2.8.0 (and as a result add hdf5 as submodule + perl as build-time dependency) (#353)
Co-authored-by: Jeffrey Curtis <[email protected]>
1 parent 0df9795 commit 4544030

File tree

19 files changed

+162
-52
lines changed

19 files changed

+162
-52
lines changed

.github/workflows/tests+pypi.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142
- run: |
143143
unset CI
144144
python -m build 2>&1 | tee build.log
145-
exit `fgrep -i warning build.log | grep -v "WARNING setuptools_scm" | wc -l`
145+
exit `fgrep -i warning build.log | grep -v "WARNING setuptools_scm" | grep -v "-warnings" | grep -v "All Warnings are enabled" | wc -l`
146146
147147
- if: startsWith(matrix.platform, 'macos-') && matrix.python-version == '3.11'
148148
run: |
@@ -206,10 +206,10 @@ jobs:
206206
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python -m pytest --durations=10 -v -s -We -p no:unraisableexception gitmodules/devops_tests
207207
208208
### uncomment to gain ssh access in case of failure
209-
# - if: ${{ failure() }}
210-
# uses: mxschmitt/action-tmate@v3
211-
# with:
212-
# limit-access-to-actor: true
209+
- if: ${{ failure() }}
210+
uses: mxschmitt/action-tmate@v3
211+
with:
212+
limit-access-to-actor: true
213213

214214
dist_check:
215215
runs-on: ubuntu-latest

.gitmodules

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@
5353
[submodule "gitmodules/optional"]
5454
path = gitmodules/optional
5555
url = https://github.com/TartanLlama/optional.git
56+
shallow = true
57+
[submodule "gitmodules/hdf5"]
58+
path = gitmodules/hdf5
59+
url = https://github.com/HDFGroup/hdf5.git
60+
shallow = true

CMakeLists.txt

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ set(camp_SOURCES
132132
)
133133
add_prefix(gitmodules/camp/src/ camp_SOURCES)
134134

135+
set(hdf5_GENERATED_HEADERS H5Edefin.h H5Einit.h H5Epubgen.h H5Eterm.h H5version.h H5overflow.h)
136+
add_prefix(gitmodules/hdf5/src/ hdf5_GENERATED_HEADERS)
137+
135138
set(netcdf_c_dispatch_SOURCES dvar.c ddim.c dvarput.c dvarget.c ddispatch.c dcompound.c denum.c daux.c
136139
dvlen.c nc.c dfile.c dnotnc4.c dstring.c nclist.c nchashmap.c dinstance_intern.c dtype.c dgroup.c
137140
nclistmgr.c dattget.c dattinq.c dvarinq.c dfilter.c derror.c doffsets.c datt.c dattput.c dcopy.c drc.c
@@ -140,13 +143,21 @@ set(netcdf_c_dispatch_SOURCES dvar.c ddim.c dvarput.c dvarget.c ddispatch.c dcom
140143
)
141144
add_prefix(gitmodules/netcdf-c/libdispatch/ netcdf_c_dispatch_SOURCES)
142145

146+
set(netcdf_c_libhdf5_SOURCES hdf5dispatch.c hdf5create.c hdf5open.c hdf5file.c
147+
hdf5attr.c hdf5debug.c hdf5dim.c hdf5filter.c hdf5grp.c hdf5internal.c hdf5set_format_compatibility.c
148+
hdf5type.c hdf5var.c nc4hdf.c nc4info.c nc4mem.c nc4memcb.c
149+
)
150+
add_prefix(gitmodules/netcdf-c/libhdf5/ netcdf_c_libhdf5_SOURCES)
151+
143152
set(netcdf_c_lib_SOURCES nc_initialize.c)
144153
add_prefix(gitmodules/netcdf-c/liblib/ netcdf_c_lib_SOURCES)
145154

146155
set(netcdf_c_src_SOURCES nc3dispatch.c nc3internal.c dim.c var.c ncio.c v1hpg.c memio.c posixio.c)
147156
add_prefix(gitmodules/netcdf-c/libsrc/ netcdf_c_src_SOURCES)
148157

149-
set(netcdf_c_src4_SOURCES nc4internal.c ncindex.c nc4cache.c nc4dispatch.c nc4type.c nc4grp.c nc4var.c)
158+
set(netcdf_c_src4_SOURCES nc4internal.c ncindex.c nc4cache.c nc4dispatch.c nc4type.c nc4grp.c nc4var.c
159+
ncfunc.c nc4dim.c nc4filters.c nc4attr.c
160+
)
150161
add_prefix(gitmodules/netcdf-c/libsrc4/ netcdf_c_src4_SOURCES)
151162

152163
set(netcdf_f_SOURCES typeSizes.F90 module_netcdf_nf_data.F90 module_netcdf_nc_data.F90
@@ -176,7 +187,7 @@ set(partmclib_SOURCES condense_solver.c aero_state.F90 integer_varray.F90 intege
176187
gas_state.F90 coagulation.F90 exact_soln.F90 coagulation_dist.F90 coag_kernel.F90 spec_line.F90
177188
rand.F90 aero_particle.F90 aero_particle_array.F90 mpi.F90 netcdf.F90 aero_info.F90
178189
aero_info_array.F90 nucleate.F90 condense.F90 fractal.F90 chamber.F90 camp_interface.F90
179-
photolysis.F90
190+
photolysis.F90 aero_component.F90
180191
)
181192
add_prefix(gitmodules/partmc/src/ partmclib_SOURCES)
182193
list(APPEND partmclib_SOURCES src/spec_file_pypartmc.F90 src/sys.F90)
@@ -321,13 +332,38 @@ execute_process(
321332
OUTPUT_FILE ${CMAKE_BINARY_DIR}/include/camp/version.h
322333
)
323334

335+
### HDF5 ###########################################################################################
336+
337+
set(HDF5_EXTERNALLY_CONFIGURED 1)
338+
set(BUILD_STATIC_LIBS ON)
339+
set(HDF5_BUILD_HL_LIB ON)
340+
set(BUILD_SHARED_LIBS OFF)
341+
set(BUILD_TESTING OFF)
342+
set(HDF5_BUILD_TOOLS OFF)
343+
set(HDF5_BUILD_EXAMPLES OFF)
344+
set(HDF5_ENABLE_Z_LIB_SUPPORT OFF)
345+
set(HDF5_ENABLE_SZIP_SUPPORT OFF)
346+
347+
add_subdirectory(${CMAKE_SOURCE_DIR}/gitmodules/hdf5)
348+
349+
foreach(file ${hdf5_GENERATED_HEADERS})
350+
execute_process(
351+
COMMAND ${PYTHON_EXECUTABLE} "-c" "import re;open(1,'wb').write(re.sub(b'\\r',b'',open(0,'rb').read()))"
352+
INPUT_FILE ${CMAKE_SOURCE_DIR}/${file}
353+
OUTPUT_FILE ${CMAKE_BINARY_DIR}/${file}
354+
)
355+
file(REMOVE ${CMAKE_SOURCE_DIR}/${file})
356+
endforeach()
357+
324358
### netCDF #########################################################################################
325359

326360
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/netcdf)
327361
string(CONCAT cmd
328362
"import sys; print(''.join([line for line in sys.stdin"
329363
" if ('VERSION' in line and line.strip().startswith('SET'))"
330364
" or 'CHUNK_' in line"
365+
" or '_CHUNKS_' in line"
366+
" or '_CACHE_SIZE' in line"
331367
" or line.strip().startswith('CHECK_INCLUDE_FILE')"
332368
" or line.strip().startswith('CHECK_TYPE_SIZE')"
333369
" or line.strip().startswith('CHECK_FUNCTION_EXISTS')"
@@ -349,6 +385,7 @@ LIST(APPEND netcdf_c_SOURCES ${netcdf_c_lib_SOURCES})
349385
LIST(APPEND netcdf_c_SOURCES ${netcdf_c_dispatch_SOURCES})
350386
LIST(APPEND netcdf_c_SOURCES ${netcdf_c_src_SOURCES})
351387
LIST(APPEND netcdf_c_SOURCES ${netcdf_c_src4_SOURCES})
388+
LIST(APPEND netcdf_c_SOURCES ${netcdf_c_libhdf5_SOURCES})
352389
foreach (f ${m4_SOURCES})
353390
set(tmp ${CMAKE_BINARY_DIR}/netcdf/${f}.c)
354391
add_custom_command(
@@ -380,15 +417,22 @@ target_include_directories(netcdf_clib PRIVATE
380417
${CMAKE_BINARY_DIR}/netcdf
381418
${CMAKE_SOURCE_DIR}/gitmodules/netcdf-c/include
382419
${CMAKE_SOURCE_DIR}/gitmodules/netcdf-c/libsrc
420+
${CMAKE_SOURCE_DIR}/gitmodules/hdf5/src
421+
${CMAKE_BINARY_DIR}/gitmodules/hdf5/src
422+
${CMAKE_SOURCE_DIR}/gitmodules/hdf5/hl/src
423+
${CMAKE_SOURCE_DIR}/gitmodules/hdf5/src/H5FDsubfiling
383424
)
384425
target_compile_definitions(netcdf_clib PRIVATE
385426
HAVE_CONFIG_H
386427
USE_NETCDF4
428+
USE_HDF5
387429
)
388430
target_compile_options(netcdf_clib PRIVATE
389431
$<$<C_COMPILER_ID:GNU>:-Wno-unused-result -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast>
390432
$<$<C_COMPILER_ID:AppleClang>:-Wno-pointer-to-int-cast -Wno-int-to-void-pointer-cast>
391433
)
434+
target_link_libraries(netcdf_clib PRIVATE hdf5-static)
435+
target_link_libraries(netcdf_clib PRIVATE hdf5_hl-static)
392436

393437
### netCDF-FORTRAN #################################################################################
394438

@@ -435,7 +479,7 @@ add_dependencies(partmclib ${SUNDIALS_items})
435479
string(CONCAT
436480
cmd
437481
"import sys;"
438-
"print(''.join([f'#define {line.split()[3]} {line.split()[5]}\\n' for line in sys.stdin if 'parameter ::' in line]))"
482+
"print(''.join([line if line.startswith('#') else f'#define {line.split()[3]} {line.split()[5]}\\n' for line in sys.stdin if 'parameter ::' in line or line.startswith('#')]))"
439483
)
440484
include(CheckFunctionExists)
441485
foreach(file aero_data;gas_data;output)

MANIFEST.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ include gitmodules/netcdf-c/include/nchttp.h
122122
include gitmodules/netcdf-c/include/netcdf_mem.h
123123
include gitmodules/netcdf-c/include/netcdf_filter.h
124124
include gitmodules/netcdf-c/include/netcdf_aux.h
125+
include gitmodules/netcdf-c/include/hdf5internal.h
126+
include gitmodules/netcdf-c/include/hdf5dispatch.h
127+
include gitmodules/netcdf-c/include/ncdimscale.h
125128
include gitmodules/netcdf-c/libdispatch/utf8proc_data.c
126129
include gitmodules/netcdf-c/libdispatch/utf8proc.h
127130
include gitmodules/netcdf-c/libdispatch/dvar.c
@@ -188,6 +191,12 @@ include gitmodules/netcdf-c/libsrc4/nc4dispatch.c
188191
include gitmodules/netcdf-c/libsrc4/nc4type.c
189192
include gitmodules/netcdf-c/libsrc4/nc4grp.c
190193
include gitmodules/netcdf-c/libsrc4/nc4var.c
194+
include gitmodules/netcdf-c/libsrc4/nc4dim.c
195+
include gitmodules/netcdf-c/libsrc4/nc4attr.c
196+
include gitmodules/netcdf-c/libsrc4/nc4filters.c
197+
include gitmodules/netcdf-c/libsrc4/ncfunc.c
198+
199+
graft gitmodules/netcdf-c/libhdf5
191200

192201
include gitmodules/netcdf-fortran/COPYRIGHT
193202
include gitmodules/netcdf-fortran/CMakeExtras/MatchNetCDFFortranTypes.cmake
@@ -230,3 +239,12 @@ include gitmodules/netcdf-fortran/fortran/netcdf_text_variables.F90
230239
include gitmodules/netcdf-fortran/fortran/netcdf_expanded.F90
231240
include gitmodules/netcdf-fortran/fortran/netcdf4_eightbyte.F90
232241
include gitmodules/netcdf-fortran/fortran/netcdf4_func.F90
242+
243+
include gitmodules/hdf5/COPYING
244+
include gitmodules/hdf5/CMakeLists.txt
245+
include gitmodules/hdf5/*.cmake
246+
graft gitmodules/hdf5/src
247+
graft gitmodules/hdf5/bin
248+
graft gitmodules/hdf5/config
249+
include gitmodules/hdf5/hl/CMakeLists.txt
250+
graft gitmodules/hdf5/hl/src

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ MOSAIC_HOME=<<PATH_TO_MOSAIC_LIB>> pip install --force-reinstall --no-binary=PyP
289289
```
290290
291291
- Q: Why `pip install PyPartMC` triggers compilation on my brand new Apple machine, while it quickly downloads and installs binary packages when executed on older Macs, Windows or Linux?
292-
A: We are not yet providing binary wheels on PyPI for Apple-silicon (arm64) machines. Cross-compilation with gfortran is only supported with experimental unofficial builds [and is tricky](https://github.com/iains/gcc-12-branch/issues/23), while Github Actions ARM64 virtual machines are [costly](https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#minute-multipliers).
292+
A: We are providing binary wheels on PyPI for Apple-silicon (arm64) machines for selected macOS version made available by Github. In case the macOS version you are using is newer, compilation from source is triggered.
293293
294294
- Q: Why some of the constructors expect data to be passed as **lists of single-entry dictionaries** instead of multi-element dictionaries?
295295
A: This is intentional and related with PartMC relying on the order of elements within spec-file input; while Python dictionaries preserve ordering (insertion order), JSON format does not, and we intend to make these data structures safe to be [de]serialized using JSON.
@@ -301,6 +301,9 @@ import PyPartMC
301301
PyPartMC.__versions_of_build_time_dependencies__['PartMC']
302302
```
303303
304+
- Q: Why m4 and perl are required at compile time?
305+
A: PyPartMC includes parts of netCDF and HDF5 codebases which depend on m4 and perl, respectively, for generating source files before compilation.
306+
304307
## Troubleshooting
305308
306309
#### Common installation issues

gitmodules/hdf5

Submodule hdf5 added at bbf1e26

gitmodules/partmc

Submodule partmc updated 103 files

readme_fortran/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_executable(main
77
$ENV{PARTMC_HOME}/src/spec_line.F90
88
$ENV{PARTMC_HOME}/src/util.F90
99
$ENV{PARTMC_HOME}/src/constants.F90
10+
$ENV{PARTMC_HOME}/src/aero_component.F90
1011
$ENV{PARTMC_HOME}/src/aero_data.F90
1112
$ENV{PARTMC_HOME}/src/aero_mode.F90
1213
$ENV{PARTMC_HOME}/src/aero_dist.F90

readme_fortran/main.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ program main
2020
call spec_file_close(f_aero_data)
2121

2222
call spec_file_open("aero_dist.dat", f_aero_dist)
23-
call spec_file_read_aero_dist(f_aero_dist, aero_data, aero_dist)
23+
call spec_file_read_aero_dist(f_aero_dist, aero_data, .false., aero_dist)
2424
call spec_file_close(f_aero_dist)
2525

2626
call aero_state_zero(aero_state)
@@ -29,7 +29,7 @@ program main
2929
AERO_STATE_WEIGHT_NUMMASS_SOURCE)
3030
call aero_state_set_n_part_ideal(aero_state, dble(n_part))
3131
call aero_state_add_aero_dist_sample(aero_state, aero_data, &
32-
aero_dist, 1d0, 0d0, .true., .true., n_part_add)
32+
aero_dist, 1d0, 1d0, 0d0, .true., .true., n_part_add)
3333

3434
num_concs = aero_state_num_concs(aero_state, aero_data)
3535
masses = aero_state_masses(aero_state, aero_data)

src/aero_dist.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ subroutine f_aero_dist_from_json(ptr_c, aero_data_ptr_c) bind(C)
3838
call c_f_pointer(ptr_c, aero_dist)
3939
call c_f_pointer(aero_data_ptr_c, aero_data_ptr_f)
4040

41-
call spec_file_read_aero_dist(file, aero_data_ptr_f, aero_dist)
41+
call spec_file_read_aero_dist(file, aero_data_ptr_f, .false., aero_dist)
4242
end subroutine
4343

4444
subroutine f_aero_dist_n_mode(ptr_c, n_mode) bind(C)

0 commit comments

Comments
 (0)