count the number of adjacent cells not a tree
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ip), | intent(in) | :: | i | |||
| integer(kind=ip), | intent(in) | :: | j |
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