Mask a region within a given shape (for the moment an ellipsis)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I4), | intent(in) | :: | x0 |
mask shape center 1st coordinate |
||
integer(kind=I4), | intent(in) | :: | y0 |
mask shape center 2nd coordinate |
||
integer(kind=I4), | intent(in) | :: | a |
ellipsis semi-length |
||
integer(kind=I4), | intent(in) | :: | b |
ellipsis semi-height |
||
character(len=8), | intent(in) | :: | shap |
kind of mask shape |
||
integer(kind=I4), | intent(inout), | dimension(1:long, 1:larg) | :: | msk |
mask |
|
integer(kind=I4), | intent(in) | :: | long |
2D array length |
||
integer(kind=I4), | intent(in) | :: | larg |
2D array height |
subroutine make_mask(x0, y0, a, b, shap, msk, long, larg) !================================================================================================ !! Mask a region within a given shape (for the moment an ellipsis) !------------------------------------------------------------------------------------------------ implicit none integer (kind=I4), intent(in ) :: long !! *2D array length* integer (kind=I4), intent(in ) :: larg !! *2D array height* integer (kind=I4), intent(in ) :: x0 !! *mask shape center 1st coordinate* integer (kind=I4), intent(in ) :: y0 !! *mask shape center 2nd coordinate* integer (kind=I4), intent(in ) :: a !! *ellipsis semi-length* integer (kind=I4), intent(in ) :: b !! *ellipsis semi-height* character(len = 8), intent(in ) :: shap !! *kind of mask shape* integer (kind=I4), intent(inout), dimension(1:long, 1:larg) :: msk !! *mask* integer(kind=I4) :: i, j select case (shap) case('ellipsis') forall( i = 1:long, j = 1:larg, (real(i - x0, kind = R8) / a)**2 + (real(j - y0, kind = R8) / b)**2 < 1. ) msk(i, j) = 1 case default stop 'make_mask, bad choice' endselect return endsubroutine make_mask