mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Use dataset_ndims and object_exists from C++
This commit is contained in:
parent
ad3bb0b43a
commit
422edace49
3 changed files with 32 additions and 17 deletions
|
|
@ -331,11 +331,18 @@ contains
|
|||
character(*), intent(in) :: name ! name of group
|
||||
logical :: exists
|
||||
|
||||
integer :: hdf5_err ! HDF5 error code
|
||||
interface
|
||||
function object_exists_c(obj_id, name) result(exists) &
|
||||
bind(C, name='object_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 object_exists_c
|
||||
end interface
|
||||
|
||||
! Check if group exists
|
||||
call h5ltpath_valid_f(object_id, trim(name), .true., exists, hdf5_err)
|
||||
|
||||
exists = object_exists_c(object_id, to_c_string(name))
|
||||
end function object_exists
|
||||
|
||||
!===============================================================================
|
||||
|
|
@ -1475,20 +1482,15 @@ contains
|
|||
integer(HID_T), intent(in) :: obj_id
|
||||
integer, intent(out) :: ndims
|
||||
|
||||
integer :: hdf5_err
|
||||
integer :: type
|
||||
integer(HID_T) :: space_id
|
||||
interface
|
||||
function dataset_ndims(dset) result(ndims) bind(C)
|
||||
import HID_T, C_INT
|
||||
integer(HID_T), value :: dset
|
||||
integer(C_INT) :: ndims
|
||||
end function dataset_ndims
|
||||
end interface
|
||||
|
||||
call h5iget_type_f(obj_id, type, hdf5_err)
|
||||
if (type == H5I_DATASET_F) then
|
||||
call h5dget_space_f(obj_id, space_id, hdf5_err)
|
||||
call h5sget_simple_extent_ndims_f(space_id, ndims, hdf5_err)
|
||||
call h5sclose_f(space_id, hdf5_err)
|
||||
elseif (type == H5I_ATTR_F) then
|
||||
call h5aget_space_f(obj_id, space_id, hdf5_err)
|
||||
call h5sget_simple_extent_ndims_f(space_id, ndims, hdf5_err)
|
||||
call h5sclose_f(space_id, hdf5_err)
|
||||
end if
|
||||
ndims = dataset_ndims(obj_id)
|
||||
end subroutine get_ndims
|
||||
|
||||
function using_mpio_device(obj_id) result(mpio)
|
||||
|
|
|
|||
|
|
@ -69,12 +69,14 @@ create_group(hid_t parent_id, char const *name)
|
|||
return out;
|
||||
}
|
||||
|
||||
|
||||
hid_t
|
||||
create_group(hid_t parent_id, const std::string &name)
|
||||
{
|
||||
return create_group(parent_id, name.c_str());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
close_dataset(hid_t dataset_id)
|
||||
{
|
||||
|
|
@ -89,6 +91,16 @@ close_group(hid_t group_id)
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
dataset_ndims(hid_t dset)
|
||||
{
|
||||
hid_t dspace = H5Dget_space(dset);
|
||||
int ndims = H5Sget_simple_extent_ndims(dspace);
|
||||
H5Sclose(dspace);
|
||||
return ndims;
|
||||
}
|
||||
|
||||
|
||||
hid_t
|
||||
file_open(const char* filename, char mode, bool parallel)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,12 +15,13 @@ hid_t create_group(hid_t parent_id, const char* name);
|
|||
hid_t create_group(hid_t parent_id, const std::string& name);
|
||||
void close_dataset(hid_t dataset_id);
|
||||
void close_group(hid_t group_id);
|
||||
extern "C" int dataset_ndims(hid_t dset);
|
||||
extern "C" hid_t file_open(const char* filename, char mode, bool parallel);
|
||||
hid_t file_open(const std::string& filename, char mode, bool parallel);
|
||||
extern "C" void file_close(hid_t file_id);
|
||||
extern "C" void get_shape(hid_t obj_if, hsize_t* dims);
|
||||
extern "C" void get_shape_attr(hid_t obj_if, const char* name, hsize_t* dims);
|
||||
bool object_exists(hid_t object_id, const char* name);
|
||||
extern "C" bool object_exists(hid_t object_id, const char* name);
|
||||
hid_t open_dataset(hid_t group_id, const char* name);
|
||||
hid_t open_group(hid_t group_id, const char* name);
|
||||
bool using_mpio_device(hid_t obj_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue