Skip to content

Commit 293557c

Browse files
authored
Replace intrinsics in allocate statements (#850)
1 parent 943029a commit 293557c

14 files changed

+67
-14
lines changed

src/common/m_derived_types.fpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,4 +443,10 @@ module m_derived_types
443443
444444
end type bubbles_lagrange_parameters
445445
446+
!> Max and min number of cells in a direction of each combination of x-,y-, and z-
447+
type cell_num_bounds
448+
integer :: mn_max, np_max, mp_max, mnp_max
449+
integer :: mn_min, np_min, mp_min, mnp_min
450+
end type cell_num_bounds
451+
446452
end module m_derived_types

src/common/m_helper_basic.fpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module m_helper_basic
1616
f_is_default, &
1717
f_all_default, &
1818
f_is_integer, &
19-
s_configure_coordinate_bounds
19+
s_configure_coordinate_bounds, &
20+
s_update_cell_bounds
2021

2122
contains
2223

@@ -146,4 +147,24 @@ contains
146147

147148
end subroutine s_configure_coordinate_bounds
148149

150+
!> Updates the min and max number of cells in each set of axes
151+
!! @param bounds Min ans max values to update
152+
!! @param m Number of cells in x-axis
153+
!! @param n Number of cells in y-axis
154+
!! @param p Number of cells in z-axis
155+
pure elemental subroutine s_update_cell_bounds(bounds, m, n, p)
156+
type(cell_num_bounds), intent(out) :: bounds
157+
integer, intent(in) :: m, n, p
158+
159+
bounds%mn_max = max(m, n)
160+
bounds%np_max = max(n, p)
161+
bounds%mp_max = max(m, p)
162+
bounds%mnp_max = max(m, n, p)
163+
bounds%mn_min = min(m, n)
164+
bounds%np_min = min(n, p)
165+
bounds%mp_min = min(m, p)
166+
bounds%mnp_min = min(m, n, p)
167+
168+
end subroutine s_update_cell_bounds
169+
149170
end module m_helper_basic

src/common/m_mpi_common.fpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ contains
6767
& (m + 2*buff_size + 1)* &
6868
& (n + 2*buff_size + 1)* &
6969
& (p + 2*buff_size + 1)/ &
70-
& (min(m, n, p) + 2*buff_size + 1))
70+
& (cells_bounds%mnp_min + 2*buff_size + 1))
7171
else
7272
halo_size = -1 + buff_size*(v_size)* &
73-
& (max(m, n) + 2*buff_size + 1)
73+
& (cells_bounds%mn_max + 2*buff_size + 1)
7474
end if
7575
else
7676
halo_size = -1 + buff_size*(v_size)
@@ -1446,6 +1446,8 @@ contains
14461446
end if
14471447
end do
14481448
1449+
call s_update_cell_bounds(cells_bounds, m, n, p)
1450+
14491451
! Boundary condition at the beginning
14501452
if (proc_coords(1) > 0 .or. (bc_x%beg == BC_PERIODIC .and. num_procs_x > 1)) then
14511453
proc_coords(1) = proc_coords(1) - 1

src/common/m_variables_conversion.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ contains
637637
#ifdef MFC_SIMULATION
638638

639639
if (viscous) then
640-
@:ALLOCATE(Res(1:2, 1:maxval(Re_size)))
640+
@:ALLOCATE(Res(1:2, 1:Re_size_max))
641641
do i = 1, 2
642642
do j = 1, Re_size(i)
643643
Res(i, j) = fluid_pp(Re_idx(i, j))%Re(i)

src/post_process/m_global_parameters.fpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ module m_global_parameters
3838
integer :: p
3939
!> @}
4040

41+
!> @name Max and min number of cells in a direction of each combination of x-,y-, and z-
42+
type(cell_num_bounds) :: cells_bounds
43+
4144
integer(8) :: nGlobal ! Total number of cells in global domain
4245

4346
!> @name Cylindrical coordinates (either axisymmetric or full 3D)
@@ -336,6 +339,8 @@ contains
336339

337340
! Computational domain parameters
338341
m = dflt_int; n = 0; p = 0
342+
call s_update_cell_bounds(cells_bounds, m, n, p)
343+
339344
m_root = dflt_int
340345
cyl_coord = .false.
341346

src/post_process/m_start_up.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ impure subroutine s_read_input_file
111111
end if
112112

113113
close (1)
114+
115+
call s_update_cell_bounds(cells_bounds, m, n, p)
116+
114117
! Store m,n,p into global m,n,p
115118
m_glb = m
116119
n_glb = n

src/pre_process/m_global_parameters.fpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ module m_global_parameters
4040
integer :: n
4141
integer :: p
4242

43+
!> @name Max and min number of cells in a direction of each combination of x-,y-, and z-
44+
type(cell_num_bounds) :: cells_bounds
45+
4346
integer(8) :: nGlobal !< Global number of cells in the domain
4447

4548
integer :: m_glb, n_glb, p_glb !< Global number of cells in each direction
@@ -306,6 +309,8 @@ contains
306309
! Computational domain parameters
307310
m = dflt_int; n = 0; p = 0
308311

312+
call s_update_cell_bounds(cells_bounds, m, n, p)
313+
309314
cyl_coord = .false.
310315

311316
x_domain%beg = dflt_real

src/pre_process/m_start_up.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ contains
169169
'likely due to a datatype mismatch. Exiting.')
170170
end if
171171
close (1)
172+
173+
call s_update_cell_bounds(cells_bounds, m, n, p)
174+
172175
! Store m,n,p into global m,n,p
173176
m_glb = m
174177
n_glb = n

src/simulation/m_global_parameters.fpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ module m_global_parameters
4343
integer :: m, n, p
4444
!> @}
4545

46+
!> @name Max and min number of cells in a direction of each combination of x-,y-, and z-
47+
type(cell_num_bounds) :: cells_bounds
48+
4649
!> @name Global number of cells in each direction
4750
!> @{
4851
integer :: m_glb, n_glb, p_glb
@@ -273,10 +276,11 @@ module m_global_parameters
273276
!! numbers, will be non-negligible.
274277
!> @{
275278
integer, dimension(2) :: Re_size
279+
integer :: Re_size_max
276280
integer, allocatable, dimension(:, :) :: Re_idx
277281
!> @}
278282

279-
$:GPU_DECLARE(create='[Re_size,Re_idx]')
283+
$:GPU_DECLARE(create='[Re_size,Re_size_max,Re_idx]')
280284

281285
! The WENO average (WA) flag regulates whether the calculation of any cell-
282286
! average spatial derivatives is carried out in each cell by utilizing the
@@ -525,6 +529,7 @@ contains
525529
526530
! Computational domain parameters
527531
m = dflt_int; n = 0; p = 0
532+
call s_update_cell_bounds(cells_bounds, m, n, p)
528533
529534
cyl_coord = .false.
530535
@@ -809,6 +814,7 @@ contains
809814
! of fluids for which the physical and geometric curvatures of the
810815
! interfaces will be computed
811816
Re_size = 0
817+
Re_size_max = 0
812818
813819
! Gamma/Pi_inf Model
814820
if (model_eqns == 1) then
@@ -1036,13 +1042,15 @@ contains
10361042
if (Re_size(1) > 0._wp) shear_stress = .true.
10371043
if (Re_size(2) > 0._wp) bulk_stress = .true.
10381044
1039-
$:GPU_UPDATE(device='[Re_size,viscous,shear_stress,bulk_stress]')
1045+
Re_size_max = maxval(Re_size)
1046+
1047+
$:GPU_UPDATE(device='[Re_size,Re_size_max,viscous,shear_stress,bulk_stress]')
10401048
10411049
! Bookkeeping the indexes of any viscous fluids and any pairs of
10421050
! fluids whose interface will support effects of surface tension
10431051
if (viscous) then
10441052
1045-
@:ALLOCATE(Re_idx(1:2, 1:maxval(Re_size)))
1053+
@:ALLOCATE(Re_idx(1:2, 1:Re_size_max))
10461054
10471055
k = 0
10481056
do i = 1, num_fluids
@@ -1169,8 +1177,6 @@ contains
11691177
if (ib) allocate (MPI_IO_IB_DATA%var%sf(0:m, 0:n, 0:p))
11701178
Np = 0
11711179
1172-
$:GPU_UPDATE(device='[Re_size]')
1173-
11741180
if (elasticity) then
11751181
fd_number = max(1, fd_order/2)
11761182
end if

src/simulation/m_mpi_proxy.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ contains
6262
& (m + 2*gp_layers + 1)* &
6363
& (n + 2*gp_layers + 1)* &
6464
& (p + 2*gp_layers + 1)/ &
65-
& (min(m, n, p) + 2*gp_layers + 1)
65+
& (cells_bounds%mnp_min + 2*gp_layers + 1)
6666
else
6767
i_halo_size = -1 + gp_layers* &
68-
& (max(m, n) + 2*gp_layers + 1)
68+
& (cells_bounds%mn_max + 2*gp_layers + 1)
6969
end if
7070
else
7171
i_halo_size = -1 + gp_layers

0 commit comments

Comments
 (0)