NeXtMidas may be used as an X-Midas option tree. This enables an X-Midas macro to call NeXtMidas primitives.
Install libXt-devel
(RHEL/CentOS) or appropriate package that provides required development headers for X11/Intrinsic.h.
In order to build NeXtMidas as an X-Midas option tree you will need to use three compilers:
Fortran Compilers | C Compilers | |||||||||
Promula | Intel (ifort) | PGF | GCC | Intel (icc) | ||||||
6.5 | 9.1 | 10.1 | 5.2 | 6.0 | 8.0 | 3.2.X | 3.4.X | 4.1.X | 10.1 | |
X-Midas 4.8.X | Yes(1) | Yes | Yes | Yes(1) | Yes(1) | Yes | Yes | Yes | Yes | Yes |
X-Midas 4.6.X | Yes(1) | Yes | Yes | Yes(1) | Yes(1) | Yes | Yes | Yes | Yes | Yes |
The below X-Midas version are no longer supported. | ||||||||||
X-Midas 4.4.X | Yes(1) | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
X-Midas 4.2.X | Yes | No | No | Yes(1) | Yes(1) | No | Yes | Yes(1) | No | No |
X-Midas 3.8.3 | Yes | No | No | No | No | No | Yes | No | No | No |
X-Midas 3.7.1 | No | No | No | No | No | No | No | No | No | No |
X-Midas 3.6.5 | No | No | No | No | No | No | No | No | No | No |
All versions require Java 7 or later | ||||||||||
(1) User tested. |
As of this writing, NeXtMidas primitives run from the X-Midas shell can:
Limitations: |
|
---|
Limitations: |
|
---|
Limitations: |
|
---|
Limitations: |
|
---|
Limitations: |
|
---|
(nm/on/bg/id=999)
.![]() xmpipe: (e.g. use xmpipe:_mypipe to read the X-Midas pipe
named _mypipe ).
|
Building NeXtMidas as an X-Midas option tree is simple:
NMROOT
, the root install directory of NeXtMidas. On Unix for
example,
$ setenv NMROOT /home/smith/nxm210
X-Midas> xmopt nxm $NMROOT/nxm/sys
X-Midas> xmp +nxm
X-Midas> xmbopt ucl
X-Midas> xmbopt nxm
X-Midas> home $NMROOT/nxm/sys/test
X-Midas> mtrans %confidence
X-Midas> %confidence
XMBOPT NXM
command to build the NXM option tree. Other
build commands will not properly build and link the JNI libraries required.
An example macro is:
X-Midas> sd360/nmplot 1e9Look for additional examples in
$NMROOT/nxm/sys/mcr/
or on the
Using NeXtMidas as an X-Midas Option Tree
Demos page.
The NM
command is used to start a Java Virtual Machine (JVM) in which all
subsequent NeXtMidas commands are launched. The steps for running a NeXtMidas command are:
X-Midas> nm/on/bg/id=999Note: The /ID=[n] switch is optional but is required for subsequent commands to send and receive messages. The value of the ID is not important.
X-Midas> nm plot nxm.sys.dat.world|nxm.sys.dat.coneflags5000
X-Midas> nm plot nxm.sys.dat.Sunset.jpg
X-Midas> nm plot nxm.sys.dat.alaska view=xyz
X-Midas> nm/off
Inside an X-Midas macro this would look like:
startmacro ... nm/on/bg/id=999 ! Start the JVM, permitting messages with /ID switch xpipe/setup on ... ! Run some NeXtMidas commands nm plot nxm.sys.dat.world ... xpipe off nm/off ! Stop the JVM ... endmacro
The global table XM
in NeXtMidas maps directly to the X-Midas
results table.
X-Midas X-Midas> res temp 123.0 NeXtMidas nM> res/global xm.temp D: XM.TEMP = 123.0
NeXtMidas can directly use X-Midas pipes. To prevent confusion all X-Midas
pipes are given an xmpipe:
prefix in NeXtMidas. For example:
startmacro nm/on/bg/id=999 ! Start the JVM, permitting messages with /ID switch xpipe/setup on waveform _mypipe sf 1e9 nm plot xmpipe:_mypipe xpipe off nm/off ! Stop the JVM endmacro
X-Midas messages are automatically mapped to NeXtMidas messages using the XBC message mapping tools (see XBC: Sending Messages to a Host Primitive for details). Many examples are included in the following files:
$NMROOT/nxm/sys/test/test_xmmessage.txt
- X-Midas Macro$NMROOT/nxm/sys/test/test_xmmessage.mm
- NeXtMidas Macro$NMROOT/nxm/sys/prim/testxmmsg.java
- NeXtMidas PrimitiveThe NeXtMidas AUX list is directly linked to the X-Midas AUX list. Any changes made in NeXtMidas show up in X-Midas and any changes made in X-Midas show up in NeXtMidas.
In addition NeXtMidas maps the familiar AUX names to their respective X-Midas counterparts:
NeXtMidas | X-Midas |
---|---|
HOME | Mc.home_path |
CWD | 0 |
HOMEPATH | 98 |
DAT | 99 |
RAM | * |
XMPIPE | * |
* X-Midas has no parallel to RAM or XMPIPE. These are special AUX entries that only NeXtMidas can see. Since they are required for the correct functioning of the pipe system, they will always be included on the READ AUX in NeXtMidas. |
Note that AUX entries 0, 98 and 99 have special handling in X-Midas. In particular, changes to AUX 0 made after NeXtMidas has been started (e.g. via a cd in the shell) will not be visible to NeXtMidas.
The design is loosely modelled after the X-Midas RSM
concept. That is to turn
on the JVM, run the Java commands, and then turn off the JVM. The NM
command
uses Inter Process Communication (IPC) to signal events between X-Midas and the shared JVM.
The NM;NXM
command has the following switches:
Global Switches /BG - Runs the command in the background with respect to the X-Midas shell. /PN=str - Sets the process name. /XS=n - Allows a graphical NeXtMidas primitive to LEARN window positions (see XPIPE). Standard Switches /ON - Turns the shared JVM on (must be used with /BG). /OFF - Turns the shared JVM off. /STATUS - Reports the status of the shared JVM. Debugging Switches /DEBUG - Turns on general debugging messages. /JDEBUG - Turns on debugging messages in the JNI code. Special-Purpose Switches /CP=str - Adds elements on the front of the classpath. /JARS=str - Adds JAR files to the end of the classpath. /VERBOSEJNI - Sets the "-verbose:jni" flag for the Java VM. /VERBOSEGC - Sets the "-verbose:gc" flag for the Java VM. /VERIFYALL - Sets the "-Xverify:all" flag for the Java VM. /XCHECKJNI - Sets the "-Xcheck:jni" flag for the Java VM. /JVMOPTIONS=s - Sets special Java VM flags.
Usually debugging Java applications it much easier than debugging those written in C, C++ or Fortran. This is because Java has a well-developed exception handling model that allows the application to detect and (frequently) recover from most errors.
When running as an X-Midas option tree NeXtMidas needs to go outside of the standard Java safety-net in order to interact with X-Midas. This makes is much easier for errors to occur that will result in core dumps or the application hanging. While every effort has been made to aviod this situation, developers are likely to see it from time to time. Below is the list of the things most-likely to cause problems:
open()
method.M$SYNC
.WARNING: JNI.C: Got back a
strange answer via IPC
message or an IPC error message saying it could
not create a message queue because it is out of memory.
To help identify where things are going wrong, add the /JDEBUG/DEBUG
switches
to the NM
command. This will turn on normal debugging (/DEBUG
)
plus debugging for the JNI code (/JDEBUG
). Most of the time this will help
determine the point where the problem first occurs.
What to do to recover from a problem depends on the type of problem. Here are some possible solutions to common problems:
X-Midas> NM/OFF
XPIPE
try using END MACRO
first.
If you are able to use END MACRO
, run NM/OFF
at
the X-Midas prompt (this will usually clean up everything). If not in an
XPIPE
or END MACRO
does not work, use CONTROL+C
to kill the current process. After a CONTROL+C
kill all processes
named nm.exe
and run:
$ $NMROOT/os/unix/ipcclean
XMEND
, kill all processes named
nm.exe
and run:
$ $NMROOT/os/unix/ipcclean
XMEND
, kill all processes named
nm.exe
and run:
$ $NMROOT/os/unix/ipccleanIf that doesn't work: Stop all X-Midas sessions with
XMEND
, kill all stale
X-Midas processes, close other applications you are using (i.e. any
started with your USER ID) using IPC and run:
$ $NMROOT/os/unix/ipcclean
NM/ON/BG/ID=999
ipcs -l
to
see your current OS limit for number of message queues. e.g.
$ ipcs -l ... ------ Messages: Limits -------- max queues system wide = 16 // kernel.msgmni max size of message (bytes) = 65536 // kernel.msgmnb default max size of queue (bytes) = 65536 // kernel.msgmaxEdit /etc/sysctl.conf (requires root/sudo access) and change/add the
kernel.msgmni
property, e.g.
# increase the number of message queues (from default of 16) kernel.msgmni = 1024Run the following to re-load the updated /etc/sysctl.conf (requires root/sudo access):
$ sysctl -p
/NMQ=
switch on your startmacro
line
or your message up
line in your macro. Since NeXtMidas 2.7.1, messages sent from NeXtMidas Primitives are automatically
translated and normally takes up 540 slots (4320 bytes) and forward to the interested X-Midas macro/command.startmacro/nmq=8k/ps=128k-- or on the
message up
line in your .txt macro:
message/nmq=8k up
These are the top ten tips to remember when running NeXtMidas commands from X-Midas.
xmpipe:
prefix to use an X-Midas pipe in NeXtMidas. Also
make sure that /NP=
is large enough to account for the
pipes created by NeXtMidas.ID=XM.<XmId>
and remember to include
ARGS=
and TYPE=
in the table for unconfigured
messages.nmstartup.mm
) are bypassed.NM/ON/BG/ID=999/PNAME=NXM_JVM
to name the shared JVM for NeXtOpt "NXM_JVM".NM/OFF
to shutdown NeXtMidas and the shared JVM.