(a) Upon the death of a retired member, 50 percent of the retirement pension, if not modified in accordance with the optional survivor allowance in subdivision (b), shall be continued during and throughout the life of his or her surviving spouse, if he or she was married to the member at least one year prior to the date of retirement. If there is no surviving spouse entitled to this allowance, or if he or she dies before every child of the deceased retired member, including stepchild or adopted child, attains the age of 18 years, then the allowance which the surviving spouse would have received had he or she lived, shall be paid to the deceased retired member's child or children under the age of 18 years. If the survivor allowance is to be paid to surviving children, the allowance shall be divided among the children in equal amounts. However, the right of any child to share in the allowance shall cease upon his or her death, marriage, or upon attaining the age of 18 years. Notwithstanding any other provisions of this subdivision, the allowance otherwise payable to the children of the retired member shall be paid to the children through the age of 21, if the children remain unmarried and are regularly enrolled as full-time students in any accredited school as determined by the board.