Skip to content

mortif

MORTIF, MORTon Indexer (Z-order) Fortran environment.

A library to encode/decode integer indexes into Morton's (Z-order) ordering. Morton's code (Z-order) is a scheme to map multi-dimensional arrays onto to a linear with a great deal of spatial locality.

References

[1] A Computer Oriented Geodetic Data Base and a New Technique in File Sequencing, Morton G.M., technical report, IBM, 1966. [2] On Spatial Orders and Location Codes, Stocco, LJ and Schrack, G, IEEE Transaction on Computers, vol 58, n 3, March 2009. [3] Out-of-Core Construction of Sparse Voxel Octrees, J. Baert, A. Lagae and Ph. Dutré, Proceedings of the Fifth ACM SIGGRAPH/Eurographics conference on High-Performance Graphics, 2013.

Source: src/lib/mortif.f90

Dependencies

Contents

Variables

NameTypeAttributesDescription
mask32_32integer(kind=I8P)parameter0000000000000000000000000000000011111111111111111111111111111111.
mask16_48integer(kind=I8P)parameter0000000000000000000000000000000000000000000000001111111111111111.
mask16_32integer(kind=I8P)parameter1111111111111111000000000000000000000000000000001111111111111111.
mask16_16integer(kind=I8P)parameter0000000000000000111111111111111100000000000000001111111111111111.
mask8_56integer(kind=I8P)parameter0000000000000000000000000000000000000000000000000000000011111111.
mask8_16integer(kind=I8P)parameter0000000011111111000000000000000011111111000000000000000011111111.
mask8_8integer(kind=I8P)parameter0000000011111111000000001111111100000000111111110000000011111111.
mask4_60integer(kind=I8P)parameter0000000000000000000000000000000000000000000000000000000000001111.
mask4_8integer(kind=I8P)parameter1111000000001111000000001111000000001111000000001111000000001111.
mask4_4integer(kind=I8P)parameter0000111100001111000011110000111100001111000011110000111100001111.
mask2_62integer(kind=I8P)parameter0000000000000000000000000000000000000000000000000000000000000011.
mask2_4integer(kind=I8P)parameter0011000011000011000011000011000011000011000011000011000011000011.
mask2_2integer(kind=I8P)parameter0011001100110011001100110011001100110011001100110011001100110011.
mask1_2integer(kind=I8P)parameter1001001001001001001001001001001001001001001001001001001001001001.
mask1_1integer(kind=I8P)parameter0101010101010101010101010101010101010101010101010101010101010101.
signifinteger(kind=I8P)parameterBinary mask for selecting significant bits.
maskinteger(kind=I8P)parameterBinary mask for perfoming significant bits shifting.
shftinteger(kind=I1P)parameterShift number array.
log10_2_invreal(kind=R4P)parameterReal parameter for computing the number of shifts (Ns).

Subroutines

contract

Contract integer of 64 bits into integer of 32 bits.

See On Spatial Orders and Location Codes, Stocco, LJ and Schrack, G, IEEE Transaction on Computers, vol 58, n 3, March 2009. The resulting integer(int8/int16/int32) has only b' significant bits obtained by the following contraction: if bb/zx0/bb-1/zx0../b1/zx0/b0 => bb/bb-1/.../b1/b0; e.g. for (b=4,z=1): b3/0/b2/0/b1/0/b0 => b3/b2/b1/b0`.

Attributes: elemental

fortran
subroutine contract(i, b, z, c)

Arguments

NameTypeIntentAttributesDescription
iinteger(kind=I8P)inInput integer.
binteger(kind=I2P)inNumber of significant bits of 'i' (2/4/8/16/32).
zinteger(kind=I1P)inNumber of zero 'i' (1/2).
cinteger(kind=I4P)outContracted integer.

Call graph

demorton2D

Decode 1 integer (64 bits) Morton's code into 2 integer (32 bits) indexes.

Attributes: elemental

fortran
subroutine demorton2D(code, i, j, b)

Arguments

NameTypeIntentAttributesDescription
codeinteger(kind=I8P)inMorton's code.
iinteger(kind=I4P)inoutI index.
jinteger(kind=I4P)inoutJ index.
binteger(kind=I2P)inoptionalNumber of significant bits of 'i' (2/4/8/16/32).

Call graph

demorton3D

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.

Attributes: elemental

fortran
subroutine demorton3D(code, i, j, k, b)

Arguments

NameTypeIntentAttributesDescription
codeinteger(kind=I8P)inMorton's code.
iinteger(kind=I4P)inoutI index.
jinteger(kind=I4P)inoutJ index.
kinteger(kind=I4P)inoutK index.
binteger(kind=I2P)inoptionalNumber of significant bits of 'i' (2/4/8/16).

Call graph

Functions

dilatate

Dilatate integer of 32 bits to integer of 64 bits.

See On Spatial Orders and Location Codes, Stocco, LJ and Schrack, G, IEEE Transaction on Computers, vol 58, n 3, March 2009. The resulting integer has 64 bits; it has only b significant bits interleaved by z zeros: bb/zx0/bb-1/zx0../b1/zx0/b0; e.g. for (b=4, z=1): b3/b2/b1/b0 => b3/0/b2/0/b1/0/b0.

Attributes: elemental

Returns: integer(kind=I8P)

fortran
function dilatate(i, b, z) result(d)

Arguments

NameTypeIntentAttributesDescription
iinteger(kind=I4P)inInput integer.
binteger(kind=I2P)inNumber of significant bits of 'i' (2/4/8/16/32).
zinteger(kind=I1P)inNumber of zero 'i' (1/2).

Call graph

morton2D

Encode 2 integer (32 bits) indexes into 1 integer (64 bits) Morton's code.

Attributes: elemental

Returns: integer(kind=I8P)

fortran
function morton2D(i, j, b) result(code)

Arguments

NameTypeIntentAttributesDescription
iinteger(kind=I4P)inI index.
jinteger(kind=I4P)inJ index.
binteger(kind=I2P)inoptionalNumber of significant bits of 'i' (2/4/8/16/32).

Call graph

morton3D

Encode 3 integer (32 bits) indexes into 1 integer (64 bits) Morton's code.

@note Due to 64 bits limit of the Morton's code, the 3 allowed-side of indexes is limited to 21 bits.

Attributes: elemental

Returns: integer(kind=I8P)

fortran
function morton3D(i, j, k, b) result(code)

Arguments

NameTypeIntentAttributesDescription
iinteger(kind=I4P)inI index.
jinteger(kind=I4P)inJ index.
kinteger(kind=I4P)inK index.
binteger(kind=I2P)inoptionalNumber of significant bits of 'i' (2/4/8/16/32).

Call graph