Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to call external program within fortran code?

Status
Not open for further replies.

zahedi66

Mechanical
Apr 13, 2015
30
hello
I want to call matlab program within my fortran code. I have google about this but can't figure out how should I write the code. for example I just want to run matlab program. is the below code is true?
-------------------------------------
program Console9
implicit none

call SYSTEMQQ("C:\ProgramFiles\MATLAB\R2015b\bin\matlab.exe")

end program Console9
 
Replies continue below

Recommended for you

actually I've tried this but there is no sign of matlab and it is not running.
i don't know what is the problem.
 
Program files is two separate words. You may also need a second set of quotes. If this doesn't work
Code:
call SYSTEMQQ("C:\Program Files\MATLAB\R2015b\bin\matlab.exe")
try this
Code:
call SYSTEMQQ(['"C:\Program Files\MATLAB\R2015b\bin\matlab.exe"')
Check that matlab is actually in Program Files. On some systems, it is in Program Files (x86)
 
thx for your reply but It doesn't work.
this error is occurred, It is not syntax error. google says that it may because of compiler or OS. My compiler is ifort.exe and OS is win10/64bit.
--------------------------------------------------------
'Console2.exe': Loaded 'C:\Windows\SysWOW64\imagehlp.dll'
'Console2.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll'
The thread 'Win32 Thread' (0x13f8) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1080) has exited with code 0 (0x0).
The program '[4488] Console2.exe: Native' has exited with code 0 (0x0).
---------------------------------------------------------
 
Have a look at the sample program in
It looks like you call matlab through COM. I think matlab.exe is just a front end which launches something else.

In most cases, the fortran programs assume that Matlab is already started. They don't try to launch matlab first. Check the process memory if you are successful - make sure your Fortran program has not grown excessively large from starting matlab.
 
No doubt it would need some work, but for a long term solution wouldn't it make more sense to re-write your application based in Matlab, and call the Fortran code from Matlab?

Doug Jenkins
Interactive Design Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor