Debugging a Macro Using an IDE
You can debug a Simcenter STAR-CCM+ macro using a special command-line option and an Integrated Development Environment (IDE) program.
There are several IDEs available for free download including the following:
- BlueJ: www.bluej.org
- Eclipse: www.eclipse.org
- JDeveloper: www.oracle.com/technetwork/developer-tools/jdev
- NetBeans: www.netbeans.org
The instructions below are for debugging a macro using NetBeans. It is necessary to use version 12.6 or later. Similar techniques can be used for other IDEs.
The process for debugging a macro involves the following steps:
- Loading the macro in the IDE
- Running Simcenter STAR-CCM+ in debugging mode
- Stepping through the macro
Loading the Macro in the IDE
NetBeans requires the macro to be in a directory structure <ProjectFolder>/<SourceFolder>/<Macro>.java, so you must organize the macro and any input files to be in the appropriate locations before starting.
- In NetBeans, select .
-
In the
New Project wizard, select
Java Project with Existing Sources and click
Next.
-
In the
Name and Location panel specify a name for your project in Project Name, provide the location of your project directory in Project Folder, and click
Next.
-
In the
Existing Sources panel, click the
Add Directory button for the
Source Package Folders, add the source directory that you created earlier and click
Next.
-
In the
Includes panel, ensure that the required macro is highlighted.
- Click Finish to create the project.
The next step is to add the Simcenter STAR-CCM+ JAR files to the project so that the IDE can interpret the Simcenter STAR-CCM+ Java classes. Add the JAR files that are held in the ext/ directory that is created as part of the installation of Simcenter STAR-CCM+.
-
In the
Projects panel in NetBeans, right-click
Libraries and select
Add JAR/Folder.
-
In the
Simcenter STAR-CCM+ installation directory, select every JAR file in the
ext/ directory.
On Linux and Windows, this directory is located in:
[INSTALLDIR]/star/lib/java/platform/modules/ext/
The error symbols disappear from the macro.
You are now ready to start Simcenter STAR-CCM+ in debugging mode.
Running Simcenter STAR-CCM+ in Debugging Mode
Simcenter STAR-CCM+ can pass messages directly to the Java Virtual Machine on which the client runs. You can use this function to attach NetBeans to the instance of Simcenter STAR-CCM+ through a specified port. In the examples below the port number 8765 is used but you can use any unused port number.
-
Do one of the following:
- On Windows, in a command prompt, enter the
following command on a single line:
<InstallationDirectory>\star\bin\starccm+ -jvmargs "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8765"
- On Linux, in a terminal window, enter the following command on a single line:
<InstallationDirectory>/star/bin/starccm+ -jvmargs '-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8765'
Simcenter STAR-CCM+ opens.
- On Windows, in a command prompt, enter the
following command on a single line:
Now attach the IDE to Simcenter STAR-CCM+ through the port:
-
In NetBeans, select Host to
localhost
, specify the port number from the command line above, and click OK. , set
You are now ready to run the macro in debugging mode.
The macro executes to the specified breakpoint. You can use the IDEs stepping tools to work through each command from this point.
Stepping Through the Macro
Connecting Simcenter STAR-CCM+ to an IDE lets you execute a macro up to any line and step through individual commands to understand each. Once the IDE is attached to Simcenter STAR-CCM+, you can create one or more breakpoints in the macro before running.
To step through the macro, do the following:
-
In NetBeans, place a breakpoint at the start of your macro by clicking the line number.
- In Simcenter STAR-CCM+, load or create a case as necessary.
- In Simcenter STAR-CCM+, run the macro.