Support Knowledge Base

Solution Number: 1006
Title: Calling external programs from COMSOL Script
Platform: All Platforms
Applies to: All Products
Versions: 3.3, 3.4
Created: January 18, 2007
Last Modified: August 15, 2008
Categories: Import, Product Information
Keywords: external program API link exe

Problem Description

I have an external program I need to call from COMSOL Script, is this possible?

Solution

It is easy to call executable programs from COMSOL Script with the DOS or SYSTEM command. What command to use depends on the operating system, DOS for Windows and SYSTEM for other operating systems.

The syntax is

[STATUS OUTPUT] = DOS(CMD)

where STATUS is an exit code and OUTPUT to the standard output and error streams. The DOS command can deliver limited input parameters to the external program. This is then done through the call, for example

[STATUS OUTPUT] = DOS('myprog 1 3 5 17')

For communication from the external program to COMSOL Script, the OUTPUT parameter can be used.

Another way to send input or output data to the external program is writing data to temporary files. The files can then be read by the external program or COMSOL Script. This can be suited for when the amount of data makes using the OUTPUT parameter difficult.

COMSOL Script can also be connected to external libraries written in other languages through the external API. For more information, see Knowledge base 1005.

Feedback

Poor | Excellent
Document quality?




« Back to Support Knowledge Base

Disclaimer

COMSOL makes every reasonable effort to verify the information you view on this page. Resources and documents are provided for your information only, and COMSOL makes no explicit or implied claims to their validity. COMSOL does not assume any legal liability for the accuracy of the data disclosed. Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark details.

COMSOL RSS
© 1997-2008 COMSOL AB.
COMSOL, COMSOL Multiphysics, COMSOL Reaction Engineering Lab, COMSOL Script and
FEMLAB are registered trademarks of COMSOL AB. Other product or brand names are
trademarks or registered trademarks of their respective holders. All Rights Reserved.