count_adjacent Function

pure function count_adjacent(i, j) result(icount)

count the number of adjacent cells not a tree

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in) :: i
integer(kind=ip), intent(in) :: j

Return Value integer(kind=ip)


Calls

proc~~count_adjacent~~CallsGraph proc~count_adjacent problem_23::count_adjacent proc~not_tree problem_23::not_tree proc~count_adjacent->proc~not_tree

Called by

proc~~count_adjacent~~CalledByGraph proc~count_adjacent problem_23::count_adjacent proc~go~5 problem_23::go proc~go~5->proc~count_adjacent program~problem_23 problem_23 program~problem_23->proc~go~5

Source Code

    pure function count_adjacent(i,j) result(icount)
        !! count the number of adjacent cells not a tree
        integer(ip),intent(in) :: i,j
        integer(ip) :: icount
        icount = 0
        if (i>=1)     icount = icount + count([not_tree(i-1,j  )])
        if (i<=nrows) icount = icount + count([not_tree(i+1,j  )])
        if (j<=ncols) icount = icount + count([not_tree(i,  j+1)])
        if (j>=1)     icount = icount + count([not_tree(i,  j-1)])
    end function count_adjacent