Check if we have reached steady state, i.e. current and new board match
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(out) | :: | steady_state |
Logical to indicate whether current and new board match |
||
| integer, | intent(in), | dimension(:,:) | :: | current_board |
The board as it currently is before this iteration |
|
| integer, | intent(in), | dimension(:,:) | :: | new_board |
The board into which the new state has been stored after this iteration |
subroutine check_for_steady_state(steady_state, current_board, new_board) !> Logical to indicate whether current and new board match logical, intent(out) :: steady_state !> The board as it currently is before this iteration integer, dimension(:,:), intent(in) :: current_board !> The board into which the new state has been stored after this iteration integer, dimension(:,:), intent(in) :: new_board integer :: nrows, ncols, row, col nrows = size(current_board, 1) ncols = size(current_board, 2) steady_state = .true. do col = 2, ncols-1 do row = 2, nrows-1 if (current_board(row, col) /= new_board(row, col)) then steady_state = .false. end if end do end do end subroutine check_for_steady_state