PB3D [2.47]
Ideal linear high-n MHD stability in 3-D
Loading...
Searching...
No Matches
HDF5_vars.f90
Go to the documentation of this file.
1!------------------------------------------------------------------------------!
2!> Variables pertaining to HDF5 and XDMF.
3!------------------------------------------------------------------------------!
5#include <PB3D_macros.h>
7 use messages
9 use hdf5
10
11 implicit none
12 private
17
18 ! global variables
19 integer, parameter :: max_xml_ln = 300 !< max. length of xml string
20 character(len=6) :: xmf_fmt = '(999A)' !< format to write the xmf file
21 integer, parameter :: max_dim_var_1d = 100000 !< maximum dimension of var_1D
22
23 ! XDMF possibilities
24 character(len=max_str_ln) :: xdmf_num_types(2) !< possible XDMF number types
25 character(len=max_str_ln) :: xdmf_format_types(2) !< possible XDMF format types
26 character(len=max_str_ln) :: xdmf_geom_types(2) !< possible XDMF geometry types
27 character(len=max_str_ln) :: xdmf_top_types(2) !< possible XDMF topology types
28 character(len=max_str_ln) :: xdmf_att_types(2) !< possible XDMF attribute types
29 character(len=max_str_ln) :: xdmf_center_types(2) !< possible XDMF attribute center types
30 character(len=max_str_ln) :: xdmf_grid_types(3) !< possible XDMF grid types
31
32 !> XML strings used in XDMF
33 type, public :: xml_str_type
34 character(len=max_str_ln) :: name !< name of this item
35 integer :: max_xml_ln = 300 !< max. length of xml string
36 character(len=max_xml_ln), allocatable :: xml_str(:) !< XML string
37 end type xml_str_type
38
39 !> HDF5 data type, containing the information about HDF5 files.
40 type, public :: hdf5_file_type
41 integer(HID_T) :: hdf5_i !< HDF5 file handle
42 integer :: xdmf_i !< XDMF file handle
43 character(len=max_str_ln) :: name !< name of files (without extensions ".h5" and ".xmf")
44 end type hdf5_file_type
45
46 !> 1D equivalent of multidimensional variables, used for internal HDF5
47 !! storage.
48 type, public :: var_1d_type
49 real(dp), allocatable :: p(:) !< 1D equivalent of data of variable
50 integer, allocatable :: tot_i_min(:) !< total min.of indices of variable
51 integer, allocatable :: tot_i_max(:) !< total max.of indices of variable
52 integer, allocatable :: loc_i_min(:) !< group min.of indices of variable
53 integer, allocatable :: loc_i_max(:) !< group max.of indices of variable
54 character(len=max_str_ln) :: var_name !< name of variable
55 end type var_1d_type
56
57 ! interfaces
58
59 !> \public Deallocates XML_str_type.
61 !> \public
62 module procedure dealloc_xml_str_ind
63 !> \public
64 module procedure dealloc_xml_str_arr
65 end interface
66
67 !> \public Deallocates 1D variable.
69 !> \public
70 module procedure dealloc_var_1d_ind
71 !> \public
72 module procedure dealloc_var_1d_arr
73 !> \public
74 module procedure dealloc_var_1d_arr_2
75 end interface
76
77contains
78 !> Initializes the HDF5 types.
79 !!
80 !! Has to be called once.
81 subroutine init_hdf5
82 ! XDMF_num_types
83 xdmf_num_types(1) = "Int"
84 xdmf_num_types(2) = "Float"
85
86 ! XDMF_format_types
87 xdmf_format_types(1) = "XML"
88 xdmf_format_types(2) = "HD5"
89
90 ! XDMF_geom_types
91 xdmf_geom_types(1) = "X_Y"
92 xdmf_geom_types(2) = "X_Y_Z"
93
94 ! XDMF_top_types
95 xdmf_top_types(1) = "2DSMesh"
96 xdmf_top_types(2) = "3DSMesh"
97
98 ! XDMF_att_types
99 xdmf_att_types(1) = "Scalar"
100 xdmf_att_types(2) = "Vector"
101
102 ! XDMF_center_types
103 xdmf_center_types(1) = "Node"
104 xdmf_center_types(2) = "Cell"
105
106 ! XDMF_grid_types
107 xdmf_grid_types(1) = "None"
108 xdmf_grid_types(2) = "Temporal"
109 xdmf_grid_types(3) = "Spatial"
110 end subroutine init_hdf5
111
112 !> \private array version
113 subroutine dealloc_xml_str_arr(XML_str)
114 ! input / output
115 type(xml_str_type), intent(inout), allocatable :: XML_str(:) !> array of XML strings to be deallocated
116
117 ! local variables
118 integer :: id ! counter
119
120 ! deallocate individual arrays
121 do id = 1,size(xml_str)
122 call dealloc_xml_str_ind(xml_str(id))
123 end do
124
125 ! deallocate the array
126 deallocate(xml_str)
127 end subroutine dealloc_xml_str_arr
128 !> \private individual version
129 subroutine dealloc_xml_str_ind(XML_str)
130 ! input / output
131 type(xml_str_type), intent(out) :: XML_str !< XML string to be deallocated
132 end subroutine dealloc_xml_str_ind
133
134 !> \private rank 2 array version
135 subroutine dealloc_var_1d_arr_2(var_1D)
136 ! input / output
137 type(var_1d_type), intent(inout), allocatable :: var_1D(:,:) !< array of 1D variables to be deallocated
138
139 ! local variables
140 integer :: id, jd ! counters
141
142 ! deallocate individual arrays
143 do jd = 1,size(var_1d,2)
144 do id = 1,size(var_1d,1)
145 call dealloc_var_1d_ind(var_1d(id,jd))
146 end do
147 end do
148
149 ! deallocate the array
150 deallocate(var_1d)
151 end subroutine dealloc_var_1d_arr_2
152 !> \private array version
153 subroutine dealloc_var_1d_arr(var_1D)
154 ! input / output
155 type(var_1d_type), intent(inout), allocatable :: var_1D(:) !< array of 1D variables to be deallocated
156
157 ! local variables
158 integer :: id ! counter
159
160 ! deallocate individual arrays
161 do id = 1,size(var_1d)
162 call dealloc_var_1d_ind(var_1d(id))
163 end do
164
165 ! deallocate the array
166 deallocate(var_1d)
167 end subroutine dealloc_var_1d_arr
168 !> \private individual version
169 subroutine dealloc_var_1d_ind(var_1D)
170 ! input / output
171 type(var_1d_type), intent(out) :: var_1D !< 1D variable to be deallocated
172 end subroutine dealloc_var_1d_ind
173end module hdf5_vars
Deallocates 1D variable.
Definition HDF5_vars.f90:68
Deallocates XML_str_type.
Definition HDF5_vars.f90:60
Variables pertaining to HDF5 and XDMF.
Definition HDF5_vars.f90:4
character(len=max_str_ln), dimension(2), public xdmf_att_types
possible XDMF attribute types
Definition HDF5_vars.f90:28
integer, parameter, public max_dim_var_1d
maximum dimension of var_1D
Definition HDF5_vars.f90:21
character(len=max_str_ln), dimension(2), public xdmf_center_types
possible XDMF attribute center types
Definition HDF5_vars.f90:29
subroutine, public init_hdf5
Initializes the HDF5 types.
Definition HDF5_vars.f90:82
character(len=max_str_ln), dimension(3), public xdmf_grid_types
possible XDMF grid types
Definition HDF5_vars.f90:30
character(len=max_str_ln), dimension(2), public xdmf_format_types
possible XDMF format types
Definition HDF5_vars.f90:25
character(len=max_str_ln), dimension(2), public xdmf_geom_types
possible XDMF geometry types
Definition HDF5_vars.f90:26
character(len=max_str_ln), dimension(2), public xdmf_top_types
possible XDMF topology types
Definition HDF5_vars.f90:27
character(len=6), public xmf_fmt
format to write the xmf file
Definition HDF5_vars.f90:20
character(len=max_str_ln), dimension(2), public xdmf_num_types
possible XDMF number types
Definition HDF5_vars.f90:24
Numerical utilities related to giving output.
Definition messages.f90:4
Numerical variables used by most other modules.
Definition num_vars.f90:4
integer, parameter, public dp
double precision
Definition num_vars.f90:46
character(len=7), public script_dir
directory where to save scripts for plots
Definition num_vars.f90:154
integer, parameter, public max_str_ln
maximum length of strings
Definition num_vars.f90:50
character(len=5), public plot_dir
directory where to save plots
Definition num_vars.f90:153
character(len=4), public data_dir
directory where to save data for plots
Definition num_vars.f90:155
Operations on strings.
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
elemental character(len=max_str_ln) function, public r2str(k)
Convert a real (double) to string.
elemental character(len=max_str_ln) function, public r2strt(k)
Convert a real (double) to string.
HDF5 data type, containing the information about HDF5 files.
Definition HDF5_vars.f90:40
1D equivalent of multidimensional variables, used for internal HDF5 storage.
Definition HDF5_vars.f90:48
XML strings used in XDMF.
Definition HDF5_vars.f90:33