$RCWAtotallayer required setting tag the layer number of the device. This layer number needs to be set in the beginning of input file. It is different from $totallayer.
Example
$RCWAtotallayer 8