├── .appveyor.yml ├── .circleci └── config.yml ├── .clang-format ├── .clang-tidy ├── .dockerignore ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ ├── install_problem.md │ └── question.md ├── ci │ ├── sanitizer │ │ └── clang │ │ │ └── Leak.supp │ └── spack-envs │ │ ├── clang11_nopy_nompi_h5_libcpp │ │ └── spack.yaml │ │ ├── clang11_nopy_ompi_h5_ad2 │ │ └── spack.yaml │ │ ├── clang11_nopy_ompi_h5_ad2_libcpp │ │ └── spack.yaml │ │ ├── clang15_py311_nompi_h5_ad2 │ │ └── spack.yaml │ │ ├── clangtidy_nopy_ompi_h5_ad2 │ │ └── spack.yaml │ │ ├── gcc12_py36_ompi_h5_ad2 │ │ └── spack.yaml │ │ ├── gcc13_py312_mpich_h5_ad2 │ │ └── spack.yaml │ │ └── gcc_py_ompi_h5_ad2_arm64 │ │ └── spack.yaml ├── dependabot.yml └── workflows │ ├── clang-format │ └── clang-format.sh │ ├── codeql.yml │ ├── dependencies │ ├── install_icc │ ├── install_icx │ ├── install_mpich │ ├── install_nvcc12.sh │ ├── install_nvhpc25-1.sh │ └── install_spack │ ├── intel.yml │ ├── linux.yml │ ├── macos.yml │ ├── nvidia.yml │ ├── source.yml │ ├── source │ ├── buildDoxygen │ ├── hasEOLwhiteSpace │ ├── hasNonASCII │ └── hasTabs │ ├── tooling.yml │ └── windows.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .readthedocs.yml ├── .rodare.json ├── CHANGELOG.rst ├── CITATION.cff ├── CMakeLists.txt ├── CODE_OF_CONDUCT.rst ├── CONTRIBUTING.rst ├── COPYING ├── COPYING.LESSER ├── Dockerfile ├── MANIFEST.in ├── NEWS.rst ├── README.md ├── Singularity ├── cmake ├── dependencies │ ├── catch.cmake │ ├── json.cmake │ ├── pybind11.cmake │ └── toml11.cmake └── openPMDFunctions.cmake ├── conda.yml ├── docs ├── Doxyfile ├── Makefile ├── requirements.txt ├── source │ ├── analysis │ │ ├── contrib.rst │ │ ├── dask.rst │ │ ├── pandas.rst │ │ ├── paraview.rst │ │ ├── rapids.rst │ │ └── viewer.rst │ ├── backends │ │ ├── adios1.rst │ │ ├── adios2.rst │ │ ├── hdf5.rst │ │ ├── json.rst │ │ ├── json_example.json │ │ └── overview.rst │ ├── citation.rst │ ├── coc.rst │ ├── conf.py │ ├── details │ │ ├── adios2.json │ │ ├── adios2.toml │ │ ├── backendconfig.rst │ │ ├── config_layout.json │ │ ├── config_layout.toml │ │ ├── doxygen.rst │ │ ├── hdf5.json │ │ ├── json.json │ │ ├── mpi.rst │ │ ├── openpmd_extended_config.json │ │ ├── openpmd_extended_config.toml │ │ └── python.rst │ ├── dev │ │ ├── IOTask.hpp │ │ ├── backend.rst │ │ ├── buildoptions.rst │ │ ├── contributing.rst │ │ ├── dependencies.rst │ │ ├── design.rst │ │ ├── linking.rst │ │ ├── repostructure.rst │ │ └── sphinx.rst │ ├── index.rst │ ├── install │ │ ├── brew.svg │ │ ├── changelog.rst │ │ ├── cmake.svg │ │ ├── conda.svg │ │ ├── install.rst │ │ ├── pypi.svg │ │ ├── spack.svg │ │ └── upgrade.rst │ ├── maintenance │ │ ├── release_channels.rst │ │ ├── release_github.rst │ │ └── requirements.txt │ ├── openPMD.png │ ├── usage │ │ ├── 10_streaming_read.cpp │ │ ├── 10_streaming_read.py │ │ ├── 10_streaming_write.cpp │ │ ├── 10_streaming_write.py │ │ ├── 2_read_serial.cpp │ │ ├── 2_read_serial.py │ │ ├── 2a_read_thetaMode_serial.cpp │ │ ├── 2a_read_thetaMode_serial.py │ │ ├── 3_write_serial.cpp │ │ ├── 3_write_serial.py │ │ ├── 3a_write_thetaMode_serial.cpp │ │ ├── 3a_write_thetaMode_serial.py │ │ ├── 3b_write_resizable_particles.cpp │ │ ├── 3b_write_resizable_particles.py │ │ ├── 4_read_parallel.cpp │ │ ├── 4_read_parallel.py │ │ ├── 5_write_parallel.cpp │ │ ├── 5_write_parallel.py │ │ ├── benchmarks.rst │ │ ├── concepts.rst │ │ ├── examples.rst │ │ ├── firstread.rst │ │ ├── firstwrite.rst │ │ ├── hierarchy.svg │ │ ├── parallel.rst │ │ ├── serial.rst │ │ ├── streaming.rst │ │ └── workflow.rst │ └── utilities │ │ ├── 8_benchmark_parallel.cpp │ │ ├── benchmark.rst │ │ └── cli.rst └── ubuntu-package.list ├── environment.yml ├── examples ├── 10_streaming_read.cpp ├── 10_streaming_read.py ├── 10_streaming_write.cpp ├── 10_streaming_write.py ├── 11_particle_dataframe.py ├── 12_span_write.cpp ├── 12_span_write.py ├── 13_write_dynamic_configuration.cpp ├── 13_write_dynamic_configuration.py ├── 14_toml_template.cpp ├── 1_structure.cpp ├── 2_read_serial.cpp ├── 2_read_serial.py ├── 2a_read_thetaMode_serial.cpp ├── 2a_read_thetaMode_serial.py ├── 3_write_serial.cpp ├── 3_write_serial.py ├── 3a_write_thetaMode_serial.cpp ├── 3a_write_thetaMode_serial.py ├── 3b_write_resizable_particles.cpp ├── 3b_write_resizable_particles.py ├── 4_read_parallel.cpp ├── 4_read_parallel.py ├── 5_write_parallel.cpp ├── 5_write_parallel.py ├── 6_dump_filebased_series.cpp ├── 7_extended_write_serial.cpp ├── 7_extended_write_serial.py ├── 8_benchmark_parallel.cpp ├── 8a_benchmark_write_parallel.cpp ├── 8b_benchmark_read_parallel.cpp └── 9_particle_write_serial.py ├── include └── openPMD │ ├── ChunkInfo.hpp │ ├── ChunkInfo_internal.hpp │ ├── Dataset.hpp │ ├── Datatype.hpp │ ├── Datatype.tpp │ ├── DatatypeHelpers.hpp │ ├── DatatypeMacros.hpp │ ├── Datatype_internal.hpp │ ├── Error.hpp │ ├── IO │ ├── ADIOS │ │ ├── ADIOS2Auxiliary.hpp │ │ ├── ADIOS2File.hpp │ │ ├── ADIOS2FilePosition.hpp │ │ ├── ADIOS2IOHandler.hpp │ │ ├── ADIOS2PreloadAttributes.hpp │ │ ├── ADIOS2PreloadVariables.hpp │ │ └── macros.hpp │ ├── AbstractFilePosition.hpp │ ├── AbstractIOHandler.hpp │ ├── AbstractIOHandlerHelper.hpp │ ├── AbstractIOHandlerImpl.hpp │ ├── AbstractIOHandlerImplCommon.hpp │ ├── Access.hpp │ ├── DummyIOHandler.hpp │ ├── FlushParametersInternal.hpp │ ├── Format.hpp │ ├── HDF5 │ │ ├── HDF5Auxiliary.hpp │ │ ├── HDF5FilePosition.hpp │ │ ├── HDF5IOHandler.hpp │ │ ├── HDF5IOHandlerImpl.hpp │ │ ├── ParallelHDF5IOHandler.hpp │ │ └── ParallelHDF5IOHandlerImpl.hpp │ ├── IOTask.hpp │ ├── InvalidatableFile.hpp │ └── JSON │ │ ├── JSONFilePosition.hpp │ │ ├── JSONIOHandler.hpp │ │ └── JSONIOHandlerImpl.hpp │ ├── Iteration.hpp │ ├── IterationEncoding.hpp │ ├── Mesh.hpp │ ├── ParticlePatches.hpp │ ├── ParticleSpecies.hpp │ ├── ReadIterations.hpp │ ├── Record.hpp │ ├── RecordComponent.hpp │ ├── RecordComponent.tpp │ ├── Series.hpp │ ├── Span.hpp │ ├── Streaming.hpp │ ├── ThrowError.hpp │ ├── UndefDatatypeMacros.hpp │ ├── UnitDimension.hpp │ ├── WriteIterations.hpp │ ├── auxiliary │ ├── Date.hpp │ ├── DerefDynamicCast.hpp │ ├── Environment.hpp │ ├── Export.hpp │ ├── Filesystem.hpp │ ├── JSON.hpp │ ├── JSONMatcher.hpp │ ├── JSON_internal.hpp │ ├── Memory.hpp │ ├── Mpi.hpp │ ├── OutOfRangeMsg.hpp │ ├── ShareRaw.hpp │ ├── ShareRawInternal.hpp │ ├── StringManip.hpp │ ├── TypeTraits.hpp │ ├── UniquePtr.hpp │ └── Variant.hpp │ ├── backend │ ├── Attributable.hpp │ ├── Attribute.hpp │ ├── BaseRecord.hpp │ ├── BaseRecordComponent.hpp │ ├── Container.hpp │ ├── MeshRecordComponent.hpp │ ├── ParsePreference.hpp │ ├── PatchRecord.hpp │ ├── PatchRecordComponent.hpp │ └── Writable.hpp │ ├── benchmark │ ├── MemoryProfiler.hpp │ ├── Timer.hpp │ └── mpi │ │ ├── BlockSlicer.hpp │ │ ├── DatasetFiller.hpp │ │ ├── MPIBenchmark.hpp │ │ ├── MPIBenchmarkReport.hpp │ │ ├── OneDimensionalBlockSlicer.hpp │ │ └── RandomDatasetFiller.hpp │ ├── binding │ └── python │ │ ├── Common.hpp │ │ ├── Container.H │ │ ├── Mpi.hpp │ │ ├── Numpy.hpp │ │ ├── Pickle.hpp │ │ ├── RecordComponent.hpp │ │ ├── UnitDimension.hpp │ │ └── auxiliary.hpp │ ├── cli │ └── ls.hpp │ ├── config.hpp.in │ ├── helper │ └── list_series.hpp │ ├── openPMD.hpp │ ├── snapshots │ ├── ContainerImpls.hpp │ ├── ContainerTraits.hpp │ ├── IteratorHelpers.hpp │ ├── IteratorTraits.hpp │ ├── RandomAccessIterator.hpp │ ├── Snapshots.hpp │ └── StatefulIterator.hpp │ └── version.hpp ├── new_version.py ├── openPMD.pc.in ├── openPMDConfig.cmake.in ├── pyproject.toml ├── requirements.txt ├── setup.py ├── share └── openPMD │ ├── download_samples.ps1 │ ├── download_samples.sh │ └── validate_files.sh ├── spack.yaml ├── src ├── ChunkInfo.cpp ├── Dataset.cpp ├── Datatype.cpp ├── Error.cpp ├── Format.cpp ├── IO │ ├── ADIOS │ │ ├── ADIOS2Auxiliary.cpp │ │ ├── ADIOS2File.cpp │ │ ├── ADIOS2IOHandler.cpp │ │ ├── ADIOS2PreloadAttributes.cpp │ │ └── ADIOS2PreloadVariables.cpp │ ├── AbstractIOHandler.cpp │ ├── AbstractIOHandlerHelper.cpp │ ├── AbstractIOHandlerImpl.cpp │ ├── Access.cpp │ ├── DummyIOHandler.cpp │ ├── FlushParams.cpp │ ├── HDF5 │ │ ├── HDF5Auxiliary.cpp │ │ ├── HDF5IOHandler.cpp │ │ └── ParallelHDF5IOHandler.cpp │ ├── IOTask.cpp │ ├── InvalidatableFile.cpp │ └── JSON │ │ ├── JSONFilePosition.cpp │ │ ├── JSONIOHandler.cpp │ │ └── JSONIOHandlerImpl.cpp ├── Iteration.cpp ├── IterationEncoding.cpp ├── Mesh.cpp ├── ParticlePatches.cpp ├── ParticleSpecies.cpp ├── ReadIterations.cpp ├── Record.cpp ├── RecordComponent.cpp ├── Series.cpp ├── UnitDimension.cpp ├── auxiliary │ ├── Date.cpp │ ├── Filesystem.cpp │ ├── JSON.cpp │ ├── JSONMatcher.cpp │ └── Mpi.cpp ├── backend │ ├── Attributable.cpp │ ├── BaseRecordComponent.cpp │ ├── MeshRecordComponent.cpp │ ├── PatchRecord.cpp │ ├── PatchRecordComponent.cpp │ └── Writable.cpp ├── benchmark │ └── mpi │ │ └── OneDimensionalBlockSlicer.cpp ├── binding │ └── python │ │ ├── Access.cpp │ │ ├── Attributable.cpp │ │ ├── BaseRecordComponent.cpp │ │ ├── ChunkInfo.cpp │ │ ├── Dataset.cpp │ │ ├── Datatype.cpp │ │ ├── Error.cpp │ │ ├── Helper.cpp │ │ ├── Iteration.cpp │ │ ├── IterationEncoding.cpp │ │ ├── Mesh.cpp │ │ ├── MeshRecordComponent.cpp │ │ ├── ParticlePatches.cpp │ │ ├── ParticleSpecies.cpp │ │ ├── PatchRecord.cpp │ │ ├── PatchRecordComponent.cpp │ │ ├── Record.cpp │ │ ├── RecordComponent.cpp │ │ ├── Series.cpp │ │ ├── UnitDimension.cpp │ │ ├── auxiliary.cpp │ │ ├── openPMD.cpp │ │ └── openpmd_api │ │ ├── DaskArray.py │ │ ├── DaskDataFrame.py │ │ ├── DataFrame.py │ │ ├── __init__.py │ │ ├── ls │ │ ├── __init__.py │ │ └── __main__.py │ │ └── pipe │ │ ├── __init__.py │ │ └── __main__.py ├── cli │ ├── ls.cpp │ └── pipe.py ├── config.cpp ├── helper │ └── list_series.cpp ├── snapshots │ ├── ContainerImpls.cpp │ ├── ContainerTraits.cpp │ ├── IteratorHelpers.cpp │ ├── IteratorTraits.cpp │ ├── RandomAccessIterator.cpp │ ├── Snapshots.cpp │ └── StatefulIterator.cpp └── version.cpp └── test ├── AuxiliaryTest.cpp ├── CatchMain.cpp ├── CatchRunner.cpp ├── CoreTest.cpp ├── Files_Core ├── CoreTests.hpp └── automatic_variable_encoding.cpp ├── Files_ParallelIO ├── ParallelIOTests.hpp ├── bug_1655_bp5_writer_hangup.cpp ├── iterate_nonstreaming_series.cpp └── read_variablebased_randomaccess.cpp ├── Files_SerialIO ├── SerialIOTests.hpp ├── close_and_reopen_test.cpp ├── filebased_write_test.cpp └── issue_1744_unique_ptrs_at_close_time.cpp ├── JSONTest.cpp ├── ParallelIOTest.cpp ├── SerialIOTest.cpp └── python └── unittest ├── API ├── APITest.py └── __init__.py ├── Test.py ├── TestUtilities ├── TestUtilities.py └── __init__.py └── __init__.py /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | jobs: 4 | linux-aarch64: 5 | working_directory: ~/linux-aarch64-wheels 6 | machine: 7 | image: ubuntu-2204:current 8 | # resource_class is what tells CircleCI to use an ARM worker for native arm builds 9 | # https://circleci.com/product/features/resource-classes/ 10 | # https://circleci.com/docs/using-arm/ 11 | resource_class: arm.large 12 | steps: 13 | - checkout 14 | - run: 15 | name: Install build dependencies 16 | command: | 17 | sudo apt update 18 | sudo apt install cmake g++ gfortran libfabric-dev libopenmpi-dev libhdf5-openmpi-dev hdf5-tools pkgconf python3 python3-setuptools 19 | sudo .github/workflows/dependencies/install_spack 20 | python3 -m pip install -U pip 21 | python3 -m pip install -U packaging setuptools wheel 22 | python3 -m pip install -U six 23 | python3 -m pip install -U numpy 24 | python3 -m pip install -U mpi4py 25 | python3 -m pip install -U pandas 26 | python3 -m pip install -U dask 27 | python3 -m pip install -U pyarrow 28 | 29 | eval $(spack env activate --sh .github/ci/spack-envs/gcc_py_ompi_h5_ad2_arm64/) 30 | spack install 31 | 32 | share/openPMD/download_samples.sh build 33 | - run: 34 | name: Build openPMD-api 35 | command: | 36 | eval $(spack env activate --sh .github/ci/spack-envs/gcc_py_ompi_h5_ad2_arm64/) 37 | 38 | export CXXFLAGS="-DPYBIND11_DETAILED_ERROR_MESSAGES=1" 39 | 40 | cmake -S . -B build \ 41 | -DopenPMD_USE_PYTHON=ON \ 42 | -DopenPMD_USE_MPI=ON \ 43 | -DopenPMD_USE_HDF5=ON \ 44 | -DopenPMD_USE_ADIOS2=ON \ 45 | -DopenPMD_USE_INVASIVE_TESTS=ON \ 46 | -DPython_EXECUTABLE=$(which python3) 47 | cmake --build build --parallel 4 48 | - run: 49 | name: Test openPMD-api 50 | command: | 51 | eval $(spack env activate --sh .github/ci/spack-envs/gcc_py_ompi_h5_ad2_arm64/) 52 | ctest --test-dir build --output-on-failure 53 | 54 | workflows: 55 | version: 2 56 | all-tests: 57 | jobs: 58 | - linux-aarch64 59 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | 4 | BasedOnStyle: LLVM 5 | AccessModifierOffset: -4 6 | AlignAfterOpenBracket: AlwaysBreak 7 | AlignConsecutiveAssignments: false 8 | AlignConsecutiveDeclarations: false 9 | # AlignEscapedNewlinesLeft: false 10 | AlignEscapedNewlines: Right 11 | AlignOperands: false 12 | AlignTrailingComments: false 13 | AllowAllArgumentsOnNextLine: true 14 | AllowAllConstructorInitializersOnNextLine: true 15 | AllowAllParametersOfDeclarationOnNextLine: true 16 | AllowShortBlocksOnASingleLine: false 17 | AllowShortCaseLabelsOnASingleLine: false 18 | AllowShortFunctionsOnASingleLine: None 19 | AllowShortIfStatementsOnASingleLine: false 20 | AllowShortLambdasOnASingleLine: true 21 | AllowShortLoopsOnASingleLine: false 22 | AlwaysBreakBeforeMultilineStrings: true 23 | AlwaysBreakTemplateDeclarations: Yes 24 | BinPackArguments: false 25 | BinPackParameters: false 26 | 27 | BreakBeforeBraces: Custom 28 | BraceWrapping: 29 | AfterClass: true 30 | AfterControlStatement: true 31 | AfterEnum: true 32 | AfterExternBlock: true 33 | AfterFunction: true 34 | AfterNamespace: true 35 | AfterStruct: true 36 | AfterUnion: true 37 | BeforeCatch: true 38 | BeforeElse: true 39 | # BeforeLambdaBody: true 40 | SplitEmptyFunction: false 41 | SplitEmptyNamespace: false 42 | SplitEmptyRecord: false 43 | 44 | BreakConstructorInitializers: BeforeComma 45 | BreakInheritanceList: BeforeComma 46 | ColumnLimit: 80 47 | CompactNamespaces: false 48 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 49 | ConstructorInitializerIndentWidth: 4 50 | ContinuationIndentWidth: 4 51 | FixNamespaceComments: true 52 | IndentWidth: 4 53 | NamespaceIndentation: Inner 54 | PointerAlignment: Right 55 | SortUsingDeclarations: false 56 | SpaceAfterCStyleCast: false 57 | SpaceAfterTemplateKeyword: true 58 | SpaceBeforeAssignmentOperators: true 59 | SpaceBeforeParens: ControlStatements 60 | SpaceInEmptyParentheses: false 61 | SpacesInAngles: false 62 | SpacesInContainerLiterals: false 63 | SpacesInCStyleCastParentheses: false 64 | SpacesInParentheses: false 65 | SpacesInSquareBrackets: false 66 | Standard: Auto 67 | StatementMacros: ["OPENPMD_private", "OPENPMD_protected"] 68 | 69 | --- 70 | Language: Json 71 | BasedOnStyle: llvm 72 | ... 73 | -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | # Future consideration: cppcoreguidelines-*,clang-analyzer-*,google-*,hicpp-*,llvm-*,misc-*,readability-*,-clang-diagnostic-unused-command-line-argument,-*-namespace-comment*,-*-braces-around-statements,-google-readability-todo,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter 2 | # FIXME: all performance-* reports 3 | # FIXME: all cert-* reports 4 | # FIXME: all bugprone-* reports 5 | Checks: -*,bugprone-*,-bugprone-unhandled-self-assignment,-bugprone-parent-virtual-call,-bugprone-narrowing-conversions,-bugprone-exception-escape,-bugprone-string-literal-with-embedded-nul,cppcoreguidelines-slicing,mpi-*,readability-non-const-parameter,performance-*,modernize-*,-modernize-use-trailing-return-type,-modernize-use-bool-literals,-modernize-avoid-c-arrays,-modernize-use-auto,-modernize-return-braced-init-list,-bugprone-easily-swappable-parameters 6 | HeaderFilterRegex: '((^(?!\/share\/openPMD\/).*)*include\/openPMD\/.+\.hpp|src\/^(?!binding).+\.cpp$)' 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://EditorConfig.org 2 | # 3 | # precedence of rules is bottom to top 4 | 5 | # this is the top-most EditorConfig file 6 | root = true 7 | 8 | 9 | [*] 10 | # 4 space indentation 11 | indent_style = space 12 | indent_size = 4 13 | 14 | # no end of line whitespaces 15 | trim_trailing_whitespace = true 16 | 17 | # unix-style newlines 18 | end_of_line = lf 19 | 20 | # newline ending in files 21 | insert_final_newline = true 22 | 23 | 24 | [*.md] 25 | # two end of line whitespaces are newlines without a paragraph 26 | trim_trailing_whitespace = false 27 | 28 | 29 | [Makefile] 30 | # TABs are part of its syntax 31 | indent_style = tab 32 | indent_size = unset 33 | 34 | 35 | [*.py] 36 | # isort config 37 | force_sort_within_sections = true 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | labels: bug 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Compile-able/executable code example to reproduce the problem: 12 | 13 | Python: 14 | ```python 15 | import openpmd_api 16 | 17 | # ... 18 | ``` 19 | or C++ 20 | ```C++ 21 | #include 22 | 23 | // ... 24 | ``` 25 | 26 | or command line script, example: 27 | ```bash 28 | # in directory $HOME/src/openPMD-api 29 | mkdir build && cd build 30 | 31 | cmake .. 32 | # fails with: 33 | # bash: cmake: command not found 34 | ``` 35 | 36 | **Expected behavior** 37 | A clear and concise description of what you expected to happen. 38 | 39 | **Software Environment** 40 | - version of openPMD-api: [X.Y.Z-abc] 41 | - installed openPMD-api via: [conda-forge, spack, pip, brew, yggdrasil, from source, module system, ...] 42 | - operating system: [name and version] 43 | - machine: [Are you running on a public cluster? It's likely we compute on it as well!] 44 | - name and version of Python implementation: [e.g. CPython 3.9] 45 | - version of HDF5: [e.g. 1.12.0] 46 | - version of ADIOS2: [e.g. 2.7.1] 47 | - name and version of MPI: [e.g. OpenMPI 4.1.1] 48 | 49 | **Additional context** 50 | Add any other context about the problem here. 51 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | labels: "feature request" 5 | --- 6 | 7 | **Is your feature request related to a problem? If so, please describe.** 8 | A clear and concise description of what the problem is. 9 | Example: I always do the following workflow [...] 10 | 11 | Don't be afraid to add code examples! 12 | Python: 13 | ```python 14 | import openpmd_api 15 | 16 | # ... 17 | ``` 18 | or C++ 19 | ```C++ 20 | #include 21 | 22 | // ... 23 | ``` 24 | 25 | **Describe the solution you'd like** 26 | A clear and concise description of what you want to happen. 27 | Example: It would be fantastic if one could [...] 28 | 29 | **Describe alternatives you've considered** 30 | A clear and concise description of any alternative solutions or features you've considered. 31 | 32 | **Additional context** 33 | Add any other context about the feature request here. 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/install_problem.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Installation problem 3 | about: Any problem experienced while trying to install 4 | labels: install 5 | --- 6 | 7 | **Performed steps** 8 | The following steps 9 | 10 | ```commandline 11 | ... 12 | ``` 13 | 14 | led to the following output/problem during install 15 | 16 | ``` 17 | ... 18 | ``` 19 | 20 | You can also add images such as screenshots :-) 21 | 22 | **System environment** 23 | - operating system: [name and version] 24 | - machine: [Are you running on a public cluster? It's likely we compute on it as well!] 25 | - name and version of Python implementation: [e.g. `python3 --version`] 26 | 27 | **Additional context** 28 | Any addition info that might help us, e.g. did you try to use a certain language binding (C++/Python?) or did you try to use a specific variant (MPI-parallel?) or backend (HDF5? ADIOS2?)? 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Usage question 3 | about: Anything unclear or not well documented 4 | labels: question 5 | --- 6 | 7 | **What do you want to achieve, please describe.** 8 | 9 | Don't be afraid to add code examples! 10 | Python: 11 | ```python 12 | import openpmd_api 13 | 14 | # ... 15 | ``` 16 | or C++ 17 | ```C++ 18 | #include 19 | 20 | // ... 21 | ``` 22 | 23 | You can also add images such as screenshots :-) 24 | 25 | **Software Environment:** 26 | Have you already installed openPMD-api? 27 | If so, please tell us which *version* of openPMD-api your question is about: 28 | 29 | - version of openPMD-api: [X.Y.Z-abc] 30 | - installed openPMD-api via: [conda-forge, spack, pip, brew, yggdrasil, from source, module system, ...] 31 | -------------------------------------------------------------------------------- /.github/ci/sanitizer/clang/Leak.supp: -------------------------------------------------------------------------------- 1 | # OpenMPI 1.10.2 Memory Leaks 2 | leak:mca_io_ompi* 3 | leak:mca_pmix_pmix* 4 | leak:libopen-pal* 5 | leak:libopen-rte* 6 | leak:libmpi* 7 | leak:libevent* 8 | # CPython 3.7.1 and pybind11 2.3.0 9 | leak:*py* 10 | # 10 byte memleak in main of "make" 4.1 11 | leak:/usr/bin/make* 12 | # ADIOS2 13 | leak:adios2::core::engine::SstReader::* 14 | leak:adios2::core::engine::SstWriter::* 15 | leak:ps_make_timer_name_ 16 | -------------------------------------------------------------------------------- /.github/ci/spack-envs/clang11_nopy_nompi_h5_libcpp/spack.yaml: -------------------------------------------------------------------------------- 1 | # This is a Spack environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development. 5 | # https//spack.readthedocs.io/en/latest/environments.html#anonymous-environments 6 | # 7 | spack: 8 | specs: 9 | - hdf5 10 | 11 | packages: 12 | all: 13 | target: [x86_64] 14 | variants: ~mpi ~fortran 15 | compiler: [clang@11.1.0] 16 | 17 | compilers: 18 | - compiler: 19 | environment: {} 20 | extra_rpaths: [] 21 | flags: 22 | cxxflags: -stdlib=libc++ 23 | ldflags: -stdlib=libc++ 24 | modules: [] 25 | operating_system: ubuntu22.04 26 | paths: 27 | cc: /usr/bin/clang-11 28 | cxx: /usr/bin/clang++-11 29 | f77: null 30 | fc: null 31 | spec: clang@11.1.0 32 | target: x86_64 33 | 34 | config: 35 | build_jobs: 2 36 | 37 | mirrors: 38 | E4S: https://cache.e4s.io 39 | -------------------------------------------------------------------------------- /.github/ci/spack-envs/clang11_nopy_ompi_h5_ad2/spack.yaml: -------------------------------------------------------------------------------- 1 | # This is a Spack environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development. 5 | # https//spack.readthedocs.io/en/latest/environments.html#anonymous-environments 6 | # 7 | spack: 8 | specs: 9 | - adios2 10 | - hdf5 11 | - openmpi 12 | 13 | packages: 14 | adios2: 15 | variants: ~zfp ~sz ~png ~dataman ~python ~fortran ~ssc ~shared ~bzip2 ~blosc2 ~mgard 16 | cmake: 17 | externals: 18 | - spec: cmake@3.31.5 19 | prefix: /usr 20 | buildable: False 21 | openmpi: 22 | externals: 23 | - spec: openmpi@4.1.2 24 | prefix: /usr 25 | buildable: False 26 | perl: 27 | externals: 28 | - spec: perl@5.34.0 29 | prefix: /usr 30 | buildable: False 31 | python: 32 | externals: 33 | - spec: python@3.10.12 34 | prefix: /usr 35 | buildable: False 36 | all: 37 | target: [x86_64] 38 | variants: ~fortran 39 | providers: 40 | mpi: [openmpi] 41 | compiler: [clang@11.1.0] 42 | 43 | compilers: 44 | - compiler: 45 | environment: {} 46 | extra_rpaths: [] 47 | flags: {} 48 | modules: [] 49 | operating_system: ubuntu22.04 50 | paths: 51 | cc: /usr/bin/clang-11 52 | cxx: /usr/bin/clang++-11 53 | f77: /usr/bin/gfortran 54 | fc: /usr/bin/gfortran 55 | spec: clang@11.1.0 56 | target: x86_64 57 | 58 | config: 59 | build_jobs: 2 60 | 61 | mirrors: 62 | E4S: https://cache.e4s.io 63 | -------------------------------------------------------------------------------- /.github/ci/spack-envs/clang11_nopy_ompi_h5_ad2_libcpp/spack.yaml: -------------------------------------------------------------------------------- 1 | # This is a Spack environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development. 5 | # https//spack.readthedocs.io/en/latest/environments.html#anonymous-environments 6 | # 7 | spack: 8 | specs: 9 | - adios2@2.10 10 | - hdf5 11 | - openmpi 12 | 13 | packages: 14 | adios2: 15 | variants: ~zfp ~sz ~png ~dataman ~python ~fortran ~ssc ~shared ~bzip2 ~mgard ~blosc2 16 | cmake: 17 | externals: 18 | - spec: cmake@3.31.5 19 | prefix: /usr 20 | buildable: False 21 | openmpi: 22 | externals: 23 | - spec: openmpi@4.1.2 24 | prefix: /usr 25 | buildable: False 26 | perl: 27 | externals: 28 | - spec: perl@5.34.0 29 | prefix: /usr 30 | buildable: False 31 | python: 32 | externals: 33 | - spec: python@3.10.12 34 | prefix: /usr 35 | buildable: False 36 | all: 37 | target: [x86_64] 38 | variants: ~fortran 39 | providers: 40 | mpi: [openmpi] 41 | compiler: [clang@11.1.0] 42 | 43 | compilers: 44 | - compiler: 45 | environment: {} 46 | extra_rpaths: [] 47 | flags: 48 | cxxflags: -stdlib=libc++ 49 | ldflags: -stdlib=libc++ 50 | modules: [] 51 | operating_system: ubuntu22.04 52 | paths: 53 | cc: /usr/bin/clang-11 54 | cxx: /usr/bin/clang++-11 55 | f77: /usr/bin/gfortran 56 | fc: /usr/bin/gfortran 57 | spec: clang@11.1.0 58 | target: x86_64 59 | 60 | config: 61 | build_jobs: 2 62 | 63 | mirrors: 64 | E4S: https://cache.e4s.io 65 | -------------------------------------------------------------------------------- /.github/ci/spack-envs/clang15_py311_nompi_h5_ad2/spack.yaml: -------------------------------------------------------------------------------- 1 | # This is a Spack environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development. 5 | # https//spack.readthedocs.io/en/latest/environments.html#anonymous-environments 6 | # 7 | spack: 8 | specs: 9 | - adios2 10 | - hdf5 11 | 12 | packages: 13 | hdf5: 14 | variants: ~mpi 15 | adios2: 16 | variants: ~mpi ~zfp ~sz ~png ~dataman ~python ~fortran ~ssc ~shared ~bzip2 ~mgard 17 | cmake: 18 | externals: 19 | - spec: cmake@3.22.1 20 | prefix: /usr 21 | buildable: False 22 | perl: 23 | externals: 24 | - spec: perl@5.34.0 25 | prefix: /usr 26 | buildable: False 27 | python: 28 | externals: 29 | - spec: python@3.11.0 30 | prefix: /usr 31 | buildable: False 32 | all: 33 | target: [x86_64] 34 | variants: ~fortran 35 | providers: 36 | mpi: [openmpi] 37 | compiler: [clang@15.0.7] 38 | 39 | compilers: 40 | - compiler: 41 | environment: {} 42 | extra_rpaths: [] 43 | flags: {} 44 | modules: [] 45 | operating_system: ubuntu22.04 46 | paths: 47 | cc: /usr/bin/clang-15 48 | cxx: /usr/bin/clang++-15 49 | f77: /usr/bin/gfortran 50 | fc: /usr/bin/gfortran 51 | spec: clang@15.0.7 52 | target: x86_64 53 | 54 | config: 55 | build_jobs: 2 56 | 57 | mirrors: 58 | E4S: https://cache.e4s.io 59 | -------------------------------------------------------------------------------- /.github/ci/spack-envs/clangtidy_nopy_ompi_h5_ad2/spack.yaml: -------------------------------------------------------------------------------- 1 | # This is a Spack environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development. 5 | # https//spack.readthedocs.io/en/latest/environments.html#anonymous-environments 6 | # 7 | spack: 8 | specs: 9 | - adios2@2.10 10 | - hdf5 11 | - openmpi 12 | 13 | packages: 14 | adios2: 15 | variants: ~zfp ~sz ~png ~dataman ~python ~fortran ~ssc ~shared ~bzip2 ~mgard 16 | c-blosc2: 17 | # snappy broken on CMake 4.0 18 | # fixed snappy not yet deployed to a Spack release 19 | variants: ~snappy 20 | cmake: 21 | externals: 22 | - spec: cmake@3.31.5 23 | prefix: /usr 24 | buildable: False 25 | openmpi: 26 | externals: 27 | - spec: openmpi@4.1.2 28 | prefix: /usr 29 | buildable: False 30 | perl: 31 | externals: 32 | - spec: perl@5.34.0 33 | prefix: /usr 34 | buildable: False 35 | python: 36 | externals: 37 | - spec: python@3.10.12 38 | prefix: /usr 39 | buildable: False 40 | all: 41 | target: [x86_64] 42 | variants: ~fortran 43 | providers: 44 | mpi: [openmpi] 45 | compiler: [clang@14.0.0] 46 | 47 | compilers: 48 | - compiler: 49 | environment: {} 50 | extra_rpaths: [] 51 | flags: {} 52 | modules: [] 53 | operating_system: ubuntu22.04 54 | paths: 55 | cc: /usr/bin/clang-14 56 | cxx: /usr/bin/clang++-14 57 | f77: /usr/bin/gfortran 58 | fc: /usr/bin/gfortran 59 | spec: clang@14.0.0 60 | target: x86_64 61 | 62 | config: 63 | build_jobs: 2 64 | 65 | mirrors: 66 | E4S: https://cache.e4s.io 67 | -------------------------------------------------------------------------------- /.github/ci/spack-envs/gcc12_py36_ompi_h5_ad2/spack.yaml: -------------------------------------------------------------------------------- 1 | # This is a Spack environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development. 5 | # https//spack.readthedocs.io/en/latest/environments.html#anonymous-environments 6 | # 7 | spack: 8 | specs: 9 | - adios2@2.10 10 | - hdf5 11 | - openmpi 12 | 13 | packages: 14 | adios2: 15 | # mgard not supported on CMake 4.0 due to unresolved compatibility 16 | # issue in dependency yaml-cpp 17 | # https://github.com/jbeder/yaml-cpp/issues/1352 18 | variants: ~zfp ~sz ~png ~dataman ~python ~fortran ~ssc ~shared ~bzip2 ~mgard 19 | c-blosc2: 20 | # snappy broken on CMake 4.0 21 | # fixed snappy not yet deployed to a Spack release 22 | variants: ~snappy 23 | cmake: 24 | externals: 25 | - spec: cmake@3.31.5 26 | prefix: /usr 27 | buildable: False 28 | openmpi: 29 | externals: 30 | - spec: openmpi@4.1.2 31 | prefix: /usr 32 | buildable: False 33 | perl: 34 | externals: 35 | - spec: perl@5.34.0 36 | prefix: /usr 37 | buildable: False 38 | python: 39 | externals: 40 | - spec: python@3.10.12 41 | prefix: /usr 42 | buildable: False 43 | all: 44 | target: [x86_64] 45 | variants: ~fortran 46 | compiler: [gcc@12.3.0] 47 | 48 | compilers: 49 | - compiler: 50 | environment: {} 51 | extra_rpaths: [] 52 | flags: {} 53 | modules: [] 54 | operating_system: ubuntu22.04 55 | paths: 56 | cc: /usr/bin/gcc-12 57 | cxx: /usr/bin/g++-12 58 | f77: /usr/bin/gfortran 59 | fc: /usr/bin/gfortran 60 | spec: gcc@12.3.0 61 | target: x86_64 62 | 63 | config: 64 | build_jobs: 2 65 | 66 | mirrors: 67 | E4S: https://cache.e4s.io 68 | -------------------------------------------------------------------------------- /.github/ci/spack-envs/gcc13_py312_mpich_h5_ad2/spack.yaml: -------------------------------------------------------------------------------- 1 | # This is a Spack environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development. 5 | # https//spack.readthedocs.io/en/latest/environments.html#anonymous-environments 6 | # 7 | spack: 8 | specs: 9 | - adios2@2.10 +mpi 10 | - hdf5 +mpi 11 | - mpich 12 | 13 | packages: 14 | adios2: 15 | variants: +mpi ~zfp ~sz ~png ~dataman ~python ~fortran ~ssc ~shared ~bzip2 ~blosc2 ~mgard 16 | cmake: 17 | externals: 18 | - spec: cmake@3.31.6 19 | prefix: /usr/local 20 | buildable: False 21 | hdf5: 22 | variants: +mpi 23 | mpich: 24 | externals: 25 | - spec: mpich@4.2.1 26 | prefix: /usr/local 27 | buildable: False 28 | perl: 29 | externals: 30 | - spec: perl@5.38.2 31 | prefix: /usr 32 | buildable: False 33 | python: 34 | externals: 35 | - spec: python@3.12.3 36 | prefix: /usr 37 | buildable: False 38 | all: 39 | target: [x86_64] 40 | variants: ~fortran 41 | providers: 42 | mpi: [mpich] 43 | compiler: [gcc@13.3.0] 44 | 45 | compilers: 46 | - compiler: 47 | environment: {} 48 | extra_rpaths: [] 49 | flags: {} 50 | modules: [] 51 | operating_system: ubuntu24.04 52 | paths: 53 | cc: /usr/bin/gcc 54 | cxx: /usr/bin/g++ 55 | f77: /usr/bin/gfortran 56 | fc: /usr/bin/gfortran 57 | spec: gcc@13.3.0 58 | target: x86_64 59 | 60 | config: 61 | build_jobs: 4 62 | 63 | mirrors: 64 | E4S: https://cache.e4s.io 65 | -------------------------------------------------------------------------------- /.github/ci/spack-envs/gcc_py_ompi_h5_ad2_arm64/spack.yaml: -------------------------------------------------------------------------------- 1 | # This is a Spack environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development. 5 | # https//spack.readthedocs.io/en/latest/environments.html#anonymous-environments 6 | # 7 | spack: 8 | specs: 9 | - adios2 10 | - hdf5 11 | - openmpi 12 | 13 | packages: 14 | adios2: 15 | variants: ~zfp ~sz ~png ~dataman ~python ~fortran ~ssc ~shared ~bzip2 16 | cmake: 17 | externals: 18 | - spec: cmake@3.22.1 19 | prefix: /usr 20 | buildable: False 21 | libfabric: 22 | externals: 23 | - spec: libfabric@1.11.0 24 | prefix: /usr 25 | buildable: False 26 | openmpi: 27 | externals: 28 | - spec: openmpi@4.1.2 29 | prefix: /usr 30 | buildable: False 31 | perl: 32 | externals: 33 | - spec: perl@5.34.0 34 | prefix: /usr 35 | buildable: False 36 | pkgconf: 37 | externals: 38 | - spec: pkgconf@1.8.0 39 | prefix: /usr 40 | buildable: False 41 | python: 42 | externals: 43 | - spec: python@3.11.5 44 | prefix: /usr 45 | buildable: False 46 | hdf5: 47 | externals: 48 | - spec: hdf5@1.10.7 49 | prefix: /usr 50 | buildable: False 51 | all: 52 | target: [aarch64] 53 | variants: ~fortran 54 | compiler: [gcc@11.4.0] 55 | 56 | compilers: 57 | - compiler: 58 | environment: {} 59 | extra_rpaths: [] 60 | flags: {} 61 | modules: [] 62 | operating_system: ubuntu22.04 63 | paths: 64 | cc: /usr/bin/gcc 65 | cxx: /usr/bin/g++ 66 | f77: /usr/bin/gfortran 67 | fc: /usr/bin/gfortran 68 | spec: gcc@11.4.0 69 | target: aarch64 70 | 71 | # arm.large with 4 vCPU cores 72 | # https://circleci.com/product/features/resource-classes/ 73 | # https://circleci.com/docs/using-arm/ 74 | config: 75 | build_jobs: 4 76 | 77 | # https://cache.spack.io 78 | mirrors: 79 | E4S: https://cache.e4s.io 80 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Reference: 2 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 3 | 4 | version: 2 5 | updates: 6 | # Maintain dependencies for GitHub Actions 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | ignore: 12 | # Official actions have moving tags like v1 13 | # that are used, so they don't need updates here 14 | - dependency-name: "actions/checkout" 15 | # - dependency-name: "actions/setup-python" 16 | - dependency-name: "actions/cache" 17 | # - dependency-name: "actions/upload-artifact" 18 | # - dependency-name: "actions/download-artifact" 19 | # - dependency-name: "actions/labeler" 20 | -------------------------------------------------------------------------------- /.github/workflows/clang-format/clang-format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if (( $# > 0 )); then 4 | # received arguments, format those files 5 | clang-format-20 -i "$@" 6 | else 7 | # received no arguments, find files on our own 8 | find include/ src/ test/ examples/ \ 9 | -regextype egrep \ 10 | -type f -regex '.*\.(hpp|cpp|hpp\.in)$' \ 11 | | xargs clang-format-20 -i 12 | fi 13 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: 🔍 CodeQL 2 | 3 | on: 4 | push: 5 | branches: [ "dev" ] 6 | pull_request: 7 | branches: [ "dev" ] 8 | schedule: 9 | - cron: "14 6 * * 6" 10 | 11 | concurrency: 12 | group: ${{ github.ref }}-${{ github.head_ref }}-codeql 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | analyze: 17 | name: Analyze 18 | runs-on: ubuntu-latest 19 | permissions: 20 | actions: read 21 | contents: read 22 | security-events: write 23 | 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | language: [ python, cpp ] 28 | 29 | steps: 30 | - name: Checkout 31 | uses: actions/checkout@v4 32 | 33 | - name: Install Packages 34 | run: | 35 | sudo apt-get update 36 | sudo apt-get install --yes cmake openmpi-bin libopenmpi-dev libhdf5-openmpi-dev 37 | 38 | python -m pip install --upgrade pip 39 | python -m pip install --upgrade wheel 40 | python -m pip install --upgrade cmake 41 | export CMAKE="$HOME/.local/bin/cmake" && echo "CMAKE=$CMAKE" >> $GITHUB_ENV 42 | python -m pip install --upgrade numpy 43 | python -m pip install --upgrade mpi4py 44 | python -m pip install --upgrade pytest 45 | 46 | - name: Configure (C++) 47 | if: ${{ matrix.language == 'cpp' }} 48 | run: $CMAKE -S . -B build 49 | 50 | - name: Initialize CodeQL 51 | uses: github/codeql-action/init@v3 52 | with: 53 | languages: ${{ matrix.language }} 54 | queries: +security-and-quality 55 | 56 | - name: Build (Py) 57 | uses: github/codeql-action/autobuild@v3 58 | if: ${{ matrix.language == 'python' }} 59 | 60 | - name: Build (C++) 61 | if: ${{ matrix.language == 'cpp' }} 62 | run: $CMAKE --build build -j 2 63 | 64 | - name: Perform CodeQL Analysis 65 | uses: github/codeql-action/analyze@v3 66 | with: 67 | category: "/language:${{ matrix.language }}" 68 | -------------------------------------------------------------------------------- /.github/workflows/dependencies/install_icc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | 4 | set -eu -o pipefail 5 | 6 | sudo apt-get -qqq update 7 | sudo apt-get install g++ 8 | # libopenmpi-dev 9 | sudo apt-get install -y wget build-essential pkg-config cmake ca-certificates gnupg 10 | 11 | # download the key to system keyring 12 | wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ 13 | | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null 14 | 15 | # add signed entry to apt sources and configure the APT client to use Intel repository 16 | echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list 17 | 18 | sudo apt-get update 19 | sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic 20 | # intel-oneapi-python 21 | -------------------------------------------------------------------------------- /.github/workflows/dependencies/install_icx: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | 4 | set -eu -o pipefail 5 | 6 | # Ref.: https://github.com/rscohn2/oneapi-ci 7 | # intel-basekit intel-hpckit are too large in size 8 | 9 | # download the key to system keyring 10 | wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ 11 | | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null 12 | 13 | # add signed entry to apt sources and configure the APT client to use Intel repository 14 | echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list 15 | 16 | sudo apt-get update 17 | 18 | sudo apt-get install -y --no-install-recommends \ 19 | build-essential \ 20 | cmake \ 21 | intel-oneapi-compiler-dpcpp-cpp intel-oneapi-mkl-devel \ 22 | g++ gfortran 23 | # libopenmpi-dev 24 | # openmpi-bin 25 | -------------------------------------------------------------------------------- /.github/workflows/dependencies/install_mpich: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | 4 | set -eu -o pipefail 5 | 6 | mpich_ver="4.3.0" 7 | 8 | cd /opt 9 | wget https://www.mpich.org/static/downloads/${mpich_ver}/mpich-${mpich_ver}.tar.gz 10 | tar -xzf mpich-${mpich_ver}.tar.gz 11 | cd mpich-${mpich_ver} 12 | ./configure --prefix=/usr/local 13 | make -j 4 14 | make -j 4 install 15 | cd .. 16 | rm -rf mpich-${mpich_ver} mpich-${mpich_ver}.tar.gz 17 | -------------------------------------------------------------------------------- /.github/workflows/dependencies/install_nvcc12.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | 4 | set -eu -o pipefail 5 | 6 | sudo apt-get -qqq update 7 | sudo apt-get install -y \ 8 | build-essential \ 9 | ca-certificates \ 10 | cmake \ 11 | g++ \ 12 | gfortran \ 13 | gnupg \ 14 | libhdf5-dev \ 15 | pkg-config \ 16 | wget 17 | 18 | sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub 19 | echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 /" \ 20 | | sudo tee /etc/apt/sources.list.d/cuda.list 21 | sudo apt-get update 22 | apt search cuda-compiler 23 | sudo apt-get install -y \ 24 | cuda-command-line-tools-12-8 \ 25 | cuda-compiler-12-8 \ 26 | cuda-cupti-dev-12-8 \ 27 | cuda-minimal-build-12-8 28 | 29 | sudo ln -s cuda-11.2 /usr/local/cuda 30 | -------------------------------------------------------------------------------- /.github/workflows/dependencies/install_nvhpc25-1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | 4 | set -eu -o pipefail 5 | 6 | sudo apt-get -qqq update 7 | sudo apt-get install -y \ 8 | build-essential \ 9 | ca-certificates \ 10 | cmake \ 11 | environment-modules \ 12 | gnupg \ 13 | libhdf5-dev \ 14 | pkg-config \ 15 | wget 16 | 17 | echo 'deb [trusted=yes] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | \ 18 | sudo tee /etc/apt/sources.list.d/nvhpc.list 19 | sudo apt-get update -y 20 | sudo apt-get install -y --no-install-recommends nvhpc-25-1 21 | 22 | # things should reside in /opt/nvidia/hpc_sdk now 23 | 24 | # activation via: 25 | # source /etc/profile.d/modules.sh 26 | # module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/21.11 27 | -------------------------------------------------------------------------------- /.github/workflows/dependencies/install_spack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | 4 | set -eu -o pipefail 5 | 6 | spack_ver="0.22.3" 7 | 8 | cd /opt 9 | if [[ -d spack && ! -f spack_${spack_ver} ]] 10 | then 11 | rm -rf spack /usr/bin/spack $HOME/.spack/ 12 | fi 13 | if [ ! -d spack ] 14 | then 15 | # download 16 | curl -sOL https://github.com/spack/spack/archive/refs/tags/v${spack_ver}.tar.gz 17 | tar -xf v${spack_ver}.tar.gz && rm v${spack_ver}.tar.gz 18 | mv spack-${spack_ver} spack 19 | touch spack_${spack_ver} 20 | fi 21 | 22 | # install 23 | ln -s /opt/spack/bin/spack /usr/bin/spack 24 | 25 | # add binary mirror 26 | #spack mirror add E4S https://cache.e4s.io 27 | #spack buildcache keys -it 28 | 29 | # find compilers & external packages 30 | #spack compiler find 31 | #spack external find 32 | 33 | # accessible by regular CI user 34 | chmod a+rwx -R /opt/spack 35 | #chmod a+rwx -R $HOME/.spack/ 36 | -------------------------------------------------------------------------------- /.github/workflows/intel.yml: -------------------------------------------------------------------------------- 1 | name: 🐧 Intel 2 | 3 | on: [push, pull_request] 4 | 5 | concurrency: 6 | group: ${{ github.ref }}-${{ github.head_ref }}-intel 7 | cancel-in-progress: true 8 | 9 | jobs: 10 | icx_cxxonly: 11 | name: ICX C++ only 12 | runs-on: ubuntu-22.04 13 | if: github.event.pull_request.draft == false 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Install 17 | run: | 18 | sudo .github/workflows/dependencies/install_icx 19 | - name: Build 20 | env: {CXXFLAGS: -Werror} 21 | run: | 22 | set +e; source /opt/intel/oneapi/setvars.sh; set -e 23 | share/openPMD/download_samples.sh build 24 | cmake -S . -B build \ 25 | -DCMAKE_C_COMPILER=$(which icx) \ 26 | -DCMAKE_CXX_COMPILER=$(which icpx) \ 27 | -DopenPMD_USE_PYTHON=OFF \ 28 | -DopenPMD_USE_MPI=OFF 29 | cmake --build build --parallel 2 30 | ctest --test-dir build --output-on-failure 31 | -------------------------------------------------------------------------------- /.github/workflows/source.yml: -------------------------------------------------------------------------------- 1 | name: 📜 Source 2 | 3 | on: [push, pull_request] 4 | 5 | concurrency: 6 | group: ${{ github.ref }}-${{ github.head_ref }}-source 7 | cancel-in-progress: true 8 | 9 | jobs: 10 | style: 11 | runs-on: ubuntu-22.04 12 | steps: 13 | - uses: actions/checkout@v4 14 | - name: Non-ASCII Characters 15 | run: .github/workflows/source/hasNonASCII 16 | - name: TABs 17 | run: .github/workflows/source/hasTabs 18 | - name: End-of-Line whitespaces 19 | run: .github/workflows/source/hasEOLwhiteSpace 20 | - name: PEP8 21 | run: | 22 | python3 -m pip install -U flake8 23 | python3 -m flake8 --exclude=thirdParty . 24 | 25 | static-analysis: 26 | runs-on: ubuntu-22.04 27 | if: github.event.pull_request.draft == false 28 | steps: 29 | - uses: actions/checkout@v4 30 | - name: pyflakes 31 | run: | 32 | python3 -m pip install -U pyflakes 33 | python3 -m pyflakes docs/ examples/ test/ setup.py 34 | 35 | documentation: 36 | runs-on: ubuntu-22.04 37 | steps: 38 | - uses: actions/checkout@v4 39 | - uses: conda-incubator/setup-miniconda@v3 40 | name: Setup conda 41 | with: 42 | auto-update-conda: true 43 | channels: conda-forge,defaults 44 | channel-priority: true 45 | - name: Install 46 | run: conda install -c conda-forge doxygen=1.9.6 47 | - name: Doxygen 48 | run: | 49 | source /usr/share/miniconda/bin/activate 50 | .github/workflows/source/buildDoxygen 51 | 52 | urls: 53 | runs-on: ubuntu-latest 54 | if: github.event.pull_request.draft == false 55 | steps: 56 | - uses: actions/checkout@v4 57 | - name: urls-checker 58 | uses: urlstechie/urlchecker-action@master 59 | with: 60 | # A comma-separated list of file types to cover in the URL checks 61 | file_types: .md,.py,.rst,.hpp,.cpp 62 | # Choose whether to include file with no URLs in the prints. 63 | print_all: false 64 | # The timeout seconds to provide to requests, defaults to 5 seconds 65 | timeout: 5 66 | # How many times to retry a failed request (each is logged, defaults to 1) 67 | retry_count: 3 68 | # A comma separated links to exclude during URL checks 69 | #exclude_urls: url1,url2 70 | # A comma separated patterns to exclude during URL checks 71 | #exclude_patterns: url1,url2 72 | # choose if the force pass or not 73 | force_pass : true 74 | -------------------------------------------------------------------------------- /.github/workflows/source/buildDoxygen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright 2020-2021 Axel Huebl 4 | # 5 | # License: LGPLv3+ 6 | 7 | # search recursive inside a folder if a file contains tabs 8 | # 9 | # @result 0 if no files are found, else 1 10 | # 11 | 12 | set -eu -o pipefail 13 | 14 | cd docs 15 | 16 | # treat all warnings as errors 17 | echo "WARN_AS_ERROR = YES" >> Doxyfile 18 | 19 | doxygen 20 | -------------------------------------------------------------------------------- /.github/workflows/source/hasEOLwhiteSpace: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright 2016-2021 Axel Huebl 4 | # 5 | # License: LGPLv3+ 6 | 7 | # search recursive inside a folder if a file contains end-of-line 8 | # (EOL) white spaces 9 | # 10 | # @result 0 if no files are found, else 1 11 | # 12 | # note: .md files can contain EOL white spaces for syntax reasons 13 | # (newline without starting a new paragraph) 14 | 15 | ok=0 16 | files=() 17 | 18 | pattern="\.c$|\.cpp$|\.F90$|\.h$|\.H$|\.ini$|\.py$|"\ 19 | "\.rst$|\.sh$|\.tex$|\.txt$|\.xml$|\.yml$|"\ 20 | "CMakeLists\.txt|inputs" 21 | 22 | for i in $(find . \ 23 | -not -path "./.git/*" \ 24 | -not -path "./.spack-env/*" \ 25 | -not -path "./.idea/*" \ 26 | -type f | \ 27 | grep -P "${pattern}") 28 | do 29 | grep -q "[[:blank:]]\+$" $i 30 | if [ $? -eq 0 ] 31 | then 32 | files+=($i) 33 | echo "# $i contains EOL white spaces!" 34 | ok=1 35 | fi 36 | done 37 | 38 | if [ $ok -ne 0 ] 39 | then 40 | echo "#" 41 | echo "# SUMMARY" 42 | echo "# -------" 43 | echo "# Run the following command(s) on the above files to remove your" 44 | echo "# end-of-line (EOL) white spaces:" 45 | echo "" 46 | echo "GNU_SED=\$(sed --help >/dev/null 2>&1 && { echo 1; } || { echo 0; })" 47 | echo "[[ \${GNU_SED} -eq 1 ]] && REPLACE=\"sed -i 's/[[:blank:]]\+$//'\" || REPLACE=\"sed -i '' -E 's/[[:blank:]]+$//'\"" 48 | for i in ${files[@]} 49 | do 50 | echo "eval \${REPLACE} $i" 51 | done 52 | fi 53 | 54 | exit $ok 55 | -------------------------------------------------------------------------------- /.github/workflows/source/hasNonASCII: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright 2016-2021 Axel Huebl 4 | # 5 | # License: LGPLv3+ 6 | 7 | # Search recursive inside a folder if a shell scripts or batch system files 8 | # contains non-ASCII characters. This causes problems with some systems. 9 | # We can also not guarantee that everyone has UTF8 locales installed, so 10 | # why depend on it. 11 | # 12 | # @result 0 if no files are found, else 1 13 | # 14 | 15 | ok=0 16 | 17 | pattern="\.c$|\.cpp$|\.F90$|\.h$|\.H$|\.ini$|\.py$|"\ 18 | "\.rst$|\.sh$|\.tex$|\.txt$|\.xml$|\.yml$|\.yaml$|"\ 19 | "CMakeLists\.txt|inputs" 20 | 21 | for i in $(find . \ 22 | -not -path "./.git/*" \ 23 | -not -path "./.spack-env/*" \ 24 | -not -path "./share/openPMD/thirdParty/*" \ 25 | -type f | \ 26 | grep -P "${pattern}") 27 | do 28 | # non-ASCII test regex via jerrymouse at stackoverflow under CC-By-SA 3.0: 29 | # http://stackoverflow.com/questions/3001177/how-do-i-grep-for-all-non-ascii-characters-in-unix/9395552#9395552 30 | result=$(grep --color='always' -P -n "[\x80-\xFF]" $i) 31 | 32 | if [ $? -eq 0 ] 33 | then 34 | echo "$i contains non-ASCII characters!" 35 | echo "$result" 36 | ok=1 37 | fi 38 | done 39 | 40 | exit $ok 41 | -------------------------------------------------------------------------------- /.github/workflows/source/hasTabs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright 2016-2021 Axel Huebl 4 | # 5 | # License: LGPLv3+ 6 | 7 | # search recursive inside a folder if a file contains tabs 8 | # 9 | # @result 0 if no files are found, else 1 10 | # 11 | 12 | ok=0 13 | files=() 14 | 15 | pattern="\.c$|\.cpp$|\.F90$|\.h$|\.H$|\.ini$|\.md$|\.py$|"\ 16 | "\.rst$|\.sh$|\.tex$|\.txt$|\.xml$|\.yml$|"\ 17 | "CMakeLists\.txt|inputs" 18 | 19 | for i in $(find . \ 20 | -not -path "./.git/*" \ 21 | -not -path "./.spack-env/*" \ 22 | -not -path "./.idea/*" \ 23 | -not -path "*wp_parse*" \ 24 | -type f | \ 25 | grep -P "${pattern}") 26 | do 27 | grep -q -P "\t" $i 28 | if [ $? -eq 0 ] 29 | then 30 | files+=($i) 31 | echo "# $i contains TABs instead of spaces!" 32 | ok=1 33 | fi 34 | done 35 | 36 | if [ $ok -ne 0 ] 37 | then 38 | echo "#" 39 | echo "# SUMMARY" 40 | echo "# -------" 41 | echo "# Run the following command(s) on the above files to replace your TABs" 42 | echo "# with four white spaces:" 43 | echo "" 44 | echo "GNU_SED=\$(sed --help >/dev/null 2>&1 && { echo 1; } || { echo 0; })" 45 | echo "[[ \${GNU_SED} -eq 1 ]] && REPLACE=\"sed -i 's/\t/\ \ \ \ /g'\" || REPLACE=\"sed -i '' -E 's/\$(printf '\t')/\ \ \ \ /g'\"" 46 | for i in ${files[@]} 47 | do 48 | echo "eval \"\${REPLACE}\" $i" 49 | done 50 | fi 51 | 52 | exit $ok 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ####### 2 | # C++ # 3 | ####### 4 | # Prerequisites 5 | *.d 6 | 7 | # Compiled Object files 8 | *.slo 9 | *.lo 10 | *.o 11 | *.obj 12 | 13 | # Precompiled Headers 14 | *.gch 15 | *.pch 16 | 17 | # Compiled Dynamic libraries 18 | *.so 19 | *.dylib 20 | *.dll 21 | 22 | # Fortran module files 23 | *.mod 24 | *.smod 25 | 26 | # Compiled Static libraries 27 | *.lai 28 | *.la 29 | *.a 30 | *.lib 31 | 32 | # Executables 33 | *.exe 34 | *.out 35 | *.app 36 | 37 | ########## 38 | # Python # 39 | ########## 40 | *.pyc 41 | __pycache__ 42 | 43 | ####### 44 | # IDE # 45 | ####### 46 | /*.cbp 47 | /*.layout 48 | .idea/ 49 | .kdev?/ 50 | *.kdev? 51 | /nbproject/ 52 | .vimrc 53 | cmake-build-*/ 54 | spack-build* 55 | build/ 56 | 57 | # File-based project format: 58 | *.iws 59 | 60 | ###### 61 | # OS # 62 | ###### 63 | .DS_Store 64 | .AppleDouble 65 | .LSOverride 66 | 67 | # Icon must end with two \r 68 | Icon 69 | 70 | # Thumbnails 71 | ._* 72 | 73 | # temporary files / backup 74 | *~ 75 | 76 | # Files that might appear in the root of a volume 77 | .DocumentRevisions-V100 78 | .fseventsd 79 | .Spotlight-V100 80 | .TemporaryItems 81 | .Trashes 82 | .VolumeIcon.icns 83 | 84 | # Directories potentially created on remote AFP share 85 | .AppleDB 86 | .AppleDesktop 87 | Network Trash Folder 88 | Temporary Items 89 | .apdisk 90 | 91 | #################### 92 | # Package Managers # 93 | #################### 94 | # anonymous Spack environments 95 | # https://spack.readthedocs.io/en/latest/environments.html#anonymous-environments 96 | .spack-env/ 97 | spack.lock 98 | 99 | ######### 100 | # CMake # 101 | ######### 102 | CMakeUserPresets.json 103 | 104 | ######### 105 | # Tools # 106 | ######### 107 | .stfolder 108 | 109 | ########### 110 | # Doxygen # 111 | ########### 112 | docs/doxyhtml/ 113 | docs/doxyxml/ 114 | docs/html/ 115 | docs/xml/ 116 | docs/doxygen_sqlite3.db 117 | docs/openpmd-api-doxygen-web.tag.xml 118 | 119 | #################### 120 | # Sphinx & Breathe # 121 | #################### 122 | docs/build/ 123 | docs/source/_static/doxyhtml/ 124 | 125 | ################ 126 | # Sample files # 127 | ################ 128 | samples/ 129 | 130 | ################ 131 | # Binaries # 132 | ################ 133 | bin/ 134 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | python: 4 | install: 5 | - requirements: docs/requirements.txt 6 | 7 | sphinx: 8 | configuration: docs/source/conf.py 9 | 10 | formats: 11 | - htmlzip 12 | - pdf 13 | - epub 14 | 15 | build: 16 | os: ubuntu-22.04 17 | tools: 18 | python: "3.11" 19 | apt_packages: 20 | - librsvg2-bin 21 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.1.0 2 | message: "If you use this software, please cite it as below." 3 | authors: 4 | - family-names: Huebl 5 | given-names: Axel 6 | affiliation: Lawrence Berkeley National Laboratory (LBNL) 7 | orcid: https://orcid.org/0000-0003-1943-7141 8 | email: axelhuebl@lbl.gov 9 | - family-names: Poeschel 10 | affiliation: Center for Advanced Systems Understanding (CASUS) 11 | given-names: Franz 12 | orcid: https://orcid.org/0000-0001-7042-5088 13 | - family-names: Koller 14 | given-names: Fabian 15 | affiliation: Helmholtz-Zentrum Dresden-Rossendorf (HZDR) 16 | orcid: https://orcid.org/0000-0001-8704-1769 17 | - family-names: Gu 18 | given-names: Junmin 19 | affiliation: Lawrence Berkeley National Laboratory (LBNL) 20 | orcid: https://orcid.org/0000-0002-1521-8534 21 | - family-names: Bussmann 22 | given-names: Michael 23 | affiliation: Center for Advanced Systems Understanding (CASUS) and Helmholtz-Zentrum Dresden-Rossendorf (HZDR) 24 | orcid: https://orcid.org/0000-0002-8258-3881 25 | - family-names: Vay 26 | given-names: Jean-Luc 27 | affiliation: Lawrence Berkeley National Laboratory (LBNL) 28 | orcid: https://orcid.org/0000-0002-0040-799X 29 | - family-names: Wu 30 | given-names: Kesheng (John) 31 | affiliation: Lawrence Berkeley National Laboratory (LBNL) 32 | orcid: https://orcid.org/0000-0002-6907-3393 33 | contact: 34 | - family-names: Huebl 35 | given-names: Axel 36 | affiliation: Lawrence Berkeley National Laboratory (LBNL) 37 | orcid: https://orcid.org/0000-0003-1943-7141 38 | email: axelhuebl@lbl.gov 39 | title: "openPMD-api: C++ & Python API for Scientific I/O with openPMD" 40 | version: 0.17.0-dev 41 | repository-code: https://github.com/openPMD/openPMD-api 42 | doi: 10.14278/rodare.27 43 | license: LGPL-3.0-or-later 44 | date-released: 2018-06-07 45 | keywords: 46 | - research 47 | - hpc 48 | - opendata 49 | - cpp14 50 | - mpi 51 | - python3 52 | - hdf5 53 | - file-handling 54 | - openscience 55 | - meta-data 56 | - adios 57 | - openpmd 58 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | .. _development-contributing: 2 | 3 | Contribution Guide 4 | ================== 5 | 6 | GitHub 7 | ------ 8 | 9 | The best starting point is the `GitHub issue tracker `_. 10 | 11 | For existing tasks, the labels `good first issue `_ and `help wanted `_ are great for contributions. 12 | In case you want to start working on one of those, just *comment* in it first so no work is duplicated. 13 | 14 | New contributions in form of `pull requests `_ always need to go in the ``dev`` (development) branch. 15 | 16 | Maintainers organize prioritites and progress in the `projects tab `_. 17 | 18 | Style Guide 19 | ----------- 20 | 21 | For coding style, please try to follow the guides in `ComputationalRadiationPhysics/contributing `_ for new code. 22 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md COPYING COPYING.LESSER 2 | include pyproject.toml 3 | include requirements.txt 4 | global-include CMakeLists.txt *.cmake *.in 5 | recursive-include cmake * 6 | recursive-include include * 7 | recursive-include src * 8 | recursive-include share * 9 | recursive-include test * 10 | recursive-include examples * 11 | -------------------------------------------------------------------------------- /Singularity: -------------------------------------------------------------------------------- 1 | Bootstrap: docker 2 | From: debian:unstable 3 | #From: debian:testing 4 | #From: ubuntu:cosmic 5 | 6 | %help 7 | Welcome to the openPMD-api container. 8 | This container contains a pre-installed openPMD-api library. 9 | This container provides serial I/O. 10 | Supported backends are HDF5 and ADIOS2. 11 | Supported frontends are C++11 and Python3. 12 | 13 | %setup 14 | mkdir -p ${SINGULARITY_ROOTFS}/opt/openpmd-api 15 | 16 | %files 17 | ./* /opt/openpmd-api 18 | 19 | %post 20 | apt-get update && \ 21 | apt-get install -y --no-install-recommends \ 22 | cmake \ 23 | make \ 24 | g++ \ 25 | ipython3 \ 26 | python3-dev \ 27 | pybind11-dev \ 28 | libglib2.0-dev libbz2-dev libibverbs-dev libnetcdf-dev \ 29 | libhdf5-dev && \ 30 | rm -rf /var/lib/apt/lists/* 31 | 32 | # python3-numpy 33 | 34 | # missing: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900804 35 | # libopenmpi-dev libhdf5-openmpi-dev 36 | 37 | cd $(mktemp -d) 38 | cmake /opt/openpmd-api \ 39 | -DopenPMD_USE_MPI=OFF \ 40 | -DopenPMD_USE_HDF5=ON \ 41 | -DopenPMD_USE_ADIOS2=OFF \ 42 | -DopenPMD_USE_PYTHON=ON \ 43 | -DopenPMD_BUILD_TESTING=OFF \ 44 | -DCMAKE_INSTALL_PREFIX=/usr/local \ 45 | -DCMAKE_INSTALL_PYTHONDIR=lib/python3.6/dist-packages 46 | make 47 | # make test 48 | make install 49 | 50 | #%test 51 | # make test 52 | 53 | %runscript 54 | ipython3 55 | 56 | %labels 57 | openPMD_HAVE_MPI OFF 58 | openPMD_HAVE_HDF5 ON 59 | openPMD_HAVE_ADIOS2 OFF 60 | openPMD_HAVE_PYTHON ON 61 | -------------------------------------------------------------------------------- /cmake/openPMDFunctions.cmake: -------------------------------------------------------------------------------- 1 | # Prints a summary of openPMD-api options at the end of the CMake configuration 2 | # 3 | function(openpmd_print_summary) 4 | message("") 5 | message("openPMD build configuration:") 6 | message(" library Version: ${openPMD_VERSION}") 7 | message(" openPMD Standard: ${openPMD_STANDARD_VERSION}") 8 | message(" C++ Compiler: ${CMAKE_CXX_COMPILER_ID} " 9 | "${CMAKE_CXX_COMPILER_VERSION} " 10 | "${CMAKE_CXX_COMPILER_WRAPPER}") 11 | message(" ${CMAKE_CXX_COMPILER}") 12 | message("") 13 | if(openPMD_INSTALL) 14 | message(" Install with RPATHs: ${openPMD_INSTALL_RPATH}") 15 | message(" Installation prefix: ${openPMD_INSTALL_PREFIX}") 16 | message(" bin: ${openPMD_INSTALL_BINDIR}") 17 | message(" lib: ${openPMD_INSTALL_LIBDIR}") 18 | message(" include: ${openPMD_INSTALL_INCLUDEDIR}") 19 | message(" cmake: ${openPMD_INSTALL_CMAKEDIR}") 20 | if(openPMD_HAVE_PYTHON) 21 | message(" python: ${openPMD_INSTALL_PYTHONDIR}") 22 | endif() 23 | else() 24 | message(" Installation: OFF") 25 | endif() 26 | message("") 27 | message(" Build Type: ${CMAKE_BUILD_TYPE}") 28 | if(openPMD_BUILD_SHARED_LIBS) 29 | message(" Library: shared") 30 | else() 31 | message(" Library: static") 32 | endif() 33 | message(" CLI Tools: ${openPMD_BUILD_CLI_TOOLS}") 34 | message(" Examples: ${openPMD_BUILD_EXAMPLES}") 35 | message(" Testing: ${openPMD_BUILD_TESTING}") 36 | message(" Invasive Tests: ${openPMD_USE_INVASIVE_TESTS}") 37 | message(" Internal VERIFY: ${openPMD_USE_VERIFY}") 38 | message(" Build Options:") 39 | 40 | foreach(opt IN LISTS openPMD_CONFIG_OPTIONS) 41 | if(${openPMD_HAVE_${opt}}) 42 | message(" ${opt}: ON") 43 | else() 44 | message(" ${opt}: OFF") 45 | endif() 46 | endforeach() 47 | message("") 48 | endfunction() 49 | -------------------------------------------------------------------------------- /conda.yml: -------------------------------------------------------------------------------- 1 | # This is a Conda environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development: 5 | # - conda env create --file conda.yml 6 | # - conda activate openpmd-api-dev 7 | # 8 | # If you need more packages in that environment, e.g. jupyter, run: 9 | # - mamba install -y -c conda-forge jupyter jupyterlab dask-labextension 10 | # 11 | 12 | name: openpmd-api-dev 13 | channels: 14 | - conda-forge 15 | dependencies: 16 | - adios=*=mpi_openmpi_* 17 | - adios2=*=mpi_openmpi_* 18 | # - catch2 # shipped internally 19 | - ccache 20 | - curl 21 | - cmake 22 | - compilers 23 | - dask 24 | - doxygen 25 | - git 26 | - hdf5=*=mpi_openmpi_* 27 | - mamba 28 | - make 29 | - mpi4py 30 | - ninja 31 | - numpy 32 | - openmpi 33 | - pandas 34 | - pkg-config 35 | - pip 36 | - pre-commit 37 | - pyarrow # for dask 38 | # - pybind11 # shipped internally 39 | - python>=3.8 40 | 41 | # just a note for later hackery, we could install pip packages inside the env, too: 42 | # - pip: 43 | # - "-r requirements.txt" 44 | -------------------------------------------------------------------------------- /docs/Doxyfile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME = "openPMD-api" 2 | XML_OUTPUT = xml 3 | INPUT = ../src ../include ../README.md 4 | 5 | # TAGFILES += "cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/" 6 | BUILTIN_STL_SUPPORT = YES 7 | 8 | GENERATE_LATEX = NO 9 | GENERATE_MAN = NO 10 | GENERATE_RTF = NO 11 | CASE_SENSE_NAMES = NO 12 | HTML_OUTPUT = doxyhtml 13 | GENERATE_HTML = YES 14 | GENERATE_XML = YES 15 | GENERATE_TAGFILE = openpmd-api-doxygen-web.tag.xml 16 | RECURSIVE = YES 17 | #QUIET = YES 18 | JAVADOC_AUTOBRIEF = YES 19 | USE_MDFILE_AS_MAINPAGE = README.md 20 | 21 | # "enable" all frontends and backends 22 | MACRO_EXPANSION = YES 23 | PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ 24 | openPMD_HAVE_MPI=1 \ 25 | openPMD_HAVE_HDF5=1 \ 26 | openPMD_HAVE_ADIOS2=1 \ 27 | openPMD_HAVE_PYTHON=1 \ 28 | OPENPMD_private:=private \ 29 | OPENPMD_protected:=protected \ 30 | __attribute__(x)= \ 31 | __declspec(x)= 32 | 33 | # ideally, you want to warn on missing doc coverage! 34 | WARN_IF_UNDOCUMENTED = NO 35 | WARN_NO_PARAMDOC = NO 36 | # the ideal CI enforcing world: WARN_AS_ERROR = YES 37 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = openPMD-api 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | clean: 18 | $(SILENT) $(RM) -r xml/ doxyhtml/ build/ openpmd-api-doxygen-web.tag.xml 19 | 20 | # Catch-all target: route all unknown targets to Sphinx using the new 21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 22 | %: Makefile 23 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 24 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | breathe 2 | docutils>=0.17.1 3 | # generate plots 4 | matplotlib 5 | numpy>=1.15 6 | pygments 7 | recommonmark 8 | scipy 9 | sphinx>=5.3,<7.2 10 | sphinx-copybutton 11 | sphinx-design 12 | sphinx_rtd_theme>=1.1.1 13 | sphinxcontrib-googleanalytics 14 | sphinxcontrib-svg2pdfconverter 15 | sphinxcontrib.programoutput 16 | -------------------------------------------------------------------------------- /docs/source/analysis/contrib.rst: -------------------------------------------------------------------------------- 1 | .. _analysis-contrib: 2 | 3 | Contributed 4 | =========== 5 | 6 | This page contains contributed projects and third party integrations to analyze openPMD data. 7 | See the `openPMD-projects `__ catalog for more community integrations. 8 | 9 | 10 | .. _analysis-contrib-visualpic: 11 | 12 | 3D Visualization: VisualPIC 13 | --------------------------- 14 | 15 | openPMD data can be visualized with the domain-specific VisualPIC renderer. 16 | Please see `the WarpX page for details `__. 17 | 18 | 19 | .. _analysis-contrib-visit: 20 | 21 | 3D Visualization: VisIt 22 | ----------------------- 23 | 24 | openPMD **HDF5** data can be visualized with VisIt 3.1.0+. 25 | VisIt supports openPMD HDF5 files and requires to rename the files from ``.h5`` to ``.opmd`` to be automatically detected. 26 | 27 | 28 | .. _analysis-contrib-yt: 29 | 30 | yt-project 31 | ---------- 32 | 33 | openPMD **HDF5** data can be visualized with `yt-project `__. 34 | Please see the `yt documentation `__ for details. 35 | -------------------------------------------------------------------------------- /docs/source/analysis/dask.rst: -------------------------------------------------------------------------------- 1 | .. _analysis-dask: 2 | 3 | DASK 4 | ==== 5 | 6 | The Python bindings of openPMD-api provide direct methods to load data into the parallel, `DASK data analysis ecosystem `__. 7 | 8 | 9 | How to Install 10 | -------------- 11 | 12 | Among many package managers, `PyPI `__ ships the latest packages of DASK: 13 | 14 | .. code-block:: python 15 | 16 | python3 -m pip install -U dask 17 | python3 -m pip install -U pyarrow 18 | 19 | 20 | How to Use 21 | ---------- 22 | 23 | The central Python API calls to convert to DASK datatypes are the ``ParticleSpecies.to_dask`` and ``Record_Component.to_dask_array`` methods. 24 | 25 | .. code-block:: python 26 | 27 | s = io.Series("samples/git-sample/data%T.h5", io.Access.read_only) 28 | electrons = s.iterations[400].particles["electrons"] 29 | 30 | # the default schedulers are local/threaded. We can also use local 31 | # "processes" or for multi-node "distributed", among others. 32 | dask.config.set(scheduler='processes') 33 | 34 | df = electrons.to_dask() 35 | type(df) # ... 36 | 37 | E = s.iterations[400].meshes["E"] 38 | E_x = E["x"] 39 | darr_x = E_x.to_dask_array() 40 | type(darr_x) # ... 41 | 42 | # note: no series.flush() needed 43 | 44 | The ``to_dask_array`` method will automatically set Dask array chunking based on the available chunks in the read data set. 45 | The default behavior can be overridden by passing an additional keyword argument ``chunks``, see the `dask.array.from_array documentation `__ for more details. 46 | For example, to chunk only along the outermost axis in a 3D dataset using the default Dask array chunk size, call ``to_dask_array(chunks={0: 'auto', 1: -1, 2: -1})``. 47 | 48 | Example 49 | ------- 50 | 51 | A detailed example script for particle and field analysis is documented under as ``11_particle_dataframe.py`` in our :ref:`examples `. 52 | 53 | See a video of openPMD on DASK in action in `pull request #963 `__ (part of openPMD-api v0.14.0 and later). 54 | -------------------------------------------------------------------------------- /docs/source/analysis/paraview.rst: -------------------------------------------------------------------------------- 1 | .. _analysis-paraview: 2 | 3 | 3D Visualization: ParaView 4 | ========================== 5 | 6 | openPMD data can be visualized by ParaView, an open source visualization and analysis software. 7 | ParaView can be downloaded and installed from httpshttps://www.paraview.org. 8 | Use the latest version for best results. 9 | 10 | Tutorials 11 | --------- 12 | 13 | ParaView is a powerful, general parallel rendering program. 14 | If this is your first time using ParaView, consider starting with a tutorial. 15 | 16 | * https://www.paraview.org/Wiki/The_ParaView_Tutorial 17 | * https://www.youtube.com/results?search_query=paraview+introduction 18 | * https://www.youtube.com/results?search_query=paraview+tutorial 19 | 20 | 21 | openPMD 22 | ------- 23 | 24 | openPMD files can be visualized with ParaView 5.9+, using 5.11+ is recommended. 25 | ParaView supports ADIOS2 and HDF5 files, as it implements against the Python bindings of openPMD-api. 26 | 27 | For openPMD output to be recognized, create a small textfile with ``.pmd`` ending per data series, which can be opened with ParaView: 28 | 29 | .. code-block:: console 30 | 31 | $ cat paraview.pmd 32 | openpmd_%06T.bp 33 | 34 | The file contains the same string as one would put in an openPMD ``Series("....")`` object. 35 | 36 | .. tip:: 37 | 38 | When you first open ParaView, adjust its global ``Settings`` (Linux: under menu item ``Edit``). 39 | ``General`` -> ``Advanced`` -> Search for ``data`` -> ``Data Processing Options``. 40 | Check the box ``Auto Convert Properties``. 41 | 42 | This will simplify application of filters, e.g., contouring of components of vector fields, without first adding a calculator that extracts a single component or magnitude. 43 | 44 | .. warning:: 45 | 46 | As of ParaView 5.11 and older, the axisLabel is not yet read for fields. 47 | See, e.g., `WarpX issue 21162 `__. 48 | Please apply rotation of, e.g., ``0 -90 0`` to mesh data where needed. 49 | 50 | .. warning:: 51 | 52 | `ParaView issue 21837 `__: 53 | In order to visualize particle traces with the ``Temporal Particles To Pathlines``, you need to apply the ``Merge Blocks`` filter first. 54 | 55 | If you have multiple species, you may have to extract the species you want with ``Extract Block`` before applying ``Merge Blocks``. 56 | -------------------------------------------------------------------------------- /docs/source/analysis/viewer.rst: -------------------------------------------------------------------------------- 1 | .. _analysis-viewer: 2 | 3 | openPMD-viewer 4 | ============== 5 | 6 | `openPMD-viewer `__ (`documentation `__) is a Python package to access openPMD data. 7 | 8 | It allows to: 9 | 10 | * Quickly browse through the data, with a GUI-type interface in the Jupyter notebook 11 | * Have access to the data numpy array, for more detailed analysis 12 | 13 | Installation 14 | ------------ 15 | 16 | openPMD-viewer can be installed via ``conda`` or ``pip``: 17 | 18 | .. code-block:: bash 19 | 20 | conda install -c conda-forge openpmd-viewer openpmd-api 21 | 22 | .. code-block:: bash 23 | 24 | python3 -m pip install openPMD-viewer openPMD-api 25 | 26 | Usage 27 | ----- 28 | 29 | openPMD-viewer can be used either in simple Python scripts or in `Jupyter `__. 30 | For interactive plots in Jupyter lab, add this `"cell magic" `__ to the first line of your notebook: 31 | 32 | .. code-block:: python 33 | 34 | %matplotlib widget 35 | 36 | and for Jupyter notebook use this instead: 37 | 38 | .. code-block:: python 39 | 40 | %matplotlib notebook 41 | 42 | If none of those work, e.g. because `ipympl `__ is not properly installed, you can as a last resort always try ``%matplotlib inline`` for non-interactive plots. 43 | 44 | In both interactive and scripted usage, you can import openPMD-viewer, and load the data with the following commands: 45 | 46 | .. code-block:: python 47 | 48 | from openpmd_viewer import OpenPMDTimeSeries 49 | ts = OpenPMDTimeSeries('path/to/data/series/') 50 | 51 | .. note:: 52 | 53 | If you are using the Jupyter notebook, then you can start a pre-filled 54 | notebook, which already contains the above lines, by typing in a terminal: 55 | 56 | :: 57 | 58 | openPMD_notebook 59 | 60 | When using the Jupyter notebook, you can quickly browse through the data 61 | by using the command: 62 | 63 | :: 64 | 65 | ts.slider() 66 | 67 | You can also access the particle and field data as numpy arrays with the methods ``ts.get_field`` and ``ts.get_particle``. 68 | See the openPMD-viewer tutorials `on read-the-docs `_ for more info. 69 | -------------------------------------------------------------------------------- /docs/source/backends/adios1.rst: -------------------------------------------------------------------------------- 1 | .. _backends-adios1: 2 | 3 | ADIOS1 4 | ====== 5 | 6 | The ADIOS1 library is no longer developed in favor of ADIOS2. 7 | Consequently, ADIOS1 support was removed in openPMD-api 0.16.0 and newer. 8 | Please transition to ADIOS2. 9 | 10 | For reading legacy ADIOS1 BP3 files, either use an older version of openPMD-api or the BP3 backend in ADIOS2. 11 | Note that ADIOS2 does not support compression in BP3 files. 12 | 13 | 14 | Selected References 15 | ------------------- 16 | 17 | * Hasan Abbasi, Matthew Wolf, Greg Eisenhauer, Scott Klasky, Karsten Schwan, and Fang Zheng. 18 | *Datastager: scalable data staging services for petascale applications,* 19 | Cluster Computing, 13(3):277–290, 2010. 20 | `DOI:10.1007/s10586-010-0135-6 `_ 21 | 22 | * Ciprian Docan, Manish Parashar, and Scott Klasky. 23 | *DataSpaces: An interaction and coordination framework or coupled simulation workflows,* 24 | In Proc. of 19th International Symposium on High Performance and Distributed Computing (HPDC’10), June 2010. 25 | `DOI:10.1007/s10586-011-0162-y `_ 26 | 27 | * Qing Liu, Jeremy Logan, Yuan Tian, Hasan Abbasi, Norbert Podhorszki, Jong Youl Choi, Scott Klasky, Roselyne Tchoua, Jay Lofstead, Ron Oldfield, Manish Parashar, Nagiza Samatova, Karsten Schwan, Arie Shoshani, Matthew Wolf, Kesheng Wu, and Weikuan Yu. 28 | *Hello ADIOS: the challenges and lessons of developing leadership class I/O frameworks,* 29 | Concurrency and Computation: Practice and Experience, 26(7):1453–1473, 2014. 30 | `DOI:10.1002/cpe.3125 `_ 31 | 32 | * Robert McLay, Doug James, Si Liu, John Cazes, and William Barth. 33 | *A user-friendly approach for tuning parallel file operations,* 34 | In Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis, SC'14, pages 229–236, IEEE Press, 2014. 35 | `DOI:10.1109/SC.2014.24 `_ 36 | 37 | * Axel Huebl, Rene Widera, Felix Schmitt, Alexander Matthes, Norbert Podhorszki, Jong Youl Choi, Scott Klasky, and Michael Bussmann. 38 | *On the Scalability of Data Reduction Techniques in Current and Upcoming HPC Systems from an Application Perspective,* 39 | ISC High Performance 2017: High Performance Computing, pp. 15-29, 2017. 40 | `arXiv:1706.00522 `_, `DOI:10.1007/978-3-319-67630-2_2 `_ 41 | -------------------------------------------------------------------------------- /docs/source/coc.rst: -------------------------------------------------------------------------------- 1 | ../../CODE_OF_CONDUCT.rst -------------------------------------------------------------------------------- /docs/source/details/adios2.json: -------------------------------------------------------------------------------- 1 | { 2 | "adios2": { 3 | "engine": { 4 | "type": "sst", 5 | "preferred_flush_target": "disk", 6 | "parameters": { 7 | "BufferGrowthFactor": "2.0", 8 | "QueueLimit": "2" 9 | } 10 | }, 11 | "dataset": { 12 | "operators": [ 13 | { 14 | "type": "blosc", 15 | "parameters": { 16 | "clevel": "1", 17 | "doshuffle": "BLOSC_BITSHUFFLE" 18 | } 19 | } 20 | ] 21 | }, 22 | "attribute_writing_ranks": 0 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /docs/source/details/adios2.toml: -------------------------------------------------------------------------------- 1 | [adios2] 2 | # ignore all attribute writes not issued on these ranks 3 | # can also be a list if multiple ranks need to be given 4 | # however rank 0 should be the most common option here 5 | attribute_writing_ranks = 0 6 | 7 | [adios2.engine] 8 | type = "sst" 9 | preferred_flush_target = "disk" 10 | 11 | [adios2.engine.parameters] 12 | BufferGrowthFactor = "2.0" 13 | QueueLimit = "2" 14 | 15 | # use double brackets to indicate lists 16 | [[adios2.dataset.operators]] 17 | type = "blosc" 18 | 19 | # specify parameters for the current operator 20 | [adios2.dataset.operators.parameters] 21 | clevel = "1" 22 | doshuffle = "BLOSC_BITSHUFFLE" 23 | 24 | # use double brackets a second time to indicate a further entry 25 | [[adios2.dataset.operators]] 26 | # specify a second operator here 27 | type = "some other operator" 28 | 29 | # the parameters dictionary can also be specified in-line 30 | parameters.clevel = "1" 31 | parameters.doshuffle = "BLOSC_BITSHUFFLE" 32 | -------------------------------------------------------------------------------- /docs/source/details/config_layout.json: -------------------------------------------------------------------------------- 1 | { 2 | "adios2": "put ADIOS2 config here", 3 | "hdf5": "put HDF5 config here", 4 | "json": "put JSON config here" 5 | } 6 | -------------------------------------------------------------------------------- /docs/source/details/config_layout.toml: -------------------------------------------------------------------------------- 1 | [adios2] 2 | # put ADIOS2 config here 3 | 4 | [hdf5] 5 | # put HDF5 config here 6 | 7 | [json] 8 | # put JSON config here 9 | -------------------------------------------------------------------------------- /docs/source/details/doxygen.rst: -------------------------------------------------------------------------------- 1 | .. _details-doxygen: 2 | 3 | C++ 4 | === 5 | 6 | Our Doxygen page `provides an index of all C++ functionality <../_static/doxyhtml/index.html>`_. 7 | 8 | 9 | Public Headers 10 | -------------- 11 | 12 | ``#include ...`` the following headers to use openPMD-api: 13 | 14 | =========================== ======================================================= 15 | Include Description 16 | =========================== ======================================================= 17 | ```` Public facade header (serial and MPI) 18 | ```` Optional :ref:`benchmark ` helpers 19 | =========================== ======================================================= 20 | 21 | 22 | External Documentation 23 | ---------------------- 24 | 25 | If you want to link to the openPMD-api doxygen index `from an external documentation `_, you can find the `Doxygen tag file here <../_static/doxyhtml/openpmd-api-doxygen-web.tag.xml>`_. 26 | 27 | If you want to use this tag file with e.g. `xeus-cling `_, add the following in its configuration directory: 28 | 29 | .. code:: json 30 | 31 | { 32 | "url": "https://openpmd-api.readthedocs.io/en//_static/doxyhtml/", 33 | "tagfile": "openpmd-api-doxygen-web.tag.xml" 34 | } 35 | -------------------------------------------------------------------------------- /docs/source/details/hdf5.json: -------------------------------------------------------------------------------- 1 | { 2 | "hdf5": { 3 | "dataset": { 4 | "chunks": "auto" 5 | }, 6 | "vfd": { 7 | "type": "subfiling", 8 | "ioc_selection": "every_nth_rank", 9 | "stripe_size": 33554432, 10 | "stripe_count": -1 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docs/source/details/json.json: -------------------------------------------------------------------------------- 1 | { 2 | "json": { 3 | "dataset": { 4 | "mode": "template" 5 | }, 6 | "attribute": { 7 | "mode": "short" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /docs/source/details/openpmd_extended_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "adios2": { 3 | "engine": { 4 | "parameters": { 5 | "Profile": "On" 6 | } 7 | }, 8 | "dataset": [ 9 | { 10 | "cfg": { 11 | "operators": [ 12 | { 13 | "type": "blosc", 14 | "parameters": { 15 | "clevel": "1", 16 | "doshuffle": "BLOSC_BITSHUFFLE" 17 | } 18 | } 19 | ] 20 | } 21 | }, 22 | { 23 | "select": [ 24 | ".*positionOffset.*", 25 | ".*particlePatches.*" 26 | ], 27 | "cfg": { 28 | "operators": [] 29 | } 30 | } 31 | ] 32 | }, 33 | "hdf5": { 34 | "independent_stores": false, 35 | "dataset": [ 36 | { 37 | "cfg": { 38 | "chunks": "auto" 39 | } 40 | }, 41 | { 42 | "select": [ 43 | "/data/1/particles/e/.*", 44 | "/data/2/particles/e/.*" 45 | ], 46 | "cfg": { 47 | "chunks": [ 48 | 5 49 | ] 50 | } 51 | }, 52 | { 53 | "select": "particles/e/.*", 54 | "cfg": { 55 | "chunks": [ 56 | 10 57 | ] 58 | } 59 | } 60 | ] 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /docs/source/details/openpmd_extended_config.toml: -------------------------------------------------------------------------------- 1 | 2 | # ADIOS2 config 3 | 4 | [adios2.engine.parameters] 5 | Profile = "On" 6 | 7 | # default configuration 8 | [[adios2.dataset]] 9 | # nested list as ADIOS2 can add multiple operators to a single dataset 10 | [[adios2.dataset.cfg.operators]] 11 | type = "blosc" 12 | parameters.doshuffle = "BLOSC_BITSHUFFLE" 13 | parameters.clevel = "1" 14 | 15 | # dataset-specific configuration to exclude some datasets 16 | # from applying operators. 17 | [[adios2.dataset]] 18 | select = [".*positionOffset.*", ".*particlePatches.*"] 19 | cfg.operators = [] 20 | 21 | # Now HDF5 22 | 23 | [hdf5] 24 | independent_stores = false 25 | 26 | # default configuration 27 | # The position of the default configuration does not matter, but there must 28 | # be only one single default configuration. 29 | [[hdf5.dataset]] 30 | cfg.chunks = "auto" 31 | 32 | # Dataset-specific configuration that specifies full paths, 33 | # i.e. including the path to the Iteration. 34 | # The non-default configurations are matched in top-down order, 35 | # so the order is relevant. 36 | [[hdf5.dataset]] 37 | select = ["/data/1/particles/e/.*", "/data/2/particles/e/.*"] 38 | cfg.chunks = [5] 39 | 40 | # dataset-specific configuration that specifies only the path 41 | # within the Iteration 42 | [[hdf5.dataset]] 43 | select = "particles/e/.*" 44 | cfg.chunks = [10] 45 | -------------------------------------------------------------------------------- /docs/source/details/python.rst: -------------------------------------------------------------------------------- 1 | .. _details-python: 2 | 3 | Python 4 | ====== 5 | 6 | Public Headers 7 | -------------- 8 | 9 | ``import ...`` the following python module to use openPMD-api: 10 | 11 | ========================= ============================================== 12 | Import Description 13 | ========================= ============================================== 14 | ``openpmd_api`` Public facade import (serial and MPI) 15 | ========================= ============================================== 16 | 17 | .. note:: 18 | 19 | As demonstrated in our :ref:`python examples `, MPI-parallel scripts must import ``from mpi4py import MPI`` prior to importing ``openpmd_api`` in order to `initialize MPI first `_. 20 | 21 | Otherwise, errors of the following kind will occur: 22 | 23 | .. code:: 24 | 25 | The MPI_Comm_test_inter() function was called before MPI_INIT was invoked. 26 | This is disallowed by the MPI standard. 27 | Your MPI job will now abort. 28 | -------------------------------------------------------------------------------- /docs/source/dev/IOTask.hpp: -------------------------------------------------------------------------------- 1 | ../../../include/openPMD/IO/IOTask.hpp -------------------------------------------------------------------------------- /docs/source/dev/contributing.rst: -------------------------------------------------------------------------------- 1 | ../../../CONTRIBUTING.rst -------------------------------------------------------------------------------- /docs/source/dev/dependencies.rst: -------------------------------------------------------------------------------- 1 | .. _development-dependencies: 2 | 3 | Build Dependencies 4 | ================== 5 | 6 | ``openPMD-api`` depends on a series of third-party projects. 7 | These are currently: 8 | 9 | Required 10 | -------- 11 | 12 | * CMake 3.22.0+ 13 | * C++17 capable compiler, e.g., g++ 7+, clang 7+, MSVC 19.15+, icpc 19+, icpx 14 | 15 | Shipped internally 16 | ------------------ 17 | 18 | The following libraries are downloaded by CMake for convenience, unless ``openPMD_SUPERBUILD=OFF`` is set: 19 | 20 | * `Catch2 `_ 2.13.10+ (`BSL-1.0 `__) 21 | * `pybind11 `_ 2.13.0+ (`new BSD `_) 22 | * `NLohmann-JSON `_ 3.9.1+ (`MIT `_) 23 | * `toml11 `_ 3.7.1+ (`MIT `__) 24 | 25 | Optional: I/O backends 26 | ---------------------- 27 | 28 | * `JSON `_ 29 | * `HDF5 `_ 1.8.13+ 30 | * `ADIOS2 `_ 2.9.0+ 31 | 32 | while those can be build either with or without: 33 | 34 | * MPI 2.1+, e.g. OpenMPI 1.6.5+ or MPICH2 35 | 36 | Optional: language bindings 37 | --------------------------- 38 | 39 | * Python: 40 | 41 | * Python 3.8 - 3.13 42 | * pybind11 2.13.0+ 43 | * numpy 1.15+ 44 | * mpi4py 2.1+ (optional, for MPI) 45 | * pandas 1.0+ (optional, for dataframes) 46 | * dask 2021+ (optional, for dask dataframes) 47 | 48 | * CUDA C++ (optional, currently used only in tests) 49 | 50 | Quick Install with Spack 51 | ------------------------ 52 | 53 | Quickly install all dependencies with a `Spack anonymous environment `_. 54 | Go in the base directory and type: 55 | 56 | 57 | .. code-block:: bash 58 | 59 | spack env activate -d . 60 | spack install 61 | -------------------------------------------------------------------------------- /docs/source/dev/repostructure.rst: -------------------------------------------------------------------------------- 1 | .. _development-repostructure: 2 | 3 | Repository Structure 4 | ==================== 5 | 6 | Branches 7 | -------- 8 | 9 | * ``dev``: the development branch where all features start from and are merged to 10 | * ``release-X.Y.Z``: release candidate for version ``X.Y.Z`` with an upcoming release, receives updates for bug fixes and documentation such as change logs but usually no new features 11 | 12 | Directory Structure 13 | ------------------- 14 | 15 | * ``include/`` 16 | 17 | * C++ header files 18 | * set ``-I`` here 19 | * prefixed with project name 20 | 21 | * ``auxiliary/`` 22 | 23 | * internal auxiliary functionality 24 | 25 | * ``helper/``, ``benchmark/`` 26 | 27 | * user-facing helper functionality 28 | 29 | * ``src/`` 30 | 31 | * C++ source files 32 | 33 | * ``cli/`` 34 | 35 | * user-facing command line tools 36 | 37 | * ``lib/`` 38 | 39 | * ``python/`` 40 | 41 | * modules, e.g. additional python interfaces and helpers 42 | * set ``PYTHONPATH`` here 43 | 44 | * ``examples/`` 45 | 46 | * read and write examples 47 | 48 | * ``samples/`` 49 | 50 | * example files; need to be added manually with: 51 | ``share/openPMD/download_samples.sh`` (or ``.ps1``) 52 | 53 | * ``share/openPMD/`` 54 | 55 | * download scripts for example files 56 | 57 | * ``cmake/`` 58 | 59 | * cmake scripts 60 | 61 | * ``thirdParty/`` 62 | 63 | * included third party software 64 | 65 | * ``test/`` 66 | 67 | * unit tests which are run with ``ctest`` (``make test``) 68 | 69 | * ``.github/`` 70 | 71 | * GitHub issue/pull request templates 72 | 73 | * ``workflows/`` 74 | 75 | * GitHub Action scripts for continuous integration checks 76 | 77 | * ``ci/`` 78 | 79 | * service-agnostic configurations for continuous integration 80 | 81 | * ``docs/`` 82 | 83 | * documentation files 84 | -------------------------------------------------------------------------------- /docs/source/install/changelog.rst: -------------------------------------------------------------------------------- 1 | ../../../CHANGELOG.rst -------------------------------------------------------------------------------- /docs/source/install/conda.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/source/install/upgrade.rst: -------------------------------------------------------------------------------- 1 | ../../../NEWS.rst -------------------------------------------------------------------------------- /docs/source/maintenance/requirements.txt: -------------------------------------------------------------------------------- 1 | # just want to say thank you! 2 | cibuildwheel==1.3.0 3 | -------------------------------------------------------------------------------- /docs/source/openPMD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openPMD/openPMD-api/42595a052e8292ed7d09a1d4679760e8fd196e07/docs/source/openPMD.png -------------------------------------------------------------------------------- /docs/source/usage/10_streaming_read.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/10_streaming_read.cpp -------------------------------------------------------------------------------- /docs/source/usage/10_streaming_read.py: -------------------------------------------------------------------------------- 1 | ../../../examples/10_streaming_read.py -------------------------------------------------------------------------------- /docs/source/usage/10_streaming_write.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/10_streaming_write.cpp -------------------------------------------------------------------------------- /docs/source/usage/10_streaming_write.py: -------------------------------------------------------------------------------- 1 | ../../../examples/10_streaming_write.py -------------------------------------------------------------------------------- /docs/source/usage/2_read_serial.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/2_read_serial.cpp -------------------------------------------------------------------------------- /docs/source/usage/2_read_serial.py: -------------------------------------------------------------------------------- 1 | ../../../examples/2_read_serial.py -------------------------------------------------------------------------------- /docs/source/usage/2a_read_thetaMode_serial.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/2a_read_thetaMode_serial.cpp -------------------------------------------------------------------------------- /docs/source/usage/2a_read_thetaMode_serial.py: -------------------------------------------------------------------------------- 1 | ../../../examples/2a_read_thetaMode_serial.py -------------------------------------------------------------------------------- /docs/source/usage/3_write_serial.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/3_write_serial.cpp -------------------------------------------------------------------------------- /docs/source/usage/3_write_serial.py: -------------------------------------------------------------------------------- 1 | ../../../examples/3_write_serial.py -------------------------------------------------------------------------------- /docs/source/usage/3a_write_thetaMode_serial.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/3a_write_thetaMode_serial.cpp -------------------------------------------------------------------------------- /docs/source/usage/3a_write_thetaMode_serial.py: -------------------------------------------------------------------------------- 1 | ../../../examples/3a_write_thetaMode_serial.py -------------------------------------------------------------------------------- /docs/source/usage/3b_write_resizable_particles.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/3b_write_resizable_particles.cpp -------------------------------------------------------------------------------- /docs/source/usage/3b_write_resizable_particles.py: -------------------------------------------------------------------------------- 1 | ../../../examples/3b_write_resizable_particles.py -------------------------------------------------------------------------------- /docs/source/usage/4_read_parallel.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/4_read_parallel.cpp -------------------------------------------------------------------------------- /docs/source/usage/4_read_parallel.py: -------------------------------------------------------------------------------- 1 | ../../../examples/4_read_parallel.py -------------------------------------------------------------------------------- /docs/source/usage/5_write_parallel.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/5_write_parallel.cpp -------------------------------------------------------------------------------- /docs/source/usage/5_write_parallel.py: -------------------------------------------------------------------------------- 1 | ../../../examples/5_write_parallel.py -------------------------------------------------------------------------------- /docs/source/usage/parallel.rst: -------------------------------------------------------------------------------- 1 | .. _usage-parallel: 2 | 3 | Parallel Examples 4 | ================= 5 | 6 | The following examples show parallel reading and writing of domain-decomposed data with MPI. 7 | 8 | The `Message Passing Interface (MPI) `_ is an open communication standard for scientific computing. 9 | MPI is used on clusters, e.g. large-scale supercomputers, to communicate between nodes and provides parallel I/O primitives. 10 | 11 | Reading 12 | ------- 13 | 14 | C++ 15 | ^^^ 16 | 17 | .. literalinclude:: 4_read_parallel.cpp 18 | :language: cpp 19 | :lines: 21- 20 | 21 | Python 22 | ^^^^^^ 23 | 24 | .. literalinclude:: 4_read_parallel.py 25 | :language: python3 26 | :lines: 9- 27 | 28 | Writing 29 | ------- 30 | 31 | C++ 32 | ^^^ 33 | 34 | .. literalinclude:: 5_write_parallel.cpp 35 | :language: cpp 36 | :lines: 21- 37 | 38 | Python 39 | ^^^^^^ 40 | 41 | .. literalinclude:: 5_write_parallel.py 42 | :language: python3 43 | :lines: 9- 44 | -------------------------------------------------------------------------------- /docs/source/usage/serial.rst: -------------------------------------------------------------------------------- 1 | .. _usage-serial: 2 | 3 | Serial Examples 4 | =============== 5 | 6 | The serial API provides sequential, one-process read and write access. 7 | Most users will use this for exploration and processing of their data. 8 | 9 | Reading 10 | ------- 11 | 12 | C++ 13 | ^^^ 14 | 15 | .. literalinclude:: 2_read_serial.cpp 16 | :language: cpp 17 | :lines: 21- 18 | 19 | An extended example can be found in ``examples/6_dump_filebased_series.cpp``. 20 | 21 | Python 22 | ^^^^^^ 23 | 24 | .. literalinclude:: 2_read_serial.py 25 | :language: python3 26 | :lines: 9- 27 | 28 | Writing 29 | ------- 30 | 31 | C++ 32 | ^^^ 33 | 34 | .. literalinclude:: 3_write_serial.cpp 35 | :language: cpp 36 | :lines: 21- 37 | 38 | An extended example can be found in ``examples/7_extended_write_serial.cpp``. 39 | 40 | Python 41 | ^^^^^^ 42 | 43 | .. literalinclude:: 3_write_serial.py 44 | :language: python3 45 | :lines: 9- 46 | -------------------------------------------------------------------------------- /docs/source/utilities/8_benchmark_parallel.cpp: -------------------------------------------------------------------------------- 1 | ../../../examples/8_benchmark_parallel.cpp -------------------------------------------------------------------------------- /docs/ubuntu-package.list: -------------------------------------------------------------------------------- 1 | doxygen 2 | graphviz 3 | imagemagick 4 | librsvg2-bin 5 | texlive-latex-recommended 6 | texlive-fonts-recommended 7 | texlive-latex-extra 8 | -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | # I am a conda environment, used for our pre-commit hooks 2 | name: openPMD-api-dev 3 | channels: 4 | - conda-forge 5 | dependencies: 6 | - clang-format-20=20.1.0 7 | - bash=5 8 | -------------------------------------------------------------------------------- /examples/12_span_write.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import openpmd_api as io 3 | 4 | 5 | def span_write(filename): 6 | series = io.Series(filename, io.Access_Type.create) 7 | 8 | datatype = np.dtype("double") 9 | length = 10 10 | extent = [length] 11 | dataset = io.Dataset(datatype, extent) 12 | 13 | # `Series.write_iterations()` and `Series.read_iterations()` are 14 | # intentionally restricted APIs that ensure a workflow which also works 15 | # in streaming setups, e.g. an iteration cannot be opened again once 16 | # it has been closed. 17 | # `Series.iterations` can be directly accessed in random-access workflows. 18 | iterations = series.write_iterations() 19 | for i in range(12): 20 | iteration = iterations[i] 21 | electronPositions = iteration.particles["e"]["position"] 22 | 23 | j = 0 24 | for dim in ["x", "y", "z"]: 25 | pos = electronPositions[dim] 26 | pos.reset_dataset(dataset) 27 | # The Python span API does not expose the extended version that 28 | # allows overriding the fallback buffer allocation 29 | span = pos.store_chunk([0], extent).current_buffer() 30 | for k in range(len(span)): 31 | span[k] = 3 * i * length + j * length + k 32 | j += 1 33 | iteration.close() 34 | 35 | # The files in 'series' are still open until the object is destroyed, on 36 | # which it cleanly flushes and closes all open file handles. 37 | # When running out of scope on return, the 'Series' destructor is called. 38 | # Alternatively, one can call `series.close()` to the same effect as 39 | # calling the destructor, including the release of file handles. 40 | series.close() 41 | 42 | 43 | if __name__ == "__main__": 44 | for ext in io.file_extensions: 45 | if ext == "sst" or ext == "ssc": 46 | continue 47 | span_write("../samples/span_write_python." + ext) 48 | -------------------------------------------------------------------------------- /examples/3_write_serial.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | This file is part of the openPMD-api. 4 | 5 | Copyright 2018-2021 openPMD contributors 6 | Authors: Axel Huebl 7 | License: LGPLv3+ 8 | """ 9 | import numpy as np 10 | import openpmd_api as io 11 | 12 | if __name__ == "__main__": 13 | # user input: size of matrix to write, default 3x3 14 | size = 3 15 | 16 | # matrix dataset to write with values 0...size*size-1 17 | data = np.arange(size*size, dtype=np.double).reshape(3, 3) 18 | 19 | print("Set up a 2D square array ({0}x{1}) that will be written".format( 20 | size, size)) 21 | 22 | # open file for writing 23 | series = io.Series( 24 | "../samples/3_write_serial_py.h5", 25 | io.Access.create 26 | ) 27 | 28 | print("Created an empty {0} Series".format(series.iteration_encoding)) 29 | 30 | print(len(series.iterations)) 31 | # `Series.write_iterations()` and `Series.read_iterations()` are 32 | # intentionally restricted APIs that ensure a workflow which also works 33 | # in streaming setups, e.g. an iteration cannot be opened again once 34 | # it has been closed. 35 | # `Series.iterations` can be directly accessed in random-access workflows. 36 | rho = series.write_iterations()[1]. \ 37 | meshes["rho"] 38 | 39 | dataset = io.Dataset(data.dtype, data.shape) 40 | 41 | print("Created a Dataset of size {0}x{1} and Datatype {2}".format( 42 | dataset.extent[0], dataset.extent[1], dataset.dtype)) 43 | 44 | rho.reset_dataset(dataset) 45 | print("Set the dataset properties for the scalar field rho in iteration 1") 46 | 47 | series.flush() 48 | print("File structure has been written") 49 | 50 | rho[()] = data 51 | 52 | print("Stored the whole Dataset contents as a single chunk, " + 53 | "ready to write content") 54 | 55 | # The iteration can be closed in order to help free up resources. 56 | # The iteration's content will be flushed automatically. 57 | # An iteration once closed cannot (yet) be reopened. 58 | series.write_iterations()[1].close() 59 | print("Dataset content has been fully written") 60 | 61 | # The files in 'series' are still open until the series is closed, at which 62 | # time it cleanly flushes and closes all open file handles. 63 | # One can close the object explicitly to trigger this. 64 | # Alternatively, this will automatically happen once the garbage collector 65 | # claims (every copy of) the series object. 66 | series.close() 67 | -------------------------------------------------------------------------------- /include/openPMD/ChunkInfo_internal.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2024 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/ChunkInfo.hpp" 24 | #include 25 | 26 | namespace openPMD::host_info 27 | { 28 | 29 | /** 30 | * @brief This defines the method identifiers used 31 | * in `{"rank_table": "hostname"}` 32 | * 33 | * Currently recognized are: 34 | * 35 | * * posix_hostname 36 | * * mpi_processor_name 37 | * 38 | * For backwards compatibility reasons, "hostname" is also recognized as a 39 | * deprecated alternative for "posix_hostname". 40 | * 41 | * @return Method enum identifier. The identifier is returned even if the 42 | * method is not available on the system. This should by checked 43 | * via methodAvailable(). 44 | * @throws std::out_of_range If an unknown string identifier is passed. 45 | */ 46 | Method methodFromStringDescription(std::string const &descr, bool consider_mpi); 47 | 48 | /* 49 | * The following block contains one wrapper for each native hostname 50 | * retrieval method. The purpose is to have the same function pointer type 51 | * for all of them. 52 | */ 53 | 54 | #ifdef _WIN32 55 | #define openPMD_POSIX_AVAILABLE false 56 | #else 57 | #define openPMD_POSIX_AVAILABLE true 58 | #endif 59 | 60 | #if openPMD_POSIX_AVAILABLE 61 | std::string posix_hostname(); 62 | #endif 63 | 64 | #if openPMD_HAVE_MPI 65 | std::string mpi_processor_name(); 66 | #endif 67 | } // namespace openPMD::host_info 68 | -------------------------------------------------------------------------------- /include/openPMD/DatatypeHelpers.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2023 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | /* 25 | * Legacy header, its functions are now included directly in Datatype.hpp. 26 | */ 27 | 28 | #include "openPMD/Datatype.hpp" 29 | -------------------------------------------------------------------------------- /include/openPMD/IO/ADIOS/ADIOS2FilePosition.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller and Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp" 24 | #include "openPMD/IO/AbstractFilePosition.hpp" 25 | #include 26 | #include 27 | 28 | namespace openPMD 29 | { 30 | struct ADIOS2FilePosition : public AbstractFilePosition 31 | { 32 | ADIOS2FilePosition(std::string s, GroupOrDataset groupOrDataset) 33 | : location{std::move(s)}, gd{groupOrDataset} 34 | {} 35 | 36 | explicit ADIOS2FilePosition(GroupOrDataset groupOrDataset) 37 | : ADIOS2FilePosition{"/", groupOrDataset} 38 | {} 39 | 40 | ADIOS2FilePosition() : ADIOS2FilePosition{GroupOrDataset::GROUP} 41 | {} 42 | 43 | /** 44 | * Convention: Starts with slash '/', ends without. 45 | */ 46 | std::string location; 47 | GroupOrDataset gd; 48 | }; // ADIOS2FilePosition 49 | } // namespace openPMD 50 | -------------------------------------------------------------------------------- /include/openPMD/IO/ADIOS/ADIOS2PreloadVariables.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2025 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/auxiliary/Variant.hpp" 24 | #include "openPMD/config.hpp" 25 | #include 26 | #include 27 | #include 28 | #if openPMD_HAVE_ADIOS2 29 | 30 | #include 31 | #include 32 | 33 | namespace openPMD::detail 34 | { 35 | struct AdiosVariables 36 | { 37 | // Buffered map for current step 38 | using AttributeMap_t = std::map; 39 | std::optional m_availableVariables; 40 | // For which step were the above variables buffered? 41 | size_t currentStep; 42 | // Optimization: If variable definitions do not vary across steps, no need 43 | // to recompute them 44 | bool variables_are_static = false; 45 | 46 | // Preparsed step data 47 | struct RandomAccessPreparsed_t 48 | { 49 | // Variable only defined in these steps 50 | std::map> m_partialVariables; 51 | 52 | AttributeMap_t m_allVariables; 53 | }; 54 | std::optional m_preparsed; 55 | 56 | /* 57 | * If use_step_selection is false, but preparsed step data is available, 58 | * this means that Advance(stepSelection = null) was executed previously. 59 | * So, we can return m_preparsed->m_allVariables. 60 | */ 61 | auto 62 | availableVariables(size_t step, bool use_step_selection, adios2::IO &IO) 63 | -> AttributeMap_t const &; 64 | }; 65 | } // namespace openPMD::detail 66 | 67 | #endif // openPMD_HAVE_ADIOS2 68 | -------------------------------------------------------------------------------- /include/openPMD/IO/ADIOS/macros.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "openPMD/config.hpp" 4 | 5 | #if openPMD_HAVE_ADIOS2 6 | 7 | #include 8 | 9 | #define openPMD_HAS_ADIOS_2_10 \ 10 | (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 210) 11 | 12 | #define openPMD_HAS_ADIOS_2_10_1 \ 13 | (ADIOS2_VERSION_MAJOR * 1000 + ADIOS2_VERSION_MINOR * 10 + \ 14 | ADIOS2_VERSION_PATCH >= \ 15 | 2101) 16 | 17 | #if defined(ADIOS2_HAVE_BP5) || openPMD_HAS_ADIOS_2_10 18 | // ADIOS2 v2.10 no longer defines this 19 | #define openPMD_HAVE_ADIOS2_BP5 1 20 | #else 21 | #define openPMD_HAVE_ADIOS2_BP5 0 22 | #endif 23 | 24 | #else 25 | 26 | #define openPMD_HAS_ADIOS_2_8 0 27 | #define openPMD_HAS_ADIOS_2_9 0 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /include/openPMD/IO/AbstractFilePosition.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | namespace openPMD 24 | { 25 | class AbstractFilePosition 26 | { 27 | public: 28 | virtual ~AbstractFilePosition() = default; 29 | }; // AbstractFilePosition 30 | } // namespace openPMD 31 | -------------------------------------------------------------------------------- /include/openPMD/IO/DummyIOHandler.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller, Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/IO/AbstractIOHandler.hpp" 24 | #include "openPMD/IO/Access.hpp" 25 | #include "openPMD/IO/IOTask.hpp" 26 | 27 | #include 28 | #include 29 | 30 | namespace openPMD 31 | { 32 | /** Dummy handler without any IO operations. 33 | */ 34 | class DummyIOHandler : public AbstractIOHandler 35 | { 36 | public: 37 | DummyIOHandler(std::string, Access); 38 | ~DummyIOHandler() override = default; 39 | 40 | /** No-op consistent with the IOHandler interface to enable library use 41 | * without IO. 42 | */ 43 | void enqueue(IOTask const &) override; 44 | /** No-op consistent with the IOHandler interface to enable library use 45 | * without IO. 46 | */ 47 | std::future flush(internal::ParsedFlushParams &) override; 48 | std::string backendName() const override; 49 | }; // DummyIOHandler 50 | } // namespace openPMD 51 | -------------------------------------------------------------------------------- /include/openPMD/IO/FlushParametersInternal.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "openPMD/IO/AbstractIOHandler.hpp" 25 | #include "openPMD/auxiliary/JSON_internal.hpp" 26 | 27 | #include 28 | 29 | namespace openPMD::internal 30 | { 31 | struct ParsedFlushParams 32 | { 33 | ParsedFlushParams(FlushParams const &); 34 | 35 | FlushLevel flushLevel = FlushLevel::InternalFlush; 36 | json::TracingJSON backendConfig; 37 | }; 38 | 39 | ParsedFlushParams const defaultParsedFlushParams{defaultFlushParams}; 40 | } // namespace openPMD::internal 41 | -------------------------------------------------------------------------------- /include/openPMD/IO/Format.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller, Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace openPMD 26 | { 27 | /** File format to use during IO. 28 | */ 29 | enum class Format 30 | { 31 | HDF5, 32 | ADIOS2_BP, 33 | ADIOS2_BP4, 34 | ADIOS2_BP5, 35 | ADIOS2_SST, 36 | ADIOS2_SSC, 37 | JSON, 38 | TOML, 39 | GENERIC, 40 | DUMMY 41 | }; 42 | 43 | /** Determine the storage format of a Series from the used filename extension. 44 | * 45 | * @param filename string containing the filename. 46 | * @return Format that best fits the filename extension. 47 | */ 48 | Format determineFormat(std::string const &filename); 49 | 50 | /** Determine the default filename suffix for a given storage format. 51 | * 52 | * @param f File format to determine suffix for. 53 | * @return String containing the default filename suffix 54 | */ 55 | std::string suffix(Format f); 56 | } // namespace openPMD 57 | -------------------------------------------------------------------------------- /include/openPMD/IO/HDF5/HDF5Auxiliary.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller, Felix Schmitt, Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/backend/Attribute.hpp" 24 | #include "openPMD/backend/Writable.hpp" 25 | #include "openPMD/config.hpp" 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace openPMD 35 | { 36 | struct GetH5DataType 37 | { 38 | std::unordered_map m_userTypes; 39 | 40 | GetH5DataType(std::unordered_map userTypes) 41 | : m_userTypes{std::move(userTypes)} 42 | {} 43 | 44 | hid_t operator()(Attribute const &att); 45 | }; 46 | 47 | hid_t getH5DataSpace(Attribute const &att); 48 | 49 | std::string concrete_h5_file_position(Writable *w); 50 | 51 | /** Computes the chunk dimensions for a dataset. 52 | * 53 | * Chunk dimensions are selected to create chunks sizes between 54 | * 64KByte and 4MB. Smaller chunk sizes are inefficient due to overhead, 55 | * larger chunks do not map well to file system blocks and striding. 56 | * 57 | * Chunk dimensions are less or equal to dataset dimensions and do 58 | * not need to be a factor of the respective dataset dimension. 59 | * 60 | * @param[in] dims dimensions of dataset to get chunk dims for 61 | * @param[in] typeSize size of each element in bytes 62 | * @return array for resulting chunk dimensions 63 | */ 64 | std::vector 65 | getOptimalChunkDims(std::vector const &dims, size_t const typeSize); 66 | } // namespace openPMD 67 | -------------------------------------------------------------------------------- /include/openPMD/IO/HDF5/HDF5FilePosition.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/IO/AbstractFilePosition.hpp" 24 | 25 | namespace openPMD 26 | { 27 | struct HDF5FilePosition : public AbstractFilePosition 28 | { 29 | HDF5FilePosition(std::string const &s) : location{s} 30 | {} 31 | 32 | std::string location; 33 | }; // HDF5FilePosition 34 | } // namespace openPMD 35 | -------------------------------------------------------------------------------- /include/openPMD/IO/HDF5/HDF5IOHandler.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/IO/AbstractIOHandler.hpp" 24 | #include "openPMD/auxiliary/JSON_internal.hpp" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace openPMD 31 | { 32 | class HDF5IOHandlerImpl; 33 | 34 | class HDF5IOHandler : public AbstractIOHandler 35 | { 36 | public: 37 | HDF5IOHandler( 38 | std::optional> initialize_from, 39 | std::string path, 40 | Access, 41 | json::TracingJSON config); 42 | ~HDF5IOHandler() override; 43 | 44 | std::string backendName() const override 45 | { 46 | return "HDF5"; 47 | } 48 | 49 | std::future flush(internal::ParsedFlushParams &) override; 50 | 51 | private: 52 | std::unique_ptr m_impl; 53 | }; // HDF5IOHandler 54 | } // namespace openPMD 55 | -------------------------------------------------------------------------------- /include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/IO/AbstractIOHandler.hpp" 24 | #include "openPMD/auxiliary/JSON_internal.hpp" 25 | #include "openPMD/config.hpp" 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace openPMD 32 | { 33 | class ParallelHDF5IOHandlerImpl; 34 | 35 | class ParallelHDF5IOHandler : public AbstractIOHandler 36 | { 37 | public: 38 | #if openPMD_HAVE_MPI 39 | ParallelHDF5IOHandler( 40 | std::optional> initialize_from, 41 | std::string path, 42 | Access, 43 | MPI_Comm, 44 | json::TracingJSON config); 45 | #else 46 | ParallelHDF5IOHandler( 47 | std::optional> initialize_from, 48 | std::string const &path, 49 | Access, 50 | json::TracingJSON config); 51 | #endif 52 | ~ParallelHDF5IOHandler() override; 53 | 54 | std::string backendName() const override 55 | { 56 | return "MPI_HDF5"; 57 | } 58 | 59 | std::future flush(internal::ParsedFlushParams &) override; 60 | 61 | private: 62 | std::unique_ptr m_impl; 63 | }; // ParallelHDF5IOHandler 64 | } // namespace openPMD 65 | -------------------------------------------------------------------------------- /include/openPMD/IO/HDF5/ParallelHDF5IOHandlerImpl.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/IO/AbstractIOHandlerImpl.hpp" 24 | #include "openPMD/config.hpp" 25 | 26 | #if openPMD_HAVE_MPI 27 | #include 28 | #if openPMD_HAVE_HDF5 29 | #include "openPMD/IO/HDF5/HDF5IOHandlerImpl.hpp" 30 | #include "openPMD/auxiliary/JSON_internal.hpp" 31 | #endif 32 | #endif 33 | 34 | namespace openPMD 35 | { 36 | #if openPMD_HAVE_HDF5 && openPMD_HAVE_MPI 37 | class ParallelHDF5IOHandlerImpl : public HDF5IOHandlerImpl 38 | { 39 | public: 40 | ParallelHDF5IOHandlerImpl(AbstractIOHandler *, MPI_Comm); 41 | ~ParallelHDF5IOHandlerImpl() override; 42 | 43 | MPI_Comm m_mpiComm; 44 | MPI_Info m_mpiInfo; 45 | 46 | std::future flush(internal::ParsedFlushParams &); 47 | }; // ParallelHDF5IOHandlerImpl 48 | #else 49 | class ParallelHDF5IOHandlerImpl 50 | {}; // ParallelHDF5IOHandlerImpl 51 | #endif 52 | } // namespace openPMD 53 | -------------------------------------------------------------------------------- /include/openPMD/IO/JSON/JSONFilePosition.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "openPMD/IO/AbstractFilePosition.hpp" 25 | #include "openPMD/config.hpp" 26 | 27 | #include 28 | 29 | namespace openPMD 30 | { 31 | struct JSONFilePosition : public AbstractFilePosition 32 | { 33 | using json = nlohmann::json; 34 | json::json_pointer id; 35 | 36 | JSONFilePosition(json::json_pointer ptr = json::json_pointer()); 37 | }; 38 | } // namespace openPMD 39 | -------------------------------------------------------------------------------- /include/openPMD/IO/JSON/JSONIOHandler.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "openPMD/IO/AbstractIOHandler.hpp" 25 | #include "openPMD/IO/JSON/JSONIOHandlerImpl.hpp" 26 | #include "openPMD/auxiliary/JSON_internal.hpp" 27 | 28 | #if openPMD_HAVE_MPI 29 | #include 30 | #endif 31 | 32 | namespace openPMD 33 | { 34 | class JSONIOHandler : public AbstractIOHandler 35 | { 36 | public: 37 | JSONIOHandler( 38 | std::optional> initialize_from, 39 | std::string path, 40 | Access at, 41 | openPMD::json::TracingJSON config, 42 | JSONIOHandlerImpl::FileFormat, 43 | std::string originalExtension); 44 | #if openPMD_HAVE_MPI 45 | JSONIOHandler( 46 | std::optional> initialize_from, 47 | std::string path, 48 | Access at, 49 | MPI_Comm, 50 | openPMD::json::TracingJSON config, 51 | JSONIOHandlerImpl::FileFormat, 52 | std::string originalExtension); 53 | #endif 54 | 55 | ~JSONIOHandler() override; 56 | 57 | std::string backendName() const override 58 | { 59 | return "JSON"; 60 | } 61 | 62 | std::future flush(internal::ParsedFlushParams &) override; 63 | 64 | private: 65 | JSONIOHandlerImpl m_impl; 66 | }; 67 | } // namespace openPMD 68 | -------------------------------------------------------------------------------- /include/openPMD/IterationEncoding.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace openPMD 26 | { 27 | /** Encoding scheme of an Iterations Series'. 28 | * 29 | * @see 30 | * https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#iterations-and-time-series 31 | */ 32 | enum class IterationEncoding 33 | { 34 | fileBased, 35 | groupBased, 36 | variableBased 37 | }; 38 | 39 | std::ostream &operator<<(std::ostream &, openPMD::IterationEncoding const &); 40 | 41 | } // namespace openPMD 42 | -------------------------------------------------------------------------------- /include/openPMD/ParticlePatches.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller, Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/backend/Container.hpp" 24 | #include "openPMD/backend/PatchRecord.hpp" 25 | 26 | #include 27 | #include 28 | 29 | namespace openPMD 30 | { 31 | class ParticlePatches : public Container 32 | { 33 | friend class ParticleSpecies; 34 | friend class Container; 35 | friend class Container; 36 | 37 | public: 38 | size_t numPatches() const; 39 | ~ParticlePatches() override = default; 40 | 41 | private: 42 | ParticlePatches() = default; 43 | void read(); 44 | }; // ParticlePatches 45 | 46 | } // namespace openPMD 47 | -------------------------------------------------------------------------------- /include/openPMD/ParticleSpecies.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/ParticlePatches.hpp" 24 | #include "openPMD/Record.hpp" 25 | #include "openPMD/backend/Attributable.hpp" 26 | #include "openPMD/backend/Container.hpp" 27 | 28 | #include 29 | 30 | namespace openPMD 31 | { 32 | 33 | class ParticleSpecies : public Container 34 | { 35 | friend class Container; 36 | friend class Container; 37 | friend class Iteration; 38 | template 39 | friend T &internal::makeOwning(T &self, Series); 40 | 41 | public: 42 | ParticlePatches particlePatches; 43 | 44 | private: 45 | ParticleSpecies(); 46 | 47 | void read(); 48 | void flush(std::string const &, internal::FlushParams const &) override; 49 | 50 | using Data_t = Container::ContainerData; 51 | 52 | inline std::shared_ptr getShared() 53 | { 54 | return m_containerData; 55 | } 56 | }; 57 | 58 | namespace traits 59 | { 60 | template <> 61 | struct GenerationPolicy 62 | { 63 | constexpr static bool is_noop = false; 64 | template 65 | void operator()(T &ret) 66 | { 67 | ret.particlePatches.linkHierarchy(ret.writable()); 68 | } 69 | }; 70 | } // namespace traits 71 | } // namespace openPMD 72 | -------------------------------------------------------------------------------- /include/openPMD/ReadIterations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * Legacy header. 5 | */ 6 | 7 | #include "openPMD/Iteration.hpp" 8 | #include "openPMD/Series.hpp" 9 | #include "openPMD/snapshots/Snapshots.hpp" 10 | 11 | namespace openPMD 12 | { 13 | /** @brief Legacy Iterator type for `Series::readIterations()` 14 | * 15 | * Wraps the Iterator type of `Series::snapshots()`, but has `IndexedIteration` 16 | * as value_type instead of `std::pair`. 17 | */ 18 | class LegacyIteratorAdaptor 19 | { 20 | using value_type = IndexedIteration; 21 | using parent_t = Snapshots::iterator; 22 | 23 | private: 24 | friend class ReadIterations; 25 | Snapshots::iterator m_iterator; 26 | LegacyIteratorAdaptor(Snapshots::iterator iterator); 27 | 28 | public: 29 | value_type operator*() const; 30 | LegacyIteratorAdaptor &operator++(); 31 | bool operator==(LegacyIteratorAdaptor const &other) const; 32 | bool operator!=(LegacyIteratorAdaptor const &other) const; 33 | }; 34 | 35 | /** 36 | * @brief Legacy class as return type for `Series::readIterations()`. 37 | * 38 | * This is a feature-restricted subset for the functionality of 39 | * `Series::snapshots()`, prefer using that. The compatibility layer is needed 40 | * due to the different value_type for `Series::readIterations()`-based 41 | * iteration (`IndexedIteration` instead of `std::pair`). 42 | * 43 | * Create instance via Series::readIterations(). 44 | * For use in a C++11-style foreach loop over iterations. 45 | * Designed to allow reading any kind of Series, streaming and non- 46 | * streaming alike. 47 | * Calling Iteration::close() manually before opening the next iteration is 48 | * encouraged and will implicitly flush all deferred IO actions. 49 | * Otherwise, Iteration::close() will be implicitly called upon 50 | * StatefulIterator::operator++(), i.e. upon going to the next iteration in 51 | * the foreach loop. 52 | * 53 | */ 54 | class ReadIterations 55 | { 56 | friend class Series; 57 | 58 | private: 59 | using iterations_t = decltype(internal::SeriesData::iterations); 60 | using iterator_t = LegacyIteratorAdaptor; 61 | 62 | Series m_series; 63 | std::optional m_parsePreference; 64 | 65 | ReadIterations( 66 | Series, 67 | Access, 68 | std::optional parsePreference); 69 | 70 | public: 71 | auto begin() -> iterator_t; 72 | static auto end() -> iterator_t; 73 | }; 74 | } // namespace openPMD 75 | -------------------------------------------------------------------------------- /include/openPMD/Record.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/RecordComponent.hpp" 24 | #include "openPMD/UnitDimension.hpp" 25 | #include "openPMD/backend/BaseRecord.hpp" 26 | 27 | #include 28 | #include 29 | 30 | namespace openPMD 31 | { 32 | class Record : public BaseRecord 33 | { 34 | friend class Container; 35 | friend class Iteration; 36 | friend class ParticleSpecies; 37 | 38 | public: 39 | Record(Record const &) = default; 40 | Record &operator=(Record const &) = default; 41 | ~Record() override = default; 42 | 43 | Record &setUnitDimension(unit_representations::AsMap const &); 44 | Record &setUnitDimension(unit_representations::AsArray const &); 45 | 46 | template 47 | T timeOffset() const; 48 | template 49 | Record &setTimeOffset(T); 50 | 51 | private: 52 | Record(); 53 | 54 | void 55 | flush_impl(std::string const &, internal::FlushParams const &) override; 56 | void read(); 57 | }; // Record 58 | 59 | template 60 | inline T Record::timeOffset() const 61 | { 62 | return readFloatingpoint("timeOffset"); 63 | } 64 | 65 | template 66 | inline Record &Record::setTimeOffset(T to) 67 | { 68 | static_assert( 69 | std::is_floating_point::value, 70 | "Type of attribute must be floating point"); 71 | 72 | setAttribute("timeOffset", to); 73 | return *this; 74 | } 75 | } // namespace openPMD 76 | -------------------------------------------------------------------------------- /include/openPMD/Streaming.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "openPMD/Dataset.hpp" 9 | #include "openPMD/benchmark/mpi/BlockSlicer.hpp" 10 | #include 11 | 12 | namespace openPMD 13 | { 14 | /** 15 | * In step-based mode (i.e. when using the Streaming API), 16 | * indicate whether there are further steps to read or not 17 | * (i.e. the stream is not over or it is). 18 | * 19 | */ 20 | enum class AdvanceStatus : unsigned char 21 | { 22 | OK, ///< stream goes on 23 | OVER, ///< stream is over 24 | RANDOMACCESS ///< there is no stream, it will never be over 25 | }; 26 | 27 | /** 28 | * In step-based mode (i.e. when using the Streaming API), 29 | * stepping/advancing through the Series is performed in terms 30 | * of interleaving begin- and end-step calls. 31 | * Distinguish both kinds by using this enum. 32 | * 33 | */ 34 | enum class AdvanceMode : unsigned char 35 | { 36 | BEGINSTEP, 37 | ENDSTEP 38 | }; 39 | 40 | /** 41 | * Used in step-based mode (i.e. when using the Streaming API) 42 | * to determine whether a step is currently active or not. 43 | * 44 | */ 45 | enum class StepStatus : unsigned char 46 | { 47 | DuringStep, /* step is currently active */ 48 | OutOfStep, /* steps used, but currently no step active */ 49 | NoStep /* no step is currently active */ 50 | }; 51 | } // namespace openPMD 52 | -------------------------------------------------------------------------------- /include/openPMD/ThrowError.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "openPMD/auxiliary/Export.hpp" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace openPMD::error 31 | { 32 | enum class AffectedObject 33 | { 34 | Attribute, 35 | Dataset, 36 | File, 37 | Group, 38 | Other 39 | }; 40 | 41 | enum class Reason 42 | { 43 | NotFound, 44 | CannotRead, 45 | UnexpectedContent, 46 | Inaccessible, 47 | Other 48 | }; 49 | 50 | [[noreturn]] OPENPMDAPI_EXPORT void 51 | throwBackendConfigSchema(std::vector jsonPath, std::string what); 52 | 53 | [[noreturn]] OPENPMDAPI_EXPORT void throwOperationUnsupportedInBackend( 54 | std::string backend, std::string const &what); 55 | 56 | [[noreturn]] OPENPMDAPI_EXPORT void throwReadError( 57 | AffectedObject affectedObject, 58 | Reason reason_in, 59 | std::optional backend, 60 | std::string description_in); 61 | 62 | [[noreturn]] OPENPMDAPI_EXPORT void 63 | throwNoSuchAttribute(std::string attributeName); 64 | } // namespace openPMD::error 65 | -------------------------------------------------------------------------------- /include/openPMD/UndefDatatypeMacros.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2023 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #undef OPENPMD_FOREACH_DATATYPE 23 | #undef OPENPMD_FOREACH_NONVECTOR_DATATYPE 24 | #undef OPENPMD_FOREACH_DATASET_DATATYPE 25 | -------------------------------------------------------------------------------- /include/openPMD/UnitDimension.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2020-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace openPMD 29 | { 30 | 31 | using UnitDimensionExponent = double; 32 | 33 | /** Physical dimension of a record 34 | * 35 | * Dimensional base quantities of the international system of quantities 36 | */ 37 | enum class UnitDimension : uint8_t 38 | { 39 | L = 0, //!< length 40 | M, //!< mass 41 | T, //!< time 42 | I, //!< electric current 43 | theta, //!< thermodynamic temperature 44 | N, //!< amount of substance 45 | J //!< luminous intensity 46 | }; 47 | 48 | namespace unit_representations 49 | { 50 | using AsMap = std::map; 51 | using AsArray = std::array; 52 | 53 | using AsMaps = std::vector; 54 | using AsArrays = std::vector; 55 | 56 | auto asArray(AsMap const &) -> AsArray; 57 | auto asMap(AsArray const &, bool skip_zeros = true) -> AsMap; 58 | 59 | auto asArrays(AsMaps const &) -> AsArrays; 60 | auto asMaps(AsArrays const &, bool skip_zeros = true) -> AsMaps; 61 | 62 | namespace auxiliary 63 | { 64 | void fromMapOfUnitDimension( 65 | double *cursor, std::map const &udim); 66 | } // namespace auxiliary 67 | } // namespace unit_representations 68 | } // namespace openPMD 69 | -------------------------------------------------------------------------------- /include/openPMD/WriteIterations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // legacy header 4 | 5 | #include "openPMD/snapshots/Snapshots.hpp" 6 | -------------------------------------------------------------------------------- /include/openPMD/auxiliary/Date.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2020-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace openPMD 26 | { 27 | namespace auxiliary 28 | { 29 | /** Return the current datetime as string 30 | * 31 | * @param format time format string, @see 32 | * http://www.cplusplus.com/reference/ctime/strftime/ 33 | * @return std::string with formatted date 34 | */ 35 | std::string 36 | getDateString(std::string const &format = std::string("%F %T %z")); 37 | } // namespace auxiliary 38 | } // namespace openPMD 39 | -------------------------------------------------------------------------------- /include/openPMD/auxiliary/DerefDynamicCast.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2020-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace openPMD 26 | { 27 | namespace auxiliary 28 | { 29 | /** Returns a value reference stored in a dynamically casted pointer 30 | * 31 | * Safe version of *dynamic_cast< New_Type* >( some_ptr ); This function 32 | * will throw as dynamic_cast and will furthermore throw if the result 33 | * of the dynamic_cast is a nullptr. 34 | * 35 | * @tparam New_Type new type to cast to 36 | * @tparam Old_Type old type to cast from 37 | * @param[in] ptr and input pointer type 38 | * @return value reference of a dereferenced, dynamically casted ptr to 39 | * New_Type* 40 | */ 41 | template 42 | inline New_Type &deref_dynamic_cast(Old_Type *ptr) 43 | { 44 | auto const tmp_ptr = dynamic_cast(ptr); 45 | if (tmp_ptr == nullptr) 46 | throw std::runtime_error("Dynamic cast returned a nullptr!"); 47 | return *tmp_ptr; 48 | } 49 | 50 | } // namespace auxiliary 51 | } // namespace openPMD 52 | -------------------------------------------------------------------------------- /include/openPMD/auxiliary/Environment.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018-2021 Franz Poeschel, Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace openPMD 31 | { 32 | namespace auxiliary 33 | { 34 | inline std::string 35 | getEnvString(std::string const &key, std::string const defaultValue) 36 | { 37 | char const *env = std::getenv(key.c_str()); 38 | if (env != nullptr) 39 | return std::string{env}; 40 | else 41 | return defaultValue; 42 | } 43 | 44 | inline int getEnvNum(std::string const &key, int defaultValue) 45 | { 46 | char const *env = std::getenv(key.c_str()); 47 | if (env != nullptr) 48 | { 49 | std::string env_string{env}; 50 | try 51 | { 52 | return std::stoi(env_string); 53 | } 54 | catch (std::invalid_argument const &) 55 | { 56 | return defaultValue; 57 | } 58 | } 59 | else 60 | return defaultValue; 61 | } 62 | } // namespace auxiliary 63 | } // namespace openPMD 64 | -------------------------------------------------------------------------------- /include/openPMD/auxiliary/Export.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2020-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #ifndef OPENPMDAPI_EXPORT 24 | #ifdef _MSC_VER 25 | #define OPENPMDAPI_EXPORT __declspec(dllexport) 26 | #elif defined(__NVCC__) 27 | #define OPENPMDAPI_EXPORT 28 | #else 29 | #define OPENPMDAPI_EXPORT __attribute__((visibility("default"))) 30 | #endif 31 | #endif 32 | 33 | #ifndef OPENPMDAPI_EXPORT_ENUM_CLASS 34 | #if defined(__GNUC__) && (__GNUC__ < 6) && !defined(__clang__) && \ 35 | !defined(__INTEL_COMPILER) 36 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43407 37 | #define OPENPMDAPI_EXPORT_ENUM_CLASS(ECNAME) \ 38 | enum class ECNAME : OPENPMDAPI_EXPORT unsigned int 39 | #else 40 | #define OPENPMDAPI_EXPORT_ENUM_CLASS(ECNAME) enum class OPENPMDAPI_EXPORT ECNAME 41 | #endif 42 | #endif 43 | -------------------------------------------------------------------------------- /include/openPMD/backend/ParsePreference.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2023 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | namespace openPMD::internal 25 | { 26 | enum class ParsePreference : char 27 | { 28 | UpFront, //. 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/backend/BaseRecord.hpp" 24 | #include "openPMD/backend/PatchRecordComponent.hpp" 25 | 26 | #include 27 | #include 28 | 29 | namespace openPMD 30 | { 31 | class PatchRecord : public BaseRecord 32 | { 33 | friend class Container; 34 | friend class ParticleSpecies; 35 | friend class ParticlePatches; 36 | 37 | public: 38 | PatchRecord &setUnitDimension(std::map const &); 39 | ~PatchRecord() override = default; 40 | 41 | private: 42 | PatchRecord() = default; 43 | 44 | void 45 | flush_impl(std::string const &, internal::FlushParams const &) override; 46 | void read(); 47 | }; // PatchRecord 48 | } // namespace openPMD 49 | -------------------------------------------------------------------------------- /include/openPMD/benchmark/mpi/BlockSlicer.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018-2021 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "openPMD/Dataset.hpp" 25 | 26 | namespace openPMD 27 | { 28 | /** 29 | * Abstract class to associate a thread with its local cuboid in the total 30 | * cuboid. 31 | */ 32 | class BlockSlicer 33 | { 34 | public: 35 | /** 36 | * Associate the current thread with its cuboid. 37 | * @param totalExtent The total extent of the cuboid. 38 | * @param size The number of threads to be used (not greater than MPI size). 39 | * @param rank The MPI rank. 40 | * @return A pair of the cuboid's offset and extent. 41 | */ 42 | virtual std::pair 43 | sliceBlock(Extent &totalExtent, int size, int rank) = 0; 44 | 45 | /** This class will be derived from 46 | */ 47 | virtual ~BlockSlicer() = default; 48 | }; 49 | } // namespace openPMD 50 | -------------------------------------------------------------------------------- /include/openPMD/benchmark/mpi/OneDimensionalBlockSlicer.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018-2021 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "openPMD/Dataset.hpp" 25 | #include "openPMD/benchmark/mpi/BlockSlicer.hpp" 26 | 27 | namespace openPMD 28 | { 29 | class OneDimensionalBlockSlicer : public BlockSlicer 30 | { 31 | public: 32 | Extent::value_type m_dim; 33 | 34 | explicit OneDimensionalBlockSlicer(Extent::value_type dim = 0); 35 | 36 | std::pair 37 | sliceBlock(Extent &totalExtent, int size, int rank) override; 38 | }; 39 | } // namespace openPMD 40 | -------------------------------------------------------------------------------- /include/openPMD/binding/python/auxiliary.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2025 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "openPMD/binding/python/Common.hpp" 25 | 26 | namespace auxiliary 27 | { 28 | auto json_dumps(py::object const &obj) -> std::string; 29 | 30 | /* 31 | * Functor is a struct of the form: 32 | * 33 | * struct Functor 34 | * { 35 | * template 36 | * static void call(... any kind of argument ...); 37 | * }; 38 | * 39 | * The variadic parameter pack (Types) specifies types which to supply for T. 40 | * 41 | * ForEachTypeNested::call(...args...) will then 42 | * call Functor::template call() for each type T in T1, T2, ... 43 | * one after another. 44 | */ 45 | template 46 | struct ForEachType; 47 | 48 | template 49 | struct ForEachType 50 | { 51 | template 52 | static void call(Args &&...args) 53 | { 54 | Functor::template call(args...); 55 | ForEachType::template call( 56 | std::forward(args)...); 57 | } 58 | }; 59 | 60 | template 61 | struct ForEachType 62 | { 63 | template 64 | static constexpr void call(Args &&...) 65 | { /* no-op */ 66 | } 67 | }; 68 | } // namespace auxiliary 69 | -------------------------------------------------------------------------------- /include/openPMD/config.hpp.in: -------------------------------------------------------------------------------- 1 | /* Copyright 2019-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #ifndef openPMD_HAS_CXX17 24 | #cmakedefine01 openPMD_HAS_CXX17 25 | #endif 26 | 27 | #ifndef openPMD_HAVE_MPI 28 | #cmakedefine01 openPMD_HAVE_MPI 29 | #endif 30 | 31 | #define openPMD_HAVE_JSON 1 32 | 33 | #ifndef openPMD_HAVE_HDF5 34 | #cmakedefine01 openPMD_HAVE_HDF5 35 | #endif 36 | 37 | #ifndef openPMD_HAVE_ADIOS1 38 | #define openPMD_HAVE_ADIOS1 0 39 | #endif 40 | 41 | #ifndef openPMD_HAVE_ADIOS2 42 | #cmakedefine01 openPMD_HAVE_ADIOS2 43 | #endif 44 | 45 | #ifndef openPMD_HAVE_CUDA_EXAMPLES 46 | #cmakedefine01 openPMD_HAVE_CUDA_EXAMPLES 47 | #endif 48 | -------------------------------------------------------------------------------- /include/openPMD/helper/list_series.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #pragma once 22 | 23 | #include "openPMD/Series.hpp" 24 | 25 | #include 26 | #include 27 | 28 | namespace openPMD 29 | { 30 | namespace helper 31 | { 32 | /** List information about an openPMD data series 33 | * 34 | * @param series a openPMD data path as in Series::Series 35 | * @param longer write more information 36 | * @param out an output stream to write textual information to 37 | * @return reference to out as output stream, e.g. to pass the stream on via 38 | * `operator<<` 39 | */ 40 | std::ostream &listSeries( 41 | Series &series, 42 | bool const longer = false, 43 | std::ostream &out = std::cout); 44 | } // namespace helper 45 | } // namespace openPMD 46 | -------------------------------------------------------------------------------- /include/openPMD/snapshots/IteratorHelpers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "openPMD/Iteration.hpp" 4 | #include "openPMD/snapshots/StatefulIterator.hpp" 5 | 6 | namespace openPMD 7 | { 8 | using value_type = 9 | Container::value_type; 10 | auto stateful_to_opaque(StatefulIterator const &it) 11 | -> OpaqueSeriesIterator; 12 | } // namespace openPMD 13 | -------------------------------------------------------------------------------- /openPMD.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix}/@CMAKE_INSTALL_BINDIR@ 3 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 5 | static=@openPMD_PC_STATIC@ 6 | 7 | Name: openPMD 8 | Description: C++ & Python API for Scientific I/O with openPMD. 9 | Version: @openPMD_VERSION@ 10 | URL: https://openpmd-api.readthedocs.io 11 | 12 | Libs: -L${libdir} -lopenPMD @openPMD_PC_PUBLIC_LIBS@ 13 | Libs.private: -L${libdir} @openPMD_PC_PRIVATE_LIBS@ 14 | Cflags: -I${includedir} @openPMD_PC_EXTRA_INCLUDE@ @openPMD_PC_PUBLIC_DEFINES@ 15 | -------------------------------------------------------------------------------- /openPMDConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # only add PUBLIC dependencies as well 2 | # https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-a-package-configuration-file 3 | include(CMakeFindDependencyMacro) 4 | 5 | # Search in _ROOT: 6 | # https://cmake.org/cmake/help/v3.12/policy/CMP0074.html 7 | if(POLICY CMP0074) 8 | cmake_policy(SET CMP0074 NEW) 9 | endif() 10 | 11 | # locate the installed CMake modules 12 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules") 13 | 14 | # optional dependencies 15 | set(openPMD_HAVE_MPI @openPMD_HAVE_MPI@) 16 | if(openPMD_HAVE_MPI) 17 | find_dependency(MPI) 18 | # deselect parallel installs if explicitly a serial install is requested 19 | set(openPMD_NOMPI_FOUND FALSE) 20 | else() 21 | set(openPMD_NOMPI_FOUND TRUE) 22 | endif() 23 | set(openPMD_MPI_FOUND ${openPMD_HAVE_MPI}) 24 | 25 | set(openPMD_HAVE_HDF5 @openPMD_HAVE_HDF5@) 26 | if(openPMD_HAVE_HDF5) 27 | set(HDF5_PREFER_PARALLEL ${openPMD_HAVE_MPI}) 28 | find_dependency(HDF5) 29 | endif() 30 | set(openPMD_HDF5_FOUND ${openPMD_HAVE_HDF5}) 31 | 32 | set(openPMD_HAVE_ADIOS2 @openPMD_HAVE_ADIOS2@) 33 | if(openPMD_HAVE_ADIOS2) 34 | set(openPMD_REQUIRED_ADIOS2_COMPONENTS CXX) 35 | if(openPMD_HAVE_MPI) 36 | LIST(APPEND openPMD_REQUIRED_ADIOS2_COMPONENTS MPI) 37 | endif() 38 | find_dependency(ADIOS2 COMPONENTS ${openPMD_REQUIRED_ADIOS2_COMPONENTS}) 39 | unset(openPMD_REQUIRED_ADIOS2_COMPONENTS) 40 | endif() 41 | set(openPMD_ADIOS2_FOUND ${openPMD_HAVE_ADIOS2}) 42 | 43 | # define central openPMD::openPMD target 44 | include("${CMAKE_CURRENT_LIST_DIR}/openPMDTargets.cmake") 45 | 46 | # check if components are fulfilled and set openPMD__FOUND vars 47 | foreach(comp ${openPMD_FIND_COMPONENTS}) 48 | if(NOT openPMD_${comp}_FOUND) 49 | if(openPMD_FIND_REQUIRED_${comp}) 50 | set(openPMD_FOUND FALSE) 51 | endif() 52 | endif() 53 | endforeach() 54 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "wheel", 5 | "cmake>=3.22.0,<4.0.0", 6 | "packaging>=23", 7 | "pybind11>=2.13.0,<3.0.0" 8 | ] 9 | build-backend = "setuptools.build_meta" 10 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | numpy>=1.15.0 2 | -------------------------------------------------------------------------------- /share/openPMD/download_samples.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | set -eu -o pipefail 4 | 5 | # build directory as optional first argument, otherwise $PWD 6 | # we assume PWD is inside the CMake build directory 7 | bdir=${1:-$(pwd)} 8 | 9 | orgdir=$(pwd) 10 | mkdir -p ${bdir} 11 | cd ${bdir} 12 | 13 | mkdir -p samples/git-sample/thetaMode 14 | mkdir -p samples/git-sample/3d-bp4 15 | 16 | curl -sOL https://github.com/openPMD/openPMD-example-datasets/raw/f3b73e43511db96217a153dc3ab3cb2e8f81f7db/example-3d.tar.gz 17 | curl -sOL https://github.com/openPMD/openPMD-example-datasets/raw/f3b73e43511db96217a153dc3ab3cb2e8f81f7db/example-thetaMode.tar.gz 18 | curl -sOL https://github.com/openPMD/openPMD-example-datasets/raw/f3b73e43511db96217a153dc3ab3cb2e8f81f7db/example-3d-bp4.tar.gz 19 | curl -sOL https://github.com/openPMD/openPMD-example-datasets/raw/566b356030df38f56049484941baacafef331163/legacy_datasets.tar.gz 20 | tar -xzf example-3d.tar.gz 21 | tar -xzf example-thetaMode.tar.gz 22 | tar -xzf example-3d-bp4.tar.gz 23 | tar -xzf legacy_datasets.tar.gz 24 | mv example-3d/hdf5/* samples/git-sample/ 25 | mv example-thetaMode/hdf5/* samples/git-sample/thetaMode/ 26 | mv example-3d-bp4/* samples/git-sample/3d-bp4 27 | mv legacy_datasets/* samples/git-sample/legacy 28 | chmod 777 samples/ 29 | rm -rf example-3d.* example-3d example-thetaMode.* example-thetaMode example-3d-bp4 example-3d-bp4.* legacy_datasets legacy_datasets.* 30 | 31 | # Ref.: https://github.com/yt-project/yt/pull/1645 32 | mkdir -p samples/issue-sample/ 33 | curl -sOL https://github.com/yt-project/yt/files/1542668/no_fields.zip 34 | unzip no_fields.zip 35 | mv no_fields samples/issue-sample/ 36 | curl -sOL https://github.com/yt-project/yt/files/1542670/no_particles.zip 37 | unzip no_particles.zip 38 | mv no_particles samples/issue-sample/ 39 | rm -rf no_fields.zip no_particles.zip 40 | 41 | # Ref.: https://github.com/openPMD/openPMD-viewer/issues/296 42 | curl -sOL https://github.com/openPMD/openPMD-viewer/files/5655027/diags.zip 43 | unzip diags.zip 44 | mv diags/hdf5/data00000050.h5 samples/issue-sample/empty_alternate_fbpic_00000050.h5 45 | rm -rf diags.zip diags 46 | 47 | # make sure we do not need write access when reading data 48 | chmod u-w samples/git-sample/*.h5 49 | chmod u-w samples/git-sample/thetaMode/*.h5 50 | chmod u-w samples/issue-sample/*.h5 51 | chmod u-w samples/issue-sample/no_fields/*.h5 52 | chmod u-w samples/issue-sample/no_particles/*.h5 53 | find samples/git-sample/3d-bp4 -type f -exec chmod u-w {} \; 54 | 55 | cd ${orgdir} 56 | -------------------------------------------------------------------------------- /share/openPMD/validate_files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | 4 | set -eu -o pipefail 5 | 6 | # create a temporary build directory 7 | tmp_dir=$(mktemp --help >/dev/null 2>&1 && mktemp -d -t ci-XXXXXXXXXX || mktemp -d "${TMPDIR:-/tmp}"/ci-XXXXXXXXXX) 8 | if [ $? -ne 0 ]; then 9 | echo "Cannot create a temporary directory" 10 | exit 2 11 | fi 12 | mkdir -p ${tmp_dir} 13 | 14 | # Call the cleanup function 15 | function cleanvenv { 16 | echo 17 | echo "Cleaning ... ${tmp_dir}" 18 | set +u 19 | deactivate 20 | set -u 21 | rm -rf ${tmp_dir}/venv-validator 22 | echo "Done" 23 | } 24 | trap cleanvenv EXIT 25 | 26 | # Install openPMD-validator 27 | python3 -m venv ${tmp_dir}/venv-validator 28 | set +u 29 | source ${tmp_dir}/venv-validator/bin/activate 30 | set -u 31 | python3 -m pip install git+https://github.com/openPMD/openPMD-validator.git@1.1.X 32 | 33 | # Check HDF5 Files 34 | # skip intentionally invalid sample files 35 | fignore=("issue-sample/no_particles/" "issue-sample/no_fields/") 36 | h5files=$(find . -name "*.h5") 37 | for f in ${h5files} 38 | do 39 | echo 40 | ok=0 41 | for fi in ${fignore[@]} 42 | do 43 | if [[ "${f}" == *"${fi}"* ]]; then 44 | ok=1 45 | break 46 | fi 47 | done 48 | if [[ ${ok} -ne 0 ]]; then 49 | echo "Skipping \"${f}\" ..." 50 | continue 51 | fi 52 | 53 | echo "Checking \"${f}\" ..." 54 | openPMD_check_h5 -i ${f} 55 | done 56 | -------------------------------------------------------------------------------- /spack.yaml: -------------------------------------------------------------------------------- 1 | # This is a Spack environment file. 2 | # 3 | # Activating and installing this environment will provide all dependencies 4 | # that are needed for full-feature development. 5 | # https//spack.readthedocs.io/en/latest/environments.html#anonymous-environments 6 | # 7 | spack: 8 | specs: 9 | - adios~sz 10 | - adios2 11 | - cmake 12 | - hdf5 13 | - mpi 14 | - python 15 | - py-mpi4py 16 | - py-numpy 17 | - py-pandas 18 | - py-dask 19 | - py-pre-commit 20 | -------------------------------------------------------------------------------- /src/IO/Access.cpp: -------------------------------------------------------------------------------- 1 | #include "openPMD/IO/Access.hpp" 2 | 3 | #include 4 | #include 5 | 6 | namespace openPMD 7 | { 8 | std::ostream &operator<<(std::ostream &o, Access const &a) 9 | { 10 | switch (a) 11 | { 12 | case Access::READ_RANDOM_ACCESS: 13 | o << std::string("READ_RANDOM_ACCESS"); 14 | break; 15 | case Access::READ_LINEAR: 16 | o << std::string("READ_LINEAR"); 17 | break; 18 | case Access::READ_WRITE: 19 | o << std::string("READ_WRITE"); 20 | break; 21 | case Access::CREATE: 22 | o << std::string("CREATE"); 23 | break; 24 | case Access::APPEND: 25 | o << std::string("APPEND"); 26 | break; 27 | } 28 | return o; 29 | } 30 | } // namespace openPMD 31 | -------------------------------------------------------------------------------- /src/IO/DummyIOHandler.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller, Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/IO/DummyIOHandler.hpp" 22 | #include "openPMD/auxiliary/JSON_internal.hpp" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace openPMD 29 | { 30 | DummyIOHandler::DummyIOHandler(std::string path, Access at) 31 | : AbstractIOHandler( 32 | std::nullopt, 33 | std::move(path), 34 | at, 35 | json::TracingJSON( 36 | nlohmann::json::object(), json::SupportedLanguages::JSON)) 37 | {} 38 | 39 | void DummyIOHandler::enqueue(IOTask const &) 40 | {} 41 | 42 | std::future DummyIOHandler::flush(internal::ParsedFlushParams &) 43 | { 44 | return std::future(); 45 | } 46 | 47 | std::string DummyIOHandler::backendName() const 48 | { 49 | return "Dummy"; 50 | } 51 | } // namespace openPMD 52 | -------------------------------------------------------------------------------- /src/IO/FlushParams.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #include "openPMD/IO/FlushParametersInternal.hpp" 23 | 24 | namespace openPMD::internal 25 | { 26 | ParsedFlushParams::ParsedFlushParams(FlushParams const &flushParams) 27 | : flushLevel(flushParams.flushLevel) 28 | , backendConfig( 29 | json::parseOptions( 30 | flushParams.backendConfig, /* considerFiles = */ false)) 31 | {} 32 | } // namespace openPMD::internal 33 | -------------------------------------------------------------------------------- /src/IO/JSON/JSONFilePosition.cpp: -------------------------------------------------------------------------------- 1 | #include "openPMD/IO/JSON/JSONFilePosition.hpp" 2 | 3 | #include 4 | 5 | namespace openPMD 6 | { 7 | JSONFilePosition::JSONFilePosition(json::json_pointer ptr) : id(std::move(ptr)) 8 | {} 9 | } // namespace openPMD 10 | -------------------------------------------------------------------------------- /src/IO/JSON/JSONIOHandler.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #include "openPMD/IO/JSON/JSONIOHandler.hpp" 23 | 24 | namespace openPMD 25 | { 26 | JSONIOHandler::~JSONIOHandler() = default; 27 | 28 | JSONIOHandler::JSONIOHandler( 29 | std::optional> initialize_from, 30 | std::string path, 31 | Access at, 32 | openPMD::json::TracingJSON jsonCfg, 33 | JSONIOHandlerImpl::FileFormat format, 34 | std::string originalExtension) 35 | : AbstractIOHandler{std::move(initialize_from), std::move(path), at, std::move(jsonCfg)} 36 | , m_impl{this, format, std::move(originalExtension)} 37 | {} 38 | 39 | #if openPMD_HAVE_MPI 40 | JSONIOHandler::JSONIOHandler( 41 | std::optional> initialize_from, 42 | std::string path, 43 | Access at, 44 | MPI_Comm comm, 45 | openPMD::json::TracingJSON jsonCfg, 46 | JSONIOHandlerImpl::FileFormat format, 47 | std::string originalExtension) 48 | : AbstractIOHandler{std::move(initialize_from), std::move(path), at, std::move(jsonCfg)} 49 | , m_impl{ 50 | JSONIOHandlerImpl{this, comm, format, std::move(originalExtension)}} 51 | {} 52 | #endif 53 | 54 | std::future JSONIOHandler::flush(internal::ParsedFlushParams &) 55 | { 56 | return m_impl.flush(); 57 | } 58 | } // namespace openPMD 59 | -------------------------------------------------------------------------------- /src/IterationEncoding.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/IterationEncoding.hpp" 22 | 23 | #include 24 | 25 | std::ostream & 26 | openPMD::operator<<(std::ostream &os, openPMD::IterationEncoding const &ie) 27 | { 28 | switch (ie) 29 | { 30 | case openPMD::IterationEncoding::fileBased: 31 | os << "fileBased"; 32 | break; 33 | case openPMD::IterationEncoding::groupBased: 34 | os << "groupBased"; 35 | break; 36 | case openPMD::IterationEncoding::variableBased: 37 | os << "variableBased"; 38 | break; 39 | } 40 | return os; 41 | } 42 | -------------------------------------------------------------------------------- /src/ReadIterations.cpp: -------------------------------------------------------------------------------- 1 | #include "openPMD/ReadIterations.hpp" 2 | #include "openPMD/snapshots/IteratorHelpers.hpp" 3 | #include "openPMD/snapshots/StatefulIterator.hpp" 4 | 5 | namespace openPMD 6 | { 7 | LegacyIteratorAdaptor::LegacyIteratorAdaptor(Snapshots::iterator iterator) 8 | : m_iterator(std::move(iterator)) 9 | {} 10 | 11 | auto LegacyIteratorAdaptor::operator*() const -> value_type 12 | { 13 | return m_iterator.operator*(); 14 | } 15 | 16 | auto LegacyIteratorAdaptor::operator++() -> LegacyIteratorAdaptor & 17 | { 18 | ++m_iterator; 19 | return *this; 20 | } 21 | 22 | auto LegacyIteratorAdaptor::operator==(LegacyIteratorAdaptor const &other) const 23 | -> bool 24 | { 25 | return m_iterator == other.m_iterator; 26 | } 27 | 28 | auto LegacyIteratorAdaptor::operator!=(LegacyIteratorAdaptor const &other) const 29 | -> bool 30 | { 31 | return m_iterator != other.m_iterator; 32 | } 33 | 34 | ReadIterations::ReadIterations( 35 | Series series, 36 | Access access, 37 | std::optional parsePreference) 38 | : m_series(std::move(series)), m_parsePreference(parsePreference) 39 | { 40 | auto &data = m_series.get(); 41 | if (access == Access::READ_LINEAR && !data.m_sharedStatefulIterator) 42 | { 43 | // Open the iterator now already, so that metadata may already be read 44 | data.m_sharedStatefulIterator = std::make_unique( 45 | StatefulIterator::tag_read, m_series, m_parsePreference); 46 | } 47 | } 48 | 49 | auto ReadIterations::begin() -> iterator_t 50 | { 51 | auto &series = m_series.get(); 52 | if (!series.m_sharedStatefulIterator) 53 | { 54 | series.m_sharedStatefulIterator = std::make_unique( 55 | StatefulIterator::tag_read, m_series, m_parsePreference); 56 | } 57 | return stateful_to_opaque(*series.m_sharedStatefulIterator); 58 | } 59 | 60 | auto ReadIterations::end() -> iterator_t 61 | { 62 | return stateful_to_opaque(StatefulIterator::end()); 63 | } 64 | } // namespace openPMD 65 | -------------------------------------------------------------------------------- /src/UnitDimension.cpp: -------------------------------------------------------------------------------- 1 | #include "openPMD/UnitDimension.hpp" 2 | #include 3 | #include 4 | 5 | namespace openPMD::unit_representations 6 | { 7 | auto asArray(AsMap const &udim) -> AsArray 8 | { 9 | AsArray res{}; 10 | auxiliary::fromMapOfUnitDimension(res.data(), udim); 11 | return res; 12 | } 13 | auto asMap(AsArray const &array, bool skip_zeros) -> AsMap 14 | { 15 | AsMap udim; 16 | for (size_t i = 0; i < array.size(); ++i) 17 | { 18 | if (!skip_zeros || array[i] != 0) 19 | { 20 | udim[static_cast(i)] = array[i]; 21 | } 22 | } 23 | return udim; 24 | } 25 | 26 | auto asArrays(AsMaps const &vec) -> AsArrays 27 | { 28 | AsArrays res; 29 | res.reserve(vec.size()); 30 | std::transform( 31 | vec.begin(), vec.end(), std::back_inserter(res), [](auto const &map) { 32 | return asArray(map); 33 | }); 34 | return res; 35 | } 36 | auto asMaps(AsArrays const &vec, bool skip_zeros) -> AsMaps 37 | { 38 | AsMaps res; 39 | res.reserve(vec.size()); 40 | std::transform( 41 | vec.begin(), 42 | vec.end(), 43 | std::back_inserter(res), 44 | [&](auto const &array) { return asMap(array, skip_zeros); }); 45 | return res; 46 | } 47 | 48 | namespace auxiliary 49 | { 50 | void fromMapOfUnitDimension( 51 | double *cursor, std::map const &udim) 52 | { 53 | for (auto [unit, exponent] : udim) 54 | { 55 | cursor[static_cast(unit)] = exponent; 56 | } 57 | } 58 | } // namespace auxiliary 59 | } // namespace openPMD::unit_representations 60 | -------------------------------------------------------------------------------- /src/auxiliary/Date.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2020-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/auxiliary/Date.hpp" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace openPMD::auxiliary 29 | { 30 | std::string getDateString(std::string const &format) 31 | { 32 | constexpr size_t maxLen = 30u; 33 | std::array buffer; 34 | 35 | time_t rawtime; 36 | time(&rawtime); 37 | struct tm *timeinfo; 38 | // https://github.com/openPMD/openPMD-api/pull/657#issuecomment-574424885 39 | timeinfo = localtime(&rawtime); // lgtm[cpp/potentially-dangerous-function] 40 | 41 | strftime(buffer.data(), maxLen, format.c_str(), timeinfo); 42 | 43 | std::stringstream dateString; 44 | dateString << buffer.data(); 45 | 46 | return dateString.str(); 47 | } 48 | } // namespace openPMD::auxiliary 49 | -------------------------------------------------------------------------------- /src/backend/PatchRecordComponent.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017-2021 Fabian Koller 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/backend/PatchRecordComponent.hpp" 22 | #include "openPMD/RecordComponent.hpp" 23 | #include "openPMD/auxiliary/Memory.hpp" 24 | #include "openPMD/backend/BaseRecord.hpp" 25 | 26 | #include 27 | 28 | namespace openPMD 29 | { 30 | 31 | PatchRecordComponent &PatchRecordComponent::setUnitSI(double usi) 32 | { 33 | setAttribute("unitSI", usi); 34 | return *this; 35 | } 36 | 37 | uint8_t PatchRecordComponent::getDimensionality() const 38 | { 39 | return 1; 40 | } 41 | 42 | Extent PatchRecordComponent::getExtent() const 43 | { 44 | auto &rc = get(); 45 | if (rc.m_dataset.has_value()) 46 | { 47 | return rc.m_dataset.value().extent; 48 | } 49 | else 50 | { 51 | return {1}; 52 | } 53 | } 54 | 55 | PatchRecordComponent::PatchRecordComponent( 56 | BaseRecord const &baseRecord) 57 | : RecordComponent(NoInit()) 58 | { 59 | static_cast(*this).operator=(baseRecord); 60 | } 61 | 62 | PatchRecordComponent::PatchRecordComponent() : RecordComponent(NoInit()) 63 | { 64 | setData(std::make_shared()); 65 | setUnitSI(1); 66 | } 67 | 68 | PatchRecordComponent::PatchRecordComponent(NoInit) : RecordComponent(NoInit()) 69 | {} 70 | } // namespace openPMD 71 | -------------------------------------------------------------------------------- /src/binding/python/BaseRecordComponent.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/backend/BaseRecordComponent.hpp" 22 | #include "openPMD/Datatype.hpp" 23 | 24 | #include "openPMD/binding/python/Common.hpp" 25 | #include "openPMD/binding/python/Container.H" 26 | #include "openPMD/binding/python/Numpy.hpp" 27 | 28 | #include 29 | 30 | void init_BaseRecordComponent(py::module &m) 31 | { 32 | py::class_( 33 | m, "Base_Record_Component", py::multiple_inheritance()) 34 | .def( 35 | "__repr__", 36 | [](BaseRecordComponent const &brc) { 37 | std::stringstream ss; 38 | ss << ""; 40 | return ss.str(); 41 | }) 42 | 43 | .def("reset_datatype", &BaseRecordComponent::resetDatatype) 44 | .def("available_chunks", &BaseRecordComponent::availableChunks) 45 | 46 | .def_property_readonly("unit_SI", &BaseRecordComponent::unitSI) 47 | .def_property_readonly("constant", &BaseRecordComponent::constant) 48 | .def_property_readonly("dtype", [](BaseRecordComponent &brc) { 49 | return dtype_to_numpy(brc.getDatatype()); 50 | }); 51 | } 52 | -------------------------------------------------------------------------------- /src/binding/python/Error.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019-2023 The openPMD Community 2 | * 3 | * This header is used to centrally define classes that shall not violate the 4 | * C++ one-definition-rule (ODR) for various Python translation units. 5 | * 6 | * Authors: Franz Poeschel, Axel Huebl 7 | * License: LGPL-3.0-or-later 8 | */ 9 | #include "openPMD/Error.hpp" 10 | 11 | #include "openPMD/binding/python/Common.hpp" 12 | 13 | void init_Error(py::module &m) 14 | { 15 | auto &baseError = py::register_exception(m, "Error"); 16 | py::register_exception( 17 | m, "ErrorOperationUnsupportedInBackend", baseError); 18 | py::register_exception( 19 | m, "ErrorWrongAPIUsage", baseError); 20 | py::register_exception( 21 | m, "ErrorBackendConfigSchema", baseError); 22 | py::register_exception(m, "ErrorInternal", baseError); 23 | py::register_exception( 24 | m, "ErrorNoSuchAttribute", baseError); 25 | py::register_exception( 26 | m, "ErrorIllegalInOpenPMDStandard", baseError); 27 | 28 | #ifndef NDEBUG 29 | m.def("test_throw", [](std::string description) { 30 | throw error::OperationUnsupportedInBackend("json", description); 31 | }); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /src/binding/python/Helper.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/Series.hpp" 22 | #include "openPMD/cli/ls.hpp" 23 | #include "openPMD/helper/list_series.hpp" 24 | 25 | #include "openPMD/binding/python/Common.hpp" 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | void init_Helper(py::module &m) 32 | { 33 | m.def( 34 | "list_series", 35 | [](Series &series, bool const longer) { 36 | std::stringstream s; 37 | helper::listSeries(series, longer, s); 38 | py::print(s.str()); 39 | }, 40 | py::arg("series"), 41 | py::arg("longer") = false, 42 | "List information about an openPMD data series") 43 | // CLI entry point 44 | .def( 45 | "_ls_run", // &cli::ls::run 46 | [](std::vector &argv) { return cli::ls::run(argv); }); 47 | } 48 | -------------------------------------------------------------------------------- /src/binding/python/IterationEncoding.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/IterationEncoding.hpp" 22 | 23 | #include "openPMD/binding/python/Common.hpp" 24 | 25 | void init_IterationEncoding(py::module &m) 26 | { 27 | py::enum_(m, "Iteration_Encoding") 28 | .value("file_based", IterationEncoding::fileBased) 29 | .value("group_based", IterationEncoding::groupBased) 30 | .value("variable_based", IterationEncoding::variableBased); 31 | } 32 | -------------------------------------------------------------------------------- /src/binding/python/ParticlePatches.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/ParticlePatches.hpp" 22 | #include "openPMD/backend/Attributable.hpp" 23 | #include "openPMD/backend/Container.hpp" 24 | #include "openPMD/backend/PatchRecord.hpp" 25 | 26 | #include "openPMD/binding/python/Common.hpp" 27 | #include "openPMD/binding/python/Container.H" 28 | 29 | #include 30 | 31 | void init_ParticlePatches(py::module &m) 32 | { 33 | auto py_pp_cnt = declare_container( 34 | m, "Particle_Patches_Container"); 35 | 36 | py::class_ >(m, "Particle_Patches") 37 | .def( 38 | "__repr__", 39 | [](ParticlePatches const &pp) { 40 | std::stringstream stream; 41 | stream << ""; 44 | return stream.str(); 45 | }) 46 | 47 | .def_property_readonly("num_patches", &ParticlePatches::numPatches); 48 | 49 | finalize_container(py_pp_cnt); 50 | } 51 | -------------------------------------------------------------------------------- /src/binding/python/PatchRecord.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/backend/PatchRecord.hpp" 22 | 23 | #include "openPMD/backend/Attributable.hpp" 24 | #include "openPMD/backend/BaseRecord.hpp" 25 | #include "openPMD/backend/PatchRecordComponent.hpp" 26 | 27 | #include "openPMD/binding/python/Common.hpp" 28 | #include "openPMD/binding/python/Container.H" 29 | #include "openPMD/binding/python/UnitDimension.hpp" 30 | 31 | void init_PatchRecord(py::module &m) 32 | { 33 | auto py_pr_cnt = declare_container( 34 | m, "Patch_Record_Container"); 35 | 36 | py::class_ >( 37 | m, "Patch_Record") 38 | .def_property( 39 | "unit_dimension", 40 | &PatchRecord::unitDimension, 41 | &PatchRecord::setUnitDimension, 42 | python::doc_unit_dimension) 43 | 44 | // TODO remove in future versions (deprecated) 45 | .def("set_unit_dimension", &PatchRecord::setUnitDimension); 46 | 47 | finalize_container(py_pr_cnt); 48 | } 49 | -------------------------------------------------------------------------------- /src/binding/python/UnitDimension.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/UnitDimension.hpp" 22 | 23 | #include "openPMD/binding/python/Common.hpp" 24 | 25 | void init_UnitDimension(py::module &m) 26 | { 27 | py::enum_(m, "Unit_Dimension") 28 | .value("L", UnitDimension::L) 29 | .value("M", UnitDimension::M) 30 | .value("T", UnitDimension::T) 31 | .value("I", UnitDimension::I) 32 | .value("theta", UnitDimension::theta) 33 | .value("N", UnitDimension::N) 34 | .value("J", UnitDimension::J) 35 | .def( 36 | "as_index", 37 | [](UnitDimension ud) -> uint8_t { 38 | return static_cast(ud); 39 | }) 40 | .def( 41 | "from_index", 42 | [](uint8_t idx) -> UnitDimension { 43 | return static_cast(idx); 44 | }) 45 | .def("as_array", &unit_representations::asArray) 46 | .def( 47 | "as_map", 48 | &unit_representations::asMap, 49 | py::arg("skip_zeros") = true) 50 | .def("as_arrays", &unit_representations::asArrays) 51 | .def( 52 | "as_maps", 53 | &unit_representations::asMaps, 54 | py::arg("skip_zeros") = true); 55 | } 56 | -------------------------------------------------------------------------------- /src/binding/python/auxiliary.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2025 Franz Poeschel 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #include "openPMD/binding/python/auxiliary.hpp" 23 | 24 | namespace auxiliary 25 | { 26 | auto json_dumps(py::object const &obj) -> std::string 27 | { 28 | py::module_ json = py::module_::import("json"); 29 | auto dumps = json.attr("dumps"); 30 | auto dumped = dumps(obj); 31 | return py::cast(dumped); 32 | } 33 | } // namespace auxiliary 34 | -------------------------------------------------------------------------------- /src/binding/python/openpmd_api/__init__.py: -------------------------------------------------------------------------------- 1 | from . import openpmd_api_cxx as cxx 2 | from .DaskArray import record_component_to_daskarray 3 | from .DaskDataFrame import particles_to_daskdataframe 4 | from .DataFrame import (iterations_to_cudf, iterations_to_dataframe, 5 | particles_to_dataframe) 6 | from .openpmd_api_cxx import * # noqa 7 | 8 | __version__ = cxx.__version__ 9 | __doc__ = cxx.__doc__ 10 | __license__ = cxx.__license__ 11 | # __author__ = cxx.__author__ 12 | 13 | # extend CXX classes with extra methods 14 | ParticleSpecies.to_df = particles_to_dataframe # noqa 15 | ParticleSpecies.to_dask = particles_to_daskdataframe # noqa 16 | Record_Component.to_dask_array = record_component_to_daskarray # noqa 17 | Series.to_df = iterations_to_dataframe # noqa 18 | Series.to_cudf = iterations_to_cudf # noqa 19 | 20 | # TODO remove in future versions (deprecated) 21 | Access_Type = Access # noqa 22 | -------------------------------------------------------------------------------- /src/binding/python/openpmd_api/ls/__init__.py: -------------------------------------------------------------------------------- 1 | __doc__ = "for usage documentation, call this module's main with --help" 2 | -------------------------------------------------------------------------------- /src/binding/python/openpmd_api/ls/__main__.py: -------------------------------------------------------------------------------- 1 | """ 2 | This file is part of the openPMD-api. 3 | 4 | This module provides functions that are wrapped into sys.exit(...()) calls by 5 | the setuptools (setup.py) "entry_points" -> "console_scripts" generator. 6 | 7 | Copyright 2020-2021 openPMD contributors 8 | Authors: Axel Huebl 9 | License: LGPLv3+ 10 | """ 11 | import sys 12 | 13 | from ..openpmd_api_cxx import _ls_run 14 | 15 | 16 | def main(): 17 | """ for usage documentation, call this with a --help argument """ 18 | return _ls_run(sys.argv) 19 | 20 | 21 | if __name__ == "__main__": 22 | sys.exit(main()) 23 | -------------------------------------------------------------------------------- /src/binding/python/openpmd_api/pipe/__init__.py: -------------------------------------------------------------------------------- 1 | __doc__ = "for usage documentation, call this module's main with --help" 2 | -------------------------------------------------------------------------------- /src/cli/ls.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | 22 | #include "openPMD/cli/ls.hpp" 23 | 24 | #include 25 | #include 26 | 27 | int main(int argc, char *argv[]) 28 | { 29 | std::vector str_argv; 30 | str_argv.reserve(argc); 31 | for (int i = 0; i < argc; ++i) 32 | str_argv.emplace_back(argv[i]); 33 | 34 | return openPMD::cli::ls::run(str_argv); 35 | } 36 | -------------------------------------------------------------------------------- /src/cli/pipe.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | This file is part of the openPMD-api. 4 | 5 | This module provides functions that are wrapped into sys.exit(...()) calls by 6 | the setuptools (setup.py) "entry_points" -> "console_scripts" generator. 7 | 8 | Copyright 2021 openPMD contributors 9 | Authors: Franz Poeschel 10 | License: LGPLv3+ 11 | """ 12 | import sys 13 | 14 | import openpmd_api.pipe.__main__ as pipe 15 | 16 | if __name__ == "__main__": 17 | pipe.main() 18 | sys.exit() 19 | -------------------------------------------------------------------------------- /src/config.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2020-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/config.hpp" 22 | #include "openPMD/version.hpp" 23 | 24 | #if openPMD_HAVE_ADIOS2 25 | #include "openPMD/IO/ADIOS/macros.hpp" 26 | #include 27 | #endif 28 | #include 29 | #include 30 | #include 31 | 32 | // @todo add TOML here 33 | std::map openPMD::getVariants() 34 | { 35 | // clang-format off 36 | return std::map{ 37 | {"mpi", bool(openPMD_HAVE_MPI)}, 38 | {"json", true}, 39 | // https://github.com/ToruNiina/toml11/issues/205 40 | #if !defined(__NVCOMPILER_MAJOR__) || __NVCOMPILER_MAJOR__ >= 23 41 | {"toml", true}, 42 | #endif 43 | {"hdf5", bool(openPMD_HAVE_HDF5)}, 44 | {"adios1", false}, 45 | {"adios2", bool(openPMD_HAVE_ADIOS2)}}; 46 | // clang-format on 47 | } 48 | 49 | std::vector openPMD::getFileExtensions() 50 | { 51 | std::vector fext; 52 | fext.emplace_back("json"); 53 | // https://github.com/ToruNiina/toml11/issues/205 54 | #if !defined(__NVCOMPILER_MAJOR__) || __NVCOMPILER_MAJOR__ >= 23 55 | fext.emplace_back("toml"); 56 | #endif 57 | #if openPMD_HAVE_ADIOS2 58 | fext.emplace_back("bp"); 59 | #endif 60 | #if openPMD_HAVE_ADIOS2 61 | // BP4 is always available in ADIOS2 62 | fext.emplace_back("bp4"); 63 | #endif 64 | #if openPMD_HAVE_ADIOS2_BP5 65 | fext.emplace_back("bp5"); 66 | #endif 67 | #ifdef ADIOS2_HAVE_SST 68 | fext.emplace_back("sst"); 69 | #endif 70 | #ifdef ADIOS2_HAVE_SSC 71 | fext.emplace_back("ssc"); 72 | #endif 73 | #if openPMD_HAVE_HDF5 74 | fext.emplace_back("h5"); 75 | #endif 76 | return fext; 77 | } 78 | -------------------------------------------------------------------------------- /src/snapshots/IteratorHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "openPMD/snapshots/IteratorHelpers.hpp" 2 | 3 | namespace openPMD 4 | { 5 | using value_type = 6 | Container::value_type; 7 | auto stateful_to_opaque(StatefulIterator const &it) 8 | -> OpaqueSeriesIterator 9 | { 10 | std::unique_ptr> internal_iterator_cloned{ 11 | new StatefulIterator(it)}; 12 | return OpaqueSeriesIterator( 13 | std::move(internal_iterator_cloned)); 14 | } 15 | } // namespace openPMD 16 | -------------------------------------------------------------------------------- /src/snapshots/RandomAccessIterator.cpp: -------------------------------------------------------------------------------- 1 | #include "openPMD/snapshots/RandomAccessIterator.hpp" 2 | namespace openPMD 3 | { 4 | template 5 | inline RandomAccessIterator::RandomAccessIterator(iterator_t it) 6 | : m_it(it) 7 | {} 8 | 9 | template 10 | RandomAccessIterator::~RandomAccessIterator() = default; 11 | 12 | template 13 | auto RandomAccessIterator::operator*() -> value_type & 14 | { 15 | return *m_it; 16 | } 17 | 18 | template 19 | auto RandomAccessIterator::operator*() const -> value_type const & 20 | { 21 | return *m_it; 22 | } 23 | 24 | template 25 | auto RandomAccessIterator::operator++() -> RandomAccessIterator & 26 | { 27 | ++m_it; 28 | return *this; 29 | } 30 | 31 | template 32 | auto RandomAccessIterator::operator--() -> RandomAccessIterator & 33 | { 34 | --m_it; 35 | return *this; 36 | } 37 | 38 | template 39 | auto RandomAccessIterator::operator++(int i) -> RandomAccessIterator 40 | { 41 | return parent_t::default_increment_operator(i); 42 | } 43 | 44 | template 45 | auto RandomAccessIterator::operator--(int i) -> RandomAccessIterator 46 | { 47 | return parent_t::default_decrement_operator(i); 48 | } 49 | 50 | template 51 | auto RandomAccessIterator::operator==( 52 | RandomAccessIterator const &other) const -> bool 53 | { 54 | return m_it == other.m_it; 55 | } 56 | 57 | using iterator = Container::iterator; 58 | using const_iterator = 59 | Container::const_iterator; 60 | using reverse_iterator = 61 | Container::reverse_iterator; 62 | using const_reverse_iterator = 63 | Container::const_reverse_iterator; 64 | template class RandomAccessIterator; 65 | template class RandomAccessIterator; 66 | template class RandomAccessIterator; 67 | template class RandomAccessIterator; 68 | } // namespace openPMD 69 | -------------------------------------------------------------------------------- /src/version.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2020-2021 Axel Huebl 2 | * 3 | * This file is part of openPMD-api. 4 | * 5 | * openPMD-api is free software: you can redistribute it and/or modify 6 | * it under the terms of of either the GNU General Public License or 7 | * the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * openPMD-api is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License and the GNU Lesser General Public License 15 | * for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * and the GNU Lesser General Public License along with openPMD-api. 19 | * If not, see . 20 | */ 21 | #include "openPMD/version.hpp" 22 | 23 | #include 24 | #include 25 | 26 | std::string openPMD::getVersion() 27 | { 28 | std::stringstream api; 29 | api << OPENPMDAPI_VERSION_MAJOR << "." << OPENPMDAPI_VERSION_MINOR << "." 30 | << OPENPMDAPI_VERSION_PATCH; 31 | if (std::string(OPENPMDAPI_VERSION_LABEL).size() > 0) 32 | api << "-" << OPENPMDAPI_VERSION_LABEL; 33 | return api.str(); 34 | } 35 | 36 | std::string openPMD::getStandard() 37 | { 38 | return getStandardMaximum(); 39 | } 40 | 41 | std::string openPMD::getStandardDefault() 42 | { 43 | std::stringstream standard; 44 | standard << OPENPMD_STANDARD_DEFAULT_MAJOR << "." 45 | << OPENPMD_STANDARD_DEFAULT_MINOR << "." 46 | << OPENPMD_STANDARD_DEFAULT_PATCH; 47 | return standard.str(); 48 | } 49 | 50 | std::string openPMD::getStandardMinimum() 51 | { 52 | std::stringstream standardMin; 53 | standardMin << OPENPMD_STANDARD_MIN_MAJOR << "." 54 | << OPENPMD_STANDARD_MIN_MINOR << "." 55 | << OPENPMD_STANDARD_MIN_PATCH; 56 | return standardMin.str(); 57 | } 58 | 59 | std::string openPMD::getStandardMaximum() 60 | { 61 | std::stringstream standard; 62 | standard << OPENPMD_STANDARD_MAJOR << "." << OPENPMD_STANDARD_MINOR << "." 63 | << OPENPMD_STANDARD_PATCH; 64 | return standard.str(); 65 | } 66 | -------------------------------------------------------------------------------- /test/CatchMain.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include 3 | -------------------------------------------------------------------------------- /test/CatchRunner.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_RUNNER 2 | #include 3 | 4 | #if openPMD_HAVE_MPI 5 | #include 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | MPI_Init(&argc, &argv); 10 | 11 | Catch::Session session; 12 | int result = 0; 13 | { 14 | // Indicates a command line parsing 15 | result = session.applyCommandLine(argc, argv); 16 | // RT tests 17 | if (result == 0) 18 | result = session.run(); 19 | } 20 | MPI_Finalize(); 21 | return result; 22 | } 23 | #else 24 | int main(int argc, char *argv[]) 25 | { 26 | Catch::Session session; 27 | int result = 0; 28 | { 29 | // Indicates a command line parsing 30 | result = session.applyCommandLine(argc, argv); 31 | // RT tests 32 | if (result == 0) 33 | result = session.run(); 34 | } 35 | return result; 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /test/Files_Core/CoreTests.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace automatic_variable_encoding 4 | { 5 | auto automatic_variable_encoding() -> void; 6 | } 7 | -------------------------------------------------------------------------------- /test/Files_ParallelIO/ParallelIOTests.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if openPMD_HAVE_MPI 4 | 5 | using namespace openPMD; 6 | 7 | struct BackendSelection 8 | { 9 | std::string backendName; 10 | std::string extension; 11 | 12 | [[nodiscard]] inline std::string jsonBaseConfig() const 13 | { 14 | return R"({"backend": ")" + backendName + "\"}"; 15 | } 16 | }; 17 | 18 | inline std::vector testedBackends() 19 | { 20 | auto variants = getVariants(); 21 | std::map extensions{ 22 | {"adios2", "bp"}, {"hdf5", "h5"}}; 23 | std::vector res; 24 | for (auto const &pair : variants) 25 | { 26 | if (pair.second) 27 | { 28 | auto lookup = extensions.find(pair.first); 29 | if (lookup != extensions.end()) 30 | { 31 | std::string extension = lookup->second; 32 | res.push_back({pair.first, std::move(extension)}); 33 | } 34 | } 35 | } 36 | return res; 37 | } 38 | 39 | inline std::vector getBackends() 40 | { 41 | // first component: backend file ending 42 | // second component: whether to test 128 bit values 43 | std::vector res; 44 | #if openPMD_HAVE_ADIOS2 45 | res.emplace_back("bp"); 46 | #endif 47 | #if openPMD_HAVE_HDF5 48 | res.emplace_back("h5"); 49 | #endif 50 | return res; 51 | } 52 | 53 | inline auto const backends = getBackends(); 54 | 55 | inline std::vector testedFileExtensions() 56 | { 57 | auto allExtensions = getFileExtensions(); 58 | auto newEnd = std::remove_if( 59 | allExtensions.begin(), allExtensions.end(), [](std::string const &ext) { 60 | // sst and ssc need a receiver for testing 61 | // bp4 is already tested via bp 62 | return ext == "sst" || ext == "ssc" || ext == "bp4" || 63 | ext == "toml" || ext == "json"; 64 | }); 65 | return {allExtensions.begin(), newEnd}; 66 | } 67 | 68 | namespace read_variablebased_randomaccess 69 | { 70 | auto read_variablebased_randomaccess() -> void; 71 | } 72 | 73 | namespace iterate_nonstreaming_series 74 | { 75 | auto iterate_nonstreaming_series() -> void; 76 | } 77 | 78 | namespace bug_1655_bp5_writer_hangup 79 | { 80 | auto bug_1655_bp5_writer_hangup() -> void; 81 | } 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /test/Files_ParallelIO/bug_1655_bp5_writer_hangup.cpp: -------------------------------------------------------------------------------- 1 | #include "ParallelIOTests.hpp" 2 | 3 | #include 4 | #include 5 | 6 | namespace bug_1655_bp5_writer_hangup 7 | { 8 | auto worker(std::string const &ext) -> void 9 | { 10 | int mpi_size; 11 | int mpi_rank; 12 | 13 | MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); 14 | MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); 15 | 16 | auto const value = float(mpi_size * 100 + mpi_rank); 17 | std::vector local_data(size_t(10) * 300, value); 18 | 19 | std::string filename = "../samples/ptl_%T." + ext; 20 | 21 | Series series = Series(filename, Access::CREATE, MPI_COMM_WORLD); 22 | 23 | Datatype datatype = determineDatatype(); 24 | 25 | auto myptl = series.writeIterations()[1].particles["ion"]; 26 | Extent global_ptl = {10ul * mpi_size * 300}; 27 | Dataset dataset_ptl = Dataset(datatype, global_ptl, "{}"); 28 | myptl["charge"].resetDataset(dataset_ptl); 29 | 30 | series.flush(); 31 | 32 | if (mpi_rank == 0) // only rank 0 adds data 33 | myptl["charge"].storeChunk(local_data, {0}, {3000}); 34 | 35 | series.flush(); // hangs here 36 | series.close(); 37 | } 38 | 39 | auto bug_1655_bp5_writer_hangup() -> void 40 | { 41 | for (auto const &ext : testedFileExtensions()) 42 | { 43 | worker(ext); 44 | } 45 | } 46 | } // namespace bug_1655_bp5_writer_hangup 47 | -------------------------------------------------------------------------------- /test/Files_SerialIO/SerialIOTests.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace filebased_write_test 4 | { 5 | auto close_and_reopen_iterations(std::string const &filename) -> void; 6 | } 7 | namespace close_and_reopen_test 8 | { 9 | auto close_and_reopen_test() -> void; 10 | } 11 | namespace issue_1744_unique_ptrs_at_close_time 12 | { 13 | auto issue_1744_unique_ptrs_at_close_time() -> void; 14 | } 15 | -------------------------------------------------------------------------------- /test/Files_SerialIO/issue_1744_unique_ptrs_at_close_time.cpp: -------------------------------------------------------------------------------- 1 | #include "SerialIOTests.hpp" 2 | 3 | #include "openPMD/Dataset.hpp" 4 | #include "openPMD/openPMD.hpp" 5 | 6 | #include 7 | #include 8 | 9 | // clang-format off 10 | /* 11 | * Tests regression introduced with #1743: 12 | * terminate called after throwing an instance of 'openPMD::error::Internal' 13 | * what(): Internal error: [ADIOS2 backend] Orphaned unique-ptr put operations found when closing file. 14 | * This is a bug. Please report at ' https://github.com/openPMD/openPMD-api/issues'. 15 | */ 16 | // clang-format on 17 | 18 | namespace issue_1744_unique_ptrs_at_close_time 19 | { 20 | auto issue_1744_unique_ptrs_at_close_time() -> void 21 | { 22 | openPMD::Series write( 23 | "../samples/issue_1744_unique_ptrs_at_close_time.bp4", 24 | openPMD::Access::CREATE, 25 | R"({"iteration_encoding": "group_based"})"); 26 | std::unique_ptr data_unique(new int[10]); 27 | std::iota(data_unique.get(), data_unique.get() + 10, 0); 28 | auto E_x = write.snapshots()[0].meshes["E"]["x"]; 29 | E_x.resetDataset({openPMD::Datatype::INT, {10}}); 30 | E_x.storeChunk(std::move(data_unique), {0}, {10}); 31 | write.close(); 32 | } 33 | } // namespace issue_1744_unique_ptrs_at_close_time 34 | -------------------------------------------------------------------------------- /test/python/unittest/API/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openPMD/openPMD-api/42595a052e8292ed7d09a1d4679760e8fd196e07/test/python/unittest/API/__init__.py -------------------------------------------------------------------------------- /test/python/unittest/Test.py: -------------------------------------------------------------------------------- 1 | """ 2 | This file is part of the openPMD-api. 3 | 4 | Copyright 2018-2021 openPMD contributors 5 | Authors: Axel Huebl, Carsten Fortmann-Grote 6 | License: LGPLv3+ 7 | """ 8 | 9 | import sys 10 | import unittest 11 | 12 | # Import suites to run. 13 | from API.APITest import APITest 14 | 15 | 16 | # Define the test suite. 17 | def suite(): 18 | test_loader = unittest.TestLoader() 19 | env_name = "OPENPMD_PYTHON_TEST_PREFIX" 20 | from os import environ 21 | if env_name in environ: 22 | test_loader.testMethodPrefix = environ[env_name] 23 | suites = [ 24 | test_loader.loadTestsFromTestCase(testCaseClass=APITest), 25 | ] 26 | 27 | return unittest.TestSuite(suites) 28 | 29 | 30 | # Run the top level suite and return a success status code. 31 | # This enables running an automated git-bisect. 32 | if __name__ == "__main__": 33 | 34 | result = unittest.TextTestRunner(verbosity=2).run(suite()) 35 | 36 | if result.wasSuccessful(): 37 | print('---> OK <---') 38 | sys.exit(0) 39 | 40 | sys.exit(1) 41 | -------------------------------------------------------------------------------- /test/python/unittest/TestUtilities/TestUtilities.py: -------------------------------------------------------------------------------- 1 | """ 2 | This file is part of the openPMD-api. 3 | 4 | Copyright 2018-2021 openPMD contributors 5 | Authors: Axel Huebl, Carsten Fortmann-Grote 6 | License: LGPLv3+ 7 | """ 8 | 9 | from os import path 10 | 11 | 12 | def generateTestFilePath(file_name): 13 | """ 14 | Returns the absolute path to a test file located in ../TestFiles. 15 | 16 | @param file_name : The name of the file in ../TestFiles. 17 | @return : The absolute path to ../TestFiles/ . 18 | """ 19 | 20 | test_files_dir = path.join('..', 'samples', file_name) 21 | return test_files_dir 22 | 23 | # this_path = path.abspath(path.dirname(__file__)) 24 | # parent_dir = path.pardir 25 | # test_files_path = path.abspath( 26 | # path.join( 27 | # this_path, parent_dir, test_files_dir 28 | # ) 29 | # ) 30 | 31 | # return path.join(test_files_path, file_name) 32 | -------------------------------------------------------------------------------- /test/python/unittest/TestUtilities/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openPMD/openPMD-api/42595a052e8292ed7d09a1d4679760e8fd196e07/test/python/unittest/TestUtilities/__init__.py -------------------------------------------------------------------------------- /test/python/unittest/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openPMD/openPMD-api/42595a052e8292ed7d09a1d4679760e8fd196e07/test/python/unittest/__init__.py --------------------------------------------------------------------------------