Convert HDF5 attribute_exists to C++

This commit is contained in:
Paul Romano 2018-04-19 11:07:27 -05:00
parent b8635f1c2b
commit 1cb46effda
3 changed files with 20 additions and 5 deletions

View file

@ -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
!===============================================================================

View file

@ -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)
{

View file

@ -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);