[MMTK] Improving error handling when netCDF.DLL is missing

hinsen at cnrs-orleans.fr hinsen at cnrs-orleans.fr
Mon Jun 28 14:19:01 CEST 2004

On Jun 25, 2004, at 13:45, Peter wrote:

> It would appear that importing MMTK.Dynamics is doing something 
> without checking if NetCDF is None.  I would suggest changing 
> Trajectory.py as follows:

Yes, because it calls trajectory handling routines at the C level.

> # Report error if the netCDF module is not available.
> try:
>     from Scientific.IO import NetCDF
> except ImportError:
>     NetCDF = None
>     #Expect this to happen (on Windows) when NETCDF.DLL is missing:
>     #ImportError: DLL load failed: The specified module could not be
>     #found.
>     raise Utility.MMTKError, \
>     "Trajectories are not available because the \
>     netCDF module is missing."

That is probably the best solution today. Originally, I planned to have 
as much functionality as possible available even without netCDF (hence 
the explicit checks), but that turned out to be unmaintainable (I'd 
have to keep a machine without netCDF around just for testing), so now 
MMTK requires netCDF.

> I don't know how common this error is (misplacing the NETCDF.DLL), but 
> if using the precompiled installers on Windows, then installing netCDF 
> is the most complicated step.

Right, the installation is manual. I am surprised that no one in the 
netCDF community came up with a better solution. Perhaps they should 
convert netCDF into a Python module ;-)

Konrad Hinsen
Laboratoire Léon Brillouin, CEA Saclay,
91191 Gif-sur-Yvette Cedex, France
Tel.: +33-1 69 08 79 25
Fax: +33-1 69 08 82 61
E-Mail: hinsen at llb.saclay.cea.fr

More information about the mmtk mailing list