併存対応のため mpi_context と rank/size の両方を受け、最終的なrank/sizeを解決する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(out) | :: | local_rank | |||
| integer(kind=i32), | intent(out) | :: | n_ranks | |||
| integer(kind=i32), | intent(in), | optional | :: | mpi_rank | ||
| integer(kind=i32), | intent(in), | optional | :: | mpi_size | ||
| type(mpi_context), | intent(in), | optional | :: | mpi | ||
| character(len=*), | intent(in) | :: | caller_name |
subroutine resolve_parallel_rank_size(local_rank, n_ranks, mpi_rank, mpi_size, mpi, caller_name) integer(i32), intent(out) :: local_rank, n_ranks integer(i32), intent(in), optional :: mpi_rank, mpi_size type(mpi_context), intent(in), optional :: mpi character(len=*), intent(in) :: caller_name call mpi_get_rank_size(local_rank, n_ranks, mpi) if (present(mpi_rank)) local_rank = mpi_rank if (present(mpi_size)) n_ranks = mpi_size if (n_ranks <= 0_i32) error stop 'mpi_size must be > 0 in '//trim(caller_name)//'.' if (local_rank < 0_i32 .or. local_rank >= n_ranks) then error stop 'mpi_rank is out of range in '//trim(caller_name)//'.' end if end subroutine resolve_parallel_rank_size