@@ -40,18 +40,27 @@ module m_mpi_common
4040 integer (kind= 8 ) :: halo_size
4141 $:GPU_DECLARE(create= ' [halo_size]' )
4242
43+ logical , private :: exchange_all_chemistry_temperatures
44+ logical , private :: use_rdma_transport
45+
4346contains
4447
4548 !> Initialize the module.
46- impure subroutine s_initialize_mpi_common_module
49+ impure subroutine s_initialize_mpi_common_module (exchange_all_chemistry_temperatures_in , use_rdma_transport_in )
50+
51+ logical , intent (in ) :: exchange_all_chemistry_temperatures_in
52+ logical , intent (in ) :: use_rdma_transport_in
53+
54+ exchange_all_chemistry_temperatures = exchange_all_chemistry_temperatures_in
55+ use_rdma_transport = use_rdma_transport_in
4756
4857#ifdef MFC_MPI
4958 ! Allocating buff_send/ recv and. Please note that for the sake of simplicity, both variables are provided sufficient storage
5059 ! to hold the largest buffer in the computational domain.
5160
5261 if (qbmm .and. .not. polytropic) then
5362 v_size = sys_size + 2 * nb* nnode
54- else if (chemistry .and. chem_params%diffusion) then
63+ else if (chemistry .and. ( chem_params%diffusion .or. exchange_all_chemistry_temperatures) ) then
5564 v_size = sys_size + 1
5665 else
5766 v_size = sys_size
@@ -311,7 +320,6 @@ contains
311320 Rc_min_glb = Rc_min_loc
312321 ccfl_max_glb = ccfl_max_loc
313322
314- #ifdef MFC_SIMULATION
315323#ifdef MFC_MPI
316324 block
317325 integer :: ierr
@@ -346,7 +354,6 @@ contains
346354 end if
347355
348356 if (bubbles_lagrange) bubs_glb = bubs_loc
349- #endif
350357#endif
351358
352359 end subroutine s_mpi_reduce_stability_criteria_extrema
@@ -564,14 +571,10 @@ contains
564571 v_size = nVar + 2 * nb* nnode
565572 buffer_counts = (/ buff_size* v_size* (n + 1 )* (p + 1 ), buff_size* v_size* (m + 2 * buff_size + 1 )* (p + 1 ), &
566573 & buff_size* v_size* (m + 2 * buff_size + 1 )* (n + 2 * buff_size + 1 )/ )
567- #ifdef MFC_SIMULATION
568- else if (present (q_T_sf) .and. chemistry .and. chem_params%diffusion) then
569- #else
570- else if (present (q_T_sf) .and. chemistry) then
571- ! post_process converts cons- >prim over the ghost- inclusive bounds, so the temperature
572- ! Newton guess must be valid at rank seams for EVERY chemistry run (not only diffusion):
574+ else if (present (q_T_sf) .and. chemistry .and. (chem_params%diffusion .or. exchange_all_chemistry_temperatures)) then
575+ ! Consumers that convert over ghost- inclusive bounds request temperature exchange for every chemistry run.
576+ ! The temperature Newton guess must be valid at rank seams even when diffusion is disabled:
573577 ! an unexchanged seam ghost is an uninitialized guess - > NaN T/ pres/ c in the output
574- #endif
575578 chem_diff_comm = .true.
576579 v_size = nVar + 1
577580 buffer_counts = (/ buff_size* v_size* (n + 1 )* (p + 1 ), buff_size* v_size* (m + 2 * buff_size + 1 )* (p + 1 ), &
@@ -800,9 +803,8 @@ contains
800803 call nvtxEndRange ! Packbuf
801804
802805 ! Send/ Recv
803- #ifdef MFC_SIMULATION
804806 #:for rdma_mpi in [False, True]
805- if (rdma_mpi .eqv. ${' .true.' if rdma_mpi else ' .false.' }$) then
807+ if (use_rdma_transport .eqv. ${' .true.' if rdma_mpi else ' .false.' }$) then
806808 #:if rdma_mpi
807809 #:call GPU_HOST_DATA(use_device_addr= ' [buff_send, buff_recv]' )
808810 call nvtxStartRange(" RHS-COMM-SENDRECV-RDMA" )
@@ -830,10 +832,6 @@ contains
830832 #:endif
831833 end if
832834 #:endfor
833- #else
834- call MPI_SENDRECV(buff_send, buffer_count, mpi_p, dst_proc, send_tag, buff_recv, buffer_count, mpi_p, src_proc, recv_tag, &
835- & MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierr)
836- #endif
837835
838836 ! Unpack Received Buffer
839837 call nvtxStartRange(" RHS-COMM-UNPACKBUF" )
@@ -1190,9 +1188,8 @@ contains
11901188 call nvtxEndRange ! Packbuf
11911189
11921190 ! Send/ Recv
1193- #ifdef MFC_SIMULATION
11941191 #:for rdma_mpi in [False, True]
1195- if (rdma_mpi .eqv. ${' .true.' if rdma_mpi else ' .false.' }$) then
1192+ if (use_rdma_transport .eqv. ${' .true.' if rdma_mpi else ' .false.' }$) then
11961193 #:if rdma_mpi
11971194 #:call GPU_HOST_DATA(use_device_addr= ' [buff_send, buff_recv]' )
11981195 call nvtxStartRange(" BETA-COMM-SENDRECV-RDMA" )
@@ -1220,10 +1217,6 @@ contains
12201217 #:endif
12211218 end if
12221219 #:endfor
1223- #else
1224- call MPI_SENDRECV(buff_send, buffer_count, mpi_p, dst_proc, send_tag, buff_recv, buffer_count, mpi_p, src_proc, recv_tag, &
1225- & MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierr)
1226- #endif
12271220
12281221 ! Unpack Received Buffer (skip if no source rank)
12291222 call nvtxStartRange(" BETA-COMM-UNPACKBUF" )
0 commit comments