Return to MTsort guide base window
The sort setup window presents a graphical interface to organise and hopefully simplify the task of creating a sort program.

To setup a sort you need to create a sort language description file. This is a text file that satisfies the syntax described in the Sort Language Manual ("Return to MTsort guide base window" and select "Language Manual"). These text files are normally kept in the directory ~/sortfiles.


Compile sortfile

The button labelled Compile sortfile causes the chosen sortfile to be processed into the many files needed to run the sort. These files are normally stored in the directory ~/sortdirs/.

The listbox to the upper right of the window can be toggled between listing sortfiles and sort directories.

The results of a compilation are presented in two places. The sort compiler processes the sortfile and generates C code. If there are any problems with the sort file syntax, warning and error messages appear in the text window occupying the lower half of the setup window.

If the sort compiler finds no errors, then the resulting C source is compiled. If there are any compilation errors produced by this stage, then they may be seen by clicking on the View compiler messages button.

If the sort compilation is successful, you will see a message saying so in the lower text window,
and the Setup status: message will say OK.

The Setup Status will also indicate if the sortfile has been compiled for a different machine architecture, or a previous non-compatible version of the sort compiler. In either of these cases, a compile will correct the bad status.

With the correct sortfile shown in the Sortfile: box, and a Setup status: saying OK , the sort can be executed by clicking on the run sort program button.

Note: The spectrum space required by the sort will be displayed in the SORT MESSAGES window. If this value is larger than the amount of memory in your workstation, problems may occur.


Shared memory spectra

Spectra are created in shared memory segments in the local workstation using a daemon called shmsas, which should be run as root. This feature makes the spectra viewable during the program execution.
The setup window shows the status of the shmsas daemon and provides the Run SHMSAS button to activate it if necessary.

Also, on clicking the Run sort program button, a test is made to see if the shmsas task is running, and if not, tries to run it automatically.


Defer map creation

By default, maps and arrays are created at setup time in the sort directory.
Setting this option defers map and array creation to run-time, and places them in the maps sub-directory of the spectrum directory.
This feature may be useful if large maps cause problems with lack of free disc space in the sort directory.


Optional User Library

User written routines can be included in a sort program. These must be specified by name in the EXEC (or USER) commands in the sort description file, and should be in the form of a C routine of the same name. The source .c file or compiled object file (.o) or library (.a) file full path name must be entered into the optional user library field of the setup window.
There may be more than one such file specified.

On Linux, for example, the relevant commands might be ..

gcc -c user.o user.c
ar rcvs libuser.a user.o

Users must make sure that the included file does not include routine or variable names that would conflict with ones in the sort.
i.e. there should be no visible routine or variable name other than the routine name(s) of the user supplied routine(s).
The included file may contain several user functions, but all other routines and variables should be defined as static.

The path name(s) entered in the setup window is kept with the sort directory, and should not need to be entered again if re-compiled.


User Routine example

int myuser(short *sortword1, short *sortword2)
{
/* do something */
*sortword2 = *sortword1;

return(0);
}

By this means, parameters can be passed to, and returned from the user routine.
Note: A non-zero return code will cause processing of the current event to end, and processing will continue with the next event.


Maintained by Janet Sampson and John Cresswell (University of Liverpool)
Email to support@ns.ph.liv.ac.uk