@@ -50,6 +50,8 @@ end subroutine s_read_abstract_data_files
5050 type (scalar_field), allocatable , dimension (:), public :: q_cons_vf ! <
5151 ! ! Conservative variables
5252
53+ type (scalar_field), allocatable , dimension (:), public :: q_cons_temp
54+
5355 type (scalar_field), allocatable , dimension (:), public :: q_prim_vf ! <
5456 ! ! Primitive variables
5557
@@ -340,6 +342,7 @@ impure subroutine s_read_parallel_data_files(t_step)
340342 integer (KIND= MPI_OFFSET_KIND) :: WP_MOK, var_MOK, str_MOK
341343 integer (KIND= MPI_OFFSET_KIND) :: NVARS_MOK
342344 integer (KIND= MPI_OFFSET_KIND) :: MOK
345+ real (wp) :: delx, dely, delz
343346
344347 character (LEN= path_len + 2 * name_len) :: file_loc
345348 logical :: file_exist
@@ -352,17 +355,25 @@ impure subroutine s_read_parallel_data_files(t_step)
352355 allocate (y_cb_glb(- 1 :n_glb))
353356 allocate (z_cb_glb(- 1 :p_glb))
354357
355- ! Read in cell boundary locations in x-direction
356- file_loc = trim (case_dir)// ' /restart_data' // trim (mpiiofs)// ' x_cb.dat'
357- inquire (FILE= trim (file_loc), EXIST= file_exist)
358-
359- if (file_exist) then
360- data_size = m_glb + 2
361- call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
362- call MPI_FILE_READ(ifile, x_cb_glb, data_size, mpi_p, status, ierr)
363- call MPI_FILE_CLOSE(ifile, ierr)
358+ if (down_sample) then
359+ delx = (x_domain% end - x_domain% beg)/ real (m_glb + 1 , wp)
360+ do i = 0 , m_glb
361+ x_cb_glb(i - 1 ) = x_domain% beg + delx* real (i, wp)
362+ end do
363+ x_cb_glb(m_glb) = x_domain% end
364364 else
365- call s_mpi_abort(' File ' // trim (file_loc)// ' is missing. Exiting.' )
365+ ! Read in cell boundary locations in x-direction
366+ file_loc = trim (case_dir)// ' /restart_data' // trim (mpiiofs)// ' x_cb.dat'
367+ inquire (FILE= trim (file_loc), EXIST= file_exist)
368+
369+ if (file_exist) then
370+ data_size = m_glb + 2
371+ call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
372+ call MPI_FILE_READ(ifile, x_cb_glb, data_size, mpi_p, status, ierr)
373+ call MPI_FILE_CLOSE(ifile, ierr)
374+ else
375+ call s_mpi_abort(' File ' // trim (file_loc)// ' is missing. Exiting.' )
376+ end if
366377 end if
367378
368379 ! Assigning local cell boundary locations
@@ -373,17 +384,25 @@ impure subroutine s_read_parallel_data_files(t_step)
373384 x_cc(0 :m) = x_cb(- 1 :m - 1 ) + dx(0 :m)/ 2._wp
374385
375386 if (n > 0 ) then
376- ! Read in cell boundary locations in y-direction
377- file_loc = trim (case_dir)// ' /restart_data' // trim (mpiiofs)// ' y_cb.dat'
378- inquire (FILE= trim (file_loc), EXIST= file_exist)
379-
380- if (file_exist) then
381- data_size = n_glb + 2
382- call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
383- call MPI_FILE_READ(ifile, y_cb_glb, data_size, mpi_p, status, ierr)
384- call MPI_FILE_CLOSE(ifile, ierr)
387+ if (down_sample) then
388+ dely = (y_domain% end - y_domain% beg)/ real (n_glb + 1 , wp)
389+ do i = 0 , n_glb
390+ y_cb_glb(i - 1 ) = y_domain% beg + dely* real (i, wp)
391+ end do
392+ y_cb_glb(n_glb) = y_domain% end
385393 else
386- call s_mpi_abort(' File ' // trim (file_loc)// ' is missing. Exiting.' )
394+ ! Read in cell boundary locations in y-direction
395+ file_loc = trim (case_dir)// ' /restart_data' // trim (mpiiofs)// ' y_cb.dat'
396+ inquire (FILE= trim (file_loc), EXIST= file_exist)
397+
398+ if (file_exist) then
399+ data_size = n_glb + 2
400+ call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
401+ call MPI_FILE_READ(ifile, y_cb_glb, data_size, mpi_p, status, ierr)
402+ call MPI_FILE_CLOSE(ifile, ierr)
403+ else
404+ call s_mpi_abort(' File ' // trim (file_loc)// ' is missing. Exiting.' )
405+ end if
387406 end if
388407
389408 ! Assigning local cell boundary locations
@@ -394,17 +413,25 @@ impure subroutine s_read_parallel_data_files(t_step)
394413 y_cc(0 :n) = y_cb(- 1 :n - 1 ) + dy(0 :n)/ 2._wp
395414
396415 if (p > 0 ) then
397- ! Read in cell boundary locations in z-direction
398- file_loc = trim (case_dir)// ' /restart_data' // trim (mpiiofs)// ' z_cb.dat'
399- inquire (FILE= trim (file_loc), EXIST= file_exist)
400-
401- if (file_exist) then
402- data_size = p_glb + 2
403- call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
404- call MPI_FILE_READ(ifile, z_cb_glb, data_size, mpi_p, status, ierr)
405- call MPI_FILE_CLOSE(ifile, ierr)
416+ if (down_sample) then
417+ delz = (z_domain% end - z_domain% beg)/ real (p_glb + 1 , wp)
418+ do i = 0 , p_glb
419+ z_cb_glb(i - 1 ) = z_domain% beg + delz* real (i, wp)
420+ end do
421+ z_cb_glb(p_glb) = z_domain% end
406422 else
407- call s_mpi_abort(' File ' // trim (file_loc)// ' is missing. Exiting.' )
423+ ! Read in cell boundary locations in z-direction
424+ file_loc = trim (case_dir)// ' /restart_data' // trim (mpiiofs)// ' z_cb.dat'
425+ inquire (FILE= trim (file_loc), EXIST= file_exist)
426+
427+ if (file_exist) then
428+ data_size = p_glb + 2
429+ call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
430+ call MPI_FILE_READ(ifile, z_cb_glb, data_size, mpi_p, status, ierr)
431+ call MPI_FILE_CLOSE(ifile, ierr)
432+ else
433+ call s_mpi_abort(' File ' // trim (file_loc)// ' is missing. Exiting.' )
434+ end if
408435 end if
409436
410437 ! Assigning local cell boundary locations
@@ -459,7 +486,42 @@ impure subroutine s_read_parallel_conservative_data(t_step, m_MOK, n_MOK, p_MOK,
459486 if (file_exist) then
460487 call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
461488
462- call s_setup_mpi_io_params(data_size, m_MOK, n_MOK, p_MOK, WP_MOK, MOK, str_MOK, NVARS_MOK)
489+ if (down_sample) then
490+ call s_initialize_mpi_data_ds(q_cons_temp)
491+ else
492+ ! Initialize MPI data I/O
493+ if (ib) then
494+ call s_initialize_mpi_data(q_cons_vf, ib_markers)
495+ else
496+ call s_initialize_mpi_data(q_cons_vf)
497+ end if
498+ end if
499+
500+ if (down_sample) then
501+ ! Size of local arrays
502+ data_size = (m + 3 )* (n + 3 )* (p + 3 )
503+
504+ ! Resize some integers so MPI can read even the biggest file
505+ m_MOK = int (m_glb + 1 , MPI_OFFSET_KIND)
506+ n_MOK = int (n_glb + 1 , MPI_OFFSET_KIND)
507+ p_MOK = int (p_glb + 1 , MPI_OFFSET_KIND)
508+ WP_MOK = int (8._wp , MPI_OFFSET_KIND)
509+ MOK = int (1._wp , MPI_OFFSET_KIND)
510+ str_MOK = int (name_len, MPI_OFFSET_KIND)
511+ NVARS_MOK = int (sys_size, MPI_OFFSET_KIND)
512+ else
513+ ! Size of local arrays
514+ data_size = (m + 1 )* (n + 1 )* (p + 1 )
515+
516+ ! Resize some integers so MPI can read even the biggest file
517+ m_MOK = int (m_glb + 1 , MPI_OFFSET_KIND)
518+ n_MOK = int (n_glb + 1 , MPI_OFFSET_KIND)
519+ p_MOK = int (p_glb + 1 , MPI_OFFSET_KIND)
520+ WP_MOK = int (8._wp , MPI_OFFSET_KIND)
521+ MOK = int (1._wp , MPI_OFFSET_KIND)
522+ str_MOK = int (name_len, MPI_OFFSET_KIND)
523+ NVARS_MOK = int (sys_size, MPI_OFFSET_KIND)
524+ end if
463525
464526 ! Read the data for each variable
465527 if (bubbles_euler .or. elasticity .or. mhd) then
@@ -479,6 +541,12 @@ impure subroutine s_read_parallel_conservative_data(t_step, m_MOK, n_MOK, p_MOK,
479541 call s_mpi_barrier()
480542 call MPI_FILE_CLOSE(ifile, ierr)
481543
544+ if (down_sample) then
545+ do i = 1 , sys_size
546+ q_cons_vf(i)% sf(0 :m,0 :n,0 :p) = q_cons_temp(i)% sf(0 :m,0 :n,0 :p)
547+ end do
548+ end if
549+
482550 call s_read_ib_data_files(trim (case_dir)// ' /restart_data' // trim (mpiiofs))
483551 else
484552 call s_mpi_abort(' File ' // trim (file_loc)// ' is missing. Exiting.' )
@@ -529,6 +597,7 @@ impure subroutine s_initialize_data_input_module
529597 ! the simulation
530598 allocate (q_cons_vf(1 :sys_size))
531599 allocate (q_prim_vf(1 :sys_size))
600+ allocate (q_cons_temp(1 :sys_size))
532601
533602 ! Allocating the parts of the conservative and primitive variables
534603 ! that do require the direct knowledge of the dimensionality of
@@ -539,6 +608,9 @@ impure subroutine s_initialize_data_input_module
539608 ! Simulation is 3D
540609 if (p > 0 ) then
541610 call s_allocate_field_arrays(- buff_size, m + buff_size, n + buff_size, p + buff_size)
611+ if (down_sample) then
612+ allocate (q_cons_temp(i)% sf(- 1 :m+1 ,- 1 :n+1 ,- 1 :p+1 ))
613+ end if
542614 else
543615 ! Simulation is 2D
544616 call s_allocate_field_arrays(- buff_size, m + buff_size, n + buff_size, 0 )
@@ -579,10 +651,14 @@ impure subroutine s_finalize_data_input_module
579651 do i = 1 , sys_size
580652 deallocate (q_cons_vf(i)% sf)
581653 deallocate (q_prim_vf(i)% sf)
654+ if (down_sample) then
655+ deallocate (q_cons_temp(i)% sf)
656+ end if
582657 end do
583658
584659 deallocate (q_cons_vf)
585660 deallocate (q_prim_vf)
661+ deallocate (q_cons_temp)
586662
587663 if (ib) then
588664 deallocate (ib_markers% sf)
0 commit comments