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# 76 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
229
230# 91 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
231
232# 102 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
233
234# 115 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
235
236# 143 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
237
238# 154 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
239
240# 165 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
241
242# 176 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
243
244# 187 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
245
246# 198 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
247
248# 208 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
249
250# 214 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
251
252# 220 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
253
254# 226 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
255
256# 232 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
257
258# 234 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
259# 235 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
260! New line at end of file is required for FYPP
261# 2 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp" 2
262
263# 14 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
264
265! Caution:
266! This macro requires the use of a binding script to set CUDA_VISIBLE_DEVICES, such that we have one GPU device per MPI rank.
267! That's because for both cudaMemAdvise (preferred location) and cudaMemPrefetchAsync we use location = device_id = 0.
268! For an example see misc/nvidia_uvm/bind.sh.
269# 63 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
270
271# 81 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
272
273# 88 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
274
275# 111 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
276
277# 127 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
278
279# 153 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
280
281# 159 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
282
283# 167 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
284! New line at end of file is required for FYPP
285# 2 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp" 2
286
287!>
288!! @file
289!! @brief Contains module m_start_up
290
291!> @brief Reads and validates user inputs, allocates variables, and configures MPI decomposition and I/O for post-processing
292
294
295 ! Dependencies
296
297 use, intrinsic :: iso_c_binding
298
299 use m_derived_types !< definitions of the derived types
300
301 use m_global_parameters !< global parameters for the code
302
303 use m_mpi_proxy !< message passing interface (mpi) module proxy
304
305 use m_mpi_common !< common mpi subroutines
306
307 use m_boundary_common !< common boundary conditions subroutines
308
309 use m_variables_conversion !< subroutines to change the state variables from
310 !! one form to another
311
312 use m_data_input !< procedures reading raw simulation data to fill
313 !! the conservative, primitive and grid variables
314
315 use m_data_output !< procedures that write the grid and chosen flow
316 !! variable(s) to the formatted database file(s)
317
318 use m_derived_variables !< procedures used to compute quantities derived
319 !! from the conservative and primitive variables
320 use m_helper
321
323
325
326 use m_checker
327
328 use m_thermochem, only: num_species, species_names
329
331
332 use m_chemistry
333
334#ifdef MFC_MPI
335 use mpi !< message passing interface (mpi) module
336#endif
337
338 implicit none
339
340 include 'fftw3.f03'
341
343 complex(c_double_complex), allocatable :: data_in(:), data_out(:)
344 complex(c_double_complex), allocatable :: data_cmplx(:, :, :), data_cmplx_y(:, :, :), data_cmplx_z(:, :, :)
345 real(wp), allocatable, dimension(:, :, :) :: en_real
346 real(wp), allocatable, dimension(:) :: en
348 integer :: nx, ny, nz, nxloc, nyloc, nyloc2, nzloc, nf
349 integer :: ierr
351 integer, dimension(3) :: cart3d_coords
352 integer, dimension(2) :: cart2d12_coords, cart2d13_coords
354
355contains
356
357 !> Reads the configuration file post_process.inp, in order
358 !! to populate parameters in module m_global_parameters.f90
359 !! with the user provided inputs
360 impure subroutine s_read_input_file
361
362 character(LEN=name_len) :: file_loc !<
363 !! Generic string used to store the address of a particular file
364
365 logical :: file_check !<
366 !! Generic logical used for the purpose of asserting whether a file
367 !! is or is not present in the designated location
368
369 integer :: iostatus
370 !! Integer to check iostat of file read
371
372 character(len=1000) :: line
373
374 ! Namelist for all of the parameters to be inputted by the user
375 namelist /user_inputs/ case_dir, m, n, p, t_step_start, &
378 weno_order, bc_x, &
379 bc_y, bc_z, fluid_pp, bub_pp, format, precision, &
381 hypoelasticity, g, mhd, &
404
405 ! Inquiring the status of the post_process.inp file
406 file_loc = 'post_process.inp'
407 inquire (file=trim(file_loc), exist=file_check)
408
409 ! Checking whether the input file is there. If it is, the input file
410 ! is read. If not, the program is terminated.
411 if (file_check) then
412 open (1, file=trim(file_loc), form='formatted', &
413 status='old', action='read')
414 read (1, nml=user_inputs, iostat=iostatus)
415
416 if (iostatus /= 0) then
417 backspace(1)
418 read (1, fmt='(A)') line
419 print *, 'Invalid line in namelist: '//trim(line)
420 call s_mpi_abort('Invalid line in post_process.inp. It is '// &
421 'likely due to a datatype mismatch. Exiting.')
422 end if
423
424 close (1)
425
426 call s_update_cell_bounds(cells_bounds, m, n, p)
427
428 if (down_sample) then
429 m = int((m + 1)/3) - 1
430 n = int((n + 1)/3) - 1
431 p = int((p + 1)/3) - 1
432 end if
433
434 ! Store m,n,p into global m,n,p
435 m_glb = m
436 n_glb = n
437 p_glb = p
438
439 nglobal = int(m_glb + 1, kind=8)*int(n_glb + 1, kind=8)*int(p_glb + 1, kind=8)
440
441 if (cfl_adap_dt .or. cfl_const_dt) cfl_dt = .true.
442
443 if (any((/bc_x%beg, bc_x%end, bc_y%beg, bc_y%end, bc_z%beg, bc_z%end/) == -17) .or. &
444 num_bc_patches > 0) then
445 bc_io = .true.
446 end if
447
448 else
449 call s_mpi_abort('File post_process.inp is missing. Exiting.')
450 end if
451
452 end subroutine s_read_input_file
453
454 !> Checking that the user inputs make sense, i.e. that the
455 !! individual choices are compatible with the code's options
456 !! and that the combination of these choices results into a
457 !! valid configuration for the post-process
458 impure subroutine s_check_input_file
459
460 character(LEN=len_trim(case_dir)) :: file_loc !<
461 !! Generic string used to store the address of a particular file
462
463 logical :: dir_check !<
464 !! Logical variable used to test the existence of folders
465
466 ! Checking the existence of the case folder
467 case_dir = adjustl(case_dir)
468
469 file_loc = trim(case_dir)//'/.'
470
471 call my_inquire(file_loc, dir_check)
472
473 ! Constraint on the location of the case directory
474 if (dir_check .neqv. .true.) then
475 call s_mpi_abort('Unsupported choice for the value of '// &
476 'case_dir. Exiting.')
477 end if
478
480 call s_check_inputs()
481
482 end subroutine s_check_input_file
483
484 !> @brief Load grid and conservative data for a time step, fill ghost-cell buffers, and convert to primitive variables.
485 impure subroutine s_perform_time_step(t_step)
486
487 integer, intent(inout) :: t_step
488 if (proc_rank == 0) then
489 if (cfl_dt) then
490 print '(" [", I3, "%] Saving ", I8, " of ", I0, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, "")', &
491 int(ceiling(100._wp*(real(t_step - n_start)/(n_save)))), &
493 else
494 print '(" [", I3, "%] Saving ", I8, " of ", I0, " @ t_step = ", I8, " Time Avg = ", ES16.6, " Time/step = ", ES12.6, "")', &
495 int(ceiling(100._wp*(real(t_step - t_step_start)/(t_step_stop - t_step_start + 1)))), &
496 (t_step - t_step_start)/t_step_save + 1, &
498 t_step, wall_time_avg, wall_time
499 end if
500 end if
501
502 ! Populating the grid and conservative variables
503 call s_read_data_files(t_step)
504
505 ! Populating the buffer regions of the grid and conservative variables
506 if (buff_size > 0) then
509 end if
510
511 ! Initialize the Temperature cache.
513
514 ! Converting the conservative variables to the primitive ones
516
517 end subroutine s_perform_time_step
518
519 !> @brief Derive requested flow quantities from primitive variables and write them to the formatted database files.
520 impure subroutine s_save_data(t_step, varname, pres, c, H)
521
522 integer, intent(inout) :: t_step
523 character(LEN=name_len), intent(inout) :: varname
524 real(wp), intent(inout) :: pres, c, h
525 real(wp) :: theta1, theta2
526 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
527 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
528 integer :: i, j, k, l, kx, ky, kz, kf, j_glb, k_glb, l_glb
529 real(wp) :: en_tot
530 character(50) :: filename, dirname
531 logical :: file_exists, dir_exists
532 integer :: x_beg, x_end, y_beg, y_end, z_beg, z_end
533
534 if (output_partial_domain) then
536 x_beg = -offset_x%beg + x_output_idx%beg
537 x_end = offset_x%end + x_output_idx%end
538 y_beg = -offset_y%beg + y_output_idx%beg
539 y_end = offset_y%end + y_output_idx%end
540 z_beg = -offset_z%beg + z_output_idx%beg
541 z_end = offset_z%end + z_output_idx%end
542 else
543 x_beg = -offset_x%beg
544 x_end = offset_x%end + m
545 y_beg = -offset_y%beg
546 y_end = offset_y%end + n
547 z_beg = -offset_z%beg
548 z_end = offset_z%end + p
549 end if
550
551 ! Opening a new formatted database file
553
554 if (sim_data .and. proc_rank == 0) then
557 end if
558
559 if (sim_data) then
562 end if
563
564 ! Adding the grid to the formatted database file
566
567 ! Computing centered finite-difference coefficients in x-direction
568 if (omega_wrt(2) .or. omega_wrt(3) .or. qm_wrt .or. liutex_wrt .or. schlieren_wrt) then
572 end if
573
574 ! Computing centered finite-difference coefficients in y-direction
575 if (omega_wrt(1) .or. omega_wrt(3) .or. qm_wrt .or. liutex_wrt .or. (n > 0 .and. schlieren_wrt)) then
579 end if
580
581 ! Computing centered finite-difference coefficients in z-direction
582 if (omega_wrt(1) .or. omega_wrt(2) .or. qm_wrt .or. liutex_wrt .or. (p > 0 .and. schlieren_wrt)) then
586 end if
587
588 ! Adding the partial densities to the formatted database file
589 if ((model_eqns == 2) .or. (model_eqns == 3) .or. (model_eqns == 4)) then
590 do i = 1, num_fluids
591 if (alpha_rho_wrt(i) .or. (cons_vars_wrt .or. prim_vars_wrt)) then
592 q_sf(:, :, :) = q_cons_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
593 if (model_eqns /= 4) then
594 write (varname, '(A,I0)') 'alpha_rho', i
595 else
596 write (varname, '(A,I0)') 'rho', i
597 end if
599
600 varname(:) = ' '
601
602 end if
603 end do
604 end if
605
606 ! Adding the density to the formatted database file
607 if ((rho_wrt .or. (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) .and. (.not. relativity)) then
608 q_sf(:, :, :) = rho_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
609 write (varname, '(A)') 'rho'
611
612 varname(:) = ' '
613 end if
614
615 if (relativity .and. (rho_wrt .or. prim_vars_wrt)) then
616 q_sf(:, :, :) = q_prim_vf(1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
617 write (varname, '(A)') 'rho'
619
620 varname(:) = ' '
621 end if
622
623 if (relativity .and. (rho_wrt .or. cons_vars_wrt)) then
624 ! For relativistic flow, conservative and primitive densities are different
625 ! Hard-coded single-component for now
626 q_sf(:, :, :) = q_cons_vf(1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
627 write (varname, '(A)') 'D'
629
630 varname(:) = ' '
631 end if
632
633 ! Adding the momentum to the formatted database file
634 do i = 1, e_idx - mom_idx%beg
635 if (mom_wrt(i) .or. cons_vars_wrt) then
636 q_sf(:, :, :) = q_cons_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
637 write (varname, '(A,I0)') 'mom', i
639
640 varname(:) = ' '
641
642 end if
643 end do
644
645 ! Adding the velocity to the formatted database file
646 do i = 1, e_idx - mom_idx%beg
647 if (vel_wrt(i) .or. prim_vars_wrt) then
648 q_sf(:, :, :) = q_prim_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
649 write (varname, '(A,I0)') 'vel', i
651
652 varname(:) = ' '
653
654 end if
655 end do
656
657 ! Adding the species' concentrations to the formatted database file
658 if (chemistry) then
659 do i = 1, num_species
660 if (chem_wrt_y(i) .or. prim_vars_wrt) then
661 q_sf(:, :, :) = q_prim_vf(chemxb + i - 1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
662 write (varname, '(A,A)') 'Y_', trim(species_names(i))
664
665 varname(:) = ' '
666
667 end if
668 end do
669
670 if (chem_wrt_t) then
671 q_sf(:, :, :) = q_t_sf%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
672 write (varname, '(A)') 'T'
674
675 varname(:) = ' '
676 end if
677 end if
678
679 ! Adding the flux limiter function to the formatted database file
680 do i = 1, e_idx - mom_idx%beg
681 if (flux_wrt(i)) then
682
684
685 write (varname, '(A,I0)') 'flux', i
687
688 varname(:) = ' '
689 end if
690 end do
691
692 ! Adding the energy to the formatted database file
693 if (e_wrt .or. cons_vars_wrt) then
694 q_sf(:, :, :) = q_cons_vf(e_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
695 write (varname, '(A)') 'E'
697
698 varname(:) = ' '
699
700 end if
701
702 ! Adding the individual energies to the formatted database file
703 if (model_eqns == 3) then
704 do i = 1, num_fluids
705 if (alpha_rho_e_wrt(i) .or. cons_vars_wrt) then
706 q_sf = q_cons_vf(i + intxb - 1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
707 write (varname, '(A,I0)') 'alpha_rho_e', i
709
710 varname(:) = ' '
711 end if
712 end do
713 end if
714
715 !Adding Energy cascade FFT
716 if (fft_wrt) then
717
718 do l = 0, p
719 do k = 0, n
720 do j = 0, m
721 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)
722 end do
723 end do
724 end do
725
726 call s_mpi_fft_fwd()
727
728 en_real = 0.5_wp*abs(data_cmplx_z)**2._wp/(1._wp*nx*ny*nz)**2._wp
729
730 do l = 0, p
731 do k = 0, n
732 do j = 0, m
733 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)
734 end do
735 end do
736 end do
737
738 call s_mpi_fft_fwd()
739
740 en_real = en_real + 0.5_wp*abs(data_cmplx_z)**2._wp/(1._wp*nx*ny*nz)**2._wp
741
742 do l = 0, p
743 do k = 0, n
744 do j = 0, m
745 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)
746 end do
747 end do
748 end do
749
750 call s_mpi_fft_fwd()
751
752 en_real = en_real + 0.5_wp*abs(data_cmplx_z)**2._wp/(1._wp*nx*ny*nz)**2._wp
753
754 do kf = 1, nf
755 en(kf) = 0._wp
756 end do
757
758 do l = 1, nz
759 do k = 1, nyloc2
760 do j = 1, nxloc
761
762 j_glb = j + cart3d_coords(2)*nxloc
763 k_glb = k + cart3d_coords(3)*nyloc2
764 l_glb = l
765
766 if (j_glb >= (m_glb + 1)/2) then
767 kx = (j_glb - 1) - (m_glb + 1)
768 else
769 kx = j_glb - 1
770 end if
771
772 if (k_glb >= (n_glb + 1)/2) then
773 ky = (k_glb - 1) - (n_glb + 1)
774 else
775 ky = k_glb - 1
776 end if
777
778 if (l_glb >= (p_glb + 1)/2) then
779 kz = (l_glb - 1) - (p_glb + 1)
780 else
781 kz = l_glb - 1
782 end if
783
784 kf = nint(sqrt(kx**2._wp + ky**2._wp + kz**2._wp)) + 1
785
786 en(kf) = en(kf) + en_real(j, k, l)
787
788 end do
789 end do
790 end do
791
792#ifdef MFC_MPI
793 call mpi_allreduce(mpi_in_place, en, nf, mpi_p, mpi_sum, mpi_comm_world, ierr)
794#endif
795
796 if (proc_rank == 0) then
797 call s_create_directory('En_FFT_DATA')
798 write (filename, '(a,i0,a)') 'En_FFT_DATA/En_tot', t_step, '.dat'
799 inquire (file=filename, exist=file_exists)
800 if (file_exists) then
801 call s_delete_file(trim(filename))
802 end if
803 end if
804
805 do kf = 1, nf
806 if (proc_rank == 0) then
807 write (filename, '(a,i0,a)') 'En_FFT_DATA/En_tot', t_step, '.dat'
808 inquire (file=filename, exist=file_exists)
809 if (file_exists) then
810 open (1, file=filename, position='append', status='old')
811 write (1, *) en(kf), t_step
812 close (1)
813 else
814 open (1, file=filename, status='new')
815 write (1, *) en(kf), t_step
816 close (1)
817 end if
818 end if
819 end do
820
821 end if
822
823 ! Adding the magnetic field to the formatted database file
824 if (mhd .and. prim_vars_wrt) then
825 do i = b_idx%beg, b_idx%end
826 q_sf(:, :, :) = q_prim_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
827
828 ! 1D: output By, Bz
829 if (n == 0) then
830 if (i == b_idx%beg) then
831 write (varname, '(A)') 'By'
832 else
833 write (varname, '(A)') 'Bz'
834 end if
835 ! 2D/3D: output Bx, By, Bz
836 else
837 if (i == b_idx%beg) then
838 write (varname, '(A)') 'Bx'
839 elseif (i == b_idx%beg + 1) then
840 write (varname, '(A)') 'By'
841 else
842 write (varname, '(A)') 'Bz'
843 end if
844 end if
845
847 varname(:) = ' '
848 end do
849 end if
850
851 ! Adding the elastic shear stresses to the formatted database file
852 if (elasticity) then
853 do i = 1, stress_idx%end - stress_idx%beg + 1
854 if (prim_vars_wrt) then
855 q_sf(:, :, :) = q_prim_vf(i - 1 + stress_idx%beg)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
856 write (varname, '(A,I0)') 'tau', i
858 end if
859 varname(:) = ' '
860 end do
861 end if
862
863 if (hyperelasticity) then
864 do i = 1, xiend - xibeg + 1
865 if (prim_vars_wrt) then
866 q_sf(:, :, :) = q_prim_vf(i - 1 + xibeg)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
867 write (varname, '(A,I0)') 'xi', i
869 end if
870 varname(:) = ' '
871 end do
872 end if
873
874 if (cont_damage) then
875 q_sf(:, :, :) = q_cons_vf(damage_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
876 write (varname, '(A)') 'damage_state'
878
879 varname(:) = ' '
880 end if
881
882 if (hyper_cleaning) then
883 q_sf = q_cons_vf(psi_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
884 write (varname, '(A)') 'psi'
886
887 varname(:) = ' '
888 end if
889
890 ! Adding the pressure to the formatted database file
891 if (pres_wrt .or. prim_vars_wrt) then
892 q_sf(:, :, :) = q_prim_vf(e_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
893 write (varname, '(A)') 'pres'
895
896 varname(:) = ' '
897
898 end if
899
900 ! Adding the volume fraction(s) to the formatted database file
901 if (((model_eqns == 2) .and. (bubbles_euler .neqv. .true.)) &
902 .or. (model_eqns == 3) &
903 ) then
904
905 do i = 1, num_fluids - 1
906 if (alpha_wrt(i) .or. (cons_vars_wrt .or. prim_vars_wrt)) then
907 q_sf(:, :, :) = q_cons_vf(i + e_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
908 write (varname, '(A,I0)') 'alpha', i
910
911 varname(:) = ' '
912
913 end if
914 end do
915
916 if (alpha_wrt(num_fluids) &
917 .or. &
918 (cons_vars_wrt .or. prim_vars_wrt)) then
919 if (igr) then
920 do k = z_beg, z_end
921 do j = y_beg, y_end
922 do i = x_beg, x_end
923 q_sf(i, j, k) = 1._wp
924 do l = 1, num_fluids - 1
925 q_sf(i, j, k) = q_sf(i, j, k) - q_cons_vf(e_idx + l)%sf(i, j, k)
926 end do
927 end do
928 end do
929 end do
930 else
931 q_sf(:, :, :) = q_cons_vf(adv_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
932 end if
933 write (varname, '(A,I0)') 'alpha', num_fluids
935
936 varname(:) = ' '
937
938 end if
939
940 end if
941
942 ! Adding specific heat ratio function to formatted database file
943 if (gamma_wrt &
944 .or. &
945 (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then
946 q_sf(:, :, :) = gamma_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
947 write (varname, '(A)') 'gamma'
949
950 varname(:) = ' '
951
952 end if
953
954 ! Adding the specific heat ratio to the formatted database file
955 if (heat_ratio_wrt) then
956
958
959 write (varname, '(A)') 'heat_ratio'
961
962 varname(:) = ' '
963
964 end if
965
966 ! Adding liquid stiffness function to formatted database file
967 if (pi_inf_wrt &
968 .or. &
969 (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then
970 q_sf(:, :, :) = pi_inf_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
971 write (varname, '(A)') 'pi_inf'
973
974 varname(:) = ' '
975
976 end if
977
978 ! Adding the liquid stiffness to the formatted database file
979 if (pres_inf_wrt) then
980
982
983 write (varname, '(A)') 'pres_inf'
985
986 varname(:) = ' '
987
988 end if
989
990 ! Adding the sound speed to the formatted database file
991 if (c_wrt) then
992 do k = -offset_z%beg, p + offset_z%end
993 do j = -offset_y%beg, n + offset_y%end
994 do i = -offset_x%beg, m + offset_x%end
995 do l = 1, adv_idx%end - e_idx
996 adv(l) = q_prim_vf(e_idx + l)%sf(i, j, k)
997 end do
998
999 pres = q_prim_vf(e_idx)%sf(i, j, k)
1000
1001 h = ((gamma_sf(i, j, k) + 1._wp)*pres + &
1002 pi_inf_sf(i, j, k) + qv_sf(i, j, k))/rho_sf(i, j, k)
1003
1004 call s_compute_speed_of_sound(pres, rho_sf(i, j, k), &
1005 gamma_sf(i, j, k), pi_inf_sf(i, j, k), &
1006 h, adv, 0._wp, 0._wp, c, qv_sf(i, j, k))
1007
1008 q_sf(i, j, k) = c
1009 end do
1010 end do
1011 end do
1012
1013 write (varname, '(A)') 'c'
1015
1016 varname(:) = ' '
1017
1018 end if
1019
1020 ! Adding the vorticity to the formatted database file
1021 do i = 1, 3
1022 if (omega_wrt(i)) then
1023
1025
1026 write (varname, '(A,I0)') 'omega', i
1028
1029 varname(:) = ' '
1030 end if
1031 end do
1032
1033 if (ib) then
1034 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))
1035 varname = 'ib_markers'
1037 end if
1038
1039 ! Adding Q_M to the formatted database file
1040 if (p > 0 .and. qm_wrt) then
1042
1043 write (varname, '(A)') 'qm'
1045
1046 varname(:) = ' '
1047 end if
1048
1049 ! Adding Liutex magnitude to the formatted database file
1050 if (liutex_wrt) then
1051
1052 ! Compute Liutex vector and its magnitude
1053 call s_derive_liutex(q_prim_vf, liutex_mag, liutex_axis)
1054
1055 ! Liutex magnitude
1056 q_sf = liutex_mag
1057
1058 write (varname, '(A)') 'liutex_mag'
1060
1061 varname(:) = ' '
1062
1063 ! Liutex axis
1064 do i = 1, 3
1065 q_sf = liutex_axis(:, :, :, i)
1066
1067 write (varname, '(A,I0)') 'liutex_axis', i
1069
1070 varname(:) = ' '
1071 end do
1072
1073 end if
1074
1075 ! Adding numerical Schlieren function to formatted database file
1076 if (schlieren_wrt) then
1077
1079
1080 write (varname, '(A)') 'schlieren'
1082
1083 varname(:) = ' '
1084
1085 end if
1086
1087 ! Adding the color function to formatted database file
1088 if (cf_wrt) then
1089 q_sf(:, :, :) = q_cons_vf(c_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1090 write (varname, '(A,I0)') 'color_function'
1092 varname(:) = ' '
1093
1094 end if
1095
1096 ! Adding the volume fraction(s) to the formatted database file
1097 if (bubbles_euler) then
1098 do i = adv_idx%beg, adv_idx%end
1099 q_sf(:, :, :) = q_cons_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1100 write (varname, '(A,I0)') 'alpha', i - e_idx
1102 varname(:) = ' '
1103 end do
1104 end if
1105
1106 ! Adding the bubble variables to the formatted database file
1107 if (bubbles_euler) then
1108 !nR
1109 do i = 1, nb
1110 q_sf(:, :, :) = q_cons_vf(bub_idx%rs(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1111 write (varname, '(A,I3.3)') 'nR', i
1113 varname(:) = ' '
1114 end do
1115
1116 !nRdot
1117 do i = 1, nb
1118 q_sf(:, :, :) = q_cons_vf(bub_idx%vs(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1119 write (varname, '(A,I3.3)') 'nV', i
1121 varname(:) = ' '
1122 end do
1123 if ((polytropic .neqv. .true.) .and. (.not. qbmm)) then
1124 !nP
1125 do i = 1, nb
1126 q_sf(:, :, :) = q_cons_vf(bub_idx%ps(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1127 write (varname, '(A,I3.3)') 'nP', i
1129 varname(:) = ' '
1130 end do
1131
1132 !nM
1133 do i = 1, nb
1134 q_sf(:, :, :) = q_cons_vf(bub_idx%ms(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1135 write (varname, '(A,I3.3)') 'nM', i
1137 varname(:) = ' '
1138 end do
1139 end if
1140
1141 ! number density
1142 if (adv_n) then
1143 q_sf(:, :, :) = q_cons_vf(n_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end)
1144 write (varname, '(A)') 'n'
1146 varname(:) = ' '
1147 end if
1148 end if
1149
1150 ! Adding the lagrangian subgrid variables to the formatted database file
1151 if (bubbles_lagrange) then
1152 !! Void fraction field
1153 q_sf(:, :, :) = 1._wp - q_cons_vf(beta_idx)%sf( &
1154 -offset_x%beg:m + offset_x%end, &
1155 -offset_y%beg:n + offset_y%end, &
1156 -offset_z%beg:p + offset_z%end)
1157 write (varname, '(A)') 'voidFraction'
1159 varname(:) = ' '
1160
1161 if (lag_txt_wrt) call s_write_lag_bubbles_results_to_text(t_step) ! text output
1162 if (lag_db_wrt) call s_write_lag_bubbles_to_formatted_database_file(t_step) ! silo file output
1163 end if
1164
1165 if (sim_data .and. proc_rank == 0) then
1168 end if
1169
1170 ! Closing the formatted database file
1172
1173 end subroutine s_save_data
1174
1175 !> @brief Transpose 3-D complex data from x-pencil to y-pencil layout via MPI_Alltoall.
1176 subroutine s_mpi_transpose_x2y
1177 complex(c_double_complex), allocatable :: sendbuf(:), recvbuf(:)
1178 integer :: dest_rank, src_rank
1179 integer :: i, j, k, l
1181#ifdef MFC_MPI
1182
1183 allocate (sendbuf(nx*nyloc*nzloc))
1184 allocate (recvbuf(nx*nyloc*nzloc))
1185
1186 do dest_rank = 0, num_procs_y - 1
1187 do l = 1, nzloc
1188 do k = 1, nyloc
1189 do j = 1, nxloc
1190 sendbuf(j + (k - 1)*nxloc + (l - 1)*nxloc*nyloc + dest_rank*nxloc*nyloc*nzloc) = data_cmplx(j + dest_rank*nxloc, k, l)
1191 end do
1192 end do
1193 end do
1194 end do
1195
1196 call mpi_alltoall(sendbuf, nxloc*nyloc*nzloc, mpi_c_double_complex, &
1197 recvbuf, nxloc*nyloc*nzloc, mpi_c_double_complex, mpi_comm_cart12, ierr)
1198
1199 do src_rank = 0, num_procs_y - 1
1200 do l = 1, nzloc
1201 do k = 1, nyloc
1202 do j = 1, nxloc
1203 data_cmplx_y(j, k + src_rank*nyloc, l) = recvbuf(j + (k - 1)*nxloc + (l - 1)*nxloc*nyloc + src_rank*nxloc*nyloc*nzloc)
1204 end do
1205 end do
1206 end do
1207 end do
1208
1209 deallocate (sendbuf)
1210 deallocate (recvbuf)
1211
1212#endif
1213
1214 end subroutine s_mpi_transpose_x2y
1215
1216 !> @brief Transpose 3-D complex data from y-pencil to z-pencil layout via MPI_Alltoall.
1217 subroutine s_mpi_transpose_y2z
1218 complex(c_double_complex), allocatable :: sendbuf(:), recvbuf(:)
1219 integer :: dest_rank, src_rank
1220 integer :: j, k, l
1222#ifdef MFC_MPI
1223
1224 allocate (sendbuf(ny*nxloc*nzloc))
1225 allocate (recvbuf(ny*nxloc*nzloc))
1226
1227 do dest_rank = 0, num_procs_z - 1
1228 do l = 1, nzloc
1229 do j = 1, nxloc
1230 do k = 1, nyloc2
1231 sendbuf(k + (j - 1)*nyloc2 + (l - 1)*(nyloc2*nxloc) + dest_rank*nyloc2*nxloc*nzloc) = data_cmplx_y(j, k + dest_rank*nyloc2, l)
1232 end do
1233 end do
1234 end do
1235 end do
1236
1237 call mpi_alltoall(sendbuf, nyloc2*nxloc*nzloc, mpi_c_double_complex, &
1238 recvbuf, nyloc2*nxloc*nzloc, mpi_c_double_complex, mpi_comm_cart13, ierr)
1239
1240 do src_rank = 0, num_procs_z - 1
1241 do l = 1, nzloc
1242 do j = 1, nxloc
1243 do k = 1, nyloc2
1244 data_cmplx_z(j, k, l + src_rank*nzloc) = recvbuf(k + (j - 1)*nyloc2 + (l - 1)*(nyloc2*nxloc) + src_rank*nyloc2*nxloc*nzloc)
1245 end do
1246 end do
1247 end do
1248 end do
1249
1250 deallocate (sendbuf)
1251 deallocate (recvbuf)
1252
1253#endif
1254
1255 end subroutine s_mpi_transpose_y2z
1256
1257 !> @brief Initialize all post-process sub-modules, set up I/O pointers, and prepare FFTW plans and MPI communicators.
1258 impure subroutine s_initialize_modules
1259 ! Computation of parameters, allocation procedures, and/or any other tasks
1260 ! needed to properly setup the modules
1261 integer :: size_n(1), inembed(1), onembed(1)
1264 if (bubbles_euler .or. bubbles_lagrange) then
1266 end if
1267 if (num_procs > 1) then
1270 end if
1276
1277 ! Associate pointers for serial or parallel I/O
1278 if (parallel_io .neqv. .true.) then
1280 else
1282 end if
1283
1284#ifdef MFC_MPI
1285 if (fft_wrt) then
1286
1287 num_procs_x = (m_glb + 1)/(m + 1)
1288 num_procs_y = (n_glb + 1)/(n + 1)
1289 num_procs_z = (p_glb + 1)/(p + 1)
1290
1291 nx = m_glb + 1
1292 ny = n_glb + 1
1293 nz = p_glb + 1
1294
1295 nxloc = (m_glb + 1)/num_procs_y
1296 nyloc = n + 1
1297 nyloc2 = (n_glb + 1)/num_procs_z
1298 nzloc = p + 1
1299
1300 nf = max(nx, ny, nz)
1301
1302#ifdef MFC_DEBUG
1303# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1304 block
1305# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1306 use iso_fortran_env, only: output_unit
1307# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1308
1309# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1310 print *, 'm_start_up.fpp:1022: ', '@:ALLOCATE(data_in(Nx*Nyloc*Nzloc))'
1311# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1312
1313# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1314 call flush (output_unit)
1315# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1316 end block
1317# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1318#endif
1319# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1320 allocate (data_in(nx*nyloc*nzloc))
1321# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1322
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#if defined(MFC_OpenACC)
1327# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1328!$acc enter data create(data_in)
1329# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1330#elif defined(MFC_OpenMP)
1331# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1332!$omp target enter data map(always,alloc:data_in)
1333# 1022 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1334#endif
1335#ifdef MFC_DEBUG
1336# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1337 block
1338# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1339 use iso_fortran_env, only: output_unit
1340# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1341
1342# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1343 print *, 'm_start_up.fpp:1023: ', '@:ALLOCATE(data_out(Nx*Nyloc*Nzloc))'
1344# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1345
1346# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1347 call flush (output_unit)
1348# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1349 end block
1350# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1351#endif
1352# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1353 allocate (data_out(nx*nyloc*nzloc))
1354# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1355
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#if defined(MFC_OpenACC)
1360# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1361!$acc enter data create(data_out)
1362# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1363#elif defined(MFC_OpenMP)
1364# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1365!$omp target enter data map(always,alloc:data_out)
1366# 1023 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1367#endif
1368
1369#ifdef MFC_DEBUG
1370# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1371 block
1372# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1373 use iso_fortran_env, only: output_unit
1374# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1375
1376# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1377 print *, 'm_start_up.fpp:1025: ', '@:ALLOCATE(data_cmplx(Nx, Nyloc, Nzloc))'
1378# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1379
1380# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1381 call flush (output_unit)
1382# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1383 end block
1384# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1385#endif
1386# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1387 allocate (data_cmplx(nx, nyloc, nzloc))
1388# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1389
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#if defined(MFC_OpenACC)
1394# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1395!$acc enter data create(data_cmplx)
1396# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1397#elif defined(MFC_OpenMP)
1398# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1399!$omp target enter data map(always,alloc:data_cmplx)
1400# 1025 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1401#endif
1402#ifdef MFC_DEBUG
1403# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1404 block
1405# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1406 use iso_fortran_env, only: output_unit
1407# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1408
1409# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1410 print *, 'm_start_up.fpp:1026: ', '@:ALLOCATE(data_cmplx_y(Nxloc, Ny, Nzloc))'
1411# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1412
1413# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1414 call flush (output_unit)
1415# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1416 end block
1417# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1418#endif
1419# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1420 allocate (data_cmplx_y(nxloc, ny, nzloc))
1421# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1422
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#if defined(MFC_OpenACC)
1427# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1428!$acc enter data create(data_cmplx_y)
1429# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1430#elif defined(MFC_OpenMP)
1431# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1432!$omp target enter data map(always,alloc:data_cmplx_y)
1433# 1026 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1434#endif
1435#ifdef MFC_DEBUG
1436# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1437 block
1438# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1439 use iso_fortran_env, only: output_unit
1440# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1441
1442# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1443 print *, 'm_start_up.fpp:1027: ', '@:ALLOCATE(data_cmplx_z(Nxloc, Nyloc2, Nz))'
1444# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1445
1446# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1447 call flush (output_unit)
1448# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1449 end block
1450# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1451#endif
1452# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1453 allocate (data_cmplx_z(nxloc, nyloc2, nz))
1454# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1455
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#if defined(MFC_OpenACC)
1460# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1461!$acc enter data create(data_cmplx_z)
1462# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1463#elif defined(MFC_OpenMP)
1464# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1465!$omp target enter data map(always,alloc:data_cmplx_z)
1466# 1027 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1467#endif
1468
1469#ifdef MFC_DEBUG
1470# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1471 block
1472# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1473 use iso_fortran_env, only: output_unit
1474# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1475
1476# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1477 print *, 'm_start_up.fpp:1029: ', '@:ALLOCATE(En_real(Nxloc, Nyloc2, Nz))'
1478# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1479
1480# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1481 call flush (output_unit)
1482# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1483 end block
1484# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1485#endif
1486# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1487 allocate (en_real(nxloc, nyloc2, nz))
1488# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1489
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#if defined(MFC_OpenACC)
1494# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1495!$acc enter data create(En_real)
1496# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1497#elif defined(MFC_OpenMP)
1498# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1499!$omp target enter data map(always,alloc:En_real)
1500# 1029 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1501#endif
1502#ifdef MFC_DEBUG
1503# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1504 block
1505# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1506 use iso_fortran_env, only: output_unit
1507# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1508
1509# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1510 print *, 'm_start_up.fpp:1030: ', '@:ALLOCATE(En(Nf))'
1511# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1512
1513# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1514 call flush (output_unit)
1515# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1516 end block
1517# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1518#endif
1519# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1520 allocate (en(nf))
1521# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1522
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#if defined(MFC_OpenACC)
1527# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1528!$acc enter data create(En)
1529# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1530#elif defined(MFC_OpenMP)
1531# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1532!$omp target enter data map(always,alloc:En)
1533# 1030 "/home/runner/work/MFC/MFC/src/post_process/m_start_up.fpp"
1534#endif
1535
1536 size_n(1) = nx
1537 inembed(1) = nx
1538 onembed(1) = nx
1539
1540 fwd_plan_x = fftw_plan_many_dft(1, size_n, nyloc*nzloc, &
1541 data_in, inembed, 1, nx, &
1542 data_out, onembed, 1, nx, &
1543 fftw_forward, fftw_measure)
1544
1545 size_n(1) = ny
1546 inembed(1) = ny
1547 onembed(1) = ny
1548
1549 fwd_plan_y = fftw_plan_many_dft(1, size_n, nxloc*nzloc, &
1550 data_out, inembed, 1, ny, &
1551 data_in, onembed, 1, ny, &
1552 fftw_forward, fftw_measure)
1553
1554 size_n(1) = nz
1555 inembed(1) = nz
1556 onembed(1) = nz
1557
1558 fwd_plan_z = fftw_plan_many_dft(1, size_n, nxloc*nyloc2, &
1559 data_in, inembed, 1, nz, &
1560 data_out, onembed, 1, nz, &
1561 fftw_forward, fftw_measure)
1562
1563 call mpi_cart_create(mpi_comm_world, 3, (/num_procs_x, &
1565 (/.true., .true., .true./), &
1566 .false., mpi_comm_cart, ierr)
1567 call mpi_cart_coords(mpi_comm_cart, proc_rank, 3, &
1569
1570 call mpi_cart_sub(mpi_comm_cart, (/.true., .true., .false./), mpi_comm_cart12, ierr)
1571 call mpi_comm_rank(mpi_comm_cart12, proc_rank12, ierr)
1572 call mpi_cart_coords(mpi_comm_cart12, proc_rank12, 2, cart2d12_coords, ierr)
1573
1574 call mpi_cart_sub(mpi_comm_cart, (/.true., .false., .true./), mpi_comm_cart13, ierr)
1575 call mpi_comm_rank(mpi_comm_cart13, proc_rank13, ierr)
1576 call mpi_cart_coords(mpi_comm_cart13, proc_rank13, 2, cart2d13_coords, ierr)
1577
1578 end if
1579#endif
1580 end subroutine s_initialize_modules
1581
1582 !> @brief Perform a distributed forward 3-D FFT using pencil decomposition with FFTW and MPI transposes.
1583 subroutine s_mpi_fft_fwd
1584
1585 integer :: j, k, l
1586
1587#ifdef MFC_MPI
1588
1589 do l = 1, nzloc
1590 do k = 1, nyloc
1591 do j = 1, nx
1592 data_in(j + (k - 1)*nx + (l - 1)*nx*nyloc) = data_cmplx(j, k, l)
1593 end do
1594 end do
1595 end do
1596
1597 call fftw_execute_dft(fwd_plan_x, data_in, data_out)
1598
1599 do l = 1, nzloc
1600 do k = 1, nyloc
1601 do j = 1, nx
1602 data_cmplx(j, k, l) = data_out(j + (k - 1)*nx + (l - 1)*nx*nyloc)
1603 end do
1604 end do
1605 end do
1606
1607 call s_mpi_transpose_x2y !!Change Pencil from data_cmplx to data_cmpx_y
1608
1609 do l = 1, nzloc
1610 do k = 1, nxloc
1611 do j = 1, ny
1612 data_out(j + (k - 1)*ny + (l - 1)*ny*nxloc) = data_cmplx_y(k, j, l)
1613 end do
1614 end do
1615 end do
1616
1617 call fftw_execute_dft(fwd_plan_y, data_out, data_in)
1618
1619 do l = 1, nzloc
1620 do k = 1, nxloc
1621 do j = 1, ny
1622 data_cmplx_y(k, j, l) = data_in(j + (k - 1)*ny + (l - 1)*ny*nxloc)
1623 end do
1624 end do
1625 end do
1626
1627 call s_mpi_transpose_y2z !!Change Pencil from data_cmplx_y to data_cmpx_z
1628
1629 do l = 1, nyloc2
1630 do k = 1, nxloc
1631 do j = 1, nz
1632 data_in(j + (k - 1)*nz + (l - 1)*nz*nxloc) = data_cmplx_z(k, l, j)
1633 end do
1634 end do
1635 end do
1636
1637 call fftw_execute_dft(fwd_plan_z, data_in, data_out)
1638
1639 do l = 1, nyloc2
1640 do k = 1, nxloc
1641 do j = 1, nz
1642 data_cmplx_z(k, l, j) = data_out(j + (k - 1)*nz + (l - 1)*nz*nxloc)
1643 end do
1644 end do
1645 end do
1646
1647#endif
1648
1649 end subroutine s_mpi_fft_fwd
1650
1651 !> @brief Set up the MPI environment, read and broadcast user inputs, and decompose the computational domain.
1652 impure subroutine s_initialize_mpi_domain
1653
1654 num_dims = 1 + min(1, n) + min(1, p)
1655
1656#ifdef MFC_MPI
1657 ! Initialization of the MPI environment
1658 call s_mpi_initialize()
1659
1660 ! Processor with rank 0 assigns default user input values prior to reading
1661 ! those in from the input file. Next, the user inputs are read in and their
1662 ! consistency is checked. The detection of any inconsistencies automatically
1663 ! leads to the termination of the post-process.
1664 if (proc_rank == 0) then
1665 call s_assign_default_values_to_user_inputs()
1666 call s_read_input_file()
1667 call s_check_input_file()
1668
1669 print '(" Post-processing a ", I0, "x", I0, "x", I0, " case on ", I0, " rank(s)")', m, n, p, num_procs
1670 end if
1671
1672 ! Broadcasting the user inputs to all of the processors and performing the
1673 ! parallel computational domain decomposition. Neither procedure has to be
1674 ! carried out if the simulation is in fact not truly executed in parallel.
1675 call s_mpi_bcast_user_inputs()
1676 call s_initialize_parallel_io()
1677 call s_mpi_decompose_computational_domain()
1678 call s_check_inputs_fft()
1679
1680#endif
1681
1682 end subroutine s_initialize_mpi_domain
1683
1684 !> @brief Destroy FFTW plans, free MPI communicators, and finalize all post-process sub-modules.
1685 impure subroutine s_finalize_modules
1686 ! Disassociate pointers for serial and parallel I/O
1687 s_read_data_files => null()
1688
1689! if (sim_data .and. proc_rank == 0) then
1690! call s_close_intf_data_file()
1691! call s_close_energy_data_file()
1692! end if
1693
1694 if (fft_wrt) then
1695 if (c_associated(fwd_plan_x)) call fftw_destroy_plan(fwd_plan_x)
1696 if (c_associated(fwd_plan_y)) call fftw_destroy_plan(fwd_plan_y)
1697 if (c_associated(fwd_plan_z)) call fftw_destroy_plan(fwd_plan_z)
1698 if (allocated(data_in)) deallocate (data_in)
1699 if (allocated(data_out)) deallocate (data_out)
1700 if (allocated(data_cmplx)) deallocate (data_cmplx)
1701 if (allocated(data_cmplx_y)) deallocate (data_cmplx_y)
1702 if (allocated(data_cmplx_z)) deallocate (data_cmplx_z)
1703 if (allocated(en_real)) deallocate (en_real)
1704 if (allocated(en)) deallocate (en)
1705 call fftw_cleanup()
1706 end if
1707
1708#ifdef MFC_MPI
1709 if (fft_wrt) then
1710 if (mpi_comm_cart12 /= mpi_comm_null) call mpi_comm_free(mpi_comm_cart12, ierr)
1711 if (mpi_comm_cart13 /= mpi_comm_null) call mpi_comm_free(mpi_comm_cart13, ierr)
1712 if (mpi_comm_cart /= mpi_comm_null) call mpi_comm_free(mpi_comm_cart, ierr)
1713 end if
1714#endif
1715
1716 ! Deallocation procedures for the modules
1717 call s_finalize_data_output_module()
1718 call s_finalize_derived_variables_module()
1719 call s_finalize_data_input_module()
1720 call s_finalize_variables_conversion_module()
1721 if (num_procs > 1) then
1722 call s_finalize_mpi_proxy_module()
1723 call s_finalize_mpi_common_module()
1724 end if
1725 call s_finalize_global_parameters_module()
1726
1727 ! Finalizing the MPI environment
1728 call s_mpi_finalize()
1729 end subroutine s_finalize_modules
1730
1731end module m_start_up
1732
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.