check_for_steady_state Subroutine

public subroutine check_for_steady_state(steady_state, current_board, new_board)

Check if we have reached steady state, i.e. current and new board match

Arguments

Type IntentOptional 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


Called by

proc~~check_for_steady_state~~CalledByGraph proc~check_for_steady_state check_for_steady_state proc~find_steady_state find_steady_state proc~find_steady_state->proc~check_for_steady_state program~main main program~main->proc~find_steady_state

Source Code

    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