Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_k_hdf5_ser_read_attribute.F90
Go to the documentation of this file.
1 integer(hid_t) :: loc_id
2 integer(hid_t) :: attr_id
3 integer(hsize_t) :: dims(1)
4 type(h5o_info_t) :: object_info
5 
6 dims = int([1], hsize_t)
7 
8 ! Inquire about type of object in target path: group or dataset?
9 call h5oget_info_by_name_f(handle%file_id, objpath, object_info, error)
10 sll_assert_always(error == 0)
11 
12 ! Open existing group or dataset
13 select case (object_info%type)
14 case (h5o_type_group)
15  call h5gopen_f(handle%file_id, objpath, loc_id, error)
16  sll_assert_always(error == 0)
17 case (h5o_type_dataset)
18  call h5dopen_f(handle%file_id, objpath, loc_id, error)
19  sll_assert_always(error == 0)
20 end select
21 
22 ! Open existing scalar attribute
23 call h5aopen_f(loc_id, attrname, attr_id, error)
24 sll_assert_always(error == 0)
25 
26 ! Read attribute
27 call h5aread_f(attr_id, datatype, attrvalue, dims, error)
28 sll_assert_always(error == 0)
29 
30 ! Close attribute
31 call h5aclose_f(attr_id, error)
32 sll_assert_always(error == 0)
33 
34 ! Close existing group or dataset
35 select case (object_info%type)
36 case (h5o_type_group)
37  call h5gclose_f(loc_id, error)
38  sll_assert_always(error == 0)
39 case (h5o_type_dataset)
40  call h5dclose_f(loc_id, error)
41  sll_assert_always(error == 0)
42 end select
    Report Typos and Errors