More explicit error message when using the derivative of an external function in the model block.

Closes #678