Skip to content

Replace intrinsics in allocate statements #850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/common/m_derived_types.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 22 additions & 1 deletion src/common/m_helper_basic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions src/common/m_mpi_common.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/common/m_variables_conversion.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
#ifdef MFC_SIMULATION

if (viscous) then
@:ALLOCATE(Res(1:2, 1:maxval(Re_size)))
@:ALLOCATE(Res(1:2, 1:Re_size_max))

Check warning on line 660 in src/common/m_variables_conversion.fpp

View check run for this annotation

Codecov / codecov/patch

src/common/m_variables_conversion.fpp#L660

Added line #L660 was not covered by tests
do i = 1, 2
do j = 1, Re_size(i)
Res(i, j) = fluid_pp(Re_idx(i, j))%Re(i)
Expand Down
6 changes: 6 additions & 0 deletions src/post_process/m_global_parameters.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.

Expand Down
12 changes: 8 additions & 4 deletions src/post_process/m_mpi_proxy.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -70,26 +72,26 @@ 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
else

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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/post_process/m_start_up.f90
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ module m_start_up

use m_chemistry

use m_helper_basic, only: s_update_cell_bounds

implicit none

contains
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/pre_process/m_global_parameters.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/pre_process/m_mpi_proxy.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 !<
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/pre_process/m_start_up.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/simulation/m_global_parameters.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
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
Expand Down Expand Up @@ -267,6 +270,7 @@
!! numbers, will be non-negligible.
!> @{
integer, dimension(2) :: Re_size
integer :: Re_size_max
integer, allocatable, dimension(:, :) :: Re_idx
!> @}

Expand Down Expand Up @@ -516,6 +520,8 @@
! 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
Expand Down Expand Up @@ -1028,13 +1034,15 @@
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))

Check warning on line 1045 in src/simulation/m_global_parameters.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_global_parameters.fpp#L1045

Added line #L1045 was not covered by tests

k = 0
do i = 1, num_fluids
Expand Down
6 changes: 4 additions & 2 deletions src/simulation/m_mpi_proxy.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/m_rhs.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@
!$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))

Check warning on line 583 in src/simulation/m_rhs.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_rhs.fpp#L583

Added line #L583 was not covered by tests
end if

if (viscous) then
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/m_riemann_solvers.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -3326,7 +3326,7 @@
!$acc update device(Gs)

if (viscous) then
@:ALLOCATE(Res(1:2, 1:maxval(Re_size)))
@:ALLOCATE(Res(1:2, 1:Re_size_max))

Check warning on line 3329 in src/simulation/m_riemann_solvers.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_riemann_solvers.fpp#L3329

Added line #L3329 was not covered by tests
end if

if (viscous) then
Expand Down
4 changes: 4 additions & 0 deletions src/simulation/m_start_up.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/m_viscous.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

integer :: i, j !< generic loop iterators

@:ALLOCATE(Res_viscous(1:2, 1:maxval(Re_size)))
@:ALLOCATE(Res_viscous(1:2, 1:Re_size_max))

Check warning on line 38 in src/simulation/m_viscous.fpp

View check run for this annotation

Codecov / codecov/patch

src/simulation/m_viscous.fpp#L38

Added line #L38 was not covered by tests

do i = 1, 2
do j = 1, Re_size(i)
Expand Down
Loading