Major rewrite to make the code more suitable for inclusion in models.

- Most functions/subroutines are now elemental (enabling calls with
  either scalars, vectors or arrays);

- constants/fixed coefficients are now defined in modules;

- implemented a prototype error handling system;