KHACE Logo
Home

  contents search contact us

MEX-Function Engineering

FORTRAN Code Re-use

We have considerable experience, from our own product development and our work for clients, in packaging FORTRAN code for use with MATLAB® and Simulink®.

We can help you re-use or integrate your existing FORTRAN code by packaging it for calling from MATLAB as a mex-function.

Change-free packaging

It is generally possible to package existing FORTRAN code for use with MATLAB without altering in any way the existing code. We do this by integrating it, unchanged, into an interface program. This is our preferred approach, because of its obvious advantages:

  • It avoids completely the introduction of errors into a customer's original, proven, code.
  • It provides clear and definite separation of responsibility for software development and test between the application software (the customer's FORTRAN code) and the application interface (the mex-function interface engineering).
  • Complete confidentiality of original code content can be maintained where required, using a customer's pre-compiled modules for linking into the mex-function deliverables, or by interfacing to a customer's existing DLL.

Where it is not practical or desirable, e.g. for performance reasons, to maintain the complete form of the existing code, we can assist with its re-engineering for mex-function use.

Back to Top

Tried and Tested Interface Software and Methods

There is more to building a FORTRAN mex-function than just passing data back and forth between MATLAB and the FORTRAN code.

  • Function arguments, both right-hand side calling and left-hand-side return, must be checked for validity, including number, type (text, numeric, scalar and array), dimension and numerical value.
  • Arrays must be orientated and re-orientated correctly between MATLAB and FORTRAN conventions.
  • Error messages must be generated appropriately.
  • The intricacies of the MATLAB Applications Program Interface (API) for FORTRAN must be learned and mastered.

Software modules and methods we have developed for our own products, already tried and tested, can be quickly adapted and applied - saving time and keeping down costs.

Back to Top

Engineered solutions

We don't use automated FORTRAN-to-mex-function code converters or translators. While taking care to preserve the integrity of the original FORTRAN code, we individually craft a mex-function interface tailored to end-user requirements. That means we can engineer into the interface any special requirements or enhancements that an automated approach cannot handle.

Back to Top

Supported Compilers

We use and support Compaq Visual FORTRAN as standard.

We may be able to support other compilers on request and at cost. Please enquire.

Back to Top

References:

  1. The Multiflash Interface for MATLAB is written by us in FORTRAN as a suite of mex-functions for interfacing with Infochem's Multiflash product DLL - also written in FORTRAN.
  2. A pipeline slug-flow dynamic simulation model, developed by a major international oil company in FORTRAN, was packaged for them by us as mex-function, and delivered integrated into a Simulink slug-flow simulation demonstrator.
  3. Emulations of Compressor Controls Corporation (CCC) Series-3 Plus compressor controls in FORTRAN were commissioned from us by Dynamation Ltd., for integration as DLLs into their Virtual Process based process operator training simulator for the North Sea Britannia Oil operator. The models were developed by us and extensively tested and demonstrated in Simulink simulation before delivery, by packaging and testing the deliverable FORTRAN modules as mex-functions.

Back to Top

To discuss your own requirements, please telephone or E-mail
 

Navigation 


Copyright 1999/2008. Kelvin Hales Associates Ltd.