Fermi energy

I would like to ask how CASTEP calculates fermi energy, written in .CASTEP output file?

Thank you very much in advance.