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/pre_process/m_start_up.fpp"
2!>
3!! @file
4!! @brief Contains module m_start_up
5
6# 1 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp" 1
7# 1 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 1
8# 1 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 1
9# 2 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
10# 3 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
11# 4 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
12# 5 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
13# 6 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
14
15# 8 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
16# 9 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
17# 10 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
18
19# 12 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
20# 1 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp" 1
21! Default for Fypp runs outside the toolchain (e.g. documentation). Searched last, so the
22! build/include/<target>/thermochem.fpp the toolchain writes from m_thermochem takes precedence.
23# 4 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
24# 5 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
25# 13 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 2
26
27# 16 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
28# 17 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
29
30# 24 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
31
32# 53 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
33
34# 65 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
35
36# 75 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
37
38# 105 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
39
40# 117 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
41
42# 127 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
43
44# 174 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
45! New line at end of file is required for FYPP
46# 2 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 2
47# 1 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp" 1
48# 1 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 1
49# 2 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
50# 3 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
51# 4 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
52# 5 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
53# 6 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
54
55# 8 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
56# 9 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
57# 10 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
58
59# 12 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
60# 1 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp" 1
61! Default for Fypp runs outside the toolchain (e.g. documentation). Searched last, so the
62! build/include/<target>/thermochem.fpp the toolchain writes from m_thermochem takes precedence.
63# 4 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
64# 5 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
65# 13 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 2
66
67# 16 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
68# 17 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
69
70# 24 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
71
72# 53 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
73
74# 65 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
75
76# 75 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
77
78# 105 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
79
80# 117 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
81
82# 127 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
83
84# 174 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
85! New line at end of file is required for FYPP
86# 2 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp" 2
87
88# 4 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
89# 5 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
90# 6 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
91# 7 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
92# 8 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
93
94# 20 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
95
96# 49 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
97
98# 54 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
99
100# 59 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
101
102# 64 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
103
104# 69 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
105
106# 74 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
107
108# 87 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
109
110# 101 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
111
112# 106 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
113
114# 111 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
115
116# 116 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
117
118# 121 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
119
120# 126 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
121
122# 131 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
123
124# 136 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
125
126# 141 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
127
128# 171 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
129
130# 231 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
131
132# 245 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
133
134# 270 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
135
136# 281 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
137
138# 283 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
139# 294 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
140
141# 343 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
142
143# 353 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
144
145# 363 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
146
147# 372 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
148
149# 389 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
150
151# 399 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
152
153# 406 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
154
155# 412 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
156
157# 418 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
158
159# 424 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
160
161# 430 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
162
163# 436 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
164! New line at end of file is required for FYPP
165# 3 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 2
166# 1 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp" 1
167# 1 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 1
168# 2 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
169# 3 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
170# 4 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
171# 5 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
172# 6 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
173
174# 8 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
175# 9 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
176# 10 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
177
178# 12 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
179# 1 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp" 1
180! Default for Fypp runs outside the toolchain (e.g. documentation). Searched last, so the
181! build/include/<target>/thermochem.fpp the toolchain writes from m_thermochem takes precedence.
182# 4 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
183# 5 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
184# 13 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 2
185
186# 16 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
187# 17 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
188
189# 24 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
190
191# 53 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
192
193# 65 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
194
195# 75 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
196
197# 105 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
198
199# 117 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
200
201# 127 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
202
203# 174 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
204! New line at end of file is required for FYPP
205# 2 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp" 2
206
207# 7 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
208
209# 17 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
210
211# 22 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
212
213# 27 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
214
215# 32 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
216
217# 37 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
218
219# 42 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
220
221# 47 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
222
223# 52 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
224
225# 57 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
226
227# 62 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
228
229# 73 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
230
231# 78 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
232
233# 83 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
234
235# 88 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
236
237# 103 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
238
239# 131 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
240
241# 161 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
242
243# 176 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
244
245# 194 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
246
247# 216 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
248
249# 245 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
250
251# 260 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
252
253# 270 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
254
255# 279 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
256
257# 295 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
258
259# 305 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
260
261# 312 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
262! New line at end of file is required for FYPP
263# 4 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 2
264
265! GPU parallel region (scalar reductions, maxval/minval)
266# 23 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
267
268! GPU parallel loop over threads (most common GPU macro)
269# 44 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
270
271! Required closing for GPU_PARALLEL_LOOP
272# 56 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
273
274! Mark routine for device compilation
275# 113 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
276
277! Declare device-resident data
278# 131 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
279
280! Inner loop within a GPU parallel region
281# 146 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
282
283! Scoped GPU data region
284# 165 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
285
286! Host code with device pointers (for MPI with GPU buffers)
287# 191 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
288
289! Allocate device memory (unscoped)
290# 205 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
291
292! Free device memory
293# 217 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
294
295! Atomic operation on device
296# 229 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
297
298! End atomic capture block
299# 240 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
300
301! Copy data between host and device
302# 252 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
303
304! Synchronization barrier
305# 264 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
306
307! Import GPU library module (openacc or omp_lib)
308# 273 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
309
310! Emit code only for AMD compiler
311# 280 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
312
313! Emit code for non-Cray compilers
314# 287 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
315
316! Emit code only for Cray compiler
317# 294 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
318
319! Cray compiler directive, emitted from Fypp so the formatter cannot turn it into a comment
320# 301 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
321
322! Emit code for non-NVIDIA compilers
323# 308 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
324
325# 310 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
326# 311 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
327! New line at end of file is required for FYPP
328# 2 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp" 2
329
330# 14 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
331
332! Caution: This macro requires the use of a binding script to set CUDA_VISIBLE_DEVICES, such that we have one GPU device per MPI
333! rank. That's because for both cudaMemAdvise (preferred location) and cudaMemPrefetchAsync we use location = device_id = 0. For an
334! example see misc/nvidia_uvm/bind.sh.
335# 52 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
336
337! Allocate and create GPU device memory
338# 72 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
339
340! Free GPU device memory and deallocate
341# 80 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
342
343! Cray-specific GPU pointer setup for vector fields
344# 104 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
345
346! Cray-specific GPU pointer setup for scalar fields
347# 120 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
348
349! Cray-specific GPU pointer teardown for scalar fields - exact inverse of ACC_SETUP_SFs. Removes the
350! present-table entries ACC_SETUP_SFs added (the scalar_field descriptor and its %sf copyin). REQUIRED when
351! an ACC_SETUP'd field is freed MID-RUN (e.g. AMR slot free on regrid/restart): Cray 'exit data delete'
352! decrements the reference counter, so the lone @:DEALLOCATE(arg%sf) only undoes the @:ALLOCATE create ref
353! and leaves the descriptor + the ACC_SETUP %sf copyin dangling. Call BEFORE @:DEALLOCATE(arg%sf).
354# 140 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
355
356! Cray-specific GPU pointer setup for acoustic source spatials
357# 165 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
358
359! Whether stress index idx is a shear component. Spelled out because NVHPC 26.9 at -O2 vectorizes any(idx == shear_indices)
360! inside a loop to always true, which doubled the normal-stress elastic energy.
361# 171 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
362
363# 177 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
364
365# 184 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
366! New line at end of file is required for FYPP
367# 6 "/home/runner/work/MFC/MFC/src/pre_process/m_start_up.fpp" 2
368
369!> @brief Reads and validates user inputs, loads existing grid/IC data, and initializes pre-process modules
371
374 use m_mpi_proxy
375 use m_mpi_common
378 use m_grid
380 use m_data_output
386 use m_helper
387
388#ifdef MFC_MPI
389 use mpi
390#endif
391
395 use m_helper
397 use m_checker
400
401 implicit none
402
403 private
408
409 abstract interface
410
411 !> Abstract interface for reading grid data files in serial or parallel.
413
415
416 !> Abstract interface for reading initial condition data files in serial or parallel.
417 impure subroutine s_read_abstract_ic_data_files(q_cons_vf_in)
418
419 import :: scalar_field, integer_field, sys_size, pres_field
420
421 type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf_in
422
423 end subroutine s_read_abstract_ic_data_files
424 end interface
425
426 character(LEN=path_len + name_len) :: proc_rank_dir !< Location of the folder associated with the rank of the local processor
427 character(LEN=path_len + 2*name_len), private :: t_step_dir !< Path to preexisting time-step folder for restart
430
431contains
432
433 !> Reads the configuration file pre_process.inp, in order to populate the parameters in module m_global_parameters.f90 with the
434 !! user provided inputs
435 impure subroutine s_read_input_file
436
437 character(LEN=name_len) :: file_loc
438 logical :: file_check
439 integer :: iostatus
440 character(len=1000) :: line
441
442# 1 "/home/runner/work/MFC/MFC/build/include/pre_process/generated_namelist.fpp" 1
443! AUTO-GENERATED - do not edit directly. Regenerate: cmake reconfigure
444!
445namelist /user_inputs/ bx0, ca, r0ref, re_inv, web, a_x, a_y, a_z, adv_n, bc_x, bc_y, bc_z, bub_pp, bubbles_euler, &
446 & bubbles_lagrange, case_dir, cfl_adap_dt, cfl_const_dt, cont_damage, cyl_coord, dist_type, down_sample, elliptic_smoothing, &
447 & elliptic_smoothing_iters, fft_wrt, file_extension, file_per_process, files_dir, fluid_pp, fluid_rho, hyper_cleaning, &
448 & hypoelasticity, ib, ib_airfoil, igr, igr_order, loops_x, loops_y, loops_z, m, mhd, mixlayer_perturb, mixlayer_perturb_k0, &
449 & mixlayer_perturb_nk, mixlayer_vel_coef, mixlayer_vel_profile, model_eqns, mpp_lim, muscl_order, n, n_start, n_start_old, &
450 & nb, num_bc_patches, num_fluids, num_ibs, num_particle_clouds, num_patches, num_stl_models, old_grid, old_ic, p, &
451 & palpha_eps, parallel_io, particle_cloud, particles_lagrange, patch_bc, patch_ib, patch_icpp, perturb_flow, &
452 & perturb_flow_fluid, perturb_flow_mag, perturb_sph, perturb_sph_fluid, pi_fac, poly_sigma, polydisperse, polytropic, &
453 & precision, ptgalpha_eps, qbmm, rburn, reactive_burn, recon_type, relativity, relax, relax_model, rhorv, sigr, sigv, sigma, &
454 & simplex_params, simplex_perturb, stl_models, stretch_x, stretch_y, stretch_z, surface_tension, t_step_old, t_step_start, &
455 & thermal, viscous, weno_order, x_a, x_b, x_domain, y_a, y_b, y_domain, z_a, z_b, z_domain
456# 81 "/home/runner/work/MFC/MFC/src/pre_process/m_start_up.fpp" 2
457
458 file_loc = 'pre_process.inp'
459 inquire (file=trim(file_loc), exist=file_check)
460
461 if (file_check) then
462 open (1, file=trim(file_loc), form='formatted', status='old', action='read')
463 read (1, nml=user_inputs, iostat=iostatus)
464 if (iostatus /= 0) then
465 backspace(1)
466 read (1, fmt='(A)') line
467 print *, 'Invalid line in namelist: ' // trim(line)
468 call s_mpi_abort('Invalid line in pre_process.inp. It is ' // 'likely due to a datatype mismatch. Exiting.')
469 end if
470 close (1)
471
473
474 m_glb = m
475 n_glb = n
476 p_glb = p
477
478 nglobal = int(m_glb + 1, kind=8)*int(n_glb + 1, kind=8)*int(p_glb + 1, kind=8)
479
480 if (cfl_adap_dt .or. cfl_const_dt) cfl_dt = .true.
481
482 if (any((/bc_x%beg, bc_x%end, bc_y%beg, bc_y%end, bc_z%beg, bc_z%end/) == bc_dirichlet) .or. num_bc_patches > 0) then
483 bc_io = .true.
484 end if
485 else
486 call s_mpi_abort('File pre_process.inp is missing. Exiting.')
487 end if
488
489 end subroutine s_read_input_file
490
491 !> Checking that the user inputs make sense, i.e. that the individual choices are compatible with the code's options and that
492 !! the combination of these choices results into a valid configuration for the pre-process
493 impure subroutine s_check_input_file
494
495 character(LEN=len_trim(case_dir)) :: file_loc
496 logical :: dir_check
497
498 case_dir = adjustl(case_dir)
499
500 file_loc = trim(case_dir) // '/.'
501
502 call my_inquire(file_loc, dir_check)
503
504 if (dir_check .neqv. .true.) then
505 print '(A)', 'WARNING: Ensure that compiler flags/choices in Makefiles match your compiler! '
506 print '(A)', 'WARNING: Ensure that preprocessor flags are enabled! '
507 call s_mpi_abort('Unsupported choice for the value of case_dir.' // 'Exiting.')
508 end if
509
510 call s_check_inputs_common(check_total_cells=.true., n_global=nglobal)
511 call s_check_inputs()
512
513 call s_check_patches()
514
515 if (ib) call s_check_ib_patches()
516
517 end subroutine s_check_input_file
518
519 !> @brief Generates the particle-cloud beds (if any) and writes the initial IB state file that simulation reads back at startup
520 !! (src/simulation/m_start_up.fpp:s_read_ib_restart_data). Must run after the domain is decomposed (s_initialize_mpi_domain) and
521 !! the grid is populated (s_read_grid). Under file_per_process every rank computes the same deterministic placement and keeps
522 !! only the IBs f_local_rank_owns_location says are its own; otherwise rank 0 alone generates and writes every IB.
523 impure subroutine s_write_ib_state_0()
524
525 type(ib_patch_parameters), allocatable :: particle_cloud_ibs(:)
526 integer :: num_particle_cloud_ibs
527 type(bounds_info), dimension(3) :: glb_bounds
528
529 if (.not. ib) return
530 if (.not. file_per_process .and. proc_rank /= 0) return
531
532 glb_bounds = (/x_domain_glb, y_domain_glb, z_domain_glb/)
533
534 call s_generate_particle_clouds(glb_bounds, particle_cloud_ibs, num_particle_cloud_ibs)
535 call s_write_ib_state_0_file(glb_bounds, particle_cloud_ibs, num_particle_cloud_ibs)
536 deallocate (particle_cloud_ibs)
537
538 end subroutine s_write_ib_state_0
539
540 !> The goal of this subroutine is to read in any preexisting grid data as well as based on the imported grid, complete the
541 !! necessary global computational domain parameters.
543
544 character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc
545 logical :: dir_check
546 logical :: file_check
547
548 write (proc_rank_dir, '(A,I0)') '/p_all/p', proc_rank
549 proc_rank_dir = trim(case_dir) // trim(proc_rank_dir)
550
551 write (t_step_dir, '(A,I0)') '/', t_step_start
552 t_step_dir = trim(proc_rank_dir) // trim(t_step_dir)
553
554 file_loc = trim(t_step_dir) // '/.'
555 call my_inquire(file_loc, dir_check)
556
557 if (dir_check .neqv. .true.) then
558 call s_mpi_abort('Time-step folder ' // trim(t_step_dir) // ' is missing. Exiting.')
559 end if
560
561 file_loc = trim(t_step_dir) // '/x_cb.dat'
562 inquire (file=trim(file_loc), exist=file_check)
563
564 if (file_check) then
565 open (1, file=trim(file_loc), form='unformatted', status='old', action='read')
566 read (1) x_cb(-1:m)
567 close (1)
568 else
569 call s_mpi_abort('File x_cb.dat is missing in ' // trim(t_step_dir) // '. Exiting.')
570 end if
571
572 x_cc(0:m) = (x_cb(0:m) + x_cb(-1:(m - 1)))/2._wp
573
574 dx_min = minval(x_cb(0:m) - x_cb(-1:m - 1))
575 if (num_procs > 1) call s_mpi_reduce_min(dx_min)
576
577 x_domain%beg = x_cb(-1)
578 x_domain%end = x_cb(m)
579
580 if (n > 0) then
581 file_loc = trim(t_step_dir) // '/y_cb.dat'
582 inquire (file=trim(file_loc), exist=file_check)
583
584 if (file_check) then
585 open (1, file=trim(file_loc), form='unformatted', status='old', action='read')
586 read (1) y_cb(-1:n)
587 close (1)
588 else
589 call s_mpi_abort('File y_cb.dat is missing in ' // trim(t_step_dir) // '. Exiting.')
590 end if
591
592 y_cc(0:n) = (y_cb(0:n) + y_cb(-1:(n - 1)))/2._wp
593
594 dy_min = minval(y_cb(0:n) - y_cb(-1:n - 1))
595 if (num_procs > 1) call s_mpi_reduce_min(dy_min)
596
597 y_domain%beg = y_cb(-1)
598 y_domain%end = y_cb(n)
599
600 if (p > 0) then
601 file_loc = trim(t_step_dir) // '/z_cb.dat'
602 inquire (file=trim(file_loc), exist=file_check)
603
604 if (file_check) then
605 open (1, file=trim(file_loc), form='unformatted', status='old', action='read')
606 read (1) z_cb(-1:p)
607 close (1)
608 else
609 call s_mpi_abort('File z_cb.dat is missing in ' // trim(t_step_dir) // '. Exiting.')
610 end if
611
612 z_cc(0:p) = (z_cb(0:p) + z_cb(-1:(p - 1)))/2._wp
613
614 dz_min = minval(z_cb(0:p) - z_cb(-1:p - 1))
615 if (num_procs > 1) call s_mpi_reduce_min(dz_min)
616
617 z_domain%beg = z_cb(-1)
618 z_domain%end = z_cb(p)
619 end if
620 end if
621
622 ! Clean processor dir and create time-step dir (unless reading preexisting IC)
623 if (old_ic .neqv. .true.) then
625 call s_create_directory(trim(proc_rank_dir) // '/0')
626 end if
627
628 end subroutine s_read_serial_grid_data_files
629
630 !> Cell-boundary data are checked for consistency by looking at the (non-)uniform cell-width distributions for all the active
631 !! coordinate directions and making sure that all of the cell-widths are positively valued
632 impure subroutine s_check_grid_data_files
633
634 if (any(x_cb(0:m) - x_cb(-1:m - 1) <= 0._wp)) then
635 call s_mpi_abort('x_cb.dat in ' // trim(t_step_dir) // ' contains non-positive cell-spacings. Exiting.')
636 end if
637
638 if (n > 0) then
639 if (any(y_cb(0:n) - y_cb(-1:n - 1) <= 0._wp)) then
640 call s_mpi_abort('y_cb.dat in ' // trim(t_step_dir) // ' contains non-positive cell-spacings. ' // 'Exiting.')
641 end if
642
643 if (p > 0) then
644 if (any(z_cb(0:p) - z_cb(-1:p - 1) <= 0._wp)) then
645 call s_mpi_abort('z_cb.dat in ' // trim(t_step_dir) // ' contains non-positive cell-spacings' // ' .Exiting.')
646 end if
647 end if
648 end if
649
650 end subroutine s_check_grid_data_files
651
652 !> The goal of this subroutine is to read in any preexisting initial condition data files so that they may be used by the
653 !! pre-process as a starting point in the creation of an all new initial condition.
654 impure subroutine s_read_serial_ic_data_files(q_cons_vf_in)
655
656 type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf_in
657 character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc
658 character(len=int(floor(log10(real(sys_size, wp)))) + 1) :: file_num
659 logical :: file_check
660 integer :: i, r
661
662 do i = 1, sys_size
663 write (file_num, '(I0)') i
664 file_loc = trim(t_step_dir) // '/q_cons_vf' // trim(file_num) // '.dat'
665 inquire (file=trim(file_loc), exist=file_check)
666
667 if (file_check) then
668 open (1, file=trim(file_loc), form='unformatted', status='old', action='read')
669 read (1) q_cons_vf_in(i)%sf
670 close (1)
671 else
672 call s_mpi_abort('File q_cons_vf' // trim(file_num) // '.dat is missing in ' // trim(t_step_dir) // '. Exiting.')
673 end if
674 end do
675
676 if (qbmm .and. .not. polytropic) then
677 do i = 1, nb
678 do r = 1, nnode
679 write (file_num, '(I0)') sys_size + r + (i - 1)*nnode
680 file_loc = trim(t_step_dir) // '/pb' // trim(file_num) // '.dat'
681 inquire (file=trim(file_loc), exist=file_check)
682
683 if (file_check) then
684 open (1, file=trim(file_loc), form='unformatted', status='old', action='read')
685 read (1) pb%sf(:,:,:,r, i)
686 close (1)
687 else
688 call s_mpi_abort('File pb' // trim(file_num) // '.dat is missing in ' // trim(t_step_dir) // '. Exiting.')
689 end if
690 end do
691 end do
692
693 do i = 1, nb
694 do r = 1, nnode
695 write (file_num, '(I0)') sys_size + r + (i - 1)*nnode
696 file_loc = trim(t_step_dir) // '/mv' // trim(file_num) // '.dat'
697 inquire (file=trim(file_loc), exist=file_check)
698
699 if (file_check) then
700 open (1, file=trim(file_loc), form='unformatted', status='old', action='read')
701 read (1) mv%sf(:,:,:,r, i)
702 close (1)
703 else
704 call s_mpi_abort('File mv' // trim(file_num) // '.dat is missing in ' // trim(t_step_dir) // '. Exiting.')
705 end if
706 end do
707 end do
708 end if
709
710 ! Since the preexisting grid and initial condition data files have been read in, the directory associated with the rank of
711 ! the local process may be cleaned out to make room for new pre-process data. In addition, the time-step folder that will
712 ! contain the new grid and initial condition data are also generated.
714 call s_create_directory(trim(proc_rank_dir) // '/0')
715
716 end subroutine s_read_serial_ic_data_files
717
718 !> Cell-boundary data are checked for consistency by looking at the (non-)uniform cell-width distributions for all the active
719 !! coordinate directions and making sure that all of the cell-widths are positively valued
721
722#ifdef MFC_MPI
723 real(wp), allocatable, dimension(:) :: x_cb_glb, y_cb_glb, z_cb_glb
724 integer :: ifile, ierr, data_size
725 integer, dimension(MPI_STATUS_SIZE) :: status
726 character(LEN=path_len + 2*name_len) :: file_loc
727 logical :: file_exist
728
729 allocate (x_cb_glb(-1:m_glb))
730 allocate (y_cb_glb(-1:n_glb))
731 allocate (z_cb_glb(-1:p_glb))
732
733 file_loc = trim(case_dir) // '/restart_data' // trim(mpiiofs) // 'x_cb.dat'
734 inquire (file=trim(file_loc), exist=file_exist)
735
736 if (file_exist) then
737 data_size = m_glb + 2
738 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
739 call s_check_mpi_file_open(ierr, file_loc)
740 call mpi_file_read_all(ifile, x_cb_glb, data_size, mpi_p, status, ierr)
741 call mpi_file_close(ifile, ierr)
742 else
743 call s_mpi_abort('File ' // trim(file_loc) // ' is missing. Exiting. ')
744 end if
745
746 x_cb(-1:m) = x_cb_glb((start_idx(1) - 1):(start_idx(1) + m))
747 x_cc(0:m) = (x_cb(0:m) + x_cb(-1:(m - 1)))/2._wp
748 dx_min = minval(x_cb(0:m) - x_cb(-1:(m - 1)))
749 if (num_procs > 1) call s_mpi_reduce_min(dx_min)
750 x_domain%beg = x_cb(-1)
751 x_domain%end = x_cb(m)
752
753 if (n > 0) then
754 file_loc = trim(case_dir) // '/restart_data' // trim(mpiiofs) // 'y_cb.dat'
755 inquire (file=trim(file_loc), exist=file_exist)
756
757 if (file_exist) then
758 data_size = n_glb + 2
759 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
760 call s_check_mpi_file_open(ierr, file_loc)
761 call mpi_file_read_all(ifile, y_cb_glb, data_size, mpi_p, status, ierr)
762 call mpi_file_close(ifile, ierr)
763 else
764 call s_mpi_abort('File ' // trim(file_loc) // ' is missing. Exiting. ')
765 end if
766
767 y_cb(-1:n) = y_cb_glb((start_idx(2) - 1):(start_idx(2) + n))
768 y_cc(0:n) = (y_cb(0:n) + y_cb(-1:(n - 1)))/2._wp
769 dy_min = minval(y_cb(0:n) - y_cb(-1:(n - 1)))
770 if (num_procs > 1) call s_mpi_reduce_min(dy_min)
771 y_domain%beg = y_cb(-1)
772 y_domain%end = y_cb(n)
773
774 if (p > 0) then
775 file_loc = trim(case_dir) // '/restart_data' // trim(mpiiofs) // 'z_cb.dat'
776 inquire (file=trim(file_loc), exist=file_exist)
777
778 if (file_exist) then
779 data_size = p_glb + 2
780 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
781 call s_check_mpi_file_open(ierr, file_loc)
782 call mpi_file_read_all(ifile, z_cb_glb, data_size, mpi_p, status, ierr)
783 call mpi_file_close(ifile, ierr)
784 else
785 call s_mpi_abort('File ' // trim(file_loc) // ' is missing. Exiting. ')
786 end if
787
788 z_cb(-1:p) = z_cb_glb((start_idx(3) - 1):(start_idx(3) + p))
789 z_cc(0:p) = (z_cb(0:p) + z_cb(-1:(p - 1)))/2._wp
790 dz_min = minval(z_cb(0:p) - z_cb(-1:(p - 1)))
791 if (num_procs > 1) call s_mpi_reduce_min(dz_min)
792 z_domain%beg = z_cb(-1)
793 z_domain%end = z_cb(p)
794 end if
795 end if
796
797 deallocate (x_cb_glb, y_cb_glb, z_cb_glb)
798#endif
799
801
802 !> The goal of this subroutine is to read in any preexisting initial condition data files so that they may be used by the
803 !! pre-process as a starting point in the creation of an all new initial condition.
804 impure subroutine s_read_parallel_ic_data_files(q_cons_vf_in)
805
806 type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf_in
807
808#ifdef MFC_MPI
809 integer :: ifile, ierr, data_size
810 integer, dimension(MPI_STATUS_SIZE) :: status
811 integer(KIND=MPI_OFFSET_KIND) :: disp
812 integer(KIND=MPI_OFFSET_KIND) :: m_mok, n_mok, p_mok
813 integer(KIND=MPI_OFFSET_KIND) :: wp_mok, var_mok
814 integer(KIND=MPI_OFFSET_KIND) :: mok
815 character(LEN=path_len + 2*name_len) :: file_loc
816 logical :: file_exist
817 integer :: i
818
819 if (cfl_adap_dt) then
820 write (file_loc, '(I0,A)') n_start, '.dat'
821 else
822 write (file_loc, '(I0,A)') t_step_start, '.dat'
823 end if
824 file_loc = trim(restart_dir) // trim(mpiiofs) // trim(file_loc)
825 inquire (file=trim(file_loc), exist=file_exist)
826
827 if (file_exist) then
828 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
829 call s_check_mpi_file_open(ierr, file_loc)
830
831 call s_initialize_mpi_data(q_cons_vf_in, qbmm_pb=pb, qbmm_mv=mv)
832
833 data_size = (m + 1)*(n + 1)*(p + 1)
834
835 ! Resize some integers so MPI can read even the biggest files
836 m_mok = int(m_glb + 1, mpi_offset_kind)
837 n_mok = int(n_glb + 1, mpi_offset_kind)
838 p_mok = int(p_glb + 1, mpi_offset_kind)
839 wp_mok = int(storage_size(0._stp)/8, mpi_offset_kind)
840 mok = int(1._wp, mpi_offset_kind)
841
842 do i = 1, sys_size
843 var_mok = int(i, mpi_offset_kind)
844
845 ! Initial displacement to skip at beginning of file
846 disp = m_mok*max(mok, n_mok)*max(mok, p_mok)*wp_mok*(var_mok - 1)
847
848 call mpi_file_set_view(ifile, disp, mpi_p, mpi_io_data%view(i), 'native', mpi_info_int, ierr)
849 call mpi_file_read(ifile, mpi_io_data%var(i)%sf(:,:,:), data_size, mpi_p, status, ierr)
850 end do
851
852 if (qbmm .and. .not. polytropic) then
853 do i = sys_size + 1, sys_size + 2*nb*nnode
854 var_mok = int(i, mpi_offset_kind)
855
856 ! Initial displacement to skip at beginning of file
857 disp = m_mok*max(mok, n_mok)*max(mok, p_mok)*wp_mok*(var_mok - 1)
858
859 call mpi_file_set_view(ifile, disp, mpi_p, mpi_io_data%view(i), 'native', mpi_info_int, ierr)
860 call mpi_file_read(ifile, mpi_io_data%var(i)%sf(:,:,:), data_size, mpi_p, status, ierr)
861 end do
862 end if
863
864 call s_mpi_barrier()
865
866 call mpi_file_close(ifile, ierr)
867 else
868 call s_mpi_abort('File ' // trim(file_loc) // ' is missing. Exiting. ')
869 end if
870
871 call s_mpi_barrier()
872#endif
873
874 end subroutine s_read_parallel_ic_data_files
875
876 !> Initialize all pre-process modules, allocate data structures, and set I/O procedure pointers.
877 impure subroutine s_initialize_modules
878
880 if (bubbles_euler .or. bubbles_lagrange) then
882 end if
883 call s_initialize_mpi_common_module(exchange_all_chemistry_temperatures_in=.false., use_rdma_transport_in=.false., &
884 & num_beta_vars_in=0)
890 call s_initialize_perturbation_module()
893 if (relax) call s_initialize_phasechange_module()
894
895 ! Create the D directory if it doesn't exit, to store the serial data files
896 call s_create_directory('D')
897
898 if (parallel_io .neqv. .true.) then
903 else
908 end if
909
910 end subroutine s_initialize_modules
911
912 !> Read an existing grid from data files or generate a new grid from user inputs.
913 impure subroutine s_read_grid()
914
915 if (old_grid) then
918 else
919 if (parallel_io .neqv. .true.) then
920 call s_generate_grid()
921 else
922 if (proc_rank == 0) call s_generate_grid()
923 call s_mpi_barrier()
926 end if
927 end if
928
929 end subroutine s_read_grid
930
931 !> Generate or read the initial condition, apply relaxation if needed, and write output data files.
932 impure subroutine s_apply_initial_condition(start, finish)
933
934 real(wp), intent(inout) :: start, finish
935 integer :: j, k, l
936 real(wp) :: r2
937
938 call cpu_time(start)
939
940 if (old_ic) call s_read_ic_data_files(ic%q_cons_vf)
941
943
944 ! hard-coded psi
945 if (hyper_cleaning) then
946 if (.not. (eqn_idx%psi > 0)) then
947# 570 "/home/runner/work/MFC/MFC/src/pre_process/m_start_up.fpp"
948 call s_mpi_abort("m_start_up.fpp:570: " // "Assertion failed: eqn_idx%psi > 0. " &
949# 570 "/home/runner/work/MFC/MFC/src/pre_process/m_start_up.fpp"
950 & // "hyper_cleaning requires eqn_idx%psi to be set")
951# 570 "/home/runner/work/MFC/MFC/src/pre_process/m_start_up.fpp"
952 end if
953# 571 "/home/runner/work/MFC/MFC/src/pre_process/m_start_up.fpp"
954 do l = 0, p
955 do k = 0, n
956 do j = 0, m
957 r2 = x_cc(j)**2
958 if (n > 0) r2 = r2 + y_cc(k)**2
959 if (p > 0) r2 = r2 + z_cc(l)**2
960 ic%q_cons_vf(eqn_idx%psi)%sf(j, k, l) = 1.0e-2_wp*exp(-r2/(2.0_wp*0.05_wp**2))
961 ic%q_prim_vf(eqn_idx%psi)%sf(j, k, l) = ic%q_cons_vf(eqn_idx%psi)%sf(j, k, l)
962 end do
963 end do
964 end do
965 end if
966
967 if (relax) then
968 if (proc_rank == 0) then
969 print *, 'initial condition might have been altered due to enforcement of pTg-equilibrium (relax = "T" activated)'
970 end if
971
972 call s_infinite_relaxation_k(ic%q_cons_vf)
973 end if
974
975 if (chemistry) then
976 call s_write_data_files(ic%q_cons_vf, ic%q_prim_vf, ic%bc_type, ic%q_T_sf)
977 else
978 call s_write_data_files(ic%q_cons_vf, ic%q_prim_vf, ic%bc_type)
979 end if
980
981 call cpu_time(finish)
982
983 end subroutine s_apply_initial_condition
984
985 !> Gather processor timing data and write elapsed wall-clock time to a summary file.
986 impure subroutine s_save_data(proc_time, time_avg, time_final, file_exists)
987
988 real(wp), dimension(:), intent(inout) :: proc_time
989 real(wp), intent(inout) :: time_avg, time_final
990 logical, intent(inout) :: file_exists
991
992 call s_mpi_barrier()
993
994 if (num_procs > 1) then
995 call mpi_bcast_time_step_values(proc_time, time_avg)
996 end if
997
998 if (proc_rank == 0) then
999 time_final = 0._wp
1000 if (num_procs == 1) then
1001 time_final = time_avg
1002 print *, "Elapsed Time", time_final
1003 else
1004 time_final = maxval(proc_time)
1005 print *, "Elapsed Time", time_final
1006 end if
1007 inquire (file='pre_time_data.dat', exist=file_exists)
1008 if (file_exists) then
1009 open (1, file='pre_time_data.dat', position='append', status='old')
1010 write (1, *) num_procs, time_final
1011 close (1)
1012 else
1013 open (1, file='pre_time_data.dat', status='new')
1014 write (1, *) num_procs, time_final
1015 close (1)
1016 end if
1017 end if
1018
1019 end subroutine s_save_data
1020
1021 !> Initialize MPI, read and validate user inputs on rank 0, and decompose the computational domain.
1022 impure subroutine s_initialize_mpi_domain
1023
1024 type(bounds_info), dimension(3) :: local_domains
1025
1026 call s_mpi_initialize()
1027
1028 if (proc_rank == 0) then
1030 call s_read_input_file()
1031 call s_check_input_file()
1032
1033 print '(" Pre-processing a ", I0, "x", I0, "x", I0, " case on ", I0, " rank(s)")', m, n, p, num_procs
1034 end if
1035
1036 ! Broadcasting the user inputs to all of the processors and performing the parallel computational domain decomposition.
1037 ! Neither procedure has to be carried out if pre-process is in fact not truly executed in parallel.
1039
1040 ! Save original BCs before decomposition overwrites them with MPI neighbor ranks
1041 ib_bc_x = bc_x
1042 ib_bc_y = bc_y
1043 ib_bc_z = bc_z
1044
1046
1047 ! Save the global domain bounds before decomposition overwrites x/y/z_domain with each processor's local sub-domain bounds
1051
1052 local_domains = (/x_domain, y_domain, z_domain/)
1053 call s_mpi_decompose_computational_domain(write_silo_ghost_offsets=.false., adjust_local_domains= .not. old_grid, &
1054 & local_domains=local_domains)
1055 x_domain = local_domains(1)
1056 y_domain = local_domains(2)
1057 z_domain = local_domains(3)
1058
1060
1061 end subroutine s_initialize_mpi_domain
1062
1063 !> Finalize all pre-process modules, deallocate resources, and shut down MPI.
1064 impure subroutine s_finalize_modules
1065
1066 s_generate_grid => null()
1067 s_read_grid_data_files => null()
1068 s_read_ic_data_files => null()
1069 s_write_data_files => null()
1070
1078 call s_finalize_perturbation_module()
1080 if (relax) call s_finalize_relaxation_solver_module()
1082 call s_mpi_finalize()
1083
1084 end subroutine s_finalize_modules
1085
1086end module m_start_up
Abstract interface for reading grid data files in serial or parallel.
Abstract interface for reading initial condition data files in serial or parallel.
integer, intent(in) k
integer, intent(in) j
integer, intent(in) l
Assigns initial primitive variables to computational cells based on patch geometry.
impure subroutine, public s_initialize_assign_variables_module
Set the patch primitive variable assignment procedure pointer.
impure subroutine, public s_finalize_assign_variables_module
Nullify the patch primitive variable assignment procedure pointer.
Noncharacteristic and processor boundary condition application for ghost cells and buffer regions.
impure subroutine, public s_initialize_boundary_common_module(use_dirichlet_buffers, nvar_io)
Allocate and set up boundary condition buffer arrays for all coordinate directions.
subroutine, public s_finalize_boundary_common_module()
Deallocate boundary condition buffer arrays allocated during module initialization.
Applies spatially varying boundary condition patches along domain edges and faces.
Validates geometry parameters and constraints for immersed boundary patches.
impure subroutine, public s_check_ib_patches
Validate the geometry parameters of all active and inactive immersed boundary patches.
Validates geometry parameters and constraints for initial condition patches.
impure subroutine, public s_check_patches
Validate the geometry parameters of all active and inactive initial condition patches.
Shared input validation checks for grid dimensions and AMD GPU compiler limits.
impure subroutine, public s_check_inputs_common(check_total_cells, n_global)
Checks compatibility of parameters in the input file. Used by all three stages.
Checks pre-process input file parameters for compatibility and correctness.
impure subroutine, public s_check_inputs
Checks compatibility of parameters in the input file. Used by the pre_process stage.
Platform-specific file and directory operations: create, delete, inquire, getcwd, and basename.
impure subroutine s_delete_directory(dir_name)
Recursively delete a directory using a platform-specific system command.
impure subroutine my_inquire(fileloc, dircheck)
Inquire on the existence of a directory or file.
impure subroutine s_create_directory(dir_name)
Create a directory and all its parents if it does not exist.
Writes grid and initial condition data to serial or parallel output files.
procedure(s_write_abstract_data_files), pointer, public s_write_data_files
impure subroutine, public s_write_ib_state_0_file(glb_bounds, particle_cloud_ibs, num_particle_cloud_ibs)
Writes the initial IB layout (namelist patch_ib entries, then generated particle-cloud beds) that sim...
impure subroutine, public s_write_serial_data_files(q_cons_vf, q_prim_vf, bc_type, q_t_sf)
Writes grid and initial condition data files to the "0" time-step directory in the local processor ra...
character(len=path_len+2 *name_len), private t_step_dir
Time-step folder into which grid and initial condition data will be placed.
impure subroutine, public s_initialize_data_output_module
Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the...
impure subroutine, public s_finalize_data_output_module
Resets s_write_data_files pointer.
impure subroutine, public s_write_parallel_data_files(q_cons_vf, q_prim_vf, bc_type, q_t_sf)
Writes grid and initial condition data files in parallel to the "0" time-step directory in the local ...
character(len=path_len+2 *name_len), public restart_dir
Restart data folder.
Shared derived types for field data, patch geometry, bubble dynamics, and MPI I/O structures.
Equations of state in Gamma/Pi form, rho e = Gamma(rho) p + Pi(rho).
impure subroutine, public s_finalize_eos_module()
Deallocate the fluid property arrays allocated in s_initialize_eos_module.
impure subroutine, public s_initialize_eos_module()
Resolve every fluid's EOS coefficients once, before any conversion runs.
Defines global parameters for the computational domain, simulation algorithm, and initial conditions.
type(int_bounds_info) ib_bc_z
bc_x/y/z before decomposition overwrites them with MPI neighbor ranks
integer p_glb
Global number of cells in each direction.
impure subroutine s_assign_default_values_to_user_inputs
Assigns default values to user inputs prior to reading them in. This allows for an easier consistency...
impure subroutine s_finalize_global_parameters_module
Deallocate all global grid, index, and equation-of-state parameter arrays.
type(int_bounds_info) ib_bc_y
type(int_bounds_info) ib_bc_x
type(int_bounds_info) bc_z
Boundary conditions in the x-, y- and z-coordinate directions.
real(wp), dimension(:), allocatable y_cc
integer proc_rank
Rank of the local processor Number of cells in the x-, y- and z-coordinate directions.
logical bc_io
whether or not to save BC data
real(wp), dimension(:), allocatable y_cb
type(bounds_info) z_domain
Locations of the domain bounds in the x-, y- and z-coordinate directions.
real(wp), dimension(:), allocatable z_cb
type(int_bounds_info) bc_y
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
Locations of cell-centers (cc) in x-, y- and z-directions, respectively.
type(int_bounds_info) bc_x
real(wp), dimension(:), allocatable x_cb
Locations of cell-boundaries (cb) in x-, y- and z-directions, respectively.
real(wp), dimension(:), allocatable z_cc
integer num_procs
Number of processors.
type(bounds_info) x_domain_glb
Global (pre-decomposition) domain bounds, needed by s_generate_serial_grid to stretch the grid using ...
type(cell_num_bounds) cells_bounds
type(mpi_io_var), public mpi_io_data
impure subroutine s_initialize_parallel_io
Configure MPI parallel I/O settings and allocate processor coordinate arrays.
type(bc_xyz_info) bc
Combined BC storage (used by the shared beta-buffer routines; pre-process-local).
integer(kind=8) nglobal
Global number of cells in the domain.
Generates uniform or stretched rectilinear grids with hyperbolic-tangent spacing.
Definition m_grid.f90:6
impure subroutine, public s_generate_serial_grid
Generate a uniform or stretched rectilinear grid in serial from user parameters.
Definition m_grid.f90:35
impure subroutine, public s_initialize_grid_module
Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the...
Definition m_grid.f90:289
procedure(s_generate_abstract_grid), pointer, public s_generate_grid
Definition m_grid.f90:29
impure subroutine, public s_generate_parallel_grid
Generate a uniform or stretched rectilinear grid in parallel from user parameters.
Definition m_grid.f90:157
impure subroutine, public s_finalize_grid_module
Deallocation procedures for the module.
Definition m_grid.f90:300
Basic floating-point utilities: approximate equality, default detection, and coordinate bounds.
elemental subroutine, public s_update_cell_bounds(bounds, m, n, p)
Update the min and max number of cells in each set of axes.
Utility routines for bubble model setup, coordinate transforms, array sampling, and special functions...
impure subroutine, public s_initialize_bubbles_model()
Initialize bubble model arrays for Euler or Lagrangian bubbles with polytropic or non-polytropic gas.
Allocate memory and read initial condition data for IC extrusion.
Assembles initial conditions by layering prioritized patches via constructive solid geometry.
type(ic_context) ic
Initial-condition state (fields, bc types, patch ids).
impure subroutine s_initialize_initial_condition_module
Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the...
impure subroutine s_finalize_initial_condition_module
Deallocation procedures for the module.
impure subroutine s_generate_initial_condition
Iterate over patches and, depending on the geometry type, call the related subroutine to setup the sa...
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(exchange_all_chemistry_temperatures_in, use_rdma_transport_in, num_beta_vars_in)
Initialize the module.
impure subroutine s_mpi_barrier
Halts all processes until all have reached barrier.
impure subroutine s_mpi_initialize
Initialize the MPI execution environment and query the number of processors and local rank.
impure subroutine s_check_mpi_file_open(ierr, file_loc)
Abort naming the file if MPI_FILE_OPEN failed. File errors default to MPI_ERRORS_RETURN,...
impure subroutine s_mpi_finalize
The subroutine finalizes the MPI execution environment.
impure subroutine s_initialize_mpi_data(q_cons_vf, ib_markers, ib_mpi_data, beta, qbmm_pb, qbmm_mv)
Set up MPI I/O data views and variable pointers for parallel file output.
subroutine s_mpi_decompose_computational_domain(write_silo_ghost_offsets, adjust_local_domains, output_offsets, local_domains)
The purpose of this procedure is to optimally decompose the computational domain among the available ...
impure subroutine mpi_bcast_time_step_values(proc_time, time_avg)
Gather per-rank time step wall-clock times onto rank 0 for performance reporting.
impure subroutine s_mpi_reduce_min(var_loc)
Reduce a local real value to its global minimum across all ranks.
impure subroutine s_finalize_mpi_common_module
Module deallocation and/or disassociation procedures.
Broadcasts user inputs and decomposes the domain across MPI ranks for pre-processing.
impure subroutine s_mpi_bcast_user_inputs
Since only processor with rank 0 is in charge of reading and checking the consistency of the user pro...
Generates particle beds by converting particle_cloud patch specifications into individual immersed bo...
impure subroutine, public s_generate_particle_clouds(glb_bounds, particle_cloud_ibs, num_particle_cloud_ibs)
Generate all particle beds and fill particle_cloud_ibs, keeping only the particles this rank owns und...
Phase transition relaxation solvers for liquid-vapor flows with cavitation and boiling.
impure subroutine, public s_finalize_relaxation_solver_module
Finalize the phase change module.
subroutine, public s_infinite_relaxation_k(q_cons_vf)
Apply pT- or pTg-equilibrium relaxation with mass depletion based on the incoming state conditions.
impure subroutine, public s_initialize_phasechange_module
Initialize the phase change module (no module-level state to set up; the pT/pTg relaxation solvers ar...
Reads and validates user inputs, loads existing grid/IC data, and initializes pre-process modules.
impure subroutine, public s_read_serial_ic_data_files(q_cons_vf_in)
The goal of this subroutine is to read in any preexisting initial condition data files so that they m...
impure subroutine, public s_initialize_modules
Initialize all pre-process modules, allocate data structures, and set I/O procedure pointers.
impure subroutine, public s_save_data(proc_time, time_avg, time_final, file_exists)
Gather processor timing data and write elapsed wall-clock time to a summary file.
impure subroutine, public s_write_ib_state_0()
Generates the particle-cloud beds (if any) and writes the initial IB state file that simulation reads...
impure subroutine, public s_apply_initial_condition(start, finish)
Generate or read the initial condition, apply relaxation if needed, and write output data files.
character(len=path_len+name_len) proc_rank_dir
Location of the folder associated with the rank of the local processor.
impure subroutine, public s_read_serial_grid_data_files
The goal of this subroutine is to read in any preexisting grid data as well as based on the imported ...
impure subroutine, public s_read_parallel_ic_data_files(q_cons_vf_in)
The goal of this subroutine is to read in any preexisting initial condition data files so that they m...
procedure(s_read_abstract_ic_data_files), pointer, public s_read_ic_data_files
impure subroutine, public s_read_grid()
Read an existing grid from data files or generate a new grid from user inputs.
impure subroutine, public s_check_grid_data_files
Cell-boundary data are checked for consistency by looking at the (non-)uniform cell-width distributio...
impure subroutine, public s_initialize_mpi_domain
Initialize MPI, read and validate user inputs on rank 0, and decompose the computational domain.
impure subroutine, public s_finalize_modules
Finalize all pre-process modules, deallocate resources, and shut down MPI.
impure subroutine, public s_read_input_file
Reads the configuration file pre_process.inp, in order to populate the parameters in module m_global_...
impure subroutine, public s_check_input_file
Checking that the user inputs make sense, i.e. that the individual choices are compatible with the co...
procedure(s_read_abstract_grid_data_files), pointer, public s_read_grid_data_files
impure subroutine, public s_read_parallel_grid_data_files
Cell-boundary data are checked for consistency by looking at the (non-)uniform cell-width distributio...
Conservative-to-primitive variable conversion, mixture property evaluation, and pressure computation.
impure subroutine, public s_finalize_variables_conversion_module()
Deallocate fluid property arrays and post-processing fields allocated during module initialization.
impure subroutine, public s_initialize_variables_conversion_module(store_mixture_fields, enforce_density_floor, preserve_qbmm_number, lagrange_beta_index)
Initialize the variables conversion module.
Groups the x, y, z boundary condition begin/end codes for passing as a single argument.
Derived type adding beginning (beg) and end bounds info as attributes.
Derived type annexing an integer scalar field (SF).
Derived type for bubble variables pb and mv at quadrature nodes (qbmm).
Derived type annexing a scalar field (SF).