diff --git a/src/common/m_derived_types.fpp b/src/common/m_derived_types.fpp index 59156d1c12..c20155528c 100644 --- a/src/common/m_derived_types.fpp +++ b/src/common/m_derived_types.fpp @@ -442,5 +442,10 @@ module m_derived_types real(wp) :: diffcoefvap !< Vapor diffusivity in the gas end type bubbles_lagrange_parameters + !> Max and min number of cells in a direction of each combination of x-,y-, and z- + type cell_num_bounds + integer :: mn_max, np_max, mp_max, mnp_max + integer :: mn_min, np_min, mp_min, mnp_min + end type cell_num_bounds end module m_derived_types diff --git a/src/common/m_helper_basic.f90 b/src/common/m_helper_basic.f90 index 4205279cd4..1066a3f504 100644 --- a/src/common/m_helper_basic.f90 +++ b/src/common/m_helper_basic.f90 @@ -13,7 +13,8 @@ module m_helper_basic f_is_default, & f_all_default, & f_is_integer, & - s_configure_coordinate_bounds + s_configure_coordinate_bounds, & + s_update_cell_bounds contains @@ -114,4 +115,24 @@ pure subroutine s_configure_coordinate_bounds(weno_polyn, buff_size, idwint, idw end subroutine s_configure_coordinate_bounds + !> Updates the min and max number of cells in each set of axes + !! @param bounds Min ans max values to update + !! @param m Number of cells in x-axis + !! @param n Number of cells in y-axis + !! @param p Number of cells in z-axis + pure elemental subroutine s_update_cell_bounds(bounds, m, n, p) + type(cell_num_bounds), intent(out) :: bounds + integer, intent(in) :: m, n, p + + bounds%mn_max = max(m, n) + bounds%np_max = max(n, p) + bounds%mp_max = max(m, p) + bounds%mnp_max = max(m, n, p) + bounds%mn_min = min(m, n) + bounds%np_min = min(n, p) + bounds%mp_min = min(m, p) + bounds%mnp_min = min(m, n, p) + + end subroutine s_update_cell_bounds + end module m_helper_basic diff --git a/src/common/m_mpi_common.fpp b/src/common/m_mpi_common.fpp index 4c84b6ff8c..7f7661ef8a 100644 --- a/src/common/m_mpi_common.fpp +++ b/src/common/m_mpi_common.fpp @@ -61,10 +61,10 @@ contains & (m + 2*buff_size + 1)* & & (n + 2*buff_size + 1)* & & (p + 2*buff_size + 1)/ & - & (min(m, n, p) + 2*buff_size + 1) + & (cells_bounds%mnp_min + 2*buff_size + 1) else halo_size = -1 + buff_size*(sys_size + 2*nb*4)* & - & (max(m, n) + 2*buff_size + 1) + & (cells_bounds%mn_max + 2*buff_size + 1) end if else halo_size = -1 + buff_size*(sys_size + 2*nb*4) @@ -76,10 +76,10 @@ contains & (m + 2*buff_size + 1)* & & (n + 2*buff_size + 1)* & & (p + 2*buff_size + 1)/ & - & (min(m, n, p) + 2*buff_size + 1) + & (cells_bounds%mnp_min + 2*buff_size + 1) else halo_size = -1 + buff_size*sys_size* & - & (max(m, n) + 2*buff_size + 1) + & (cells_bounds%mn_max + 2*buff_size + 1) end if else halo_size = -1 + buff_size*sys_size diff --git a/src/common/m_variables_conversion.fpp b/src/common/m_variables_conversion.fpp index 288c2fb0f3..67de9d0277 100644 --- a/src/common/m_variables_conversion.fpp +++ b/src/common/m_variables_conversion.fpp @@ -657,7 +657,7 @@ contains #ifdef MFC_SIMULATION if (viscous) then - @:ALLOCATE(Res(1:2, 1:maxval(Re_size))) + @:ALLOCATE(Res(1:2, 1:Re_size_max)) do i = 1, 2 do j = 1, Re_size(i) Res(i, j) = fluid_pp(Re_idx(i, j))%Re(i) diff --git a/src/post_process/m_global_parameters.fpp b/src/post_process/m_global_parameters.fpp index 2c93cca230..7f9e8072a8 100644 --- a/src/post_process/m_global_parameters.fpp +++ b/src/post_process/m_global_parameters.fpp @@ -38,6 +38,9 @@ module m_global_parameters integer :: p !> @} + !> @name Max and min number of cells in a direction of each combination of x-,y-, and z- + type(cell_num_bounds) :: cells_bounds + integer(8) :: nGlobal ! Total number of cells in global domain !> @name Cylindrical coordinates (either axisymmetric or full 3D) @@ -333,6 +336,9 @@ contains ! Computational domain parameters m = dflt_int; n = 0; p = 0 + + call s_update_cell_bounds(cells_bounds, m, n, p) + m_root = dflt_int cyl_coord = .false. diff --git a/src/post_process/m_mpi_proxy.fpp b/src/post_process/m_mpi_proxy.fpp index 2e693488f1..1b98d192ac 100644 --- a/src/post_process/m_mpi_proxy.fpp +++ b/src/post_process/m_mpi_proxy.fpp @@ -21,6 +21,8 @@ module m_mpi_proxy use ieee_arithmetic + use m_helper_basic, only: s_update_cell_bounds + implicit none !> @name Buffers of the conservative variables received/sent from/to neighboring @@ -70,14 +72,14 @@ contains (m + 2*buff_size + 1)* & (n + 2*buff_size + 1)* & (p + 2*buff_size + 1)/ & - (min(m, n, p) & + (cells_bounds%mnp_min & + 2*buff_size + 1) - 1)) allocate (q_cons_buffer_out(0:buff_size* & sys_size* & (m + 2*buff_size + 1)* & (n + 2*buff_size + 1)* & (p + 2*buff_size + 1)/ & - (min(m, n, p) & + (cells_bounds%mnp_min & + 2*buff_size + 1) - 1)) ! Simulation is 2D @@ -85,11 +87,11 @@ contains allocate (q_cons_buffer_in(0:buff_size* & sys_size* & - (max(m, n) & + (cells_bounds%mn_max & + 2*buff_size + 1) - 1)) allocate (q_cons_buffer_out(0:buff_size* & sys_size* & - (max(m, n) & + (cells_bounds%mn_max & + 2*buff_size + 1) - 1)) end if @@ -599,6 +601,8 @@ contains end if end do + call s_update_cell_bounds(cells_bounds, m, n, p) + ! Boundary condition at the beginning if (proc_coords(1) > 0 .or. bc_x%beg == BC_PERIODIC) then proc_coords(1) = proc_coords(1) - 1 diff --git a/src/post_process/m_start_up.f90 b/src/post_process/m_start_up.f90 index e7435f6ad6..d4440a7dbd 100644 --- a/src/post_process/m_start_up.f90 +++ b/src/post_process/m_start_up.f90 @@ -41,6 +41,8 @@ module m_start_up use m_chemistry + use m_helper_basic, only: s_update_cell_bounds + implicit none contains @@ -106,6 +108,9 @@ impure subroutine s_read_input_file end if close (1) + + call s_update_cell_bounds(cells_bounds, m, n, p) + ! Store m,n,p into global m,n,p m_glb = m n_glb = n diff --git a/src/pre_process/m_global_parameters.fpp b/src/pre_process/m_global_parameters.fpp index bb49f35d0d..9f6ab24806 100644 --- a/src/pre_process/m_global_parameters.fpp +++ b/src/pre_process/m_global_parameters.fpp @@ -40,6 +40,9 @@ module m_global_parameters integer :: n integer :: p + !> @name Max and min number of cells in a direction of each combination of x-,y-, and z- + type(cell_num_bounds) :: cells_bounds + integer(8) :: nGlobal !< Global number of cells in the domain integer :: m_glb, n_glb, p_glb !< Global number of cells in each direction @@ -303,6 +306,8 @@ contains ! Computational domain parameters m = dflt_int; n = 0; p = 0 + call s_update_cell_bounds(cells_bounds, m, n, p) + cyl_coord = .false. x_domain%beg = dflt_real diff --git a/src/pre_process/m_mpi_proxy.fpp b/src/pre_process/m_mpi_proxy.fpp index 3950fdb42d..1f45c32542 100644 --- a/src/pre_process/m_mpi_proxy.fpp +++ b/src/pre_process/m_mpi_proxy.fpp @@ -21,6 +21,8 @@ module m_mpi_proxy use m_mpi_common + use m_helper_basic, only: s_update_cell_bounds + implicit none integer, private :: err_code, ierr, v_size !< @@ -571,6 +573,8 @@ contains end if end do + call s_update_cell_bounds(cells_bounds, m, n, p) + ! Boundary condition at the beginning if (proc_coords(1) > 0 .or. (bc_x%beg == BC_PERIODIC .and. num_procs_x > 1)) then proc_coords(1) = proc_coords(1) - 1 diff --git a/src/pre_process/m_start_up.fpp b/src/pre_process/m_start_up.fpp index 1c9c79d342..1c991152a7 100644 --- a/src/pre_process/m_start_up.fpp +++ b/src/pre_process/m_start_up.fpp @@ -169,6 +169,9 @@ contains 'likely due to a datatype mismatch. Exiting.') end if close (1) + + call s_update_cell_bounds(cells_bounds, m, n, p) + ! Store m,n,p into global m,n,p m_glb = m n_glb = n diff --git a/src/simulation/m_global_parameters.fpp b/src/simulation/m_global_parameters.fpp index d0b94f6b7a..0ce4c17e25 100644 --- a/src/simulation/m_global_parameters.fpp +++ b/src/simulation/m_global_parameters.fpp @@ -43,6 +43,9 @@ module m_global_parameters integer :: m, n, p !> @} + !> @name Max and min number of cells in a direction of each combination of x-,y-, and z- + type(cell_num_bounds) :: cells_bounds + !> @name Global number of cells in each direction !> @{ integer :: m_glb, n_glb, p_glb @@ -267,6 +270,7 @@ module m_global_parameters !! numbers, will be non-negligible. !> @{ integer, dimension(2) :: Re_size + integer :: Re_size_max integer, allocatable, dimension(:, :) :: Re_idx !> @} @@ -516,6 +520,8 @@ contains ! Computational domain parameters m = dflt_int; n = 0; p = 0 + call s_update_cell_bounds(cells_bounds, m, n, p) + cyl_coord = .false. dt = dflt_real @@ -1028,13 +1034,15 @@ contains if (Re_size(1) > 0._wp) shear_stress = .true. if (Re_size(2) > 0._wp) bulk_stress = .true. + Re_size_max = maxval(Re_size) + !$acc update device(Re_size, viscous, shear_stress, bulk_stress) ! Bookkeeping the indexes of any viscous fluids and any pairs of ! fluids whose interface will support effects of surface tension if (viscous) then - @:ALLOCATE(Re_idx(1:2, 1:maxval(Re_size))) + @:ALLOCATE(Re_idx(1:2, 1:Re_size_max)) k = 0 do i = 1, num_fluids diff --git a/src/simulation/m_mpi_proxy.fpp b/src/simulation/m_mpi_proxy.fpp index f931227f4d..6bdcdd2d0f 100644 --- a/src/simulation/m_mpi_proxy.fpp +++ b/src/simulation/m_mpi_proxy.fpp @@ -552,6 +552,8 @@ contains end if end do + call s_update_cell_bounds(cells_bounds, m, n, p) + ! Boundary condition at the beginning if (proc_coords(1) > 0 .or. (bc_x%beg == BC_PERIODIC .and. num_procs_x > 1)) then proc_coords(1) = proc_coords(1) - 1 @@ -780,10 +782,10 @@ contains & (m + 2*gp_layers + 1)* & & (n + 2*gp_layers + 1)* & & (p + 2*gp_layers + 1)/ & - & (min(m, n, p) + 2*gp_layers + 1))) + & (cells_bounds%mnp_min + 2*gp_layers + 1))) else @:ALLOCATE(ib_buff_send(0:-1 + gp_layers* & - & (max(m, n) + 2*gp_layers + 1))) + & (cells_bounds%mn_max + 2*gp_layers + 1))) end if else @:ALLOCATE(ib_buff_send(0:-1 + gp_layers)) diff --git a/src/simulation/m_rhs.fpp b/src/simulation/m_rhs.fpp index deb869c11b..3ea6aeac53 100644 --- a/src/simulation/m_rhs.fpp +++ b/src/simulation/m_rhs.fpp @@ -580,7 +580,7 @@ contains !$acc update device(gamma_min, pres_inf) if (viscous) then - @:ALLOCATE(Res(1:2, 1:maxval(Re_size))) + @:ALLOCATE(Res(1:2, 1:Re_size_max)) end if if (viscous) then diff --git a/src/simulation/m_riemann_solvers.fpp b/src/simulation/m_riemann_solvers.fpp index 52a4640524..88088125e0 100644 --- a/src/simulation/m_riemann_solvers.fpp +++ b/src/simulation/m_riemann_solvers.fpp @@ -3326,7 +3326,7 @@ contains !$acc update device(Gs) if (viscous) then - @:ALLOCATE(Res(1:2, 1:maxval(Re_size))) + @:ALLOCATE(Res(1:2, 1:Re_size_max)) end if if (viscous) then diff --git a/src/simulation/m_start_up.fpp b/src/simulation/m_start_up.fpp index bf1d429714..dc52ab3a21 100644 --- a/src/simulation/m_start_up.fpp +++ b/src/simulation/m_start_up.fpp @@ -66,6 +66,8 @@ module m_start_up use ieee_arithmetic use m_helper_basic !< Functions to compare floating point numbers + + #ifdef MFC_OpenACC use openacc @@ -207,6 +209,8 @@ contains bodyForces = .true. endif + call s_update_cell_bounds(cells_bounds, m, n, p) + ! Store m,n,p into global m,n,p m_glb = m n_glb = n diff --git a/src/simulation/m_viscous.fpp b/src/simulation/m_viscous.fpp index f9fe0e5446..a064540471 100644 --- a/src/simulation/m_viscous.fpp +++ b/src/simulation/m_viscous.fpp @@ -35,7 +35,7 @@ contains integer :: i, j !< generic loop iterators - @:ALLOCATE(Res_viscous(1:2, 1:maxval(Re_size))) + @:ALLOCATE(Res_viscous(1:2, 1:Re_size_max)) do i = 1, 2 do j = 1, Re_size(i)