9 integer,
parameter :: max_valuesfromfile = 10
12 double precision :: origin(3)
13 double precision :: dx(3)
14 double precision,
allocatable :: values(:, :, :, :)
15 integer :: n_variables
16 integer :: n_points(3)
17 character(len=40),
allocatable :: names(:)
18 end type read_data_values
21 type(
lt2_t) :: lt_2d(max_valuesfromfile)
22 type(
lt3_t) :: lt_3d(max_valuesfromfile)
35 double precision :: xmax(3)
37 type(read_data_values) :: bc
41 print *,
'Reading data from input usr_filename=',
usr_filename
44 xmax=bc%origin + (bc%n_points-1) * bc%dx
46 print *,
'Obtained data in ',bc%n_points,
' grid with spacings ',bc%dx,
' for number of vars=',bc%n_variables
49 do ivar = 1,bc%n_variables
52 xmax(1), bc%values(:, 1, 1:1, ivar))
56 xmax(1:
ndim), bc%values(:, :, 1:1, ivar))
60 xmax(1:
ndim), bc%values(:, :, :, ivar:ivar))
68 integer,
intent(in) :: ivar
69 double precision,
intent(in) :: x1, x2, x3
70 double precision :: val
76 integer,
intent(in) :: ivar
77 double precision,
intent(in) :: x1, x2
78 double precision :: val
84 integer,
intent(in) :: ivar
85 double precision,
intent(in) :: x1
86 double precision :: val
94 integer,
intent(in) :: ixi^
l, ixo^
l, nval
95 double precision,
intent(in) :: x(ixi^s,1:
ndim)
96 double precision,
intent(out) :: val(ixi^s,1:nval)
107 x(ixomin1:ixomax1, ixomin2:ixomax2, 1), x(ixomin1:ixomax1, ixomin2:ixomax2, 2))
112 val(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3:ixomax3, ival) =
read_data_get_3d(ival, &
113 x(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3:ixomax3, 1), &
114 x(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3:ixomax3, 2), &
115 x(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3:ixomax3, 3))
121 subroutine read_vtk_structured_points(fname, bc)
122 character(len=*),
intent(in) :: fname
123 type(read_data_values),
intent(out) :: bc
124 double precision,
allocatable :: tmp_data(:, :, :, :)
125 integer,
parameter :: max_variables = 10
126 integer,
parameter :: my_unit = 123
127 integer :: n, n_points_total
128 integer :: n_components
129 character(len=40) :: tmp_names(max_variables)
130 character(len=256) :: line
131 character(len=40) :: word, typename
133 open(my_unit, file=trim(fname), status=
"old", action=
"read")
136 read(my_unit,
"(A)") line
139 read(my_unit,
"(A)") line
142 read(my_unit,
"(A)") line
144 if (line /=
"ASCII")
then
145 print *,
"line: ", trim(line)
146 error stop
"read_vtk: not an ASCII file"
150 read(my_unit,
"(A)") line
152 if (line /=
"DATASET STRUCTURED_POINTS")
then
153 print *,
"line: ", trim(line)
154 error stop
"read_vtk must have: DATASET STRUCTURED_POINTS"
158 read(my_unit,
"(A)") line
159 read(line, *) word, bc%n_points
161 if (word /=
"DIMENSIONS")
then
162 print *,
"line: ", trim(line)
163 error stop
"read_vtk expects: DIMENSIONS"
167 read(my_unit, *) word, bc%dx
169 if (word /=
"SPACING")
then
170 print *,
"line: ", trim(line)
171 error stop
"read_vtk expects: SPACING"
175 read(my_unit, *) word, bc%origin
176 if (word /=
"ORIGIN")
then
177 print *,
"line: ", trim(line)
178 error stop
"read_vtk expects: ORIGIN"
182 read(my_unit, *) word, n_points_total
184 if (word /=
"POINT_DATA")
then
185 print *,
"line: ", trim(line)
186 error stop
"read_vtk expects: POINT_DATA n_points"
189 if (n_points_total /= product(bc%n_points)) &
190 error stop
"read_vtk: n_points not equal to NX*NY*NZ"
192 allocate(tmp_data(bc%n_points(1), bc%n_points(2), bc%n_points(3), &
196 do n = 1, max_variables
199 read(my_unit, *,
end=900) word, tmp_names(n), typename, n_components
201 if (word /=
"SCALARS")
then
202 print *,
"line: ", trim(line)
203 error stop
"read_vtk expects: SCALARS name type ncomponents"
206 if (n_components /= 1) error stop
"read_vtk: ncomponents should be 1"
209 read(my_unit, *) word, typename
211 if (word /=
"LOOKUP_TABLE")
then
212 print *,
"line: ", trim(line)
213 error stop
"read_vtk expects: LOOKUP_TABLE name"
217 read(my_unit, *) tmp_data(:, :, :, n)
225 if (n == max_variables + 1) &
226 error stop
"read_vtk: increase max_variables"
230 bc%values = tmp_data(:, :, :, 1:n-1)
231 bc%names = tmp_names(1:n-1)
232 end subroutine read_vtk_structured_points
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer, parameter ndim
Number of spatial dimensions for grid variables.
integer mype
The rank of the current MPI task.
character(len=std_len) usr_filename
User parameter file.
Module to set (or derive) initial conditions from user data We read in a vtk file that provides value...
type(lt_t), dimension(max_valuesfromfile) lt_1d
elemental double precision function, public read_data_get_2d(ivar, x1, x2)
subroutine, public read_data_set(ixil, ixol, x, val, nval)
Set values according to user data.
elemental double precision function, public read_data_get_3d(ivar, x1, x2, x3)
elemental double precision function, public read_data_get_1d(ivar, x1)
subroutine, public read_data_init()
A Fortran 90 module for creating 1D and 2D lookup tables. These tables can be used to efficiently int...
type(lt2_t) function, public lt2_create_from_data(x_min, x_max, spaced_data)
This function returns a new lookup table from regularly spaced data.
elemental real(dp) function, public lt_get_col(my_lt, col_ix, x)
Get the value of a single column at x.
elemental real(dp) function, public lt2_get_col(my_lt, col_ix, x1, x2)
Get the value of a single column at x.
elemental real(dp) function, public lt3_get_col(my_lt, col_ix, x1, x2, x3)
Get the value of a single column at x.
type(lt_t) function, public lt_create_from_data(x_min, x_max, spaced_data)
This function returns a new lookup table from regularly spaced data.
type(lt3_t) function, public lt3_create_from_data(x_min, x_max, spaced_data)
This function returns a new lookup table from regularly spaced data.
The 2D lookup table type.
The 3D lookup table type.
The lookup table type. There can be one or more columns, for which values can be looked up for a give...