When you say co-simulation between MATLAB and Dymola, you mean MATLAB and not Simulink right? (Because S-functions are a Simulink feature only).
You haven't specified the kind of external interface that Dymola provides. MATLAB provides several kinds of external interfaces. You may want to choose from among them, depending on which one Dymola can also interface with.