- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear All,
I am trying to run fortran codethat contains some of the eng * commands(e.g. engOpen, engClose)to open the Matlab engine but it just does not seem to work. I am not sure how to set the environment to call the Matlab functionsand would appreciate any assistance that can be offered. I am running the Intel Fortran compiler from the Microsoft Visual Studio 2003.net environment.
Many thanks,
Tony
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tony,
I've had problems starting the Matlab engine directly from Fortran, so I had to write a C wrapper to do the job. I'm using CVF 6.6 with Matlab 6.5.1. I've attached some code that may be of some help to you. Make sure you link with the following Matlab libraries: libeng.lib, libmat.lib, and libmx.lib.
Hope this helps,
Mike
I've had problems starting the Matlab engine directly from Fortran, so I had to write a C wrapper to do the job. I'm using CVF 6.6 with Matlab 6.5.1. I've attached some code that may be of some help to you. Make sure you link with the following Matlab libraries: libeng.lib, libmat.lib, and libmx.lib.
Hope this helps,
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Tony!
Heres the way that I do it (without any C code). This is also in CVF 6.6, Im afraid but...
I write my Fortran code and compile it (not link) declaring the MATLAB engOpen, engClose e.t.c. as INTEGER, EXTERNAL.
Then I open MATLAB and cd myself (not necessary, but practical) to where my object code is, in this case h:TM253A (see below).
I then issue a link command in MATLAB. It executes link.m, which can look like this
mex -f h:TM253Adf60engmatopts.bat TM253A.obj ...
c:mat_dvfsmat_dvfs.lib ...
c:mat_matlabsmat_matlab.lib ...
h:f90libf2kclif2kcli.lib
! Editbin TM253A.EXE /Stack:500000000
In this case, for example, TM253A.obj and mat_matlab.lib both contain (pure Fortran) MATLAB stuff.
I am not sure that I need the df60engmatopts.bat file anymore but its a good place to put your linker options, see line:
LINKFLAGS=/LIBPATH:"%LIBLOC%" libmx.lib libmat.lib libeng.lib /nodefaultlib:"libc.lib"
for example, where the linker ignores libc.lib.
I attach the df60engmatopts.bat file.
Lars
Heres the way that I do it (without any C code). This is also in CVF 6.6, Im afraid but...
I write my Fortran code and compile it (not link) declaring the MATLAB engOpen, engClose e.t.c. as INTEGER, EXTERNAL.
Then I open MATLAB and cd myself (not necessary, but practical) to where my object code is, in this case h:TM253A (see below).
I then issue a link command in MATLAB. It executes link.m, which can look like this
mex -f h:TM253Adf60engmatopts.bat TM253A.obj ...
c:mat_dvfsmat_dvfs.lib ...
c:mat_matlabsmat_matlab.lib ...
h:f90libf2kclif2kcli.lib
! Editbin TM253A.EXE /Stack:500000000
In this case, for example, TM253A.obj and mat_matlab.lib both contain (pure Fortran) MATLAB stuff.
I am not sure that I need the df60engmatopts.bat file anymore but its a good place to put your linker options, see line:
LINKFLAGS=/LIBPATH:"%LIBLOC%" libmx.lib libmat.lib libeng.lib /nodefaultlib:"libc.lib"
for example, where the linker ignores libc.lib.
I attach the df60engmatopts.bat file.
Lars
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Trying to attach it as a ZIP file to see if it works.
Lars
Lars
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've attached an IVF 8 .vfproj (.txt) that runs fengdemo.f from MATLAB R12.
Ciao,
Gerry T.
Ciao,
Gerry T.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page