@@ -1222,27 +1222,63 @@ contains
12221222 end do
12231223
12241224 ! Boundary condition at the beginning
1225- if (proc_coords(3) > 0 .or. (bc_z%beg == -1 .and. num_procs_z > 1)) then
1225+ if (proc_coords(3) > 0 .or. (bc_z%beg == BC_PERIODIC .and. num_procs_z > 1)) then
12261226 proc_coords(3) = proc_coords(3) - 1
12271227 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, &
12281228 bc_z%beg, ierr)
12291229 proc_coords(3) = proc_coords(3) + 1
12301230 end if
12311231
12321232 ! Boundary condition at the end
1233- if (proc_coords(3) < num_procs_z - 1 .or. (bc_z%end == -1 .and. num_procs_z > 1)) then
1233+ if (proc_coords(3) < num_procs_z - 1 .or. (bc_z%end == BC_PERIODIC .and. num_procs_z > 1)) then
12341234 proc_coords(3) = proc_coords(3) + 1
12351235 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, &
12361236 bc_z%end, ierr)
12371237 proc_coords(3) = proc_coords(3) - 1
12381238 end if
12391239
1240+ #ifdef MFC_POST_PROCESS
1241+ ! Ghost zone at the beginning
1242+ if (proc_coords(3) > 0 .and. format == 1) then
1243+ offset_z%beg = 2
1244+ else
1245+ offset_z%beg = 0
1246+ end if
1247+
1248+ ! Ghost zone at the end
1249+ if (proc_coords(3) < num_procs_z - 1 .and. format == 1) then
1250+ offset_z%end = 2
1251+ else
1252+ offset_z%end = 0
1253+ end if
1254+ #endif
1255+
1256+ ! Beginning and end sub-domain boundary locations
12401257 if (parallel_io) then
12411258 if (proc_coords(3) < rem_cells) then
12421259 start_idx(3) = (p + 1)*proc_coords(3)
12431260 else
12441261 start_idx(3) = (p + 1)*proc_coords(3) + rem_cells
12451262 end if
1263+ else
1264+ #ifdef MFC_PRE_PROCESS
1265+ if (old_grid .neqv. .true.) then
1266+ dz = (z_domain%end - z_domain%beg)/real(p_glb + 1, wp)
1267+
1268+ if (proc_coords(3) < rem_cells) then
1269+ z_domain%beg = z_domain%beg + dz*real((p + 1)* &
1270+ proc_coords(3))
1271+ z_domain%end = z_domain%end - dz*real((p + 1)* &
1272+ (num_procs_z - proc_coords(3) - 1) &
1273+ - (num_procs_z - rem_cells))
1274+ else
1275+ z_domain%beg = z_domain%beg + dz*real((p + 1)* &
1276+ proc_coords(3) + rem_cells)
1277+ z_domain%end = z_domain%end - dz*real((p + 1)* &
1278+ (num_procs_z - proc_coords(3) - 1))
1279+ end if
1280+ end if
1281+ #endif
12461282 end if
12471283
12481284 ! 2D Cartesian Processor Topology
@@ -1325,27 +1361,63 @@ contains
13251361 end do
13261362
13271363 ! Boundary condition at the beginning
1328- if (proc_coords(2) > 0 .or. (bc_y%beg == -1 .and. num_procs_y > 1)) then
1364+ if (proc_coords(2) > 0 .or. (bc_y%beg == BC_PERIODIC .and. num_procs_y > 1)) then
13291365 proc_coords(2) = proc_coords(2) - 1
13301366 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, &
13311367 bc_y%beg, ierr)
13321368 proc_coords(2) = proc_coords(2) + 1
13331369 end if
13341370
13351371 ! Boundary condition at the end
1336- if (proc_coords(2) < num_procs_y - 1 .or. (bc_y%end == -1 .and. num_procs_y > 1)) then
1372+ if (proc_coords(2) < num_procs_y - 1 .or. (bc_y%end == BC_PERIODIC .and. num_procs_y > 1)) then
13371373 proc_coords(2) = proc_coords(2) + 1
13381374 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, &
13391375 bc_y%end, ierr)
13401376 proc_coords(2) = proc_coords(2) - 1
13411377 end if
13421378
1379+ #ifdef MFC_POST_PROCESS
1380+ ! Ghost zone at the beginning
1381+ if (proc_coords(2) > 0 .and. format == 1) then
1382+ offset_y%beg = 2
1383+ else
1384+ offset_y%beg = 0
1385+ end if
1386+
1387+ ! Ghost zone at the end
1388+ if (proc_coords(2) < num_procs_y - 1 .and. format == 1) then
1389+ offset_y%end = 2
1390+ else
1391+ offset_y%end = 0
1392+ end if
1393+ #endif
1394+
1395+ ! Beginning and end sub-domain boundary locations
13431396 if (parallel_io) then
13441397 if (proc_coords(2) < rem_cells) then
13451398 start_idx(2) = (n + 1)*proc_coords(2)
13461399 else
13471400 start_idx(2) = (n + 1)*proc_coords(2) + rem_cells
13481401 end if
1402+ else
1403+ #ifdef MFC_PRE_PROCESS
1404+ if (old_grid .neqv. .true.) then
1405+ dy = (y_domain%end - y_domain%beg)/real(n_glb + 1, wp)
1406+
1407+ if (proc_coords(2) < rem_cells) then
1408+ y_domain%beg = y_domain%beg + dy*real((n + 1)* &
1409+ proc_coords(2))
1410+ y_domain%end = y_domain%end - dy*real((n + 1)* &
1411+ (num_procs_y - proc_coords(2) - 1) &
1412+ - (num_procs_y - rem_cells))
1413+ else
1414+ y_domain%beg = y_domain%beg + dy*real((n + 1)* &
1415+ proc_coords(2) + rem_cells)
1416+ y_domain%end = y_domain%end - dy*real((n + 1)* &
1417+ (num_procs_y - proc_coords(2) - 1))
1418+ end if
1419+ end if
1420+ #endif
13491421 end if
13501422
13511423 ! 1D Cartesian Processor Topology
@@ -1381,27 +1453,62 @@ contains
13811453 end do
13821454
13831455 ! Boundary condition at the beginning
1384- if (proc_coords(1) > 0 .or. (bc_x%beg == -1 .and. num_procs_x > 1)) then
1456+ if (proc_coords(1) > 0 .or. (bc_x%beg == BC_PERIODIC .and. num_procs_x > 1)) then
13851457 proc_coords(1) = proc_coords(1) - 1
13861458 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, bc_x%beg, ierr)
13871459 proc_coords(1) = proc_coords(1) + 1
13881460 end if
13891461
13901462 ! Boundary condition at the end
1391- if (proc_coords(1) < num_procs_x - 1 .or. (bc_x%end == -1 .and. num_procs_x > 1)) then
1463+ if (proc_coords(1) < num_procs_x - 1 .or. (bc_x%end == BC_PERIODIC .and. num_procs_x > 1)) then
13921464 proc_coords(1) = proc_coords(1) + 1
13931465 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, bc_x%end, ierr)
13941466 proc_coords(1) = proc_coords(1) - 1
13951467 end if
13961468
1469+ #ifdef MFC_POST_PROCESS
1470+ ! Ghost zone at the beginning
1471+ if (proc_coords(1) > 0 .and. format == 1 .and. n > 0) then
1472+ offset_x%beg = 2
1473+ else
1474+ offset_x%beg = 0
1475+ end if
1476+
1477+ ! Ghost zone at the end
1478+ if (proc_coords(1) < num_procs_x - 1 .and. format == 1 .and. n > 0) then
1479+ offset_x%end = 2
1480+ else
1481+ offset_x%end = 0
1482+ end if
1483+ #endif
1484+
1485+ ! Beginning and end sub-domain boundary locations
13971486 if (parallel_io) then
13981487 if (proc_coords(1) < rem_cells) then
13991488 start_idx(1) = (m + 1)*proc_coords(1)
14001489 else
14011490 start_idx(1) = (m + 1)*proc_coords(1) + rem_cells
14021491 end if
1492+ else
1493+ #ifdef MFC_PRE_PROCESS
1494+ if (old_grid .neqv. .true.) then
1495+ dx = (x_domain%end - x_domain%beg)/real(m_glb + 1, wp)
1496+
1497+ if (proc_coords(1) < rem_cells) then
1498+ x_domain%beg = x_domain%beg + dx*real((m + 1)* &
1499+ proc_coords(1))
1500+ x_domain%end = x_domain%end - dx*real((m + 1)* &
1501+ (num_procs_x - proc_coords(1) - 1) &
1502+ - (num_procs_x - rem_cells))
1503+ else
1504+ x_domain%beg = x_domain%beg + dx*real((m + 1)* &
1505+ proc_coords(1) + rem_cells)
1506+ x_domain%end = x_domain%end - dx*real((m + 1)* &
1507+ (num_procs_x - proc_coords(1) - 1))
1508+ end if
1509+ end if
1510+ #endif
14031511 end if
1404-
14051512#endif
14061513
14071514 end subroutine s_mpi_decompose_computational_domain
0 commit comments