@@ -2562,7 +2562,7 @@ contains
25622562#ifndef MFC_PRE_PROCESS
25632563 ! Populating cell- width distribution buffer at bc%x%beg
25642564 if (bc%x%beg >= 0 ) then
2565- call s_mpi_sendrecv_grid_variables_buffers(1 , - 1 )
2565+ if ( .not. parallel_io) call s_mpi_sendrecv_grid_variables_buffers(1 , - 1 )
25662566 else if (bc%x%beg <= BC_GHOST_EXTRAP) then
25672567 do i = 1 , buff_size
25682568 dx(- i) = dx(0 )
@@ -2577,18 +2577,21 @@ contains
25772577 end do
25782578 end if
25792579
2580- ! Computing the cell- boundary and center locations buffer at bc%x%beg
2581- do i = 1 , offset_x%beg
2582- x_cb(- 1 - i) = x_cb(- i) - dx(- i)
2583- end do
2580+ ! Computing the cell- boundary and center locations buffer at bc%x%beg. Skip when parallel_io has already filled the ghost
2581+ ! x_cb / x_cc bitwise from the global grid file via s_apply_grid_from_global_dim
2582+ if (.not. (bc%x%beg >= 0 .and. parallel_io)) then
2583+ do i = 1 , offset_x%beg
2584+ x_cb(- 1 - i) = x_cb(- i) - dx(- i)
2585+ end do
25842586
2585- do i = 1 , buff_size
2586- x_cc(- i) = x_cc(1 - i) - (dx(1 - i) + dx(- i))/ 2._wp
2587- end do
2587+ do i = 1 , buff_size
2588+ x_cc(- i) = x_cc(1 - i) - (dx(1 - i) + dx(- i))/ 2._wp
2589+ end do
2590+ end if
25882591
25892592 ! Populating the cell- width distribution buffer at bc%x%end
25902593 if (bc%x%end >= 0 ) then
2591- call s_mpi_sendrecv_grid_variables_buffers(1 , 1 )
2594+ if ( .not. parallel_io) call s_mpi_sendrecv_grid_variables_buffers(1 , 1 )
25922595 else if (bc%x%end <= BC_GHOST_EXTRAP) then
25932596 do i = 1 , buff_size
25942597 dx(m + i) = dx(m)
@@ -2603,20 +2606,22 @@ contains
26032606 end do
26042607 end if
26052608
2606- ! Populating the cell- boundary and center locations buffer at bc%x%end
2607- do i = 1 , offset_x%end
2608- x_cb(m + i) = x_cb(m + (i - 1 )) + dx(m + i)
2609- end do
2609+ ! Populating the cell- boundary and center locations buffer at bc%x%end. Skip when parallel_io has already filled the ghost.
2610+ if (.not. (bc%x%end >= 0 .and. parallel_io)) then
2611+ do i = 1 , offset_x%end
2612+ x_cb(m + i) = x_cb(m + (i - 1 )) + dx(m + i)
2613+ end do
26102614
2611- do i = 1 , buff_size
2612- x_cc(m + i) = x_cc(m + (i - 1 )) + (dx(m + (i - 1 )) + dx(m + i))/ 2._wp
2613- end do
2615+ do i = 1 , buff_size
2616+ x_cc(m + i) = x_cc(m + (i - 1 )) + (dx(m + (i - 1 )) + dx(m + i))/ 2._wp
2617+ end do
2618+ end if
26142619
26152620 ! Populating cell- width distribution buffer at bc%y%beg
26162621 if (n == 0 ) then
26172622 return
26182623 else if (bc%y%beg >= 0 ) then
2619- call s_mpi_sendrecv_grid_variables_buffers(2 , - 1 )
2624+ if ( .not. parallel_io) call s_mpi_sendrecv_grid_variables_buffers(2 , - 1 )
26202625 else if (bc%y%beg <= BC_GHOST_EXTRAP .and. bc%y%beg /= BC_AXIS) then
26212626 do i = 1 , buff_size
26222627 dy(- i) = dy(0 )
@@ -2631,18 +2636,20 @@ contains
26312636 end do
26322637 end if
26332638
2634- ! Computing the cell- boundary and center locations buffer at bc%y%beg
2635- do i = 1 , offset_y%beg
2636- y_cb(- 1 - i) = y_cb(- i) - dy(- i)
2637- end do
2639+ ! Computing the cell- boundary and center locations buffer at bc%y%beg. Skip when parallel_io has already filled the ghost.
2640+ if (.not. (bc%y%beg >= 0 .and. parallel_io)) then
2641+ do i = 1 , offset_y%beg
2642+ y_cb(- 1 - i) = y_cb(- i) - dy(- i)
2643+ end do
26382644
2639- do i = 1 , buff_size
2640- y_cc(- i) = y_cc(1 - i) - (dy(1 - i) + dy(- i))/ 2._wp
2641- end do
2645+ do i = 1 , buff_size
2646+ y_cc(- i) = y_cc(1 - i) - (dy(1 - i) + dy(- i))/ 2._wp
2647+ end do
2648+ end if
26422649
26432650 ! Populating the cell- width distribution buffer at bc%y%end
26442651 if (bc%y%end >= 0 ) then
2645- call s_mpi_sendrecv_grid_variables_buffers(2 , 1 )
2652+ if ( .not. parallel_io) call s_mpi_sendrecv_grid_variables_buffers(2 , 1 )
26462653 else if (bc%y%end <= BC_GHOST_EXTRAP) then
26472654 do i = 1 , buff_size
26482655 dy(n + i) = dy(n)
@@ -2657,20 +2664,22 @@ contains
26572664 end do
26582665 end if
26592666
2660- ! Populating the cell- boundary and center locations buffer at bc%y%end
2661- do i = 1 , offset_y%end
2662- y_cb(n + i) = y_cb(n + (i - 1 )) + dy(n + i)
2663- end do
2667+ ! Populating the cell- boundary and center locations buffer at bc%y%end. Skip when parallel_io has already filled the ghost.
2668+ if (.not. (bc%y%end >= 0 .and. parallel_io)) then
2669+ do i = 1 , offset_y%end
2670+ y_cb(n + i) = y_cb(n + (i - 1 )) + dy(n + i)
2671+ end do
26642672
2665- do i = 1 , buff_size
2666- y_cc(n + i) = y_cc(n + (i - 1 )) + (dy(n + (i - 1 )) + dy(n + i))/ 2._wp
2667- end do
2673+ do i = 1 , buff_size
2674+ y_cc(n + i) = y_cc(n + (i - 1 )) + (dy(n + (i - 1 )) + dy(n + i))/ 2._wp
2675+ end do
2676+ end if
26682677
26692678 ! Populating cell- width distribution buffer at bc%z%beg
26702679 if (p == 0 ) then
26712680 return
26722681 else if (bc%z%beg >= 0 ) then
2673- call s_mpi_sendrecv_grid_variables_buffers(3 , - 1 )
2682+ if ( .not. parallel_io) call s_mpi_sendrecv_grid_variables_buffers(3 , - 1 )
26742683 else if (bc%z%beg <= BC_GHOST_EXTRAP) then
26752684 do i = 1 , buff_size
26762685 dz(- i) = dz(0 )
@@ -2685,18 +2694,20 @@ contains
26852694 end do
26862695 end if
26872696
2688- ! Computing the cell- boundary and center locations buffer at bc%z%beg
2689- do i = 1 , offset_z%beg
2690- z_cb(- 1 - i) = z_cb(- i) - dz(- i)
2691- end do
2697+ ! Computing the cell- boundary and center locations buffer at bc%z%beg. Skip when parallel_io has already filled the ghost.
2698+ if (.not. (bc%z%beg >= 0 .and. parallel_io)) then
2699+ do i = 1 , offset_z%beg
2700+ z_cb(- 1 - i) = z_cb(- i) - dz(- i)
2701+ end do
26922702
2693- do i = 1 , buff_size
2694- z_cc(- i) = z_cc(1 - i) - (dz(1 - i) + dz(- i))/ 2._wp
2695- end do
2703+ do i = 1 , buff_size
2704+ z_cc(- i) = z_cc(1 - i) - (dz(1 - i) + dz(- i))/ 2._wp
2705+ end do
2706+ end if
26962707
26972708 ! Populating the cell- width distribution buffer at bc%z%end
26982709 if (bc%z%end >= 0 ) then
2699- call s_mpi_sendrecv_grid_variables_buffers(3 , 1 )
2710+ if ( .not. parallel_io) call s_mpi_sendrecv_grid_variables_buffers(3 , 1 )
27002711 else if (bc%z%end <= BC_GHOST_EXTRAP) then
27012712 do i = 1 , buff_size
27022713 dz(p + i) = dz(p)
@@ -2711,14 +2722,16 @@ contains
27112722 end do
27122723 end if
27132724
2714- ! Populating the cell- boundary and center locations buffer at bc%z%end
2715- do i = 1 , offset_z%end
2716- z_cb(p + i) = z_cb(p + (i - 1 )) + dz(p + i)
2717- end do
2725+ ! Populating the cell- boundary and center locations buffer at bc%z%end. Skip when parallel_io has already filled the ghost.
2726+ if (.not. (bc%z%end >= 0 .and. parallel_io)) then
2727+ do i = 1 , offset_z%end
2728+ z_cb(p + i) = z_cb(p + (i - 1 )) + dz(p + i)
2729+ end do
27182730
2719- do i = 1 , buff_size
2720- z_cc(p + i) = z_cc(p + (i - 1 )) + (dz(p + (i - 1 )) + dz(p + i))/ 2._wp
2721- end do
2731+ do i = 1 , buff_size
2732+ z_cc(p + i) = z_cc(p + (i - 1 )) + (dz(p + (i - 1 )) + dz(p + i))/ 2._wp
2733+ end do
2734+ end if
27222735#endif
27232736
27242737 end subroutine s_populate_grid_variables_buffers
0 commit comments