Habitat variation, species diversity and ecological functioning in a marine system