PB3D  [2.45]
Ideal linear high-n MHD stability in 3-D
HDF5_vars.f90
Go to the documentation of this file.
1 !------------------------------------------------------------------------------!
3 !------------------------------------------------------------------------------!
4 module hdf5_vars
5 #include <PB3D_macros.h>
7  use messages
8  use str_utilities, only: i2str, r2str, r2strt
9  use hdf5
10 
11  implicit none
12  private
17 
18  ! global variables
19  integer, parameter :: max_xml_ln = 300
20  character(len=6) :: xmf_fmt = '(999A)'
21  integer, parameter :: max_dim_var_1d = 100000
22 
23  ! XDMF possibilities
24  character(len=max_str_ln) :: xdmf_num_types(2)
25  character(len=max_str_ln) :: xdmf_format_types(2)
26  character(len=max_str_ln) :: xdmf_geom_types(2)
27  character(len=max_str_ln) :: xdmf_top_types(2)
28  character(len=max_str_ln) :: xdmf_att_types(2)
29  character(len=max_str_ln) :: xdmf_center_types(2)
30  character(len=max_str_ln) :: xdmf_grid_types(3)
31 
33  type, public :: xml_str_type
34  character(len=max_str_ln) :: name
35  integer :: max_xml_ln = 300
36  character(len=max_xml_ln), allocatable :: xml_str(:)
37  end type xml_str_type
38 
40  type, public :: hdf5_file_type
41  integer(HID_T) :: hdf5_i
42  integer :: xdmf_i
43  character(len=max_str_ln) :: name
44  end type hdf5_file_type
45 
48  type, public :: var_1d_type
49  real(dp), allocatable :: p(:)
50  integer, allocatable :: tot_i_min(:)
51  integer, allocatable :: tot_i_max(:)
52  integer, allocatable :: loc_i_min(:)
53  integer, allocatable :: loc_i_max(:)
54  character(len=max_str_ln) :: var_name
55  end type var_1d_type
56 
57  ! interfaces
58 
60  interface dealloc_xml_str
62  module procedure dealloc_xml_str_ind
64  module procedure dealloc_xml_str_arr
65  end interface
66 
68  interface dealloc_var_1d
70  module procedure dealloc_var_1d_ind
72  module procedure dealloc_var_1d_arr
74  module procedure dealloc_var_1d_arr_2
75  end interface
76 
77 contains
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 
113  subroutine dealloc_xml_str_arr(XML_str)
114  ! input / output
115  type(xml_str_type), intent(inout), allocatable :: XML_str(:)
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
129  subroutine dealloc_xml_str_ind(XML_str)
130  ! input / output
131  type(xml_str_type), intent(out) :: XML_str
132  end subroutine dealloc_xml_str_ind
133 
135  subroutine dealloc_var_1d_arr_2(var_1D)
136  ! input / output
137  type(var_1d_type), intent(inout), allocatable :: var_1D(:,:)
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
153  subroutine dealloc_var_1d_arr(var_1D)
154  ! input / output
155  type(var_1d_type), intent(inout), allocatable :: var_1D(:)
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
169  subroutine dealloc_var_1d_ind(var_1D)
170  ! input / output
171  type(var_1d_type), intent(out) :: var_1D
172  end subroutine dealloc_var_1d_ind
173 end module hdf5_vars
hdf5_vars::dealloc_var_1d
Deallocates 1D variable.
Definition: HDF5_vars.f90:68
num_vars::dp
integer, parameter, public dp
double precision
Definition: num_vars.f90:46
num_vars::script_dir
character(len=7), public script_dir
directory where to save scripts for plots
Definition: num_vars.f90:154
num_vars
Numerical variables used by most other modules.
Definition: num_vars.f90:4
num_vars::max_str_ln
integer, parameter, public max_str_ln
maximum length of strings
Definition: num_vars.f90:50
str_utilities::i2str
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
Definition: str_utilities.f90:18
hdf5_vars::xdmf_att_types
character(len=max_str_ln), dimension(2), public xdmf_att_types
possible XDMF attribute types
Definition: HDF5_vars.f90:28
hdf5_vars
Variables pertaining to HDF5 and XDMF.
Definition: HDF5_vars.f90:4
num_vars::data_dir
character(len=4), public data_dir
directory where to save data for plots
Definition: num_vars.f90:155
str_utilities
Operations on strings.
Definition: str_utilities.f90:4
str_utilities::r2strt
elemental character(len=max_str_ln) function, public r2strt(k)
Convert a real (double) to string.
Definition: str_utilities.f90:54
hdf5_vars::dealloc_xml_str
Deallocates XML_str_type.
Definition: HDF5_vars.f90:60
hdf5_vars::xdmf_grid_types
character(len=max_str_ln), dimension(3), public xdmf_grid_types
possible XDMF grid types
Definition: HDF5_vars.f90:30
hdf5_vars::max_dim_var_1d
integer, parameter, public max_dim_var_1d
maximum dimension of var_1D
Definition: HDF5_vars.f90:21
hdf5_vars::xdmf_center_types
character(len=max_str_ln), dimension(2), public xdmf_center_types
possible XDMF attribute center types
Definition: HDF5_vars.f90:29
hdf5_vars::init_hdf5
subroutine, public init_hdf5
Initializes the HDF5 types.
Definition: HDF5_vars.f90:82
hdf5_vars::var_1d_type
1D equivalent of multidimensional variables, used for internal HDF5 storage.
Definition: HDF5_vars.f90:48
hdf5_vars::xmf_fmt
character(len=6), public xmf_fmt
format to write the xmf file
Definition: HDF5_vars.f90:20
str_utilities::r2str
elemental character(len=max_str_ln) function, public r2str(k)
Convert a real (double) to string.
Definition: str_utilities.f90:42
messages
Numerical utilities related to giving output.
Definition: messages.f90:4
hdf5_vars::xdmf_geom_types
character(len=max_str_ln), dimension(2), public xdmf_geom_types
possible XDMF geometry types
Definition: HDF5_vars.f90:26
hdf5_vars::xdmf_num_types
character(len=max_str_ln), dimension(2), public xdmf_num_types
possible XDMF number types
Definition: HDF5_vars.f90:24
hdf5_vars::hdf5_file_type
HDF5 data type, containing the information about HDF5 files.
Definition: HDF5_vars.f90:40
num_vars::plot_dir
character(len=5), public plot_dir
directory where to save plots
Definition: num_vars.f90:153
hdf5_vars::xdmf_format_types
character(len=max_str_ln), dimension(2), public xdmf_format_types
possible XDMF format types
Definition: HDF5_vars.f90:25
hdf5_vars::xdmf_top_types
character(len=max_str_ln), dimension(2), public xdmf_top_types
possible XDMF topology types
Definition: HDF5_vars.f90:27
hdf5_vars::xml_str_type
XML strings used in XDMF.
Definition: HDF5_vars.f90:33