|
5 | 5 | !> @details |
6 | 6 | !> Reads a sequence of 1D primitive-variable files and maps them onto |
7 | 7 | !> a 2D domain along the x-direction. These files are produced when parallel I/O is disabled in `case.py`. |
8 | | -!> Parameters control file counts, grid resolution, and domain offsets. |
| 8 | +!> Parameters control grid resolution, and domain offsets. |
9 | 9 | !> |
10 | | -!> @param nFiles Number of primitive-variable files to read |
11 | 10 | !> @param nRows Number of grid points per row |
12 | 11 | !> @param init_dir Directory containing the `prim.*.dat` files |
13 | 12 | real(wp) :: eps |
14 | 13 | real(wp) :: r, rmax, gam, umax, p0 |
15 | 14 | real(wp) :: rhoH, rhoL, pRef, pInt, h, lam, wl, amp, intH, intL, alph |
16 | 15 | real(wp) :: factor |
17 | 16 |
|
18 | | - integer, parameter :: nFiles = 14 ! Number of files (variables) |
19 | | - integer, parameter :: nRows = 401 ! Number of grid points |
| 17 | + !integer :: nFiles ! Number of files (variables) |
| 18 | + integer, parameter :: nRows = 401 ! Number of grid points |
20 | 19 | integer :: f, iter, ios, unit, idx, jump, index_1 |
21 | 20 | real(wp) :: x_len, x_step |
22 | 21 | integer :: global_offset ! MPI subdomain offset |
23 | 22 | real(wp) :: delta_x |
24 | | - character(len=100), dimension(nFiles) :: fileNames |
| 23 | + character(len=100), dimension(sys_size - 1) :: fileNames |
25 | 24 | character(len=200) :: errmsg |
26 | 25 | ! Arrays to store all data from files |
27 | | - real(wp), dimension(nRows, nFiles) :: stored_values ! Imported Data |
| 26 | + real(wp), dimension(nRows, sys_size - 1) :: stored_values ! Imported Data |
28 | 27 | real(wp), dimension(nRows) :: x_coords |
29 | 28 | logical :: files_loaded = .false. |
30 | 29 | real(wp) :: domain_start, domain_end |
|
33 | 32 | character(len=20) :: zeros_part ! For the trailing zeros part |
34 | 33 | character(len=6), parameter :: zeros_default = "018681" ! Default zeros (can be changed) |
35 | 34 | ! Generate file names in a loop |
36 | | - do f = 1, nFiles |
37 | | - ! Convert file number to string with proper formatting |
38 | | - if (f < 10) then |
39 | | - write (file_num_str, '(I1)') f ! Single digit |
40 | | - else |
41 | | - write (file_num_str, '(I2)') f ! Double digit |
42 | | - ! For more than 99 files, you might need to adjust this format |
43 | | - end if |
44 | | - fileNames(f) = trim(init_dir)//"prim."//trim(file_num_str)//".00."//zeros_default//".dat" |
45 | | - end do |
46 | 35 |
|
47 | 36 | eps = 1e-9_wp |
48 | 37 |
|
|
198 | 187 | end if |
199 | 188 |
|
200 | 189 | case (270) |
| 190 | + |
| 191 | + do f = 1, sys_size - 1 |
| 192 | + ! Convert file number to string with proper formatting |
| 193 | + if (f < 10) then |
| 194 | + write (file_num_str, '(I1)') f ! Single digit |
| 195 | + else |
| 196 | + write (file_num_str, '(I2)') f ! Double digit |
| 197 | + ! For more than 99 files, you might need to adjust this format |
| 198 | + end if |
| 199 | + fileNames(f) = trim(init_dir)//"prim."//trim(file_num_str)//".00."//zeros_default//".dat" |
| 200 | + end do |
| 201 | + |
201 | 202 | if (.not. files_loaded) then |
202 | 203 | ! Print status message |
203 | 204 | index_1 = i |
204 | | - do f = 1, nFiles |
| 205 | + do f = 1, sys_size - 1 |
205 | 206 | ! Open the file for reading |
206 | 207 | open (newunit=unit, file=trim(fileNames(f)), status='old', action='read', iostat=ios) |
207 | | - if (ios /= 0) then |
208 | | - cycle ! Skip this file on error |
| 208 | + if (ios /= 0 .and. proc_rank == 0) then |
| 209 | + write (errmsg, '(A,A)') "Error opening file: ", trim(fileNames(f)) |
| 210 | + call s_mpi_abort(trim(errmsg)) |
209 | 211 | end if |
210 | 212 | ! Read all rows at once into memory |
211 | 213 | do iter = 1, nRows |
|
228 | 230 | end if |
229 | 231 | ! Calculate the index in the file data array corresponding to x_cc(i) |
230 | 232 | idx = i + 1 + global_offset - index_1 |
231 | | - do f = 1, nFiles |
| 233 | + do f = 1, sys_size - 1 |
232 | 234 | if (f >= momxe) then |
233 | 235 | jump = 1 |
234 | 236 | else |
|
0 commit comments