$totallayer required setting tag the layer number of the device. This layer number needs to be set in the beginning of input file. Most parameters setting has the same layer number as this. Except the doping setting and the background setting.
Example
$totallayer
5