Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matOpen: how to use mat.h in fortran ?

Subject: matOpen: how to use mat.h in fortran ?

From: Max

Date: 23 Sep, 2009 12:12:49

Message: 1 of 5

Hi,
I'm trying to include the C-file 'mat.h' into my Fortran code in order to generate mat-files with Fortran via the matOpen command. According to the Matlab-help this should be possible: http://www.mathworks.com/access/helpdesk_r13/help/techdoc/apiref/matopen_01.html#1081657
But when i try to include mat.h i get catastrophic errors from my compiler (Intel Fortran with Visual Studio 2008)...
Has anyone used mat.h with Fortran or has any experience in compiling C and Fortran mixed code?
Best regards,
Eli

Subject: matOpen: how to use mat.h in fortran ?

From: James Tursa

Date: 24 Sep, 2009 03:55:20

Message: 2 of 5

"Max " <el_eli@gmx.de> wrote in message <h9d3c0$46k$1@fred.mathworks.com>...
> Hi,
> I'm trying to include the C-file 'mat.h' into my Fortran code in order to generate mat-files with Fortran via the matOpen command. According to the Matlab-help this should be possible: http://www.mathworks.com/access/helpdesk_r13/help/techdoc/apiref/matopen_01.html#1081657
> But when i try to include mat.h i get catastrophic errors from my compiler (Intel Fortran with Visual Studio 2008)...
> Has anyone used mat.h with Fortran or has any experience in compiling C and Fortran mixed code?
> Best regards,
> Eli

Never include any C headers. Just do this:

#include "fintrf.h"

That has everything you need for mex or eng stuff in it for Fortran. I have no idea why TMW doesn't include this necessary piece of information in their Fortran API doc.

James Tursa

Subject: matOpen: how to use mat.h in fortran ?

From: Max

Date: 24 Sep, 2009 11:40:22

Message: 3 of 5

Hi, thank you for your quick response...unfortunately i get
warning #5117: Bad # preprocessor line
when i try to compile the file - somehow the compiler is not able to put the stuff together. Maybe it is about to give the compiler/linker/whatever some instructions how to handle the .c file...

Subject: matOpen: how to use mat.h in fortran ?

From: Max

Date: 24 Sep, 2009 13:37:01

Message: 4 of 5

Hi again,
thank you for your answers... using #include "fintrf.h" in Fortran instead of the mat.h plus a lot of changes in the Visual Studio compiler settings finally solved it :-)
Unfortunately the Matlab documentation is not very helpful in that topic.

Subject: matOpen: how to use mat.h in fortran ?

From: yigal.evron@gmail.com

Date: 2 Sep, 2013 06:59:16

Message: 5 of 5

Hello,
could you please explain what changes in Visual Studio's settings are needed?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us