A small amount of SLD code is written in C, but only Prepmort contains an interface to the Jazelle data structures. So to work in SLD, you need to learn Prepmort. Even if you write your own code in C, you will need to learn Prepmort in order to read the majority of SLD's existing code.
Half of the concepts in Prepmort come from Fortran, the other half come from C. So if you have already picked up one of these languages, you have already solved half the puzzle.
This section of the Offline Users Workbook will start by introducing you to the basics of Prepmort and then will go on to discuss how some special code packages interface to Prepmort.
Those special code packages are:
The Prepmort pre-compiler allows SLD to add the Jazelle data structure and the Signal error handling system to Fortran. It also enabled SLD to provide its users with some program structure features that were not present in the Fortran standard when SLD began.
Half of the concepts used in Prepmort will be familiar to users who already know Fortran. The basic syntax of Prepmort is like Fortran. The other half of the concepts used in Prepmort will be familiar to users who already know C. The "pointer-driven" data structures are like C. Users who already know both Fortran and C will find there is very little left for them to learn.
The detailed section,
Writing Code: Prepmort, will teach you the structure of Prepmort by
showing you a simple example of a Prepmort file.
Study that section before going on.
Using Jazelle from Prepmort
You have already seen a simple example of using Jazelle from Prepmort.
Some pointers to a bank were declared using the construction:
POINTER F_MA_BEL --> MA_BEL; POINTER P_MA_BEL --> MA_BEL;
One of these pointers was set to the head of the family by the call:
$CALL JZBLOC( 'MA_BEL', F_MA_BEL ) ERROR RETURN;
A bank contained the pointer to the next bank as:
We set one pointer to this forwards pointer by:
P_MA_BEL = F_MA_BEL%(JB$FORPT);
And we accessed a value within a bank by the construction:
You should now read the detailed section,
Writing Code: Using Jazelle from Prepmort, for a more complete discussion.
The Signal System
When we showed you the
UCHKTAG PREPMORT example,
we mentioned that some parts of the code have to do with a sophisticated
message handling system.
These were the three lines that contained the dollar symbol:
$SLD_INTEGER_FUNCTION UCHKTAG ... $CALL JZBLOC( 'MA_BEL', F_MA_BEL ) ERROR RETURN; $RETURN;They work together to allow errors found in any one program to be reported back to IDA in a controlled way:
In addition to the above kinds of lines, the Signal System also includes
lines for issuing informational messages. These lines begin with the
$SIGNAL, for example:
$SIGNAL GDS$NOREL RELNAME; or $SIGNAL DSP$GENINFO 'Did not save relations since there are none.';These lines allow information to be presented in a more flexible way than normal Fortran
Now is a good time to learn more about the Signal System.
Read the detailed section,
Writing Code: The Signal System.
The Constants System
In the detailed section on
using Jazelle from Prepmort, you saw that initial values for some
Jazelle data elements can be inserted directly into the relevant Template file.
In other cases, Jazelle data element values may be read in from something
called the "Constants System."
This comes up when different values need to be inserted into different
instances of a repeat block, or when different values need to be used for
different Physics runs.
When you issue the IDA command PROCESSOR RECSLD, many of the
processors that are invoked in turn invoke the constants system.
If you try that now you will see that there are many messages written out
that begin with
These messages inform you that various sets of constants are being read in.
In some cases, the constants read in are "run-dependent." This means that a new set of constants may be read in for each Physics run. This is especially important for the event reconstruction processors. Many of them need to use different physical constants for different runs to compensate for changes in temperatures, pressures and so forth.
You will probably not use the constants system in the first few Prepmort
files you write, but you may need to understand how the system is
used in other SLD code.
Study a little about the constants system now in the detailed section,
Writing Code: the Constants System.
Making Histograms from Prepmort
Most of the time, you will create your histograms directly from IDA.
You learned how to do this in the Workbook section called
You used IDA commands such as
But in some cases you may want to call histogram routines directly from
To do so, you just make calls to a special library of Fortran routines.
Read about how to make these calls in the detailed section,
Writing Code: Making Histograms from Prepmort.
As we said at the start of this section, the official programming language
of the SLD Offline Software group is Prepmort.
A small amount of SLD code is written in C, but only Prepmort contains an
interface to the Jazelle data structures.
So to work in SLD, you need to learn Prepmort.
The main debate over what programming language SLD's Offline Software group should adopt took place a full ten years ago. The debate originally was between something called Mortran (which led to our Prepmort), Pascal, Ada and C.
Take a look at some of the earliest items in the SLD Software Conference to follow some of this debate that raged ten years ago (the earliest items are at the bottom of the list).
If we were rewriting the entire SLD Offline Software system today, most of the people authors would choose C (though there would probably be a big fight over C versus C++). Now, ten years later, so much code has now been accumulated in Prepmort that all SLD offline users need to learn Prepmort. It seems best then to keep most of the code in a single language.
If you absolutely insist, you can write your personal routines in C. The interface between Prepmort and C works fine. C routines can call Prepmort routines, and Prepmort routines can call C routines.
Indeed, one part of the official SLD software which we will talk about in a later section of this Workbook, the MIDAS Interactive Data Analysis Shell, is written mostly in C. If you want to look at examples of C for SLD, look at this code in DUCS sections PRODMIDAS and PRODSLDMIDAS.
We will mention how to compile C in the next section when we talk about how to compile Prepmort. Both are done in roughly the same way.
The next section of this Workbook will show you how to compile, link, run and debug the code you write for SLD. We will use the example code that you already saw in the section on Writing Code: Making Histograms from Prepmort.