Skip to content

MORTIFMorton Indexer (Z-order)

A pure Fortran 2003+ library to encode and decode multidimensional integer indexes into Morton's Z-order.

Quick start โ€‹

Encode a 3D index tuple and decode it back:

fortran
use, intrinsic :: iso_fortran_env, only : int32, int64
use mortif

integer(int32) :: i, j, k
integer(int64) :: code

! Encode
code = morton3D(i=1_int32, j=2_int32, k=3_int32)
print '(A,I20)', "Morton code of {1,2,3}: ", code

! Decode
call demorton3D(code=code, i=i, j=j, k=k)
print '(A,3(I0,1X))', "Decoded indexes: ", i, j, k
fortran
use, intrinsic :: iso_fortran_env, only : int32, int64
use mortif

integer(int64) :: code

! 2D example
code = morton2D(i=0_int32, j=1_int32)
print '(A,I20)', "Morton code of {0,1}: ", code   ! 2

Authors โ€‹

Contributions are welcome โ€” see the Contributing page.

Copyrights โ€‹

MORTIF is distributed under a multi-licensing system:

Use caseLicense
FOSS projectsGPL v3
Closed source / commercialBSD 2-Clause
Closed source / commercialBSD 3-Clause
Closed source / commercialMIT

Anyone interested in using, developing, or contributing to MORTIF is welcome โ€” pick the license that best fits your needs.