Decode 1 integer (64 bits) Morton's code into 3 integer (16 bits) indexes.
Due to 64 bits limit of the Morton's code, the 3 allowed-side of indexes is limited to 21 bits.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I8P), | intent(in) | :: | code | Morton's code. |
||
| integer(kind=I4P), | intent(inout) | :: | i | I index. |
||
| integer(kind=I4P), | intent(inout) | :: | j | J index. |
||
| integer(kind=I4P), | intent(inout) | :: | k | K index. |
||
| integer(kind=I2P), | intent(in), | optional | :: | b | Number of significant bits of 'i' (2/4/8/16). |
elemental subroutine demorton3D(code, i, j, k, b)
!---------------------------------------------------------------------------------------------------------------------------------
!< Decode 1 integer (64 bits) Morton's code into 3 integer (16 bits) indexes.
!<
!< @note Due to 64 bits limit of the Morton's code, the 3 allowed-side of indexes is limited to 21 bits.
!---------------------------------------------------------------------------------------------------------------------------------
integer(I8P), intent(in) :: code !< Morton's code.
integer(I4P), intent(inout) :: i !< I index.
integer(I4P), intent(inout) :: j !< J index.
integer(I4P), intent(inout) :: k !< K index.
integer(I2P), intent(in), optional :: b !< Number of significant bits of 'i' (2/4/8/16).
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (present(b)) then
call contract(i=code, b=b, z=2_I1P, c=i)
call contract(i=ishft(code,-1), b=b, z=2_I1P, c=j)
call contract(i=ishft(code,-2), b=b, z=2_I1P, c=k)
else
call contract(i=code, b=32_I2P, z=2_I1P, c=i)
call contract(i=ishft(code,-1), b=32_I2P, z=2_I1P, c=j)
call contract(i=ishft(code,-2), b=32_I2P, z=2_I1P, c=k)
endif
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine demorton3D