mpi_context から rank/size を取得する。未指定時は単一rank(0/1)。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(out) | :: | rank | |||
| integer(kind=i32), | intent(out) | :: | size | |||
| type(mpi_context), | intent(in), | optional | :: | ctx |
subroutine mpi_get_rank_size(rank, size, ctx) integer(i32), intent(out) :: rank, size type(mpi_context), intent(in), optional :: ctx rank = 0_i32 size = 1_i32 if (present(ctx)) then rank = ctx%rank size = max(1_i32, ctx%size) end if if (rank < 0_i32 .or. rank >= size) then error stop 'mpi_get_rank_size detected an invalid rank/size pair.' end if end subroutine mpi_get_rank_size