# tem_FirstIdAtLevel Function

## public elemental function tem_FirstIdAtLevel(level) result(res)

This function delivers the refinement level of a TreeID

The refinement level of a \ref treelmesh_module::treelmesh_type::treeid "treeID" is found by repeatedly computing the parents with the equation used in the [tem_ParentOf function] (@ref tem_parentatlevel) and counting the iterations, until the universal root is reached.

First TreeID in the complete tree on a given level

e.g. level 1: 1 .. 8 -> offset = 1 level 2: 9 .. 72 -> offset = 9 level 3: 73 .. -> offset = 73

A level offset is calculated by summing all the nodes of coarser levels. With a level count starting at \f$0\f$ on the coarsest level (the universal root node), this offset \f$s\f$ for a given level \f$L\f$ can be computed by the follwing equation: \f[ s = \sum\limits_{i=0}^{L-1} 8^i = \frac{8^{L} - 1}{7} \f]

### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: level

level to check

### Return Value integer(kind=long_k)

resulting first treeID

None