A dynamic boundary value problem arising in the ecology of mangroves