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/simulation/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/case.fpp" 1
7! This file exists so that Fypp can be run without generating case.fpp files for
8! each target. This is useful when generating documentation, for example. This
9! should also let MFC be built with CMake directly, without invoking mfc.sh.
10
11! For pre-process.
12# 8 "/home/runner/work/MFC/MFC/src/common/include/case.fpp"
13
14! For moving immersed boundaries in simulation
15# 12 "/home/runner/work/MFC/MFC/src/common/include/case.fpp"
16# 6 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp" 2
17# 1 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp" 1
18# 1 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 1
19# 1 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 1
20# 2 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
21# 3 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
22# 4 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
23# 5 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
24# 6 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
25
26# 8 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
27# 9 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
28# 10 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
29
30# 12 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
31# 1 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp" 1
32! Default for Fypp runs outside the toolchain (e.g. documentation). Searched last, so the
33! build/include/<target>/thermochem.fpp the toolchain writes from m_thermochem takes precedence.
34# 4 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
35# 5 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
36# 13 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 2
37
38# 16 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
39# 17 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
40
41# 24 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
42
43# 53 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
44
45# 65 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
46
47# 75 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
48
49# 105 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
50
51# 117 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
52
53# 127 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
54
55# 174 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
56! New line at end of file is required for FYPP
57# 2 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 2
58# 1 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp" 1
59# 1 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 1
60# 2 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
61# 3 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
62# 4 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
63# 5 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
64# 6 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
65
66# 8 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
67# 9 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
68# 10 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
69
70# 12 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
71# 1 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp" 1
72! Default for Fypp runs outside the toolchain (e.g. documentation). Searched last, so the
73! build/include/<target>/thermochem.fpp the toolchain writes from m_thermochem takes precedence.
74# 4 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
75# 5 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
76# 13 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 2
77
78# 16 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
79# 17 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
80
81# 24 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
82
83# 53 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
84
85# 65 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
86
87# 75 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
88
89# 105 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
90
91# 117 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
92
93# 127 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
94
95# 174 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
96! New line at end of file is required for FYPP
97# 2 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp" 2
98
99# 4 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
100# 5 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
101# 6 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
102# 7 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
103# 8 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
104
105# 20 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
106
107# 49 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
108
109# 54 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
110
111# 59 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
112
113# 64 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
114
115# 69 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
116
117# 74 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
118
119# 87 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
120
121# 101 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
122
123# 106 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
124
125# 111 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
126
127# 116 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
128
129# 121 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
130
131# 126 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
132
133# 131 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
134
135# 136 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
136
137# 141 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
138
139# 171 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
140
141# 231 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
142
143# 245 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
144
145# 270 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
146
147# 281 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
148
149# 283 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
150# 294 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
151
152# 343 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
153
154# 353 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
155
156# 363 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
157
158# 372 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
159
160# 389 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
161
162# 399 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
163
164# 406 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
165
166# 412 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
167
168# 418 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
169
170# 424 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
171
172# 430 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
173
174# 436 "/home/runner/work/MFC/MFC/src/common/include/omp_macros.fpp"
175! New line at end of file is required for FYPP
176# 3 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 2
177# 1 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp" 1
178# 1 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 1
179# 2 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
180# 3 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
181# 4 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
182# 5 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
183# 6 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
184
185# 8 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
186# 9 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
187# 10 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
188
189# 12 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
190# 1 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp" 1
191! Default for Fypp runs outside the toolchain (e.g. documentation). Searched last, so the
192! build/include/<target>/thermochem.fpp the toolchain writes from m_thermochem takes precedence.
193# 4 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
194# 5 "/home/runner/work/MFC/MFC/src/common/include/defaults/thermochem.fpp"
195# 13 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp" 2
196
197# 16 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
198# 17 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
199
200# 24 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
201
202# 53 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
203
204# 65 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
205
206# 75 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
207
208# 105 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
209
210# 117 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
211
212# 127 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
213
214# 174 "/home/runner/work/MFC/MFC/src/common/include/shared_parallel_macros.fpp"
215! New line at end of file is required for FYPP
216# 2 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp" 2
217
218# 7 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
219
220# 17 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
221
222# 22 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
223
224# 27 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
225
226# 32 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
227
228# 37 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
229
230# 42 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
231
232# 47 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
233
234# 52 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
235
236# 57 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
237
238# 62 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
239
240# 73 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
241
242# 78 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
243
244# 83 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
245
246# 88 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
247
248# 103 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
249
250# 131 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
251
252# 161 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
253
254# 176 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
255
256# 194 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
257
258# 216 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
259
260# 245 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
261
262# 260 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
263
264# 270 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
265
266# 279 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
267
268# 295 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
269
270# 305 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
271
272# 312 "/home/runner/work/MFC/MFC/src/common/include/acc_macros.fpp"
273! New line at end of file is required for FYPP
274# 4 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp" 2
275
276! GPU parallel region (scalar reductions, maxval/minval)
277# 23 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
278
279! GPU parallel loop over threads (most common GPU macro)
280# 44 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
281
282! Required closing for GPU_PARALLEL_LOOP
283# 56 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
284
285! Mark routine for device compilation
286# 113 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
287
288! Declare device-resident data
289# 131 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
290
291! Inner loop within a GPU parallel region
292# 146 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
293
294! Scoped GPU data region
295# 165 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
296
297! Host code with device pointers (for MPI with GPU buffers)
298# 191 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
299
300! Allocate device memory (unscoped)
301# 205 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
302
303! Free device memory
304# 217 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
305
306! Atomic operation on device
307# 229 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
308
309! End atomic capture block
310# 240 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
311
312! Copy data between host and device
313# 252 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
314
315! Synchronization barrier
316# 264 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
317
318! Import GPU library module (openacc or omp_lib)
319# 273 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
320
321! Emit code only for AMD compiler
322# 280 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
323
324! Emit code for non-Cray compilers
325# 287 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
326
327! Emit code only for Cray compiler
328# 294 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
329
330! Cray compiler directive, emitted from Fypp so the formatter cannot turn it into a comment
331# 301 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
332
333! Emit code for non-NVIDIA compilers
334# 308 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
335
336# 310 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
337# 311 "/home/runner/work/MFC/MFC/src/common/include/parallel_macros.fpp"
338! New line at end of file is required for FYPP
339# 2 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp" 2
340
341# 14 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
342
343! Caution: This macro requires the use of a binding script to set CUDA_VISIBLE_DEVICES, such that we have one GPU device per MPI
344! rank. That's because for both cudaMemAdvise (preferred location) and cudaMemPrefetchAsync we use location = device_id = 0. For an
345! example see misc/nvidia_uvm/bind.sh.
346# 52 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
347
348! Allocate and create GPU device memory
349# 72 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
350
351! Free GPU device memory and deallocate
352# 80 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
353
354! Cray-specific GPU pointer setup for vector fields
355# 104 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
356
357! Cray-specific GPU pointer setup for scalar fields
358# 120 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
359
360! Cray-specific GPU pointer teardown for scalar fields - exact inverse of ACC_SETUP_SFs. Removes the
361! present-table entries ACC_SETUP_SFs added (the scalar_field descriptor and its %sf copyin). REQUIRED when
362! an ACC_SETUP'd field is freed MID-RUN (e.g. AMR slot free on regrid/restart): Cray 'exit data delete'
363! decrements the reference counter, so the lone @:DEALLOCATE(arg%sf) only undoes the @:ALLOCATE create ref
364! and leaves the descriptor + the ACC_SETUP %sf copyin dangling. Call BEFORE @:DEALLOCATE(arg%sf).
365# 140 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
366
367! Cray-specific GPU pointer setup for acoustic source spatials
368# 165 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
369
370! Whether stress index idx is a shear component. Spelled out because NVHPC 26.9 at -O2 vectorizes any(idx == shear_indices)
371! inside a loop to always true, which doubled the normal-stress elastic energy.
372# 171 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
373
374# 177 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
375
376# 184 "/home/runner/work/MFC/MFC/src/common/include/macros.fpp"
377! New line at end of file is required for FYPP
378# 7 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp" 2
379
380!> @brief Reads input files, loads initial conditions and grid data, and orchestrates solver initialization and finalization
382
386 use m_mpi_proxy
387 use m_mpi_common
389 use m_eos
390 use m_weno
391 use m_muscl
392 use m_thinc
394 use m_cbc
396 use m_boundary_io
398 use m_rhs
400 use m_chemistry
401 use m_data_output
403 use m_qbmm
405 use m_hypoelastic
407 use m_viscous
408 use m_bubbles_ee
409 use m_bubbles_el
412 use ieee_arithmetic
414 use m_helper
415
416#if defined(MFC_OpenACC)
417# 44 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
418 use openacc
419# 44 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
420#elif defined(MFC_OpenMP)
421# 44 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
422 use omp_lib
423# 44 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
424#endif
425# 45 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
426
427 use m_nvtx
428 use m_ibm
429 use m_ib_patches
430 use m_model
431 use m_collisions
434 use m_checker
436 use m_body_forces
437 use m_sim_helpers
438 use m_igr
439 use m_amr, only: amr_maxc_fit, s_initialize_amr_module, s_populate_amr_fine, s_finalize_amr_module, s_amr_setup_ib
440 use m_amr_regrid, only: s_amr_regrid
446
447 implicit none
448
452
453 type(scalar_field), allocatable, dimension(:) :: q_cons_temp
454 real(wp) :: dt_init
455
456contains
457
458 !> Read data files. Dispatch subroutine that replaces procedure pointer.
459 impure subroutine s_read_data_files(q_cons_vf)
460
461 type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf
462
463 if (.not. parallel_io) then
465 else
467 end if
468
469 end subroutine s_read_data_files
470
471 !> Verify the input file exists and read it
472 impure subroutine s_read_input_file
473
474 character(LEN=name_len), parameter :: file_path = './simulation.inp'
475 logical :: file_exist !< Logical used to check the existence of the input file
476 integer :: iostatus
477 ! Integer to check iostat of file read
478
479 character(len=1000) :: line
480
481# 1 "/home/runner/work/MFC/MFC/build/include/simulation/generated_namelist.fpp" 1
482! AUTO-GENERATED - do not edit directly. Regenerate: cmake reconfigure
483!
484# 27 "/home/runner/work/MFC/MFC/build/include/simulation/generated_namelist.fpp"
485namelist /user_inputs/ adc_kappa, bx0, ca, r0ref, re_inv, web, acoustic, acoustic_source, adap_dt, adap_dt_max_iters, &
486 & adap_dt_tol, adv_n, alf_factor, alpha_bar, alt_soundspeed, amr, amr_block_beg, amr_block_end, amr_blocking_factor, &
487 & amr_buf, amr_cluster_eff, amr_device_pack, amr_max_blocks, amr_max_grid_size, amr_max_level, amr_place_owner, amr_prolong, &
488 & amr_ref_ratio, amr_regrid_int, amr_snap, amr_subcycle, amr_tag_abs, amr_tag_eps, avg_state, bc_x, bc_y, bc_z, &
489 & bf_spatial_support, bf_x, bf_y, bf_z, bub_pp, bubble_model, bubbles_euler, bubbles_lagrange, case_dir, cfl_adap_dt, &
490 & cfl_const_dt, cfl_target, chem_params, coefficient_of_restitution, collision_model, collision_temporal_resolution, &
491 & collision_time, cont_damage, cont_damage_s, cyl_coord, down_sample, dt, face_bound, fd_order, fft_wrt, file_per_process, &
492 & fluid_pp, g_x, g_y, g_z, hll_u_interface, hyper_cleaning, hyper_cleaning_speed, hyper_cleaning_tau, &
493 & hypo_hll_interface_rhs, hypoelasticity, ib, ib_airfoil, ib_coefficient_of_friction, ib_flux_wall, ib_force_stride, &
494 & ib_force_wrt, ib_heat_wrt, ib_ip_interp, ib_ip_min_dist, ib_mass_relax, ib_neighborhood_radius, ib_second_order_vel, &
495 & ib_smooth_contact, ib_state_wrt, ib_surface_wrt, ib_visc_compact, ib_wall_order, ic_beta, ic_eps, int_comp, k_x, k_y, k_z, &
496 & lag_params, low_mach, m, many_ib_patch_parallelism, mean_dpdx, mean_dpdx_gain, mean_mflux, mean_qdot, mean_temp, &
497 & mean_temp_gain, mean_temp_wall, mixture_err, model_eqns, mp_weno, mpp_lim, muscl_eps, n, n_start, null_weights, &
498 & num_bc_patches, num_ibs, num_igr_iters, num_igr_warm_start_iters, num_particle_clouds, num_probes, num_source, &
499 & num_stl_models, num_turbulent_sources, nv_uvm_igr_temps_on_gpu, nv_uvm_out_of_core, nv_uvm_pref_gpu, p, p_x, p_y, p_z, &
500 & palpha_eps, parallel_io, particle_cloud, particle_params, particle_pp, particles_lagrange, patch_ib, pi_fac, poly_sigma, &
501 & polydisperse, polytropic, precision, prim_vars_wrt, probe, probe_wrt, ptgalpha_eps, qbmm, ramp_ratio, rank_time_wrt, &
502 & rburn, rdma_mpi, reactive_burn, relax, relax_model, riemann_hypo_adc, riemann_solver, run_time_info, sigma, spatial_bf, &
503 & stl_models, surface_tension, synth_l, synth_u_inf, synth_amp_shell, synth_k_shell, synth_n_shells, &
504 & synth_n_waves_per_shell, synth_seed, synthetic_turbulence, t_save, t_step_old, t_step_print, t_step_save, t_step_start, &
505 & t_step_stop, t_stop, tau_star, teno_ct, thermal, time_stepper, turb_pos, w_x, w_y, w_z, wave_speeds, weno_re_flux, &
506 & weno_avg, weno_eps, &
507 & igr, igr_iter_solver, igr_order, igr_pres_lim, mapped_weno, mhd, muscl_lim, muscl_order, nb, num_fluids, recon_type, &
508 & relativity, teno, viscous, weno_order, wenoz, wenoz_q
509# 52 "/home/runner/work/MFC/MFC/build/include/simulation/generated_namelist.fpp"
510# 101 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp" 2
511
512 inquire (file=trim(file_path), exist=file_exist)
513
514 if (file_exist) then
515 open (1, file=trim(file_path), form='formatted', action='read', status='old')
516 read (1, nml=user_inputs, iostat=iostatus)
517
518 if (iostatus /= 0) then
519 backspace(1)
520 read (1, fmt='(A)') line
521 print *, 'Invalid line in namelist: ' // trim(line)
522 call s_mpi_abort('Invalid line in simulation.inp. It is ' // 'likely due to a datatype mismatch. Exiting.')
523 end if
524
525 close (1)
526
527 if (bf_x .or. bf_y .or. bf_z .or. bf_spatial_support .or. any(mean_dpdx /= 0._wp) &
528 & .or. any(.not. f_is_default(mean_mflux)) .or. mean_qdot /= 0._wp .or. .not. f_is_default(mean_temp)) then
529 bodyforces = .true.
530 end if
531
532 m_glb = m
533 n_glb = n
534 p_glb = p
535
537
538 if (cfl_adap_dt .or. cfl_const_dt) cfl_dt = .true.
539
540 if (any((/bc_x%beg, bc_x%end, bc_y%beg, bc_y%end, bc_z%beg, bc_z%end/) == -17) .or. num_bc_patches > 0) then
541 bc_io = .true.
542 end if
543
544 if (bc_x%beg == bc_periodic .and. bc_x%end == bc_periodic) periodic_bc(1) = .true.
545 if (bc_y%beg == bc_periodic .and. bc_y%end == bc_periodic) periodic_bc(2) = .true.
546 if (bc_z%beg == bc_periodic .and. bc_z%end == bc_periodic) periodic_bc(3) = .true.
547 else
548 call s_mpi_abort(trim(file_path) // ' is missing. Exiting.')
549 end if
550
551 end subroutine s_read_input_file
552
553 !> Validate that all user-provided inputs form a consistent simulation configuration
554 impure subroutine s_check_input_file
555
556 character(LEN=path_len) :: file_path
557 logical :: file_exist
558
559 file_path = trim(case_dir) // '/.'
560
561 call my_inquire(file_path, file_exist)
562
563 if (file_exist .neqv. .true.) then
564 call s_mpi_abort(trim(file_path) // ' is missing. Exiting.')
565 end if
566
567 call s_check_inputs_common(check_total_cells=.false., n_global=0_8)
568 call s_check_inputs()
569
570 end subroutine s_check_input_file
571
572 !> Read serial initial condition and grid data files and compute cell-width distributions
573 impure subroutine s_read_serial_data_files(q_cons_vf)
574
575 type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf
576 character(LEN=path_len + 2*name_len) :: t_step_dir !< Relative path to the starting time-step directory
577 character(LEN=path_len + 3*name_len) :: file_path !< Relative path to the grid and conservative variables data files
578 logical :: file_exist !< Logical used to check the existence of the input file
579 integer :: i, r
580
581 if (cfl_dt) then
582 write (t_step_dir, '(A,I0,A,I0)') trim(case_dir) // '/p_all/p', proc_rank, '/', n_start
583 else
584 write (t_step_dir, '(A,I0,A,I0)') trim(case_dir) // '/p_all/p', proc_rank, '/', t_step_start
585 end if
586
587 file_path = trim(t_step_dir) // '/.'
588 call my_inquire(file_path, file_exist)
589
590 if (file_exist .neqv. .true.) then
591 call s_mpi_abort(trim(file_path) // ' is missing. Exiting.')
592 end if
593
594 if (bc_io) then
596 else
598 end if
599
600 file_path = trim(t_step_dir) // '/x_cb.dat'
601
602 inquire (file=trim(file_path), exist=file_exist)
603
604 if (file_exist) then
605 open (2, file=trim(file_path), form='unformatted', action='read', status='old')
606 read (2) x_cb(-1:m); close (2)
607 else
608 call s_mpi_abort(trim(file_path) // ' is missing. Exiting.')
609 end if
610
611 dx(0:m) = x_cb(0:m) - x_cb(-1:m - 1)
612 x_cc(0:m) = x_cb(-1:m - 1) + dx(0:m)/2._wp
613
614 if (n > 0) then
615 file_path = trim(t_step_dir) // '/y_cb.dat'
616
617 inquire (file=trim(file_path), exist=file_exist)
618
619 if (file_exist) then
620 open (2, file=trim(file_path), form='unformatted', action='read', status='old')
621 read (2) y_cb(-1:n); close (2)
622 else
623 call s_mpi_abort(trim(file_path) // ' is missing. Exiting.')
624 end if
625
626 dy(0:n) = y_cb(0:n) - y_cb(-1:n - 1)
627 y_cc(0:n) = y_cb(-1:n - 1) + dy(0:n)/2._wp
628 end if
629
630 if (p > 0) then
631 file_path = trim(t_step_dir) // '/z_cb.dat'
632
633 inquire (file=trim(file_path), exist=file_exist)
634
635 if (file_exist) then
636 open (2, file=trim(file_path), form='unformatted', action='read', status='old')
637 read (2) z_cb(-1:p); close (2)
638 else
639 call s_mpi_abort(trim(file_path) // ' is missing. Exiting.')
640 end if
641
642 dz(0:p) = z_cb(0:p) - z_cb(-1:p - 1)
643 z_cc(0:p) = z_cb(-1:p - 1) + dz(0:p)/2._wp
644 end if
645
646 do i = 1, sys_size
647 write (file_path, '(A,I0,A)') trim(t_step_dir) // '/q_cons_vf', i, '.dat'
648 inquire (file=trim(file_path), exist=file_exist)
649 if (file_exist) then
650 open (2, file=trim(file_path), form='unformatted', action='read', status='old')
651 read (2) q_cons_vf(i)%sf(0:m,0:n,0:p); close (2)
652 else
653 call s_mpi_abort(trim(file_path) // ' is missing. Exiting.')
654 end if
655 end do
656
657 if (bubbles_euler .or. hypoelasticity) then
658 ! Read pb and mv for non-polytropic qbmm
659 if (qbmm .and. .not. polytropic) then
660 do i = 1, nb
661 do r = 1, nnode
662 write (file_path, '(A,I0,A)') trim(t_step_dir) // '/pb', sys_size + (i - 1)*nnode + r, '.dat'
663 inquire (file=trim(file_path), exist=file_exist)
664 if (file_exist) then
665 open (2, file=trim(file_path), form='unformatted', action='read', status='old')
666 read (2) pb_ts(1)%sf(0:m,0:n,0:p,r, i); close (2)
667 else
668 call s_mpi_abort(trim(file_path) // ' is missing. Exiting.')
669 end if
670 end do
671 end do
672 do i = 1, nb
673 do r = 1, nnode
674 write (file_path, '(A,I0,A)') trim(t_step_dir) // '/mv', sys_size + (i - 1)*nnode + r, '.dat'
675 inquire (file=trim(file_path), exist=file_exist)
676 if (file_exist) then
677 open (2, file=trim(file_path), form='unformatted', action='read', status='old')
678 read (2) mv_ts(1)%sf(0:m,0:n,0:p,r, i); close (2)
679 else
680 call s_mpi_abort(trim(file_path) // ' is missing. Exiting.')
681 end if
682 end do
683 end do
684 end if
685 end if
686
687 end subroutine s_read_serial_data_files
688
689 !> Read parallel initial condition and grid data files via MPI I/O
690 impure subroutine s_read_parallel_data_files(q_cons_vf)
691
692 type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf
693
694#ifdef MFC_MPI
695 real(wp), allocatable, dimension(:) :: x_cb_glb, y_cb_glb, z_cb_glb
696 integer :: ifile, ierr, data_size
697 integer, dimension(MPI_STATUS_SIZE) :: status
698 integer(KIND=MPI_OFFSET_KIND) :: disp
699 integer(KIND=MPI_OFFSET_KIND) :: m_mok, n_mok, p_mok
700 integer(KIND=MPI_OFFSET_KIND) :: wp_mok, var_mok
701 integer(KIND=MPI_OFFSET_KIND) :: mok
702 character(LEN=path_len + 2*name_len) :: file_loc
703 logical :: file_exist
704 character(len=10) :: t_step_start_string
705 integer :: i, j
706 integer(KIND=MPI_OFFSET_KIND) :: nvars_mok !< variables read per cell
707
708 ! Downsampled data variables
709 integer :: m_ds, n_ds, p_ds
710 integer :: m_glb_ds, n_glb_ds, p_glb_ds
711 integer :: m_glb_read, n_glb_read, p_glb_read !< data size of read
712
713 allocate (x_cb_glb(-1:m_glb))
714 allocate (y_cb_glb(-1:n_glb))
715 allocate (z_cb_glb(-1:p_glb))
716
717 file_loc = trim(case_dir) // '/restart_data' // trim(mpiiofs) // 'x_cb.dat'
718 inquire (file=trim(file_loc), exist=file_exist)
719
720 if (down_sample) then
721 m_ds = int((m + 1)/3) - 1
722 n_ds = int((n + 1)/3) - 1
723 p_ds = int((p + 1)/3) - 1
724
725 m_glb_ds = int((m_glb + 1)/3) - 1
726 n_glb_ds = int((n_glb + 1)/3) - 1
727 p_glb_ds = int((p_glb + 1)/3) - 1
728 end if
729
730 if (file_exist) then
731 data_size = m_glb + 2
732 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
733 call s_check_mpi_file_open(ierr, file_loc)
734 call mpi_file_read(ifile, x_cb_glb, data_size, mpi_p, status, ierr)
735 call mpi_file_close(ifile, ierr)
736 else
737 call s_mpi_abort('File ' // trim(file_loc) // ' is missing. Exiting.')
738 end if
739
740 call s_apply_grid_from_global_dim(x_cb_glb, m_glb, m, start_idx(1), bc_x%beg, bc_x%end, buff_size, buff_size, buff_size, &
741 & buff_size, x_cb, x_cc, dx)
742
743 if (n > 0) then
744 file_loc = trim(case_dir) // '/restart_data' // trim(mpiiofs) // 'y_cb.dat'
745 inquire (file=trim(file_loc), exist=file_exist)
746
747 if (file_exist) then
748 data_size = n_glb + 2
749 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
750 call s_check_mpi_file_open(ierr, file_loc)
751 call mpi_file_read(ifile, y_cb_glb, data_size, mpi_p, status, ierr)
752 call mpi_file_close(ifile, ierr)
753 else
754 call s_mpi_abort('File ' // trim(file_loc) // ' is missing. Exiting.')
755 end if
756
757 call s_apply_grid_from_global_dim(y_cb_glb, n_glb, n, start_idx(2), bc_y%beg, bc_y%end, buff_size, buff_size, &
759
760 if (p > 0) then
761 file_loc = trim(case_dir) // '/restart_data' // trim(mpiiofs) // 'z_cb.dat'
762 inquire (file=trim(file_loc), exist=file_exist)
763
764 if (file_exist) then
765 data_size = p_glb + 2
766 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
767 call s_check_mpi_file_open(ierr, file_loc)
768 call mpi_file_read(ifile, z_cb_glb, data_size, mpi_p, status, ierr)
769 call mpi_file_close(ifile, ierr)
770 else
771 call s_mpi_abort('File ' // trim(file_loc) // 'is missing. Exiting.')
772 end if
773
774 call s_apply_grid_from_global_dim(z_cb_glb, p_glb, p, start_idx(3), bc_z%beg, bc_z%end, buff_size, buff_size, &
776 end if
777 end if
778
779 nvars_mok = int(sys_size, mpi_offset_kind)
780 if ((bubbles_euler .or. hypoelasticity) .and. qbmm .and. .not. polytropic) nvars_mok = nvars_mok + 2*nb*nnode
781
782 if (file_per_process) then
783 if (cfl_dt) then
784 call s_int_to_str(n_start, t_step_start_string)
785 write (file_loc, '(I0,A1,I7.7,A)') n_start, '_', proc_rank, '.dat'
786 else
787 call s_int_to_str(t_step_start, t_step_start_string)
788 write (file_loc, '(I0,A1,I7.7,A)') t_step_start, '_', proc_rank, '.dat'
789 end if
790 file_loc = trim(case_dir) // '/restart_data/lustre_' // trim(t_step_start_string) // trim(mpiiofs) // trim(file_loc)
791 inquire (file=trim(file_loc), exist=file_exist)
792
793 if (file_exist) then
794 call mpi_file_open(mpi_comm_self, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
795 call s_check_mpi_file_open(ierr, file_loc)
796
797 if (down_sample) then
798 call s_initialize_mpi_data_ds(m_ds, n_ds, p_ds)
799 else
800 if (ib) then
802 & qbmm_pb=pb_ts(1), qbmm_mv=mv_ts(1))
803 else
804 call s_initialize_mpi_data(q_cons_vf, qbmm_pb=pb_ts(1), qbmm_mv=mv_ts(1))
805 end if
806 end if
807
808 if (down_sample) then
809 data_size = (m_ds + 3)*(n_ds + 3)*(p_ds + 3)
810 m_glb_read = m_glb_ds + 1
811 n_glb_read = n_glb_ds + 1
812 p_glb_read = p_glb_ds + 1
813 else
814 data_size = (m + 1)*(n + 1)*(p + 1)
815 m_glb_read = m_glb + 1
816 n_glb_read = n_glb + 1
817 p_glb_read = p_glb + 1
818 end if
819 call s_check_restart_file_size(ifile, file_loc, int(data_size, mpi_offset_kind)*int(storage_size(0._stp)/8, &
820 & mpi_offset_kind)*nvars_mok)
821
822 m_mok = int(m_glb_read + 1, mpi_offset_kind)
823 n_mok = int(m_glb_read + 1, mpi_offset_kind)
824 p_mok = int(m_glb_read + 1, mpi_offset_kind)
825 wp_mok = int(storage_size(0._stp)/8, mpi_offset_kind)
826 mok = int(1._wp, mpi_offset_kind)
827
828 if (bubbles_euler .or. hypoelasticity) then
829 do i = 1, sys_size
830 var_mok = int(i, mpi_offset_kind)
831
832 call mpi_file_read(ifile, mpi_io_data%var(i)%sf(:,:,:), data_size*mpi_io_type, mpi_io_p, status, ierr)
833 end do
834 ! Read pb and mv for non-polytropic qbmm
835 if (qbmm .and. .not. polytropic) then
836 do i = sys_size + 1, sys_size + 2*nb*nnode
837 var_mok = int(i, mpi_offset_kind)
838
839 call mpi_file_read(ifile, mpi_io_data%var(i)%sf(:,:,:), data_size*mpi_io_type, mpi_io_p, status, ierr)
840 end do
841 end if
842 else
843 if (down_sample) then
844 do i = 1, sys_size
845 var_mok = int(i, mpi_offset_kind)
846
847 call mpi_file_read(ifile, q_cons_temp(i)%sf, data_size*mpi_io_type, mpi_io_p, status, ierr)
848 end do
849 else
850 do i = 1, sys_size
851 var_mok = int(i, mpi_offset_kind)
852
853 call mpi_file_read(ifile, mpi_io_data%var(i)%sf(:,:,:), data_size*mpi_io_type, mpi_io_p, status, ierr)
854 end do
855 end if
856 end if
857
858 call s_mpi_barrier()
859
860 call mpi_file_close(ifile, ierr)
861 else
862 call s_mpi_abort('File ' // trim(file_loc) // ' is missing. Exiting.')
863 end if
864 else
865 if (cfl_dt) then
866 write (file_loc, '(I0,A)') n_start, '.dat'
867 else
868 write (file_loc, '(I0,A)') t_step_start, '.dat'
869 end if
870 file_loc = trim(case_dir) // '/restart_data' // trim(mpiiofs) // trim(file_loc)
871 inquire (file=trim(file_loc), exist=file_exist)
872
873 if (file_exist) then
874 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
875 call s_check_mpi_file_open(ierr, file_loc)
876
877 if (ib) then
879 & qbmm_mv=mv_ts(1))
880 else
881 call s_initialize_mpi_data(q_cons_vf, qbmm_pb=pb_ts(1), qbmm_mv=mv_ts(1))
882 end if
883
884 data_size = (m + 1)*(n + 1)*(p + 1)
885
886 m_mok = int(m_glb + 1, mpi_offset_kind)
887 n_mok = int(n_glb + 1, mpi_offset_kind)
888 p_mok = int(p_glb + 1, mpi_offset_kind)
889 wp_mok = int(storage_size(0._stp)/8, mpi_offset_kind)
890 mok = int(1._wp, mpi_offset_kind)
891 call s_check_restart_file_size(ifile, file_loc, m_mok*max(mok, n_mok)*max(mok, p_mok)*wp_mok*nvars_mok)
892
893 if (bubbles_euler .or. hypoelasticity) then
894 do i = 1, sys_size
895 var_mok = int(i, mpi_offset_kind)
896 disp = m_mok*max(mok, n_mok)*max(mok, p_mok)*wp_mok*(var_mok - 1)
897
898 call mpi_file_set_view(ifile, disp, mpi_io_p, mpi_io_data%view(i), 'native', mpi_info_int, ierr)
899 call mpi_file_read(ifile, mpi_io_data%var(i)%sf(:,:,:), data_size*mpi_io_type, mpi_io_p, status, ierr)
900 end do
901 ! Read pb and mv for non-polytropic qbmm
902 if (qbmm .and. .not. polytropic) then
903 do i = sys_size + 1, sys_size + 2*nb*nnode
904 var_mok = int(i, mpi_offset_kind)
905 disp = m_mok*max(mok, n_mok)*max(mok, p_mok)*wp_mok*(var_mok - 1)
906
907 call mpi_file_set_view(ifile, disp, mpi_io_p, mpi_io_data%view(i), 'native', mpi_info_int, ierr)
908 call mpi_file_read(ifile, mpi_io_data%var(i)%sf(:,:,:), data_size*mpi_io_type, mpi_io_p, status, ierr)
909 end do
910 end if
911 else
912 do i = 1, sys_size
913 var_mok = int(i, mpi_offset_kind)
914
915 disp = m_mok*max(mok, n_mok)*max(mok, p_mok)*wp_mok*(var_mok - 1)
916
917 call mpi_file_set_view(ifile, disp, mpi_io_p, mpi_io_data%view(i), 'native', mpi_info_int, ierr)
918 call mpi_file_read_all(ifile, mpi_io_data%var(i)%sf(:,:,:), data_size*mpi_io_type, mpi_io_p, status, ierr)
919 end do
920 end if
921
922 call s_mpi_barrier()
923
924 call mpi_file_close(ifile, ierr)
925 else
926 call s_mpi_abort('File ' // trim(file_loc) // ' is missing. Exiting.')
927 end if
928 end if
929
930 deallocate (x_cb_glb, y_cb_glb, z_cb_glb)
931
932 if (bc_io) then
934 else
936 end if
937#endif
938
939 end subroutine s_read_parallel_data_files
940
941#ifdef MFC_MPI
942 !> Abort if an open restart file holds fewer bytes than are about to be read from it, as a job killed while writing it leaves.
943 !! MPI reads past the end return short without an error, so the missing tail would come back as garbage.
944 impure subroutine s_check_restart_file_size(ifile, file_loc, expected_bytes)
945
946 integer, intent(in) :: ifile
947 character(len=*), intent(in) :: file_loc
948 integer(KIND=MPI_OFFSET_KIND), intent(in) :: expected_bytes
949 integer(KIND=MPI_OFFSET_KIND) :: file_bytes
950 integer :: ierr
951 character(len=64) :: sizes
952
953 call mpi_file_get_size(ifile, file_bytes, ierr)
954 if (ierr /= mpi_success) call s_mpi_abort('MPI_FILE_GET_SIZE failed on ' // trim(file_loc) // '. Exiting.')
955 if (file_bytes < expected_bytes) then
956 write (sizes, '(I0," bytes but ",I0)') file_bytes, expected_bytes
957 call s_mpi_abort('Restart file ' // trim(file_loc) // ' holds ' // trim(sizes) // ' are expected. It is ' &
958 & // 'truncated, e.g. by a job killed while writing it; restart from an earlier step.')
959 end if
960
961 end subroutine s_check_restart_file_size
962#endif
963
964 !> Initialize internal-energy equations from phase mass, mixture momentum, and total energy
966
967 type(scalar_field), dimension(sys_size), intent(inout) :: v_vf
968 real(wp) :: rho
969 real(wp) :: dyn_pres
970 real(wp) :: gamma
971 real(wp) :: pi_inf
972 real(wp) :: qv
973 real(wp), dimension(2) :: re
974 real(wp) :: pres, t
975 real(wp) :: alpha_i, alpha_rho_i, e_i
976 integer :: i, j, k, l, c
977 real(wp), dimension(num_species) :: rhoyks
978 real(wp) :: pres_mag
979
980 pres_mag = 0._wp
981
982 t = dflt_t_guess
983
984 do j = 0, m
985 do k = 0, n
986 do l = 0, p
987 call s_convert_to_mixture_variables(v_vf, j, k, l, rho, gamma, pi_inf, qv, re)
988
989 dyn_pres = 0._wp
990 do i = eqn_idx%mom%beg, eqn_idx%mom%end
991 dyn_pres = dyn_pres + 5.e-1_wp*v_vf(i)%sf(j, k, l)*v_vf(i)%sf(j, k, l)/max(rho, sgm_eps)
992 end do
993
994 if (chemistry) then
995 do c = 1, num_species
996 rhoyks(c) = v_vf(eqn_idx%species%beg + c - 1)%sf(j, k, l)
997 end do
998 end if
999
1000 if (mhd) then
1001 if (n == 0) then
1002 pres_mag = 0.5_wp*(bx0**2 + v_vf(eqn_idx%B%beg)%sf(j, k, l)**2 + v_vf(eqn_idx%B%beg + 1)%sf(j, k, l)**2)
1003 else
1004 pres_mag = 0.5_wp*(v_vf(eqn_idx%B%beg)%sf(j, k, l)**2 + v_vf(eqn_idx%B%beg + 1)%sf(j, k, &
1005 & l)**2 + v_vf(eqn_idx%B%beg + 2)%sf(j, k, l)**2)
1006 end if
1007 end if
1008
1009 call s_compute_pressure(v_vf(eqn_idx%E)%sf(j, k, l), 0._stp, dyn_pres, pi_inf, gamma, rho, qv, rhoyks, pres, &
1010 & t, pres_mag=pres_mag)
1011
1012 do i = 1, num_fluids
1013 alpha_i = v_vf(i + eqn_idx%adv%beg - 1)%sf(j, k, l)
1014 alpha_rho_i = v_vf(i + eqn_idx%cont%beg - 1)%sf(j, k, l)
1015 call s_phase_internal_energy(pres, alpha_i, alpha_rho_i, i, e_i)
1016 v_vf(i + eqn_idx%int_en%beg - 1)%sf(j, k, l) = e_i
1017 end do
1018 end do
1019 end do
1020 end do
1021
1023
1024 !> Advance the simulation by one time step, handling CFL-based dt and time-stepper dispatch
1025 impure subroutine s_perform_time_step(t_step, time_avg)
1026
1027 integer, intent(inout) :: t_step
1028 real(wp), intent(inout) :: time_avg
1029 integer :: i, eta_hh, eta_mm, eta_ss
1030 real(wp) :: eta_sec
1031 real(wp) :: dt_floor
1032 character(len=8) :: lim_str !< Time-step limiter tag, e.g. ' (ICFL)'
1033
1034 call s_phase_step_tic()
1035 if (t_step == t_step_start) call s_amr_check_fixed_dt()
1036 if (cfl_dt) then
1037 if (cfl_const_dt .and. t_step == 0) call s_compute_dt()
1038
1039 if (cfl_adap_dt) call s_compute_dt()
1040
1041 if (t_step == 0) dt_init = dt
1042
1043 ! the collision restriction deliberately drops dt to collision_time/collision_temporal_resolution, so lower the
1044 ! runaway-dt abort threshold below that cap when it is enabled
1045 dt_floor = 1.e-3_wp*dt_init
1046 if (collision_model > 0 .and. collision_temporal_resolution > 0) then
1047 dt_floor = min(dt_floor, 1.e-3_wp*collision_time/real(collision_temporal_resolution, wp))
1048 end if
1049
1050 if (dt < dt_floor .and. cfl_adap_dt .and. proc_rank == 0) then
1051 print *, "Delta t = ", dt, " limited by ", dt_limiter
1052 call s_mpi_abort("Delta t has become too small")
1053 end if
1054 end if
1055
1056 ! Land exactly on t_stop. A fixed dt already lands on t_step_stop by step count; trimming it to t_step_stop*dt - mytime
1057 ! would only change the run's last dt by round-off, which a run continuing past that step does not see
1058 if (cfl_dt) then
1059 if ((mytime + dt) >= t_stop) then
1060 dt = t_stop - mytime
1061
1062# 651 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1063#if defined(MFC_OpenACC)
1064# 651 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1065!$acc update device(dt)
1066# 651 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1067#elif defined(MFC_OpenMP)
1068# 651 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1069!$omp target update to(dt)
1070# 651 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1071#endif
1072# 652 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1073 end if
1074 end if
1075
1076 if (cfl_dt) then
1077 if (proc_rank == 0 .and. mod(t_step - t_step_start, t_step_print) == 0) then
1078 eta_sec = wall_time_avg*(t_stop - mytime)/max(dt, tiny(dt))
1079 eta_hh = int(eta_sec)/3600
1080 eta_mm = mod(int(eta_sec), 3600)/60
1081 eta_ss = mod(int(eta_sec), 60)
1082 lim_str = ''
1083 if (cfl_adap_dt) lim_str = ' (' // dt_limiter // ')'
1084 print '(" [", I3, "%] t = ", ES11.4, " dt = ", ES11.4, A, " @ step ", I0, " t/step ", ES9.2, "s (avg ", ES9.2, "s) ETA ", I0, ":", I2.2, ":", I2.2)', &
1085 & int(ceiling(100._wp*(mytime/t_stop))), mytime, dt, trim(lim_str), t_step, wall_time, wall_time_avg, eta_hh, &
1086 & eta_mm, eta_ss
1087 end if
1088 else
1089 if (proc_rank == 0 .and. mod(t_step - t_step_start, t_step_print) == 0) then
1090 eta_sec = wall_time_avg*real(t_step_stop - t_step, wp)
1091 eta_hh = int(eta_sec)/3600
1092 eta_mm = mod(int(eta_sec), 3600)/60
1093 eta_ss = mod(int(eta_sec), 60)
1094 print '(" [", I3, "%] step ", I0, " of ", I0, " (t_step ", I0, ") t/step ", ES9.2, "s (avg ", ES9.2, "s) ETA ", I0, ":", I2.2, ":", I2.2)', &
1095 & int(ceiling(100._wp*(real(t_step - t_step_start)/(t_step_stop - t_step_start + 1)))), &
1096 & t_step - t_step_start + 1, t_step_stop - t_step_start + 1, t_step, wall_time, wall_time_avg, eta_hh, &
1097 & eta_mm, eta_ss
1098 end if
1099 end if
1100
1101 if (probe_wrt) then
1102 do i = 1, sys_size
1103
1104# 682 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1105#if defined(MFC_OpenACC)
1106# 682 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1107!$acc update host(q_cons_ts(1)%vf(i)%sf)
1108# 682 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1109#elif defined(MFC_OpenMP)
1110# 682 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1111!$omp target update from(q_cons_ts(1)%vf(i)%sf)
1112# 682 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1113#endif
1114# 683 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1115 end do
1116 if (bubbles_euler) then
1117
1118# 685 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1119#if defined(MFC_OpenACC)
1120# 685 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1121!$acc update host(ptil)
1122# 685 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1123#elif defined(MFC_OpenMP)
1124# 685 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1125!$omp target update from(ptil)
1126# 685 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1127#endif
1128# 686 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1129 end if
1130 end if
1131
1132 ! Total-variation-diminishing (TVD) Runge-Kutta (RK) time-steppers
1133 if (any(time_stepper == (/time_stepper_rk1, time_stepper_rk2, time_stepper_rk3/))) then
1134 call s_tvd_rk(t_step, time_avg, time_stepper)
1135 end if
1136
1137 ! Advance time after RK so source terms see current-step time. With a fixed dt, use the same t_step*dt a restart
1138 ! starts from (p_main): a running sum drifts from it (1290 ulps by step 27000), so a restarted run would see the
1139 ! prescribed IB kinematics, inflow ramps and forcing at slightly different times than the run it continues
1140 if (cfl_dt) then
1141 mytime = mytime + dt
1142 else
1143 mytime = (t_step + 1)*dt
1144 end if
1145
1146 if (relax) then
1148 if (amr) call s_amr_relax_fine(q_cons_ts(1)%vf)
1149 end if
1150
1151 ! Time-stepping loop controls
1152 t_step = t_step + 1
1153
1154 if (amr .and. amr_regrid_int > 0) then
1155 if (mod(t_step, amr_regrid_int) == 0) then
1157 call s_amr_regrid(q_cons_ts(1)%vf)
1160 end if
1161 end if
1162
1163 call s_phase_step_toc()
1164
1165 end subroutine s_perform_time_step
1166
1167 !> Collect per-process wall-clock times and write aggregate performance metrics to file
1168 impure subroutine s_save_performance_metrics(time_avg, time_final, io_time_avg, io_time_final, proc_time, io_proc_time, &
1169 & file_exists)
1170
1171 real(wp), intent(inout) :: time_avg, time_final
1172 real(wp), intent(inout) :: io_time_avg, io_time_final
1173 real(wp), dimension(:), intent(inout) :: proc_time
1174 real(wp), dimension(:), intent(inout) :: io_proc_time
1175 logical, intent(inout) :: file_exists
1176 real(wp) :: grind_time
1177
1178 call s_mpi_barrier()
1179
1180 if (num_procs > 1) then
1181 call mpi_bcast_time_step_values(proc_time, time_avg)
1182
1183 call mpi_bcast_time_step_values(io_proc_time, io_time_avg)
1184 end if
1185
1186 if (proc_rank == 0) then
1187 time_final = 0._wp
1188 io_time_final = 0._wp
1189 if (num_procs == 1) then
1190 time_final = time_avg
1191 io_time_final = io_time_avg
1192 else
1193 time_final = maxval(proc_time)
1194 io_time_final = maxval(io_proc_time)
1195 end if
1196
1197 grind_time = time_final*1.0e9_wp/(real(sys_size, wp)*real(maxval((/1, m_glb/)), wp)*real(maxval((/1, n_glb/)), &
1198 & wp)*real(maxval((/1, p_glb/)), wp))
1199
1200 print *, "Performance:", grind_time, "ns/gp/eq/rhs"
1201 inquire (file='time_data.dat', exist=file_exists)
1202 if (file_exists) then
1203 open (1, file='time_data.dat', position='append', status='old')
1204 else
1205 open (1, file='time_data.dat', status='new')
1206 ! time_final is the fastest single RK stage (one RHS evaluation), not a whole step; see s_tvd_rk
1207 write (1, '(A10, A15, A15)') "Ranks", "s/rhs", "ns/gp/eq/rhs"
1208 end if
1209
1210 write (1, '(I10, 2(F15.8))') num_procs, time_final, grind_time
1211
1212 close (1)
1213
1214 inquire (file='io_time_data.dat', exist=file_exists)
1215 if (file_exists) then
1216 open (1, file='io_time_data.dat', position='append', status='old')
1217 else
1218 open (1, file='io_time_data.dat', status='new')
1219 ! io_time_final is the mean time of one s_save_data call
1220 write (1, '(A10, A15)') "Ranks", "s/save"
1221 end if
1222
1223 write (1, '(I10, F15.8)') num_procs, io_time_final
1224 close (1)
1225 end if
1226
1227 end subroutine s_save_performance_metrics
1228
1229 !> Save conservative variable data to disk at the current time step
1230 impure subroutine s_save_data(t_step, start, finish, io_time_avg, nt)
1231
1232 integer, intent(inout) :: t_step
1233 real(wp), intent(inout) :: start, finish, io_time_avg
1234 integer, intent(inout) :: nt
1235 integer(kind=8) :: i, j, k, l
1236 integer :: stor
1237 integer :: save_count
1238
1239 if (down_sample) then
1241 end if
1242
1243 stor = 1
1244
1245 if (time_stepper /= time_stepper_rk1) then
1246
1247# 803 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1248
1249# 803 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1250#if defined(MFC_OpenACC)
1251# 803 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1252!$acc parallel loop collapse(4) gang vector default(present) copyin(idwbuff)
1253# 803 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1254#elif defined(MFC_OpenMP)
1255# 803 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1256
1257# 803 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1258
1259# 803 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1260
1261# 803 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1262!$omp target teams loop defaultmap(firstprivate:scalar) bind(teams,parallel) collapse(4) defaultmap(tofrom:aggregate) defaultmap(tofrom:allocatable) defaultmap(tofrom:pointer) map(to:idwbuff)
1263# 803 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1264#endif
1265# 804 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1266 do i = 1, sys_size
1267 do l = idwbuff(3)%beg, idwbuff(3)%end
1268 do k = idwbuff(2)%beg, idwbuff(2)%end
1269 do j = idwbuff(1)%beg, idwbuff(1)%end
1270 q_cons_ts(2)%vf(i)%sf(j, k, l) = q_cons_ts(1)%vf(i)%sf(j, k, l)
1271 end do
1272 end do
1273 end do
1274 end do
1275
1276# 813 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1277#if defined(MFC_OpenACC)
1278# 813 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1279!$acc end parallel loop
1280# 813 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1281#elif defined(MFC_OpenMP)
1282# 813 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1283
1284# 813 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1285!$omp end target teams loop
1286# 813 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1287#endif
1288# 814 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1289 stor = 2
1290 end if
1291
1292 call cpu_time(start)
1293 call nvtxstartrange("SAVE-DATA")
1294 do i = 1, sys_size
1295#ifndef FRONTIER_UNIFIED
1296
1297# 821 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1298#if defined(MFC_OpenACC)
1299# 821 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1300!$acc update host(q_cons_ts(stor)%vf(i)%sf)
1301# 821 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1302#elif defined(MFC_OpenMP)
1303# 821 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1304!$omp target update from(q_cons_ts(stor)%vf(i)%sf)
1305# 821 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1306#endif
1307# 822 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1308#endif
1309 do l = 0, p
1310 do k = 0, n
1311 do j = 0, m
1312 if (ieee_is_nan(real(q_cons_ts(stor)%vf(i)%sf(j, k, l), kind=wp))) then
1313 print *, "NaN(s) in timestep output.", j, k, l, i, proc_rank, t_step, m, n, p
1314 call s_mpi_abort("NaN(s) in timestep output.")
1315 end if
1316 end do
1317 end do
1318 end do
1319 end do
1320
1321 if (qbmm .and. .not. polytropic) then
1322
1323# 836 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1324#if defined(MFC_OpenACC)
1325# 836 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1326!$acc update host(pb_ts(1)%sf)
1327# 836 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1328#elif defined(MFC_OpenMP)
1329# 836 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1330!$omp target update from(pb_ts(1)%sf)
1331# 836 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1332#endif
1333# 837 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1334
1335# 837 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1336#if defined(MFC_OpenACC)
1337# 837 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1338!$acc update host(mv_ts(1)%sf)
1339# 837 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1340#elif defined(MFC_OpenMP)
1341# 837 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1342!$omp target update from(mv_ts(1)%sf)
1343# 837 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1344#endif
1345# 838 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1346 end if
1347
1348 if (cfl_dt) then
1349 save_count = int(mytime/t_save)
1350 else
1351 save_count = t_step
1352 end if
1353
1354 if (bubbles_lagrange) then
1356 call s_write_data_files(q_cons_ts(stor)%vf, q_t_sf, q_prim_vf, save_count, bc_type, q_beta(bub_q_idx%alphaf))
1357 call s_write_lag_save_data(save_count)
1358 else if (particles_lagrange) then
1361 call s_write_lag_save_data(save_count)
1362 else
1363 call s_write_data_files(q_cons_ts(stor)%vf, q_t_sf, q_prim_vf, save_count, bc_type)
1364 end if
1365
1366 ! Write IB kinematic state for restart
1367 if (ib) call s_write_ib_state_file(save_count)
1368 if (ib .and. ib_surface_wrt) call s_write_ib_surface(save_count)
1369 ! Fine-level AMR restart file (current box + intersection-local fine state) alongside the level-0 restart
1370 if (amr) call s_write_amr_restart(save_count)
1371
1372 call nvtxendrange
1373 call cpu_time(finish)
1374 if (cfl_dt) then
1375 nt = mytime/t_save
1376 else
1377 nt = int((t_step - t_step_start)/(t_step_save))
1378 end if
1379
1380 if (nt <= 1) then ! nt = 0 for the initial save of Lagrangian particle runs
1381 io_time_avg = abs(finish - start)
1382 else
1383 io_time_avg = (abs(finish - start) + io_time_avg*(nt - 1))/nt
1384 end if
1385
1386 end subroutine s_save_data
1387
1388 !> Initialize all simulation sub-modules in the required dependency order
1389 impure subroutine s_initialize_modules
1390
1391 integer :: m_ds, n_ds, p_ds
1392 integer :: i
1393 integer :: save_count, n_lag_loc
1394 real(wp) :: qtime
1395 real(wp), allocatable, dimension(:,:) :: lag_rows !< Lagrangian input-file or restart rows
1396 integer, allocatable, dimension(:) :: lag_ids !< Their global IDs on a fresh start
1397 logical :: amr_restored
1398
1400 ! Start time; a CFL-mode restart replaces the nominal t_save*n_start with the saved time (s_read_ib_restart_data)
1401 if (cfl_dt) then
1402 mytime = t_save*n_start
1403 else
1404 mytime = t_step_start*dt
1405 end if
1406# 908 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1407 if (bubbles_euler .or. bubbles_lagrange) then
1409 end if
1410 ! AMR needs the temperature ghost as the cons->prim Newton guess when a fine block's conversion widens over the ghost shell
1411 call s_initialize_mpi_common_module(exchange_all_chemistry_temperatures_in=amr, use_rdma_transport_in=rdma_mpi, &
1412 & num_beta_vars_in=max(merge(bub_q_idx%num, 0, bubbles_lagrange), &
1413 & merge(part_q_idx%num, 0, particles_lagrange)))
1416 call s_initialize_variables_conversion_module(enforce_density_floor=.true., preserve_qbmm_number=.true.)
1417 if (grid_geometry == 3) call s_initialize_fftw_module()
1418
1419 if (bubbles_euler) call s_initialize_bubbles_ee_module()
1420 if (ib) then
1422 end if
1423 if (qbmm) call s_initialize_qbmm_module()
1424
1425 if (acoustic_source) then
1427 end if
1428
1429 if (viscous .and. (.not. igr)) then
1431 end if
1432
1434
1435 if (surface_tension) call s_initialize_surface_tension_module()
1436
1437 if (relax) call s_initialize_phasechange_module()
1438
1442
1443 call s_initialize_boundary_common_module(use_dirichlet_buffers=.true.)
1444
1445 if (down_sample) then
1446 m_ds = int((m + 1)/3) - 1
1447 n_ds = int((n + 1)/3) - 1
1448 p_ds = int((p + 1)/3) - 1
1449
1450 allocate (q_cons_temp(1:sys_size))
1451 do i = 1, sys_size
1452 allocate (q_cons_temp(i)%sf(-1:m_ds + 1,-1:n_ds + 1,-1:p_ds + 1))
1453 end do
1454 end if
1455
1456 if (down_sample) then
1459 do i = 1, sys_size
1460
1461# 961 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1462#if defined(MFC_OpenACC)
1463# 961 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1464!$acc update device(q_cons_ts(1)%vf(i)%sf)
1465# 961 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1466#elif defined(MFC_OpenMP)
1467# 961 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1468!$omp target update to(q_cons_ts(1)%vf(i)%sf)
1469# 961 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1470#endif
1471# 962 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1472 end do
1473 do i = 1, sys_size
1474 deallocate (q_cons_temp(i)%sf)
1475 end do
1476 deallocate (q_cons_temp)
1477 else
1478 call s_read_data_files(q_cons_ts(1)%vf)
1479 end if
1480
1481 block
1482 type(int_bounds_info), dimension(3) :: grid_offsets
1483
1484 grid_offsets(:)%beg = buff_size
1485 grid_offsets(:)%end = buff_size
1486 if (n == 0) then
1487 call s_populate_grid_variables_buffers(x_cb, x_cc, dx, grid_offsets(1), grid_offsets(2), grid_offsets(3), &
1488 & global_bounds=glb_bounds)
1489 else if (p == 0) then
1490 call s_populate_grid_variables_buffers(x_cb, x_cc, dx, grid_offsets(1), grid_offsets(2), grid_offsets(3), y_cb, &
1491 & y_cc, dy, global_bounds=glb_bounds)
1492 else
1493 call s_populate_grid_variables_buffers(x_cb, x_cc, dx, grid_offsets(1), grid_offsets(2), grid_offsets(3), y_cb, &
1494 & y_cc, dy, z_cb, z_cc, dz, glb_bounds)
1495 end if
1496 end block
1497
1498# 987 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1499#if defined(MFC_OpenACC)
1500# 987 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1501!$acc update device(glb_bounds)
1502# 987 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1503#elif defined(MFC_OpenMP)
1504# 987 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1505!$omp target update to(glb_bounds)
1506# 987 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1507#endif
1508# 988 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1509 ! the grid arrays are allocated to the _alloc extents (a pinned block cap can exceed the subdomain) but filled only over
1510 ! the buffered range: take the minima there
1511 dx_min = minval(dx(-buff_size:m + buff_size))
1512 if (n > 0) dy_min = minval(dy(-buff_size:n + buff_size))
1513 if (p > 0) dz_min = minval(dz(-buff_size:p + buff_size))
1514
1516 call s_initialize_amr_registers(amr_maxc_fit)
1517 ! restarts restore the saved fine state; otherwise prolong from coarse
1518 call s_read_amr_restart(amr_restored)
1519 if (.not. amr_restored) call s_populate_amr_fine(q_cons_ts(1)%vf)
1520
1522 if (ib) then
1526 if (cfl_dt .and. n_start > 0) then
1527 call s_read_ib_restart_data(n_start)
1528 else if (t_step_start > 0) then
1529 call s_read_ib_restart_data(t_step_start)
1530 else
1532 end if
1534 call s_ibm_setup()
1535 ! resolve the body on each fine block from the geometry
1536 if (amr) call s_amr_setup_ib()
1537 ! a CFL-mode run keeps t_step_start = 0, so only n_start tells a restart apart
1538 if (merge(n_start, t_step_start, cfl_dt) == 0) call s_write_ib_data_file(0)
1539 end if
1540 if (bodyforces .or. synthetic_turbulence) call s_initialize_body_forces_module()
1541 if (acoustic_source) call s_precalculate_acoustic_spatial_sources()
1542
1543 ! Initialize the Temperature cache.
1544 if (chemistry) call s_compute_q_t_sf(q_t_sf, q_cons_ts(1)%vf, idwint)
1545
1546 ! Computation of parameters, allocation of memory, association of pointers, and/or execution of any other tasks that are
1547 ! needed to properly configure the modules. The preparations below DO DEPEND on the grid being complete.
1548 if (igr) then
1550 end if
1551 if (.not. igr) then
1552 if (recon_type == recon_type_weno) then
1554 else if (recon_type == recon_type_muscl) then
1556 end if
1559 end if
1560 if (int_comp > 0) call s_initialize_thinc_module()
1562 if (bubbles_lagrange .or. particles_lagrange) then
1563 ! qtime is taken before a restart read resets dt
1564 call s_get_lag_restart_point(save_count, qtime)
1565 call s_read_lag_entities(save_count, lag_rows, lag_ids, n_lag_loc)
1566 if (bubbles_lagrange) call s_initialize_bubbles_el_module(q_cons_ts(1)%vf, bc_type, lag_rows, lag_ids, n_lag_loc)
1567 if (particles_lagrange) call s_initialize_particles_el_module(bc_type, lag_rows, lag_ids, n_lag_loc)
1568 call s_initialize_lag_output(save_count, qtime)
1569 end if
1570
1571 if (hypoelasticity) call s_initialize_hypoelastic_module()
1572
1573 end subroutine s_initialize_modules
1574
1575 !> Set up the MPI execution environment, bind GPUs, and decompose the computational domain
1576 impure subroutine s_initialize_mpi_domain
1577
1578 integer :: ierr
1579
1580#ifdef MFC_GPU
1581 real(wp) :: starttime, endtime
1582 integer :: num_devices, local_size, num_nodes, ppn, my_device_num
1583 integer :: dev, devnum, local_rank
1584#ifdef MFC_MPI
1585 integer :: local_comm
1586#endif
1587#if defined(MFC_OpenACC)
1588 integer(acc_device_kind) :: devtype
1589#endif
1590#endif
1591
1592 call s_mpi_initialize()
1593
1594#ifdef MFC_GPU
1595#ifndef MFC_MPI
1596 local_size = 1
1597 local_rank = 0
1598#else
1599 call mpi_comm_split_type(mpi_comm_world, mpi_comm_type_shared, 0, mpi_info_null, local_comm, ierr)
1600 call mpi_comm_size(local_comm, local_size, ierr)
1601 call mpi_comm_rank(local_comm, local_rank, ierr)
1602#endif
1603#if defined(MFC_OpenACC)
1604 devtype = acc_get_device_type()
1605 devnum = acc_get_num_devices(devtype)
1606 dev = mod(local_rank, devnum)
1607
1608 call acc_set_device_num(dev, devtype)
1609#elif defined(MFC_OpenMP)
1610 devnum = omp_get_num_devices()
1611 dev = mod(local_rank, devnum)
1612 call omp_set_default_device(dev)
1613#endif
1614#endif
1615
1616 if (proc_rank == 0) then
1617 call s_assign_default_values_to_user_inputs()
1618 call s_read_input_file()
1619 call s_check_input_file()
1620
1621 print '(" Simulating a ", A, " ", I0, "x", I0, "x", I0, " case on ", I0, " rank(s) ", A, ".")', &
1622# 1102 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1623 "regular", &
1624# 1106 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1625 m, n, p, num_procs, &
1626#if defined(MFC_OpenACC)
1627 "with OpenACC offloading"
1628#elif defined(MFC_OpenMP)
1629 "with OpenMP offloading"
1630#else
1631 "on CPUs"
1632#endif
1633 end if
1634
1635 call s_mpi_bcast_user_inputs()
1636
1637 ! Save original BCs before decomposition overwrites them with MPI neighbor ranks
1638 ib_bc_x = bc_x
1639 ib_bc_y = bc_y
1640 ib_bc_z = bc_z
1641
1642 call s_initialize_parallel_io()
1643
1644 call s_mpi_decompose_computational_domain(write_silo_ghost_offsets=.false., adjust_local_domains=.false.)
1645
1646 bc = bc_xyz_info(bc_x, bc_y, bc_z)
1647
1648 end subroutine s_initialize_mpi_domain
1649
1650 !> Transfer initial conservative variable and model parameter data to the GPU device
1652
1653 integer :: i
1654
1655 if (.not. down_sample) then
1656 do i = 1, sys_size
1657
1658# 1138 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1659#if defined(MFC_OpenACC)
1660# 1138 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1661!$acc update device(q_cons_ts(1)%vf(i)%sf)
1662# 1138 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1663#elif defined(MFC_OpenMP)
1664# 1138 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1665!$omp target update to(q_cons_ts(1)%vf(i)%sf)
1666# 1138 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1667#endif
1668# 1139 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1669 end do
1670 end if
1671
1672 if (qbmm .and. .not. polytropic) then
1673
1674# 1143 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1675#if defined(MFC_OpenACC)
1676# 1143 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1677!$acc update device(pb_ts(1)%sf, mv_ts(1)%sf)
1678# 1143 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1679#elif defined(MFC_OpenMP)
1680# 1143 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1681!$omp target update to(pb_ts(1)%sf, mv_ts(1)%sf)
1682# 1143 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1683#endif
1684# 1144 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1685 end if
1686 if (chemistry) then
1687
1688# 1146 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1689#if defined(MFC_OpenACC)
1690# 1146 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1691!$acc update device(q_T_sf%sf)
1692# 1146 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1693#elif defined(MFC_OpenMP)
1694# 1146 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1695!$omp target update to(q_T_sf%sf)
1696# 1146 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1697#endif
1698# 1147 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1699 end if
1700
1701
1702# 1149 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1703#if defined(MFC_OpenACC)
1704# 1149 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1705!$acc update device(chem_params)
1706# 1149 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1707#elif defined(MFC_OpenMP)
1708# 1149 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1709!$omp target update to(chem_params)
1710# 1149 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1711#endif
1712# 1150 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1713
1714
1715# 1151 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1716#if defined(MFC_OpenACC)
1717# 1151 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1718!$acc update device(rburn)
1719# 1151 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1720#elif defined(MFC_OpenMP)
1721# 1151 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1722!$omp target update to(rburn)
1723# 1151 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1724#endif
1725# 1152 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1726
1727
1728# 1153 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1729#if defined(MFC_OpenACC)
1730# 1153 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1731!$acc update device(R0ref, p0ref, rho0ref, ss, pv, vd, mu_l, mu_v, mu_g, gam_v, gam_g, M_v, M_g, R_v, R_g, Tw, cp_v, cp_g, k_vl, k_gl, gam, gam_m, Eu, Ca, Web, Re_inv, Pe_c, phi_vg, phi_gv, omegaN, bubbles_euler, polytropic, polydisperse, qbmm, ptil, bubble_model, thermal, poly_sigma, adv_n, adap_dt, adap_dt_tol, adap_dt_max_iters, eqn_idx%n, pi_fac, low_Mach)
1732# 1153 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1733#elif defined(MFC_OpenMP)
1734# 1153 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1735!$omp target update to(R0ref, p0ref, rho0ref, ss, pv, vd, mu_l, mu_v, mu_g, gam_v, gam_g, M_v, M_g, R_v, R_g, Tw, cp_v, cp_g, k_vl, k_gl, gam, gam_m, Eu, Ca, Web, Re_inv, Pe_c, phi_vg, phi_gv, omegaN, bubbles_euler, polytropic, polydisperse, qbmm, ptil, bubble_model, thermal, poly_sigma, adv_n, adap_dt, adap_dt_tol, adap_dt_max_iters, eqn_idx%n, pi_fac, low_Mach)
1736# 1153 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1737#endif
1738# 1157 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1739
1740 if (bubbles_euler) then
1741
1742# 1159 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1743#if defined(MFC_OpenACC)
1744# 1159 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1745!$acc update device(weight, R0)
1746# 1159 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1747#elif defined(MFC_OpenMP)
1748# 1159 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1749!$omp target update to(weight, R0)
1750# 1159 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1751#endif
1752# 1160 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1753 if (.not. polytropic) then
1754
1755# 1161 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1756#if defined(MFC_OpenACC)
1757# 1161 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1758!$acc update device(pb0, Pe_T, k_g, k_v, mass_g0, mass_v0, Re_trans_T, Re_trans_c, Im_trans_T, Im_trans_c)
1759# 1161 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1760#elif defined(MFC_OpenMP)
1761# 1161 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1762!$omp target update to(pb0, Pe_T, k_g, k_v, mass_g0, mass_v0, Re_trans_T, Re_trans_c, Im_trans_T, Im_trans_c)
1763# 1161 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1764#endif
1765# 1162 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1766 else if (qbmm) then
1767
1768# 1163 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1769#if defined(MFC_OpenACC)
1770# 1163 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1771!$acc update device(pb0)
1772# 1163 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1773#elif defined(MFC_OpenMP)
1774# 1163 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1775!$omp target update to(pb0)
1776# 1163 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1777#endif
1778# 1164 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1779 end if
1780 end if
1781
1782
1783# 1167 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1784#if defined(MFC_OpenACC)
1785# 1167 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1786!$acc update device(adv_n, adap_dt, adap_dt_tol, adap_dt_max_iters, pi_fac, low_Mach, ib_flux_wall)
1787# 1167 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1788#elif defined(MFC_OpenMP)
1789# 1167 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1790!$omp target update to(adv_n, adap_dt, adap_dt_tol, adap_dt_max_iters, pi_fac, low_Mach, ib_flux_wall)
1791# 1167 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1792#endif
1793# 1168 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1794
1795
1796# 1169 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1797#if defined(MFC_OpenACC)
1798# 1169 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1799!$acc update device(acoustic_source, num_source)
1800# 1169 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1801#elif defined(MFC_OpenMP)
1802# 1169 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1803!$omp target update to(acoustic_source, num_source)
1804# 1169 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1805#endif
1806# 1170 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1807
1808# 1170 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1809#if defined(MFC_OpenACC)
1810# 1170 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1811!$acc update device(sigma, surface_tension)
1812# 1170 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1813#elif defined(MFC_OpenMP)
1814# 1170 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1815!$omp target update to(sigma, surface_tension)
1816# 1170 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1817#endif
1818# 1171 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1819
1820
1821# 1172 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1822#if defined(MFC_OpenACC)
1823# 1172 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1824!$acc update device(dx, dy, dz, x_cb, x_cc, y_cb, y_cc, z_cb, z_cc)
1825# 1172 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1826#elif defined(MFC_OpenMP)
1827# 1172 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1828!$omp target update to(dx, dy, dz, x_cb, x_cc, y_cb, y_cc, z_cb, z_cc)
1829# 1172 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1830#endif
1831# 1173 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1832
1833# 1173 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1834#if defined(MFC_OpenACC)
1835# 1173 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1836!$acc update device(bc_x%beg, bc_x%end, bc_y%beg, bc_y%end, bc_z%beg, bc_z%end)
1837# 1173 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1838#elif defined(MFC_OpenMP)
1839# 1173 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1840!$omp target update to(bc_x%beg, bc_x%end, bc_y%beg, bc_y%end, bc_z%beg, bc_z%end)
1841# 1173 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1842#endif
1843# 1174 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1844
1845# 1174 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1846#if defined(MFC_OpenACC)
1847# 1174 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1848!$acc update device(bc_x%vb1, bc_x%vb2, bc_x%vb3, bc_x%ve1, bc_x%ve2, bc_x%ve3)
1849# 1174 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1850#elif defined(MFC_OpenMP)
1851# 1174 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1852!$omp target update to(bc_x%vb1, bc_x%vb2, bc_x%vb3, bc_x%ve1, bc_x%ve2, bc_x%ve3)
1853# 1174 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1854#endif
1855# 1175 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1856
1857# 1175 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1858#if defined(MFC_OpenACC)
1859# 1175 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1860!$acc update device(bc_y%vb1, bc_y%vb2, bc_y%vb3, bc_y%ve1, bc_y%ve2, bc_y%ve3)
1861# 1175 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1862#elif defined(MFC_OpenMP)
1863# 1175 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1864!$omp target update to(bc_y%vb1, bc_y%vb2, bc_y%vb3, bc_y%ve1, bc_y%ve2, bc_y%ve3)
1865# 1175 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1866#endif
1867# 1176 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1868
1869# 1176 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1870#if defined(MFC_OpenACC)
1871# 1176 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1872!$acc update device(bc_z%vb1, bc_z%vb2, bc_z%vb3, bc_z%ve1, bc_z%ve2, bc_z%ve3)
1873# 1176 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1874#elif defined(MFC_OpenMP)
1875# 1176 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1876!$omp target update to(bc_z%vb1, bc_z%vb2, bc_z%vb3, bc_z%ve1, bc_z%ve2, bc_z%ve3)
1877# 1176 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1878#endif
1879# 1177 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1880
1881
1882# 1178 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1883#if defined(MFC_OpenACC)
1884# 1178 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1885!$acc update device(bc_x%grcbc_in, bc_x%grcbc_out, bc_x%grcbc_vel_out)
1886# 1178 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1887#elif defined(MFC_OpenMP)
1888# 1178 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1889!$omp target update to(bc_x%grcbc_in, bc_x%grcbc_out, bc_x%grcbc_vel_out)
1890# 1178 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1891#endif
1892# 1179 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1893
1894# 1179 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1895#if defined(MFC_OpenACC)
1896# 1179 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1897!$acc update device(bc_y%grcbc_in, bc_y%grcbc_out, bc_y%grcbc_vel_out)
1898# 1179 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1899#elif defined(MFC_OpenMP)
1900# 1179 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1901!$omp target update to(bc_y%grcbc_in, bc_y%grcbc_out, bc_y%grcbc_vel_out)
1902# 1179 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1903#endif
1904# 1180 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1905
1906# 1180 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1907#if defined(MFC_OpenACC)
1908# 1180 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1909!$acc update device(bc_z%grcbc_in, bc_z%grcbc_out, bc_z%grcbc_vel_out)
1910# 1180 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1911#elif defined(MFC_OpenMP)
1912# 1180 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1913!$omp target update to(bc_z%grcbc_in, bc_z%grcbc_out, bc_z%grcbc_vel_out)
1914# 1180 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1915#endif
1916# 1181 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1917
1918
1919# 1182 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1920#if defined(MFC_OpenACC)
1921# 1182 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1922!$acc update device(bc_x%vel_in_ramp, bc_x%vel_in_t0, bc_x%vel_in_frac0)
1923# 1182 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1924#elif defined(MFC_OpenMP)
1925# 1182 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1926!$omp target update to(bc_x%vel_in_ramp, bc_x%vel_in_t0, bc_x%vel_in_frac0)
1927# 1182 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1928#endif
1929# 1183 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1930
1931# 1183 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1932#if defined(MFC_OpenACC)
1933# 1183 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1934!$acc update device(bc_y%vel_in_ramp, bc_y%vel_in_t0, bc_y%vel_in_frac0)
1935# 1183 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1936#elif defined(MFC_OpenMP)
1937# 1183 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1938!$omp target update to(bc_y%vel_in_ramp, bc_y%vel_in_t0, bc_y%vel_in_frac0)
1939# 1183 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1940#endif
1941# 1184 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1942
1943# 1184 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1944#if defined(MFC_OpenACC)
1945# 1184 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1946!$acc update device(bc_z%vel_in_ramp, bc_z%vel_in_t0, bc_z%vel_in_frac0)
1947# 1184 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1948#elif defined(MFC_OpenMP)
1949# 1184 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1950!$omp target update to(bc_z%vel_in_ramp, bc_z%vel_in_t0, bc_z%vel_in_frac0)
1951# 1184 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1952#endif
1953# 1185 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1954
1955
1956# 1186 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1957#if defined(MFC_OpenACC)
1958# 1186 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1959!$acc update device(bc_x%isothermal_in, bc_x%isothermal_out)
1960# 1186 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1961#elif defined(MFC_OpenMP)
1962# 1186 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1963!$omp target update to(bc_x%isothermal_in, bc_x%isothermal_out)
1964# 1186 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1965#endif
1966# 1187 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1967
1968# 1187 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1969#if defined(MFC_OpenACC)
1970# 1187 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1971!$acc update device(bc_y%isothermal_in, bc_y%isothermal_out)
1972# 1187 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1973#elif defined(MFC_OpenMP)
1974# 1187 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1975!$omp target update to(bc_y%isothermal_in, bc_y%isothermal_out)
1976# 1187 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1977#endif
1978# 1188 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1979
1980# 1188 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1981#if defined(MFC_OpenACC)
1982# 1188 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1983!$acc update device(bc_z%isothermal_in, bc_z%isothermal_out)
1984# 1188 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1985#elif defined(MFC_OpenMP)
1986# 1188 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1987!$omp target update to(bc_z%isothermal_in, bc_z%isothermal_out)
1988# 1188 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1989#endif
1990# 1189 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1991
1992# 1189 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1993#if defined(MFC_OpenACC)
1994# 1189 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1995!$acc update device(bc_x%Twall_in, bc_x%Twall_out, bc_y%Twall_in, bc_y%Twall_out, bc_z%Twall_in, bc_z%Twall_out)
1996# 1189 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1997#elif defined(MFC_OpenMP)
1998# 1189 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
1999!$omp target update to(bc_x%Twall_in, bc_x%Twall_out, bc_y%Twall_in, bc_y%Twall_out, bc_z%Twall_in, bc_z%Twall_out)
2000# 1189 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2001#endif
2002# 1190 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2003
2004
2005# 1191 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2006#if defined(MFC_OpenACC)
2007# 1191 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2008!$acc update device(bc)
2009# 1191 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2010#elif defined(MFC_OpenMP)
2011# 1191 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2012!$omp target update to(bc)
2013# 1191 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2014#endif
2015# 1192 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2016
2017
2018# 1193 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2019#if defined(MFC_OpenACC)
2020# 1193 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2021!$acc update device(relax, relax_model)
2022# 1193 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2023#elif defined(MFC_OpenMP)
2024# 1193 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2025!$omp target update to(relax, relax_model)
2026# 1193 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2027#endif
2028# 1194 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2029 if (relax) then
2030
2031# 1195 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2032#if defined(MFC_OpenACC)
2033# 1195 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2034!$acc update device(palpha_eps, ptgalpha_eps)
2035# 1195 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2036#elif defined(MFC_OpenMP)
2037# 1195 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2038!$omp target update to(palpha_eps, ptgalpha_eps)
2039# 1195 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2040#endif
2041# 1196 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2042 end if
2043
2044 if (ib) then
2045
2046# 1199 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2047#if defined(MFC_OpenACC)
2048# 1199 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2049!$acc update device(ib_markers%sf)
2050# 1199 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2051#elif defined(MFC_OpenMP)
2052# 1199 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2053!$omp target update to(ib_markers%sf)
2054# 1199 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2055#endif
2056# 1200 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2057 end if
2058# 1202 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2059
2060# 1202 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2061#if defined(MFC_OpenACC)
2062# 1202 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2063!$acc update device(igr, nb, igr_order)
2064# 1202 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2065#elif defined(MFC_OpenMP)
2066# 1202 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2067!$omp target update to(igr, nb, igr_order)
2068# 1202 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2069#endif
2070# 1203 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2071# 1204 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2072
2073 end subroutine s_initialize_gpu_vars
2074
2075 !> Read the Lagrangian bubbles or particles this rank starts with: the input-file rows (and their global IDs) on a fresh start,
2076 !! otherwise the restart-file rows, which also reset mytime and dt.
2077 impure subroutine s_read_lag_entities(save_count, rows, ids, n_loc)
2078
2079 integer, intent(in) :: save_count
2080 real(wp), allocatable, dimension(:,:), intent(out) :: rows
2081 integer, allocatable, dimension(:), intent(out) :: ids
2082 integer, intent(out) :: n_loc
2083 character(LEN=pathlen_max) :: path
2084 character(len=9) :: lag_kind
2085 integer :: ncols, n_glb, n_read
2086
2087 if (bubbles_lagrange) then
2088 lag_kind = 'bubbles'; path = lag_params%input_path; ncols = 8; n_glb = lag_params%nBubs_glb
2089 else
2090 lag_kind = 'particles'; path = particle_params%input_path; ncols = 7; n_glb = particle_params%nParticles_glb
2091 end if
2092
2093 n_read = 0
2094 if (save_count == 0) then
2095 if (proc_rank == 0) print *, 'Reading lagrange ' // trim(lag_kind) // ' input file.'
2096 call s_read_lag_input(path, ncols, n_glb, rows, ids, n_loc, n_read)
2097 else
2098 if (proc_rank == 0) print *, 'Restarting lagrange ' // trim(lag_kind) // ' at save_count: ', save_count
2099 call s_read_lag_restart(trim(lag_kind), save_count, rows, n_loc)
2100 if (.not. allocated(rows)) allocate (rows(1, lag_io_vars))
2101 allocate (ids(0))
2102 end if
2103
2104 if (bubbles_lagrange) print *, " Lagrange bubbles running, in proc", proc_rank, "number:", n_loc, "/", n_read
2105
2106 end subroutine s_read_lag_entities
2107
2108 !> Read the initial Lagrangian entities from path, one per line with ncols values, and return those in this rank's physical
2109 !! domain: rows(1:n_loc, :) and their global IDs ids(1:n_loc), which are the line numbers among the n_read lines read.
2110 impure subroutine s_read_lag_input(path, ncols, n_glb, rows, ids, n_loc, n_read)
2111
2112 character(len=*), intent(in) :: path
2113 integer, intent(in) :: ncols, n_glb
2114 real(wp), allocatable, dimension(:,:), intent(out) :: rows
2115 integer, allocatable, dimension(:), intent(out) :: ids
2116 integer, intent(out) :: n_loc, n_read
2117 real(wp), dimension(ncols) :: vals
2118 character(LEN=1024) :: line
2119 character(LEN=200) :: abort_msg
2120 integer :: ios, ios_line, iunit
2121 logical :: file_exist
2122
2123 call my_inquire(trim(path), file_exist)
2124 if (.not. file_exist) call s_mpi_abort('Lagrangian input file ' // trim(path) // ' does not exist')
2125
2126 allocate (rows(max(1, n_glb), ncols), ids(max(1, n_glb)))
2127 n_loc = 0
2128 n_read = 0
2129 open (newunit=iunit, file=trim(path), form='formatted', status='old', iostat=ios)
2130 if (ios /= 0) call s_mpi_abort('Cannot open the Lagrangian input file ' // trim(path))
2131 do while (ios == 0)
2132 ! Read line by line so a line with extra columns cannot shift the lines after it
2133 read (iunit, '(A)', iostat=ios) line
2134 if (ios /= 0 .or. len_trim(line) == 0) cycle
2135 read (line, *, iostat=ios_line) vals
2136 if (ios_line /= 0) then
2137 write (abort_msg, '(A,I0,A)') 'Each line of ' // trim(path) // ' needs ', ncols, ' columns'
2138 call s_mpi_abort(trim(abort_msg))
2139 end if
2140 n_read = n_read + 1
2141 if (n_read > n_glb) call s_mpi_abort('More entries in ' // trim(path) // ' than the global count (nBubs_glb or ' &
2142 & // 'nParticles_glb)')
2143 if (f_lag_entity_in_physical_domain(vals(1:3))) then
2144 n_loc = n_loc + 1
2145 rows(n_loc,:) = vals
2146 ids(n_loc) = n_read
2147 end if
2148 end do
2149 close (iunit)
2150
2151 end subroutine s_read_lag_input
2152
2153 !> Read restart_data/lag_<lag_kind>_<save_count>.dat written by s_write_lag_restart: set mytime and dt from the header and
2154 !! return this rank's n_loc rows in io_data(1:n_loc, 1:lag_io_vars). Each rank reads what the same rank wrote, so the run must
2155 !! use the same number of ranks as the one that wrote the file.
2156 impure subroutine s_read_lag_restart(lag_kind, save_count, io_data, n_loc)
2157
2158 character(len=*), intent(in) :: lag_kind
2159 integer, intent(in) :: save_count
2160 real(wp), allocatable, dimension(:,:), intent(out) :: io_data
2161 integer, intent(out) :: n_loc
2162 character(LEN=path_len + 2*name_len) :: file_loc
2163 character(len=200) :: abort_msg
2164 logical :: file_exist
2165
2166#ifndef MFC_MPI
2167 n_loc = 0
2168 if (.true.) then
2169# 1300 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2170 call s_prohibit_abort(".true.", "Lagrangian restart requires MPI (--mpi)")
2171# 1300 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2172 end if
2173# 1301 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2174#else
2175 real(wp) :: file_time, file_dt
2176 integer :: file_num_procs, file_tot_part, ifile, ierr, view, i
2177 integer, dimension(MPI_STATUS_SIZE) :: status
2178 integer(kind=MPI_OFFSET_KIND) :: disp
2179 integer, dimension(2) :: gsizes, lsizes, start_idx_part
2180 integer, dimension(:), allocatable :: proc_counts
2181 real(wp), dimension(1:1,1:lag_io_vars) :: dummy
2182
2183 dummy = 0._wp
2184 n_loc = 0
2185
2186 write (file_loc, '(A,A,A,I0,A)') 'lag_', lag_kind, '_', save_count, '.dat'
2187 file_loc = trim(case_dir) // '/restart_data' // trim(mpiiofs) // trim(file_loc)
2188
2189 inquire (file=trim(file_loc), exist=file_exist)
2190 if (.not. file_exist) call s_mpi_abort('Restart file ' // trim(file_loc) // ' does not exist!')
2191
2192 if (proc_rank == 0) then
2193 call mpi_file_open(mpi_comm_self, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
2194 call s_check_mpi_file_open(ierr, file_loc)
2195 call mpi_file_read(ifile, file_tot_part, 1, mpi_integer, status, ierr)
2196 call mpi_file_read(ifile, file_time, 1, mpi_p, status, ierr)
2197 call mpi_file_read(ifile, file_dt, 1, mpi_p, status, ierr)
2198 call mpi_file_read(ifile, file_num_procs, 1, mpi_integer, status, ierr)
2199 call mpi_file_close(ifile, ierr)
2200 end if
2201
2202 call mpi_bcast(file_tot_part, 1, mpi_integer, 0, mpi_comm_world, ierr)
2203 call mpi_bcast(file_time, 1, mpi_p, 0, mpi_comm_world, ierr)
2204 call mpi_bcast(file_dt, 1, mpi_p, 0, mpi_comm_world, ierr)
2205 call mpi_bcast(file_num_procs, 1, mpi_integer, 0, mpi_comm_world, ierr)
2206
2207 if (file_num_procs /= num_procs) then
2208 write (abort_msg, &
2209 & '(A,I0,A,I0)') 'Lagrangian restart needs the same number of ranks as the run that wrote the ' &
2210 & // 'restart file. Ranks in the file: ', file_num_procs, ', ranks in this run: ', num_procs
2211 call s_mpi_abort(trim(abort_msg))
2212 end if
2213
2214 allocate (proc_counts(file_num_procs))
2215 if (proc_rank == 0) then
2216 call mpi_file_open(mpi_comm_self, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
2217 call s_check_mpi_file_open(ierr, file_loc)
2218 disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs), mpi_offset_kind)
2219 call mpi_file_seek(ifile, disp, mpi_seek_set, ierr)
2220 call mpi_file_read(ifile, proc_counts, file_num_procs, mpi_integer, status, ierr)
2221 call mpi_file_close(ifile, ierr)
2222 end if
2223 call mpi_bcast(proc_counts, file_num_procs, mpi_integer, 0, mpi_comm_world, ierr)
2224
2225 mytime = file_time
2226 dt = file_dt
2227
2228 n_loc = proc_counts(proc_rank + 1)
2229 start_idx_part(1) = 0
2230 do i = 1, proc_rank
2231 start_idx_part(1) = start_idx_part(1) + proc_counts(i)
2232 end do
2233 start_idx_part(2) = 0
2234 lsizes(1) = n_loc
2235 lsizes(2) = lag_io_vars
2236 gsizes(1) = file_tot_part
2237 gsizes(2) = lag_io_vars
2238
2239 allocate (io_data(max(1, n_loc),1:lag_io_vars))
2240
2241 if (n_loc > 0) then
2242 call mpi_type_create_subarray(2, gsizes, lsizes, start_idx_part, mpi_order_fortran, mpi_p, view, ierr)
2243 else
2244 call mpi_type_contiguous(0, mpi_p, view, ierr)
2245 end if
2246 call mpi_type_commit(view, ierr)
2247
2248 call mpi_file_open(mpi_comm_world, file_loc, mpi_mode_rdonly, mpi_info_int, ifile, ierr)
2249 call s_check_mpi_file_open(ierr, file_loc)
2250
2251 ! Skip the header
2252 disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs) + file_num_procs*sizeof(proc_counts(1)), &
2253 & mpi_offset_kind)
2254 call mpi_file_set_view(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr)
2255
2256 if (n_loc > 0) then
2257 call mpi_file_read_all(ifile, io_data, lag_io_vars*n_loc, mpi_p, status, ierr)
2258 else
2259 call mpi_file_read_all(ifile, dummy, 0, mpi_p, status, ierr)
2260 end if
2261
2262 call mpi_file_close(ifile, ierr)
2263 call mpi_type_free(view, ierr)
2264 deallocate (proc_counts)
2265
2266 if (proc_rank == 0) then
2267 write (*, '(A,I0,A,A,A,I0)') 'Read ', file_tot_part, ' Lagrangian ', lag_kind, ' from restart file at t_step = ', &
2268 & save_count
2269 write (*, '(A,E15.7,A,E15.7)') 'Restart time = ', mytime, ', dt = ', dt
2270 end if
2271#endif
2272
2273 end subroutine s_read_lag_restart
2274
2275 !> Finalize and deallocate all simulation sub-modules in reverse initialization order
2276 impure subroutine s_finalize_modules
2277
2278 if (ib) call s_close_ib_history()
2279
2280 if (model_eqns == model_eqns_6eq) call s_report_pressure_relaxation()
2281 if (ib .and. (chemistry .or. ib_wall_order == 2)) call s_report_ibm_surface()
2282
2283 if (ib) call s_ibm_note_fine_memory()
2284 call s_finalize_amr_registers()
2285 call s_finalize_amr_module()
2286 call s_phase_report()
2287 call s_finalize_time_steppers_module()
2288 if (hypoelasticity) call s_finalize_hypoelastic_module()
2289 call s_finalize_derived_variables_module()
2290 call s_finalize_data_output_module()
2291 call s_finalize_rhs_module()
2292 if (igr) then
2293 call s_finalize_igr_module()
2294 else
2295 call s_finalize_cbc_module()
2296 call s_finalize_riemann_solvers_module()
2297 if (recon_type == recon_type_weno) then
2298 call s_finalize_weno_module()
2299 else if (recon_type == recon_type_muscl) then
2300 call s_finalize_muscl_module()
2301 end if
2302 end if
2303 if (int_comp > 0) call s_finalize_thinc_module()
2304 call s_finalize_variables_conversion_module()
2305 call s_finalize_eos_module()
2306 if (grid_geometry == 3) call s_finalize_fftw_module
2307 call s_finalize_mpi_common_module()
2308 call s_finalize_global_parameters_module()
2309 call s_finalize_boundary_common_module()
2310 if (relax) call s_finalize_relaxation_solver_module()
2311 if (bubbles_lagrange) call s_finalize_lagrangian_solver()
2312 if (particles_lagrange) call s_finalize_particles_el_module()
2313 if (viscous .and. (.not. igr)) then
2314 call s_finalize_viscous_module()
2315 end if
2316 call s_finalize_mpi_proxy_module()
2317
2318 if (surface_tension) call s_finalize_surface_tension_module()
2319 if (bodyforces .or. synthetic_turbulence) call s_finalize_body_forces_module()
2320 if (ib) call s_finalize_ibm_module()
2321
2322 call s_mpi_finalize()
2323
2324 end subroutine s_finalize_modules
2325
2326 !> @brief Fills the properties of a generated particle-cloud IB that the IB state file does not carry (geometry, mass,
2327 !! moving_ibm, inert surface, identity rotation matrix, zeroed step state). This is the only place they are set - pre_process
2328 !! (s_add_cloud_particle) generates only position, kinematics and radius. cloud_ib_idx is the global patch id minus the number
2329 !! of namelist patches; pre_process numbers particles cloud by cloud.
2330 subroutine s_assign_particle_cloud_ib_defaults(cloud_ib_idx, ib_patch)
2331
2332 integer, intent(in) :: cloud_ib_idx
2333 type(ib_patch_parameters), intent(inout) :: ib_patch
2334 integer :: cloud_idx, idx_in_cloud
2335
2336 idx_in_cloud = cloud_ib_idx
2337 do cloud_idx = 1, num_particle_clouds - 1
2338 if (idx_in_cloud <= particle_cloud(cloud_idx)%num_particles) exit
2339 idx_in_cloud = idx_in_cloud - particle_cloud(cloud_idx)%num_particles
2340 end do
2341
2342 ib_patch%geometry = merge(2, 8, num_dims < 3)
2343 ib_patch%step_x_centroid = 0._wp
2344 ib_patch%step_y_centroid = 0._wp
2345 ib_patch%step_z_centroid = 0._wp
2346 ib_patch%step_angles(:) = 0._wp
2347 ib_patch%step_vel(:) = 0._wp
2348 ib_patch%step_angular_vel(:) = 0._wp
2349 ib_patch%accel(:) = 0._wp
2350 ib_patch%angular_accel(:) = 0._wp
2351 ib_patch%force(:) = 0._wp
2352 ib_patch%torque(:) = 0._wp
2353 ib_patch%centroid_offset(:) = 0._wp
2354 ib_patch%rotation_matrix = 0._wp
2355 ib_patch%rotation_matrix(1, 1) = 1._wp
2356 ib_patch%rotation_matrix(2, 2) = 1._wp
2357 ib_patch%rotation_matrix(3, 3) = 1._wp
2358 ib_patch%rotation_matrix_inverse = ib_patch%rotation_matrix
2359 ib_patch%mass = particle_cloud(cloud_idx)%mass
2360 ib_patch%moment = dflt_real
2361 ib_patch%moving_ibm = particle_cloud(cloud_idx)%moving_ibm
2362 ib_patch%slip = .false.
2363 ! Particles are inert surfaces: a cloud IB carries no case-file surface condition, so the thermal,
2364 ! reaction and blowing fields must be set here rather than left as whatever patch_ib held.
2365 ib_patch%thermal_bc = 0
2366 ib_patch%Twall = 0._wp
2367 ib_patch%thermal_layer = 0._wp
2368 ib_patch%rho_solid = 0._wp
2369 ib_patch%cp_solid = 0._wp
2370 ib_patch%emissivity = 0._wp
2371 ib_patch%T_rad = 0._wp
2372 ib_patch%heat_power = 0._wp
2373 ib_patch%surface_reaction = 0
2374 ib_patch%v_blow = 0._wp
2375 ib_patch%inj_species = 0
2376 ib_patch%burn_rate_exp = 0._wp
2377 ib_patch%burn_rate_pref = 0._wp
2378 ! Selector for the prescribed-kinematics block; zero leaves the eleven kin_* reals unread.
2379 ib_patch%kin_model = 0
2380
2382
2383 !> @brief Loads the IBs this rank owns from the IB state file for t_step into patch_ib(1:num_ibs), all of which are local. Under
2384 !! file_per_process the rank reads only its own restart_data/lustre_<t_step>/ib_state_<t_step>_<rank>.dat, which holds exactly
2385 !! its IBs; otherwise every rank reads every record of restart_data/ib_state_<t_step>.dat and keeps the ones
2386 !! f_local_rank_owns_location assigns it. Records carry kinematics, position, radius and the lumped wall temperature (read for
2387 !! thermal_bc = 3 only); every other property comes from the namelist patch (global id <= num_ibs) or the particle cloud the IB
2388 !! was generated from. Written by pre_process at t_step = 0 (src/pre_process/m_data_output.fpp:s_write_ib_state_0_file) and by
2389 !! s_write_ib_state_file on later steps.
2390 impure subroutine s_read_ib_restart_data(t_step)
2391
2392 integer, intent(in) :: t_step
2393 type(ib_patch_parameters), allocatable, dimension(:) :: namelist_ibs
2394 character(len=path_len + 2*name_len) :: file_loc
2395 integer :: i, ios, file_unit, gbl_id, n_records
2396 real(wp) :: ib_buf(ib_state_nfields), t_rst, t_rst_glb
2397 character(len=10) :: t_step_string
2398
2399 moving_immersed_boundary_flag = any(patch_ib(1:num_ibs)%moving_ibm /= 0) &
2400 & .or. any(particle_cloud(1:num_particle_clouds)%moving_ibm /= 0)
2401
2402 allocate (namelist_ibs(num_ibs))
2403 namelist_ibs(:) = patch_ib(1:num_ibs)
2404 num_gbl_ibs = num_ibs + sum(particle_cloud(1:num_particle_clouds)%num_particles)
2405
2406 if (file_per_process) then
2407 call s_int_to_str(t_step, t_step_string)
2408 write (file_loc, '(A,I0,A,i7.7,A)') 'ib_state_', t_step, '_', proc_rank, '.dat'
2409 file_loc = trim(case_dir) // '/restart_data/lustre_' // trim(t_step_string) // '/' // trim(file_loc)
2410 else
2411 write (file_loc, '(A,I0,A)') '/restart_data/ib_state_', t_step, '.dat'
2412 file_loc = trim(case_dir) // trim(file_loc)
2413 end if
2414
2415 open (newunit=file_unit, file=trim(file_loc), form='unformatted', access='stream', status='old', action='read', iostat=ios)
2416 if (ios /= 0) call s_mpi_abort('Error opening IB state file: ' // trim(file_loc))
2417
2418 n_records = num_gbl_ibs
2419 if (file_per_process) then
2420 read (file_unit, iostat=ios) n_records
2421 if (ios /= 0) call s_mpi_abort('Error reading IB state file header: ' // trim(file_loc))
2422 end if
2423
2424 num_ibs = 0
2425 t_rst = -huge(1._wp)
2426 do i = 1, n_records
2427 gbl_id = i
2428 if (file_per_process) read (file_unit, iostat=ios) gbl_id
2429 if (ios == 0) read (file_unit, iostat=ios) ib_buf
2430 if (ios /= 0) call s_mpi_abort('Error reading IB state file: ' // trim(file_loc))
2431 t_rst = max(t_rst, ib_buf(1))
2432
2433 if (.not. file_per_process) then
2434 if (.not. f_local_rank_owns_location(ib_buf(17:19), glb_bounds)) cycle
2435 end if
2436
2437 num_ibs = num_ibs + 1
2438 if (num_ibs > num_local_ibs_max) then
2439# 1565 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2440 call s_prohibit_abort("num_ibs > num_local_ibs_max", "Too many IBs on a single processor rank. Modify case file or increase limit of num_local_ibs_max to resolve.")
2441# 1565 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2442 end if
2443# 1567 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2444 if (gbl_id <= size(namelist_ibs)) then
2445 patch_ib(num_ibs) = namelist_ibs(gbl_id)
2446 else
2447 call s_assign_particle_cloud_ib_defaults(gbl_id - size(namelist_ibs), patch_ib(num_ibs))
2448 end if
2449 patch_ib(num_ibs)%gbl_patch_id = gbl_id
2450 patch_ib(num_ibs)%force = ib_buf(2:4)
2451 patch_ib(num_ibs)%torque = ib_buf(5:7)
2452 patch_ib(num_ibs)%vel = ib_buf(8:10)
2453 patch_ib(num_ibs)%angular_vel = ib_buf(11:13)
2454 patch_ib(num_ibs)%angles = ib_buf(14:16)
2455 patch_ib(num_ibs)%x_centroid = ib_buf(17)
2456 patch_ib(num_ibs)%y_centroid = ib_buf(18)
2457 patch_ib(num_ibs)%z_centroid = ib_buf(19)
2458 patch_ib(num_ibs)%radius = ib_buf(20)
2459 if (patch_ib(num_ibs)%thermal_bc == 3) patch_ib(num_ibs)%Twall = ib_buf(21)
2460 local_ib_patch_ids(num_ibs) = num_ibs
2461 end do
2462
2463 close (file_unit)
2464 deallocate (namelist_ibs)
2465
2466 num_local_ibs = num_ibs
2467
2468 ! A CFL-mode save lands past t_save*n_start; resume from the time it was written at (ranks may hold no record)
2469 if (cfl_dt .and. t_step > 0) then
2470 t_rst_glb = t_rst
2471#ifdef MFC_MPI
2472 call s_mpi_allreduce_max(t_rst, t_rst_glb)
2473#endif
2474 if (t_rst_glb > 0._wp) mytime = t_rst_glb
2475 end if
2476
2477 end subroutine s_read_ib_restart_data
2478
2479 !> @brief Completes this rank's IB neighborhood once s_read_ib_restart_data has loaded only the IBs it owns: every rank sends
2480 !! its own IBs to, and receives the owned IBs of, each distinct rank in ib_neighbor_ranks, appending them to patch_ib after its
2481 !! own.
2483
2484#ifdef MFC_MPI
2485 integer, allocatable, dimension(:) :: nbr_ranks, recv_counts, requests
2486 type(ib_patch_parameters), allocatable, dimension(:,:) :: recv_ibs
2487 integer :: i, n_nbrs, nreqs, patch_bytes, ierr
2488#endif
2489
2491
2492#ifdef MFC_MPI
2493 if (num_procs > 1) then
2494 ! A rank can fill several table slots (periodicity, few ranks) or be its own neighbor; exchange once per distinct rank
2495 allocate (nbr_ranks(size(ib_neighbor_ranks)))
2496 nbr_ranks = reshape(ib_neighbor_ranks, [size(ib_neighbor_ranks)])
2497 n_nbrs = 0
2498 do i = 1, size(nbr_ranks)
2499 if (nbr_ranks(i) < 0 .or. nbr_ranks(i) == proc_rank) cycle
2500 if (any(nbr_ranks(1:n_nbrs) == nbr_ranks(i))) cycle
2501 n_nbrs = n_nbrs + 1
2502 nbr_ranks(n_nbrs) = nbr_ranks(i)
2503 end do
2504
2505 ! the IBs loaded from restart are this rank's own; neighbors learn their owner from the sender below
2506 patch_ib(1:num_local_ibs)%owner_rank = proc_rank
2507
2508 allocate (recv_counts(n_nbrs), requests(2*n_nbrs))
2509 do i = 1, n_nbrs
2510 call mpi_irecv(recv_counts(i), 1, mpi_integer, nbr_ranks(i), 500, mpi_comm_world, requests(2*i - 1), ierr)
2511 call mpi_isend(num_local_ibs, 1, mpi_integer, nbr_ranks(i), 500, mpi_comm_world, requests(2*i), ierr)
2512 end do
2513 call mpi_waitall(2*n_nbrs, requests, mpi_statuses_ignore, ierr)
2514
2515 patch_bytes = storage_size(patch_ib(1))/8
2516 allocate (recv_ibs(max(1, maxval(recv_counts)), n_nbrs))
2517 nreqs = 0
2518 do i = 1, n_nbrs
2519 if (recv_counts(i) > 0) then
2520 nreqs = nreqs + 1
2521 call mpi_irecv(recv_ibs(:,i), recv_counts(i)*patch_bytes, mpi_byte, nbr_ranks(i), 501, mpi_comm_world, &
2522 & requests(nreqs), ierr)
2523 end if
2524 if (num_local_ibs > 0) then
2525 nreqs = nreqs + 1
2526 call mpi_isend(patch_ib, num_local_ibs*patch_bytes, mpi_byte, nbr_ranks(i), 501, mpi_comm_world, &
2527 & requests(nreqs), ierr)
2528 end if
2529 end do
2530 call mpi_waitall(nreqs, requests, mpi_statuses_ignore, ierr)
2531
2532 do i = 1, n_nbrs
2533 if (num_ibs + recv_counts(i) > num_ib_patches_max_namelist) then
2534# 1656 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2535 call s_prohibit_abort("num_ibs + recv_counts(i) > num_ib_patches_max_namelist", "IB neighborhood exceeds patch_ib capacity. Increase num_ib_patches_max_namelist.")
2536# 1656 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2537 end if
2538# 1658 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2539 patch_ib(num_ibs + 1:num_ibs + recv_counts(i)) = recv_ibs(1:recv_counts(i),i)
2540 patch_ib(num_ibs + 1:num_ibs + recv_counts(i))%owner_rank = nbr_ranks(i)
2541 num_ibs = num_ibs + recv_counts(i)
2542 end do
2543
2544 deallocate (nbr_ranks, recv_counts, requests, recv_ibs)
2545 end if
2546#endif
2547
2548 end subroutine s_build_ib_neighborhood
2549
2550 !> Build ib_neighbor_ranks(-1:1,-1:1,-1:1): MPI ranks of all neighbor domains. Uses two rounds of MPI_SENDRECV cascades - face
2551 !! neighbors are known from bc_*, edge neighbors are obtained in round 1, and (3D) corner neighbors in round 2.
2553
2554 integer :: ax, k, nbr_idx, nreqs, sx, sy, sz, dx, dy, dz
2555 integer, allocatable :: send_table(:,:,:), recv_tables(:,:,:,:)
2556 integer, dimension(52) :: requests
2557
2558#ifdef MFC_MPI
2559 integer :: ierr
2560 integer, dimension(4) :: buf4, rbuf4
2561 integer, dimension(2) :: buf2, rbuf2
2562
2563 ax = ib_neighborhood_radius
2564
2565 if (allocated(ib_neighbor_ranks)) deallocate (ib_neighbor_ranks)
2566 allocate (ib_neighbor_ranks(-ax:ax,-ax:ax,-ax:ax))
2567 ib_neighbor_ranks = mpi_proc_null
2568 ib_neighbor_ranks(0, 0, 0) = proc_rank
2569
2570 ! Fill radius-1 entries: face neighbors are known from domain decomposition
2571 ib_neighbor_ranks(-1, 0, 0) = bc_x%beg
2572 ib_neighbor_ranks(+1, 0, 0) = bc_x%end
2573 if (num_dims >= 2) then
2574 ib_neighbor_ranks(0, -1, 0) = bc_y%beg
2575 ib_neighbor_ranks(0, +1, 0) = bc_y%end
2576 end if
2577 if (num_dims == 3) then
2578 ib_neighbor_ranks(0, 0, -1) = bc_z%beg
2579 ib_neighbor_ranks(0, 0, +1) = bc_z%end
2580 end if
2581
2582 if (num_dims >= 2) then
2583 ! Round 1a: exchange y/z face ranks with +/-x face neighbors -> xy and xz edge ranks
2584 buf4 = [bc_y%beg, bc_y%end, bc_z%beg, bc_z%end]
2585
2586 ! Send to -x, receive from +x -> edges (+1,+/-1,0) and (+1,0,+/-1)
2587 call mpi_sendrecv(buf4, 4, mpi_integer, merge(bc_x%beg, mpi_proc_null, bc_x%beg >= 0), 310, rbuf4, 4, mpi_integer, &
2588 & merge(bc_x%end, mpi_proc_null, bc_x%end >= 0), 310, mpi_comm_world, mpi_status_ignore, ierr)
2589 if (bc_x%end >= 0) then
2590 ib_neighbor_ranks(+1, -1, 0) = rbuf4(1)
2591 ib_neighbor_ranks(+1, +1, 0) = rbuf4(2)
2592 ib_neighbor_ranks(+1, 0, -1) = rbuf4(3)
2593 ib_neighbor_ranks(+1, 0, +1) = rbuf4(4)
2594 end if
2595
2596 call mpi_sendrecv(buf4, 4, mpi_integer, merge(bc_x%end, mpi_proc_null, bc_x%end >= 0), 311, rbuf4, 4, mpi_integer, &
2597 & merge(bc_x%beg, mpi_proc_null, bc_x%beg >= 0), 311, mpi_comm_world, mpi_status_ignore, ierr)
2598 if (bc_x%beg >= 0) then
2599 ib_neighbor_ranks(-1, -1, 0) = rbuf4(1)
2600 ib_neighbor_ranks(-1, +1, 0) = rbuf4(2)
2601 ib_neighbor_ranks(-1, 0, -1) = rbuf4(3)
2602 ib_neighbor_ranks(-1, 0, +1) = rbuf4(4)
2603 end if
2604 end if
2605
2606 if (num_dims == 3) then
2607 ! Round 1b: exchange z face ranks with +/-y face neighbors -> yz edge ranks
2608 buf2 = [bc_z%beg, bc_z%end]
2609
2610 call mpi_sendrecv(buf2, 2, mpi_integer, merge(bc_y%beg, mpi_proc_null, bc_y%beg >= 0), 312, rbuf2, 2, mpi_integer, &
2611 & merge(bc_y%end, mpi_proc_null, bc_y%end >= 0), 312, mpi_comm_world, mpi_status_ignore, ierr)
2612 if (bc_y%end >= 0) then
2613 ib_neighbor_ranks(0, +1, -1) = rbuf2(1)
2614 ib_neighbor_ranks(0, +1, +1) = rbuf2(2)
2615 end if
2616
2617 call mpi_sendrecv(buf2, 2, mpi_integer, merge(bc_y%end, mpi_proc_null, bc_y%end >= 0), 313, rbuf2, 2, mpi_integer, &
2618 & merge(bc_y%beg, mpi_proc_null, bc_y%beg >= 0), 313, mpi_comm_world, mpi_status_ignore, ierr)
2619 if (bc_y%beg >= 0) then
2620 ib_neighbor_ranks(0, -1, -1) = rbuf2(1)
2621 ib_neighbor_ranks(0, -1, +1) = rbuf2(2)
2622 end if
2623
2624 ! Round 2: exchange z face ranks with xy-diagonal edge neighbors -> corner ranks. Each of the 4 xy diagonals gives 2
2625 ! corners (the +/-z variants). Pattern: send buf2 to mirror diagonal, receive from this diagonal -> that edge's z face
2626 ! ranks.
2627# 1747 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2628 call mpi_sendrecv(buf2, 2, mpi_integer, merge(ib_neighbor_ranks(-1, -1, 0), mpi_proc_null, &
2629# 1748 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2630 & ib_neighbor_ranks(-1, -1, 0) >= 0), 320, rbuf2, 2, mpi_integer, &
2631# 1749 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2632 & merge(ib_neighbor_ranks(1, 1, 0), mpi_proc_null, ib_neighbor_ranks(1, 1, &
2633# 1750 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2634 & 0) >= 0), 320, mpi_comm_world, mpi_status_ignore, ierr)
2635# 1751 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2636 if (ib_neighbor_ranks(1, 1, 0) >= 0) then
2637# 1752 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2638 ib_neighbor_ranks(1, 1, -1) = rbuf2(1)
2639# 1753 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2640 ib_neighbor_ranks(1, 1, +1) = rbuf2(2)
2641# 1754 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2642 end if
2643# 1747 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2644 call mpi_sendrecv(buf2, 2, mpi_integer, merge(ib_neighbor_ranks(-1, 1, 0), mpi_proc_null, &
2645# 1748 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2646 & ib_neighbor_ranks(-1, 1, 0) >= 0), 321, rbuf2, 2, mpi_integer, &
2647# 1749 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2648 & merge(ib_neighbor_ranks(1, -1, 0), mpi_proc_null, ib_neighbor_ranks(1, -1, &
2649# 1750 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2650 & 0) >= 0), 321, mpi_comm_world, mpi_status_ignore, ierr)
2651# 1751 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2652 if (ib_neighbor_ranks(1, -1, 0) >= 0) then
2653# 1752 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2654 ib_neighbor_ranks(1, -1, -1) = rbuf2(1)
2655# 1753 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2656 ib_neighbor_ranks(1, -1, +1) = rbuf2(2)
2657# 1754 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2658 end if
2659# 1747 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2660 call mpi_sendrecv(buf2, 2, mpi_integer, merge(ib_neighbor_ranks(1, -1, 0), mpi_proc_null, &
2661# 1748 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2662 & ib_neighbor_ranks(1, -1, 0) >= 0), 322, rbuf2, 2, mpi_integer, &
2663# 1749 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2664 & merge(ib_neighbor_ranks(-1, 1, 0), mpi_proc_null, ib_neighbor_ranks(-1, 1, &
2665# 1750 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2666 & 0) >= 0), 322, mpi_comm_world, mpi_status_ignore, ierr)
2667# 1751 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2668 if (ib_neighbor_ranks(-1, 1, 0) >= 0) then
2669# 1752 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2670 ib_neighbor_ranks(-1, 1, -1) = rbuf2(1)
2671# 1753 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2672 ib_neighbor_ranks(-1, 1, +1) = rbuf2(2)
2673# 1754 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2674 end if
2675# 1747 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2676 call mpi_sendrecv(buf2, 2, mpi_integer, merge(ib_neighbor_ranks(1, 1, 0), mpi_proc_null, &
2677# 1748 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2678 & ib_neighbor_ranks(1, 1, 0) >= 0), 323, rbuf2, 2, mpi_integer, &
2679# 1749 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2680 & merge(ib_neighbor_ranks(-1, -1, 0), mpi_proc_null, ib_neighbor_ranks(-1, -1, &
2681# 1750 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2682 & 0) >= 0), 323, mpi_comm_world, mpi_status_ignore, ierr)
2683# 1751 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2684 if (ib_neighbor_ranks(-1, -1, 0) >= 0) then
2685# 1752 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2686 ib_neighbor_ranks(-1, -1, -1) = rbuf2(1)
2687# 1753 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2688 ib_neighbor_ranks(-1, -1, +1) = rbuf2(2)
2689# 1754 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2690 end if
2691# 1756 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2692 end if
2693
2694 ! For radius > 1: extend the table by iterative 26-neighbor full-table exchanges. In each round, every rank broadcasts its
2695 ! current table to all 26 immediate neighbors. Their entry at offset (dx,dy,dz) from them = our entry at
2696 ! (dx+sx,dy+sy,dz+sz). One extension round fills the entire next shell, so ax-1 rounds suffice.
2697 if (ax > 1) then
2698 allocate (send_table(-ax:ax,-ax:ax,-ax:ax))
2699 allocate (recv_tables(-ax:ax,-ax:ax,-ax:ax,1:26))
2700
2701 do k = 2, ax
2702 send_table = ib_neighbor_ranks
2703
2704 nreqs = 0
2705 nbr_idx = 0
2706 do sz = -1, 1
2707 do sy = -1, 1
2708 do sx = -1, 1
2709 if (sx == 0 .and. sy == 0 .and. sz == 0) cycle
2710 nbr_idx = nbr_idx + 1
2711 if (ib_neighbor_ranks(sx, sy, sz) < 0) cycle
2712 nreqs = nreqs + 1
2713 call mpi_irecv(recv_tables(:,:,:,nbr_idx), (2*ax + 1)**3, mpi_integer, ib_neighbor_ranks(sx, sy, sz), &
2714 & 400, mpi_comm_world, requests(nreqs), ierr)
2715 end do
2716 end do
2717 end do
2718
2719 do sz = -1, 1
2720 do sy = -1, 1
2721 do sx = -1, 1
2722 if (sx == 0 .and. sy == 0 .and. sz == 0) cycle
2723 if (ib_neighbor_ranks(sx, sy, sz) < 0) cycle
2724 nreqs = nreqs + 1
2725 call mpi_isend(send_table, (2*ax + 1)**3, mpi_integer, ib_neighbor_ranks(sx, sy, sz), 400, &
2726 & mpi_comm_world, requests(nreqs), ierr)
2727 end do
2728 end do
2729 end do
2730
2731 call mpi_waitall(nreqs, requests, mpi_statuses_ignore, ierr)
2732
2733 nbr_idx = 0
2734 do sz = -1, 1
2735 do sy = -1, 1
2736 do sx = -1, 1
2737 if (sx == 0 .and. sy == 0 .and. sz == 0) cycle
2738 nbr_idx = nbr_idx + 1
2739 if (ib_neighbor_ranks(sx, sy, sz) < 0) cycle
2740 do dz = -ax, ax
2741 do dy = -ax, ax
2742 do dx = -ax, ax
2743 if (recv_tables(dx, dy, dz, nbr_idx) == mpi_proc_null) cycle
2744 if (dx + sx < -ax .or. dx + sx > ax) cycle
2745 if (dy + sy < -ax .or. dy + sy > ax) cycle
2746 if (dz + sz < -ax .or. dz + sz > ax) cycle
2747 if (ib_neighbor_ranks(dx + sx, dy + sy, dz + sz) /= mpi_proc_null) cycle
2748 ib_neighbor_ranks(dx + sx, dy + sy, dz + sz) = recv_tables(dx, dy, dz, nbr_idx)
2749 end do
2750 end do
2751 end do
2752 end do
2753 end do
2754 end do
2755 end do
2756
2757 deallocate (send_table, recv_tables)
2758 end if
2759#endif
2760
2761 end subroutine s_compute_ib_neighbor_ranks
2762
2764
2765 real(wp) :: beg_val, end_val, recv_val, bound, max_ib_bound, local_rank_width, min_rank_width
2766 integer :: k, send_neighbor, recv_neighbor, ierr, temporary_radius
2767
2768 ! Default: unbounded in all directions (covers single-rank and no-MPI cases)
2769
2770 neighbor_domain_x%beg = -huge(0._wp)
2771 neighbor_domain_x%end = huge(0._wp)
2772 neighbor_domain_y%beg = -huge(0._wp)
2773 neighbor_domain_y%end = huge(0._wp)
2774 neighbor_domain_z%beg = -huge(0._wp)
2775 neighbor_domain_z%end = huge(0._wp)
2776
2777#ifdef MFC_MPI
2778 ! perform setup if we are doing automatic radius checking
2779 if (ib_neighborhood_radius < 1) then
2780 ib_neighborhood_radius = 0 ! ensure we are starting with 0 neighborhood radius
2781
2782 ! determine the maximum length of space that needs to be contained by the neighborhood
2783 max_ib_bound = -1._wp
2784 do k = 1, num_ibs
2785 call s_get_ib_bound(patch_ib(k), bound)
2786 max_ib_bound = max(max_ib_bound, bound)
2787 end do
2788 do k = 1, num_particle_clouds
2789 max_ib_bound = max(max_ib_bound, particle_cloud(k)%radius)
2790 end do
2791
2792 ! Narrowest rank extent, over every direction as well as every rank. The radius is a count of rank
2793 ! hops, so the distance one hop covers is the extent of the rank it steps over, and the direction
2794 ! needing the most hops to span the body is the one whose ranks are thinnest. Reducing over each
2795 ! rank's widest extent first reports the wrong number whenever ranks are anisotropic, which is the
2796 ! norm on a stretched grid or an elongated domain.
2797 local_rank_width = huge(0._wp)
2798# 1863 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2799 if (num_dims >= 1) local_rank_width = min(local_rank_width, abs(x_cb(m) - x_cb(-1)))
2800# 1864 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2801# 1863 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2802 if (num_dims >= 2) local_rank_width = min(local_rank_width, abs(y_cb(n) - y_cb(-1)))
2803# 1864 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2804# 1863 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2805 if (num_dims >= 3) local_rank_width = min(local_rank_width, abs(z_cb(p) - z_cb(-1)))
2806# 1864 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2807# 1865 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2808 call s_mpi_allreduce_min(local_rank_width, min_rank_width)
2809
2810 ! approximate the size of the neighborhood with a local 1.1x fudge factor for safety, lower bound of 1
2811 ib_neighborhood_radius = max(1, ceiling(1.1_wp*max_ib_bound/(min_rank_width)))
2812 if (proc_rank == 0) print *, "Automatic choice of ib_neighborhood_radius selected: ", ib_neighborhood_radius
2813 end if
2814
2815 ! For each direction, propagate the left/right boundary edges outward ib_neighborhood_radius hops. After k rounds: beg_val =
2816 ! left edge of the rank k hops to the left; end_val = right edge of the rank k hops to the right.
2817# 1875 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2818 if (num_dims >= 1) then
2819# 1876 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2820 beg_val = x_cb(-1)
2821# 1877 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2822 end_val = x_cb(m)
2823# 1878 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2824 do k = 1, ib_neighborhood_radius
2825 send_neighbor = merge(bc_x%end, mpi_proc_null, bc_x%end >= 0)
2826# 1880 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2827 recv_neighbor = merge(bc_x%beg, mpi_proc_null, bc_x%beg >= 0)
2828# 1881 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2829 recv_val = -huge(0._wp)
2830 call mpi_sendrecv(beg_val, 1, mpi_p, send_neighbor, 100, recv_val, 1, mpi_p, recv_neighbor, 100, &
2831# 1883 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2832 & mpi_comm_world, mpi_status_ignore, ierr)
2833 beg_val = recv_val
2834
2835 send_neighbor = merge(bc_x%beg, mpi_proc_null, bc_x%beg >= 0)
2836# 1887 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2837 recv_neighbor = merge(bc_x%end, mpi_proc_null, bc_x%end >= 0)
2838# 1888 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2839 recv_val = huge(0._wp)
2840 call mpi_sendrecv(end_val, 1, mpi_p, send_neighbor, 101, recv_val, 1, mpi_p, recv_neighbor, &
2841# 1890 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2842 & 101, mpi_comm_world, mpi_status_ignore, ierr)
2843# 1891 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2844 end_val = recv_val
2845
2846 ! protect from looping back around on yourself multiple times
2847 if (f_approx_equal(beg_val, x_cb(m)) .or. f_approx_equal(end_val, x_cb(-1))) then
2848# 1895 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2849 beg_val = -huge(0._wp)
2850 end_val = huge(0._wp)
2851 exit
2852 end if
2853 end do
2854 neighbor_domain_x%beg = beg_val
2855# 1901 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2856 neighbor_domain_x%end = end_val
2857# 1902 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2858 end if
2859# 1875 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2860 if (num_dims >= 2) then
2861# 1876 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2862 beg_val = y_cb(-1)
2863# 1877 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2864 end_val = y_cb(n)
2865# 1878 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2866 do k = 1, ib_neighborhood_radius
2867 send_neighbor = merge(bc_y%end, mpi_proc_null, bc_y%end >= 0)
2868# 1880 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2869 recv_neighbor = merge(bc_y%beg, mpi_proc_null, bc_y%beg >= 0)
2870# 1881 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2871 recv_val = -huge(0._wp)
2872 call mpi_sendrecv(beg_val, 1, mpi_p, send_neighbor, 102, recv_val, 1, mpi_p, recv_neighbor, 102, &
2873# 1883 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2874 & mpi_comm_world, mpi_status_ignore, ierr)
2875 beg_val = recv_val
2876
2877 send_neighbor = merge(bc_y%beg, mpi_proc_null, bc_y%beg >= 0)
2878# 1887 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2879 recv_neighbor = merge(bc_y%end, mpi_proc_null, bc_y%end >= 0)
2880# 1888 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2881 recv_val = huge(0._wp)
2882 call mpi_sendrecv(end_val, 1, mpi_p, send_neighbor, 103, recv_val, 1, mpi_p, recv_neighbor, &
2883# 1890 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2884 & 103, mpi_comm_world, mpi_status_ignore, ierr)
2885# 1891 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2886 end_val = recv_val
2887
2888 ! protect from looping back around on yourself multiple times
2889 if (f_approx_equal(beg_val, y_cb(n)) .or. f_approx_equal(end_val, y_cb(-1))) then
2890# 1895 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2891 beg_val = -huge(0._wp)
2892 end_val = huge(0._wp)
2893 exit
2894 end if
2895 end do
2896 neighbor_domain_y%beg = beg_val
2897# 1901 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2898 neighbor_domain_y%end = end_val
2899# 1902 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2900 end if
2901# 1875 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2902 if (num_dims >= 3) then
2903# 1876 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2904 beg_val = z_cb(-1)
2905# 1877 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2906 end_val = z_cb(p)
2907# 1878 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2908 do k = 1, ib_neighborhood_radius
2909 send_neighbor = merge(bc_z%end, mpi_proc_null, bc_z%end >= 0)
2910# 1880 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2911 recv_neighbor = merge(bc_z%beg, mpi_proc_null, bc_z%beg >= 0)
2912# 1881 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2913 recv_val = -huge(0._wp)
2914 call mpi_sendrecv(beg_val, 1, mpi_p, send_neighbor, 104, recv_val, 1, mpi_p, recv_neighbor, 104, &
2915# 1883 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2916 & mpi_comm_world, mpi_status_ignore, ierr)
2917 beg_val = recv_val
2918
2919 send_neighbor = merge(bc_z%beg, mpi_proc_null, bc_z%beg >= 0)
2920# 1887 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2921 recv_neighbor = merge(bc_z%end, mpi_proc_null, bc_z%end >= 0)
2922# 1888 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2923 recv_val = huge(0._wp)
2924 call mpi_sendrecv(end_val, 1, mpi_p, send_neighbor, 105, recv_val, 1, mpi_p, recv_neighbor, &
2925# 1890 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2926 & 105, mpi_comm_world, mpi_status_ignore, ierr)
2927# 1891 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2928 end_val = recv_val
2929
2930 ! protect from looping back around on yourself multiple times
2931 if (f_approx_equal(beg_val, z_cb(p)) .or. f_approx_equal(end_val, z_cb(-1))) then
2932# 1895 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2933 beg_val = -huge(0._wp)
2934 end_val = huge(0._wp)
2935 exit
2936 end if
2937 end do
2938 neighbor_domain_z%beg = beg_val
2939# 1901 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2940 neighbor_domain_z%end = end_val
2941# 1902 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2942 end if
2943# 1904 "/home/runner/work/MFC/MFC/src/simulation/m_start_up.fpp"
2944#endif
2945
2946 end subroutine s_get_neighbor_bounds
2947
2948end module m_start_up
type(scalar_field), dimension(sys_size), intent(inout) q_cons_vf
One-way acoustic source injection, Maeda and Colonius JCP (2017).
impure subroutine, public s_precalculate_acoustic_spatial_sources
Pre-compute non-zero spatial source weights before time-stepping.
impure subroutine, public s_initialize_acoustic_src
Initialize the acoustic source module.
AMR flux registers: per-RK-stage refluxing at the coarse/fine block boundary. Depends only on m_deriv...
impure subroutine, public s_finalize_amr_registers()
impure subroutine, public s_initialize_amr_registers(maxc_fit)
Dynamic regrid for the AMR level set: density-gradient tagging, clustering (m_amr_cluster),...
impure subroutine, public s_amr_regrid(q_cons_base)
Regrid: tag by density gradient, cluster, shape, nest and rebuild the slots, carrying old data into t...
AMR fine-level restart I/O: writes/reads the fine-level restart file alongside the level-0 restart (s...
impure subroutine, public s_read_amr_restart(restored)
Restore the fine level from the AMR restart file at t_step_start (n_start under cfl_dt),...
impure subroutine, public s_write_amr_restart(t_step)
Write the fine-level restart file for save step t_step alongside the level-0 restart: the writing ran...
The AMR hooks of the SSP-RK stage loop (m_time_steppers): the stage-top coarse halo,...
impure subroutine, public s_amr_relax_fine(q_cons)
End-of-step phase-change relaxation on the fine blocks (the coarse grid's is in m_start_up),...
Block-structured AMR: up to amr_max_blocks refined blocks (2:1 or 4:1 per amr_ref_ratio),...
impure subroutine s_finalize_amr_module()
impure subroutine s_initialize_amr_module()
Re-exports every AMR service module.
Computes gravitational and body force source terms for the momentum equations.
impure subroutine, public s_initialize_body_forces_module
Initialize the body forces module. When synthetic_turbulence is enabled, generates random wave vector...
Noncharacteristic and processor boundary condition application for ghost cells and buffer regions.
subroutine, public s_populate_grid_variables_buffers(x_cb_in, x_cc_in, dx_in, x_offset, y_offset, z_offset, y_cb_in, y_cc_in, dy_in, z_cb_in, z_cc_in, dz_in, global_bounds)
Populate the buffers of the grid variables, which are constituted of the cell-boundary locations and ...
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.
impure subroutine, public s_populate_variables_buffers(bc_type, q_prim_vf, pb_in, mv_in, q_t_sf, skip_mpi)
Populate the buffers of the primitive variables based on the selected boundary conditions.
Boundary condition restart I/O, capillary/IGR buffer population, and grid-variable buffers.
subroutine s_assign_default_bc_type(bc_type)
Initialize the per-cell boundary condition type arrays with the global default BC values.
subroutine s_read_serial_boundary_condition_files(step_dirpath, bc_type)
Read boundary condition type and buffer data from serial (unformatted) restart files.
subroutine s_read_parallel_boundary_condition_files(bc_type, strict)
Read boundary condition type and buffer data from per-rank parallel files using MPI I/O.
Computes ensemble-averaged (Euler–Euler) bubble source terms for radius, velocity,...
impure subroutine s_initialize_bubbles_ee_module
Initialize the Euler-Euler bubble module.
Real fields of a bubble MPI slot, as (names, indices, count) in pack order. Used by both pack and unp...
impure subroutine s_sync_bubbles_for_save()
Bring the bubble state and void fraction to the host for a save, aborting on a negative or NaN radius...
type(scalar_field), dimension(:), allocatable q_beta
Projection of the Lagrangian bubbles in the Eulerian framework.
impure subroutine s_initialize_bubbles_el_module(q_cons_vf, bc_type, rows, ids, n_loc)
Initialize the Lagrangian subgrid bubble solver with this rank's n_loc bubbles from rows (input file,...
Characteristic boundary conditions (CBCs) for slip walls, non-reflecting subsonic inflow/outflow,...
impure subroutine, public s_initialize_cbc_module
Initialize the CBC module.
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.
Validates simulation input parameters for consistency and supported configurations.
impure subroutine, public s_check_inputs
Checks compatibility of parameters in the input file. Used by the simulation 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)
Initialize the temperature field from conservative variables by inverting the energy equation.
Ghost-node immersed boundary method: locates ghost/image points, computes interpolation coefficients,...
Platform-specific file and directory operations: create, delete, inquire, getcwd, and basename.
impure subroutine my_inquire(fileloc, dircheck)
Inquire on the existence of a directory or file.
Compile-time constant parameters: default values, tolerances, and physical constants.
integer, parameter ib_state_nfields
Reals per IB in restart_data/ib_state: time, force(3), torque(3), vel(3), angular_vel(3),...
real(wp), parameter dflt_t_guess
Default guess for temperature (when a previous value is not available).
integer, parameter time_stepper_rk2
real(wp), parameter sgm_eps
Segmentation tolerance.
integer, parameter recon_type_muscl
integer, parameter time_stepper_rk1
integer, parameter time_stepper_rk3
integer, parameter nnode
Number of QBMM nodes.
integer, parameter recon_type_weno
integer, parameter model_eqns_6eq
integer, parameter bc_periodic
Writes solution data, run-time stability diagnostics (ICFL, VCFL, CCFL, Rc), and probe/center-of-mass...
impure subroutine, public s_initialize_lag_output(save_count, qtime)
Create D/, open the Lagrangian output files, and write the initial output, from the restart point (sa...
impure subroutine, public s_initialize_data_output_module
Initialize the data output module.
impure subroutine, public s_write_lag_save_data(save_count)
Write the Lagrangian restart file, and the bubble statistics, for save save_count....
impure subroutine, public s_write_data_files(q_cons_vf, q_t_sf, q_prim_vf, t_step, bc_type, beta)
Write data files. Dispatch subroutine that replaces procedure pointer.
impure subroutine, public s_write_ib_state_file(time_step)
Writes IB state records to restart_data/ib_state.dat. Called on every rank.
subroutine, public s_write_ib_data_file(time_step)
Dispatch immersed boundary data output to the serial or parallel writer.
Shared derived types for field data, patch geometry, bubble dynamics, and MPI I/O structures.
Derives diagnostic flow quantities (vorticity, speed of sound, numerical Schlieren,...
impure subroutine, public s_initialize_derived_variables
Allocate and open derived variables. Computing FD coefficients.
impure subroutine, public s_initialize_derived_variables_module
Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the...
Equations of state in Gamma/Pi form, rho e = Gamma(rho) p + Pi(rho).
impure subroutine, public s_initialize_eos_module()
Resolve every fluid's EOS coefficients once, before any conversion runs.
subroutine, public s_phase_internal_energy(pres, alpha, alpha_rho, i, e_phase)
Internal energy per unit volume of phase i at pressure pres: alpha (Gamma p + Pi) + alpha_rho qv,...
Utilities shared by the Euler-Lagrange bubble and solid-particle solvers: cell location,...
subroutine, public s_get_lag_restart_point(save_count, qtime)
Save index and time the run starts from: zero on a fresh start, the restart point otherwise.
Global parameters for the computational domain, fluid properties, and simulation algorithm configurat...
real(wp) mytime
Current simulation time.
real(wp), dimension(num_synth_shells_max) synth_k_shell
type(part_q_idx_info) part_q_idx
Lagrangian particle projected-field indices.
real(wp), dimension(num_synth_shells_max) synth_amp_shell
type(int_bounds_info), dimension(1:3) idwint
real(wp), dimension(:), allocatable, target z_cb
logical, dimension(3) periodic_bc
integer proc_rank
Rank of the local processor.
type(mpi_io_ib_var), public mpi_io_ib_data
type(bounds_info), dimension(3) glb_bounds
type(int_bounds_info), dimension(1:3) idwbuff
integer buff_size
Number of ghost cells for boundary condition storage.
type(bub_q_idx_info) bub_q_idx
Lagrangian bubble projected-field indices.
impure subroutine s_initialize_global_parameters_module
Initialize the global parameters module.
real(wp), dimension(:), allocatable, target y_cc
type(pres_field), dimension(:), allocatable pb_ts
type(pres_field), dimension(:), allocatable mv_ts
real(wp), dimension(:), allocatable, target z_cc
integer num_procs
Number of processors.
real(wp), dimension(:), allocatable, target x_cc
integer, dimension(num_synth_shells_max) synth_n_waves_per_shell
real(wp), dimension(num_turb_sources_max, 3) turb_pos
real(wp), dimension(:), allocatable, target y_cb
type(cell_num_bounds) cells_bounds
type(mpi_io_var), public mpi_io_data
real(wp), dimension(:), allocatable, target dy
real(wp), dimension(num_turb_sources_max, 3) synth_l
real(wp), dimension(:), allocatable, target dz
real(wp), dimension(:), allocatable, target dx
real(wp), dimension(:), allocatable, target x_cb
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.
logical elemental function, public f_is_default(var)
Check if a real(wp) variable is of default value.
Utility routines for bubble model setup, coordinate transforms, array sampling, and special functions...
subroutine, public s_upsample_data(q_cons_vf, q_cons_temp)
Upsample conservative variable fields from a coarsened grid back to the original resolution using int...
impure subroutine, public s_initialize_bubbles_model()
Initialize bubble model arrays for Euler or Lagrangian bubbles with polytropic or non-polytropic gas.
elemental subroutine, public s_int_to_str(i, res)
Convert an integer to its trimmed string representation.
Computes hypoelastic stress-rate source terms and damage-state evolution.
impure subroutine, public s_initialize_hypoelastic_module
Initialize the hypoelastic module.
Allocate memory and read initial condition data for IC extrusion.
subroutine, public s_initialize_ib_airfoils()
Initialize the NACA surface grids for all airfoil IB patches. Must be called after the grid is establ...
Ghost-node immersed boundary method: locates ghost/image points, computes interpolation coefficients,...
impure subroutine, public s_ibm_setup()
Initializes the values of various IBM variables, such as ghost points and image points.
impure subroutine, public s_write_ib_surface(save_count)
Write this rank's surface records to D/ib_surface_<rank>_<save>.dat, one line per weighted ghost poin...
type(integer_field), public ib_markers
impure subroutine, public s_initialize_ibm_module()
Allocates memory for the variables in the IBM module.
Iterative ghost rasterization (IGR) for sharp immersed boundary treatment.
subroutine, public s_initialize_igr_module()
Initialize the IGR module.
integer(kind=8) j
integer(kind=8) i
integer(kind=8) l
integer(kind=8) r
integer(kind=8) k
Binary STL file reader and processor for immersed boundary geometry.
subroutine, public s_instantiate_stl_models()
Load, transform, and register STL/OBJ immersed-boundary models onto the simulation grid.
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_check_mpi_file_open(ierr, file_loc)
Abort naming the file if MPI_FILE_OPEN failed. File errors default to MPI_ERRORS_RETURN,...
subroutine s_apply_grid_from_global_dim(x_cb_glb, m_dim_glb, m_dim, sidx, bc_beg, bc_end, cb_lo, cb_hi, cw_lo, cw_hi, x_cb_loc, x_cc_loc, dx_loc)
Populate the local cell-boundary, cell-center, and cell-width arrays in one direction directly from t...
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.
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.
subroutine s_initialize_mpi_data_ds(m_ds, n_ds, p_ds, q_cons_vf)
Set up MPI I/O data views for downsampled (coarsened) parallel file output.
MPI halo exchange, domain decomposition, and buffer packing/unpacking for the simulation solver.
subroutine s_initialize_mpi_proxy_module()
Initialize the MPI proxy module.
MUSCL reconstruction with interface sharpening for contact-preserving advection.
subroutine, public s_initialize_muscl_module()
Allocate and initialize MUSCL reconstruction working arrays.
NVIDIA NVTX profiling API bindings for GPU performance instrumentation.
Definition m_nvtx.f90:6
subroutine nvtxstartrange(name, id)
Push a named NVTX range for GPU profiling, optionally with a color based on the given identifier.
Definition m_nvtx.f90:62
subroutine nvtxendrange
Pop the current NVTX range to end the GPU profiling region.
Definition m_nvtx.f90:83
Real fields of a particle MPI slot, as (names, indices, count) in pack order. Used by both pack and u...
impure subroutine, public s_initialize_particles_el_module(bc_type, rows, ids, n_loc)
Allocate the particle and projected-field arrays, load this rank's n_loc particles from rows (input f...
type(scalar_field), dimension(:), allocatable, public q_particles
Eulerian projection of particle data (volume fraction, momentum, sources).
impure subroutine, public s_sync_particles_for_save()
Copy the particle state and projected volume fraction to the host before a save, and abort if any par...
Phase transition relaxation solvers for liquid-vapor flows with cavitation and boiling.
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...
Per-phase wall-time budget of the AMR step, reported when rank_time_wrt is on. Brackets are disjoint ...
integer, parameter, public ph_regrid
regrid
impure subroutine, public s_phase_step_toc()
impure subroutine, public s_phase_step_tic()
impure subroutine, public s_phase_report()
Mean and max over ranks per phase, share of the step-loop wall, imbalance (max/mean) and calls; the r...
impure subroutine, public s_phase_tic(id)
impure subroutine, public s_phase_toc(id)
Pressure relaxation for the six-equation multi-component model via Newton–Raphson equilibration and v...
impure subroutine, public s_report_pressure_relaxation
One line at the end of a run if the equilibration ever stopped on its iteration cap....
Quadrature-based moment methods (QBMM) for polydisperse bubble moment inversion and transport.
impure subroutine, public s_initialize_qbmm_module
Initialize the QBMM module.
Assemble the right-hand side of the governing equations using finite-volume flux differencing,...
impure subroutine, public s_initialize_rhs_module
Initialize the RHS module.
Approximate and exact Riemann solvers (HLL, HLLC, HLLD, exact) for the multicomponent Navier–Stokes e...
impure subroutine, public s_initialize_riemann_solvers_module
Initialize the Riemann solvers module.
Simulation helper routines for cell state, CFL calculation, and stability checks.
character(len=4), public dt_limiter
Criterion currently limiting the adaptive time step (ICFL, VCFL, CCFL, TCFL, the collision cap,...
Reads input files, loads initial conditions and grid data, and orchestrates solver initialization and...
impure subroutine s_read_ib_restart_data(t_step)
Loads the IBs this rank owns from the IB state file for t_step into patch_ib(1:num_ibs),...
impure subroutine, public s_read_serial_data_files(q_cons_vf)
Read serial initial condition and grid data files and compute cell-width distributions.
impure subroutine, public s_initialize_modules
Initialize all simulation sub-modules in the required dependency order.
impure subroutine, public s_read_data_files(q_cons_vf)
Read data files. Dispatch subroutine that replaces procedure pointer.
subroutine s_assign_particle_cloud_ib_defaults(cloud_ib_idx, ib_patch)
Fills the properties of a generated particle-cloud IB that the IB state file does not carry (geometry...
impure subroutine, public s_read_parallel_data_files(q_cons_vf)
Read parallel initial condition and grid data files via MPI I/O.
subroutine, public s_initialize_internal_energy_equations(v_vf)
Initialize internal-energy equations from phase mass, mixture momentum, and total energy.
impure subroutine, public s_save_performance_metrics(time_avg, time_final, io_time_avg, io_time_final, proc_time, io_proc_time, file_exists)
Collect per-process wall-clock times and write aggregate performance metrics to file.
subroutine s_compute_ib_neighbor_ranks()
Build ib_neighbor_ranks(-1:1,-1:1,-1:1): MPI ranks of all neighbor domains. Uses two rounds of MPI_SE...
impure subroutine, public s_save_data(t_step, start, finish, io_time_avg, nt)
Save conservative variable data to disk at the current time step.
impure subroutine s_read_lag_restart(lag_kind, save_count, io_data, n_loc)
Read restart_data/lag_<lag_kind>_<save_count>.dat written by s_write_lag_restart: set mytime and dt f...
subroutine s_get_neighbor_bounds()
type(scalar_field), dimension(:), allocatable q_cons_temp
impure subroutine s_read_lag_input(path, ncols, n_glb, rows, ids, n_loc, n_read)
Read the initial Lagrangian entities from path, one per line with ncols values, and return those in t...
subroutine, public s_initialize_gpu_vars
Transfer initial conservative variable and model parameter data to the GPU device.
impure subroutine s_check_restart_file_size(ifile, file_loc, expected_bytes)
Abort if an open restart file holds fewer bytes than are about to be read from it,...
impure subroutine, public s_initialize_mpi_domain
Set up the MPI execution environment, bind GPUs, and decompose the computational domain.
impure subroutine, public s_finalize_modules
Finalize and deallocate all simulation sub-modules in reverse initialization order.
impure subroutine, public s_read_input_file
Verify the input file exists and read it.
impure subroutine, public s_check_input_file
Validate that all user-provided inputs form a consistent simulation configuration.
subroutine s_build_ib_neighborhood()
Completes this rank's IB neighborhood once s_read_ib_restart_data has loaded only the IBs it owns: ev...
impure subroutine, public s_perform_time_step(t_step, time_avg)
Advance the simulation by one time step, handling CFL-based dt and time-stepper dispatch.
impure subroutine s_read_lag_entities(save_count, rows, ids, n_loc)
Read the Lagrangian bubbles or particles this rank starts with: the input-file rows (and their global...
Computes capillary source fluxes and color-function gradients for the diffuse-interface surface tensi...
impure subroutine, public s_initialize_surface_tension_module
Allocate and initialize surface tension module arrays.
THINC and MTHINC interface compression for volume fraction sharpening. THINC (int_comp=1): 1D directi...
subroutine, public s_initialize_thinc_module()
real(wp), dimension(:,:,:), allocatable position
Total-variation-diminishing (TVD) Runge–Kutta time integrators (1st-, 2nd-, and 3rd-order SSP).
type(scalar_field) q_t_sf
Cell-average temperature variables at the current time-stage.
type(integer_field), dimension(:,:), allocatable bc_type
Boundary condition identifiers.
impure subroutine s_initialize_time_steppers_module
Initialize the time steppers module.
type(vector_field), dimension(:), allocatable q_cons_ts
Cell-average conservative variables at each time-stage (TS).
impure subroutine s_compute_dt(dt_cand)
Compute the global time step size from CFL stability constraints across all cells Sets dt from the CF...
type(scalar_field), dimension(:), allocatable q_prim_vf
Cell-average primitive variables at the current time-stage.
impure subroutine s_amr_check_fixed_dt()
AMR with a fixed dt: abort if dt exceeds the finest level's inviscid limit (ICFL = 1,...
impure subroutine s_tvd_rk(t_step, time_avg, nstage)
Advance the solution one full step using a TVD Runge-Kutta time integrator.
integer stor
storage index
Conservative-to-primitive variable conversion, mixture property evaluation, and pressure computation.
subroutine, public s_compute_pressure(energy, alf, dyn_p, pi_inf, gamma, rho, qv, rhoyks, pres, t, e_e_in, pres_mag)
Compute the pressure from the appropriate equation of state.
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.
subroutine, public s_convert_to_mixture_variables(q_vf, i, j, k, rho, gamma, pi_inf, qv, re_k, g_k, g)
Dispatch to the s_convert_mixture_to_mixture_variables and s_convert_species_to_mixture_variables sub...
Computes viscous stress tensors and diffusive flux contributions for the Navier–Stokes equations.
impure subroutine, public s_initialize_viscous_module
Initialize the viscous module.
WENO/WENO-Z/TENO reconstructions with optional monotonicity-preserving bounds and mapped weights.
impure subroutine, public s_initialize_weno_module
Initialize the WENO module.
Integer bounds for variables.
Derived type annexing a scalar field (SF).