MFC
Exascale flow solver
Loading...
Searching...
No Matches
m_data_input.f90
Go to the documentation of this file.
1!>
2!! @file
3!> @brief Contains module m_data_input
4
5!> @brief Reads raw simulation grid and conservative-variable data for a given time-step and fills buffer regions
7
8#ifdef MFC_MPI
9 use mpi !< message passing interface (mpi) module
10#endif
11
12 use m_derived_types !< definitions of the derived types
13
14 use m_global_parameters !< global parameters for the code
15
16 use m_mpi_proxy !< message passing interface (mpi) module proxy
17
18 use m_mpi_common
19
21
23
24 use m_helper
25
26 implicit none
27
28 private; public :: s_initialize_data_input_module, &
33
34 abstract interface
35
36 !> Subroutine for reading data files
37 !! @param t_step Current time-step to input
38 impure subroutine s_read_abstract_data_files(t_step)
39
40 implicit none
41
42 integer, intent(in) :: t_step
43
44 end subroutine s_read_abstract_data_files
45
46 end interface
47
48 type(scalar_field), allocatable, dimension(:), public :: q_cons_vf !<
49 !! Conservative variables
50
51 type(scalar_field), allocatable, dimension(:), public :: q_cons_temp
52
53 type(scalar_field), allocatable, dimension(:), public :: q_prim_vf !<
54 !! Primitive variables
55
56 type(integer_field), allocatable, dimension(:, :), public :: bc_type !<
57 !! Boundary condition identifiers
58
59 type(scalar_field), public :: q_t_sf !<
60 !! Temperature field
61
62 ! type(scalar_field), public :: ib_markers !<
63 type(integer_field), public :: ib_markers
64
65 procedure(s_read_abstract_data_files), pointer :: s_read_data_files => null()
66
67contains
68
69 !> Helper subroutine to read grid data files for a given direction
70 !! @param t_step_dir Directory containing the time-step data
71 !! @param direction Direction name ('x', 'y', 'z')
72 !! @param cb_array Cell boundary array to populate
73 !! @param d_array Cell width array to populate
74 !! @param cc_array Cell center array to populate
75 !! @param size_dim Size of the dimension
76 impure subroutine s_read_grid_data_direction(t_step_dir, direction, cb_array, d_array, cc_array, size_dim)
77
78 character(len=*), intent(in) :: t_step_dir
79 character(len=1), intent(in) :: direction
80 real(wp), dimension(-1:), intent(out) :: cb_array
81 real(wp), dimension(0:), intent(out) :: d_array
82 real(wp), dimension(0:), intent(out) :: cc_array
83 integer, intent(in) :: size_dim
84
85 character(LEN=len_trim(t_step_dir) + 10) :: file_loc
86 logical :: file_check
87
88 ! Checking whether direction_cb.dat exists
89 file_loc = trim(t_step_dir)//'/'//direction//'_cb.dat'
90 inquire (file=trim(file_loc), exist=file_check)
91
92 ! Reading direction_cb.dat if it exists, exiting otherwise
93 if (file_check) then
94 open (1, file=trim(file_loc), form='unformatted', &
95 status='old', action='read')
96 read (1) cb_array(-1:size_dim)
97 close (1)
98 else
99 call s_mpi_abort('File '//direction//'_cb.dat is missing in '// &
100 trim(t_step_dir)//'. Exiting.')
101 end if
102
103 ! Computing the cell-width distribution
104 d_array(0:size_dim) = cb_array(0:size_dim) - cb_array(-1:size_dim - 1)
105
106 ! Computing the cell-center locations
107 cc_array(0:size_dim) = cb_array(-1:size_dim - 1) + d_array(0:size_dim)/2._wp
108
109 end subroutine s_read_grid_data_direction
110
111#ifdef MFC_MPI
112 !> Helper subroutine to setup MPI data I/O parameters
113 !! @param data_size Local array size (output)
114 !! @param m_MOK, n_MOK, p_MOK MPI offset kinds for dimensions (output)
115 !! @param WP_MOK, MOK, str_MOK, NVARS_MOK Other MPI offset kinds (output)
116 impure subroutine s_setup_mpi_io_params(data_size, m_MOK, n_MOK, p_MOK, WP_MOK, MOK, str_MOK, NVARS_MOK)
117
118 integer, intent(out) :: data_size
119 integer(KIND=MPI_OFFSET_KIND), intent(out) :: m_mok, n_mok, p_mok
120 integer(KIND=MPI_OFFSET_KIND), intent(out) :: wp_mok, mok, str_mok, nvars_mok
121
122 ! Initialize MPI data I/O
123 if (ib) then
125 else
127 end if
128
129 ! Size of local arrays
130 data_size = (m + 1)*(n + 1)*(p + 1)
131
132 ! Resize some integers so MPI can read even the biggest file
133 m_mok = int(m_glb + 1, mpi_offset_kind)
134 n_mok = int(n_glb + 1, mpi_offset_kind)
135 p_mok = int(p_glb + 1, mpi_offset_kind)
136 wp_mok = int(8._wp, mpi_offset_kind)
137 mok = int(1._wp, mpi_offset_kind)
138 str_mok = int(name_len, mpi_offset_kind)
139 nvars_mok = int(sys_size, mpi_offset_kind)
140
141 end subroutine s_setup_mpi_io_params
142#endif
143
144 !> Helper subroutine to read IB data files
145 !! @param file_loc_base Base file location for IB data
146 !! @param t_step Time step index
147 impure subroutine s_read_ib_data_files(file_loc_base, t_step)
148
149 character(len=*), intent(in) :: file_loc_base
150 integer, intent(in), optional :: t_step
151
152 character(LEN=len_trim(file_loc_base) + 20) :: file_loc
153 logical :: file_exist
154 integer :: ifile, ierr, data_size, var_mok
155
156#ifdef MFC_MPI
157 integer, dimension(MPI_STATUS_SIZE) :: status
158 integer(KIND=MPI_OFFSET_KIND) :: disp
159 integer :: m_mok, n_mok, p_mok, mok, wp_mok, save_index
160
161#endif
162 if (.not. ib) return
163
164 if (parallel_io) then
165 write (file_loc, '(A)') trim(file_loc_base)//'ib.dat'
166 else
167 write (file_loc, '(A)') trim(file_loc_base)//'/ib.dat'
168 end if
169 inquire (file=trim(file_loc), exist=file_exist)
170
171 if (file_exist) then
172 if (parallel_io) then
173#ifdef MFC_MPI
174 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
175
176 m_mok = int(m_glb + 1, mpi_offset_kind)
177 n_mok = int(n_glb + 1, mpi_offset_kind)
178 p_mok = int(p_glb + 1, mpi_offset_kind)
179 mok = int(1._wp, mpi_offset_kind)
180 wp_mok = int(8._wp, mpi_offset_kind)
181 save_index = t_step/t_step_save ! get the number of saves done to this point
182
183 data_size = (m + 1)*(n + 1)*(p + 1)
184 var_mok = int(sys_size + 1, mpi_offset_kind)
185 if (t_step == 0) then
186 disp = 0
187 else
188 disp = m_mok*max(mok, n_mok)*max(mok, p_mok)*wp_mok*(var_mok - 1 + int(save_index, mpi_offset_kind))
189 end if
190
191 call mpi_file_set_view(ifile, disp, mpi_integer, mpi_io_ib_data%view, &
192 'native', mpi_info_int, ierr)
193 call mpi_file_read(ifile, mpi_io_ib_data%var%sf, data_size, &
194 mpi_integer, status, ierr)
195
196 call mpi_file_close(ifile, ierr)
197#endif
198 else
199 open (2, file=trim(file_loc), &
200 form='unformatted', &
201 action='read', &
202 status='old')
203 read (2) ib_markers%sf(0:m, 0:n, 0:p)
204 close (2)
205 end if
206 else
207 call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.')
208 end if
209
210 end subroutine s_read_ib_data_files
211
212 !> Helper subroutine to allocate field arrays for given dimensionality
213 !! @param local_start_idx Starting index for allocation
214 !! @param end_x End index for x dimension
215 !! @param end_y End index for y dimension
216 !! @param end_z End index for z dimension
217 impure subroutine s_allocate_field_arrays(local_start_idx, end_x, end_y, end_z)
218
219 integer, intent(in) :: local_start_idx, end_x, end_y, end_z
220 integer :: i
221
222 do i = 1, sys_size
223 allocate (q_cons_vf(i)%sf(local_start_idx:end_x, local_start_idx:end_y, local_start_idx:end_z))
224 allocate (q_prim_vf(i)%sf(local_start_idx:end_x, local_start_idx:end_y, local_start_idx:end_z))
225 end do
226
227 if (ib) then
228 allocate (ib_markers%sf(local_start_idx:end_x, local_start_idx:end_y, local_start_idx:end_z))
229 end if
230
231 if (chemistry) then
232 allocate (q_t_sf%sf(local_start_idx:end_x, local_start_idx:end_y, local_start_idx:end_z))
233 end if
234
235 end subroutine s_allocate_field_arrays
236
237 !> This subroutine is called at each time-step that has to
238 !! be post-processed in order to read the raw data files
239 !! present in the corresponding time-step directory and to
240 !! populate the associated grid and conservative variables.
241 !! @param t_step Current time-step
242 impure subroutine s_read_serial_data_files(t_step)
243
244 integer, intent(in) :: t_step
245
246 character(LEN=len_trim(case_dir) + 2*name_len) :: t_step_dir !<
247 !! Location of the time-step directory associated with t_step
248
249 character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc !<
250 !! Generic string used to store the location of a particular file
251
252 character(len= &
253 int(floor(log10(real(sys_size, wp)))) + 1) :: file_num !<
254 !! Used to store the variable position, in character form, of the
255 !! currently manipulated conservative variable file
256
257 character(LEN=len_trim(case_dir) + 2*name_len) :: t_step_ib_dir !<
258 !! Location of the time-step directory associated with t_step
259
260 logical :: dir_check !<
261 !! Generic logical used to test the existence of a particular folder
262
263 logical :: file_check !<
264 !! Generic logical used to test the existence of a particular file
265
266 integer :: i !< Generic loop iterator
267
268 ! Setting location of time-step folder based on current time-step
269 write (t_step_dir, '(A,I0,A,I0)') '/p_all/p', proc_rank, '/', t_step
270 t_step_dir = trim(case_dir)//trim(t_step_dir)
271
272 ! Inquiring as to the existence of the time-step directory
273 file_loc = trim(t_step_dir)//'/.'
274 call my_inquire(file_loc, dir_check)
275
276 ! If the time-step directory is missing, the post-process exits.
277 if (dir_check .neqv. .true.) then
278 call s_mpi_abort('Time-step folder '//trim(t_step_dir)// &
279 ' is missing. Exiting.')
280 end if
281
282 if (bc_io) then
284 else
286 end if
287
288 ! Reading the Grid Data Files using helper subroutine
289 call s_read_grid_data_direction(t_step_dir, 'x', x_cb, dx, x_cc, m)
290
291 if (n > 0) then
292 call s_read_grid_data_direction(t_step_dir, 'y', y_cb, dy, y_cc, n)
293
294 if (p > 0) then
295 call s_read_grid_data_direction(t_step_dir, 'z', z_cb, dz, z_cc, p)
296 end if
297 end if
298
299 ! Reading the Conservative Variables Data Files
300 do i = 1, sys_size
301
302 ! Checking whether the data file associated with the variable
303 ! position of currently manipulated conservative variable exists
304 write (file_num, '(I0)') i
305 file_loc = trim(t_step_dir)//'/q_cons_vf'// &
306 trim(file_num)//'.dat'
307 inquire (file=trim(file_loc), exist=file_check)
308
309 ! Reading the data file if it exists, exiting otherwise
310 if (file_check) then
311 open (1, file=trim(file_loc), form='unformatted', &
312 status='old', action='read')
313 read (1) q_cons_vf(i)%sf(0:m, 0:n, 0:p)
314 close (1)
315 else if (bubbles_lagrange .and. i == beta_idx) then
316 ! beta (Lagrangian void fraction) is not written by pre_process
317 ! for t_step_start; initialize to zero.
318 q_cons_vf(i)%sf(0:m, 0:n, 0:p) = 0._wp
319 else
320 call s_mpi_abort('File q_cons_vf'//trim(file_num)// &
321 '.dat is missing in '//trim(t_step_dir)// &
322 '. Exiting.')
323 end if
324
325 end do
326
327 ! Reading IB data using helper subroutine
328 call s_read_ib_data_files(t_step_dir)
329
330 end subroutine s_read_serial_data_files
331
332 !> This subroutine is called at each time-step that has to
333 !! be post-processed in order to parallel-read the raw data files
334 !! present in the corresponding time-step directory and to
335 !! populate the associated grid and conservative variables.
336 !! @param t_step Current time-step
337 impure subroutine s_read_parallel_data_files(t_step)
338
339 integer, intent(in) :: t_step
340
341#ifdef MFC_MPI
342
343 real(wp), allocatable, dimension(:) :: x_cb_glb, y_cb_glb, z_cb_glb
344
345 integer :: ifile, ierr, data_size, filetype, stride
346 integer, dimension(MPI_STATUS_SIZE) :: status
347
348 integer(KIND=MPI_OFFSET_KIND) :: disp
349 integer(KIND=MPI_OFFSET_KIND) :: m_mok, n_mok, p_mok
350 integer(KIND=MPI_OFFSET_KIND) :: wp_mok, var_mok, str_mok
351 integer(KIND=MPI_OFFSET_KIND) :: nvars_mok
352 integer(KIND=MPI_OFFSET_KIND) :: mok
353 integer(kind=MPI_OFFSET_KIND) :: offset
354 real(wp) :: delx, dely, delz
355
356 character(LEN=path_len + 2*name_len) :: file_loc
357 logical :: file_exist
358
359 character(len=10) :: t_step_string
360
361 integer :: i
362
363 allocate (x_cb_glb(-1:m_glb))
364 allocate (y_cb_glb(-1:n_glb))
365 allocate (z_cb_glb(-1:p_glb))
366
367 if (down_sample) then
368 stride = 3
369 else
370 stride = 1
371 end if
372
373 ! Read in cell boundary locations in x-direction
374 file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'x_cb.dat'
375 inquire (file=trim(file_loc), exist=file_exist)
376
377 if (file_exist) then
378 data_size = m_glb + 2
379 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
380
381 call mpi_type_vector(data_size, 1, stride, mpi_p, filetype, ierr)
382 call mpi_type_commit(filetype, ierr)
383
384 offset = 0
385 call mpi_file_set_view(ifile, offset, mpi_p, filetype, 'native', mpi_info_int, ierr)
386
387 call mpi_file_read(ifile, x_cb_glb, data_size, mpi_p, status, ierr)
388 call mpi_file_close(ifile, ierr)
389 else
390 call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.')
391 end if
392
393 ! Assigning local cell boundary locations
394 x_cb(-1:m) = x_cb_glb((start_idx(1) - 1):(start_idx(1) + m))
395 ! Computing the cell width distribution
396 dx(0:m) = x_cb(0:m) - x_cb(-1:m - 1)
397 ! Computing the cell center location
398 x_cc(0:m) = x_cb(-1:m - 1) + dx(0:m)/2._wp
399
400 if (n > 0) then
401 ! Read in cell boundary locations in y-direction
402 file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'y_cb.dat'
403 inquire (file=trim(file_loc), exist=file_exist)
404
405 if (file_exist) then
406 data_size = n_glb + 2
407 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
408
409 call mpi_type_vector(data_size, 1, stride, mpi_p, filetype, ierr)
410 call mpi_type_commit(filetype, ierr)
411
412 offset = 0
413 call mpi_file_set_view(ifile, offset, mpi_p, filetype, 'native', mpi_info_int, ierr)
414
415 call mpi_file_read(ifile, y_cb_glb, data_size, mpi_p, status, ierr)
416 call mpi_file_close(ifile, ierr)
417 else
418 call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.')
419 end if
420
421 ! Assigning local cell boundary locations
422 y_cb(-1:n) = y_cb_glb((start_idx(2) - 1):(start_idx(2) + n))
423 ! Computing the cell width distribution
424 dy(0:n) = y_cb(0:n) - y_cb(-1:n - 1)
425 ! Computing the cell center location
426 y_cc(0:n) = y_cb(-1:n - 1) + dy(0:n)/2._wp
427
428 if (p > 0) then
429 ! Read in cell boundary locations in z-direction
430 file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'z_cb.dat'
431 inquire (file=trim(file_loc), exist=file_exist)
432
433 if (file_exist) then
434 data_size = p_glb + 2
435 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
436
437 call mpi_type_vector(data_size, 1, stride, mpi_p, filetype, ierr)
438 call mpi_type_commit(filetype, ierr)
439
440 offset = 0
441 call mpi_file_set_view(ifile, offset, mpi_p, filetype, 'native', mpi_info_int, ierr)
442
443 call mpi_file_read(ifile, z_cb_glb, data_size, mpi_p, status, ierr)
444 call mpi_file_close(ifile, ierr)
445 else
446 call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.')
447 end if
448
449 ! Assigning local cell boundary locations
450 z_cb(-1:p) = z_cb_glb((start_idx(3) - 1):(start_idx(3) + p))
451 ! Computing the cell width distribution
452 dz(0:p) = z_cb(0:p) - z_cb(-1:p - 1)
453 ! Computing the cell center location
454 z_cc(0:p) = z_cb(-1:p - 1) + dz(0:p)/2._wp
455 end if
456 end if
457
458 call s_read_parallel_conservative_data(t_step, m_mok, n_mok, p_mok, wp_mok, mok, str_mok, nvars_mok)
459
460 deallocate (x_cb_glb, y_cb_glb, z_cb_glb)
461
462 if (bc_io) then
464 else
466 end if
467
468#endif
469
470 end subroutine s_read_parallel_data_files
471
472#ifdef MFC_MPI
473 !> Helper subroutine to read parallel conservative variable data
474 !! @param t_step Current time-step
475 !! @param m_MOK, n_MOK, p_MOK MPI offset kinds for dimensions
476 !! @param WP_MOK, MOK, str_MOK, NVARS_MOK Other MPI offset kinds
477 impure subroutine s_read_parallel_conservative_data(t_step, m_MOK, n_MOK, p_MOK, WP_MOK, MOK, str_MOK, NVARS_MOK)
478
479 integer, intent(in) :: t_step
480 integer(KIND=MPI_OFFSET_KIND), intent(inout) :: m_mok, n_mok, p_mok
481 integer(KIND=MPI_OFFSET_KIND), intent(inout) :: wp_mok, mok, str_mok, nvars_mok
482
483 integer :: ifile, ierr, data_size
484 integer, dimension(MPI_STATUS_SIZE) :: status
485 integer(KIND=MPI_OFFSET_KIND) :: disp, var_mok
486 character(LEN=path_len + 2*name_len) :: file_loc
487 logical :: file_exist
488 character(len=10) :: t_step_string
489 integer :: i
490
491 if (file_per_process) then
492 call s_int_to_str(t_step, t_step_string)
493 ! Open the file to read conservative variables
494 write (file_loc, '(I0,A1,I7.7,A)') t_step, '_', proc_rank, '.dat'
495 file_loc = trim(case_dir)//'/restart_data/lustre_'//trim(t_step_string)//trim(mpiiofs)//trim(file_loc)
496 inquire (file=trim(file_loc), exist=file_exist)
497
498 if (file_exist) then
499 call mpi_file_open(mpi_comm_self, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
500
501 if (down_sample) then
503 else
504 ! Initialize MPI data I/O
505 if (ib) then
507 else
509 end if
510 end if
511
512 if (down_sample) then
513 ! Size of local arrays
514 data_size = (m + 3)*(n + 3)*(p + 3)
515 else
516 ! Size of local arrays
517 data_size = (m + 1)*(n + 1)*(p + 1)
518 end if
519
520 ! Resize some integers so MPI can read even the biggest file
521 m_mok = int(m_glb + 1, mpi_offset_kind)
522 n_mok = int(n_glb + 1, mpi_offset_kind)
523 p_mok = int(p_glb + 1, mpi_offset_kind)
524 wp_mok = int(8._wp, mpi_offset_kind)
525 mok = int(1._wp, mpi_offset_kind)
526 str_mok = int(name_len, mpi_offset_kind)
527 nvars_mok = int(sys_size, mpi_offset_kind)
528
529 ! Read the data for each variable
530 if (bubbles_euler .or. elasticity .or. mhd) then
531 do i = 1, sys_size
532 var_mok = int(i, mpi_offset_kind)
533 call mpi_file_read_all(ifile, mpi_io_data%var(i)%sf, data_size*mpi_io_type, &
534 mpi_io_p, status, ierr)
535 end do
536 else
537 do i = 1, sys_size
538 var_mok = int(i, mpi_offset_kind)
539 call mpi_file_read_all(ifile, mpi_io_data%var(i)%sf, data_size*mpi_io_type, &
540 mpi_io_p, status, ierr)
541 end do
542 end if
543
544 call s_mpi_barrier()
545 call mpi_file_close(ifile, ierr)
546
547 if (down_sample) then
548 do i = 1, sys_size
549 q_cons_vf(i)%sf(0:m, 0:n, 0:p) = q_cons_temp(i)%sf(0:m, 0:n, 0:p)
550 end do
551 end if
552
553 call s_read_ib_data_files(trim(case_dir)//'/restart_data'//trim(mpiiofs), t_step)
554 else
555 call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.')
556 end if
557 else
558 ! Open the file to read conservative variables
559 write (file_loc, '(I0,A)') t_step, '.dat'
560 file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc)
561 inquire (file=trim(file_loc), exist=file_exist)
562
563 if (file_exist) then
564 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
565
566 call s_setup_mpi_io_params(data_size, m_mok, n_mok, p_mok, wp_mok, mok, str_mok, nvars_mok)
567
568 ! Read the data for each variable
569 do i = 1, sys_size
570 var_mok = int(i, mpi_offset_kind)
571
572 ! Initial displacement to skip at beginning of file
573 disp = m_mok*max(mok, n_mok)*max(mok, p_mok)*wp_mok*(var_mok - 1)
574
575 call mpi_file_set_view(ifile, disp, mpi_p, mpi_io_data%view(i), &
576 'native', mpi_info_int, ierr)
577 call mpi_file_read_all(ifile, mpi_io_data%var(i)%sf, data_size*mpi_io_type, &
578 mpi_io_p, status, ierr)
579 end do
580
581 call s_mpi_barrier()
582 call mpi_file_close(ifile, ierr)
583
584 call s_read_ib_data_files(trim(case_dir)//'/restart_data'//trim(mpiiofs), t_step)
585 else
586 call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.')
587 end if
588 end if
590#endif
591
592 !> Computation of parameters, allocation procedures, and/or
593 !! any other tasks needed to properly setup the module
595
596 integer :: i !< Generic loop iterator
597
598 ! Allocating the parts of the conservative and primitive variables
599 ! that do not require the direct knowledge of the dimensionality of
600 ! the simulation
601 allocate (q_cons_vf(1:sys_size))
602 allocate (q_prim_vf(1:sys_size))
603 allocate (q_cons_temp(1:sys_size))
604
605 ! Allocating the parts of the conservative and primitive variables
606 ! that do require the direct knowledge of the dimensionality of
607 ! the simulation using helper subroutine
608
609 ! Simulation is at least 2D
610 if (n > 0) then
611 ! Simulation is 3D
612 if (p > 0) then
614 if (down_sample) then
615 do i = 1, sys_size
616 allocate (q_cons_temp(i)%sf(-1:m + 1, -1:n + 1, -1:p + 1))
617 end do
618 end if
619 else
620 ! Simulation is 2D
622 end if
623 else
624 ! Simulation is 1D
626 end if
627
628 ! Allocating arrays to store the bc types
629 allocate (bc_type(1:num_dims, 1:2))
630
631 allocate (bc_type(1, 1)%sf(0:0, 0:n, 0:p))
632 allocate (bc_type(1, 2)%sf(0:0, 0:n, 0:p))
633 if (n > 0) then
634 allocate (bc_type(2, 1)%sf(-buff_size:m + buff_size, 0:0, 0:p))
635 allocate (bc_type(2, 2)%sf(-buff_size:m + buff_size, 0:0, 0:p))
636 if (p > 0) then
637 allocate (bc_type(3, 1)%sf(-buff_size:m + buff_size, -buff_size:n + buff_size, 0:0))
638 allocate (bc_type(3, 2)%sf(-buff_size:m + buff_size, -buff_size:n + buff_size, 0:0))
639 end if
640 end if
641
642 if (parallel_io .neqv. .true.) then
644 else
646 end if
647
648 end subroutine s_initialize_data_input_module
649
650 !> Deallocation procedures for the module
652
653 integer :: i !< Generic loop iterator
654
655 ! Deallocating the conservative and primitive variables
656 do i = 1, sys_size
657 deallocate (q_cons_vf(i)%sf)
658 deallocate (q_prim_vf(i)%sf)
659 if (down_sample) then
660 deallocate (q_cons_temp(i)%sf)
661 end if
662 end do
663
664 deallocate (q_cons_vf)
665 deallocate (q_prim_vf)
666 deallocate (q_cons_temp)
667
668 if (ib) then
669 deallocate (ib_markers%sf)
670 end if
671
672 if (chemistry) then
673 deallocate (q_t_sf%sf)
674 end if
675
676 deallocate (bc_type(1, 1)%sf, bc_type(1, 2)%sf)
677 if (n > 0) then
678 deallocate (bc_type(2, 1)%sf, bc_type(2, 2)%sf)
679 if (p > 0) then
680 deallocate (bc_type(3, 1)%sf, bc_type(3, 2)%sf)
681 end if
682 end if
683
684 deallocate (bc_type)
685
686 s_read_data_files => null()
687
688 end subroutine s_finalize_data_input_module
689
690end module m_data_input
Subroutine for reading data files.
Noncharacteristic and processor boundary condition application for ghost cells and buffer regions.
subroutine, public s_read_parallel_boundary_condition_files(bc_type)
Reads boundary condition type and buffer data from per-rank parallel files using MPI I/O.
subroutine, public s_read_serial_boundary_condition_files(step_dirpath, bc_type)
Reads boundary condition type and buffer data from serial (unformatted) restart files.
subroutine, public s_assign_default_bc_type(bc_type)
Initializes the per-cell boundary condition type arrays with the global default BC values.
Platform-specific file and directory operations: create, delete, inquire, getcwd, and basename.
impure subroutine my_inquire(fileloc, dircheck)
Inquires on the existence of a directory.
Reads raw simulation grid and conservative-variable data for a given time-step and fills buffer regio...
impure subroutine s_allocate_field_arrays(local_start_idx, end_x, end_y, end_z)
Helper subroutine to allocate field arrays for given dimensionality.
impure subroutine, public s_read_parallel_data_files(t_step)
This subroutine is called at each time-step that has to be post-processed in order to parallel-read t...
type(scalar_field), public q_t_sf
Temperature field.
type(scalar_field), dimension(:), allocatable, public q_cons_vf
Conservative variables.
impure subroutine s_read_parallel_conservative_data(t_step, m_mok, n_mok, p_mok, wp_mok, mok, str_mok, nvars_mok)
Helper subroutine to read parallel conservative variable data.
impure subroutine, public s_initialize_data_input_module
Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the...
type(scalar_field), dimension(:), allocatable, public q_prim_vf
Primitive variables.
impure subroutine s_setup_mpi_io_params(data_size, m_mok, n_mok, p_mok, wp_mok, mok, str_mok, nvars_mok)
Helper subroutine to setup MPI data I/O parameters.
impure subroutine, public s_finalize_data_input_module
Deallocation procedures for the module.
impure subroutine s_read_grid_data_direction(t_step_dir, direction, cb_array, d_array, cc_array, size_dim)
Helper subroutine to read grid data files for a given direction.
impure subroutine, public s_read_serial_data_files(t_step)
This subroutine is called at each time-step that has to be post-processed in order to read the raw da...
type(scalar_field), dimension(:), allocatable, public q_cons_temp
type(integer_field), dimension(:, :), allocatable, public bc_type
Boundary condition identifiers.
procedure(s_read_abstract_data_files), pointer, public s_read_data_files
type(integer_field), public ib_markers
impure subroutine s_read_ib_data_files(file_loc_base, t_step)
Helper subroutine to read IB data files.
Shared derived types for field data, patch geometry, bubble dynamics, and MPI I/O structures.
Global parameters for the post-process: domain geometry, equation of state, and output database setti...
logical, parameter chemistry
Chemistry modeling.
integer beta_idx
Index of lagrange bubbles beta.
real(wp), dimension(:), allocatable y_cc
integer proc_rank
Rank of the local processor.
type(mpi_io_ib_var), public mpi_io_ib_data
real(wp), dimension(:), allocatable y_cb
character(len=name_len) mpiiofs
integer, dimension(:), allocatable start_idx
Starting cell-center index of local processor in global grid.
integer sys_size
Number of unknowns in the system of equations.
real(wp), dimension(:), allocatable dz
integer buff_size
Number of cells in buffer region. For the variables which feature a buffer region,...
real(wp), dimension(:), allocatable z_cb
integer num_dims
Number of spatial dimensions.
real(wp), dimension(:), allocatable x_cc
real(wp), dimension(:), allocatable x_cb
real(wp), dimension(:), allocatable dy
integer t_step_save
Interval between consecutive time-step directory.
real(wp), dimension(:), allocatable z_cc
character(len=path_len) case_dir
Case folder location.
logical mhd
Magnetohydrodynamics.
logical parallel_io
Format of the data files.
logical down_sample
down sampling of the database file(s)
logical file_per_process
output format
logical elasticity
elasticity modeling, true for hyper or hypo
type(mpi_io_var), public mpi_io_data
real(wp), dimension(:), allocatable dx
Cell-width distributions in the x-, y- and z-coordinate directions.
Utility routines for bubble model setup, coordinate transforms, array sampling, and special functions...
elemental subroutine, public s_int_to_str(i, res)
Converts an integer to its trimmed string representation.
MPI communication layer: domain decomposition, halo exchange, reductions, and parallel I/O setup.
impure subroutine s_mpi_abort(prnt, code)
The subroutine terminates the MPI execution environment.
impure subroutine s_mpi_barrier
Halts all processes until all have reached barrier.
impure subroutine s_initialize_mpi_data(q_cons_vf, ib_markers, beta)
subroutine s_initialize_mpi_data_ds(q_cons_vf)
MPI gather and scatter operations for distributing post-process grid and flow-variable data.
Derived type annexing an integer scalar field (SF).
Derived type annexing a scalar field (SF).