public pure function tem_IdOfCoord(coord, offset) result(nTreeID)

This function calculates the tree ID for a given x,y and z on the given
refinement level. This ID in the complete tree does not have to be in the
list of leafs (treeIDlist)
An example of this procedure is following:
1. Convert coordinates into binary representation:
(x,y,z) = (5,9,1) = (0101,1001,0001)
2. Interleaving the bits by 3 digits for each direction:
x(0101): 0 1 0 1
y(1001): 1001
z(0001): 0 0 0 1
Combining these bits results in a binary number: 010 001 000 111,
which is 1095 when seen as a 10-base number.
3. This number is the cell position in a single level sorted element list.
Its treeID can be obtained by adding the correspoding level offset.

Periodic displacement for requested elements outside the cube

Nodes of different colours represent the following:

Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.