ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
xgetImageStatMPI.F90
Go to the documentation of this file.
1
49 use mpi !mpi_f08, only : mpi_initialized, mpi_comm_world, mpi_comm_size, mpi_init
50 implicit none
51 logical :: isinit
52 logical :: isfinit
53 integer :: ierrMPI
54 integer :: imageRank = -1
55 integer :: imageCount = 0
56 imageCountMPI_block: block
57 call mpi_finalized(isfinit, ierrMPI)
58 if (isfinit) error stop "@xgetImageStatMPI(): Error occurred. A finalized MPI library cannot be reinitialized."
59 call mpi_initialized(isinit, ierrMPI)
60 if (ierrMPI /= 0) exit imageCountMPI_block
61 if (.not. isinit) then
62 call mpi_init(ierrMPI)
63 if (ierrMPI /= 0) exit imageCountMPI_block
64 end if
65 call mpi_comm_size(mpi_comm_world, imageCount, ierrMPI)
66 if (ierrMPI /= 0) imageCount = 0
67 call mpi_comm_rank(mpi_comm_world, imageRank, ierrMPI)
68 if (ierrMPI /= 0) imageRank = -1
69 imageRank = imageRank + 1
70 end block imageCountMPI_block
71 ! All images report their rank and the MPI image count.
72 ! The current bash process is responsible for capturing it.
73 write(*, "(*(g0))") "imageCountRank", imageCount, "imageCountRank", imageRank, "imageCountRank"
74 !call mpi_finalize(ierrMPI)
75end program xgetImageStatMPI
program xgetImageStatMPI
This program contains instructions to determine the number of MPI-parallel processes and MPI image ra...