5 Debugging OOMMF

5.3 Bypassing the oommf.tcl bootstrap

When an application is launched by clicking a button in mmLaunch or from the command shell like

> tclsh oommf.tcl mmdisp
the application (here mmDisp) is not executed directly but rather through the “bootstrap” program oommf.tcl. The bootstrap constructs a list linking application names to commands using the appindex.tcl files in the various application (oommf/app/) directories, and then runs the command associated with the given name. This is convenient for normal use, but the additional execution layer can obfuscate the debugging process. You can obtain the direct command from the bootstrap program itself with the +command option
> tclsh oommf.tcl mmdisp +command
app/mmdisp/windows-x86_64/mmdispsh.exe app/mmdisp/scripts/mmdisp.tcl &
The response is the command as used inside a Tcl shell to launch the application. You may need to make minor edits to run the application at your shell command prompt. For example, the trailing ampersand runs the program in the background, which is not what one usually wants when debugging, so you would omit this. On Windows you may want to change the forward slash path separators to backslashes. Another Windows-specific modification involves the first component of this command, app/mmdisp/windows-x86_64/mmdispsh.exe. This is an executable containing an embedded Tcl interpreter that processes the Tcl script specified as the second command component. If you examine the app/mmdisp/windows-x86_64/ directory you’ll find two executables, mmdispsh.exe and condispsh.exe. On Unix and macOS these two programs are the same, but on Windows the first is linked as a native Windows application and the second as a console application. The importance of this is that only the second provides the usual C++ standard channels stdin, stdout, and stderr. In case of abnormal operation programs will sometimes write error messages to stdout or stderr, which will be lost if the program is not running as a console application. The upshot is that for debugging purposes you would probably want to run mmDisp (for example) from a Windows command console as
> app\mmdisp\windows-x86_64\condispsh.exe app/mmdisp/scripts/mmdisp.tcl

It is worth noting that on the bootstrap command line, arguments starting with ‘+’ (for example, “+command”) are options to oommf.tcl itself. Run “tclsh oommf.tcl +h” to see the bootstrap help message. Options to the OOMMF application follow the application name and start with ‘-’. For example, to see the help message for a particular application, run “tclsh oommf.tcl <appName> -h”.