@@ -24,7 +24,7 @@ module m_mpi_common
2424
2525 implicit none
2626
27- integer, private :: ierr, v_size !<
27+ integer, private :: v_size
2828 $:GPU_DECLARE(create=' [v_size]' )
2929 !! Generic flags used to identify and report MPI errors
3030
@@ -88,6 +88,10 @@ contains
8888 !! available for the job and the local processor rank.
8989 impure subroutine s_mpi_initialize
9090
91+ #ifdef MFC_MPI
92+ integer :: ierr !< Generic flag used to identify and report MPI errors
93+ #endif
94+
9195#ifndef MFC_MPI
9296
9397 ! Serial run only has 1 processor
@@ -136,6 +140,7 @@ contains
136140
137141 ! Generic loop iterator
138142 integer :: i, j
143+ integer :: ierr !< Generic flag used to identify and report MPI errors
139144
140145 !Altered system size for the lagrangian subgrid bubble model
141146 integer :: alt_sys
@@ -284,15 +289,16 @@ contains
284289 integer, intent(in) :: root ! Rank of the root process
285290 real(wp), allocatable, intent(out) :: gathered_vector(:) ! Gathered vector on the root process
286291
287- integer :: i, local_ierr
292+ integer :: i
293+ integer :: ierr !< Generic flag used to identify and report MPI errors
288294 integer, allocatable :: recounts(:), displs(:)
289295
290296#ifdef MFC_MPI
291297
292298 allocate (recounts(num_procs))
293299
294300 call MPI_GATHER(counts, 1, MPI_INTEGER, recounts, 1, MPI_INTEGER, root, &
295- MPI_COMM_WORLD, local_ierr )
301+ MPI_COMM_WORLD, ierr )
296302
297303 allocate (displs(size(recounts)))
298304
@@ -304,7 +310,7 @@ contains
304310
305311 allocate (gathered_vector(sum(recounts)))
306312 call MPI_GATHERV(my_vector, counts, mpi_p, gathered_vector, recounts, displs, mpi_p, &
307- root, MPI_COMM_WORLD, local_ierr )
313+ root, MPI_COMM_WORLD, ierr )
308314#endif
309315 end subroutine s_mpi_gather_data
310316
@@ -314,6 +320,7 @@ contains
314320 real(wp), intent(inout) :: time_avg
315321
316322#ifdef MFC_MPI
323+ integer :: ierr !< Generic flag used to identify and report MPI errors
317324
318325 call MPI_GATHER(time_avg, 1, mpi_p, proc_time(0), 1, mpi_p, 0, MPI_COMM_WORLD, ierr)
319326
@@ -365,6 +372,7 @@ contains
365372
366373#ifdef MFC_SIMULATION
367374#ifdef MFC_MPI
375+ integer :: ierr !< Generic flag used to identify and report MPI errors
368376
369377 ! Reducing local extrema of ICFL, VCFL, CCFL and Rc numbers to their
370378 ! global extrema and bookkeeping the results on the rank 0 processor
@@ -408,6 +416,7 @@ contains
408416 real(wp), intent(out) :: var_glb
409417
410418#ifdef MFC_MPI
419+ integer :: ierr !< Generic flag used to identify and report MPI errors
411420
412421 ! Performing the reduction procedure
413422 call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, &
@@ -430,6 +439,7 @@ contains
430439 real(wp), intent(out) :: var_glb
431440
432441#ifdef MFC_MPI
442+ integer :: ierr !< Generic flag used to identify and report MPI errors
433443
434444 ! Performing the reduction procedure
435445 call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, &
@@ -452,6 +462,7 @@ contains
452462 real(wp), intent(out) :: var_glb
453463
454464#ifdef MFC_MPI
465+ integer :: ierr !< Generic flag used to identify and report MPI errors
455466
456467 ! Performing the reduction procedure
457468 call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, &
@@ -472,6 +483,7 @@ contains
472483 real(wp), intent(inout) :: var_loc
473484
474485#ifdef MFC_MPI
486+ integer :: ierr !< Generic flag used to identify and report MPI errors
475487
476488 ! Temporary storage variable that holds the reduced minimum value
477489 real(wp) :: var_glb
@@ -507,6 +519,7 @@ contains
507519 real(wp), dimension(2), intent(inout) :: var_loc
508520
509521#ifdef MFC_MPI
522+ integer :: ierr !< Generic flag used to identify and report MPI errors
510523
511524 real(wp), dimension(2) :: var_glb !<
512525 !! Temporary storage variable that holds the reduced maximum value
@@ -533,6 +546,10 @@ contains
533546 character(len=*), intent(in), optional :: prnt
534547 integer, intent(in), optional :: code
535548
549+ #ifdef MFC_MPI
550+ integer :: ierr !< Generic flag used to identify and report MPI errors
551+ #endif
552+
536553 if (present(prnt)) then
537554 print *, prnt
538555 call flush (6)
@@ -560,6 +577,7 @@ contains
560577 impure subroutine s_mpi_barrier
561578
562579#ifdef MFC_MPI
580+ integer :: ierr !< Generic flag used to identify and report MPI errors
563581
564582 ! Calling MPI_BARRIER
565583 call MPI_BARRIER(MPI_COMM_WORLD, ierr)
@@ -572,6 +590,7 @@ contains
572590 impure subroutine s_mpi_finalize
573591
574592#ifdef MFC_MPI
593+ integer :: ierr !< Generic flag used to identify and report MPI errors
575594
576595 ! Finalizing the MPI environment
577596 call MPI_FINALIZE(ierr)
@@ -609,6 +628,7 @@ contains
609628 integer :: pack_offset, unpack_offset
610629
611630#ifdef MFC_MPI
631+ integer :: ierr !< Generic flag used to identify and report MPI errors
612632
613633 call nvtxStartRange("RHS-COMM-PACKBUF")
614634
@@ -1058,6 +1078,7 @@ contains
10581078 integer :: recon_order !< reconstruction order
10591079
10601080 integer :: i, j !< Generic loop iterators
1081+ integer :: ierr !< Generic flag used to identify and report MPI errors
10611082
10621083 if (num_procs == 1 .and. parallel_io) then
10631084 do i = 1, num_dims
@@ -1532,6 +1553,7 @@ contains
15321553 integer, intent(in) :: pbc_loc
15331554
15341555#ifdef MFC_MPI
1556+ integer :: ierr !< Generic flag used to identify and report MPI errors
15351557
15361558 ! MPI Communication in x-direction
15371559 if (mpi_dir == 1) then
0 commit comments