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