Find which rank owns a given column
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | ncols |
Total number of columns |
||
| integer(kind=int32), | intent(in) | :: | nranks |
Total number of columns Number of MPI ranks |
||
| integer(kind=int32), | intent(in) | :: | col |
Total number of columns Number of MPI ranks Column index (0-indexed) |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int32), | private | :: | base_cols | ||||
| integer(kind=int32), | private | :: | boundary | ||||
| integer(kind=int32), | private | :: | extra |
pure function get_owner(ncols, nranks, col) result(owner) integer(int32), intent(in) :: ncols, nranks, col integer(int32) :: owner integer(int32) :: base_cols, extra, boundary base_cols = ncols/nranks extra = mod(ncols, nranks) ! Boundary where ranks switch from (base+1) to base columns boundary = extra*(base_cols + 1) if (col < boundary) then owner = col/(base_cols + 1) else owner = extra + (col - boundary)/base_cols end if end function get_owner