diff --git a/src/aero_particle.F90 b/src/aero_particle.F90 index c706e01a..050aa858 100644 --- a/src/aero_particle.F90 +++ b/src/aero_particle.F90 @@ -479,4 +479,19 @@ subroutine f_aero_particle_n_orig_part( & end subroutine + subroutine f_aero_particle_id( & + aero_particle_ptr_c, & + id & + ) bind(C) + + type(aero_particle_t), pointer :: aero_particle_ptr_f => null() + type(c_ptr), intent(in) :: aero_particle_ptr_c + integer(c_int), intent(out) :: id + + call c_f_pointer(aero_particle_ptr_c, aero_particle_ptr_f) + + id = aero_particle_ptr_f%id + + end subroutine + end module diff --git a/src/aero_particle.hpp b/src/aero_particle.hpp index 2a9a1b8f..e2be6c2a 100644 --- a/src/aero_particle.hpp +++ b/src/aero_particle.hpp @@ -41,6 +41,7 @@ extern "C" void f_aero_particle_asymmetry(const void *aero_particle_ptr, double extern "C" void f_aero_particle_greatest_create_time(const void *aero_particle_ptr, double *val) noexcept; extern "C" void f_aero_particle_least_create_time(const void *aero_particle_ptr, double *val) noexcept; extern "C" void f_aero_particle_n_orig_part(const void *aero_particle_ptr, void *arr_data, const int *arr_size) noexcept; +extern "C" void f_aero_particle_id(const void *aero_particle_ptr, int *val) noexcept; namespace py = pybind11; struct AeroParticle { @@ -335,4 +336,13 @@ struct AeroParticle { return val; } + static auto id(const AeroParticle &self) { + int val; + f_aero_particle_id( + self.ptr.f_arg(), + &val + ); + return val; + } + }; diff --git a/src/pypartmc.cpp b/src/pypartmc.cpp index 6a45ca94..76e921c1 100644 --- a/src/pypartmc.cpp +++ b/src/pypartmc.cpp @@ -141,6 +141,7 @@ PYBIND11_MODULE(_PyPartMC, m) { "First time a constituent was created (s).") .def_property_readonly("greatest_create_time", AeroParticle::greatest_create_time, "Last time a constituent was created (s).") + .def_property_readonly("id", AeroParticle::id, "Unique ID number.") .def("mobility_diameter", AeroParticle::mobility_diameter, "Mobility diameter of the particle (m).") .def_property_readonly("density", AeroParticle::density,