Logical AND operation on two masks
@param[in] mask1 First boolean mask @param[in] mask2 Second boolean mask @return result_mask Combined mask with AND operation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(boolean_mask), | intent(in) | :: | mask1 | |||
| type(boolean_mask), | intent(in) | :: | mask2 |
function mask_and(mask1, mask2) result(result_mask) type(boolean_mask), intent(in) :: mask1, mask2 type(boolean_mask) :: result_mask logical, dimension(:), allocatable :: arr1, arr2, combined integer :: i if (mask1 % get_size() /= mask2 % get_size()) then error stop "masks must have the same size for AND operation" end if arr1 = mask1 % get_mask() arr2 = mask2 % get_mask() allocate (combined(size(arr1))) do i = 1, size(arr1) combined(i) = arr1(i) .and. arr2(i) end do call result_mask % new(combined) deallocate (arr1, arr2, combined) end function mask_and