subroutine comm_setup() ! internal character(len=*), parameter :: this_procedure = 'comm_setup' character(len=128) :: msg #ifdef MPI integer :: ierr, rank_local, size_local logical :: mpi_is_initialized call MPI_Initialized(mpi_is_initialized, ierr) if (.not. mpi_is_initialized) then call MPI_Init(ierr) if (ierr /= MPI_SUCCESS) call stop_error("Error initializing MPI", this_module, this_procedure) end if call MPI_Comm_rank(MPI_COMM_WORLD, rank_local, ierr) call MPI_Comm_size(MPI_COMM_WORLD, size_local, ierr) call set_rank(rank_local) call set_comm_size(size_local) if (rank_local==0) then call logger%log_message('Setup parallel run', this_module, this_procedure) write (msg, '(A,I0,A,I0)') 'comm_size = ', size_local call logger%log_message(trim(msg), this_module, this_procedure) end if #else call set_rank(0) call set_comm_size(1) call logger%log_message('Setup serial run', this_module, this_procedure) #endif end subroutine comm_setup