Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_k_hdf5_par_write_array.F90
Go to the documentation of this file.
1 integer(hid_t) :: plist_id
2 integer(hid_t) :: dset_id
3 integer(hid_t) :: memspace
4 integer(hid_t) :: filespace
5 integer(hsize_t) :: dimsfi(dspace_dims)
6 integer(hsize_t) :: block(dspace_dims)
7 integer(hsize_t) :: start(dspace_dims)
8 integer(hsize_t) :: count(dspace_dims)
9 integer(hsize_t) :: stride(dspace_dims)
10 integer :: rank
11 
12 ! Basic dataset parameters
13 rank = dspace_dims
14 count = 1
15 stride = 1
16 
17 ! Integer kind type conversions
18 dimsfi = int(global_size, hsize_t)
19 block = int(shape(array), hsize_t)
20 start = int(offset, hsize_t)
21 
22 !
23 ! Create dataspaces ('file space' and 'memory space').
24 !
25 call h5screate_simple_f(rank, dimsfi, filespace, error)
26 sll_assert_always(error == 0)
27 
28 call h5screate_simple_f(rank, block, memspace, error)
29 sll_assert_always(error == 0)
30 
31 !
32 ! Create dataset.
33 !
34 call h5pcreate_f(h5p_dataset_create_f, plist_id, error)
35 sll_assert_always(error == 0)
36 
37 !
38 ! If required, use chunked layout
39 !
40 if (present(chunk_dims)) then
41  call h5pset_chunk_f(plist_id, rank, chunk_dims, error)
42  sll_assert_always(error == 0)
43 end if
44 
45 call h5dcreate_f(handle%file_id, dsetname, datatype, filespace, &
46  dset_id, error, plist_id)
47 sll_assert_always(error == 0)
48 
49 call h5pclose_f(plist_id, error)
50 sll_assert_always(error == 0)
51 
52 call h5sclose_f(filespace, error)
53 sll_assert_always(error == 0)
54 
55 !
56 ! Each process defines dataset in memory and writes it to the hyperslab
57 ! in the file.
58 !
59 ! Select hyperslab in the file.
60 !
61 call h5dget_space_f(dset_id, filespace, error)
62 sll_assert_always(error == 0)
63 
64 call h5sselect_hyperslab_f(filespace, h5s_select_set_f, &
65  start, count, error, stride, block)
66 sll_assert_always(error == 0)
67 
68 !
69 ! Initialize data buffer with trivial data.
70 !
71 !
72 ! Create property list for collective dataset write
73 !
74 call h5pcreate_f(h5p_dataset_xfer_f, plist_id, error)
75 sll_assert_always(error == 0)
76 
77 call h5pset_dxpl_mpio_f(plist_id, h5fd_mpio_collective_f, error)
78 sll_assert_always(error == 0)
79 
80 !
81 ! Write the dataset collectively.
82 !
83 call h5dwrite_f(dset_id, datatype, array, dimsfi, error, &
84  file_space_id=filespace, mem_space_id=memspace, &
85  xfer_prp=plist_id)
86 sll_assert_always(error == 0)
87 
88 !
89 ! Close the property list.
90 !
91 call h5pclose_f(plist_id, error)
92 sll_assert_always(error == 0)
93 
94 !
95 ! Close dataspaces.
96 !
97 call h5sclose_f(filespace, error)
98 sll_assert_always(error == 0)
99 
100 call h5sclose_f(memspace, error)
101 sll_assert_always(error == 0)
102 
103 !
104 ! Close the dataset.
105 !
106 call h5dclose_f(dset_id, error)
107 sll_assert_always(error == 0)
    Report Typos and Errors