Calling Matlab from G95 code

  • Follow


Calling Matlab from G95 code
 Matlab lets third party programs call its routines through Matlab
External Interface.
 I try to use Matlab engine in a G95 (Fortran 95 compiler) code. I use
G95-MinGW32 under windows XP SP2.
  To call Matlab engine from a G95 code, the basic three Matlab dlls
(libeng.dll, libmx.dll, libut.dll) should be linked to the G95 code. It
seems there is a problem with decoration and case sensitivity. Matlab
routines reside in dll have a special char cases like "engOpen" or
"engClose". This while G95 can be instructed only to generate the codes
with lowercase or uppercase. Linking a G95 code with Matlab dlls
generates the following error:

  feng.f90:(.text+0x18): undefined reference to 'engopen'

  To clear the subject I introduce here a step by step example:

  1. Fortran program to Call Matlab
     --------------------------------
     program feng
		integer engOpen
      	integer ep

      	ep = engOpen('matlab ')
		if (ep .eq. 0) then
         	write(6,*) 'Can''t start MATLAB engine'
         	stop
      	else
       		write(6,*) 'MATLAB engine started'
      	endif
      end program main

	2. All matlab dlls are in the Path, now we compile the above code
under Windows XP using G95 - MinGW compiler as follows:
	   ------------------------------------------

	   g95 -c  -mrtd -fno-underscoring  feng.f90 -o feng.o
	   g95 -o %1.exe -shared -L. libeng.dll %1.o

   ::::OUTPUTS
       feng.f90:(.text+0x18): undefined reference to 'engopen'


   How we can resolve this problem. Your kind help is appreciated


   Aria


 P.s:
 - I know about GNUmex and some other methods, but they are very
complicated.
 - I generated a lib interface as "lib /def:libeng.def" using the
Matlab provided "def" files but the problem was not resolved.

0
Reply mohammad.rahmani (13) 1/12/2006 12:53:39 PM

"Mohammad" <mohammad.rahmani@gmail.com> writes:

> Calling Matlab from G95 code

there is something about this on the following page that may help;

http://g95.sourceforge.net/howto.html#matlabwin

Helge
0
Reply avle1 (27) 1/12/2006 1:11:25 PM


Thanks Helge.
There are two method on that page.
ne of them needs GNUmex to do that. The other method proposed by Aaron
Schmidt seems promising but I failed to implement it on a windows
machine. 

Any comment?

Mohammad

0
Reply mohammad.rahmani (13) 1/13/2006 8:59:29 PM

2 Replies
67 Views

(page loaded in 0.073 seconds)


Reply: