Dynamic response of density-stratified fluid in a submarine rectangular trench