Skip to content

Commit 7eeaa84

Browse files
committed
Replace intrinsics in allocate
1 parent 3c80270 commit 7eeaa84

14 files changed

+136
-16
lines changed

src/common/m_mpi_common.fpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ contains
6161
& (m + 2*buff_size + 1)* &
6262
& (n + 2*buff_size + 1)* &
6363
& (p + 2*buff_size + 1)/ &
64-
& (min(m, n, p) + 2*buff_size + 1)
64+
& (mnp_min + 2*buff_size + 1)
6565
else
6666
halo_size = -1 + buff_size*(sys_size + 2*nb*4)* &
67-
& (max(m, n) + 2*buff_size + 1)
67+
& (mn_max + 2*buff_size + 1)
6868
end if
6969
else
7070
halo_size = -1 + buff_size*(sys_size + 2*nb*4)
@@ -76,10 +76,10 @@ contains
7676
& (m + 2*buff_size + 1)* &
7777
& (n + 2*buff_size + 1)* &
7878
& (p + 2*buff_size + 1)/ &
79-
& (min(m, n, p) + 2*buff_size + 1)
79+
& (mnp_min + 2*buff_size + 1)
8080
else
8181
halo_size = -1 + buff_size*sys_size* &
82-
& (max(m, n) + 2*buff_size + 1)
82+
& (mn_max + 2*buff_size + 1)
8383
end if
8484
else
8585
halo_size = -1 + buff_size*sys_size

src/common/m_variables_conversion.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ contains
657657
#ifdef MFC_SIMULATION
658658

659659
if (viscous) then
660-
@:ALLOCATE(Res(1:2, 1:maxval(Re_size)))
660+
@:ALLOCATE(Res(1:2, 1:Re_size_max))
661661
do i = 1, 2
662662
do j = 1, Re_size(i)
663663
Res(i, j) = fluid_pp(Re_idx(i, j))%Re(i)

src/post_process/m_global_parameters.fpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ 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+
!> @{
43+
integer :: mn_max, np_max, mp_max, mnp_max
44+
integer :: mn_min, np_min, mp_min, mnp_min
45+
!> @}
46+
47+
4148
integer(8) :: nGlobal ! Total number of cells in global domain
4249

4350
!> @name Cylindrical coordinates (either axisymmetric or full 3D)
@@ -333,6 +340,17 @@ contains
333340

334341
! Computational domain parameters
335342
m = dflt_int; n = 0; p = 0
343+
344+
! Update the min and max of the cells in each direction
345+
mn_max = max(m, n)
346+
np_max = max(n, p)
347+
mp_max = max(m, p)
348+
mnp_max = max(m, n, p)
349+
mn_min = min(m, n)
350+
np_min = min(n, p)
351+
mp_min = min(m, p)
352+
mnp_min = min(m, n, p)
353+
336354
m_root = dflt_int
337355
cyl_coord = .false.
338356

src/post_process/m_mpi_proxy.fpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,26 @@ contains
7070
(m + 2*buff_size + 1)* &
7171
(n + 2*buff_size + 1)* &
7272
(p + 2*buff_size + 1)/ &
73-
(min(m, n, p) &
73+
(mnp_min &
7474
+ 2*buff_size + 1) - 1))
7575
allocate (q_cons_buffer_out(0:buff_size* &
7676
sys_size* &
7777
(m + 2*buff_size + 1)* &
7878
(n + 2*buff_size + 1)* &
7979
(p + 2*buff_size + 1)/ &
80-
(min(m, n, p) &
80+
(mnp_min &
8181
+ 2*buff_size + 1) - 1))
8282
8383
! Simulation is 2D
8484
else
8585
8686
allocate (q_cons_buffer_in(0:buff_size* &
8787
sys_size* &
88-
(max(m, n) &
88+
(mn_max &
8989
+ 2*buff_size + 1) - 1))
9090
allocate (q_cons_buffer_out(0:buff_size* &
9191
sys_size* &
92-
(max(m, n) &
92+
(mn_max &
9393
+ 2*buff_size + 1) - 1))
9494
9595
end if
@@ -599,6 +599,16 @@ contains
599599
end if
600600
end do
601601
602+
! Update the min and max of the cells in each direction
603+
mn_max = max(m, n)
604+
np_max = max(n, p)
605+
mp_max = max(m, p)
606+
mnp_max = max(m, n, p)
607+
mn_min = min(m, n)
608+
np_min = min(n, p)
609+
mp_min = min(m, p)
610+
mnp_min = min(m, n, p)
611+
602612
! Boundary condition at the beginning
603613
if (proc_coords(1) > 0 .or. bc_x%beg == BC_PERIODIC) then
604614
proc_coords(1) = proc_coords(1) - 1

src/post_process/m_start_up.f90

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ subroutine s_read_input_file
106106
end if
107107

108108
close (1)
109+
110+
! Update the min and max of the cells in each direction
111+
mn_max = max(m, n)
112+
np_max = max(n, p)
113+
mp_max = max(m, p)
114+
mnp_max = max(m, n, p)
115+
mn_min = min(m, n)
116+
np_min = min(n, p)
117+
mp_min = min(m, p)
118+
mnp_min = min(m, n, p)
119+
120+
109121
! Store m,n,p into global m,n,p
110122
m_glb = m
111123
n_glb = n

src/pre_process/m_global_parameters.fpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ 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+
!> @{
45+
integer :: mn_max, np_max, mp_max, mnp_max
46+
integer :: mn_min, np_min, mp_min, mnp_min
47+
48+
!> @}
49+
50+
4351
integer(8) :: nGlobal !< Global number of cells in the domain
4452

4553
integer :: m_glb, n_glb, p_glb !< Global number of cells in each direction
@@ -302,7 +310,17 @@ contains
302310

303311
! Computational domain parameters
304312
m = dflt_int; n = 0; p = 0
305-
313+
314+
! Update the min and max of the cells in each direction
315+
mn_max = max(m, n)
316+
np_max = max(n, p)
317+
mp_max = max(m, p)
318+
mnp_max = max(m, n, p)
319+
mn_min = min(m, n)
320+
np_min = min(n, p)
321+
mp_min = min(m, p)
322+
mnp_min = min(m, n, p)
323+
306324
cyl_coord = .false.
307325

308326
x_domain%beg = dflt_real

src/pre_process/m_mpi_proxy.fpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,16 @@ contains
571571
end if
572572
end do
573573
574+
! Update the min and max of the cells in each direction
575+
mn_max = max(m, n)
576+
np_max = max(n, p)
577+
mp_max = max(m, p)
578+
mnp_max = max(m, n, p)
579+
mn_min = min(m, n)
580+
np_min = min(n, p)
581+
mp_min = min(m, p)
582+
mnp_min = min(m, n, p)
583+
574584
! Boundary condition at the beginning
575585
if (proc_coords(1) > 0 .or. (bc_x%beg == BC_PERIODIC .and. num_procs_x > 1)) then
576586
proc_coords(1) = proc_coords(1) - 1

src/pre_process/m_start_up.fpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ contains
169169
'likely due to a datatype mismatch. Exiting.')
170170
end if
171171
close (1)
172+
173+
! Update the min and max of the cells in each direction
174+
mn_max = max(m, n)
175+
np_max = max(n, p)
176+
mp_max = max(m, p)
177+
mnp_max = max(m, n, p)
178+
mn_min = min(m, n)
179+
np_min = min(n, p)
180+
mp_min = min(m, p)
181+
mnp_min = min(m, n, p)
182+
172183
! Store m,n,p into global m,n,p
173184
m_glb = m
174185
n_glb = n

src/simulation/m_global_parameters.fpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ 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+
!> @{
48+
integer :: mn_max, np_max, mp_max, mnp_max
49+
integer :: mn_min, np_min, mp_min, mnp_min
50+
51+
!> @}
52+
4653
!> @name Global number of cells in each direction
4754
!> @{
4855
integer :: m_glb, n_glb, p_glb
@@ -267,6 +274,7 @@ module m_global_parameters
267274
!! numbers, will be non-negligible.
268275
!> @{
269276
integer, dimension(2) :: Re_size
277+
integer :: Re_size_max
270278
integer, allocatable, dimension(:, :) :: Re_idx
271279
!> @}
272280

@@ -516,6 +524,16 @@ contains
516524
! Computational domain parameters
517525
m = dflt_int; n = 0; p = 0
518526
527+
! Update the min and max of the cells in each direction
528+
mn_max = max(m, n)
529+
np_max = max(n, p)
530+
mp_max = max(m, p)
531+
mnp_max = max(m, n, p)
532+
mn_min = min(m, n)
533+
np_min = min(n, p)
534+
mp_min = min(m, p)
535+
mnp_min = min(m, n, p)
536+
519537
cyl_coord = .false.
520538
521539
dt = dflt_real
@@ -1028,13 +1046,15 @@ contains
10281046
if (Re_size(1) > 0._wp) shear_stress = .true.
10291047
if (Re_size(2) > 0._wp) bulk_stress = .true.
10301048
1049+
Re_size_max = maxval(Re_size)
1050+
10311051
!$acc update device(Re_size, viscous, shear_stress, bulk_stress)
10321052
10331053
! Bookkeeping the indexes of any viscous fluids and any pairs of
10341054
! fluids whose interface will support effects of surface tension
10351055
if (viscous) then
10361056
1037-
@:ALLOCATE(Re_idx(1:2, 1:maxval(Re_size)))
1057+
@:ALLOCATE(Re_idx(1:2, 1:Re_size_max))
10381058
10391059
k = 0
10401060
do i = 1, num_fluids

src/simulation/m_mpi_proxy.fpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,17 @@ contains
552552
end if
553553
end do
554554
555+
! Update the min and max of the cells in each direction
556+
mn_max = max(m, n)
557+
np_max = max(n, p)
558+
mp_max = max(m, p)
559+
mnp_max = max(m, n, p)
560+
mn_min = min(m, n)
561+
np_min = min(n, p)
562+
mp_min = min(m, p)
563+
mnp_min = min(m, n, p)
564+
565+
555566
! Boundary condition at the beginning
556567
if (proc_coords(1) > 0 .or. (bc_x%beg == BC_PERIODIC .and. num_procs_x > 1)) then
557568
proc_coords(1) = proc_coords(1) - 1
@@ -780,10 +791,10 @@ contains
780791
& (m + 2*gp_layers + 1)* &
781792
& (n + 2*gp_layers + 1)* &
782793
& (p + 2*gp_layers + 1)/ &
783-
& (min(m, n, p) + 2*gp_layers + 1)))
794+
& (mnp_min + 2*gp_layers + 1)))
784795
else
785796
@:ALLOCATE(ib_buff_send(0:-1 + gp_layers* &
786-
& (max(m, n) + 2*gp_layers + 1)))
797+
& (mn_max + 2*gp_layers + 1)))
787798
end if
788799
else
789800
@:ALLOCATE(ib_buff_send(0:-1 + gp_layers))

0 commit comments

Comments
 (0)