demorton3D Subroutine

public elemental subroutine demorton3D(code, i, j, k, b)

Decode 1 integer (64 bits) Morton's code into 3 integer (16 bits) indexes.

Arguments

Type IntentOptional AttributesName
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).

Calls

proc~~demorton3d~~CallsGraph proc~demorton3d demorton3D proc~contract contract proc~demorton3d->proc~contract
Help

Called By

proc~~demorton3d~~CalledByGraph proc~demorton3d demorton3D proc~test_morton3d test_morton3D proc~test_morton3d->proc~demorton3d program~mortif_test_correctness mortif_test_correctness program~mortif_test_correctness->proc~test_morton3d
Help

Source Code


Source Code

  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