Silverfrost Forums

Welcome to our forums

Matlab engine form a Fortran program

10 Aug 2009 11:09 #4891

Hi FTN95 Users,

I am trying to use the Matlab enige from a Fortran program. According to the supplied example in the Matlab-Help I need to include <fintrf.h>. This file has the following content (only part of it):

#if defined(WITH_COMMENTS)
/*
 * fintrf.h	- MATLAB/FORTRAN interface header file. This file
 *		  contains the declaration of the pointer type needed
 *		  by the MATLAB/FORTRAN interface.
 *
 * Copyright 1984-2006 The MathWorks, Inc.
 * All Rights Reserved.
 */
#endif
#if defined(__x86_64__) || defined(_M_AMD64) || defined(__amd64) || \    defined(__sparcv9)  || defined(__ppc64__)
# define mwpointer integer*8
# define mwPointer integer*8
# define MWPOINTER INTEGER*8
#else
# define mwpointer integer*4
# define mwPointer integer*4
# define MWPOINTER INTEGER*4
#endif
...

FTN95 is (unfortunatley) not supported by Matlab and the # might not be allowed. What is the neccesary changes which I need to make to be able to complie this include?

Johannes

10 Aug 2009 5:39 #4892

Hi everyone,

this seems to be a known problem. I found the same comments in the Mathworks forum:

[u:7b2c3e93d0]http://www.mathworks.com/matlabcentral/newsreader/view_thread/135815[/u:7b2c3e93d0] [u:7b2c3e93d0]http://www.mathworks.in/matlabcentral/newsreader/view_thread/164128[/u:7b2c3e93d0]

It seems like with each new version of Matlab the 'logic' changes a bit. I would be glad if someone in the Silverfrost Forum could answer the following:

does the linker/compiler have a switch like -cpp to compile Fortran and C; does anyone have some working example of calling the Matlab engine with FTN95?

Any advice in this context will be most welcome!

Johannes

11 Aug 2009 7:12 #4893

Fortran code can be compiled with FTN95. C/C++ code can be compiled with SCC. SLINK can be used to link object files produced by either FTN95 or SCC or SRC (i.e. you could have a mixture of files in one linking process).

The only examples I know about are in the download that is given in the KBase article on Matlab in this forum.

11 Aug 2009 7:25 #4894

Hi Paul,

thanks. The example in the KBase forum explains how to use a Fortran program as a m-file in the Matlab environment.

In the present topic the aim is to use Matlab functions from a Fortran program, i.e. the other way arround. I have worked through the example provided in the Matlab documentation without success.

Even though I assume that the solution must be quit simple, the Mathworks hotline only argue that FTN95 is not supported.

Anyway, thanks for your reply.

Johannes

Please login to reply.