@@ -27,8 +27,6 @@ module m_boundary_common
2727 type(scalar_field), dimension (:, :), allocatable :: bc_buffers
2828 !$acc declare create(bc_buffers)
2929
30- real (wp) :: bcxb, bcxe, bcyb, bcye, bczb, bcze
31-
3230#ifdef MFC_MPI
3331 integer , dimension (1 :3 , - 1 :1 ) :: MPI_BC_TYPE_TYPE, MPI_BC_BUFFER_TYPE
3432#endif
@@ -42,9 +40,10 @@ module m_boundary_common
4240 s_read_serial_boundary_condition_files, &
4341 s_read_parallel_boundary_condition_files, &
4442 s_assign_default_bc_type, &
43+ s_populate_grid_variables_buffers, &
4544 s_finalize_boundary_common_module
4645
47- public :: bc_buffers, bcxb, bcxe, bcyb, bcye, bczb, bcze
46+ public :: bc_buffers
4847
4948#ifdef MFC_MPI
5049 public :: MPI_BC_TYPE_TYPE, MPI_BC_BUFFER_TYPE
@@ -54,8 +53,6 @@ contains
5453
5554 subroutine s_initialize_boundary_common_module ()
5655
57- bcxb = bc_x%beg; bcxe = bc_x%end; bcyb = bc_y%beg; bcye = bc_y%end; bczb = bc_z%beg; bcze = bc_z%end
58-
5956 @:ALLOCATE(bc_buffers(1 :num_dims, - 1 :1 ))
6057
6158 if (bc_io) then
@@ -89,7 +86,7 @@ contains
8986 integer :: k, l
9087
9188 ! Population of Buffers in x- direction
92- if (bcxb >= 0 ) then
89+ if (bc_x%beg >= 0 ) then
9390 call s_mpi_sendrecv_variables_buffers(q_prim_vf, 1 , - 1 , sys_size, pb, mv)
9491 else
9592 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -113,7 +110,7 @@ contains
113110 end do
114111 end if
115112
116- if (bcxe >= 0 ) then
113+ if (bc_x%end >= 0 ) then
117114 call s_mpi_sendrecv_variables_buffers(q_prim_vf, 1 , 1 , sys_size, pb, mv)
118115 else
119116 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -141,7 +138,7 @@ contains
141138
142139 if (n == 0 ) return
143140
144- if (bcyb >= 0 ) then
141+ if (bc_y%beg >= 0 ) then
145142 call s_mpi_sendrecv_variables_buffers(q_prim_vf, 2 , - 1 , sys_size, pb, mv)
146143 else
147144 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -167,7 +164,7 @@ contains
167164 end do
168165 end if
169166
170- if (bcye >= 0 ) then
167+ if (bc_y%end >= 0 ) then
171168 call s_mpi_sendrecv_variables_buffers(q_prim_vf, 2 , 1 , sys_size, pb, mv)
172169 else
173170 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -195,7 +192,7 @@ contains
195192
196193 if (p == 0 ) return
197194
198- if (bczb >= 0 ) then
195+ if (bc_z%beg >= 0 ) then
199196 call s_mpi_sendrecv_variables_buffers(q_prim_vf, 3 , - 1 , sys_size, pb, mv)
200197 else
201198 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -219,7 +216,7 @@ contains
219216 end do
220217 end if
221218
222- if (bcze >= 0 ) then
219+ if (bc_z%end >= 0 ) then
223220 call s_mpi_sendrecv_variables_buffers(q_prim_vf, 3 , 1 , sys_size, pb, mv)
224221 else
225222 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -1173,7 +1170,7 @@ contains
11731170 integer :: i, j, k, l
11741171
11751172 !< x- direction
1176- if (bcxb >= 0 ) then
1173+ if (bc_x%beg >= 0 ) then
11771174 call s_mpi_sendrecv_variables_buffers(c_divs, 1 , - 1 , num_dims + 1 )
11781175 else
11791176 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -1191,7 +1188,7 @@ contains
11911188 end do
11921189 end if
11931190
1194- if (bcxe >= 0 ) then
1191+ if (bc_x%end >= 0 ) then
11951192 call s_mpi_sendrecv_variables_buffers(c_divs, 1 , 1 , num_dims + 1 )
11961193 else
11971194 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -1212,7 +1209,7 @@ contains
12121209 if (n == 0 ) return
12131210
12141211 !< y- direction
1215- if (bcyb >= 0 ) then
1212+ if (bc_y%beg >= 0 ) then
12161213 call s_mpi_sendrecv_variables_buffers(c_divs, 2 , - 1 , num_dims + 1 )
12171214 else
12181215 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -1230,7 +1227,7 @@ contains
12301227 end do
12311228 end if
12321229
1233- if (bcye >= 0 ) then
1230+ if (bc_y%end >= 0 ) then
12341231 call s_mpi_sendrecv_variables_buffers(c_divs, 2 , 1 , num_dims + 1 )
12351232 else
12361233 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -1251,7 +1248,7 @@ contains
12511248 if (p == 0 ) return
12521249
12531250 !< z- direction
1254- if (bczb >= 0 ) then
1251+ if (bc_z%beg >= 0 ) then
12551252 call s_mpi_sendrecv_variables_buffers(c_divs, 3 , - 1 , num_dims + 1 )
12561253 else
12571254 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -1269,7 +1266,7 @@ contains
12691266 end do
12701267 end if
12711268
1272- if (bcze >= 0 ) then
1269+ if (bc_z%end >= 0 ) then
12731270 call s_mpi_sendrecv_variables_buffers(c_divs, 3 , 1 , num_dims + 1 )
12741271 else
12751272 !$acc parallel loop collapse(2 ) gang vector default(present)
@@ -1790,6 +1787,195 @@ contains
17901787
17911788 end subroutine s_assign_default_bc_type
17921789
1790+ #ifndef MFC_PRE_PROCESS
1791+ !> The purpose of this subroutine is to populate the buffers
1792+ !! of the grid variables, which are constituted of the cell-
1793+ !! boundary locations and cell- width distributions, based on
1794+ !! the boundary conditions.
1795+ subroutine s_populate_grid_variables_buffers
1796+
1797+ integer :: i !< Generic loop iterator
1798+
1799+ #ifndef MFC_POST_PROCESS
1800+ ! Required for compatibiliy between codes
1801+ type(int_bounds_info) :: offset_x, offset_y, offset_z
1802+ offset_x%beg = buff_size; offset_x%end = buff_size
1803+ offset_y%beg = buff_size; offset_y%end = buff_size
1804+ offset_z%beg = buff_size; offset_z%end = buff_size
1805+ #endif
1806+
1807+ ! Population of Buffers in x- direction
1808+
1809+ ! Populating cell- width distribution buffer at bc_x%beg
1810+ if (bc_x%beg >= 0 ) then
1811+ call s_mpi_sendrecv_grid_variables_buffers(1 , - 1 )
1812+ elseif (bc_x%beg <= BC_GHOST_EXTRAP) then
1813+ do i = 1 , buff_size
1814+ dx(- i) = dx(0 )
1815+ end do
1816+ elseif (bc_x%beg == BC_REFLECTIVE) then
1817+ do i = 1 , buff_size
1818+ dx(- i) = dx(i - 1 )
1819+ end do
1820+ elseif (bc_x%beg == BC_PERIODIC) then
1821+ do i = 1 , buff_size
1822+ dx(- i) = dx(m - (i - 1 ))
1823+ end do
1824+ endif
1825+
1826+ ! Computing the cell- boundary and center locations buffer at bc_x%beg
1827+ do i = 1 , offset_x%beg
1828+ x_cb(- 1 - i) = x_cb(- i) - dx(- i)
1829+ enddo
1830+
1831+ do i = 1 , buff_size
1832+ x_cc(- i) = x_cc(1 - i) - (dx(1 - i) + dx(- i))/ 2._wp
1833+ end do
1834+
1835+ ! Populating the cell- width distribution buffer at bc_x%end
1836+ if (bc_x%end >= 0 ) then
1837+ call s_mpi_sendrecv_grid_variables_buffers(1 , 1 )
1838+ elseif (bc_x%end <= BC_GHOST_EXTRAP) then
1839+ do i = 1 , buff_size
1840+ dx(m + i) = dx(m)
1841+ end do
1842+ elseif (bc_x%end == BC_REFLECTIVE) then
1843+ do i = 1 , buff_size
1844+ dx(m + i) = dx(m - (i - 1 ))
1845+ end do
1846+ elseif (bc_x%end == BC_PERIODIC) then
1847+ do i = 1 , buff_size
1848+ dx(m + i) = dx(i - 1 )
1849+ end do
1850+ endif
1851+
1852+ ! Populating the cell- boundary and center locations buffer at bc_x%end
1853+ do i = 1 , offset_x%end
1854+ x_cb(m + i) = x_cb(m + (i - 1 )) + dx(m + i)
1855+ end do
1856+
1857+ do i = 1 , buff_size
1858+ x_cc(m + i) = x_cc(m + (i - 1 )) + (dx(m + (i - 1 )) + dx(m + i))/ 2._wp
1859+ enddo
1860+ ! END: Population of Buffers in x- direction
1861+
1862+ ! Population of Buffers in y- direction
1863+
1864+ ! Populating cell- width distribution buffer at bc_y%beg
1865+ if (n == 0 ) then
1866+ return
1867+ elseif (bc_y%beg >= 0 ) then
1868+ call s_mpi_sendrecv_grid_variables_buffers(2 , - 1 )
1869+ elseif (bc_y%beg <= BC_GHOST_EXTRAP .and. bc_y%beg /= BC_AXIS) then
1870+ do i = 1 , buff_size
1871+ dy(- i) = dy(0 )
1872+ end do
1873+ elseif (bc_y%beg == BC_REFLECTIVE .or. bc_y%beg == BC_AXIS) then
1874+ do i = 1 , buff_size
1875+ dy(- i) = dy(i - 1 )
1876+ end do
1877+ elseif (bc_y%beg == BC_PERIODIC) then
1878+ do i = 1 , buff_size
1879+ dy(- i) = dy(n - (i - 1 ))
1880+ end do
1881+ endif
1882+
1883+ ! Computing the cell- boundary and center locations buffer at bc_y%beg
1884+ do i = 1 , offset_y%beg
1885+ y_cb(- 1 - i) = y_cb(- i) - dy(- i)
1886+ enddo
1887+
1888+ do i = 1 , buff_size
1889+ y_cc(- i) = y_cc(1 - i) - (dy(1 - i) + dy(- i))/ 2._wp
1890+ enddo
1891+
1892+ ! Populating the cell- width distribution buffer at bc_y%end
1893+ if (bc_y%end >= 0 ) then
1894+ call s_mpi_sendrecv_grid_variables_buffers(2 , 1 )
1895+ elseif (bc_y%end <= BC_GHOST_EXTRAP) then
1896+ do i = 1 , buff_size
1897+ dy(n + i) = dy(n)
1898+ end do
1899+ elseif (bc_y%end == BC_REFLECTIVE) then
1900+ do i = 1 , buff_size
1901+ dy(n + i) = dy(n - (i - 1 ))
1902+ end do
1903+ elseif (bc_y%end == BC_PERIODIC) then
1904+ do i = 1 , buff_size
1905+ dy(n + i) = dy(i - 1 )
1906+ end do
1907+ endif
1908+
1909+ ! Populating the cell- boundary and center locations buffer at bc_y%end
1910+ do i = 1 , offset_y%end
1911+ y_cb(n + i) = y_cb(n + (i - 1 )) + dy(n + i)
1912+ enddo
1913+
1914+ do i = 1 , buff_size
1915+ y_cc(n + i) = y_cc(n + (i - 1 )) + (dy(n + (i - 1 )) + dy(n + i))/ 2._wp
1916+ end do
1917+ ! END: Population of Buffers in y- direction
1918+
1919+ ! Population of Buffers in z- direction
1920+
1921+ ! Populating cell- width distribution buffer at bc_z%beg
1922+ if (p == 0 ) then
1923+ return
1924+ elseif (Bc_z%beg >= 0 ) then
1925+ call s_mpi_sendrecv_grid_variables_buffers(3 , - 1 )
1926+ elseif (bc_z%beg <= BC_GHOST_EXTRAP) then
1927+ do i = 1 , buff_size
1928+ dz(- i) = dz(0 )
1929+ end do
1930+ elseif (bc_z%beg == BC_REFLECTIVE) then
1931+ do i = 1 , buff_size
1932+ dz(- i) = dz(i - 1 )
1933+ end do
1934+ elseif (bc_z%beg == BC_PERIODIC) then
1935+ do i = 1 , buff_size
1936+ dz(- i) = dz(p - (i - 1 ))
1937+ end do
1938+ endif
1939+
1940+ ! Computing the cell- boundary and center locations buffer at bc_z%beg
1941+ do i = 1 , offset_z%beg
1942+ z_cb(- 1 - i) = z_cb(- i) - dz(- i)
1943+ enddo
1944+
1945+ do i = 1 , buff_size
1946+ z_cc(- i) = z_cc(1 - i) - (dz(1 - i) + dz(- i))/ 2._wp
1947+ enddo
1948+
1949+ ! Populating the cell- width distribution buffer at bc_z%end
1950+ if (bc_z%end >= 0 ) then
1951+ call s_mpi_sendrecv_grid_variables_buffers(3 , 1 )
1952+ elseif (bc_z%end <= BC_GHOST_EXTRAP) then
1953+ do i = 1 , buff_size
1954+ dz(p + i) = dz(p)
1955+ end do
1956+ elseif (bc_z%end == BC_REFLECTIVE) then
1957+ do i = 1 , buff_size
1958+ dz(p + i) = dz(p - (i - 1 ))
1959+ end do
1960+ elseif (bc_z%end == BC_PERIODIC) then
1961+ do i = 1 , buff_size
1962+ dz(p + i) = dz(i - 1 )
1963+ end do
1964+ endif
1965+
1966+ ! Populating the cell- boundary and center locations buffer at bc_z%end
1967+ do i = 1 , buff_size
1968+ z_cb(p + i) = z_cb(p + (i - 1 )) + dz(p + i)
1969+ enddo
1970+
1971+ do i = 1 , buff_size
1972+ z_cc(p + i) = z_cc(p + (i - 1 )) + (dz(p + (i - 1 )) + dz(p + i))/ 2._wp
1973+ enddo
1974+ ! END: Population of Buffers in z- direction
1975+
1976+ end subroutine s_populate_grid_variables_buffers
1977+ #endif
1978+
17931979 subroutine s_finalize_boundary_common_module ()
17941980
17951981 if (bc_io) then
0 commit comments