MFC
Exascale flow solver
Loading...
Searching...
No Matches
m_start_up.fpp.f90
Go to the documentation of this file.
1# 1 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
2# 1 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp" 1
3# 1 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 1
4# 1 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 1
5# 2 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
6# 3 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
7# 4 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
8# 5 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
9# 6 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
10
11# 8 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
12# 9 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
13# 10 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
14
15# 17 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
16
17# 46 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
18
19# 58 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
20
21# 68 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
22
23# 98 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
24
25# 110 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
26
27# 120 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
28! New line at end of file is required for FYPP
29# 2 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 2
30# 1 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp" 1
31# 1 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 1
32# 2 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
33# 3 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
34# 4 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
35# 5 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
36# 6 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
37
38# 8 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
39# 9 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
40# 10 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
41
42# 17 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
43
44# 46 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
45
46# 58 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
47
48# 68 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
49
50# 98 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
51
52# 110 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
53
54# 120 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
55! New line at end of file is required for FYPP
56# 2 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp" 2
57
58# 4 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
59# 5 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
60# 6 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
61# 7 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
62# 8 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
63
64# 20 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
65
66# 43 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
67
68# 48 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
69
70# 53 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
71
72# 58 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
73
74# 63 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
75
76# 68 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
77
78# 76 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
79
80# 81 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
81
82# 86 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
83
84# 91 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
85
86# 96 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
87
88# 101 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
89
90# 106 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
91
92# 111 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
93
94# 116 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
95
96# 121 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
97
98# 151 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
99
100# 192 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
101
102# 207 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
103
104# 232 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
105
106# 243 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
107
108# 245 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
109# 255 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
110
111# 283 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
112
113# 293 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
114
115# 303 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
116
117# 312 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
118
119# 329 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
120
121# 339 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
122
123# 346 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
124
125# 352 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
126
127# 358 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
128
129# 364 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
130
131# 370 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
132
133# 376 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
134! New line at end of file is required for FYPP
135# 3 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 2
136# 1 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp" 1
137# 1 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 1
138# 2 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
139# 3 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
140# 4 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
141# 5 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
142# 6 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
143
144# 8 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
145# 9 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
146# 10 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
147
148# 17 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
149
150# 46 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
151
152# 58 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
153
154# 68 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
155
156# 98 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
157
158# 110 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
159
160# 120 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
161! New line at end of file is required for FYPP
162# 2 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp" 2
163
164# 7 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
165
166# 17 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
167
168# 22 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
169
170# 27 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
171
172# 32 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
173
174# 37 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
175
176# 42 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
177
178# 47 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
179
180# 52 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
181
182# 57 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
183
184# 62 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
185
186# 73 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
187
188# 78 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
189
190# 83 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
191
192# 88 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
193
194# 103 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
195
196# 131 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
197
198# 160 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
199
200# 175 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
201
202# 192 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
203
204# 213 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
205
206# 241 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
207
208# 256 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
209
210# 266 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
211
212# 275 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
213
214# 291 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
215
216# 301 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
217
218# 308 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
219! New line at end of file is required for FYPP
220# 4 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 2
221
222# 21 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
223
224# 37 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
225
226# 50 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
227
228# 104 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
229
230# 119 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
231
232# 130 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
233
234# 143 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
235
236# 171 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
237
238# 182 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
239
240# 193 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
241
242# 204 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
243
244# 214 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
245
246# 225 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
247
248# 236 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
249
250# 246 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
251
252# 252 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
253
254# 258 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
255
256# 264 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
257
258# 270 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
259
260# 272 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
261# 273 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
262! New line at end of file is required for FYPP
263# 2 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp" 2
264
265# 14 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
266
267! Caution:
268! This macro requires the use of a binding script to set CUDA_VISIBLE_DEVICES, such that we have one GPU device per MPI rank.
269! That's because for both cudaMemAdvise (preferred location) and cudaMemPrefetchAsync we use location = device_id = 0.
270! For an example see misc/nvidia_uvm/bind.sh.
271# 63 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
272
273# 81 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
274
275# 88 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
276
277# 111 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
278
279# 127 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
280
281# 153 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
282
283# 159 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
284
285# 167 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
286! New line at end of file is required for FYPP
287# 2 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp" 2
288
289!>
290!! @file
291!! @brief Contains module m_start_up
292
293!> @brief Reads and validates user inputs, allocates variables, and configures MPI decomposition and I/O for post-processing
294
296
297 ! Dependencies
298
299 use, intrinsic :: iso_c_binding
300
301 use m_derived_types !< definitions of the derived types
302
303 use m_global_parameters !< global parameters for the code
304
305 use m_mpi_proxy !< message passing interface (mpi) module proxy
306
307 use m_mpi_common !< common mpi subroutines
308
309 use m_boundary_common !< common boundary conditions subroutines
310
311 use m_variables_conversion !< subroutines to change the state variables from
312 !! one form to another
313
314 use m_data_input !< procedures reading raw simulation data to fill
315 !! the conservative, primitive and grid variables
316
317 use m_data_output !< procedures that write the grid and chosen flow
318 !! variable(s) to the formatted database file(s)
319
320 use m_derived_variables !< procedures used to compute quantities derived
321 !! from the conservative and primitive variables
322 use m_helper
323
325
327
328 use m_checker
329
330 use m_thermochem, only: num_species, species_names
331
333
334 use m_chemistry
335
336#ifdef MFC_MPI
337 use mpi !< message passing interface (mpi) module
338#endif
339
340 implicit none
341
342 include 'fftw3.f03'
343
345 complex(c_double_complex), allocatable :: data_in(:), data_out(:)
346 complex(c_double_complex), allocatable :: data_cmplx(:, :, :), data_cmplx_y(:, :, :), data_cmplx_z(:, :, :)
347 real(wp), allocatable, dimension(:, :, :) :: en_real
348 real(wp), allocatable, dimension(:) :: en
350 integer :: nx, ny, nz, nxloc, nyloc, nyloc2, nzloc, nf
351 integer :: ierr
353 integer, dimension(3) :: cart3d_coords
354 integer, dimension(2) :: cart2d12_coords, cart2d13_coords
356
357contains
358
359 !> Reads the configuration file post_process.inp, in order
360 !! to populate parameters in module m_global_parameters.f90
361 !! with the user provided inputs
362 impure subroutine s_read_input_file
363
364 character(LEN=name_len) :: file_loc !<
365 !! Generic string used to store the address of a particular file
366
367 logical :: file_check !<
368 !! Generic logical used for the purpose of asserting whether a file
369 !! is or is not present in the designated location
370
371 integer :: iostatus
372 !! Integer to check iostat of file read
373
374 character(len=1000) :: line
375
376 ! Namelist for all of the parameters to be inputted by the user
377 namelist /user_inputs/ case_dir, m, n, p, t_step_start, &
380 weno_order, bc_x, &
381 bc_y, bc_z, fluid_pp, bub_pp, format, precision, &
383 hypoelasticity, g, mhd, &
406
407 ! Inquiring the status of the post_process.inp file
408 file_loc = 'post_process.inp'
409 inquire (file=trim(file_loc), exist=file_check)
410
411 ! Checking whether the input file is there. If it is, the input file
412 ! is read. If not, the program is terminated.
413 if (file_check) then
414 open (1, file=trim(file_loc), form='formatted', &
415 status='old', action='read')
416 read (1, nml=user_inputs, iostat=iostatus)
417
418 if (iostatus /= 0) then
419 backspace(1)
420 read (1, fmt='(A)') line
421 print *, 'Invalid line in namelist: '//trim(line)
422 call s_mpi_abort('Invalid line in post_process.inp. It is '// &
423 'likely due to a datatype mismatch. Exiting.')
424 end if
425
426 close (1)
427
428 call s_update_cell_bounds(cells_bounds, m, n, p)
429
430 if (down_sample) then
431 m = int((m + 1)/3) - 1
432 n = int((n + 1)/3) - 1
433 p = int((p + 1)/3) - 1
434 end if
435
436 ! Store m,n,p into global m,n,p
437 m_glb = m
438 n_glb = n
439 p_glb = p
440
441 nglobal = int(m_glb + 1, kind=8)*int(n_glb + 1, kind=8)*int(p_glb + 1, kind=8)
442
443 if (cfl_adap_dt .or. cfl_const_dt) cfl_dt = .true.
444
445 if (any((/bc_x%beg, bc_x%end, bc_y%beg, bc_y%end, bc_z%beg, bc_z%end/) == -17) .or. &
446 num_bc_patches > 0) then
447 bc_io = .true.
448 end if
449
450 else
451 call s_mpi_abort('File post_process.inp is missing. Exiting.')
452 end if
453
454 end subroutine s_read_input_file
455
456 !> Checking that the user inputs make sense, i.e. that the
457 !! individual choices are compatible with the code's options
458 !! and that the combination of these choices results into a
459 !! valid configuration for the post-process
460 impure subroutine s_check_input_file
461
462 character(LEN=len_trim(case_dir)) :: file_loc !<
463 !! Generic string used to store the address of a particular file
464
465 logical :: dir_check !<
466 !! Logical variable used to test the existence of folders
467
468 ! Checking the existence of the case folder
469 case_dir = adjustl(case_dir)
470
471 file_loc = trim(case_dir)//'/.'
472
473 call my_inquire(file_loc, dir_check)
474
475 ! Constraint on the location of the case directory
476 if (dir_check .neqv. .true.) then
477 call s_mpi_abort('Unsupported choice for the value of '// &
478 'case_dir. Exiting.')
479 end if
480
482 call s_check_inputs()
483
484 end subroutine s_check_input_file
485
486 !> @brief Load grid and conservative data for a time step, fill ghost-cell buffers, and convert to primitive variables.
487 impure subroutine s_perform_time_step(t_step)
488
489 integer, intent(inout) :: t_step
490 if (proc_rank == 0) then
491 if (cfl_dt) then
492 print '(" [", I3, "%] Saving ", I8, " of ", I0, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, "")', &
493 int(ceiling(100._wp*(real(t_step - n_start)/(n_save)))), &
495 else
496 print '(" [", I3, "%] Saving ", I8, " of ", I0, " @ t_step = ", I8, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, "")', &
497 int(ceiling(100._wp*(real(t_step - t_step_start)/(t_step_stop - t_step_start + 1)))), &
498 (t_step - t_step_start)/t_step_save + 1, &
500 t_step, wall_time_avg, wall_time
501 end if
502 end if
503
504 ! Populating the grid and conservative variables
505 call s_read_data_files(t_step)
506
507 ! Populating the buffer regions of the grid and conservative variables
508 if (buff_size > 0) then
511 end if
512
513 ! Initialize the Temperature cache.
515
516 ! Converting the conservative variables to the primitive ones
518
519 end subroutine s_perform_time_step
520
521 !> @brief Derive requested flow quantities from primitive variables and write them to the formatted database files.
522 impure subroutine s_save_data(t_step, varname, pres, c, H)
523
524 integer, intent(inout) :: t_step
525 character(LEN=name_len), intent(inout) :: varname
526 real(wp), intent(inout) :: pres, c, h
527 real(wp) :: theta1, theta2
528 real(wp), dimension(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end) :: liutex_mag
529 real(wp), dimension(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end, 3) :: liutex_axis
530 integer :: i, j, k, l, kx, ky, kz, kf, j_glb, k_glb, l_glb
531 real(wp) :: en_tot
532 character(50) :: filename, dirname
533 logical :: file_exists, dir_exists
534 integer :: x_beg, x_end, y_beg, y_end, z_beg, z_end
535
536 if (output_partial_domain) then
538 x_beg = -offset_x%beg + x_output_idx%beg
539 x_end = offset_x%end + x_output_idx%end
540 y_beg = -offset_y%beg + y_output_idx%beg
541 y_end = offset_y%end + y_output_idx%end
542 z_beg = -offset_z%beg + z_output_idx%beg
543 z_end = offset_z%end + z_output_idx%end
544 else
545 x_beg = -offset_x%beg
546 x_end = offset_x%end + m
547 y_beg = -offset_y%beg
548 y_end = offset_y%end + n
549 z_beg = -offset_z%beg
550 z_end = offset_z%end + p
551 end if
552
553 ! Opening a new formatted database file
555
556 if (sim_data .and. proc_rank == 0) then
559 end if
560
561 if (sim_data) then
564 end if
565
566 ! Adding the grid to the formatted database file
568
569 ! Computing centered finite-difference coefficients in x-direction
570 if (omega_wrt(2) .or. omega_wrt(3) .or. qm_wrt .or. liutex_wrt .or. schlieren_wrt) then
574 end if
575
576 ! Computing centered finite-difference coefficients in y-direction
577 if (omega_wrt(1) .or. omega_wrt(3) .or. qm_wrt .or. liutex_wrt .or. (n > 0 .and. schlieren_wrt)) then
581 end if
582
583 ! Computing centered finite-difference coefficients in z-direction
584 if (omega_wrt(1) .or. omega_wrt(2) .or. qm_wrt .or. liutex_wrt .or. (p > 0 .and. schlieren_wrt)) then
588 end if
589
590 ! Adding the partial densities to the formatted database file
591 if ((model_eqns == 2) .or. (model_eqns == 3) .or. (model_eqns == 4)) then
592 do i = 1, num_fluids
593 if (alpha_rho_wrt(i) .or. (cons_vars_wrt .or. prim_vars_wrt)) then
594 q_sf(:, :, :) = q_cons_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
595 if (model_eqns /= 4) then
596 write (varname, '(A,I0)') 'alpha_rho', i
597 else
598 write (varname, '(A,I0)') 'rho', i
599 end if
601
602 varname(:) = ' '
603
604 end if
605 end do
606 end if
607
608 ! Adding the density to the formatted database file
609 if ((rho_wrt .or. (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) .and. (.not. relativity)) then
610 q_sf(:, :, :) = rho_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
611 write (varname, '(A)') 'rho'
613
614 varname(:) = ' '
615 end if
616
617 if (relativity .and. (rho_wrt .or. prim_vars_wrt)) then
618 q_sf(:, :, :) = q_prim_vf(1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
619 write (varname, '(A)') 'rho'
621
622 varname(:) = ' '
623 end if
624
625 if (relativity .and. (rho_wrt .or. cons_vars_wrt)) then
626 ! For relativistic flow, conservative and primitive densities are different
627 ! Hard-coded single-component for now
628 q_sf(:, :, :) = q_cons_vf(1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
629 write (varname, '(A)') 'D'
631
632 varname(:) = ' '
633 end if
634
635 ! Adding the momentum to the formatted database file
636 do i = 1, e_idx - mom_idx%beg
637 if (mom_wrt(i) .or. cons_vars_wrt) then
638 q_sf(:, :, :) = q_cons_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
639 write (varname, '(A,I0)') 'mom', i
641
642 varname(:) = ' '
643
644 end if
645 end do
646
647 ! Adding the velocity to the formatted database file
648 do i = 1, e_idx - mom_idx%beg
649 if (vel_wrt(i) .or. prim_vars_wrt) then
650 q_sf(:, :, :) = q_prim_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
651 write (varname, '(A,I0)') 'vel', i
653
654 varname(:) = ' '
655
656 end if
657 end do
658
659 ! Adding the species' concentrations to the formatted database file
660 if (chemistry) then
661 do i = 1, num_species
662 if (chem_wrt_y(i) .or. prim_vars_wrt) then
663 q_sf(:, :, :) = q_prim_vf(chemxb + i - 1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
664 write (varname, '(A,A)') 'Y_', trim(species_names(i))
666
667 varname(:) = ' '
668
669 end if
670 end do
671
672 if (chem_wrt_t) then
673 q_sf(:, :, :) = q_t_sf%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
674 write (varname, '(A)') 'T'
676
677 varname(:) = ' '
678 end if
679 end if
680
681 ! Adding the flux limiter function to the formatted database file
682 do i = 1, e_idx - mom_idx%beg
683 if (flux_wrt(i)) then
684
686
687 write (varname, '(A,I0)') 'flux', i
689
690 varname(:) = ' '
691 end if
692 end do
693
694 ! Adding the energy to the formatted database file
695 if (e_wrt .or. cons_vars_wrt) then
696 q_sf(:, :, :) = q_cons_vf(e_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
697 write (varname, '(A)') 'E'
699
700 varname(:) = ' '
701
702 end if
703
704 ! Adding the individual energies to the formatted database file
705 if (model_eqns == 3) then
706 do i = 1, num_fluids
707 if (alpha_rho_e_wrt(i) .or. cons_vars_wrt) then
708 q_sf = q_cons_vf(i + intxb - 1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
709 write (varname, '(A,I0)') 'alpha_rho_e', i
711
712 varname(:) = ' '
713 end if
714 end do
715 end if
716
717 !Adding Energy cascade FFT
718 if (fft_wrt) then
719
720 do l = 0, p
721 do k = 0, n
722 do j = 0, m
723 data_cmplx(j + 1, k + 1, l + 1) = cmplx(q_cons_vf(mom_idx%beg)%sf(j, k, l)/q_cons_vf(1)%sf(j, k, l), 0._wp)
724 end do
725 end do
726 end do
727
728 call s_mpi_fft_fwd()
729
730 en_real = 0.5_wp*abs(data_cmplx_z)**2._wp/(1._wp*nx*ny*nz)**2._wp
731
732 do l = 0, p
733 do k = 0, n
734 do j = 0, m
735 data_cmplx(j + 1, k + 1, l + 1) = cmplx(q_cons_vf(mom_idx%beg + 1)%sf(j, k, l)/q_cons_vf(1)%sf(j, k, l), 0._wp)
736 end do
737 end do
738 end do
739
740 call s_mpi_fft_fwd()
741
742 en_real = en_real + 0.5_wp*abs(data_cmplx_z)**2._wp/(1._wp*nx*ny*nz)**2._wp
743
744 do l = 0, p
745 do k = 0, n
746 do j = 0, m
747 data_cmplx(j + 1, k + 1, l + 1) = cmplx(q_cons_vf(mom_idx%beg + 2)%sf(j, k, l)/q_cons_vf(1)%sf(j, k, l), 0._wp)
748 end do
749 end do
750 end do
751
752 call s_mpi_fft_fwd()
753
754 en_real = en_real + 0.5_wp*abs(data_cmplx_z)**2._wp/(1._wp*nx*ny*nz)**2._wp
755
756 do kf = 1, nf
757 en(kf) = 0._wp
758 end do
759
760 do l = 1, nz
761 do k = 1, nyloc2
762 do j = 1, nxloc
763
764 j_glb = j + cart3d_coords(2)*nxloc
765 k_glb = k + cart3d_coords(3)*nyloc2
766 l_glb = l
767
768 if (j_glb >= (m_glb + 1)/2) then
769 kx = (j_glb - 1) - (m_glb + 1)
770 else
771 kx = j_glb - 1
772 end if
773
774 if (k_glb >= (n_glb + 1)/2) then
775 ky = (k_glb - 1) - (n_glb + 1)
776 else
777 ky = k_glb - 1
778 end if
779
780 if (l_glb >= (p_glb + 1)/2) then
781 kz = (l_glb - 1) - (p_glb + 1)
782 else
783 kz = l_glb - 1
784 end if
785
786 kf = nint(sqrt(kx**2._wp + ky**2._wp + kz**2._wp)) + 1
787
788 en(kf) = en(kf) + en_real(j, k, l)
789
790 end do
791 end do
792 end do
793
794#ifdef MFC_MPI
795 call mpi_allreduce(mpi_in_place, en, nf, mpi_p, mpi_sum, mpi_comm_world, ierr)
796#endif
797
798 if (proc_rank == 0) then
799 call s_create_directory('En_FFT_DATA')
800 write (filename, '(a,i0,a)') 'En_FFT_DATA/En_tot', t_step, '.dat'
801 inquire (file=filename, exist=file_exists)
802 if (file_exists) then
803 call s_delete_file(trim(filename))
804 end if
805 end if
806
807 do kf = 1, nf
808 if (proc_rank == 0) then
809 write (filename, '(a,i0,a)') 'En_FFT_DATA/En_tot', t_step, '.dat'
810 inquire (file=filename, exist=file_exists)
811 if (file_exists) then
812 open (1, file=filename, position='append', status='old')
813 write (1, *) en(kf), t_step
814 close (1)
815 else
816 open (1, file=filename, status='new')
817 write (1, *) en(kf), t_step
818 close (1)
819 end if
820 end if
821 end do
822
823 end if
824
825 ! Adding the magnetic field to the formatted database file
826 if (mhd .and. prim_vars_wrt) then
827 do i = b_idx%beg, b_idx%end
828 q_sf(:, :, :) = q_prim_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
829
830 ! 1D: output By, Bz
831 if (n == 0) then
832 if (i == b_idx%beg) then
833 write (varname, '(A)') 'By'
834 else
835 write (varname, '(A)') 'Bz'
836 end if
837 ! 2D/3D: output Bx, By, Bz
838 else
839 if (i == b_idx%beg) then
840 write (varname, '(A)') 'Bx'
841 elseif (i == b_idx%beg + 1) then
842 write (varname, '(A)') 'By'
843 else
844 write (varname, '(A)') 'Bz'
845 end if
846 end if
847
849 varname(:) = ' '
850 end do
851 end if
852
853 ! Adding the elastic shear stresses to the formatted database file
854 if (elasticity) then
855 do i = 1, stress_idx%end - stress_idx%beg + 1
856 if (prim_vars_wrt) then
857 q_sf(:, :, :) = q_prim_vf(i - 1 + stress_idx%beg)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
858 write (varname, '(A,I0)') 'tau', i
860 end if
861 varname(:) = ' '
862 end do
863 end if
864
865 if (hyperelasticity) then
866 do i = 1, xiend - xibeg + 1
867 if (prim_vars_wrt) then
868 q_sf(:, :, :) = q_prim_vf(i - 1 + xibeg)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
869 write (varname, '(A,I0)') 'xi', i
871 end if
872 varname(:) = ' '
873 end do
874 end if
875
876 if (cont_damage) then
877 q_sf(:, :, :) = q_cons_vf(damage_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
878 write (varname, '(A)') 'damage_state'
880
881 varname(:) = ' '
882 end if
883
884 if (hyper_cleaning) then
885 q_sf = q_cons_vf(psi_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
886 write (varname, '(A)') 'psi'
888
889 varname(:) = ' '
890 end if
891
892 ! Adding the pressure to the formatted database file
893 if (pres_wrt .or. prim_vars_wrt) then
894 q_sf(:, :, :) = q_prim_vf(e_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
895 write (varname, '(A)') 'pres'
897
898 varname(:) = ' '
899
900 end if
901
902 ! Adding the volume fraction(s) to the formatted database file
903 if (((model_eqns == 2) .and. (bubbles_euler .neqv. .true.)) &
904 .or. (model_eqns == 3) &
905 ) then
906
907 do i = 1, num_fluids - 1
908 if (alpha_wrt(i) .or. (cons_vars_wrt .or. prim_vars_wrt)) then
909 q_sf(:, :, :) = q_cons_vf(i + e_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
910 write (varname, '(A,I0)') 'alpha', i
912
913 varname(:) = ' '
914
915 end if
916 end do
917
918 if (alpha_wrt(num_fluids) &
919 .or. &
920 (cons_vars_wrt .or. prim_vars_wrt)) then
921 if (igr) then
922 do k = z_beg, z_end
923 do j = y_beg, y_end
924 do i = x_beg, x_end
925 q_sf(i, j, k) = 1._wp
926 do l = 1, num_fluids - 1
927 q_sf(i, j, k) = q_sf(i, j, k) - q_cons_vf(e_idx + l)%sf(i, j, k)
928 end do
929 end do
930 end do
931 end do
932 else
933 q_sf(:, :, :) = q_cons_vf(adv_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
934 end if
935 write (varname, '(A,I0)') 'alpha', num_fluids
937
938 varname(:) = ' '
939
940 end if
941
942 end if
943
944 ! Adding specific heat ratio function to formatted database file
945 if (gamma_wrt &
946 .or. &
947 (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then
948 q_sf(:, :, :) = gamma_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
949 write (varname, '(A)') 'gamma'
951
952 varname(:) = ' '
953
954 end if
955
956 ! Adding the specific heat ratio to the formatted database file
957 if (heat_ratio_wrt) then
958
960
961 write (varname, '(A)') 'heat_ratio'
963
964 varname(:) = ' '
965
966 end if
967
968 ! Adding liquid stiffness function to formatted database file
969 if (pi_inf_wrt &
970 .or. &
971 (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then
972 q_sf(:, :, :) = pi_inf_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
973 write (varname, '(A)') 'pi_inf'
975
976 varname(:) = ' '
977
978 end if
979
980 ! Adding the liquid stiffness to the formatted database file
981 if (pres_inf_wrt) then
982
984
985 write (varname, '(A)') 'pres_inf'
987
988 varname(:) = ' '
989
990 end if
991
992 ! Adding the sound speed to the formatted database file
993 if (c_wrt) then
994 do k = -offset_z%beg, p + offset_z%end
995 do j = -offset_y%beg, n + offset_y%end
996 do i = -offset_x%beg, m + offset_x%end
997 do l = 1, adv_idx%end - e_idx
998 adv(l) = q_prim_vf(e_idx + l)%sf(i, j, k)
999 end do
1000
1001 pres = q_prim_vf(e_idx)%sf(i, j, k)
1002
1003 h = ((gamma_sf(i, j, k) + 1._wp)*pres + &
1004 pi_inf_sf(i, j, k) + qv_sf(i, j, k))/rho_sf(i, j, k)
1005
1006 call s_compute_speed_of_sound(pres, rho_sf(i, j, k), &
1007 gamma_sf(i, j, k), pi_inf_sf(i, j, k), &
1008 h, adv, 0._wp, 0._wp, c, qv_sf(i, j, k))
1009
1010 q_sf(i, j, k) = c
1011 end do
1012 end do
1013 end do
1014
1015 write (varname, '(A)') 'c'
1017
1018 varname(:) = ' '
1019
1020 end if
1021
1022 ! Adding the vorticity to the formatted database file
1023 do i = 1, 3
1024 if (omega_wrt(i)) then
1025
1027
1028 write (varname, '(A,I0)') 'omega', i
1030
1031 varname(:) = ' '
1032 end if
1033 end do
1034
1035 if (ib) then
1036 q_sf(:, :, :) = real(ib_markers%sf(-offset_x%beg:m + offset_x%end, -offset_y%beg:n + offset_y%end, -offset_z%beg:p + offset_z%end))
1037 varname = 'ib_markers'
1039 end if
1040
1041 ! Adding Q_M to the formatted database file
1042 if (p > 0 .and. qm_wrt) then
1044
1045 write (varname, '(A)') 'qm'
1047
1048 varname(:) = ' '
1049 end if
1050
1051 ! Adding Liutex magnitude to the formatted database file
1052 if (liutex_wrt) then
1053
1054 ! Compute Liutex vector and its magnitude
1055 call s_derive_liutex(q_prim_vf, liutex_mag, liutex_axis)
1056
1057 ! Liutex magnitude
1058 q_sf = liutex_mag
1059
1060 write (varname, '(A)') 'liutex_mag'
1062
1063 varname(:) = ' '
1064
1065 ! Liutex axis
1066 do i = 1, 3
1067 q_sf = liutex_axis(:, :, :, i)
1068
1069 write (varname, '(A,I0)') 'liutex_axis', i
1071
1072 varname(:) = ' '
1073 end do
1074
1075 end if
1076
1077 ! Adding numerical Schlieren function to formatted database file
1078 if (schlieren_wrt) then
1079
1081
1082 write (varname, '(A)') 'schlieren'
1084
1085 varname(:) = ' '
1086
1087 end if
1088
1089 ! Adding the color function to formatted database file
1090 if (cf_wrt) then
1091 q_sf(:, :, :) = q_cons_vf(c_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1092 write (varname, '(A,I0)') 'color_function'
1094 varname(:) = ' '
1095
1096 end if
1097
1098 ! Adding the volume fraction(s) to the formatted database file
1099 if (bubbles_euler) then
1100 do i = adv_idx%beg, adv_idx%end
1101 q_sf(:, :, :) = q_cons_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1102 write (varname, '(A,I0)') 'alpha', i - e_idx
1104 varname(:) = ' '
1105 end do
1106 end if
1107
1108 ! Adding the bubble variables to the formatted database file
1109 if (bubbles_euler) then
1110 !nR
1111 do i = 1, nb
1112 q_sf(:, :, :) = q_cons_vf(bub_idx%rs(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1113 write (varname, '(A,I3.3)') 'nR', i
1115 varname(:) = ' '
1116 end do
1117
1118 !nRdot
1119 do i = 1, nb
1120 q_sf(:, :, :) = q_cons_vf(bub_idx%vs(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1121 write (varname, '(A,I3.3)') 'nV', i
1123 varname(:) = ' '
1124 end do
1125 if ((polytropic .neqv. .true.) .and. (.not. qbmm)) then
1126 !nP
1127 do i = 1, nb
1128 q_sf(:, :, :) = q_cons_vf(bub_idx%ps(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1129 write (varname, '(A,I3.3)') 'nP', i
1131 varname(:) = ' '
1132 end do
1133
1134 !nM
1135 do i = 1, nb
1136 q_sf(:, :, :) = q_cons_vf(bub_idx%ms(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1137 write (varname, '(A,I3.3)') 'nM', i
1139 varname(:) = ' '
1140 end do
1141 end if
1142
1143 ! number density
1144 if (adv_n) then
1145 q_sf(:, :, :) = q_cons_vf(n_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1146 write (varname, '(A)') 'n'
1148 varname(:) = ' '
1149 end if
1150 end if
1151
1152 ! Adding the lagrangian subgrid variables to the formatted database file
1153 if (bubbles_lagrange) then
1154 !! Void fraction field
1155 q_sf(:, :, :) = 1._wp - q_cons_vf(beta_idx)%sf( &
1156 -offset_x%beg:m + offset_x%end, &
1157 -offset_y%beg:n + offset_y%end, &
1158 -offset_z%beg:p + offset_z%end)
1159 write (varname, '(A)') 'voidFraction'
1161 varname(:) = ' '
1162
1163 if (lag_txt_wrt) call s_write_lag_bubbles_results_to_text(t_step) ! text output
1164 if (lag_db_wrt) call s_write_lag_bubbles_to_formatted_database_file(t_step) ! silo file output
1165 end if
1166
1167 if (sim_data .and. proc_rank == 0) then
1170 end if
1171
1172 ! Closing the formatted database file
1174
1175 end subroutine s_save_data
1176
1177 !> @brief Transpose 3-D complex data from x-pencil to y-pencil layout via MPI_Alltoall.
1178 subroutine s_mpi_transpose_x2y
1179 complex(c_double_complex), allocatable :: sendbuf(:), recvbuf(:)
1180 integer :: dest_rank, src_rank
1181 integer :: i, j, k, l
1183#ifdef MFC_MPI
1184
1185 allocate (sendbuf(nx*nyloc*nzloc))
1186 allocate (recvbuf(nx*nyloc*nzloc))
1187
1188 do dest_rank = 0, num_procs_y - 1
1189 do l = 1, nzloc
1190 do k = 1, nyloc
1191 do j = 1, nxloc
1192 sendbuf(j + (k - 1)*nxloc + (l - 1)*nxloc*nyloc + dest_rank*nxloc*nyloc*nzloc) = data_cmplx(j + dest_rank*nxloc, k, l)
1193 end do
1194 end do
1195 end do
1196 end do
1197
1198 call mpi_alltoall(sendbuf, nxloc*nyloc*nzloc, mpi_c_double_complex, &
1199 recvbuf, nxloc*nyloc*nzloc, mpi_c_double_complex, mpi_comm_cart12, ierr)
1200
1201 do src_rank = 0, num_procs_y - 1
1202 do l = 1, nzloc
1203 do k = 1, nyloc
1204 do j = 1, nxloc
1205 data_cmplx_y(j, k + src_rank*nyloc, l) = recvbuf(j + (k - 1)*nxloc + (l - 1)*nxloc*nyloc + src_rank*nxloc*nyloc*nzloc)
1206 end do
1207 end do
1208 end do
1209 end do
1210
1211 deallocate (sendbuf)
1212 deallocate (recvbuf)
1213
1214#endif
1215
1216 end subroutine s_mpi_transpose_x2y
1217
1218 !> @brief Transpose 3-D complex data from y-pencil to z-pencil layout via MPI_Alltoall.
1219 subroutine s_mpi_transpose_y2z
1220 complex(c_double_complex), allocatable :: sendbuf(:), recvbuf(:)
1221 integer :: dest_rank, src_rank
1222 integer :: j, k, l
1224#ifdef MFC_MPI
1225
1226 allocate (sendbuf(ny*nxloc*nzloc))
1227 allocate (recvbuf(ny*nxloc*nzloc))
1228
1229 do dest_rank = 0, num_procs_z - 1
1230 do l = 1, nzloc
1231 do j = 1, nxloc
1232 do k = 1, nyloc2
1233 sendbuf(k + (j - 1)*nyloc2 + (l - 1)*(nyloc2*nxloc) + dest_rank*nyloc2*nxloc*nzloc) = data_cmplx_y(j, k + dest_rank*nyloc2, l)
1234 end do
1235 end do
1236 end do
1237 end do
1238
1239 call mpi_alltoall(sendbuf, nyloc2*nxloc*nzloc, mpi_c_double_complex, &
1240 recvbuf, nyloc2*nxloc*nzloc, mpi_c_double_complex, mpi_comm_cart13, ierr)
1241
1242 do src_rank = 0, num_procs_z - 1
1243 do l = 1, nzloc
1244 do j = 1, nxloc
1245 do k = 1, nyloc2
1246 data_cmplx_z(j, k, l + src_rank*nzloc) = recvbuf(k + (j - 1)*nyloc2 + (l - 1)*(nyloc2*nxloc) + src_rank*nyloc2*nxloc*nzloc)
1247 end do
1248 end do
1249 end do
1250 end do
1251
1252 deallocate (sendbuf)
1253 deallocate (recvbuf)
1254
1255#endif
1256
1257 end subroutine s_mpi_transpose_y2z
1258
1259 !> @brief Initialize all post-process sub-modules, set up I/O pointers, and prepare FFTW plans and MPI communicators.
1260 impure subroutine s_initialize_modules
1261 ! Computation of parameters, allocation procedures, and/or any other tasks
1262 ! needed to properly setup the modules
1263 integer :: size_n(1), inembed(1), onembed(1)
1266 if (bubbles_euler .or. bubbles_lagrange) then
1268 end if
1269 if (num_procs > 1) then
1272 end if
1278
1279 ! Associate pointers for serial or parallel I/O
1280 if (parallel_io .neqv. .true.) then
1282 else
1284 end if
1285
1286#ifdef MFC_MPI
1287 if (fft_wrt) then
1288
1289 num_procs_x = (m_glb + 1)/(m + 1)
1290 num_procs_y = (n_glb + 1)/(n + 1)
1291 num_procs_z = (p_glb + 1)/(p + 1)
1292
1293 nx = m_glb + 1
1294 ny = n_glb + 1
1295 nz = p_glb + 1
1296
1297 nxloc = (m_glb + 1)/num_procs_y
1298 nyloc = n + 1
1299 nyloc2 = (n_glb + 1)/num_procs_z
1300 nzloc = p + 1
1301
1302 nf = max(nx, ny, nz)
1303
1304#ifdef MFC_DEBUG
1305# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1306 block
1307# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1308 use iso_fortran_env, only: output_unit
1309# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1310
1311# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1312 print *, 'm_start_up.fpp:1022: ', '@:ALLOCATE(data_in(Nx*Nyloc*Nzloc))'
1313# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1314
1315# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1316 call flush (output_unit)
1317# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1318 end block
1319# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1320#endif
1321# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1322 allocate (data_in(nx*nyloc*nzloc))
1323# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1324
1325# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1326
1327# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1328#if defined(MFC_OpenACC)
1329# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1330!$acc enter data create(data_in)
1331# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1332#elif defined(MFC_OpenMP)
1333# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1334!$omp target enter data map(always,alloc:data_in)
1335# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1336#endif
1337#ifdef MFC_DEBUG
1338# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1339 block
1340# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1341 use iso_fortran_env, only: output_unit
1342# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1343
1344# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1345 print *, 'm_start_up.fpp:1023: ', '@:ALLOCATE(data_out(Nx*Nyloc*Nzloc))'
1346# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1347
1348# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1349 call flush (output_unit)
1350# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1351 end block
1352# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1353#endif
1354# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1355 allocate (data_out(nx*nyloc*nzloc))
1356# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1357
1358# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1359
1360# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1361#if defined(MFC_OpenACC)
1362# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1363!$acc enter data create(data_out)
1364# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1365#elif defined(MFC_OpenMP)
1366# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1367!$omp target enter data map(always,alloc:data_out)
1368# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1369#endif
1370
1371#ifdef MFC_DEBUG
1372# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1373 block
1374# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1375 use iso_fortran_env, only: output_unit
1376# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1377
1378# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1379 print *, 'm_start_up.fpp:1025: ', '@:ALLOCATE(data_cmplx(Nx, Nyloc, Nzloc))'
1380# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1381
1382# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1383 call flush (output_unit)
1384# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1385 end block
1386# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1387#endif
1388# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1389 allocate (data_cmplx(nx, nyloc, nzloc))
1390# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1391
1392# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1393
1394# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1395#if defined(MFC_OpenACC)
1396# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1397!$acc enter data create(data_cmplx)
1398# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1399#elif defined(MFC_OpenMP)
1400# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1401!$omp target enter data map(always,alloc:data_cmplx)
1402# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1403#endif
1404#ifdef MFC_DEBUG
1405# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1406 block
1407# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1408 use iso_fortran_env, only: output_unit
1409# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1410
1411# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1412 print *, 'm_start_up.fpp:1026: ', '@:ALLOCATE(data_cmplx_y(Nxloc, Ny, Nzloc))'
1413# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1414
1415# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1416 call flush (output_unit)
1417# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1418 end block
1419# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1420#endif
1421# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1422 allocate (data_cmplx_y(nxloc, ny, nzloc))
1423# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1424
1425# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1426
1427# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1428#if defined(MFC_OpenACC)
1429# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1430!$acc enter data create(data_cmplx_y)
1431# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1432#elif defined(MFC_OpenMP)
1433# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1434!$omp target enter data map(always,alloc:data_cmplx_y)
1435# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1436#endif
1437#ifdef MFC_DEBUG
1438# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1439 block
1440# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1441 use iso_fortran_env, only: output_unit
1442# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1443
1444# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1445 print *, 'm_start_up.fpp:1027: ', '@:ALLOCATE(data_cmplx_z(Nxloc, Nyloc2, Nz))'
1446# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1447
1448# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1449 call flush (output_unit)
1450# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1451 end block
1452# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1453#endif
1454# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1455 allocate (data_cmplx_z(nxloc, nyloc2, nz))
1456# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1457
1458# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1459
1460# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1461#if defined(MFC_OpenACC)
1462# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1463!$acc enter data create(data_cmplx_z)
1464# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1465#elif defined(MFC_OpenMP)
1466# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1467!$omp target enter data map(always,alloc:data_cmplx_z)
1468# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1469#endif
1470
1471#ifdef MFC_DEBUG
1472# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1473 block
1474# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1475 use iso_fortran_env, only: output_unit
1476# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1477
1478# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1479 print *, 'm_start_up.fpp:1029: ', '@:ALLOCATE(En_real(Nxloc, Nyloc2, Nz))'
1480# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1481
1482# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1483 call flush (output_unit)
1484# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1485 end block
1486# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1487#endif
1488# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1489 allocate (en_real(nxloc, nyloc2, nz))
1490# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1491
1492# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1493
1494# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1495#if defined(MFC_OpenACC)
1496# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1497!$acc enter data create(En_real)
1498# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1499#elif defined(MFC_OpenMP)
1500# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1501!$omp target enter data map(always,alloc:En_real)
1502# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1503#endif
1504#ifdef MFC_DEBUG
1505# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1506 block
1507# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1508 use iso_fortran_env, only: output_unit
1509# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1510
1511# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1512 print *, 'm_start_up.fpp:1030: ', '@:ALLOCATE(En(Nf))'
1513# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1514
1515# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1516 call flush (output_unit)
1517# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1518 end block
1519# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1520#endif
1521# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1522 allocate (en(nf))
1523# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1524
1525# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1526
1527# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1528#if defined(MFC_OpenACC)
1529# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1530!$acc enter data create(En)
1531# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1532#elif defined(MFC_OpenMP)
1533# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1534!$omp target enter data map(always,alloc:En)
1535# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1536#endif
1537
1538 size_n(1) = nx
1539 inembed(1) = nx
1540 onembed(1) = nx
1541
1542 fwd_plan_x = fftw_plan_many_dft(1, size_n, nyloc*nzloc, &
1543 data_in, inembed, 1, nx, &
1544 data_out, onembed, 1, nx, &
1545 fftw_forward, fftw_measure)
1546
1547 size_n(1) = ny
1548 inembed(1) = ny
1549 onembed(1) = ny
1550
1551 fwd_plan_y = fftw_plan_many_dft(1, size_n, nxloc*nzloc, &
1552 data_out, inembed, 1, ny, &
1553 data_in, onembed, 1, ny, &
1554 fftw_forward, fftw_measure)
1555
1556 size_n(1) = nz
1557 inembed(1) = nz
1558 onembed(1) = nz
1559
1560 fwd_plan_z = fftw_plan_many_dft(1, size_n, nxloc*nyloc2, &
1561 data_in, inembed, 1, nz, &
1562 data_out, onembed, 1, nz, &
1563 fftw_forward, fftw_measure)
1564
1565 call mpi_cart_create(mpi_comm_world, 3, (/num_procs_x, &
1567 (/.true., .true., .true./), &
1568 .false., mpi_comm_cart, ierr)
1569 call mpi_cart_coords(mpi_comm_cart, proc_rank, 3, &
1571
1572 call mpi_cart_sub(mpi_comm_cart, (/.true., .true., .false./), mpi_comm_cart12, ierr)
1573 call mpi_comm_rank(mpi_comm_cart12, proc_rank12, ierr)
1574 call mpi_cart_coords(mpi_comm_cart12, proc_rank12, 2, cart2d12_coords, ierr)
1575
1576 call mpi_cart_sub(mpi_comm_cart, (/.true., .false., .true./), mpi_comm_cart13, ierr)
1577 call mpi_comm_rank(mpi_comm_cart13, proc_rank13, ierr)
1578 call mpi_cart_coords(mpi_comm_cart13, proc_rank13, 2, cart2d13_coords, ierr)
1579
1580 end if
1581#endif
1582 end subroutine s_initialize_modules
1583
1584 !> @brief Perform a distributed forward 3-D FFT using pencil decomposition with FFTW and MPI transposes.
1585 subroutine s_mpi_fft_fwd
1586
1587 integer :: j, k, l
1588
1589#ifdef MFC_MPI
1590
1591 do l = 1, nzloc
1592 do k = 1, nyloc
1593 do j = 1, nx
1594 data_in(j + (k - 1)*nx + (l - 1)*nx*nyloc) = data_cmplx(j, k, l)
1595 end do
1596 end do
1597 end do
1598
1599 call fftw_execute_dft(fwd_plan_x, data_in, data_out)
1600
1601 do l = 1, nzloc
1602 do k = 1, nyloc
1603 do j = 1, nx
1604 data_cmplx(j, k, l) = data_out(j + (k - 1)*nx + (l - 1)*nx*nyloc)
1605 end do
1606 end do
1607 end do
1608
1609 call s_mpi_transpose_x2y !!Change Pencil from data_cmplx to data_cmpx_y
1610
1611 do l = 1, nzloc
1612 do k = 1, nxloc
1613 do j = 1, ny
1614 data_out(j + (k - 1)*ny + (l - 1)*ny*nxloc) = data_cmplx_y(k, j, l)
1615 end do
1616 end do
1617 end do
1618
1619 call fftw_execute_dft(fwd_plan_y, data_out, data_in)
1620
1621 do l = 1, nzloc
1622 do k = 1, nxloc
1623 do j = 1, ny
1624 data_cmplx_y(k, j, l) = data_in(j + (k - 1)*ny + (l - 1)*ny*nxloc)
1625 end do
1626 end do
1627 end do
1628
1629 call s_mpi_transpose_y2z !!Change Pencil from data_cmplx_y to data_cmpx_z
1630
1631 do l = 1, nyloc2
1632 do k = 1, nxloc
1633 do j = 1, nz
1634 data_in(j + (k - 1)*nz + (l - 1)*nz*nxloc) = data_cmplx_z(k, l, j)
1635 end do
1636 end do
1637 end do
1638
1639 call fftw_execute_dft(fwd_plan_z, data_in, data_out)
1640
1641 do l = 1, nyloc2
1642 do k = 1, nxloc
1643 do j = 1, nz
1644 data_cmplx_z(k, l, j) = data_out(j + (k - 1)*nz + (l - 1)*nz*nxloc)
1645 end do
1646 end do
1647 end do
1648
1649#endif
1650
1651 end subroutine s_mpi_fft_fwd
1652
1653 !> @brief Set up the MPI environment, read and broadcast user inputs, and decompose the computational domain.
1654 impure subroutine s_initialize_mpi_domain
1655
1656 num_dims = 1 + min(1, n) + min(1, p)
1657
1658 ! Initialization of the MPI environment
1659 call s_mpi_initialize()
1660
1661 ! Processor with rank 0 assigns default user input values prior to reading
1662 ! those in from the input file. Next, the user inputs are read in and their
1663 ! consistency is checked. The detection of any inconsistencies automatically
1664 ! leads to the termination of the post-process.
1665 if (proc_rank == 0) then
1666 call s_assign_default_values_to_user_inputs()
1667 call s_read_input_file()
1668 call s_check_input_file()
1669
1670 print '(" Post-processing a ", I0, "x", I0, "x", I0, " case on ", I0, " rank(s)")', m, n, p, num_procs
1671 end if
1672
1673 ! Broadcasting the user inputs to all of the processors and performing the
1674 ! parallel computational domain decomposition. Neither procedure has to be
1675 ! carried out if the post-process is in fact not truly executed in parallel.
1676 call s_mpi_bcast_user_inputs()
1677 call s_initialize_parallel_io()
1678 call s_mpi_decompose_computational_domain()
1679 call s_check_inputs_fft()
1680
1681 end subroutine s_initialize_mpi_domain
1682
1683 !> @brief Destroy FFTW plans, free MPI communicators, and finalize all post-process sub-modules.
1684 impure subroutine s_finalize_modules
1685 ! Disassociate pointers for serial and parallel I/O
1686 s_read_data_files => null()
1687
1688! if (sim_data .and. proc_rank == 0) then
1689! call s_close_intf_data_file()
1690! call s_close_energy_data_file()
1691! end if
1692
1693 if (fft_wrt) then
1694 if (c_associated(fwd_plan_x)) call fftw_destroy_plan(fwd_plan_x)
1695 if (c_associated(fwd_plan_y)) call fftw_destroy_plan(fwd_plan_y)
1696 if (c_associated(fwd_plan_z)) call fftw_destroy_plan(fwd_plan_z)
1697 if (allocated(data_in)) deallocate (data_in)
1698 if (allocated(data_out)) deallocate (data_out)
1699 if (allocated(data_cmplx)) deallocate (data_cmplx)
1700 if (allocated(data_cmplx_y)) deallocate (data_cmplx_y)
1701 if (allocated(data_cmplx_z)) deallocate (data_cmplx_z)
1702 if (allocated(en_real)) deallocate (en_real)
1703 if (allocated(en)) deallocate (en)
1704 call fftw_cleanup()
1705 end if
1706
1707#ifdef MFC_MPI
1708 if (fft_wrt) then
1709 if (mpi_comm_cart12 /= mpi_comm_null) call mpi_comm_free(mpi_comm_cart12, ierr)
1710 if (mpi_comm_cart13 /= mpi_comm_null) call mpi_comm_free(mpi_comm_cart13, ierr)
1711 if (mpi_comm_cart /= mpi_comm_null) call mpi_comm_free(mpi_comm_cart, ierr)
1712 end if
1713#endif
1714
1715 ! Deallocation procedures for the modules
1716 call s_finalize_data_output_module()
1717 call s_finalize_derived_variables_module()
1718 call s_finalize_data_input_module()
1719 call s_finalize_variables_conversion_module()
1720 if (num_procs > 1) then
1721 call s_finalize_mpi_proxy_module()
1722 call s_finalize_mpi_common_module()
1723 end if
1724 call s_finalize_global_parameters_module()
1725
1726 ! Finalizing the MPI environment
1727 call s_mpi_finalize()
1728 end subroutine s_finalize_modules
1729
1730end module m_start_up
1731
integer, intent(in) k
integer, intent(in) j
integer, intent(in) l
Noncharacteristic and processor boundary condition application for ghost cells and buffer regions.
impure subroutine, public s_initialize_boundary_common_module()
Allocates and sets up boundary condition buffer arrays for all coordinate directions.
impure subroutine, public s_populate_variables_buffers(bc_type, q_prim_vf, pb_in, mv_in)
The purpose of this procedure is to populate the buffers of the primitive variables,...
subroutine, public s_populate_grid_variables_buffers
The purpose of this subroutine is to populate the buffers of the grid variables, which are constitute...
Shared input validation checks for grid dimensions and AMD GPU compiler limits.
impure subroutine, public s_check_inputs_common
Checks compatibility of parameters in the input file. Used by all three stages.
Validates post-process input parameters and output format consistency.
impure subroutine, public s_check_inputs
Checks compatibility of parameters in the input file. Used by the post_process stage.
Multi-species chemistry interface for thermodynamic properties, reaction rates, and transport coeffic...
subroutine s_compute_q_t_sf(q_t_sf, q_cons_vf, bounds)
Initializes the temperature field from conservative variables by inverting the energy equation.
Platform-specific file and directory operations: create, delete, inquire, getcwd, and basename.
impure subroutine s_delete_file(filepath)
Deletes a file at the given path using a platform-specific system command.
impure subroutine my_inquire(fileloc, dircheck)
Inquires on the existence of a directory.
impure subroutine s_create_directory(dir_name)
Creates a directory and all its parents if it does not exist.
Reads raw simulation grid and conservative-variable data for a given time-step and fills buffer regio...
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, 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, 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(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
Writes post-processed grid and flow-variable data to Silo-HDF5 or binary database files.
impure subroutine, public s_write_grid_to_formatted_database_file(t_step)
Write the computational grid (cell-boundary coordinates) to the formatted database slave and master f...
impure subroutine, public s_write_variable_to_formatted_database_file(varname, t_step)
Write a single flow variable field to the formatted database slave and master files for a given time ...
impure subroutine, public s_open_energy_data_file()
Open the energy data file for appending volume-integrated energy budget quantities.
impure subroutine, public s_open_intf_data_file()
Open the interface data file for appending extracted interface coordinates.
impure subroutine, public s_write_energy_data_file(q_prim_vf, q_cons_vf)
Compute volume-integrated kinetic, potential, and internal energies and write the energy budget to th...
impure subroutine, public s_write_lag_bubbles_to_formatted_database_file(t_step)
Read Lagrangian bubble restart data and write bubble positions and scalar fields to the Silo database...
impure subroutine, public s_write_intf_data_file(q_prim_vf)
Extract the volume-fraction interface contour from primitive fields and write the coordinates to the ...
impure subroutine, public s_initialize_data_output_module()
Allocate storage arrays, configure output directories, and count flow variables for formatted databas...
impure subroutine, public s_close_energy_data_file()
Close the energy data file.
impure subroutine, public s_close_formatted_database_file()
Close the formatted database slave file and, for the root process, the master file.
impure subroutine, public s_open_formatted_database_file(t_step)
Open (or create) the Silo-HDF5 or Binary formatted database slave and master files for a given time s...
impure subroutine, public s_close_intf_data_file()
Close the interface data file.
impure subroutine, public s_write_lag_bubbles_results_to_text(t_step)
Subroutine that writes the post processed results in the folder 'lag_bubbles_data'.
impure subroutine, public s_define_output_region
Compute the cell-index bounds for the user-specified partial output domain in each coordinate directi...
real(wp), dimension(:, :, :), allocatable, public q_sf
Shared derived types for field data, patch geometry, bubble dynamics, and MPI I/O structures.
Computes derived flow quantities (sound speed, vorticity, Schlieren, etc.) from conservative and prim...
real(wp), dimension(:, :), allocatable, public fd_coeff_z
real(wp), dimension(:, :), allocatable, public fd_coeff_y
impure subroutine, public s_derive_liutex(q_prim_vf, liutex_mag, liutex_axis)
This subroutine gets as inputs the primitive variables. From those inputs, it proceeds to calculate t...
subroutine, public s_derive_specific_heat_ratio(q_sf)
This subroutine receives as input the specific heat ratio function, gamma_sf, and derives from it the...
subroutine, public s_derive_liquid_stiffness(q_sf)
This subroutine admits as inputs the specific heat ratio function and the liquid stiffness function,...
impure subroutine, public s_initialize_derived_variables_module
Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the...
real(wp), dimension(:, :), allocatable, public fd_coeff_x
subroutine, public s_derive_vorticity_component(i, q_prim_vf, q_sf)
This subroutine receives as inputs the indicator of the component of the vorticity that should be out...
impure subroutine, public s_derive_numerical_schlieren_function(q_cons_vf, q_sf)
This subroutine gets as inputs the conservative variables and density. From those inputs,...
subroutine, public s_derive_flux_limiter(i, q_prim_vf, q_sf)
This subroutine derives the flux_limiter at cell boundary i+1/2. This is an approximation because the...
subroutine, public s_derive_qm(q_prim_vf, q_sf)
This subroutine gets as inputs the primitive variables. From those inputs, it proceeds to calculate t...
Finite difference operators for computing divergence of velocity fields.
subroutine s_compute_finite_difference_coefficients(q, s_cc, fd_coeff_s, local_buff_size, fd_number_in, fd_order_in, offset_s)
The purpose of this subroutine is to compute the finite- difference coefficients for the centered sch...
Global parameters for the post-process: domain geometry, equation of state, and output database setti...
logical cont_damage
Continuum damage modeling.
logical hypoelasticity
Turn hypoelasticity on.
integer thermal
1 = adiabatic, 2 = isotherm, 3 = transfer
integer avg_state
Average state evaluation method.
integer recon_type
Which type of reconstruction to use.
logical, parameter chemistry
Chemistry modeling.
integer beta_idx
Index of lagrange bubbles beta.
type(int_bounds_info) offset_y
type(int_bounds_info) mom_idx
Indexes of first & last momentum eqns.
real(wp), dimension(num_fluids_max) schlieren_alpha
Amplitude coefficients of the numerical Schlieren function that are used to adjust the intensity of n...
integer num_fluids
Number of different fluids present in the flow.
logical, dimension(3) flux_wrt
real(wp), dimension(:), allocatable y_cc
type(int_bounds_info) stress_idx
Indices of elastic stresses.
integer proc_rank
Rank of the local processor.
logical mixture_err
Mixture error limiter.
logical output_partial_domain
Specify portion of domain to output for post-processing.
real(wp), dimension(:), allocatable adv
Advection variables.
integer n_idx
Index of number density.
type(int_bounds_info) z_output_idx
Indices of domain to output for post-processing.
integer muscl_order
Order of accuracy for the MUSCL reconstruction.
logical alt_soundspeed
Alternate sound speed.
integer relax_model
Phase change relaxation model.
logical, dimension(3) mom_wrt
type(int_bounds_info) cont_idx
Indexes of first & last continuity eqns.
integer fd_number
The finite-difference number is given by MAX(1, fd_order/2). Essentially, it is a measure of the half...
logical, dimension(num_fluids_max) alpha_wrt
logical, dimension(num_fluids_max) alpha_rho_wrt
type(int_bounds_info) b_idx
Indexes of first and last magnetic field eqns.
logical, dimension(num_fluids_max) alpha_rho_e_wrt
type(int_bounds_info), dimension(1:3) idwbuff
integer model_eqns
Multicomponent flow model.
integer buff_size
Number of cells in buffer region. For the variables which feature a buffer region,...
integer precision
Floating point precision of the database file(s).
logical hyperelasticity
Turn hyperelasticity on.
type(physical_parameters), dimension(num_fluids_max) fluid_pp
Database of the physical parameters of each of the fluids that is present in the flow....
type(bounds_info) z_output
Portion of domain to output for post-processing.
type(int_bounds_info) x_output_idx
impure subroutine s_initialize_global_parameters_module
Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the...
real(wp), dimension(:), allocatable x_cc
integer fd_order
The order of the finite-difference (fd) approximations of the first-order derivatives that need to be...
integer t_step_save
Interval between consecutive time-step directory.
type(int_bounds_info) offset_x
type(bub_bounds_info) bub_idx
Indexes of first & last bubble variable eqns.
integer damage_idx
Index of damage state variable (D) for continuum damage model.
logical hyper_cleaning
Hyperbolic cleaning for MHD.
real(wp), dimension(:), allocatable z_cc
real(wp) bx0
Constant magnetic field in the x-direction (1D).
logical, dimension(3) omega_wrt
integer num_procs
Number of processors.
character(len=path_len) case_dir
Case folder location.
type(int_bounds_info) y_output_idx
type(int_bounds_info) adv_idx
Indexes of first & last advection eqns.
integer weno_order
Order of accuracy for the WENO reconstruction.
type(int_bounds_info) offset_z
logical mhd
Magnetohydrodynamics.
logical parallel_io
Format of the data files.
integer e_idx
Index of energy equation.
type(cell_num_bounds) cells_bounds
logical down_sample
down sampling of the database file(s)
logical file_per_process
output format
integer t_step_start
First time-step directory.
real(wp) wall_time_avg
Wall time measurements.
logical elasticity
elasticity modeling, true for hyper or hypo
integer c_idx
Index of color function.
logical mpp_lim
Maximum volume fraction limiter.
integer igr_order
IGR reconstruction order.
integer psi_idx
Index of hyperbolic cleaning state variable for MHD.
logical, dimension(3) vel_wrt
type(subgrid_bubble_physical_parameters) bub_pp
logical, dimension(1:num_species) chem_wrt_y
logical relativity
Relativity for RMHD.
integer num_ibs
Number of immersed boundaries.
integer t_step_stop
Last time-step directory.
Utility routines for bubble model setup, coordinate transforms, array sampling, and special functions...
impure subroutine, public s_initialize_bubbles_model()
bubbles_euler + polytropic bubbles_euler + non-polytropic bubbles_lagrange + non-polytropic
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_initialize_mpi_common_module
The computation of parameters, the allocation of memory, the association of pointers and/or the execu...
MPI gather and scatter operations for distributing post-process grid and flow-variable data.
impure subroutine s_initialize_mpi_proxy_module
Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the...
Reads and validates user inputs, allocates variables, and configures MPI decomposition and I/O for po...
impure subroutine s_save_data(t_step, varname, pres, c, h)
Derive requested flow quantities from primitive variables and write them to the formatted database fi...
impure subroutine s_check_input_file
Checking that the user inputs make sense, i.e. that the individual choices are compatible with the co...
real(wp), dimension(:), allocatable en
subroutine s_mpi_fft_fwd
Perform a distributed forward 3-D FFT using pencil decomposition with FFTW and MPI transposes.
type(c_ptr) fwd_plan_y
integer mpi_comm_cart13
integer num_procs_x
complex(c_double_complex), dimension(:, :, :), allocatable data_cmplx
impure subroutine s_initialize_mpi_domain
Set up the MPI environment, read and broadcast user inputs, and decompose the computational domain.
impure subroutine s_read_input_file
Reads the configuration file post_process.inp, in order to populate parameters in module m_global_par...
complex(c_double_complex), dimension(:), allocatable data_out
integer, dimension(2) cart2d13_coords
type(c_ptr) fwd_plan_z
integer num_procs_z
complex(c_double_complex), dimension(:), allocatable data_in
integer, dimension(3) cart3d_coords
impure subroutine s_perform_time_step(t_step)
Load grid and conservative data for a time step, fill ghost-cell buffers, and convert to primitive va...
complex(c_double_complex), dimension(:, :, :), allocatable data_cmplx_y
integer num_procs_y
integer mpi_comm_cart
complex(c_double_complex), dimension(:, :, :), allocatable data_cmplx_z
integer proc_rank12
subroutine s_mpi_transpose_x2y
Transpose 3-D complex data from x-pencil to y-pencil layout via MPI_Alltoall.
impure subroutine s_finalize_modules
Destroy FFTW plans, free MPI communicators, and finalize all post-process sub-modules.
subroutine s_mpi_transpose_y2z
Transpose 3-D complex data from y-pencil to z-pencil layout via MPI_Alltoall.
real(wp), dimension(:, :, :), allocatable en_real
impure subroutine s_initialize_modules
Initialize all post-process sub-modules, set up I/O pointers, and prepare FFTW plans and MPI communic...
integer mpi_comm_cart12
type(c_ptr) fwd_plan_x
integer proc_rank13
integer, dimension(2) cart2d12_coords
Conservative-to-primitive variable conversion, mixture property evaluation, and pressure computation.
real(wp), dimension(:, :, :), allocatable, public pi_inf_sf
Scalar liquid stiffness function.
subroutine s_compute_speed_of_sound(pres, rho, gamma, pi_inf, h, adv, vel_sum, c_c, c, qv)
Computes the speed of sound from thermodynamic state variables, supporting multiple equation-of-state...
real(wp), dimension(:, :, :), allocatable, public rho_sf
Scalar density function.
real(wp), dimension(:, :, :), allocatable, public qv_sf
Scalar liquid energy reference function.
subroutine, public s_convert_conservative_to_primitive_variables(qk_cons_vf, q_t_sf, qk_prim_vf, ibounds)
The following procedure handles the conversion between the conservative variables and the primitive v...
impure subroutine, public s_initialize_variables_conversion_module
The computation of parameters, the allocation of memory, the association of pointers and/or the execu...
real(wp), dimension(:, :, :), allocatable, public gamma_sf
Scalar sp. heat ratio function.