mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Convert HDF5 attribute_exists to C++
This commit is contained in:
parent
b8635f1c2b
commit
1cb46effda
3 changed files with 20 additions and 5 deletions
|
|
@ -332,7 +332,7 @@ contains
|
|||
end subroutine get_groups
|
||||
|
||||
!===============================================================================
|
||||
! CHECK_ATTRIBUTE Checks to see if an attribute exists in the object
|
||||
! ATTRIBUTE_EXISTS checks to see if an attribute exists in the object
|
||||
!===============================================================================
|
||||
|
||||
function attribute_exists(object_id, name) result(exists)
|
||||
|
|
@ -340,11 +340,17 @@ contains
|
|||
character(*), intent(in) :: name ! name of group
|
||||
logical :: exists
|
||||
|
||||
integer :: hdf5_err ! HDF5 error code
|
||||
|
||||
! Check if attribute exists
|
||||
call h5aexists_by_name_f(object_id, '.', trim(name), exists, hdf5_err)
|
||||
interface
|
||||
function attribute_exists_c(obj_id, name) result(exists) &
|
||||
bind(C, name='attribute_exists')
|
||||
import HID_T, C_CHAR, C_BOOL
|
||||
integer(HID_T), value :: obj_id
|
||||
character(kind=C_CHAR), intent(in) :: name(*)
|
||||
logical(C_BOOL) :: exists
|
||||
end function attribute_exists_c
|
||||
end interface
|
||||
|
||||
exists = attribute_exists_c(object_id, to_c_string(name))
|
||||
end function attribute_exists
|
||||
|
||||
!===============================================================================
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
bool
|
||||
attribute_exists(hid_t obj_id, const char* name)
|
||||
{
|
||||
htri_t out = H5Aexists_by_name(obj_id, ".", name, H5P_DEFAULT);
|
||||
return out > 0;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
using_mpio_device(hid_t obj_id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
extern "C" bool attribute_exists(hid_t obj_id, const char* name);
|
||||
extern "C" hid_t create_group(hid_t parent_id, const char* name);
|
||||
hid_t create_group(hid_t parent_id, const std::string& name);
|
||||
extern "C" void close_dataset(hid_t dataset_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue