merged Vadim's support for coupling with DSM, cleaned and improved by Clément Durochat